liaolijun 2 месяцев назад
Родитель
Сommit
f0eb1cab06

+ 1 - 1
cors.js

@@ -205,7 +205,7 @@ module.exports = {
       }
     }
   },
-  // devModules: ['index', 'reportForm','workFlow', 'systemConfig', 'demo', 'taskManagement', 'batchManagement', 'programManagement', 'entrustedManagement', 'screeningTests','sampleManagement', 'sampleManager', 'samplePreparationTask','approveManagement','weightingManagement','testAnalysis','decideManagement','commodityInspection', 'exceptionManagement', 'certificateManagement', 'standardManagement', 'resourceManager']
+  // devModules: ['index', 'entrustedManagement','approveManagement']
   //devModules: ['reportForm', 'screeningTests', 'index',  'entrustedManagement','measurementDataManagement', 'approveManagement', 'testAnalysis', 'resourceManager', 'taskManagement']
    devModules: ['all']
   //  devModules:['index']

+ 152 - 86
src/views/approveManagement/components/fourApprove.vue

@@ -1,8 +1,8 @@
-<!-- 四级审核页面 -->
+<!-- 四级审核页面:动态获取表格字段、正则表达式 -->
 <template>
   <div class="examination secondApprove">
     <div class="common-head-search">
-      <el-form :inline="true" :model="search" ref="search" :rules="rules">
+      <el-form :inline="true" :model="search" ref="search">
         <el-form-item label="检验车间" prop="deptNo">
           <el-select v-model="search.deptNo" filterable clearable style="width: 140px" @clear="clearSelect"
             @change="selectClass" size="small">
@@ -57,18 +57,6 @@
           <el-date-picker v-model="search.times[1]" value-format="yyyy-MM-dd" format="yyyy-MM-dd" type="date"
             placeholder="结束日期" size="mini" style="width: 140px" :default-time="'23:59:59'">
           </el-date-picker>
-          <!-- <el-date-picker
-            v-model="search.times"
-            type="daterange"
-            range-separator="至"
-            start-placeholder="开始日期"
-            end-placeholder="结束日期"
-            size="small"
-            style="width: 300px"
-            format="yyyy-MM-dd"
-            value-format="yyyy-MM-dd"
-          >
-          </el-date-picker> -->
         </el-form-item>
         <el-form-item>
           <el-button icon="el-icon-search" type="goon" size="mini" :disable="disSearch" @click="searchData"
@@ -377,10 +365,15 @@
                         <span @click.stop="
                           showDataSource(scope.row, scope.row[col])
                           " style="cursor: pointer">
-                          {{
+                          <!-- {{
                             scope.row[col] || scope.row[col] == "0"
                               ? scope.row[col].split("_")[0]
                               : ""
+                          }} -->
+                          {{
+                            scope.row[col] || scope.row[col] == "0"
+                              ? String(scope.row[col]).split('_')[0] || ''
+                              : ""
                           }}
                         </span>
                       </template>
@@ -583,26 +576,26 @@ export default {
         carNo: "",
         sampleTypeCode: "",
         matName: "",
-        times: "",
+        times: [null, null],
         type: ""
       },
-      rules: {
-        times: [
-          {
-            trigger: ['change', 'blur'],
-            validator: (rule, value, callback) => {
-              const startDate = value[0];
-              const endDate = value[1];
-              if (!startDate || !endDate) {
-                return callback(new Error('请选择完整的日期范围'));
-              }
-              if (new Date(startDate) > new Date(endDate)) {
-                return callback(new Error('开始日期不能晚于结束日期'));
-              }
-              callback();
-            }
-          }],
-      },
+      // rules: {
+      //   times: [
+      //     {
+      //       trigger: ['change', 'blur'],
+      //       validator: (rule, value, callback) => {
+      //         const startDate = value[0];
+      //         const endDate = value[1];
+      //         if (!startDate || !endDate) {
+      //           return callback(new Error('请选择完整的日期范围'));
+      //         }
+      //         if (new Date(startDate) > new Date(endDate)) {
+      //           return callback(new Error('开始日期不能晚于结束日期'));
+      //         }
+      //         callback();
+      //       }
+      //     }],
+      // },
       loading: false,
       dialogTableVisible: false,
       dialogEntrustVisible: false,
@@ -688,8 +681,11 @@ export default {
       this.activeName = this.fromDaiban.status == 1 ? "second" : "first";
     } else {
       this.search.times = [
-        this.getYNM(new Date(timestamp)) + " 00:00:00",
-        this.getYNM(new Date()) + " 23:59:59",
+        null, null
+      ];
+      this.search.times = [
+        this.getYNM(new Date(timestamp)),
+        this.getYNM(new Date()),
       ];
     }
 
@@ -860,10 +856,10 @@ export default {
       this.search.sampleNo = "";
       let timestamp = new Date().getTime() - 7 * 24 * 60 * 60 * 1000; // 默认前一周
 
-      this.search.times = [
-        this.getYNM(new Date(timestamp)) + " 00:00:00",
-        this.getYNM(new Date()) + " 23:59:59",
-      ];
+      // this.search.times = [
+      //   this.getYNM(new Date(timestamp)) + " 00:00:00",
+      //   this.getYNM(new Date()) + " 23:59:59",
+      // ];
       this.searchData();
     },
     refresh() { },
@@ -1201,35 +1197,38 @@ export default {
         });
     },
     //查询
