From 03cfba0f636b42417070fc8caef44bcdd792a085 Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期二, 07 五月 2024 17:34:37 +0800
Subject: [PATCH] 概述 出库模块 编辑的时候循环处理对应产品调用接口获取在库数量的逻辑处理

---
 src/views/warehouseManage/position/AddDialog.vue |  310 ++++++++++++++++++++++++++-------------------------
 1 files changed, 159 insertions(+), 151 deletions(-)

diff --git a/src/views/warehouseManage/position/AddDialog.vue b/src/views/warehouseManage/position/AddDialog.vue
index 2859b07..b7f7ca6 100644
--- a/src/views/warehouseManage/position/AddDialog.vue
+++ b/src/views/warehouseManage/position/AddDialog.vue
@@ -15,9 +15,18 @@
             <span>鎵撳嵃</span>
           </span>
           <span class="btn" style="margin-left: 15px">
-            <el-button plain size="mini" style="margin-left: 15px" @click="deleteClick">鍒犻櫎</el-button>
+            <i class="el-icon-s-tools"></i>
+            <span>鍔ㄤ綔</span>
+            <!-- <el-button plain size="mini" style="margin-left: 15px" @click="deleteClick">鍒犻櫎</el-button> -->
           </span>
-          <el-button v-if="showEdit" plain size="mini" style="margin-left: 15px" @click="editClick">缂栬緫</el-button>
+          <el-button
+            v-if="showEdit && editConfig.infomation.type == 3"
+            plain
+            size="mini"
+            style="margin-left: 15px"
+            @click="editClick"
+            >缂栬緫</el-button
+          >
         </div>
       </div>
       <!-- 鍐呭 -->
@@ -25,138 +34,122 @@
         ref="form"
         :model="editConfig.infomation"
         :rules="rules"
-        label-position="left"
-        label-width="110px"
+        label-position="right"
+        label-width="130px"
         size="mini"
-        style="height: 60vh; overflow-x: hidden"
       >
-        <div>
-          <!-- <div>aaa</div> -->
-          <FormBtnsView :showPosition="true" :showWarehouse=false @productClick="productClick" />
+        <div class="content-number-bg">
+          <FormBtnsView :showPosition="true" :showPositionCursor="this.editConfig.title != '鏂板缓'?true:false" @positionReport="positionReport" :showWarehouse="false" @productClick="productClick" />
         </div>
         <div class="basic-info">
           <div class="basic-info-view">
-
             <el-row>
-              <el-col :span="24" class="line_height_30px">
+              <el-col :span="12" class="line_height_30px">
                 <el-form-item label="浣嶇疆鍚嶇О" prop="name">
                   <el-input
-                  :disabled="!showFooter"
+                    :disabled="!showFooter"
                     v-model="editConfig.infomation.name"
                     placeholder="璇疯緭鍏�"
+                    style="width: 90%"
                   ></el-input>
                 </el-form-item>
               </el-col>
-              <el-col :span="24">
+              <el-col :span="12">
                 <el-form-item label="涓婄骇浣嶇疆" prop="parentId">
                   <el-select
                     v-model="editConfig.infomation.parentId"
                     placeholder="璇烽�夋嫨"
                     size="mini"
-                    style="width: 45%"
-                    :disabled="!showFooter"
+                    :disabled="editCommonConfig.title != '鏂板缓'"
+                    style="width: 90%"
                   >
-                    <el-option
-                      v-for="item in positionList"
-                      :key="item.id"
-                      :label="item.name"
-                      :value="item.id"
-                    >
+                    <el-option v-for="item in positionList" :key="item.id" :label="item.jointName" :value="item.id">
                     </el-option>
                   </el-select>
                 </el-form-item>
               </el-col>
             </el-row>
-          </div>
-          <div class="bottom">
+            <div class="purchase-view">
               <div class="left">
-                <div class="second-label">鍏朵粬淇℃伅</div>
                 <el-form-item label="浣嶇疆绫诲瀷" prop="type">
                   <el-select
-                   v-model="editConfig.infomation.type"
+                    v-model="editConfig.infomation.type"
                     filterable
-                    :disabled="!showFooter"
+                    :disabled="editCommonConfig.title != '鏂板缓'"
                     placeholder="璇烽�夋嫨"
-                    style="width: 100%"
+                    style="width: 90%"
                     no-data-text="鏆傛棤鏁版嵁"
                   >
-                    <el-option
-                      v-for="item in positionTypeList"
-                      :key="item.id"
-                      :label="item.name"
-                      :value="item.id"
-                    >
+                    <el-option v-for="item in positionTypeList" :key="item.id" :label="item.name" :value="item.id">
                     </el-option>
                   </el-select>
