From d18abaac1b9b9f250de8145381fc03d14926953b Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期二, 14 十一月 2023 15:01:42 +0800
Subject: [PATCH] 产品添加编辑增加产品编码产品规格产品型号采购类型联调添加编辑产品接口获取编码列表获取自动编码规则接口

---
 src/api/common/standard.js                |   20 +++++
 src/api/data.js                           |   17 ++++
 src/components/mixin/codeMixin.js         |  131 ++++++++++++++++++++++++++++++++
 src/components/makepager/FormBtnsView.vue |   24 +++--
 4 files changed, 183 insertions(+), 9 deletions(-)

diff --git a/src/api/common/standard.js b/src/api/common/standard.js
new file mode 100644
index 0000000..68e203d
--- /dev/null
+++ b/src/api/common/standard.js
@@ -0,0 +1,20 @@
+import request from "@/common/untils/request"
+export function getCodeStandardList(data) {
+  // return  axios.get(`/api/code/getCodeList`, {
+  //   params: data
+  // })
+
+  return request({
+    url: "/api-wms/v1/code/getCodeList",
+    method: "get",
+    params: data
+  })
+} 
+// 鑾峰彇鑷姩缂栫爜
+export function getAutoCode(data) {
+  return request({
+    url: "/api-wms/v1/code/getAutoCode",
+    method: "post",
+    data
+  })
+}
diff --git a/src/api/data.js b/src/api/data.js
index d748f82..37e68c5 100644
--- a/src/api/data.js
+++ b/src/api/data.js
@@ -201,6 +201,21 @@
     id: 5
   },
 ]
+//閲囪喘绫诲瀷
+const purchaseType = [
+  {
+    name: "閲囪喘",
+    id: 1,
+  },
+  {
+    name: "鑷埗",
+    id: 2,
+  },
+  {
+    name: "濮斿",
+    id: 3,
+  },
+];
 export const getDataByType = (type) => {
   if (type == "purchaseStatus") {
     return purchaseStatus
@@ -224,5 +239,7 @@
     return positionType
   }else if(type=='baseOperationTypeTwo'){
     return baseOperationTypeTwo
+  }else if(type=='purchaseType'){
+    return purchaseType;
   }
 }
diff --git a/src/components/makepager/FormBtnsView.vue b/src/components/makepager/FormBtnsView.vue
index 6a1fafa..876a61c 100644
--- a/src/components/makepager/FormBtnsView.vue
+++ b/src/components/makepager/FormBtnsView.vue
@@ -14,14 +14,14 @@
     >
       <div class="left"><i class="el-icon-present"></i></div>
       <div class="right">
-        <div class="right-label">{{ (countObject?.inLibrary ?? 0) + "浠�" }}</div>
+        <div class="right-label">{{ (countObject?.amount ?? 0) + "浠�" }}</div>
         <div class="right-label">鍦ㄥ簱</div>
       </div>
     </div>
     <div v-if="!showProduct && !showWarehouse && !showPosition && !addProduct" class="sub-number no-cursor">
       <div class="left"><i class="el-icon-present"></i></div>
       <div class="right">
-        <div class="right-label">{{ (countObject?.forecast ?? 0) + "浠�" }}</div>
+        <div class="right-label">{{ (countObject?.predictionAmount ?? 0) + "浠�" }}</div>
         <div class="right-label">棰勬祴</div>
       </div>
     </div>
@@ -33,8 +33,8 @@
     >
       <div class="left icon-view"><i class="el-icon-sort"></i></div>
       <div class="right">
-        <div class="right-label">{{ "杩�: " + (countObject?.enter ?? 0) }}</div>
-        <div class="right-label">{{ "鍑�: " + (countObject?.exit ?? 0) }}</div>
+        <div class="right-label">{{ "杩�: " + (countObject?.inputAmount ?? 0) }}</div>
+        <div class="right-label">{{ "鍑�: " + (countObject?.outputAmount ?? 0) }}</div>
       </div>
     </div>
     <!-- <div
@@ -56,14 +56,20 @@
     >
       <div class="left"><i class="el-icon-refresh"></i></div>
       <div class="right">
-        <div class="right-label">{{ countObject?.reorderRule ?? 0 }}</div>
-        <div class="right-label">閲嶈璐ц鍒�</div>
+        <template v-if="countObject?.reorderRuleNum== 1">
+          <div class="right-label">鏈�灏忥細{{ countObject?.minInventoryRule ?? 0 }}</div>
+          <div class="right-label">鏈�澶э細{{  countObject?.maxInventoryRule ?? 0 }}</div>
+        </template>
+        <template v-else>
+          <div class="right-label">{{ countObject?.reorderRuleNum ?? 0 }}</div>
+          <div class="right-label">閲嶈璐ц鍒�</div>
+        </template>
       </div>
     </div>
     <div v-if="showProduct" class="sub-number left_border yes-cursor" @click="productClick">
       <div class="left"><i class="el-icon-s-fold"></i></div>
       <div class="right">
-        <div class="right-label">{{ countObject?.product ?? 0 }}</div>
+        <div class="right-label">{{ countObject?.reorderRuleNum ?? 0 }}</div>
         <div class="right-label">浜у搧</div>
       </div>
     </div>