+    // searchData() {
+    //   if (this.loading) return;
+    //   this.loading = true;
+    //   this.pageIndex = 1;
+    //   this.pageSize = 500;
+    //   this.pageIndex2 = 1;
+    //   this.pageSize2 = 500;
+    //   try {
+    //     this.dataMainWl11().catch(err => console.error('dataMainWl11失败:', err))
+    //       .then(() => this.dataMainWl21().catch(err => console.error('dataMainWl21失败:', err)))
+    //       .finally(() => this.loading = false);
+    //   } catch (error) {
+    //     console.error('数据加载失败:', error);
+    //     this.loading = false;
+    //   }
+    // },
     searchData() {
       if (this.loading) return;
-      console.log("search  time1......", this.search);
-      // this.$refs['search'].validate((valid) => {
-      // this.loading = true;
-      this.$nextTick(() => {
-        this.$refs['search'].validate((valid) => {
-          if (valid) {
-            try {
-              console.log('表单验证通过.......')
-              this.loading = true;
-              this.pageIndex = 1;
-              this.pageSize = 500;
-              this.pageIndex2 = 1;
-              this.pageSize2 = 500;
-              this.dataMainWl11(),
-                this.dataMainWl21()
-            } catch (error) {
-              console.error('数据加载失败:', error);
-              this.loading = false;
-            } finally {
-              this.loading = false;
-            }
-          } else {
-            console.log('表单验证失败');
-            this.loading = false;
-          }
-        });
-      })
+      try {
+        this.loading = true;
+        this.pageIndex = 1;
+        this.pageSize = 500;
+        this.pageIndex2 = 1;
+        this.pageSize2 = 500;
+        this.dataMainWl11(),
+        this.dataMainWl21()
+      } catch (error) {
+        console.error('数据加载失败:', error);
+        this.loading = false;
+      } finally {
+        this.loading = false;
+      }
     },
     // 车间列表(检测中心下)
     selectDepartment(val) {
@@ -1255,15 +1254,10 @@ export default {
       this.click_main = {};
       this.tableData1 = [];
       this.total_main = 0;
-      // let startTime = "";
-      // let endTime = "";
-      let startTime = this.search.times[0];
-      let endTime = this.search.times[1];
-      if (new Date(startTime) > new Date(endTime)) {
-        this.$message.error('开始时间不能晚于结束时间');
-        this.loading = false;
-        return;
-      }
+      let startTime = null;
+      let endTime = null;
+      startTime = this.search.times[0] === null ? null : (this.search.times[0] + ' 00:00:00')
+      endTime = this.search.times[1] === null ? null : (this.search.times[1] + ' 23:59:59')
       let obj = {
         object: {
           validFlag: "1",
@@ -1286,19 +1280,21 @@ export default {
           { individualType: "json" }
         )
         .then((res) => {
+          console.log('search1    res', res)
           if (res.code == 0 || res.code == 200) {
+            console.log('search1......', res.data);
             this.tableData11 = res.data;
             this.loading = false;
           } else {
             this.loading = false;
-            this.$message.error(res.message);
+            // this.$message.error(res.message);
           }
           this.tableLoading11 = false;
         })
         .catch((err) => {
           this.loading = false;
           this.tableLoading11 = false;
-          this.$message.error(err.message);
+          // this.$message.error(err.message);
         });
     },
     // 已审核物料
@@ -1306,13 +1302,10 @@ export default {
       this.click_main2 = {};
       this.tableData2 = [];
       this.total_main2 = 0;
-      let startTime = this.search.times[0];
-      let endTime = this.search.times[1];
-      if (new Date(startTime) > new Date(endTime)) {
-        this.$message.error('开始时间不能晚于结束时间');
-        this.loading = false;
-        return;
-      }
+      let startTime = null;
+      let endTime = null;
+      startTime = this.search.times[0] === null ? null : (this.search.times[0] + ' 00:00:00')
+      endTime = this.search.times[1] === null ? null : (this.search.times[1] + ' 23:59:59')
       let obj = {
         object: {
           validFlag: "1",
@@ -1336,6 +1329,7 @@ export default {
         )
         .then((res) => {
           if (res.code == 0 || res.code == 200) {
+            console.log('search2......', res.data);
             this.tableData21 = res.data;
             this.loading = false;
           } else {
@@ -1388,7 +1382,7 @@ export default {
         .then((res) => {
           if (res.code == 0 || res.code == 200) {
             this.tableData1 = res.data.data.list;
-            this.cols = res.data.head;
+            this.cols = res.data.head;//如何动态获取表头!!!!
             this.total_main = res.data.data.total;
             if (this.tableData1.length > 0) {
               this.isShowSuppName = res.data.data.list[0].SUPP_NAME
@@ -1411,6 +1405,35 @@ export default {
           this.$message.error(err.message);
         });
     },
+    parseFieldWithBracket(val) {
+      // 初始化返回结果
+      const result = {
+        isValid: false, // 是否整体有效
+        restValue: '',  // 括号后的剩余内容
+        matchedValue: null // 匹配成功的拼接值
+      };
+      if (!val || typeof val !== 'string') {
+        return result;
+      }
+      const reg = /([\d,.]+)\(([\d,.]+)\)/;
+      const match = val.match(reg);
+      if (!match) {
+        return result;
+      }
+      const before = match[1].trim();
+      const inside = match[2].trim();
+
+      const bracketStartIndex = val.indexOf(')') + 1;
+      if (bracketStartIndex > 0) {
+        result.restValue = val.substring(bracketStartIndex);
+      }
+      console.log('val.....', val, 'bracketStartIndex.....', bracketStartIndex, 'restValue.....', result.restValue);
+      const numCheckReg = /^[\d,.]+$/;
+      if (!numCheckReg.test(before) || !numCheckReg.test(inside)) {
+        console.log('包含非数字内容,跳过:', before, inside);
+        return result;
+      }
+    },
     // 已审核数据
     dataMain2() {
       if (!this.click_main2 || !this.click_main2.MAT_NO) {
@@ -1447,7 +1470,50 @@ export default {
         )
         .then((res) => {
           if (res.code == 0 || res.code == 200) {
-            this.tableData2 = res.data.data.list;
+            const processedData = [];
+            const FIELDS = [
+              '质量损失', '外观等级', '样品尺寸:宽',
+              '样品尺寸:长', '样品尺寸:面积', '测试前质量', '测试后质量'
+            ];
+            const checkField = (val) => {
+              if (!val || typeof val !== 'string') return null;
+              const reg = /([\d,.]+)\(([\d,.]+)\)/;
+              const match = val.match(reg);
+              if (!match) return null;
+              const before = match[1].trim();
+              const inside = match[2].trim();
+              // 剩余内容截取
+              // const bracketStartIndex = val.indexOf(')') + 1;
+              // const restValue = bracketStartIndex > 0 ? val.substring(bracketStartIndex) : '';
+              // 数字校验
+              const numCheckReg = /^[\d,.]+$/;
+              if (!numCheckReg.test(before) || !numCheckReg.test(inside)) return null;
+              // 数组匹配
+              const beforeArr = before.split(',').map(item => item.trim());
+              const insideArr = inside.split(',').map(item => item.trim());
+              if (beforeArr.length !== insideArr.length) return null;
+              const isAllMatch = beforeArr.every((item, index) => item === insideArr[index]);
+              return isAllMatch ? beforeArr : null;
+            };
+
+            res.data.data.list.forEach(row => {
+              // 缓存核心字段校验结果:避免重复调用checkField
+              const qualityLossRes = checkField(row['质量损失'] || '');
+              const appearanceGradeRes = checkField(row['外观等级'] || '');
+
+              // 仅满足条件时处理
+              if (qualityLossRes !== null || appearanceGradeRes !== null) {
+                const newRow = { ...row };
+                FIELDS.forEach(field => {
+                  newRow[field] = checkField(row[field] || '');
+                });
+                processedData.push(newRow, { ...newRow });
+              }
+            });
+
+            this.tableData2 = processedData;
+            console.log('tableData2....', this.tableData2)
+            // this.tableData2 = res.data.data.list;
             this.cols2 = res.data.head;
             this.total_main2 = res.data.data.total;
             if (this.tableData2.length > 0) {

+ 3 - 3
src/views/entrustedManagement/components/inspectionMaterials/inspectionMaterialsGit.vue

@@ -915,11 +915,11 @@ export default {
           carNo: this.search.carNo,
           contractNo: this.search.contractNo,
           planNo: this.search.planNo,
-          validFlag: '1',
+          validFlag: '1'
         },
         list: [this.search.testTypeCode],
-        'startTime': this.startTime,
-        'endTime': this.endTime,
+        startTime: this.startTime,
+        endTime: this.endTime,
         pageIndex: this.page.pageNum,
         pageSize: this.page.pageSize
       }

+ 35 - 20
src/views/entrustedManagement/components/inspectionProudects/inspectionProudects.vue

@@ -26,14 +26,25 @@
           <el-input v-model="search.sampleNo" size="small" @keyup.enter.native="searchData()" placeholder="请输入查询内容"
             style="width: 200px; margin-right: 10px" clearable></el-input>
         </el-form-item>
-        <el-form-item label="委托日期">
+        <br/>
+        <el-form-item label="委托开始时间">
           <el-date-picker v-model="search.times[0]" value-format="yyyy-MM-dd" format="yyyy-MM-dd" type="date"
             placeholder="开始日期" size="mini" style="width: 140px">
           </el-date-picker>
-          <span>至</span>
+        </el-form-item>
+        <el-form-item label="委托结束时间">
           <el-date-picker v-model="search.times[1]" value-format="yyyy-MM-dd" format="yyyy-MM-dd" type="date"
             placeholder="结束日期" size="mini" style="width: 140px">
           </el-date-picker>
+        </el-form-item>
+        <!-- <el-form-item label="委托日期">
+          <el-date-picker v-model="search.times[0]" value-format="yyyy-MM-dd" format="yyyy-MM-dd" type="date"
+            placeholder="开始日期" size="mini" style="width: 140px">
+          </el-date-picker>
+          <span>至</span>
+          <el-date-picker v-model="search.times[1]" value-format="yyyy-MM-dd" format="yyyy-MM-dd" type="date"
+            placeholder="结束日期" size="mini" style="width: 140px">
+          </el-date-picker> -->
           <!-- <el-date-picker
             v-model="search.times"
             type="daterange"
@@ -46,7 +57,7 @@
             value-format="yyyy-MM-dd"
           >
           </el-date-picker> -->
-        </el-form-item>
+        <!-- </el-form-item> -->
         <el-form-item>
           <el-button icon="el-icon-search" type="goon" size="mini" @click="searchData">查询</el-button>
           <el-button icon="el-icon-refresh" type="info" plain size="mini" @click="reset">重置</el-button>
@@ -1260,16 +1271,18 @@ export default {
     },
     mainData() {
       (this.saveRow = {}), (this.dataLoading = true);
-      let startTime = "";
-      let endTime = "";
-      if (!this.search.times) {
-        startTime = null;
-        endTime = null;
-      } else {
-        startTime =
-          formatDate(this.search.times[0], "yyyy-MM-dd") + " 00:00:00";
-        endTime = formatDate(this.search.times[1], "yyyy-MM-dd") + " 23:59:59";
-      }
+      let startTime = null;
+      let endTime = null;
+      startTime = this.search.times[0] === null ? null : (this.search.times[0] + ' 00:00:00')
+      endTime = this.search.times[1] === null ? null : (this.search.times[1] + ' 23:59:59')
+      // if (!this.search.times) {
+      //   startTime = null;
+      //   endTime = null;
+      // } else {
+      //   startTime =
+      //     formatDate(this.search.times[0], "yyyy-MM-dd") + " 00:00:00";
+      //   endTime = formatDate(this.search.times[1], "yyyy-MM-dd") + " 23:59:59";
+      // }
       let obj = {
         sampleTypeCode: "480103",
         isBatch: "",
@@ -1318,13 +1331,15 @@ export default {
       (this.saveRow = {}), (this.invalidLoading = true);
       let startTime = "";
       let endTime = "";
-      if (!this.search.times) {
-        startTime = null;
-        endTime = null;
-      } else {
-        startTime = this.search.times[0];
-        endTime = this.search.times[1];
-      }
+      this.startTime = this.search.times[0] === null ? null : (this.search.times[0] + ' 00:00:00')
+      this.endTime = this.search.times[1] === null ? null : (this.search.times[1] + ' 23:59:59')
+      // if (!this.search.times) {
+      //   startTime = null;
+      //   endTime = null;
+      // } else {
+      //   startTime = this.search.times[0];
+      //   endTime = this.search.times[1];
+      // }
       let tempobj = {
         object: {
           sampleTypeCode: "480103",