Browse Source

修改原始数据

zhangafei 3 weeks ago
parent
commit
7a1dafd210
1 changed files with 215 additions and 70 deletions
  1. 215 70
      src/views/billet/operator/components/printOriginalRecords.vue

+ 215 - 70
src/views/billet/operator/components/printOriginalRecords.vue

@@ -13,6 +13,7 @@
       ref="print"
       style="padding: 10px 10px 0; position: relative; border: 1px solid #c5c5c5; background: #fff; width: 100%; height: 100%"
       id="printBilletSampleCard"
+      :key="printKey"
     >
       <div class="ticket next-ticket">
         <div style="text-align: center">
@@ -23,7 +24,7 @@
         <div class="flex ccmno-info" style="line-height: 24px">
           <div class="flex-1"> 班组:<component :is="renderDictTag(shiftInfo.shiftGroup, 'lg_bz')" /> </div>
           <div class="flex-1"> 班次:<component :is="renderDictTag(shiftInfo.shift, 'lg_bb')" /> </div>
-          <div class="flex-1"> 定尺: </div>
+          <div class="flex-1 flex"><span> 定尺:</span><a-input v-model:value="mainSize" style="flex: 1" :bordered="false" size="small" /> </div>
           <div class="flex-1" style="text-align: center; font-size: 13px">
             {{ dayjs(curTime).format('YYYY 年 MM 月 DD 日') }}
           </div>
@@ -38,8 +39,10 @@
               <a-table-summary-cell :col-span="weightColSpan" style="text-align: center"> 产量(吨) </a-table-summary-cell>
             </a-table-summary-row>
             <a-table-summary-row class="summary-row-no-border">
-              <a-table-summary-cell :col-span="remakeColSpan">
-                <div class="summary-cell-remark"></div>
+              <a-table-summary-cell :row-span="2" :col-span="remakeColSpan">
+                <div class="summary-cell-remark">
+                  <a-textarea v-model:value="mainRemark" style="min-height: 160px" :bordered="false" />
+                </div>
               </a-table-summary-cell>
               <a-table-summary-cell :row-span="1" :col-span="1"> 热送 </a-table-summary-cell>
               <a-table-summary-cell :row-span="1" :col-span="sizeColSpan - 1">
@@ -66,9 +69,9 @@
               </a-table-summary-cell>
             </a-table-summary-row>
             <a-table-summary-row>
-              <a-table-summary-cell :col-span="remakeColSpan">
+              <!-- <a-table-summary-cell :col-span="remakeColSpan">
                 <div class="summary-cell-remark"></div>
-              </a-table-summary-cell>
+              </a-table-summary-cell> -->
               <a-table-summary-cell :row-span="1" :col-span="1"> 堆垛 </a-table-summary-cell>
               <a-table-summary-cell :row-span="1" :col-span="sizeColSpan - 1">
                 <div class="song-items flex">
@@ -174,7 +177,7 @@
   import type { TableColumnsType } from 'ant-design-vue';
   import { queryBilletRecordByCcmNo, editBilletRecord } from '../operator.api';
   import { render } from '/@/utils/common/renderUtils';
-  import { isNumber } from '/@/utils/is';
+  import { isArray, isNumber } from '/@/utils/is';
   import Icon from '/@/components/Icon';
   import { Input, Select } from 'ant-design-vue';
   import { throttle } from 'lodash-es';
@@ -182,6 +185,7 @@
   import { initDictOptions } from '/@/utils/dict';
 
   const { createMessage } = useMessage();
+  const printKey = ref(dayjs().unix());
   // 渲染字典标签
   const renderDictTag = (value: string, dictCode: string) => {
     return render.renderDict(value, dictCode);
@@ -284,7 +288,12 @@
             if (!record.heatNo) {
               return '';
             }
-            return h(Input, { class: 'total-input', size: 'small', bordered: false, value: text, onBlur: (e) => handleTotalChange(e, record) }, '');
+            const allCount = handleTotalSum(record.orgData);
+            return h(
+              Input,
+              { class: 'total-input', size: 'small', bordered: false, value: allCount, onBlur: (e) => handleTotalChange(e, record) },
+              ''
+            );
           },
         },
       ],
