From f13d1d01c3c3cbb075e63ae02be54bbb023c13d0 Mon Sep 17 00:00:00 2001
From: charles <981744753@qq.com>
Date: 星期三, 24 七月 2024 16:50:22 +0800
Subject: [PATCH] feat:薪资薪酬核算模块

---
 src/views/productManage/silkRegisterForm/addPage.vue |  426 ++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 309 insertions(+), 117 deletions(-)

diff --git a/src/views/productManage/silkRegisterForm/addPage.vue b/src/views/productManage/silkRegisterForm/addPage.vue
index ba68d9e..df2b635 100644
--- a/src/views/productManage/silkRegisterForm/addPage.vue
+++ b/src/views/productManage/silkRegisterForm/addPage.vue
@@ -30,13 +30,13 @@
                 type="primary"
                 :loading="isAddloading"
                 @click="saveClickOne('form')"
+                :disabled="title==='鏌ョ湅'"
                 >淇濆瓨</el-button
               >
             </template>
           </CommonSearch>
         </div>
       </div>
-
       <div class="body">
         <div class="body-l">
           <el-form
@@ -48,15 +48,17 @@
             label-width="80px"
           >
             <el-form-item label="缂栧彿" prop="number" class="form-item">
-              <el-input v-model="form.number" placeholder="璇疯緭鍏�"> </el-input>
+              <el-input v-model="form.number" :disabled="title=='淇敼'||title=='鏌ョ湅'?true:false" placeholder="璇疯緭鍏�"> </el-input>
             </el-form-item>
             <el-form-item label="钀戒笣鏃堕棿" prop="finishDate" class="form-item">
               <el-date-picker
                 v-model="form.finishDate"
                 value-format="yyyy-MM-dd"
+                :picker-options="pickerOptions"
                 type="date"
                 placeholder="閫夋嫨鏃ユ湡"
                 class="select-width"
+                :disabled='title==="鏌ョ湅"'
               >
               </el-date-picker>
             </el-form-item>
@@ -65,6 +67,8 @@
                 v-model="form.market"
                 placeholder="璇烽�夋嫨"
                 class="select-width"
+                @change="getGroupNumber"
+                :disabled='title==="鏌ョ湅"'
               >
                 <el-option
                   v-for="item in marketList"
@@ -75,18 +79,18 @@
                 </el-option>
               </el-select>
             </el-form-item>
-            <el-form-item label="杞﹂棿" prop="name" class="form-item">
+            <el-form-item label="杞﹂棿" prop="workshopObj" class="form-item">
               <el-select
-                v-model="form.name"
+                v-model="form.workshopObj"
                 placeholder="璇烽�夋嫨"
                 class="select-width"
-              >
+                :disabled='title==="鏌ョ湅"'
+                @change="getGroupNumber('workshopObj')">
                 <el-option
                   v-for="item in nameList"
                   :key="item.ID"
                   :label="item.name"
-                  :value="item.name"
-                >
+                  :value="{ value: item.number, label: item.name }">
                 </el-option>
               </el-select>
             </el-form-item>
@@ -95,6 +99,7 @@
                 v-model="form.spec"
                 placeholder="璇烽�夋嫨"
                 class="select-width"
+                :disabled='title==="鏌ョ湅"'
               >
                 <el-option
                   v-for="item in specList"
@@ -110,15 +115,17 @@
             <el-form-item label="缁勫埆" prop="workshopGroup" class="form-item">
               <el-select
                 v-model="form.workshopGroup"
-                placeholder="璇烽�夋嫨"
+                placeholder="璇峰厛閫夋嫨杞﹂棿"
+                no-data-text="璇峰厛閫夋嫨杞﹂棿"
                 class="select-width"
+                :disabled='title==="鏌ョ湅"'
+                @change="getGroupNumber()"
               >
                 <el-option
                   v-for="item in workshopGroupList"
-                  :key="item.ID"
-                  :label="item.name"
-                  :value="item.ID"
-                >
+                  :key="item"
+                  :label="item"
+                  :value="item">
                 </el-option>
               </el-select>
             </el-form-item>
@@ -137,12 +144,11 @@
                       placeholder="璇疯緭鍏�"
                       show-word-limit
                       class="select-width"
+                      :disabled='title==="鏌ョ湅"'
                     ></el-input>
                   </el-form-item>
                 </el-col>
