From 01d52b4d848d2636fa778689a2c1f783e0e15bd4 Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期二, 16 四月 2024 18:30:08 +0800
Subject: [PATCH] wms项目 产品模块  增加启用多单位的前端开发+新增和编辑产品 2个接口联调

---
 src/views/productManage/product/components/UnitMoreDialog.vue |  251 +++++++++++++++++++++++++++++++++++++++++
 src/views/productManage/product/AddProductDialog.vue          |   52 ++++++++
 2 files changed, 301 insertions(+), 2 deletions(-)

diff --git a/src/views/productManage/product/AddProductDialog.vue b/src/views/productManage/product/AddProductDialog.vue
index 3be77ba..4649572 100644
--- a/src/views/productManage/product/AddProductDialog.vue
+++ b/src/views/productManage/product/AddProductDialog.vue
@@ -146,7 +146,7 @@
                       placeholder="鍗曚綅"
                       filterable
                       @change="Gtechange"
-                      style="width: 85%"
+                      style="width: calc(85% - 110px)"
                     >
                       <el-option
                         v-for="ele in unitList"
@@ -160,6 +160,14 @@
                       style="font-size: 20px; color: gray"
                       @click="handleUnitShow"
                     ></i>
+                    <el-checkbox
+                    class="margin_left_10px"
+                    :disabled="editConfig.infomation.unit&&showFooter?false:true"
+                    v-model="editConfig.infomation.moreUnit"
+                    @change="moreUnitChange"
+                    ></el-checkbox
+                  >
+                  <span class="margin_left_10px cursor_pointer"  @click="handleUnitMore">鍚敤澶氬崟浣�</span>
                   </el-form-item>
                   
                   <el-form-item label="浜у搧鏍囩" prop="productTagName">
@@ -542,6 +550,13 @@
       :workList="unitList"
       title="璁¢噺鍗曚綅"
     ></BomDialog>
+    <UnitMoreDialog
+      ref="unitMoreDialog"
+      @saveUnitMore="saveUnitMore"
+      :workList="unitList"
+      :dataList="editConfig.infomation.moreUnitList"
+      title="鍚敤澶氬崟浣�"
+    ></UnitMoreDialog>
   </div>
 </template>
 
@@ -555,7 +570,7 @@
 import BomDialog from "./components/bomDialog";
 import {getUnitInfo,  } from "@/api/basic/standard";
 // import { postGetSaveSUnitDict  } from "@/api/basic/standard";