@@ -305,22 +314,40 @@
               class: 'noprint',
               onClick: () => {
                 console.log('点击了');
-                const rollOnrColumn = columns.value.find((item: any) => item.dataIndex === 'rollOne');
-                let newSize = '';
+                const rollOnrColumn: any = columns.value.find((item: any) => item.dataIndex === 'rollOne');
+                let newSize: string | number = '';
                 rollOnrColumn.children.push({
                   title: () => {
                     return h(
-                      Select,
+                      // Select,
+                      Input,
                       {
-                        options: sizeListOPtions.value,
+                        // options: sizeListOPtions.value,
                         bordered: false,
-                        dropdownStyle: {
-                          minWidth: '80px',
-                        },
+                        // dropdownStyle: {
+                        //   minWidth: '80px',
+                        // },
                         defaultValue: '',
-                        onChange: (value) => {
-                          newSize = value;
+                        style: {
+                          padding: 0,
+                          textAlign: 'center',
                         },
+                        // onChange: (value) => {
+                        //   newSize = value;
+                        // },
+                        onBlur: throttle((e) => {
+                          if (e.target.value.trim() === '') {
+                            createMessage.error('请输入定尺');
+                            return;
+                          }
+                          const size = Number(e.target.value.trim());
+                          if (!isNumber(size)) {
+                            createMessage.error('请输入数字');
+                            return;
+                          }
+
+                          newSize = size <= 20 ? size * 1000 : size;
+                        }, 500),
                       },
                       ''
                     );
@@ -366,6 +393,7 @@
   const sizeListOPtions = ref([]);
   const [registerModal, { changeOkLoading, changeLoading }] = useModalInner(async (data) => {
     const { ccmNo, shiftText, queryType, curShiftInfo, changeShiftId, time } = data;
+    printKey.value = dayjs().unix();
 
     hostNumber.value = ccmNo;
     fetchQueryType.value = queryType;
@@ -402,8 +430,8 @@
     });
 
     // 获取定尺啊
-    initDictOptions('lg_dcgg').then((res) => {
-      sizeListOPtions.value = (res || []).map((item) => {
+    initDictOptions('lg_dcgg').then((dc) => {
+      sizeListOPtions.value = (dc || []).map((item) => {
         return {
           label: Number(item.value) / 1000,
           value: item.value,
@@ -431,21 +459,26 @@
   // 产量
   const weightColSpan = ref(4);
   // 热送统计
-  const hotSendList = ref({});
+  const hotSendList = ref<any>({});
   // 堆垛统计
-  const stackingList = ref([]);
+  const stackingList = ref<any>([]);
+  // 定尺和备注
+  const mainSize = ref('');
+  const mainRemark = ref('');
   const getHeatList = async (params) => {
     try {
       changeLoading(true);
-      const res = await queryBilletRecordByCcmNo(params);
+      const { billetOriginalProductRecordList, content, sizeInfo } = await queryBilletRecordByCcmNo(params);
       let newArr: any[] = [];
-      if (res && Array.isArray(res)) {
+      mainSize.value = sizeInfo;
+      mainRemark.value = content;
+      if (billetOriginalProductRecordList && Array.isArray(billetOriginalProductRecordList)) {
         // 根据时间排序
-        newArr = res.sort((a, b) => {
+        newArr = billetOriginalProductRecordList.sort((a, b) => {
           return dayjs(a.createTime).isBefore(dayjs(b.createTime)) ? -1 : 1;
         });
 
-        let sizeColumn: string[] = [];
+        let sizeColumn: string | number[] = [];
         let sizeHeadContent = {};
         // 棒一
         const rollOneColumns: TableColumnsType = [];
@@ -475,22 +508,40 @@
                   },
                   class: 'noprint',
                   onClick: () => {
-                    const rollOnrColumn = columns.value.find((item: any) => item.dataIndex === 'stackLength');
-                    let newSize = '';
+                    const rollOnrColumn: any = columns.value.find((item: any) => item.dataIndex === 'stackLength');
+                    let newSize: string | number = '';
                     rollOnrColumn.children.push({
                       title: () => {
                         return h(
-                          Select,
+                          // Select,
+                          Input,
                           {
-                            options: sizeListOPtions.value,
+                            //   options: sizeListOPtions.value,
                             bordered: false,
-                            dropdownStyle: {
-                              minWidth: '80px',
-                            },
-                            defaultValue: '',
-                            onChange: (value) => {
-                              newSize = value;
+                            //   dropdownStyle: {
+                            //     minWidth: '80px',
+                            //   },
+                            style: {
+                              padding: '0px',
+                              textAlign: 'center',
                             },
+                            defaultValue: ' ',
+                            // onChange: (value) => {
+                            //   newSize = value;
+                            // },
+                            onBlur: throttle((e) => {
+                              if (e.target.value.trim() === '') {
+                                createMessage.error('请输入定尺');
+                                return;
+                              }
+                              const size = Number(e.target.value.trim());
+                              if (!isNumber(size)) {
+                                createMessage.error('请输入数字');
+                                return;
+                              }
+
+                              newSize = size <= 20 ? size * 1000 : size;
+                            }, 500),
                           },
                           ''
                         );
@@ -523,7 +574,7 @@
         };
         dataSource.value = dataSource.value.map((item, index) => {
           if (!newArr[index]) return item;
-          const { lengthDetails, hotChargeLength, rollClubOneDetails, stackLength } = newArr[index];
+          const { hotChargeLength, rollClubOneDetails, stackLength } = newArr[index];
 
           // 棒一
           let rollOneNum = '';
@@ -547,17 +598,26 @@
                     title: () => {
                       return h('div', { class: 'rollOneColumnWrapper' }, [
                         h(
-                          Select,
+                          // Select,
+                          Input,
                           {
-                            options: sizeListOPtions.value,
+                            // options: sizeListOPtions.value,
                             bordered: false,
-                            dropdownStyle: {
-                              minWidth: '80px',
-                            },
-                            defaultValue: column,
-                            onChange: (value) => {
-                              switchSizehandler(value, column);
+                            // dropdownStyle: {
+                            //   minWidth: '80px',
+                            // },
+                            style: {
+                              padding: '0px',
+                              textAlign: 'center',
                             },
+                            defaultValue: Number(column) > 20 ? Number(column) / 1000 : column,
+                            // onChange: (value) => {
+                            //   switchSizehandler(value, column);
+                            // },
+                            onBlur: throttle((e) => {
+                              const value = Number(e.target.value) < 20 ? Number(e.target.value) * 1000 : Number(e.target.value);
+                              switchSizehandler(value, Number(column));
+                            }, 500),
                           },
                           ''
                         ),
@@ -683,17 +743,26 @@
                   title: () => {
                     return h('div', { class: 'rollOneColumnWrapper' }, [
                       h(
-                        Select,
+                        // Select,
+                        Input,
                         {
-                          options: sizeListOPtions.value,
+                          // options: sizeListOPtions.value,
                           bordered: false,
-                          dropdownStyle: {
-                            minWidth: '80px',
-                          },
-                          defaultValue: sSize,
-                          onChange: (value) => {
-                            switchStackhandler(value, sSize);
+                          // dropdownStyle: {
+                          //   minWidth: '80px',
+                          // },
+                          style: {
+                            padding: '0px',
+                            textAlign: 'center',
                           },
+                          defaultValue: Number(sSize) > 20 ? Number(sSize) / 1000 : sSize,
+                          // onChange: (value) => {
+                          //   switchSizehandler(value, column);
+                          // },
+                          onBlur: throttle((e) => {
+                            const value = Number(e.target.value) < 20 ? Number(e.target.value) * 1000 : Number(e.target.value);
+                            switchStackhandler(value, Number(sSize));
+                          }, 500),
                         },
                         ''
                       ),
@@ -745,7 +814,7 @@
             sevenFlow: newArr[index].sevenStrandSum || '',
             eightFlow: newArr[index].eightStrandSum || '',
             total: newArr[index].amount || '',
-            rollOne: rollOneNum,
+            rollOneOld: rollOneNum,
             ...sizeArr,
             ...rollOneSizesObj,
             ...stackSizeData,
@@ -799,9 +868,12 @@
         // 添加空白列
         otherColumn.push(stackLengthColumn);
         columns.value = [...defaultColumns, ...otherColumn];
-        if (rollOneColumns.length) {
-          columns.value[4].children = rollOneColumns;
-        }
+        (columns.value[4] as any).children = rollOneColumns.length ? rollOneColumns : [];
+        // if (rollOneColumns.length) {
+        //   columns.value[4].children = rollOneColumns;
+        // } else {
+        //   columns.value[4].children = [];
+        // }
         const allSpan = 12 + rollOneColumns.length + otherColumn.length + stackLengthColumn.children.length;
         remakeColSpan.value = Math.ceil(allSpan / 3);
         const nnColSpan = Math.ceil((allSpan - remakeColSpan.value) / 2);
@@ -893,8 +965,8 @@
       return;
     }
     const val = Number(e.target.value);
-    if (!isNumber(val)) {
-      createMessage.error('请输入大于0的数字');
+    if (!isNumber(val) || val < 0) {
+      createMessage.error('请输入大于或等于0的数字');
       return;
     }
 
@@ -920,22 +992,63 @@
       } else {
         obj.lengthGroupCount[size] = val;
       }
-      handleEdit({
+
+      const params = {
         ...orgData,
         rollClubOneDetails: JSON.stringify(obj),
+      };
+      const amount = handleTotalSum(params);
+      handleEdit({
+        ...params,
+        amount,
       });
     }
   }, 800);
 
+  // 计算总数
+  const handleTotalSum = (record) => {
+    const { rollClubOneDetails, stackLength, hotChargeLength } = record;
+    let allCount = 0;
+    if (rollClubOneDetails) {
+      const sendObj = JSON.parse(rollClubOneDetails);
+      if (sendObj.lengthGroupCount) {
+        Object.keys(sendObj.lengthGroupCount).forEach((key) => {
+          allCount += sendObj.lengthGroupCount[key];
+        });
+      }
+    }
+
+    if (stackLength) {
+      const stackObj = JSON.parse(stackLength);
+      if (isArray(stackObj)) {
+        stackObj.forEach((item) => {
+          allCount += item.stackingCount;
+        });
+      }
+    }
+
+    if (hotChargeLength) {
+      const chargeObj = JSON.parse(hotChargeLength);
+      if (isArray(chargeObj)) {
+        chargeObj.forEach((item) => {
+          allCount += item.totalCount;
+        });
+      }
+    }
+
+    return allCount;
+  };
+
   // 修改堆垛定尺数量
   const handleStackChange = throttle((e: any, record, size) => {
+    if (e.target.value.trim() === '') return;
     if (!size) {
       createMessage.error('请选择定尺');
       return;
     }
     const val = Number(e.target.value);
     if (!isNumber(val)) {
-      createMessage.error('请输入大于0的数字');
+      createMessage.error('请输入大于等于0的数字');
       return;
     }
 
@@ -947,6 +1060,20 @@
     }
 
     const lengthGroupCount = obj.findIndex((v) => v.stackingLength == size);
+
+    // 计算补的数量是不是4的倍数
+    let stackInfo: any = null;
+    const buCount = lengthGroupCount > -1 ? val - obj[lengthGroupCount].stackingCount : val;
+    if (buCount && buCount > 0) {
+      if (buCount % 4 !== 0) {
+        createMessage.error('补数量必须是4的倍数');
+        return;
+      }
+      stackInfo = buCount + '-' + size + '-10';
+    } else {
+      stackInfo = null;
+    }
+
     if (lengthGroupCount === -1) {
       obj.push({
         stackingCount: val,
@@ -959,9 +1086,15 @@
       obj[lengthGroupCount].stackingWeight = val * (Number(size) / 1000) * 0.2265;
     }
 
-    handleEdit({
+    const params = {
       ...orgData,
       stackLength: JSON.stringify(obj),
+      stackInfo,
+    };
+    const amount = handleTotalSum(params);
+    handleEdit({
+      ...params,
+      amount,
     });
   }, 800);
 
@@ -1014,8 +1147,9 @@
 
   // 堆垛编辑定尺
   const switchStackhandler = async (val, oldSize) => {
+    console.log(val, oldSize);
     try {
-      // changeLoading(true);
+      changeLoading(true);
       const fetchArr: any[] = [];
       dataSource.value.forEach((item) => {
         if (item.heatNo && item.orgData) {
@@ -1078,10 +1212,16 @@
                 delete obj.lengthGroupCount[size];
 
                 // 请求push了
+                const params = {
+                  ...item.orgData,
+                  rollClubOneDetails: JSON.stringify(obj),
+                };
+
+                const amount = handleTotalSum(params);
                 fetchArr.push(
                   editBilletRecord({
-                    ...item.orgData,
-                    rollClubOneDetails: JSON.stringify(obj),
+                    ...params,
+                    amount,
                   })
                 );
               }
@@ -1117,15 +1257,21 @@
           const { stackLength } = item.orgData;
           if (stackLength) {
             const obj = JSON.parse(stackLength);
-            const hasStackItem = obj.findIndex((n) => n.stackingLength === size);
+            const hasStackItem = obj.findIndex((n) => n.stackingLength == size);
             if (hasStackItem > -1) {
-              const lengthGroupCount = obj.filter((m) => m.stackingLength !== size);
+              const lengthGroupCount = obj.filter((m) => m.stackingLength != size);
 
               // 请求push了
+              const params = {
+                ...item.orgData,
+                stackLength: JSON.stringify(lengthGroupCount),
+              };
+
+              const amount = handleTotalSum(params);
               fetchArr.push(
                 editBilletRecord({
-                  ...item.orgData,
-                  stackLength: JSON.stringify(lengthGroupCount),
+                  ...params,
+                  amount,
                 })
               );
             }
@@ -1141,9 +1287,8 @@
           queryType: fetchQueryType.value,
           changeShiftId: fetchChangeShiftId.value,
         });
-
-        changeLoading(false);
       }
+      changeLoading(false);
     } catch (error) {
       changeLoading(false);
       console.log(error);
@@ -1300,7 +1445,7 @@
           .ant-table-summary > tr > td {
             padding: 2px;
             border-inline-end: 1px solid rgba(0, 0, 0, 0.6);
-            border-bottom: 1px solid rgba(0, 0, 0, 0.6);
+            border-bottom: 1px solid rgba(0, 0, 0, 0.6) !important;
             text-align: center;
             position: relative;
           }