-                <el-col :span="2" style="margin: 0 auto; text-align: center"
-                  >-</el-col
-                >
+                <el-col :span="2" style="margin: 0 auto; text-align: center">-</el-col>
                 <el-col :span="11">
                   <el-form-item
                     label=""
@@ -155,6 +161,7 @@
                       @input="inputStart"
                       placeholder="璇疯緭鍏�"
                       show-word-limit
+                      :disabled='title==="鏌ョ湅"'
                       class="select-width"
                     ></el-input>
                   </el-form-item>
@@ -162,7 +169,7 @@
               </el-row>
             </el-form-item>
             <el-form-item label="杞﹀彿" prop="position" class="form-item">
-              <el-input v-model.number="form.position" placeholder="璇疯緭鍏�">
+              <el-input disabled v-model.number="form.position" placeholder="璇疯緭鍏ヨ溅鍙�">
               </el-input>
             </el-form-item>
           </el-form>
@@ -171,16 +178,17 @@
                             @selTableCol="selTableCol">
                         </TableCommonView> -->
             <!-- 淇敼涓鸿緭鍏� -->
-            <CommonFormTableView
-              ref="commonFormTableView"
+            <FormTableView
+              ref="formTableView"
               :detail-enter="isView ? true : false"
               :selectBox="false"
               :detailEnter="true"
+              :isBorder="true"
               :show-summary="showSummary"
               :product-table-list="tableList"
               @inputContent="inputContent"
               @addProductClick="addProductClick"
-            ></CommonFormTableView>
+            ></FormTableView>
           </div>
         </div>
         <div class="body-r">
@@ -203,10 +211,10 @@
             type="primary"
             :loading="isAddloading"
             @click="saveClickOne('form')"
-            >淇濆瓨</el-button
-          >
+            :disabled="title==='鏌ョ湅'"
+            >淇濆瓨</el-button>
           <!-- </template>
-</CommonSearch> -->
+          </CommonSearch> -->
         </div>
       </div>
       <div class="body-two body">
@@ -217,25 +225,25 @@
           :model="form"
           :rules="rules"
           label-position="right"
-          label-width="60px"
+          label-width="70px"
         >
           <div class="form-box-t">
-            <el-form-item label="缂栧彿" prop="number" class="form-item">
+            <el-form-item label="缂栧彿锛�" prop="number" class="form-item">
               {{ form.number }}
             </el-form-item>
-            <el-form-item label="杞﹂棿" prop="name" class="form-item">
-              {{ form.name }}
+            <el-form-item label="杞﹂棿锛�" prop="workshopName" class="form-item">
+              {{ form.workshopName }}
             </el-form-item>
-            <el-form-item label="缁勫埆" prop="workshopGroup" class="form-item">
+            <el-form-item label="缁勫埆锛�" prop="workshopGroup" class="form-item">
               {{ form.workshopGroup }}
             </el-form-item>
-            <el-form-item label="鍥炴暟" prop="circle" class="form-item">
+            <el-form-item label="鍥炴暟锛�" prop="circle" class="form-item">
               {{ form.circle }}
             </el-form-item>
-            <el-form-item label="瑙勬牸" prop="spec" class="form-item">
+            <el-form-item label="瑙勬牸锛�" prop="spec" class="form-item">
               {{ form.spec }}
             </el-form-item>
-            <el-form-item label="鏃ユ湡" prop="finishDate" class="form-item">
+            <el-form-item label="鏃ユ湡锛�" prop="finishDate" class="form-item">
               {{ form.finishDate }}
             </el-form-item>
           </div>
@@ -246,8 +254,10 @@
               tooltip-effect="dark"
               style="width: 100%"
               :height="'calc(100% - 0px)'"
+              :header-cell-style="{ background: '#f1f3f8',color: '#000009', 'font-size': '12px', 'font-family': 'PingFangSC' }"
+              border
             >
-              <el-table-column label="杞﹀彿" prop="ID" width="100">
+              <el-table-column label="杞﹀彿" prop="position" width="90">
               </el-table-column>
               <el-table-column
                 label="涓嬪樊绾ゅ害"
@@ -266,6 +276,9 @@
                     show-overflow-tooltip
                     :sortable="item.sortable"
                   >
+                    <template slot-scope="scope">
+                      {{scope.row[item.prop]}}
+                    </template>
                   </el-table-column>
                 </template>
               </el-table-column>
@@ -286,6 +299,9 @@
                     show-overflow-tooltip
                     :sortable="item.sortable"
                   >
