Packagingoutput.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944
  1. <template>
  2. <div>
  3. <!-- 左侧树形结构 -->
  4. <el-container>
  5. <!-- <el-aside width="250px">
  6. <div class="JKWTree-tree">
  7. <h3>包装工序产量维护</h3>
  8. <el-tree :data="treeData" :props="defaultProps" highlight-current="true"
  9. @node-click="handleNodeClick"></el-tree>
  10. </div>
  11. </el-aside> -->
  12. <layout-sider
  13. :resize-directions="['right']"
  14. :width="220"
  15. style="margin-right: 10px;"
  16. >
  17. <div
  18. class="JKWTree-tree"
  19. style="height: 70vh;"
  20. >
  21. <h3>包装工序产量维护</h3>
  22. <el-tree
  23. :data="treeData"
  24. highlight-current
  25. @node-click="handleNodeClick"
  26. />
  27. </div>
  28. </layout-sider>
  29. <el-container>
  30. <el-main>
  31. <!-- 按钮区域 -->
  32. <div class="gva-table-box">
  33. <el-form-item>
  34. <el-input v-model="positionvalue" placeholder="输入工单编号或产品名称" style="width: 180px;" />
  35. <el-button type="primary" class="search" icon="search" @click="onSearch"></el-button>
  36. <el-button type="primary" class="bt" icon="plus" @click="onAdd">新增</el-button>
  37. <el-button type="primary" class="bt" icon="search" @click="positioningVisible">定位</el-button>
  38. <el-button type="primary" class="bt" icon="refresh">重置</el-button>
  39. <el-button type="primary" class="bt" icon="delete" @click="Del">删除</el-button>
  40. <div style="margin-left: auto;">
  41. <el-button type="primary" :icon="Download" @click="exportExcel">导出到Excel</el-button>
  42. </div>
  43. </el-form-item>
  44. <!-- 数据展示 -->
  45. <el-table ref="multipleTable" style="width: 100%" tooltip-effect="dark" :data="tableData" row-key="ID"
  46. highlight-current-row="true" :cell-style="cellStyle" border @selection-change="handleSelectionChange"
  47. :show-overflow-tooltip="true" @row-click="Click" @row-dblclick="doubleClick">
  48. <el-table-column type="selection" width="55" />
  49. <!-- 循环渲染列 -->
  50. <el-table-column
  51. v-for=" column in tableColumns "
  52. :key="column.prop"
  53. :prop="column.prop"
  54. :label="column.label"
  55. :width="column.width"
  56. sortable
  57. show-overflow-tooltip="true"
  58. />
  59. </el-table>
  60. <!-- 分页 -->
  61. <div class="gva-pagination">
  62. <el-pagination layout="total, sizes, prev, pager, next, jumper" v-model:current-page="page"
  63. v-model:page-size="limit"
  64. :page-sizes="[10, 30, 50, 100]" :total="total" @current-change="handleCurrentChange"
  65. @size-change="handleSizeChange" />
  66. </div>
  67. </div>
  68. <!-- 弹出框 -->
  69. <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" :title="type === 'create' ? '添加' : '修改'"
  70. destroy-on-close width="1000px">
  71. <el-form :model="formData" label-position="right" ref="elFormRef" :rules="rule" label-width="70px" >
  72. <el-row :gutter="24">
  73. <el-col :span="6">
  74. <el-form-item label="日期" prop="name">
  75. <el-input type="date" max="9999-12-31" v-model="formData.sczl_rq" id="日期" @focus="rqHandleFocus()" @keydown="ent1($event)" style="width: 120px; " />
  76. </el-form-item>
  77. </el-col>
  78. </el-row>
  79. <el-row :gutter="24">
  80. <div style="width: 900px; margin-left: 40px;">
  81. <div style="margin-bottom: 5px;">
  82. <span style="display: inline-block; text-align: center; width: 95px; margin-right: 5px;" >工单编号</span>
  83. <span style="display: inline-block; text-align: center; width: 95px; margin-right: 5px;" >印件工序</span>
  84. <span style="display: inline-block; text-align: center; width: 95px; margin-right: 5px;" >工序名称</span>
  85. <span style="display: inline-block; text-align: center; width: 295px; margin-right: 5px;" >印件名称</span>
  86. <span style="display: inline-block; text-align: center; width: 95px; margin-right: 5px;" >包装产量</span>
  87. <span style="display: inline-block; text-align: center; width: 95px; margin-right: 5px;" >每箱数量</span>
  88. <span style="display: inline-block; text-align: center; width: 95px; margin-right: 5px;" >零头</span>
  89. </div>
  90. <div v-for="index in 6" :key="index">
  91. <el-input style="width: 95px; margin-right: 5px;margin-bottom: 5px;" v-model="formData['sczl_gdbh' + index]" :id="'sczl_gdbh' + index" @keydown="ent1($event, index.toString())" @blur="getGxMcsubmit($event, index.toString())" />
  92. <el-input style="width: 95px; margin-right: 5px;margin-bottom: 5px;" :readonly="true" :value="formData['sczl_yjGx' + index]" :id="'sczl_yjGx' + index" @keydown="ent1($event)"/>
  93. <el-input style="width: 95px; margin-right: 5px;margin-bottom: 5px;" :readonly="true" v-model="formData['sczl_gxmc' + index]" :id="'sczl_gxmc' + index" @keydown="ent1($event)"/>
  94. <el-input style="width: 295px; margin-right: 5px;margin-bottom: 5px;" :readonly="true" v-model="formData['Gd_cpmc' + index]" :id="'Gd_cpmc' + index" @keydown="ent1($event)"/>
  95. <el-input style="width: 95px; margin-right: 5px;margin-bottom: 5px;" v-model="formData['sczl_cl' + index]" :id="'sczl_cl' + index" @keydown="ent1($event)"/>
  96. <el-input style="width: 95px; margin-right: 5px;margin-bottom: 5px;" v-model="formData['sczl_PgCl' + index]" :id="'sczl_PgCl' + index" @keydown="ent1($event)"/>
  97. <el-input style="width: 95px;margin-bottom: 5px;" v-model="formData['sczl_clAdd' + index]" :id="'sczl_clAdd' + index" @keydown="ent1($event)"/>
  98. </div>
  99. </div>
  100. </el-row>
  101. </el-form>
  102. <!-- </el-scrollbar> -->
  103. <template #footer>
  104. <div class="dialog-footer">
  105. <el-button @click="closeDialog">取 消</el-button>
  106. <el-button type="primary" @click="enterDialog">确 定</el-button>
  107. </div>
  108. </template>
  109. </el-dialog>
  110. <el-dialog v-model="positioningVisibleshow" :before-close="closepositioningVisible" :title="type==='create'?'添加':'修改'" destroy-on-close>
  111. <el-card>
  112. <el-form-item label="工单编号" prop="name">
  113. <el-input v-model="positionvalue" :clearable="true" placeholder="ZT01733" />
  114. </el-form-item>
  115. </el-card>
  116. <el-button type="primary" @click="enterpositioning">确 定</el-button>
  117. </el-dialog>
  118. <el-dialog v-model="dialogSelectVisible" title="选择"
  119. destroy-on-close width="800px" >
  120. <el-table tooltip-effect="dark" :data="selectData" row-key="ID"
  121. highlight-current-row="true" border style="width:100%"
  122. @row-dblclick="handleSelectClick" >
  123. <el-table-column prop="Gd_cpmc" label="印件名称" width="450" />
  124. <el-table-column prop="jyGx" label="检验工序" width="85" />
  125. <el-table-column prop="Gy0_gxmc" label="工序名称" width="225" />
  126. </el-table>
  127. </el-dialog>
  128. <el-dialog v-model="getGxMcshow"
  129. :before-close="closegetGxMcshow" title="选择"
  130. destroy-on-close width="600px"
  131. >
  132. <el-table tooltip-effect="dark" :data="selectData"
  133. row-key="ID" highlight-current-row="true"
  134. border style="width:100%"
  135. @row-dblclick="handleSelectClick"
  136. >
  137. <el-table-column prop="jyGx" label="" width="100" />
  138. <el-table-column prop="Gd_cpmc" label="" width="460" />
  139. </el-table>
  140. <template #footer>
  141. <div class="dialog-footer">
  142. <el-button @click="closegetGxMcshow">取 消</el-button>
  143. </div>
  144. </template>
  145. </el-dialog>
  146. </el-main>
  147. </el-container>
  148. </el-container>
  149. </div>
  150. </template>
  151. <script setup>
  152. import {
  153. getList,
  154. getTab,
  155. locate,
  156. getInfo,
  157. getGxMc,
  158. edit,
  159. del,
  160. packagingAdd
  161. } from '@/api/jixiaoguanli/jitairibaobiao'
  162. // 全量引入格式化工具 请按需保留
  163. import { getDictFunc, formatDate, formatBoolean, filterDict, ReturnArrImg, onDownloadFile } from '@/utils/format'
  164. import { ElMessage, ElMessageBox, LAST_KEYS } from 'element-plus'
  165. import { Search, Refresh, Download } from '@element-plus/icons-vue'
  166. import { ref, reactive, nextTick, onMounted, onBeforeMount } from 'vue'
  167. import { getPackingSideTable, getPackingTable } from '@/api/mes_api_gty/myapi'
  168. import { Layout, LayoutContent, LayoutHeader, LayoutSider } from '@arco-design/web-vue'
  169. import { useUserStore } from '@/pinia/modules/user'
  170. const userStore = useUserStore()
  171. const sys_id='['+userStore.userInfo.userName+'/'+userStore.userInfo.nickName+']'
  172. defineOptions({
  173. name: '06-packingDocuments'
  174. })
  175. // 侧边栏数据请求
  176. const treeData = reactive([]);
  177. const getTabdata = async () => {
  178. //接口调用函数
  179. const response = await getTab();
  180. const transformedData = response.data.map(item => ({
  181. label: `${item.date.replace(/-/g, '.')}【单据数: ${item.counts}张】`,
  182. children: item.sys.map(sysItem => ({
  183. label: `${sysItem.sys_id} 【记录数: ${sysItem.count}张】`,
  184. params: {
  185. date: item.date.replace(/\./g, '-'),
  186. sys_id: sysItem.sys_id,
  187. total: sysItem.count,
  188. },
  189. })),
  190. }));
  191. treeData.splice(0, treeData.length, ...transformedData);
  192. }
  193. getTabdata();
  194. // 自动化生成的字典(可能为空)以及字段
  195. const formData = ref({
  196. sczl_rq: '',
  197. sczl_gdbh1: '',
  198. sczl_gdbh2: '',
  199. sczl_gdbh3: '',
  200. sczl_gdbh4: '',
  201. sczl_gdbh5: '',
  202. sczl_gdbh6: '',
  203. sczl_yjGx1: '',
  204. sczl_yjGx2: '',
  205. sczl_yjGx3: '',
  206. sczl_yjGx4: '',
  207. sczl_yjGx5: '',
  208. sczl_yjGx6: '',
  209. sczl_gxmc1: '',
  210. sczl_gxmc2: '',
  211. sczl_gxmc3: '',
  212. sczl_gxmc4: '',
  213. sczl_gxmc5: '',
  214. sczl_gxmc6: '',
  215. Gd_cpmc1: '',
  216. Gd_cpmc2: '',
  217. Gd_cpmc3: '',
  218. Gd_cpmc4: '',
  219. Gd_cpmc5: '',
  220. Gd_cpmc6: '',
  221. sczl_cl1: '0.00',
  222. sczl_cl2: '0.00',
  223. sczl_cl3: '0.00',
  224. sczl_cl4: '0.00',
  225. sczl_cl5: '0.00',
  226. sczl_cl6: '0.00',
  227. sczl_PgCl1:'0',
  228. sczl_PgCl2: '0',
  229. sczl_PgCl3: '0',
  230. sczl_PgCl4: '0',
  231. sczl_PgCl5: '0',
  232. sczl_PgCl6: '0',
  233. sczl_clAdd1: '0',
  234. sczl_clAdd2: '0',
  235. sczl_clAdd3: '0',
  236. sczl_clAdd4: '0',
  237. sczl_clAdd5: '0',
  238. sczl_clAdd6: '0',
  239. UniqId:'000',
  240. })
  241. const initFormData = () => {
  242. formData.value = {
  243. sczl_rq: '',
  244. sczl_gdbh1: '',
  245. sczl_gdbh2: '',
  246. sczl_gdbh3: '',
  247. sczl_gdbh4: '',
  248. sczl_gdbh5: '',
  249. sczl_gdbh6: '',
  250. sczl_yjGx1: '',
  251. sczl_yjGx2: '',
  252. sczl_yjGx3: '',
  253. sczl_yjGx4: '',
  254. sczl_yjGx5: '',
  255. sczl_yjGx6: '',
  256. sczl_gxmc1: '',
  257. sczl_gxmc2: '',
  258. sczl_gxmc3: '',
  259. sczl_gxmc4: '',
  260. sczl_gxmc5: '',
  261. sczl_gxmc6: '',
  262. Gd_cpmc1: '',
  263. Gd_cpmc2: '',
  264. Gd_cpmc3: '',
  265. Gd_cpmc4: '',
  266. Gd_cpmc5: '',
  267. Gd_cpmc6: '',
  268. sczl_cl1: '0.00',
  269. sczl_cl2: '0.00',
  270. sczl_cl3: '0.00',
  271. sczl_cl4: '0.00',
  272. sczl_cl5: '0.00',
  273. sczl_cl6: '0.00',
  274. sczl_PgCl1:'0',
  275. sczl_PgCl2: '0',
  276. sczl_PgCl3: '0',
  277. sczl_PgCl4: '0',
  278. sczl_PgCl5: '0',
  279. sczl_PgCl6: '0',
  280. sczl_clAdd1: '0',
  281. sczl_clAdd2: '0',
  282. sczl_clAdd3: '0',
  283. sczl_clAdd4: '0',
  284. sczl_clAdd5: '0',
  285. sczl_clAdd6: '0',
  286. UniqId:'000',
  287. }
  288. }
  289. // 验证规则
  290. const rule = reactive({
  291. })
  292. const elFormRef = ref()
  293. const elSearchFormRef = ref()
  294. // =========== 表格控制部分 ===========
  295. const tableData = reactive([])
  296. const GxMctableData = reactive([])
  297. const tableColumns = [
  298. { label: '创建用户', prop: 'sys_id', width: '120' },
  299. { label: '日期', prop: 'sczl_rq', width: '100' },
  300. { label: '包装产量', prop: 'sczl_cl', width: '105' },
  301. { label: '包装数量', prop: 'sczl_PgCl', width: '105' },
  302. { label: '创建时间', prop: 'sys_rq', width: '160' },
  303. { label: '修改时间', prop: 'mod_rq', width: '160' },
  304. { label: 'UNIQID', prop: 'UniqId', width: '120' },
  305. ]
  306. const total=ref(0)
  307. const inputname=ref(0)
  308. const page = ref(1)
  309. const limit = ref(10)
  310. const searchInfo = ref('')
  311. const params = {
  312. type: '',
  313. date: '',
  314. sys_id: '',
  315. gdbh: '',
  316. }
  317. const locatevalue={
  318. gdbh:'',
  319. cpmc:'',
  320. page:page.value.toString(),
  321. limit:limit.value.toString(),
  322. }
  323. let table=ref(5);
  324. let positionvalue=ref()
  325. let GxMcvalue=ref()
  326. // 分页设置
  327. const handleSizeChange = (val) => {
  328. switch (params.type) {
  329. case 'getTableData':
  330. getTableData()
  331. break
  332. case 'getLocateTable':
  333. GetmachineLocate()
  334. break
  335. default:
  336. break
  337. }
  338. }
  339. // 页面跳转
  340. const handleCurrentChange = (val) => {
  341. switch (params.type) {
  342. case 'getTableData':
  343. getTableData()
  344. break
  345. case 'getLocateTable':
  346. GetmachineLocate()
  347. break
  348. default:
  349. break
  350. }
  351. }
  352. // 查询
  353. const getTableData = async () => {
  354. const response = await getList(params);
  355. if (response.code === 0) {
  356. tableData.splice(0, tableData.length, ...response.data.rows);
  357. }
  358. }
  359. const handleNodeClick = (node, check) => {
  360. //存放当前节点的nodeId
  361. if (node.params) {
  362. params.date = node.params.date;
  363. params.sys_id = node.params.sys_id;
  364. total.value = node.params.total;
  365. getTableData();
  366. }
  367. }
  368. const Getlocate = async () => {
  369. const response = await locate({
  370. gdbh: params.gdbh,
  371. page: page.value.toString(), limit: limit.value.toString(),
  372. })
  373. if (response.code === 0) {
  374. total.value = response.data.total
  375. tableData.splice(0, tableData.length, ...response.data.rows)
  376. }
  377. }
  378. const enterpositioning = async () => {
  379. locatevalue.gdbh=positionvalue.value;
  380. Getlocate()
  381. closepositioningVisible()
  382. }
  383. let sczl_rqValue=ref()
  384. const getpickInfo = async (value) => {
  385. const response = await getInfo({UniqId:value});
  386. if (response.code === 0) {
  387. formData.value=response.data;
  388. }
  389. }
  390. //键盘 input框跳转
  391. const ent1 = (event) => {
  392. const inputs = document.getElementsByTagName('input');
  393. const currentIndex = Array.from(inputs).indexOf(event.target);
  394. if (event.keyCode === 13 || event.keyCode === 40) { // Enter 或向下箭头
  395. if(event.target.id=='sczl_clAdd6'){
  396. ElMessageBox.confirm('数据存盘?', '提示', {
  397. confirmButtonText: '确定',
  398. cancelButtonText: '取消',
  399. type: 'warning'
  400. }).then(() => {
  401. enterDialog()
  402. })
  403. }
  404. for (let i = currentIndex + 1; i < inputs.length; i++) {
  405. if (!inputs[i].readOnly) {
  406. nextTick(()=>{
  407. inputs[i].focus();
  408. inputs[i].select();
  409. })
  410. break;
  411. }
  412. }
  413. if(event.target.id.substring(0, 2)=='cl' || event.target.id.substring(0, 2)=='fp'){
  414. ent_sum()
  415. }
  416. } else if (event.keyCode === 38) { // 向上箭头
  417. for (let i = currentIndex - 1; i >= 0; i--) {
  418. if (!inputs[i].readOnly) {
  419. nextTick(()=>{
  420. inputs[i].focus();
  421. inputs[i].select();
  422. })
  423. break;
  424. }
  425. }
  426. if(event.target.id.substring(0, 2)=='cl' || event.target.id.substring(0, 2)=='fp'){
  427. ent_sum()
  428. }
  429. } else if (event.keyCode === 8) { // 删除箭头
  430. if (event.target.selectionStart === 0) {
  431. for (let i = currentIndex - 1; i >= 0; i--) {
  432. if (!inputs[i].readOnly) {
  433. nextTick(()=>{
  434. inputs[i].focus();
  435. inputs[i].setSelectionRange(0, 0);
  436. })
  437. break;
  438. }
  439. }
  440. if(event.target.id.substring(0, 2)=='cl' || event.target.id.substring(0, 2)=='fp'){
  441. ent_sum()
  442. }
  443. }
  444. } else if (event.keyCode === 37) { // 向左箭头
  445. if (event.target.selectionStart === 0) {
  446. for (let i = currentIndex - 1; i >= 0; i--) {
  447. if (!inputs[i].readOnly) {
  448. nextTick(()=>{
  449. inputs[i].focus();
  450. inputs[i].select();
  451. })
  452. break;
  453. }
  454. }
  455. if(event.target.id.substring(0, 2)=='cl' || event.target.id.substring(0, 2)=='fp'){
  456. ent_sum()
  457. }
  458. }
  459. } else if (event.keyCode === 39) { // 向右箭头
  460. if(event.target.id=='sczl_clAdd6'){
  461. ElMessageBox.confirm('数据存盘?', '提示', {
  462. confirmButtonText: '确定',
  463. cancelButtonText: '取消',
  464. type: 'warning'
  465. }).then(() => {
  466. enterDialog()
  467. })
  468. }
  469. if (event.target.selectionStart === event.target.value.length) {
  470. for (let i = currentIndex + 1; i < inputs.length; i++) {
  471. if (!inputs[i].readOnly) {
  472. nextTick(()=>{
  473. inputs[i].focus();
  474. inputs[i].select();
  475. })
  476. break;
  477. }
  478. }
  479. }
  480. if(event.target.id.substring(0, 2)=='cl' || event.target.id.substring(0, 2)=='fp'){
  481. ent_sum()
  482. }
  483. }
  484. }
  485. //追加字体颜色和不可输入
  486. const setColorReadonly = (id) => {
  487. const newInput = document.getElementById(id)
  488. newInput.style.color = 'red';
  489. newInput.setAttribute('readonly', true);
  490. }
  491. //追加字体颜色和可输入
  492. const unsetColorReadonly = (id) => {
  493. const newInput = document.getElementById(id)
  494. newInput.style.color = 'black';
  495. newInput.removeAttribute('readonly');
  496. }
  497. //日期获得焦点事件
  498. const rqHandleFocus = () =>{
  499. if(formData.value.sczl_rq==''){
  500. formData.value.sczl_rq = new Date().toISOString().split('T')[0]
  501. }
  502. }
  503. //工单编号失去焦点事件
  504. const getGxMcshow = ref(false)
  505. const selectData = reactive([])
  506. let tableIndex = 0
  507. const getGxMcsubmit = async (event, index) => {
  508. if(formData.value['sczl_gdbh'+index]!=''){
  509. const response = await getGxMc({gdbh: formData.value['sczl_gdbh'+index] })
  510. if (response.code === 0) {
  511. if(response.data.length==0){
  512. ElMessage({
  513. type: 'error',
  514. message: '查无此编号的工单,请仔细检查后重新输入'
  515. })
  516. //设置输入框的值为空
  517. formData.value['sczl_gdbh'+index] = ''
  518. formData.value['Gd_cpmc'+index] = ''
  519. formData.value['sczl_yjGx'+index] = ''
  520. formData.value['sczl_gxmc'+index] = ''
  521. }else if(response.data.length==1){
  522. const { Gd_cpmc, Gy0_gxmc, jyGx } = response.data[0]
  523. formData.value['Gd_cpmc'+index] = Gd_cpmc
  524. formData.value['sczl_yjGx'+index] = jyGx
  525. formData.value['sczl_gxmc'+index] = Gy0_gxmc
  526. setColorReadonly('Gd_cpmc'+index);
  527. setColorReadonly('sczl_yjGx'+index);
  528. setColorReadonly('sczl_gxmc'+index);
  529. unsetColorReadonly('sczl_cl'+index);
  530. unsetColorReadonly('sczl_PgCl'+index);
  531. }else{
  532. selectData.splice(0, selectData.length, ...response.data)
  533. tableIndex = index
  534. getGxMcshow.value = true
  535. }
  536. }
  537. }else{
  538. formData.value['Gd_cpmc'+index] = ''
  539. formData.value['sczl_yjGx'+index] = ''
  540. formData.value['sczl_gxmc'+index] = ''
  541. formData.value['sczl_cl'+index] = '0.00'
  542. formData.value['sczl_PgCl'+index] = '0'
  543. setColorReadonly('sczl_cl'+index);
  544. setColorReadonly('sczl_PgCl'+index);
  545. }
  546. }
  547. // 处理选择框
  548. const handleSelectClick = (row, column, event) => {
  549. const { Gd_cpmc, Gy0_gxmc, jyGx } = row
  550. formData.value['Gd_cpmc'+tableIndex] = Gd_cpmc
  551. formData.value['sczl_yjGx'+tableIndex] = jyGx
  552. formData.value['sczl_gxmc'+tableIndex] = Gy0_gxmc
  553. setColorReadonly('Gd_cpmc'+tableIndex);
  554. setColorReadonly('sczl_yjGx'+tableIndex);
  555. setColorReadonly('sczl_gxmc'+tableIndex);
  556. unsetColorReadonly('sczl_cl'+tableIndex);
  557. unsetColorReadonly('sczl_PgCl'+tableIndex);
  558. getGxMcshow.value = false
  559. }
  560. // 更新数据
  561. const updateDetailData = async() => {
  562. const restoredData = {
  563. UniqId: lastCellValue,
  564. sczl_rq: formData.value.sczl_rq,
  565. sczl_gdbh1: formData.value.sczl_gdbh1,
  566. sczl_gdbh2: formData.value.sczl_gdbh2,
  567. sczl_gdbh3: formData.value.sczl_gdbh3,
  568. sczl_gdbh4: formData.value.sczl_gdbh4,
  569. sczl_gdbh5: formData.value.sczl_gdbh5,
  570. sczl_gdbh6: formData.value.sczl_gdbh6,
  571. sczl_yjGx1: formData.value.sczl_yjGx1,
  572. sczl_yjGx2: formData.value.sczl_yjGx2,
  573. sczl_yjGx3: formData.value.sczl_yjGx3,
  574. sczl_yjGx4: formData.value.sczl_yjGx4,
  575. sczl_yjGx5: formData.value.sczl_yjGx5,
  576. sczl_yjGx6: formData.value.sczl_yjGx6,
  577. sczl_gxmc1: formData.value.sczl_gxmc1,
  578. sczl_gxmc2: formData.value.sczl_gxmc2,
  579. sczl_gxmc3: formData.value.sczl_gxmc3,
  580. sczl_gxmc4: formData.value.sczl_gxmc4,
  581. sczl_gxmc5: formData.value.sczl_gxmc5,
  582. sczl_gxmc6: formData.value.sczl_yjGx6,
  583. sczl_cl1: formData.value.sczl_cl1,
  584. sczl_cl2: formData.value.sczl_cl2,
  585. sczl_cl3: formData.value.sczl_cl3,
  586. sczl_cl4: formData.value.sczl_cl4,
  587. sczl_cl5: formData.value.sczl_cl5,
  588. sczl_cl6: formData.value.sczl_cl6,
  589. sczl_PgCl1:formData.value.sczl_PgCl1,
  590. sczl_PgCl2: formData.value.sczl_PgCl2,
  591. sczl_PgCl3: formData.value.sczl_PgCl3,
  592. sczl_PgCl4: formData.value.sczl_PgCl4,
  593. sczl_PgCl5: formData.value.sczl_PgCl5,
  594. sczl_PgCl6: formData.value.sczl_PgCl6,
  595. Gd_cpmc1: formData.value.Gd_cpmc1,
  596. Gd_cpmc3: formData.value.Gd_cpmc2,
  597. Gd_cpmc4: formData.value.Gd_cpmc3,
  598. Gd_cpmc5: formData.value.Gd_cpmc4,
  599. Gd_cpmc6: formData.value.Gd_cpmc5,
  600. sczl_clAdd1: formData.value.sczl_clAdd1,
  601. sczl_clAdd2: formData.value.sczl_clAdd2,
  602. sczl_clAdd3: formData.value.sczl_clAdd3,
  603. sczl_clAdd4: formData.value.sczl_clAdd4,
  604. sczl_clAdd5:formData.value.sczl_clAdd5,
  605. sczl_clAdd6: formData.value.sczl_clAdd6,
  606. sys_id:sys_id,
  607. }
  608. if(ADD.value=='新增'){
  609. const response = await packagingAdd(restoredData);
  610. ADD.value='0'
  611. if(response.code==0){
  612. ElMessage({
  613. type: 'success',
  614. message: '新增成功',
  615. })
  616. }
  617. dialogFormVisible.value = false
  618. }else{
  619. const res = await edit(restoredData)
  620. if(res.code==0){
  621. ElMessage({
  622. type: 'success',
  623. message: '更新成功',
  624. })
  625. }
  626. dialogFormVisible.value = false
  627. }
  628. }
  629. const GxMcdel = async () => {
  630. const response = await del({UniqId:lastCellValue});
  631. if (response.code === 0) {
  632. ElMessage({
  633. type: 'success',
  634. message: '删除成功',
  635. })
  636. }
  637. getTableData()
  638. }
  639. // 搜索
  640. function onSearch() {
  641. params.gdbh = positionvalue.value
  642. params.type = 'getLocateTable'
  643. page.value = 1
  644. Getlocate()
  645. }
  646. // ============== 表格控制部分结束 ===============
  647. // 获取需要的字典 可能为空 按需保留
  648. const setOptions = async () => {
  649. }
  650. // 获取需要的字典 可能为空 按需保留
  651. setOptions()
  652. // 多选数据
  653. const multipleSelection = ref([])
  654. // 多选
  655. const handleSelectionChange = (val) => {
  656. if(val.length>0){
  657. multipleSelection.value = val
  658. const lenth=val.length
  659. lastCellValue=val[lenth-1].UniqId
  660. console.log(val)
  661. val.splice(0, val.length); // 清空 val 数组
  662. console.log(lastCellValue)
  663. }
  664. }
  665. // 批量删除控制标记
  666. const deleteVisible = ref(false)
  667. // 多选删除
  668. const onDelete = async () => {
  669. const ids = []
  670. if (multipleSelection.value.length === 0) {
  671. ElMessage({
  672. type: 'warning',
  673. message: '请选择要删除的数据'
  674. })
  675. return
  676. }
  677. multipleSelection.value &&
  678. multipleSelection.value.map(item => {
  679. ids.push(item.ID)
  680. })
  681. const res = await deleteCompanyByIds({ ids })
  682. if (res.code === 0) {
  683. ElMessage({
  684. type: 'success',
  685. message: '删除成功'
  686. })
  687. if (tableData.value.length === ids.length && page.value > 1) {
  688. page.value--
  689. }
  690. deleteVisible.value = false
  691. getTableData()
  692. }
  693. }
  694. // 弹窗控制标记
  695. const dialogFormVisible = ref(false)
  696. // 行为控制标记(弹窗内部需要增还是改)
  697. const type = ref('')
  698. // 更新行
  699. const updateCompanyFunc = async (row) => {
  700. const res = await findCompany({ ID: row.ID })
  701. type.value = 'update'
  702. if (res.code === 0) {
  703. formData.value = res.data.recompany
  704. dialogFormVisible.value = true
  705. }
  706. }
  707. // 弹窗控制标记
  708. const positioningVisibleshow = ref(false)
  709. const positioningVisible = () => {
  710. type.value = 'create'
  711. positioningVisibleshow.value = true
  712. }
  713. const ADD=ref('0')
  714. //新增
  715. function onAdd() {
  716. ADD.value='新增'
  717. type.value = 'create'
  718. // if(typeof(lastCellValue)=='number'){
  719. // getpickInfo(lastCellValue)
  720. // }
  721. initFormData()
  722. dialogFormVisible.value = true
  723. // Productionadd()
  724. }
  725. const Del = () => {
  726. GxMcdel()
  727. }
  728. const closepositioningVisible = () => {
  729. positioningVisibleshow.value = false
  730. formData.value = {
  731. address: '',
  732. image: '',
  733. name: '',
  734. }
  735. }
  736. const closegetGxMcshow = () => {
  737. getGxMcshow.value = false
  738. }
  739. // 打开弹窗
  740. const openDialog = () => {
  741. type.value = 'create'
  742. dialogFormVisible.value = true
  743. }
  744. // 关闭弹窗
  745. const closeDialog = () => {
  746. dialogFormVisible.value = false
  747. formData.value = {
  748. address: '',
  749. image: '',
  750. name: '',
  751. }
  752. }
  753. // 弹窗确定
  754. const enterDialog = async () => {
  755. ElMessageBox.confirm('数据存盘?', '提示', {
  756. confirmButtonText: '确定',
  757. cancelButtonText: '取消',
  758. type: 'warning'
  759. }).then(() => {
  760. if(formData.value.sczl_rq==''){
  761. ElMessage({
  762. type: 'error',
  763. message: '请填写日期'
  764. });
  765. document.getElementById('日期').focus()
  766. document.getElementById('日期').select()
  767. return;
  768. }
  769. if(formData.value.sczl_gdbh1=='' && formData.value.sczl_gdbh2=='' && formData.value.sczl_gdbh3=='' &&
  770. formData.value.sczl_gdbh4=='' && formData.value.sczl_gdbh5=='' && formData.value.sczl_gdbh6==''){
  771. ElMessage({
  772. type: 'error',
  773. message: '请填写工单编号'
  774. });
  775. document.getElementById('sczl_gdbh1').focus()
  776. document.getElementById('sczl_gdbh1').select()
  777. return;
  778. }
  779. if(parseFloat(formData.value.sczl_cl1)==0 && parseFloat(formData.value.sczl_cl2)==0 && parseFloat(formData.value.sczl_cl3)==0 &&
  780. parseFloat(formData.value.sczl_cl4)==0 && parseFloat(formData.value.sczl_cl5)==0 && parseFloat(formData.value.sczl_cl6)==0){
  781. ElMessage({
  782. type: 'error',
  783. message: '请填写包装产量'
  784. });
  785. document.getElementById('sczl_cl1').focus()
  786. document.getElementById('sczl_cl1').select()
  787. return;
  788. }
  789. if(parseFloat(formData.value.sczl_PgCl1)==0 && parseFloat(formData.value.sczl_PgCl2)==0 && parseFloat(formData.value.sczl_PgCl3)==0 &&
  790. parseFloat(formData.value.sczl_PgCl4)==0 && parseFloat(formData.value.sczl_PgCl5)==0 && parseFloat(formData.value.sczl_PgCl6)==0){
  791. ElMessage({
  792. type: 'error',
  793. message: '请填写每箱数量'
  794. });
  795. document.getElementById('sczl_PgCl1').focus()
  796. document.getElementById('sczl_PgCl1').select()
  797. return;
  798. }
  799. updateDetailData()
  800. });
  801. }
  802. let lastCellValue=ref()
  803. // 双击表格操作
  804. function doubleClick(row) {
  805. type.value = 'update';
  806. getpickInfo(row['UniqId'])
  807. dialogFormVisible.value = true
  808. }
  809. // 单击表格操作
  810. function Click(row, column, event) {
  811. lastCellValue= row['UniqId'];
  812. }
  813. // 导出excel
  814. function exportExcel() {
  815. console.log('导出到excel');
  816. }
  817. // 生命周期钩子
  818. onMounted(async () => {
  819. });
  820. </script>
  821. <style>
  822. .JKWTree-container {
  823. display: flex;
  824. }
  825. .JKWTree-tree {
  826. width: 300px;
  827. background-color: #fff;
  828. padding: 10px;
  829. margin-right: 20px;
  830. }
  831. .JKWTree-tree h3 {
  832. font-size: 15px;
  833. font-weight: 700;
  834. margin: 10px 0;
  835. }
  836. .JKWTree-content {
  837. flex: 1;
  838. }
  839. /* 选中某行时的背景色*/
  840. .el-table__body tr.current-row>td {
  841. background: #ff80ff !important;
  842. /* 背景颜色 */
  843. }
  844. </style>
  845. <style scoped>
  846. :deep(.el-table td .cell) {
  847. line-height: 20px !important;
  848. }
  849. :deep(.el-tabs__header){
  850. margin-bottom: 0;
  851. }
  852. .search{
  853. margin-left: 0px !important;
  854. margin-right: 10px !important;
  855. }
  856. .bt{
  857. margin-left: 2px !important;
  858. padding: 3px !important;
  859. font-size: 12px;
  860. }
  861. .el-tabs__header{
  862. margin: 0px !important;
  863. }
  864. .gva-table-box{
  865. padding: 0px !important;
  866. }
  867. .mab{
  868. margin-bottom: 5px;
  869. }
  870. </style>