Packagingoutput.vue 27 KB

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