-                </el-form-item> 
-                <el-form-item label="鏄竴涓姤搴熶綅缃�" v-if="editConfig.infomation.type==3||editConfig.infomation.type==5" prop="isScrapLocation">
-                  <el-checkbox
-                  :disabled="!showFooter"
-                  v-model="editConfig.infomation.isScrapLocation"
-                  >
-                  </el-checkbox>
+                </el-form-item>
+                <el-form-item
+                  label="鏄竴涓姤搴熶綅缃�"
+                  v-if="editConfig.infomation.type == 3 || editConfig.infomation.type == 5"
+                  prop="isScrapLocation"
+                >
+                  <el-checkbox :disabled="!showFooter" v-model="editConfig.infomation.isScrapLocation"> </el-checkbox>
                 </el-form-item>
                 <el-form-item label="鏄竴涓��鍥炰綅缃�" prop="isReturnLocation">
-                  <el-checkbox
-                  :disabled="!showFooter"
-                  v-model="editConfig.infomation.isReturnLocation"
-                  >
-                  </el-checkbox>
+                  <el-checkbox :disabled="!showFooter" v-model="editConfig.infomation.isReturnLocation"> </el-checkbox>
                 </el-form-item>
-                <el-form-item label="琛ュ厖浣嶇疆" v-if="editConfig.infomation.type==3" prop="replenishLocation">
-                  <el-checkbox
-                  :disabled="!showFooter"
-                  v-model="editConfig.infomation.replenishLocation"
-                  >
-                  </el-checkbox>
+                <el-form-item label="琛ュ厖浣嶇疆" v-if="editConfig.infomation.type == 3" prop="replenishLocation">
+                  <el-checkbox :disabled="!showFooter" v-model="editConfig.infomation.replenishLocation"> </el-checkbox>
                 </el-form-item>
               </div>
-              <div class="left" v-if="editConfig.infomation.type==3||editConfig.infomation.type==7">
-                <div class="second-label">寰幆璁℃暟</div>
+              <div class="right" v-if="editConfig.infomation.type == 3 || editConfig.infomation.type == 7">
+                <!-- <div class="second-label">寰幆璁℃暟</div> -->
                 <el-form-item label="鐩樼偣棰戠巼锛堝ぉ锛�" prop="countFrequency">
                   <el-input
-                   :disabled="!showFooter"
+                    :disabled="!showFooter"
                     v-model="editConfig.infomation.countFrequency"
                     placeholder="璇疯緭鍏�"
+                    style="width: 90%"
                   ></el-input>
                 </el-form-item>
                 <el-form-item label="鏈�杩戞湁鏁堢洏鐐�" prop="recentlyCount">
                   <el-date-picker
-                   :disabled="!showFooter"
+                    :disabled="!showFooter"
                     v-model="editConfig.infomation.recentlyCount"
                     type="date"
                     placeholder="閫夋嫨鏃ユ湡"
                     value-format="yyyy-MM-dd"
+                    style="width: 90%"
                   >
                   </el-date-picker>
                 </el-form-item>
                 <el-form-item label="棰勮涓嬩竴娆$洏鐐�" prop="nextCount">
                   <el-date-picker
-                   :disabled="!showFooter"
+                    :disabled="!showFooter"
                     v-model="editConfig.infomation.nextCount"
                     type="date"
                     placeholder="閫夋嫨鏃ユ湡"
                     value-format="yyyy-MM-dd"
+                    style="width: 90%"
                   >
                   </el-date-picker>
                 </el-form-item>
               </div>
+            </div>
+            <el-form-item label="澶囨敞" prop="notes">
+              <el-input
+                :disabled="!showFooter"
+                type="textarea"
+                placeholder="澶栭儴澶囨敞"
+                :autosize="{ minRows: 3, maxRows: 4 }"
+                maxlength="500"
+                clearable
+                v-model="editConfig.infomation.notes"
+                style="width: 96%"
+              ></el-input>
+            </el-form-item>
           </div>
-          <el-form-item label="" prop="notes" label-width="20px">
-                  <el-input
-                    :disabled="!showFooter"
-                      type="textarea"
-                      placeholder="澶栭儴澶囨敞"
-                      :autosize="{ minRows: 3, maxRows: 4 }"
-                      maxlength="500"
-                      clearable
-                      v-model="editConfig.infomation.notes"
-                  ></el-input>
-          </el-form-item>
+
           <div class="bottom">
             <!-- <div class="left"> -->
-                <!-- <div class="second-label">鐗╂祦</div> -->
-                <!-- <el-form-item label="涓嬭浇绛栫暐" prop="desc">
+            <!-- <div class="second-label">鐗╂祦</div> -->
+            <!-- <el-form-item label="涓嬭浇绛栫暐" prop="desc">
                   <el-select
                    v-model="editConfig.value1"
                     filterable
@@ -175,22 +168,22 @@
                     </el-option>
                   </el-select>
                 </el-form-item> -->