@@ -188,12 +194,12 @@
   padding: 0px 10px;
   font-size: 13px;
   .sub-number {
-    width: 12.5%;
+    width: 13%;
     border-right: 1px solid #e9e9e9;
     border-top: 1px solid #e9e9e9;
     border-bottom: 1px solid #e9e9e9;
     display: flex;
-    padding: 3px 9px;
+    padding: 3px 5px;
     .left {
       margin-top: 3px;
       font-size: 22px;
diff --git a/src/components/mixin/codeMixin.js b/src/components/mixin/codeMixin.js
new file mode 100644
index 0000000..9c07427
--- /dev/null
+++ b/src/components/mixin/codeMixin.js
@@ -0,0 +1,131 @@
+
+import { getCodeStandardList,getAutoCode } from "@/api/common/standard"
+export default {
+  components: {},
+  data() {
+    return {
+      // 缂栫爜
+      // 鏄惁鑷姩鐢熸垚
+      isIdDisabled: false,
+      inputValue: [],
+      explain: "",
+      codenumer: 0, //姣忔杈撳叆鐨勭紪鐮�
+      codenumberList: [], //鏁存潯缂栫爜
+      sum: 0,
+      method: 0,
+      objCode: { name: "", page: 0, pageSize: 0, type: "鐗╂枡缂栫爜", codeStandID: "" },
+      codeRule: {},
+      codeLength: 0,
+      autoCodeObj: {}
+    }
+  },
+
+  methods: {
+    async getRCodeStandardList() {
+      try {
+        if (this.editConfig.title == "鏂板缓") {
+          const res = await getCodeStandardList(this.objCode)
+          this.codenumer = []
+          this.sum = 0
+          this.explain = ""
+          this.codeLength = 0;
+          if (res.code == 200) {
+            const { List = [], ID, AutoRule = {}, Method } = res.data ? res.data[0] : []
+            this.codeRule = res.data ? res.data[0] : {}
+            let autoRule = AutoRule  
+            let method = Method ? Method : 0
+            this.method = method
+            let rules = List
+            this.editConfig.infomation.ID = ID
+            if (method == 0 && res.data.data.length > 0) {
+              console.log("sss")
+              rules.forEach((item, index) => {
+                // setTimeout(() => {
+                //   this.codenumer = item.length;
+                //   this.sum++;
+                // }, 200);
+                this.codenumer.push(item.Length)
+                this.codeLength += item.Length;
+                this.sum++
+                this.explain += item.Name + (index === rules.Length - 1 ? "" : "/")
+              })
+            }
+            console.log(method)
+            if (method == 1) {
+              if (Object.keys(autoRule).length > 0) {
+                this.isIdDisabled = true
+                if (autoRule.PrefixMethod == 1) {
+                  let prefix = autoRule.PrefixValue.split("").length
+
+                  this.codenumer.push(prefix)
+                  this.codeLength += prefix;
+                  if (autoRule.SuffixMethod == 2) {
+                    this.codenumer.push(8)
+                    this.codeLength += 8;
+                  }
+                  if (autoRule.AutoLength) {
+                    this.codenumer.push(autoRule.AutoLength)
+                    this.codeLength += autoRule.AutoLength;
+                  }
+                  this.sum = prefix + Number(autoRule.AutoLength)
+                  // this.codeList(
+                  //   this.editConfig.infomation.id ? this.editConfig.infomation.id : autoRule.PrefixValue
+                  // )
+                }
+              }
+            }
+
+            this.$forceUpdate()
+          } else {
+            this.$message.error(res.data.msg ? res.data.msg : "鑾峰彇缂栫爜瑙勮寖澶辫触锛岃閲嶈瘯锛�")
+          }
+          this.getAutoCodeValue()
+        } else {
+          this.codeList(this.editConfig.infomation.id)
+        }
+      } catch (err) {
+        console.log(err)
+      }
+    },
+    async getAutoCodeValue() {
+      if(Object.keys(this.codeRule).length>0){
+        const res = await getAutoCode(this.codeRule);
+        if (res.code == 200) {
+          let p={
+            id:'',
+            codeStandardID:'',
+            maxAutoIncr:''
+          }
+          this.autoCodeObj = res.data?res.data:p;
+          this.$set(this.editConfig.infomation, 'id', this.autoCodeObj.id)
+        }else{
+          this.$set(this.editConfig.infomation, 'id', this.codeRule.AutoRule.PrefixValue?this.codeRule.AutoRule.PrefixValue:'')
+        }
+      }
+      
+    },
+    codeList(val) {
+      this.inputValue = val
+      this.codenumberList = val.toString()
+      this.editConfig.infomation.number = this.codenumberList.length > 0 ? this.codenumberList.replace(/,/g, "") : ""
+      console.log(this.codenumberList.replace(/,/g, ""))
+    },
+     // 璁㈠崟缂栫爜鍗曠嫭鏍¢獙
+     validateCheckCode(rule, value, callback) {
+      if (value && value.length > 0) {
+        if (this.editConfig.title == "鏂板缓") {
+            if (value.length != this.codeLength) {
+              callback(new Error("璇峰~鍐�" + this.codeLength + "浣嶇殑缂栫爜锛�"));
+            }
+         }
+        callback();
+      } else {
+        callback(new Error("璇疯緭鍏ョ紪鐮�"));
+      }
+    },
+    // 閰嶇疆缂栫爜瑙勮寖鐨勮烦杞�
+    numberClick() {
+      window.open("http://www.fai365.com:9080/facilty", "_blank")
+    }
+  }
+}

--
Gitblit v1.8.0