From 544f30e28a3d8ea41e5ea8c0add2ce77c1b6fb1a Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期二, 07 五月 2024 17:48:31 +0800
Subject: [PATCH] 工种管理模块 编辑工种接口400的问题修改+增加如果启用不达标保底,则必须输入保底工资的逻辑

---
 src/views/productManage/silkRegisterForm/addPage.vue |  259 ++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 193 insertions(+), 66 deletions(-)

diff --git a/src/views/productManage/silkRegisterForm/addPage.vue b/src/views/productManage/silkRegisterForm/addPage.vue
index e3ca7de..24bcbdb 100644
--- a/src/views/productManage/silkRegisterForm/addPage.vue
+++ b/src/views/productManage/silkRegisterForm/addPage.vue
@@ -48,12 +48,13 @@
             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=='淇敼'?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"
@@ -65,6 +66,7 @@
                 v-model="form.market"
                 placeholder="璇烽�夋嫨"
                 class="select-width"
+                @change="getGroupNumber"
               >
                 <el-option
                   v-for="item in marketList"
@@ -75,17 +77,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"
+                @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>
@@ -110,14 +113,16 @@
             <el-form-item label="缁勫埆" prop="workshopGroup" class="form-item">
               <el-select
                 v-model="form.workshopGroup"
-                placeholder="璇烽�夋嫨"
+                placeholder="璇峰厛閫夋嫨杞﹂棿"
+                no-data-text="璇峰厛閫夋嫨杞﹂棿"
                 class="select-width"
+                @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>
@@ -162,7 +167,7 @@
               </el-row>
             </el-form-item>
             <el-form-item label="杞﹀彿" prop="position" class="form-item">
-              <el-input v-model="form.position" placeholder="璇疯緭鍏�">
+              <el-input v-model.number="form.position" placeholder="璇疯緭鍏�">
               </el-input>
             </el-form-item>
           </el-form>
@@ -176,6 +181,7 @@
               :detail-enter="isView ? true : false"
               :selectBox="false"
               :detailEnter="true"
+              :isBorder="true"
               :show-summary="showSummary"
               :product-table-list="tableList"
               @inputContent="inputContent"
@@ -195,7 +201,7 @@
           <!-- <CommonSearch :show-add="false" :show-download="false" :amount-view="false" :show-action-btn="false"
                         placeholder="璇疯緭鍏ュ叧閿瘝" @searchClick="onFilterSearch">
                         <template slot="leftButton"> -->
-          <el-button size="small" type="primary" @click="cancelClickTwo"
+          <el-button size="small" type="primary" @click="cancelClickOne"
             >鏀惧純</el-button
           >
           <el-button
@@ -206,7 +212,7 @@
             >淇濆瓨</el-button
           >
           <!-- </template>
-</CommonSearch> -->
+          </CommonSearch> -->
         </div>
       </div>
       <div class="body-two body">
@@ -217,34 +223,37 @@
           :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>
-          <div class="list-view">
+          <div class="list-view-two">
             <el-table
               ref="multipleTable"
               :data="tableTwoList.tableInfomation"
               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>
@@ -316,11 +325,19 @@
                 show-overflow-tooltip
               >
               </el-table-column>
-              <el-table-column prop="valueRange" label="閲庣氦" width="120">
+              <el-table-column prop="finenessGradeye" label="閲庣氦" width="120">
               </el-table-column>
-              <el-table-column prop="unit" label="澶ч噹" show-overflow-tooltip>
+              <el-table-column
+                prop="finenessGradebig"
+                label="澶ч噹"
+                show-overflow-tooltip
+              >
               </el-table-column>
-              <el-table-column prop="valueRange" label="鐗归噹" width="120">
+              <el-table-column
+                prop="finenessGradeSpecial"
+                label="鐗归噹"
+                width="120"
+              >
               </el-table-column>
               <el-table-column
                 prop="finenessGrade"
@@ -413,11 +430,12 @@
 </template>
 
 <script>
+// getWorkshopManageList
 import {
   saveRegister,
   getDictList,
-  getWorkshopManageList,
   getRegisterDetails,
+  getCarNumber
 } from "@/api/productManage/silkRegisterForm.js";
 import {
   getCheckDetails,
@@ -425,6 +443,7 @@
 } from "@/api/productManage/silkInspectForm.js";
 import pageMixin from "@/components/makepager/pager/mixin/pageMixin";
 import CommonFormTableView from "@/components/makepager/CommonFormTableView";