-
+import UnitMoreDialog from "./components/UnitMoreDialog";
 
 export default {
   mixins: [codeMixin],
@@ -576,6 +591,7 @@
   components: { 
     IconCropper,
     BomDialog, 
+    UnitMoreDialog,
   },
   computed: {
     modalTitle() {
@@ -688,6 +704,33 @@
     // 鍗曚綅
     handleUnitShow() {
       this.editRow.editDialogVisible = true;
+    },
+    // 鍚敤澶氬崟浣�
+    handleUnitMore(){
+      if(this.editConfig.infomation.unit){
+        this.$refs.unitMoreDialog.editDialogVisible = true;
+      }else{
+        this.$message.error('璇峰厛閫夋嫨鍗曚綅锛�')
+      }
+    },
+    saveUnitMore(list){
+      this.editConfig.infomation.moreUnitList=list
+    },
+    // 鍚敤澶氬崟浣嶇殑寮�鍏�
+    moreUnitChange(){
+      let string=false;
+      if(this.editConfig.infomation.moreUnitList&&this.editConfig.infomation.moreUnitList.length>0){
+        for(let i in this.editConfig.infomation.moreUnitList){
+          if(this.editConfig.infomation.moreUnitList[i].unit&&this.editConfig.infomation.moreUnitList[i].amount){
+            string=true;
+            break;
+          }
+        }
+      }
+      if(!string){
+        this.editConfig.infomation.moreUnit=false
+        this.$message.error('璇峰厛閰嶇疆澶氬崟浣嶏紒')
+      }
     },
     handleConfirmSave(dataList) {
       saveUnitDict({ data: dataList }).then((res) => {
@@ -839,6 +882,11 @@
         params.codeStandardID = this.autoCodeObj.codeStandardID
         params.autoIncr = this.autoCodeObj.maxAutoIncr
       }
+      if(params.moreUnitList.length>0){
+        for(let i in params.moreUnitList){
+          params.moreUnitList[i].amount=Number(params.moreUnitList[i].amount)
+        }
+      }
       requestUrl(params).then((res) => {
         console.log(res)
         this.editConfig.visible = false
diff --git a/src/views/productManage/product/components/UnitMoreDialog.vue b/src/views/productManage/product/components/UnitMoreDialog.vue
new file mode 100644
index 0000000..fd1d60b
--- /dev/null
+++ b/src/views/productManage/product/components/UnitMoreDialog.vue
@@ -0,0 +1,251 @@
+<template>
+  <el-dialog
+    :close-on-click-modal="false"
+    :visible.sync="editDialogVisible"
+    width="35rem"
+    class="add-event-dialog"
+    @close="shutdown"
+    append-to-body
+  >
+    <div slot="title" class="tac drawerHeader">
+      {{ title }}
+    </div>
+    <div class="drawerContent">
+      <el-form
+        ref="form"
+        :rules="rules"
+        :model="form"
+        :inline="true"
+        label-width="0"
+        label-position="left"
+      >
+        <div class="form-item" v-for="(item, index) in form.formList" :key="index">
+          <el-row>
+            <el-col :span="2" class="col-name">1</el-col>
+            <el-col :span="7">
+              <el-form-item
+                label=""
+                :prop="`formList.${index}.unit`"
+                :rules="[
+                  {
+                    required: item.amount?true:false,
+                    message: '璇烽�夋嫨',
+                    trigger: 'change',
+                  },
+                ]"
+              >
+                <el-select
+                  v-model.number="form.formList[index].unit"
+                  placeholder="鍗曚綅"
+                  filterable
+                  clearable
+                  :popper-append-to-body="false"
+                  size="mini"
+                >
+                  <el-option
+                    v-for="ele in workList"
+                    :key="ele.id"
+                    :label="ele.name"
+                    :value="ele.name"
+                  ></el-option>
+                </el-select>
+              </el-form-item>
+            </el-col>
+            <el-col :span="1" class="col-name">鈮�</el-col>
+            <el-col :span="7">
+              <el-form-item
+                label=""
+                :prop="`formList.${index}.amount`"
+                :rules="[
+                  {
+                    required: item.unit?true:false,
+                    message: '璇峰~鍐欏ぇ浜庨浂鐨�2浣嶅皬鏁�',
+                    trigger: ['change', 'blur'],
+                    validator: validatorNum,
+                  },
+                ]"
+              >
+                <el-input
+                  v-model="item.amount"
+                  placeholder="璇疯緭鍏�"
+                  size="mini"
+                ></el-input>
+              </el-form-item>
+            </el-col>
+            <el-col :span="2" class="col-name">鍖�</el-col>
+            <el-col :span="5" v-if="index==0"> 
+              <el-form-item
+                label=""
+                :prop="`formList.${index}.floating`"
+              >
+              <el-checkbox
+                    class="margin_left_10px"
+                    v-model="item.floating"
+                    >娴姩鎹㈢畻</el-checkbox
+                  >
+                </el-form-item>
+            </el-col>
+            <el-col :span="5" class="col-name" v-else> 
+              <el-button
+                @click="delItem(index)"
+                type="text"
+                size="small"
+                style="text-align:center;"
+                >娓呯┖</el-button
+              >
+            </el-col>
+          </el-row>
+        </div>
+      </el-form>
+    </div>
+    <div slot="footer" class="dialog-footer tac">
+      <el-button @click="shutdown">鍙栨秷</el-button
+      ><el-button
+        type="primary"
+        @click="handleConfirmSave()"
+        style="margin-left: 16px; color: #fff; background-color: #2a78fb"
+        >纭畾</el-button
+      >
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+export default {
+  props: {
+    title: {
+      type: String,
+    },
+    dataList: {
+      type: [Array],
+    },
+    workList: {
+      type: [Array],
+    },
+  },
+  data() {
+    return {
+      editDialogVisible: false,
+      
+      form: {
+        formList: [
+          {
+            unit:'',
+            amount:'',
+            floating:false,
+          },
+          {
+            unit:'',
+            amount:null,
+            floating:false,
+          },
+          {
+            unit:'',
+            amount:null,
+            floating:false,
+          }
+        ],
+      },
+      rules: {},
+    };
+  },
+  watch: {
+    editDialogVisible(newVal) {
+      if (newVal) {
+        this.getInfo()
+      }
+    },
+    dataList() {
+    },
+  },
+  mounted() {},
+  methods: {
+    getInfo(){
+      if(this.dataList&&this.dataList.length>0){
+        this.form.formList = this.dataList;
+          for(let i in this.form.formList){
+            this.form.formList[i].amount=this.form.formList[i].amount==0?null:this.form.formList[i].amount
+          }
+      }else{
+        this.form.formList = [
+          {
+            unit:'',
+            amount:null,
+            floating:false,
+          },
+          {
+            unit:'',
+            amount:null,
+            floating:false,
+          },
+          {
+            unit:'',
+            amount:null,
+            floating:false,
+          }
+        ]
+      }
+    },
+    delItem(index){
+      this.$set(this.form.formList[index],'unit','')
+      this.$set(this.form.formList[index],'amount','')
+    },
+    validatorNum(rule, value, callback) {
+      if(rule.required){
+        if (value == undefined || value == null) {
+          callback(new Error("璇疯緭鍏ユ湁鏁堟暟瀛�"));
+        } else {
+          let reg2 =
+            /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
+          if (!reg2.test(value) || value == 0) {
+            callback(new Error("璇峰~鍐欏ぇ浜庨浂鐨�2浣嶅皬鏁扮殑鏁板瓧"));
+          } else {
+            callback();
+          }
+        }
+      }else{
+        callback();
+      }
+    },
+    handleConfirmSave() {
+      this.$refs.form.validate((valid) => {
+        if (valid) {
+          this.shutdown()
+          this.$emit('saveUnitMore',this.form.formList)
+        }
+      })
+    },
+    shutdown() {
+      this.editDialogVisible = false;
+    },
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+.drawerContent{
+  height:200px;
+  overflow-y: auto;
+  .el-form{
+    width:100%;
+   
+    .col-name{
+      line-height:40px;
+      text-align:center;
+    }
+  }
+}
+.drawerFooter {
+  margin-top: 16px;
+  margin-right: 20px;
+  text-align: right;
+  .el-button {
+    width: 80px;
+    height: 38px;
+    border-color: rgba(0, 0, 0, 0.1);
+    font-family: PingFangSC-Medium, sans-serif;
+    color: #000;
+  }
+}
+
+</style>

--
Gitblit v1.8.0