Packagingoutput.vue 27 KB

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