+                    <template slot-scope="scope">
+                      {{scope.row[item.prop]}}
+                    </template>
                   </el-table-column>
                 </template>
               </el-table-column>
@@ -295,6 +311,9 @@
                 width="100"
                 align="center"
               >
+                <template slot-scope="scope">
+                  {{scope.row[item.prop]}}
+                </template>
                 <template v-for="(item, i) in tableTwoList.upper">
                   <el-table-column
                     align="center"
@@ -306,6 +325,9 @@
                     show-overflow-tooltip
                     :sortable="item.sortable"
                   >
+                    <template slot-scope="scope">
+                      {{scope.row[item.prop]}}
+                    </template>
                   </el-table-column>
                 </template>
               </el-table-column>
@@ -319,9 +341,17 @@
               </el-table-column>
               <el-table-column prop="finenessGradeye" label="閲庣氦" width="120">
               </el-table-column>
-              <el-table-column prop="finenessGradebig" label="澶ч噹" show-overflow-tooltip>
+              <el-table-column
+                prop="finenessGradebig"
+                label="澶ч噹"
+                show-overflow-tooltip
+              >
               </el-table-column>
-              <el-table-column prop="finenessGradeSpecial" label="鐗归噹" width="120">
+              <el-table-column
+                prop="finenessGradeSpecial"
+                label="鐗归噹"
+                width="120"
+              >
               </el-table-column>
               <el-table-column
                 prop="finenessGrade"
@@ -414,28 +444,33 @@
 </template>
 
 <script>
+// getWorkshopManageList
 import {
   saveRegister,
   getDictList,
-  getWorkshopManageList,
   getRegisterDetails,
+  getCarNumber,
+  getAutoCode
 } from "@/api/productManage/silkRegisterForm.js";
 import {
   getCheckDetails,
   saveCheck,
+    getNewCheckDetails
 } from "@/api/productManage/silkInspectForm.js";
 import pageMixin from "@/components/makepager/pager/mixin/pageMixin";
