cropdefective.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852
  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" class="treecolor" 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="searchinfo" @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. <el-button type="primary" :icon="Download" @click="exportExcel2">导出到Excel(明细)</el-button>
  23. </div>
  24. </el-form-item>
  25. <!-- 数据展示 -->
  26. <el-table ref="multipleTable" style="width: 100%;height: 70vh;" tooltip-effect="dark" :data="tableData" row-key="ID"
  27. highlight-current-row="true" border @selection-change="handleSelectionChange" id="table"
  28. :row-style="{ height: '20px' }" :header-cell-style="{ padding: '0px' }"
  29. :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
  30. :show-overflow-tooltip="true" @row-click="Click" @row-dblclick="doubleClick">
  31. <el-table-column align="left" label="单据编号" prop="单据编号" width="140" />
  32. <el-table-column align="left" label="面料名称" prop="面料名称" width="120" />
  33. <el-table-column align="left" label="次片数量" prop="数量" width="100" />
  34. <el-table-column align="left" label="订单编号" prop="订单编号" width="190" />
  35. <el-table-column align="left" label="生产款号" prop="生产款号" width="140" />
  36. <el-table-column align="left" label="款式" prop="款式" width="120" />
  37. <el-table-column align="left" label="颜色" prop="颜色" width="100" />
  38. <el-table-column align="left" label="问题分类" prop="问题分类" width="120" />
  39. <el-table-column align="left" label="创建时间" prop="Sys_rq" width="120" />
  40. <el-table-column fixed="right" label="操作" width="130">
  41. <template #default="{ row, $index }">
  42. <el-button @click="Order_detailsRow(row,$index)" type="success" size="small"
  43. style="font-size: 16px;padding: 0px;width: 90px;">
  44. 查看明细
  45. </el-button>
  46. </template>
  47. </el-table-column>
  48. </el-table>
  49. <!-- 分页 -->
  50. <div class="gva-pagination">
  51. <el-pagination layout="total, sizes, prev, pager, next, jumper" v-model:current-page="page"
  52. v-model:page-size="limit"
  53. :page-sizes="[10, 30, 50, 100]" :total="total" @current-change="handleCurrentChange"
  54. @size-change="handleSizeChange" />
  55. </div>
  56. </div>
  57. <!-- 弹出框 -->
  58. <el-dialog
  59. v-model="dialogFormVisible"
  60. :before-close="closeDialog"
  61. :title="type === 'create' ? '裁剪次片汇总报工页面' : '裁剪次片汇总报工修改'"
  62. destroy-on-close
  63. style="width: 100%; height: 100%; margin: 0%;"
  64. >
  65. <el-form :model="formData" label-position="right" ref="elFormRef" :rules="rule" label-width="120px">
  66. <!-- 日期选择框 -->
  67. <el-row :gutter="10" >
  68. <el-col :span="8">
  69. <el-form-item label="日期" label-width="50px">
  70. <el-date-picker v-model="DefectiveformData['Sys_rq']" style="width: 40%;" type="date" />
  71. </el-form-item>
  72. </el-col>
  73. <el-col :span="8">
  74. <el-form-item label="报工小组" label-width="100px">
  75. <el-input v-model="ReworkTeam['zb']" style="width: 120px;" />
  76. </el-form-item>
  77. </el-col>
  78. </el-row>
  79. <!-- 新增一行按钮 -->
  80. <el-button type="primary" @click="addRow" style="margin-left: 20px; margin-bottom: 20px;">新增一行</el-button>
  81. <!-- 表格区域 -->
  82. <el-table
  83. :data="SecondarytabeleData"
  84. border
  85. style="width: 100%; height: 63vh;margin-bottom: 20px;"
  86. :row-style="{ height: '40px' }"
  87. :header-cell-style="{ padding: '0px' }"
  88. :cell-style="{ padding: '0px' }"
  89. :header-row-style="{ height: '40px' }"
  90. :show-overflow-tooltip="true"
  91. >
  92. <!-- 订单编号|款号 -->
  93. <el-table-column label="订单编号|款号" width="200">
  94. <template #default="{ row, $index }">
  95. <el-select
  96. v-model="row.ddbh"
  97. placeholder="请输入或选择订单号"
  98. filterable
  99. clearable
  100. remote
  101. :remote-method="(query) => searchOrder(query, $index)"
  102. @change="(value) => handleOrderSelect(value, $index)"
  103. >
  104. <el-option
  105. v-for="ddbh in row.ddbhOptions"
  106. :key="ddbh.value"
  107. :label="ddbh.label"
  108. :value="ddbh.value"
  109. />
  110. </el-select>
  111. </template>
  112. </el-table-column>
  113. <!-- 面料分类|面料名称 -->
  114. <el-table-column label="面料分类|面料名称" width="200">
  115. <template #default="{ row }">
  116. <el-select v-model="row.material" placeholder="请选择面料" >
  117. <el-option
  118. v-for="material in row.materialOptions"
  119. :key="material.value"
  120. :label="material.label"
  121. :value="material.value"
  122. />
  123. </el-select>
  124. </template>
  125. </el-table-column>
  126. <!-- 颜色 -->
  127. <el-table-column label="颜色" width="140">
  128. <template #default="{ row }">
  129. <el-select v-model="row.color" placeholder="请选择颜色" >
  130. <el-option
  131. v-for="color in row.colorOptions"
  132. :key="color.value"
  133. :label="color.label"
  134. :value="color.value"
  135. />
  136. </el-select>
  137. </template>
  138. </el-table-column>
  139. <!-- 款号|款式 -->
  140. <el-table-column label="款式" width="120">
  141. <template #default="{ row }">
  142. <el-input v-model="row.ks" />
  143. </template>
  144. </el-table-column>
  145. <!-- 次片数量 -->
  146. <el-table-column label="次片数量" width="100">
  147. <template #default="{ row }">
  148. <el-input v-model="row.defectiveQuantity" />
  149. </template>
  150. </el-table-column>
  151. <!-- 次片问题 -->
  152. <el-table-column label="次片问题" width="140">
  153. <template #default="{ row }">
  154. <el-select v-model="row.issue" placeholder="请选择次片问题">
  155. <el-option
  156. v-for="issue in row.issueOptions"
  157. :key="issue.value"
  158. :label="issue.label"
  159. :value="issue.value"
  160. />
  161. </el-select>
  162. </template>
  163. </el-table-column>
  164. <!-- 报工小组 -->
  165. <!-- <el-table-column label="报工小组" width="150">
  166. <template #default="{ row }">
  167. <el-select v-model="row.group" placeholder="请选择报工小组" >
  168. <el-option
  169. v-for="group in row.groupOptions"
  170. :key="group.value"
  171. :label="group.label"
  172. :value="group.value"
  173. />
  174. </el-select>
  175. </template>
  176. </el-table-column> -->
  177. <!-- 备注 -->
  178. <el-table-column label="备注" width="220">
  179. <template #default="{ row }">
  180. <el-input v-model="row.remark" />
  181. </template>
  182. </el-table-column>
  183. <!-- 操作列 -->
  184. <el-table-column label="操作" width="220" fixed="right">
  185. <template #default="{ row, $index }">
  186. <el-button type="primary" @click="copyRow($index)" style="font-size: 18px;">复制本条</el-button>
  187. <el-button type="danger" @click="removeRow($index)" style="font-size: 18px;">移除</el-button>
  188. </template>
  189. </el-table-column>
  190. </el-table>
  191. </el-form>
  192. <!-- 弹窗底部按钮 -->
  193. <template #footer>
  194. <div class="dialog-footer" style="width: 100%;">
  195. <el-button @click="closeDialog" style="width: 100px; height: 40px;">关 闭</el-button>
  196. <el-button type="primary" @click="enterDialog" style="width: 100px; height: 40px;">确 定</el-button>
  197. </div>
  198. </template>
  199. </el-dialog>
  200. <!-- 明细数据 -->
  201. <el-dialog v-model="OrderdetailsdialogFormVisible" :before-close="Orderdetails_bomcloseDialog" :title="'裁剪次片汇总单据详情'"
  202. width="100%" style="height: 100%;margin: 0%;padding: 0px 10px 0px 10px;" destroy-on-close>
  203. <el-button type="primary" @click="Orderdetails_closeDialog" style="width: 100px;height: 50px;margin-left: 10px;">关 闭</el-button>
  204. <div class="gva-table-box">
  205. <el-table ref="multipleTable"
  206. :row-style="{ height: '30px' }" :header-cell-style="{ padding: '0px' }"
  207. :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
  208. :show-overflow-tooltip="true" highlight-current-row="true"
  209. @row-click="detailsclicks" @row-dblclick="Doubleclickdetails"
  210. @selection-change="detailSelectionChange" style="width: 100%;height: 75vh" border
  211. :summary-method="getSummaries" tooltip-effect="dark" :data="Orderdetailsdata" row-key="ID" >
  212. <el-table-column align="left" label="单据编号" prop="单据编号" width="140" />
  213. <el-table-column align="left" label="订单编号" prop="订单编号" width="120" />
  214. <el-table-column align="left" label="生产款号" prop="生产款号" width="120" />
  215. <el-table-column align="left" label="面料分类" prop="面料分类" width="120" />
  216. <el-table-column align="left" label="面料名称" prop="面料名称" width="120" />
  217. <el-table-column align="left" label="颜色" prop="颜色" width="100" />
  218. <el-table-column align="left" label="款式" prop="款式" width="120" />
  219. <el-table-column align="left" label="次片数量" prop="数量" width="80" />
  220. <!-- <el-table-column align="left" label="计划用料" prop="计划用料" width="100" />
  221. <el-table-column align="left" label="实际用料" prop="实际用料" width="100" /> -->
  222. <el-table-column align="left" label="次片问题" prop="问题分类" width="120" />
  223. <el-table-column align="left" label="备注" prop="备注" width="120" />
  224. <el-table-column align="left" label="报工小组" prop="组别" width="120" />
  225. <el-table-column align="left" label="操作人员" prop="Sys_id" width="120" />
  226. <el-table-column align="left" label="创建时间" prop="Sys_rq" width="120" />
  227. </el-table>
  228. <div class="dialog-footer" style="text-align: left;margin-right: 60px;">
  229. </div>
  230. </div>
  231. </el-dialog>
  232. </el-main>
  233. </el-container>
  234. </el-container>
  235. </div>
  236. </template>
  237. <script setup>
  238. // 全量引入格式化工具 请按需保留
  239. import { ElMessage, ElMessageBox, LAST_KEYS } from 'element-plus';
  240. import * as XLSX from 'xlsx';
  241. import FileSaver from 'file-saver';
  242. import { Search, Refresh, Download } from '@element-plus/icons-vue'
  243. import { ref, reactive, nextTick, onMounted, onBeforeMount } from 'vue'
  244. import { Layout, LayoutContent, LayoutHeader, LayoutSider } from '@arco-design/web-vue'
  245. import {getMachineMac} from '@/api/jixiaoguanli/jitairibaobiao'
  246. import {queryOrderSize,ApiAddDefective,ApiMouthlist,ApiSubPieceAnd,ApiSubPieceAndReworkList, Apiorder} from '@/api/mes/job'
  247. import { useUserStore } from '@/pinia/modules/user'
  248. // import { el } from 'element-plus/es/locale'
  249. //获取登录用户信息
  250. const userStore = useUserStore()
  251. const _username = ref('')
  252. _username.value = userStore.userInfo.userName + '/' + userStore.userInfo.nickName
  253. console.log('获取用户名称',_username.value)
  254. //全局获取当前日期
  255. const today = new Date();
  256. const year = today.getFullYear();
  257. const month = String(today.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始,需要补零
  258. const day = String(today.getDate()).padStart(2, '0');
  259. const hours = String(today.getHours()).padStart(2, '0');
  260. const minutes = String(today.getMinutes()).padStart(2, '0');
  261. const seconds = String(today.getSeconds()).padStart(2, '0');
  262. const currentDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  263. const currentDates = `${year}-${month}-${day}`;
  264. // 侧边栏数据请求
  265. const treeData = reactive([]);
  266. const getTabdata = async () => {
  267. try {
  268. const response = await ApiMouthlist({ code: '次片' });
  269. if (response.code === 0) {
  270. // 清空数组
  271. treeData.splice(0, treeData.length);
  272. // 转换接口数据为树形结构
  273. const formattedData = Object.entries(response.data).map(([year, months]) => ({
  274. label: year,
  275. children: Object.entries(months).map(([month, days]) => ({
  276. label: month,
  277. children: days.map(day => ({
  278. label: day
  279. }))
  280. }))
  281. }));
  282. treeData.push(...formattedData);
  283. console.log('转换后的树形数据:', treeData); // 调试用
  284. } else {
  285. ElMessage.error(response.msg || '获取数据失败');
  286. }
  287. } catch (error) {
  288. console.error('请求错误:', error);
  289. ElMessage.error('请求失败,请稍后重试');
  290. }
  291. };
  292. getTabdata();
  293. const ReworkTeam = reactive({
  294. zb: '车缝01组', // 返工车缝小组
  295. });
  296. const Machine = ref('') //机台号
  297. //自动获取物理地址
  298. const GetAddr = () => {
  299. var xmlhttp = null;
  300. var res;
  301. if (window.XMLHttpRequest) {
  302. xmlhttp = new XMLHttpRequest();
  303. } else if (window.ActiveXObject) {
  304. xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  305. }
  306. // 2. 设置回调函数
  307. xmlhttp.onreadystatechange = function() {
  308. if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  309. res = eval('('+xmlhttp.response+')');
  310. let result = ''
  311. for (let i = 0; i < res.macAddress.length; i++) {
  312. if (i % 2 === 0 && i !== 0) {
  313. result += '-' // 根据实际需求修改分隔符
  314. }
  315. result += res.macAddress[i]
  316. }
  317. Machine.value = result
  318. getMachineMacdata(Machine.value)
  319. }
  320. }
  321. // 3. 打开一个连接
  322. xmlhttp.open("get", "http://127.0.0.1:8090/init")
  323. // 5. 发送
  324. xmlhttp.send();
  325. }
  326. GetAddr()
  327. //物理地址获取机台编号
  328. const getMachineMacdata = async () => {
  329. console.log("机台获取物理地址",Machine.value)
  330. try {
  331. const data = await getMachineMac({sys_sbID:Machine.value});
  332. if (data.data === null) {
  333. return;
  334. }
  335. console.log("机台获取物理地址",data.data)
  336. ReworkTeam['zb'] = data.data.组别;
  337. } catch (error) {
  338. console.error(error)
  339. }
  340. }
  341. const tableData = reactive([]);
  342. const exceltableData = reactive([]);
  343. const loading = ref(false);
  344. const noderq = ref('');
  345. const handleNodeClick = async (node) => {
  346. noderq.value = node.label;
  347. loading.value = true;
  348. // 取消所有节点的颜色
  349. const allNodes = document.querySelectorAll('.treecolor .el-tree-node');
  350. allNodes.forEach(node => {
  351. node.querySelector('.el-tree-node__label').style.color = '';
  352. });
  353. // 获取点击的节点 给当前点击的节点改变颜色【红色】
  354. const clickedNodeId = node['$treeNodeId'];
  355. const clickedNode = document.querySelector(`.treecolor .el-tree-node[data-key="${clickedNodeId}"]`);
  356. if (clickedNode) {
  357. clickedNode.querySelector('.el-tree-node__label').style.color = 'red';
  358. }
  359. try {
  360. //获取汇总数据
  361. const response = await ApiSubPieceAnd({
  362. Sys_rq: node.label,
  363. page: 1,
  364. limit: 50,
  365. code: '次片'
  366. });
  367. //获取详情数据
  368. const excelresponse = await ApiSubPieceAndReworkList({
  369. Sys_rq: node.label,
  370. page: 1,
  371. limit: 50,
  372. code: '次片'
  373. });
  374. if (response.code === 0 && response.data?.data) {
  375. // 清空并更新表格数据
  376. tableData.splice(0, tableData.length, ...response.data.data);
  377. } else {
  378. tableData.splice(0, tableData.length);
  379. }
  380. if (excelresponse.code === 0 && excelresponse.data?.data) {
  381. // 清空并更新Excel表格数据
  382. exceltableData.splice(0, exceltableData.length, ...excelresponse.data.data);
  383. } else {
  384. exceltableData.splice(0, exceltableData.length);
  385. }
  386. } catch (error) {
  387. console.error('加载数据失败:', error);
  388. ElMessage.error('数据加载失败');
  389. } finally {
  390. loading.value = false;
  391. }
  392. };
  393. const searchinfo = ref('');
  394. const onSearch = async () => { // 搜索按钮触发的事件处理函数,根据需要修改逻辑和接口调用
  395. const response = await ApiSubPieceAnd({
  396. search: searchinfo.value,
  397. Sys_rq:'',
  398. page: 1,
  399. limit: 50,
  400. code: '次片'
  401. });
  402. if (response.code === 0 && response.data?.data) {
  403. // 清空并更新表格数据
  404. tableData.splice(0, tableData.length, ...response.data.data);
  405. } else {
  406. ElMessage.warning(response.msg || '暂无数据');
  407. tableData.splice(0, tableData.length);
  408. }
  409. }
  410. //回车搜索
  411. const keydown_onSearch = async (event) => {
  412. if(event.keyCode === 13){
  413. onSearch();
  414. }
  415. }
  416. /**
  417. * 新增次品
  418. */
  419. const dialogFormVisible = ref(false);
  420. const DefectiveformData = reactive({
  421. Sys_rq: '' ,
  422. bgxz: '裁剪01z组'
  423. });
  424. const rule = {}; // 表单验证规则(如果有)
  425. const GROUP_OPTIONS = [
  426. { value: '裁剪01组', label: '裁剪01组' },
  427. { value: '裁剪02组', label: '裁剪02组' },
  428. { value: '裁剪03组', label: '裁剪03组' },
  429. { value: '裁剪04组', label: '裁剪04组' }
  430. ];
  431. const SecondarytabeleData = reactive([
  432. {
  433. ddbh: '', // 订单编号
  434. material: '', // 面料分类
  435. colorOptions: [], // 颜色
  436. ks: '', // 款式
  437. defectiveQuantity: '', // 次片数量
  438. issueOptions: [], // 次片问题(下拉框选项)
  439. remark: '', // 备注
  440. group: '裁剪01组', // 报工小组
  441. },
  442. ]);
  443. // 定义初始行数据
  444. const initialRowData = () => ({
  445. ddbh: '', // 订单编号
  446. material: '', // 面料分类
  447. colorOptions: [], // 颜色
  448. ks: '', // 款式
  449. defectiveQuantity: '', // 次片数量
  450. issueOptions: [], // 次片问题(下拉框选项)
  451. remark: '', // 备注
  452. group: '裁剪01组', // 报工小组
  453. });
  454. // 方法:新增一行
  455. const addRow = () => {
  456. SecondarytabeleData.push({
  457. ddbh: '', // 订单编号
  458. material: '', // 面料分类
  459. colorOptions: [], // 颜色
  460. ks: '', // 款式
  461. defectiveQuantity: '', // 次片数量
  462. issueOptions: [], // 次片问题(下拉框选项)
  463. remark: '', // 备注
  464. group: '裁剪01组', // 报工小组
  465. });
  466. };
  467. const type = ref('create'); // 弹窗类型,默认为 'create'
  468. //新增按钮
  469. const onAdd = async () => {
  470. type.value = 'create'
  471. dialogFormVisible.value = true
  472. DefectiveformData.Sys_rq = currentDates
  473. }
  474. // 键盘事件
  475. const ent1 = (event, index) => {
  476. // 处理键盘事件
  477. console.log(event, index);
  478. };
  479. const searchOrder = async (query, index) => {
  480. if (!query.trim()) {
  481. SecondarytabeleData[index].ddbhOptions = [];
  482. return;
  483. }
  484. try {
  485. const response = await Apiorder({ search: query }); // 根据实际接口调整参数
  486. if (response.code === 0) {
  487. SecondarytabeleData[index].ddbhOptions = response.data.list.map(item => ({
  488. value: `${item.订单编号}---${item.生产款号}`, // 格式与之前一致
  489. label: `${item.订单编号}---${item.生产款号}`,
  490. rawData: item, // 保存原始数据,供后续使用
  491. }));
  492. } else {
  493. ElMessage.error(response.msg || '搜索失败');
  494. }
  495. } catch (error) {
  496. ElMessage.error('搜索接口异常');
  497. }
  498. };
  499. const handleOrderSelect = (value, index) => {
  500. if (!value) return;
  501. const row = SecondarytabeleData[index];
  502. const selectedOption = row.ddbhOptions.find(opt => opt.value === value);
  503. if (selectedOption) {
  504. // 调用原来的 getGxMcsubmit 逻辑(需稍作调整)
  505. getGxMcsubmit(selectedOption.rawData, index);
  506. }
  507. };
  508. // 工单编号|款号回车事件
  509. const getGxMcsubmit = async (event, index) => {
  510. const row = SecondarytabeleData[index]; // 获取当前行数据
  511. const ddbh = row.ddbh.split('---')[0]; // 获取输入的工单编号
  512. if (!ddbh) {
  513. ElMessage.warning('请输入工单编号');
  514. return;
  515. }
  516. try {
  517. // 调用接口获取数据
  518. const response = await queryOrderSize({ 订单编号: ddbh });
  519. if (response.code === 0) {
  520. const { list, fetchCategory, colorremark, FabricData, 面料统计 } = response.data;
  521. // 更新当前行的数据
  522. row.ddbh = `${list.订单编号}---${list.生产款号}`;
  523. row.ks = list.款式;
  524. // 更新下拉框选项
  525. row.colorOptions = colorremark.map(item => ({ value: item, label: item })); // 颜色选项
  526. row.issueOptions = fetchCategory.次片.map(item => ({ value: item, label: item })); // 次片问题选项
  527. row.materialOptions = FabricData.map(item => ({ value: item, label: item }));
  528. row.groupOptions = GROUP_OPTIONS;// 报工小组选项
  529. // 保存面料统计数据
  530. row.fabricStats = 面料统计;
  531. ElMessage.success('数据加载成功');
  532. } else {
  533. ElMessage.error(response.msg || '接口返回错误');
  534. }
  535. } catch (error) {
  536. ElMessage.error('接口调用失败,请稍后重试');
  537. }
  538. };
  539. // 关闭弹窗
  540. const closeDialog = () => {
  541. SecondarytabeleData.splice(0, SecondarytabeleData.length, initialRowData());
  542. dialogFormVisible.value = false;
  543. };
  544. // 提交确认
  545. const enterDialog = async () => {
  546. console.log('确认提交', SecondarytabeleData);
  547. // 获取面料统计数据
  548. const fabricStats = SecondarytabeleData[0]?.fabricStats || [];
  549. console.log('fabricStats', fabricStats);
  550. const params = SecondarytabeleData.map(item => {
  551. // 查找匹配的面料数据
  552. console.log('物料名称', item['material'].split('-')[1]);
  553. console.log('颜色', item.color);
  554. const matchedFabric = fabricStats.find(f =>
  555. f.颜色 === item.color && f.物料名称 === item['material'].split(' - ')[1]
  556. );
  557. console.log('匹配统计数据', matchedFabric);
  558. return {
  559. 订单编号: item['ddbh'].split('---')[0],
  560. 生产款号: item['ddbh'].split('---')[1],
  561. 款式: item['ks'],
  562. 颜色: item['color'],
  563. 数量: item['defectiveQuantity'],
  564. 备注: item['remark'],
  565. Sys_id: userStore.userInfo.nickName,
  566. 组别: ReworkTeam['zb'],
  567. Sys_rq: currentDates,
  568. sczl_rq: currentDate,
  569. 状态: '次片',
  570. 问题分类: item['issue'],
  571. 尺码: '',
  572. 实际用料: matchedFabric ? matchedFabric.实际用料 : '',
  573. 计划用料: matchedFabric ? matchedFabric.计划用料 : '',
  574. 物料名称: item['material'],
  575. };
  576. });
  577. console.log('提交参数', params);
  578. try {
  579. // 在这里执行提交逻辑
  580. const ApiAddDefectiveRes = await ApiAddDefective(params);
  581. if (ApiAddDefectiveRes.code === 0) {
  582. ElMessage.success('提交成功');
  583. getTabdata();//刷新左侧数据
  584. handleNodeClick(noderq.value);//刷新右侧数据
  585. closeDialog(); // 关闭弹窗
  586. } else {
  587. ElMessage.error(ApiAddDefectiveRes.msg || '接口返回错误');
  588. }
  589. } catch (error) {
  590. ElMessage.error('提交失败,请稍后重试');
  591. }
  592. };
  593. // 复制行
  594. const copyRow = (index) => {
  595. const copiedRow = { ...SecondarytabeleData[index] };
  596. SecondarytabeleData.splice(index + 1, 0, copiedRow);
  597. };
  598. // 移除行
  599. const removeRow = (index) => {
  600. SecondarytabeleData.splice(index, 1);
  601. }
  602. const OrderdetailsdialogFormVisible = ref(false);
  603. const Orderdetailsdata = reactive([]);
  604. //查看单号详情
  605. const Order_detailsRow = async (row, index) => {
  606. console.log('查看详情', row.Sys_rq, index);
  607. OrderdetailsdialogFormVisible.value = true
  608. const response = await ApiSubPieceAndReworkList({
  609. search: row.单据编号,
  610. Sys_rq: row.Sys_rq,
  611. page: 1,
  612. limit: 50,
  613. code: '次片'
  614. });
  615. if (response.code === 0 && response.data?.data) {
  616. // 清空并更新表格数据
  617. Orderdetailsdata.splice(0, Orderdetailsdata.length, ...response.data.data);
  618. } else {
  619. ElMessage.warning(response.msg || '暂无数据');
  620. Orderdetailsdata.splice(0, Orderdetailsdata.length);
  621. }
  622. }
  623. //关闭
  624. const Orderdetails_closeDialog = () => {
  625. OrderdetailsdialogFormVisible.value = false;
  626. }
  627. //导出
  628. const exportExcel = () => {
  629. const el = document.getElementById('table');
  630. const filename = '导出次片汇总EXCEL.xlsx';
  631. // 获取表格数据
  632. const ws = XLSX.utils.table_to_sheet(el);
  633. // 找出需要保留为数字的列(假设'sl'列是数字)
  634. const numCols = ['数量']; // 添加其他需要保留数字的列名
  635. // 遍历工作表数据,将指定列转换为数字
  636. for (const cell in ws) {
  637. if (cell[0] === '!') continue; // 跳过特殊属性
  638. const colName = cell.replace(/[0-9]/g, ''); // 获取列字母
  639. const header = ws[colName + '1']; // 获取表头
  640. if (header && numCols.includes(header.v)) {
  641. // 如果是数字列,尝试转换为数字
  642. const value = ws[cell].v;
  643. if (!isNaN(value) && value !== '') {
  644. ws[cell].t = 'n'; // 设置为数字类型
  645. ws[cell].v = Number(value); // 转换为数字
  646. }
  647. }
  648. }
  649. // 创建工作簿并导出
  650. const wb = XLSX.utils.book_new();
  651. XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
  652. try {
  653. XLSX.writeFile(wb, filename);
  654. } catch (e) {
  655. console.log(e);
  656. }
  657. }
  658. const exportExcel2 = () => {
  659. const filename = '裁剪次片汇总报工页面表.xlsx';
  660. console.log('导出数据', exceltableData);
  661. // 获取 el-table 的列配置
  662. const columns = [
  663. { label: "单据编号", prop: "单据编号" },
  664. { label: "订单编号", prop: "订单编号" },
  665. { label: "生产款号", prop: "生产款号" },
  666. { label: "面料分类", prop: "面料分类" },
  667. { label: "面料名称", prop: "面料名称" },
  668. { label: "颜色", prop: "颜色" },
  669. { label: "款式", prop: "款式" },
  670. { label: "次片数量", prop: "数量" },
  671. // { label: "计划用料", prop: "计划用料" },
  672. // { label: "实际用料", prop: "实际用料" },
  673. { label: "次片分类", prop: "问题分类" },
  674. { label: "备注", prop: "备注" },
  675. { label: "报工小组", prop: "组别" },
  676. // { label: "操作人员", prop: "Sys_id" },
  677. // { label: "创建时间", prop: "Sys_rq" }
  678. ];
  679. // 创建表头映射对象
  680. const headerMap = {};
  681. columns.forEach(col => {
  682. headerMap[col.prop] = col.label;
  683. });
  684. // 重新映射数据,确保顺序和表头一致
  685. const remappedData = exceltableData.map(item => {
  686. const newItem = {};
  687. columns.forEach(col => {
  688. newItem[col.label] = item[col.prop];
  689. });
  690. return newItem;
  691. });
  692. // 获取表格数据
  693. const ws = XLSX.utils.json_to_sheet(remappedData);
  694. // 找出需要保留为数字的列
  695. const numCols = ['数量']; // 添加其他需要保留数字的列名
  696. // 遍历工作表数据,将指定列转换为数字
  697. for (const cell in ws) {
  698. if (cell[0] === '!') continue; // 跳过特殊属性
  699. const colName = cell.replace(/[0-9]/g, ''); // 获取列字母
  700. const header = ws[colName + '1']; // 获取表头
  701. if (header && numCols.some(numCol => headerMap[numCol] === header.v)) {
  702. // 如果是数字列,尝试转换为数字
  703. const value = ws[cell].v;
  704. if (!isNaN(value) && value !== '') {
  705. ws[cell].t = 'n'; // 设置为数字类型
  706. ws[cell].v = Number(value); // 转换为数字
  707. }
  708. }
  709. }
  710. // 创建工作簿并导出
  711. const wb = XLSX.utils.book_new();
  712. XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
  713. try {
  714. XLSX.writeFile(wb, filename);
  715. } catch (e) {
  716. console.log(e);
  717. }
  718. }
  719. </script>
  720. <style>
  721. .JKWTree-container {
  722. display: flex;
  723. }
  724. .JKWTree-tree {
  725. width: 300px;
  726. background-color: #fff;
  727. padding: 10px;
  728. margin-right: 20px;
  729. }
  730. .JKWTree-tree h3 {
  731. font-size: 15px;
  732. font-weight: 700;
  733. margin: 10px 0;
  734. }
  735. .JKWTree-content {
  736. flex: 1;
  737. }
  738. /* 选中某行时的背景色*/
  739. .el-table__body tr.current-row>td {
  740. background: #ff80ff !important;
  741. /* 背景颜色 */
  742. }
  743. </style>
  744. <style scoped>
  745. :deep(.el-table td .cell) {
  746. line-height: 20px !important;
  747. }
  748. :deep(.el-tabs__header){
  749. margin-bottom: 0;
  750. }
  751. .search{
  752. margin-left: 0px !important;
  753. margin-right: 10px !important;
  754. }
  755. .bt{
  756. margin-left: 2px !important;
  757. padding: 3px !important;
  758. font-size: 12px;
  759. }
  760. .el-tabs__header{
  761. margin: 0px !important;
  762. }
  763. .gva-table-box{
  764. padding: 0px !important;
  765. }
  766. .mab{
  767. margin-bottom: 5px;
  768. }
  769. </style>