-              <!-- </div> -->
+            <!-- </div> -->
           </div>
         </div>
       </el-form>
       <!-- 灏� -->
-      <div v-if="showFooter" slot="footer" class="dialog-footer">
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" size="small" @click="saveClick('form')" :disabled="!showFooter">淇濆瓨</el-button>
         <el-button size="small" @click="editConfig.visible = false">鍙栨秷</el-button>
-        <el-button type="primary" size="small" @click="saveClick('form')">淇濆瓨</el-button>
       </div>
     </el-dialog>
   </div>
 </template>
 
 <script>
-import { addLocation,updateLocation,deleteLocation } from "@/api/warehouseManage/warehouse"
-import { getDataByType } from "@/api/data";
+import { addLocation, updateLocation, deleteLocation } from "@/api/warehouseManage/warehouse"
+import { getDataByType } from "@/api/data"
 export default {
   name: "AddScrapDialog",
   props: {
@@ -204,8 +197,8 @@
         }
       }
     },
-    positionList:{
-      type:[Array]
+    positionList: {
+      type: [Array]
     }
   },
   components: {},
@@ -216,48 +209,62 @@
       editConfig: this.editCommonConfig,
       rules: {
         name: [{ required: true, message: "璇疯緭鍏�", trigger: "change" }],
-        countFrequency: [{
+        // parentId: [{ required: true, message: "璇烽�夋嫨浣嶇疆绫诲瀷", trigger: "change" }],
+        type: [{ required: true, message: "璇烽�夋嫨涓婄骇浣嶇疆", trigger: "change" }],
+        countFrequency: [
+          {
             required: false,
             message: "璇峰~鍐欎笉灏忎簬0鐨勬暟瀛�",
-            trigger: "change",
+            trigger: "change"
           },
           {
             validator: this.validatorNum,
-            trigger: "blur",
-          },],
+            trigger: "blur"
+          }
+        ]
       },
       showEdit: false, // 鏄惁鏄剧ず缂栬緫鎸夐挳
       showFooter: false, // 鏄惁鏄剧ず鍙栨秷淇濆瓨