+import { getWorkshopManageGroup } from "@/api/productManage/productRegisterForm.js";
 export default {
   name: "silkRegisterAddPage",
   props: {},
@@ -435,6 +454,7 @@
   computed: {},
   data() {
     return {
+      title:'',
       loading: false,
       activeName: "first",
       searchOptions: [],
@@ -452,8 +472,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: [
@@ -461,7 +485,7 @@
         ],
         // 缁勫埆 搴旇true
         workshopGroup: [
-          { required: false, message: "璇烽�夋嫨", trigger: ["change", "blur"] },
+          { required: true, message: "璇烽�夋嫨", trigger: ["change", "blur"] },
         ],
         circleTwo: [
           { required: true, message: "璇峰~鍐�", trigger: ["change", "blur"] },
@@ -475,6 +499,11 @@
         position: [
           { required: true, message: "璇峰~鍐�", trigger: ["change", "blur"] },
         ],
+      },
+      pickerOptions: {
+        disabledDate(time) {
+          return time.getTime() < new Date().getTime() - 86400000;
+        },
       },
       tableTwoList: {
         tableInfomation: [],
@@ -528,12 +557,18 @@
           {
             label: "绾ゅ害鍚堣",
             prop: "sum",
-            inputNumber: true,
-            isRequird: true,
           }, // 涓嬫鍥炶鏃ユ湡
         ],
       },
-      tableData: [],
+      tableData: [ 
+        {
+            productId: 1,
+            position: null,
+            fineness: null,
+            quantity: null,
+            sum: null,
+          }
+        ],
       registerId: "",
       inspectID: "",
       isRegisterSave: false,
@@ -545,19 +580,20 @@
       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 getDetailsData(id) {
       if (this.activeName == "first") {
         this.form = {
           number: "",
           finishDate: "",
           market: "",
-          name: "",
+          workshopObj: "",
           spec: "",
           workshopGroup: "",
           circleTwo: "",
@@ -566,16 +602,28 @@
           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
                   : [];
+                if(finenessList.length>0){
+                  finenessList.map((item,index)=>{
+                    item.productId=index+1
+                  })
+                }
+                this.tableList.tableData = finenessList
+                this.tableData = this.tableList.tableData;
               }
             }
           );
@@ -583,7 +631,7 @@
       } else {
         this.form = {
           number: "",
-          name: "",
+          workshopObj: "",
           workshopGroup: "",
           circle: "",
           spec: "",
@@ -607,24 +655,31 @@
               );
               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(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] = round[j].quantity;
+                  }
+                }
+              }
+              this.tableTwoList.tableInfomation = arr;
             }
           });
         }
@@ -700,11 +755,11 @@
         }
       });
       //缁勫埆
-      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,
@@ -713,6 +768,50 @@
           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=[]
+                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})
+                }
+               }
+               this.tableList.tableData = this.tableData 
+              }else{
+                this.tableData=[]
+              }
+            });
+          }
+      } else {
+        this.workshopGroupList = [];
+      }
     },
     inputStart() {
       this.form.circleTwo = this.form.circle + "-" + this.form.totalCircle;
@@ -737,7 +836,11 @@
         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") {
@@ -770,7 +873,7 @@
           number: "",
           finishDate: "",
           market: "",
-          name: "",
+          workshopObj: "",
           spec: "",
           workshopGroup: "",
           circleTwo: "",
@@ -789,25 +892,42 @@
             sum: "",
           },
         ];
+        this.tableData =this.tableList.tableData
+      } else {
+        this.form.measureFineness = "";
+        this.form.twiceChange = "";
+        this.form.cleanliness = "";
+        this.form.purity = "";
+        this.form.marketProcessOrderNumber = "";
+        this.form.inspector = "";
       }
     },
-    // 绾ゅ害妫�楠岃〃
-    cancelClickTwo() {},
     // 淇濆瓨
     saveClickOne(formName) {
       this.$refs[formName].validate((valid) => {
         if (valid) {
           let form = JSON.parse(JSON.stringify(this.form));
           // params.workshopGroup=Number(params.workshopGroup)
-          this.isAddloading = true;
           if (this.activeName == "first") {
-            delete form.circle;
+            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;
             }
+            this.isAddloading = true;
             let params = {
               finenessList: finenessList,
               ...form,
@@ -816,6 +936,8 @@
             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) {
@@ -837,7 +959,9 @@
               });
           } else {
             let paramsTwo = {
-              ...form,
+              // ...form,
+              info:form,
+              items:this.tableTwoList.tableInfomation,
             };
             // 缂栬緫
             if (this.registerId) {
@@ -845,6 +969,7 @@
                 ? this.form.ID
                 : Number(this.registerId);
             }
+            this.isAddloading = true;
             saveCheck(paramsTwo)
               .then((res) => {
                 if (res.code == 200) {
@@ -852,6 +977,7 @@
                     message: "淇濆瓨鎴愬姛锛�",
                     type: "success",
                   });
+                  this.getDetailsData();
                 }
                 this.isAddloading = false;
               })
@@ -868,9 +994,6 @@
         }
       });
     },
-    // 鏀惧純
-    cancelClick() {},
-    saveClick() {},
   },
 };
 </script>
@@ -887,7 +1010,11 @@
     height: 45px;
   }
 }
-
+::v-deep .el-table .el-table__cell {
+  padding: 6px 0 !important;
+  height: 35px;
+  text-align: center;
+}
 .custom-manage {
   height: 100%;
   overflow: hidden;
@@ -924,7 +1051,7 @@
     .body-l {
       background-color: #fff;
       border-radius: 12px;
-      height: calc(100% - 180px - 20px);
+      height: calc(100% - 20px);
       width: calc(100% - 420px);
       float: left;
       overflow: hidden;
@@ -957,9 +1084,9 @@
       }
 
       .list-view {
-        height: calc(100% - 0px);
+        height: calc(100% - 180px);
         min-height: 200px;
-        overflow: hidden;
+        overflow-y: auto;
       }
     }
 
@@ -1020,8 +1147,8 @@
       }
     }
 
-    .list-view {
-      max-height: calc(100% - 90px - 10px);
+    .list-view-two {
+      height: calc(100% - 120px);
       overflow: hidden;
     }
 

--
Gitblit v1.8.0