cropdefective.vue 32 KB

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