-import CommonFormTableView from "@/components/makepager/CommonFormTableView";
+//import CommonFormTableView from "@/components/makepager/CommonFormTableView";
+import { getWorkshopManageGroup } from "@/api/productManage/productRegisterForm.js";
+import FormTableView from '@/views/productManage/silkRegisterForm/components/FormTableView.vue';
 export default {
   name: "silkRegisterAddPage",
   props: {},
   mixins: [pageMixin],
   components: {
-    CommonFormTableView,
+      FormTableView,
   },
-  computed: {},
   data() {
     return {
+      title:'',
       loading: false,
       activeName: "first",
       searchOptions: [],
@@ -445,7 +480,9 @@
       workshopGroupList: [], //缁勫埆
       deliveryTypeList: [],
       specList: [], //瑙勬牸
-      form: {},
+      form: {
+          number:''
+      },
       rules: {
         number: [
           { required: true, message: "璇峰~鍐�", trigger: ["change", "blur"] },
@@ -453,8 +490,12 @@
         finishDate: [
           { required: true, message: "璇烽�夋嫨", trigger: ["change", "blur"] },
         ],
+        // 搴勫彛
+        market: [
+          { required: true, message: "璇烽�夋嫨", trigger: ["change", "blur"] },
+        ],
         // 杞﹂棿 搴旇true
-        name: [
+        workshopObj: [
           { required: true, message: "璇烽�夋嫨", trigger: ["change", "blur"] },
         ],
         spec: [
@@ -462,7 +503,7 @@
         ],
         // 缁勫埆 搴旇true
         workshopGroup: [
-          { required: false, message: "璇烽�夋嫨", trigger: ["change", "blur"] },
+          { required: true, message: "璇烽�夋嫨", trigger: ["change", "blur"] },
         ],
         circleTwo: [
           { required: true, message: "璇峰~鍐�", trigger: ["change", "blur"] },
@@ -476,6 +517,12 @@
         position: [
           { required: true, message: "璇峰~鍐�", trigger: ["change", "blur"] },
         ],
+      },
+      pickerOptions: {
+        disabledDate(time) {
+          //return time.getTime() < new Date().getTime() - 86400000;
+            return false;
+        },
       },
       tableTwoList: {
         tableInfomation: [],
@@ -503,7 +550,7 @@
             productId: 1,
             position: null,
             fineness: null,
-            quantity: null,
+            quantity: 0,
             sum: null,
           },
         ],
@@ -513,28 +560,37 @@
             prop: "position",
             inputNumber: true,
             isRequird: true,
+              noOperate:true
           }, // 瀹㈡埛鍚嶇О
           {
             label: "绾ゅ害鍊�",
             prop: "fineness",
             inputNumber: true,
             isRequird: true,
+              noOperate:this.$route.query.title==='鏌ョ湅'
           }, // 閿�鍞礋璐d汉
           {
             label: "鏁伴噺",
             prop: "quantity",
             inputNumber: true,
             isRequird: true,
+              noOperate:true
           }, // 閲嶈绾у埆
           {
             label: "绾ゅ害鍚堣",
             prop: "sum",
-            inputNumber: true,
-            isRequird: true,
           }, // 涓嬫鍥炶鏃ユ湡
         ],
       },
-      tableData: [],
+      tableData: [ 
+        {
+            productId: 1,
+            position: null,
+            fineness: null,
+            quantity: null,
+            sum: null,
+          }
+        ],
       registerId: "",
       inspectID: "",
       isRegisterSave: false,
@@ -546,50 +602,70 @@
       this.activeName = query.activeName ? query.activeName : "first";
       this.registerId = query.id ? query.id : "";
       this.inspectID = query.inspectID ? query.inspectID : "";
+      this.title= query.title ? query.title : "";
     }
     this.getSelectDataList();
     this.keyword = "";
     this.getDetailsData();
   },
   methods: {
-    getDetailsData(id) {
+    async getAutoCode(){
+        const {code,data}=await getAutoCode({type:2});
+        if(code===200){
+            return data.id;
+        }
+        return '';
+    },
+    async getDetailsData(id) {
+      const code= await this.getAutoCode()
       if (this.activeName == "first") {
         this.form = {
-          number: "",
-          finishDate: "",
+          number: code,
+          finishDate:this.$moment(new Date()).format('YYYY-MM-DD'),
           market: "",
-          name: "",
+          workshopObj: "",
           spec: "",
           workshopGroup: "",
           circleTwo: "",
           circle: "",
           totalCircle: "",
           position: "",
-        };
+        }
         if (this.registerId) {
-          getRegisterDetails({ id: id ? id : this.registerId }).then(
+         await getRegisterDetails({ id: id ? id : this.registerId }).then(
             (response) => {
               if (response.code === 200) {
                 let config = JSON.parse(
                   JSON.stringify(response.data ? response.data : {})
                 );
                 this.form = config;
-                this.tableList.tableData = config.finenessList
+                this.form.workshopObj={
+                  value:config.workshopNumber,
+                  label:config.workshopName,
+                }
+                this.getGroupNumber('','edit')
+                let finenessList=config.finenessList
                   ? config.finenessList
                   : [];
-                  this.tableData=this.tableList.tableData
+                if(finenessList.length>0){
+                  finenessList.map((item,index)=>{
+                    item.productId=index+1
+                  })
+                }
+                this.tableList.tableData = finenessList
+                this.tableData = this.tableList.tableData;
               }
             }
           );
         }
       } else {
         this.form = {
-          number: "",
-          name: "",
+          number: code,
+          workshopObj: "",
           workshopGroup: "",
           circle: "",
           spec: "",
-          finishDate: "",
+          finishDate: this.$moment(new Date()).format('YYYY-MM-DD'),
           averageFineness: "",
           measureFineness: "",
           deviation: "",
@@ -601,41 +677,39 @@
           marketProcessOrderNumber: "",
           inspector: "",
         };
-        if (this.inspectID) {
-          getCheckDetails({ id: id ? id : this.inspectID }).then((response) => {
+        if (this.registerId) {
+          getNewCheckDetails({ id: id ? id : this.registerId }).then((response) => {
             if (response.code === 200) {
               let config = JSON.parse(
                 JSON.stringify(response.data.info ? response.data.info : {})
               );
               this.form = config;
               this.form.number = config.finenessRegister.number;
-              this.form.name = config.finenessRegister.name;
+              this.form.workshopName = config.finenessRegister.workshopName;
               this.form.workshopGroup = config.finenessRegister.workshopGroup;
               this.form.spec = config.finenessRegister.spec;
               this.form.finishDate = config.finenessRegister.finishDate;
               this.form.circle = config.finenessRegister.circle;
               this.getTableHeader();
-              let arr= response.data.items
-                ? response.data.items
-                : [];
-                for(let i in arr){
-                    let round=arr[i].finenessRoundingItems
-                    if(arr[i].finenessGrade){
-                        if(arr[i].finenessGrade.indexOf('閲庣氦')>-1){
-                            arr[i].finenessGradeye=arr[i].finenessGrade
-                        }else if(arr[i].finenessGrade.indexOf('澶ч噹')>-1){
-                            arr[i].finenessGradebig=arr[i].finenessGrade
-                        }else if(arr[i].finenessGrade.indexOf('鐗归噹')>-1){
-                            arr[i].finenessGradeSpecial=arr[i].finenessGrade
-                        }
-                    }
-                    if(round){
-                        for(let j in round){
-                            arr[i][round[j].fineness]=round[j].quantity
-                        }
-                    }
+              let arr = response.data.items ? response.data.items : [];
+              for (let i in arr) {
+                let round = arr[i].finenessRoundingItems;
+                if (arr[i].finenessGrade) {
+                  if (arr[i].finenessGrade.indexOf("閲庣氦") > -1) {
+                    arr[i].finenessGradeye = arr[i].finenessGrade;
+                  } else if (arr[i].finenessGrade.indexOf("澶ч噹") > -1) {
+                    arr[i].finenessGradebig = arr[i].finenessGrade;
+                  } else if (arr[i].finenessGrade.indexOf("鐗归噹") > -1) {
+                    arr[i].finenessGradeSpecial = arr[i].finenessGrade;
+                  }
                 }
-              this.tableTwoList.tableInfomation =arr;
+                if (round) {
+                  for (let j in round) {
+                    arr[i][round[j].fineness.toString()] = round[j].quantity;
+                  }
+                }
+              }
+                this.tableTwoList.tableInfomation = arr;
             }
           });
         }
@@ -656,7 +730,7 @@
           let item = {
             label: lowNumber + i * 0.5 + "",
             prop: lowNumber + i * 0.5 + "",
-            min: 100,
+            min: 50,
             default: true,
           };
           this.tableTwoList.objective.push(item);
@@ -669,7 +743,7 @@
           let item = {
             label: lowStart + i * 0.5 + "",
             prop: lowStart + i * 0.5 + "",
-            min: 100,
+            min: 50,
             default: true,
           };
           this.tableTwoList.lower.push(item);
@@ -682,7 +756,7 @@
           let item = {
             label: topNumber + i * 0.5 + "",
             prop: topNumber + i * 0.5 + "",
-            min: 100,
+            min: 50,
             default: true,
           };
           this.tableTwoList.upper.push(item);
@@ -696,7 +770,7 @@
     getSelectDataList() {
       //杞﹂棿
       getDictList({
-        dictType: 1,
+        dictType: 2,
       }).then((res) => {
         if (res.code == 200) {
           this.nameList = res.data || [];
@@ -711,19 +785,91 @@
         }
       });
       //缁勫埆
-      getWorkshopManageList().then((res) => {
-        if (res.code == 200) {
-          this.workshopGroupList = res.data || [];
-        }
-      });
+      // getWorkshopManageList().then((res) => {
+      //   if (res.code == 200) {
+      //     this.workshopGroupList = res.data || [];
+      //   }
+      // });
       //搴勫彛
       getDictList({
-        dictType: 0,
+        dictType: 1,
       }).then((res) => {
         if (res.code == 200) {
           this.marketList = res.data || [];
         }
       });
+    },
+    async getGroupNumber(val,type) {
+      if (Object.keys(this.form.workshopObj).length>0) {
+        if(this.form.workshopObj.value){
+          await getWorkshopManageGroup({ number: this.form.workshopObj.value }).then((res) => {
+            if (res.code == 200) {
+              this.workshopGroupList = [];
+              let workshopGroupList = res.data || {};
+              this.workshopGroupList=[]
+              if(val=='workshopObj'){
+                this.form.workshopGroup=''
+              }
+              if (Object.keys(workshopGroupList).length > 0) {
+                for (let i in workshopGroupList) {
+                  this.workshopGroupList.push(workshopGroupList[i]);
+                }
+              }
+            }
+          })
+        }
+        if(this.form.workshopGroup&&this.form.market&&type!='edit'){
+          await  getCarNumber({
+              workshopName:this.form.workshopObj.label,
+              marketName:this.form.market,
+              groupNumber:this.form.workshopGroup,
+            }).then((res) => {
+              if (res.code == 200) {
+                this.tableData=[]
+                const {startCarNumber,endCarNumber,startCarHalf,endCarHalf}=res.data;
+                for(let i=startCarNumber;i<=endCarNumber;i++){
+                    if((i===startCarNumber&&startCarHalf===2)||(i===endCarNumber&&endCarHalf===1)){
+                        this.tableData.push({position:i,productId:Number(i)*2-1,quantity:1});
+                    }else{
+                        this.tableData.push({position:i,productId:Number(i)*2-1,quantity:1});
+                        this.tableData.push({position:i,productId:Number(i)*2,quantity:1});
+                    }
+                   /*if(i===startCarNumber){
+                      if(startCarHalf===1){//宸﹀崐杞�
+                          this.tableData.push({position:i,productId:Number(i)*2-1});
+                          this.tableData.push({position:i,productId:Number(i)*2});
+                      }else{//鍙冲崐杞�
+                          this.tableData.push({position:i,productId:Number(i)*2-1});
+                      }
+                   }else if(i===endCarNumber){
+                      if(endCarHalf===1){//宸﹀崐杞�
+                          this.tableData.push({position:i,productId:Number(i)*2-1});
+                          this.tableData.push({position:i,productId:Number(i)*2});
+                      }else{//鍙冲崐杞�
+                          this.tableData.push({position:i,productId:Number(i)*2-1});
+                      }
+                   }else{
+                       this.tableData.push({position:i,productId:Number(i)*2-1});
+                       this.tableData.push({position:i,productId:Number(i)*2});
+                   }*/
+                }
+                /*let data = res.data?JSON.parse(JSON.stringify(res.data)) : [];
+               if(Object.keys(data).length>0){
+                for(let i in data){
+                    this.tableData.push({position:data[i],productId:Number(i)*2+1})
+                    this.tableData.push({position:data[i],productId:Number(i)*2+2})
+                  }
+               }*/
+               console.log(this.tableData);
+               this.tableList.tableData = this.tableData 
+              }else{
+                this.tableData=[]
+              }
+            });
+          }
+      } else {
+        this.workshopGroupList = [];
+      }
     },
     inputStart() {
       this.form.circleTwo = this.form.circle + "-" + this.form.totalCircle;
@@ -744,11 +890,16 @@
     // 浜у搧鍒楄〃杈撳叆
     inputContent(val, prop, row) {
       this.productId = row.productId;
+      this.form.position=row.position;
       this.tableData.map((item) => {
         if (item.productId === row.productId) {
           item[prop] = val;
         }
+        if(item.fineness&&item.quantity){
+          item.sum=Number(item.fineness)*Number(item.quantity).toFixed(2)
+        }
       });
+      this.tableList.tableData= this.tableData 
     },
     tabsClick() {
       // if (tab.name === "first") {
@@ -756,14 +907,15 @@
       // } else {
       //     this.is_public = false
       // }
-      this.$router.push({
+      /*this.$router.push({
         path: "/productManage/silkRegisterForm/addPage",
         query: {
           activeName: this.activeName,
           inspectID: this.inspectID,
           id: this.registerId,
+          title:this.title
         },
-      });
+      });*/
       this.getDetailsData();
       this.keyword = "";
     },
@@ -775,13 +927,14 @@
     },
     // 绾ゅ害鐧昏琛�
     // 鏀惧純
-    cancelClickOne() {
+   async cancelClickOne() {
+      const code=await this.getAutoCode()
       if (this.activeName == "first") {
         this.form = {
-          number: "",
-          finishDate: "",
+          number: code,
+          finishDate:this.$moment(new Date()).format('YYYY-MM-DD'),
           market: "",
-          name: "",
+          workshopObj: "",
           spec: "",
           workshopGroup: "",
           circleTwo: "",
@@ -796,17 +949,18 @@
             productId: 1,
             position: "",
             fineness: 0,
-            quantity: 0,
+            quantity: 1,
             sum: "",
           },
         ];
-      }else{
-        this.form.measureFineness=''
-        this.form.twiceChange=''
-        this.form.cleanliness=''
-        this.form.purity=''
-        this.form.marketProcessOrderNumber=''
-        this.form.inspector=''
+        this.tableData =this.tableList.tableData
+      } else {
+        this.form.measureFineness = "";
+        this.form.twiceChange = "";
+        this.form.cleanliness = "";
+        this.form.purity = "";
+        this.form.marketProcessOrderNumber = "";
+        this.form.inspector = "";
       }
     },
     // 淇濆瓨
@@ -815,23 +969,54 @@
         if (valid) {
           let form = JSON.parse(JSON.stringify(this.form));
           // params.workshopGroup=Number(params.workshopGroup)
-          this.isAddloading = true;
           if (this.activeName == "first") {
             delete form.circleTwo;
             let finenessList = JSON.parse(
               JSON.stringify(this.tableList.tableData)
             );
+            let isContinue=false
+            for (let i in finenessList) {
+              if(!finenessList[i].position||!finenessList[i].fineness||!finenessList[i].quantity||!finenessList[i].sum){
+                isContinue=true
+                break;
+              }
+            }
+            if(isContinue){
+              this.$message.error('璇峰~鍐欏畬鏁村啀淇濆瓨锛�')
+              return true;
+            }
             for (let i in finenessList) {
               delete finenessList[i].productId;
+                finenessList[i].sum=finenessList[i].sum*1;
             }
+            this.isAddloading = true;
+            const mapFineness=new Map();
+            finenessList.forEach(item=>{
+               if(mapFineness.has(item.position)){
+                  const value=mapFineness.get(item.position);
+                  if(value[0].fineness===item.fineness){
+                      value[0].sum+=item.sum;
+                      value[0].quantity+=item.quantity;
+                  }else{
+                      value.push(item);
+                  }
+                  mapFineness.set(item.position,value);
+               } else{
+                   mapFineness.set(item.position,[item]);
+               }
+            });
+            console.log("淇敼",mapFineness)
+            finenessList=[...mapFineness.values()].flat(Infinity);
             let params = {
-              finenessList: finenessList,
               ...form,
+                finenessList: finenessList,
             };
             // 缂栬緫
             if (this.inspectID) {
               params.ID = this.form.ID ? this.form.ID : Number(this.inspectID);
             }
+            params.workshopName=this.form.workshopObj.label;
+            params.workshopNumber=this.form.workshopObj.value;
             saveRegister(params)
               .then((res) => {
                 if (res.code == 200) {
@@ -840,9 +1025,14 @@
                     message: "淇濆瓨鎴愬姛锛�",
                     type: "success",
                   });
-                  this.$router.push({
-                    path: "/productManage/silkRegisterForm",
-                  });
+                    if(res.data.ID){
+                        this.registerId=res.data.ID;
+                    }
+                  this.activeName = "second";
+                    this.getDetailsData();
+                  // this.$router.push({
+                  //   path: "/productManage/silkRegisterForm",
+                  // });
                 }
                 this.isAddloading = false;
               })
@@ -853,7 +1043,8 @@
               });
           } else {
             let paramsTwo = {
-              ...form,
+              info:form,
+              items:this.tableTwoList.tableInfomation,
             };
             // 缂栬緫
             if (this.registerId) {
@@ -861,6 +1052,7 @@
                 ? this.form.ID
                 : Number(this.registerId);
             }
+            this.isAddloading = true;
             saveCheck(paramsTwo)
               .then((res) => {
                 if (res.code == 200) {
@@ -868,11 +1060,10 @@
                     message: "淇濆瓨鎴愬姛锛�",
                     type: "success",
                   });
-                  this.getDetailsData()
+                  this.getDetailsData();
                 }
                 this.isAddloading = false;
-              })
-              .catch(() => {
+              }).catch(() => {
                 setTimeout(() => {
                   this.isAddloading = false;
                 }, 3000);
@@ -880,14 +1071,10 @@
           }
         } else {
           console.log("error submit!!");
-
           return false;
         }
       });
     },
-    // 鏀惧純
-    cancelClick() {},
-    saveClick() {},
   },
 };
 </script>
@@ -978,6 +1165,7 @@
       }
 
       .list-view {
+        margin-top: 20px;
         height: calc(100% - 180px);
         min-height: 200px;
         overflow-y: auto;
@@ -1028,16 +1216,20 @@
     .form-box-t {
       width: 100%;
       height: 60px;
-      overflow: hidden;
+      overflow-x: auto;
 
       .form-item {
-        width: calc(16% - 5px);
+        max-width: calc(16% - 5px);
+        min-width:210px;
         margin-right: 10px;
         float: left;
 
         &:nth-of-type(6n) {
           margin-right: 0;
         }
+        &:last-child{
+          float:right;
+        }
       }
     }
 

--
Gitblit v1.8.0