cropdefective.vue 27 KB

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