-      positionTypeList: getDataByType("positionType"),
+      positionTypeList: getDataByType("positionType")
     }
   },
   created() {
+    console.log(this.editConfig.infomation)
     this.setBottonView()
   },
   methods: {
     validatorNum(rule, value, callback) {
       if (value) {
         if (value == undefined || value == null) {
-          callback(new Error("璇疯緭鍏ユ湁鏁堟暟瀛�"));
+          callback(new Error("璇疯緭鍏ユ湁鏁堟暟瀛�"))
         } else {
-          var reg = /^\+?[0-9]\d*$/;
+          var reg = /^\+?[0-9]\d*$/
           if (!reg.test(value)) {
-            callback(new Error("璇峰~鍐欎笉灏忎簬0鐨勬暟瀛�"));
+            callback(new Error("璇峰~鍐欎笉灏忎簬0鐨勬暟瀛�"))
           } else {
-            callback();
+            callback()
           }
         }
       } else {
-        callback();
+        callback()
+      }
+    },
+    // 褰撳墠搴撳瓨
+    positionReport(){
+      if(this.editConfig.title != '鏂板缓'){
+        this.$router.push({
+          name: "locationReport",
+          params: {
+            locationId: this.editConfig.infomation.id
+          }
+        })
       }
     },
     // 璺嚎
-    productClick() {
-      
-    },
+    productClick() {},
     // 璁剧疆鍒犻櫎/鎵撳嵃/缂栬緫鏄惁鏄剧ず
     setBottonView() {
-      if (this.editConfig.title === "鏂板缓") {
+      if (this.editConfig.title === "鏂板缓" || this.editConfig.title === "缂栬緫") {
         this.showEdit = false
         this.showFooter = true
       } else if (this.editConfig.infomation.status === "瀹屾垚") {
@@ -274,16 +281,16 @@
     },
     // 鍒櫎
     deleteClick() {
-      let data = JSON.parse(JSON.stringify(this.editConfig.infomation));
+      let data = JSON.parse(JSON.stringify(this.editConfig.infomation))
       deleteLocation({ id: data.id }).then((res) => {
         if (res.code == 200) {
-          this.editConfig.visible = false;
-          this.$message.success("鍒櫎鎴愬姛!");
-          this.$emit("refresh");
+          this.editConfig.visible = false
+          this.$message.success("鍒櫎鎴愬姛!")
+          this.$emit("refresh")
         } else {
-            this.$message.warning(res.msg?res.msg:"鍒犻櫎澶辫触!")
-         }
-      });
+          this.$message.warning(res.msg ? res.msg : "鍒犻櫎澶辫触!")
+        }
+      })
     },
     // 缂栬緫
     editClick() {
@@ -291,56 +298,57 @@
       this.showFooter = true
     },
     saveParams() {
-      let data =JSON.parse(JSON.stringify(this.editConfig.infomation));
-      
+      let data = JSON.parse(JSON.stringify(this.editConfig.infomation))
+
       let params = {
-        name:data.name,
-        parentId:data.parentId+'',
-        type:data.type,
-        isScrapLocation:data.isScrapLocation,
-        isReturnLocation:data.isReturnLocation,
-        replenishLocation:data.replenishLocation,
-        countFrequency:data.countFrequency?Number(data.countFrequency):0,
-        recentlyCount:data.recentlyCount,
-        nextCount:data.nextCount,
-        notes:data.notes,
+        name: data.name,
+        parentId: data.parentId,
+        type: data.type,
+        isScrapLocation: data.isScrapLocation,
+        isReturnLocation: data.isReturnLocation,
+        replenishLocation: data.replenishLocation,
+        countFrequency: data.countFrequency ? Number(data.countFrequency) : 0,
+        recentlyCount: data.recentlyCount,
+        nextCount: data.nextCount,
+        notes: data.notes
       }
-      if(data.id){
-        params.id=data.id
+      if (data.id) {
+        params.id = data.id
+        params.jointName = data.jointName
       }
-      return params;
+      return params
     },
     // 淇濆瓨
     saveClick(formName) {
       this.$refs[formName].validate((valid) => {
         if (valid) {
-          const params = this.saveParams();
-            if (this.editConfig.title === "鏂板缓") {
-              addLocation(params).then((res) => {
-                if (res.code == 200) {
-                  this.editConfig.visible = false;
-                  this.$message.success("娣诲姞鎴愬姛!");
-                  this.$emit('refresh')
-                } else {
-                    this.$message.warning(res.msg?res.msg:"娣诲姞澶辫触!")
-                }
-              });
-            } else {
-              updateLocation(params).then((res) => {
-                if (res.code == 200) {
-                  this.editConfig.visible = false;
-                  this.$message.success("缂栬緫鎴愬姛!");
-                  this.$emit('refresh')
-                } else {
-                    this.$message.warning(res.msg?res.msg:"缂栬緫澶辫触!")
-                }
-              });
-            }
-        }else {
-          console.log("error submit");
-          return false;
+          const params = this.saveParams()
+          if (this.editConfig.title === "鏂板缓") {
+            addLocation(params).then((res) => {
+              if (res.code == 200) {
+                this.editConfig.visible = false
+                this.$message.success("娣诲姞鎴愬姛!")
+                this.$emit("refresh")
+              } else {
+                this.$message.warning(res.msg ? res.msg : "娣诲姞澶辫触!")
+              }
+            })
+          } else {
+            updateLocation(params).then((res) => {
+              if (res.code == 200) {
+                this.editConfig.visible = false
+                this.$message.success("缂栬緫鎴愬姛!")
+                this.$emit("refresh")
+              } else {
+                this.$message.warning(res.msg ? res.msg : "缂栬緫澶辫触!")
+              }
+            })
+          }
+        } else {
+          console.log("error submit")
+          return false
         }
-      });
+      })
     }
   }
 }
@@ -364,39 +372,39 @@
 .content-status {
   display: flex;
 }
+.content-number-bg {
+  margin-top: 10px;
+}
 .basic-info {
   height: calc(100% - 80px);
   overflow: auto;
   margin: 20px;
-  border: 1px solid #dcdfe6;
-  box-shadow: inset 0 0 2px #dee2e6;
-  -moz-box-shadow: inset 0 0 2px #dee2e6;
-  -webkit-box-shadow: inset 0 0 2px #dee2e6;
-  .basic-info-view {
-    margin-top: 20px;
-    padding:0 20px;
-
-  }
-  .bottom{
+  // border: 1px solid #dcdfe6;
+  // box-shadow: inset 0 0 2px #dee2e6;
+  // -moz-box-shadow: inset 0 0 2px #dee2e6;
+  // -webkit-box-shadow: inset 0 0 2px #dee2e6;
+  // .basic-info-view {
+  //   margin-top: 20px;
+  //   padding: 0 20px;
+  // }
+  .bottom {
     display: flex;
     margin-left: 20px;
     .left {
       width: calc(50% - 10px);
-      margin-right:20px;
+      margin-right: 20px;
     }
     .right {
       width: calc(50% - 10px);
     }
     .second-label {
-      
       border-bottom: 1px solid #d9d9d9;
       margin-bottom: 10px;
     }
-    ::v-deep .el-tabs__content{
+    ::v-deep .el-tabs__content {
       padding: 0 20px;
     }
   }
-  
 }
 .purchase-view {
   display: flex;

--
Gitblit v1.8.0