From 96aea12d4cbbda5d51fd8e85fdfb871c1f20a7fc Mon Sep 17 00:00:00 2001
From: zuozhengqing <a13193816592@163.com>
Date: 星期三, 10 四月 2024 11:30:17 +0800
Subject: [PATCH] 生丝定价,数据字典,车间管理接口联调

---
 src/views/systemSetting/dataDictionary/components/addDataDictionaries.vue |  172 ++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 96 insertions(+), 76 deletions(-)

diff --git a/src/views/systemSetting/dataDictionary/components/addDataDictionaries.vue b/src/views/systemSetting/dataDictionary/components/addDataDictionaries.vue
index aac1404..507c6d1 100644
--- a/src/views/systemSetting/dataDictionary/components/addDataDictionaries.vue
+++ b/src/views/systemSetting/dataDictionary/components/addDataDictionaries.vue
@@ -1,76 +1,82 @@
 <template>
   <div class="add_wordshop">
-    <el-dialog
-      :title="editConfig.dialogTitle+editConfig.dialogTitleType"
-      :visible.sync="editConfig.visible"
-      width="30%"
+    <el-dialog :title="editConfig.dialogTitle + editConfig.dialogTitleType" :visible.sync="editConfig.visible" width="30%"
       :before-close="handleClose">
-      <el-form :inline="true" label-width="20%" style="width: 100%;" :model="form" >
-        <template v-if="editConfig.infomitton.TabsIndex===0||editConfig.infomitton.TabsIndex===1">
-          <el-form-item label="缂栫爜" style="width: 100%;" >
-            <el-input   v-model="form.number" placeholder="璇疯緭鍏�"></el-input>
+      <el-form :inline="true" label-width="20%" style="width: 100%;" :model="editConfig.infomitton" :rules="rules"
+        ref="ruleForm">
+        <template v-if="editConfig.infomitton.TabsIndex === 0 || editConfig.infomitton.TabsIndex === 1">
+          <el-form-item prop="number" label="缂栫爜" style="width: 100%;">
+            <el-input :disabled="editConfig.dialogTitle === '鏌ョ湅'" v-model="editConfig.infomitton.number"
+              placeholder="璇疯緭鍏�"></el-input>
           </el-form-item>
-          <el-form-item label="鍚嶇О" style="width: 100%;" >
-            <el-input   v-model="form.name" placeholder="璇疯緭鍏ュ瓧姣嶆垨鏁板瓧锛屼笉鍏佽鏈夌┖鏍笺�佷腑鏂�"></el-input>
+          <el-form-item prop="name" label="鍚嶇О" style="width: 100%;">
+            <el-input :disabled="editConfig.dialogTitle === '鏌ョ湅'" v-model="editConfig.infomitton.name"
+              placeholder="璇疯緭鍏ュ瓧姣嶆垨鏁板瓧锛屼笉鍏佽鏈夌┖鏍笺�佷腑鏂�"></el-input>
           </el-form-item>
         </template>
 
-        <template v-if="editConfig.infomitton.TabsIndex===2">
-          <el-form-item label="甯﹀彿棰滆壊" style="width: 100%;" >
-            <el-input  v-model="form.name" placeholder="璇疯緭鍏ュ瓧姣嶆垨鏁板瓧锛屼笉鍏佽鏈夌┖鏍笺�佷腑鏂�"></el-input>
-          </el-form-item>
-        </template>
-        
-        <template v-if="editConfig.infomitton.TabsIndex===3">
-          <el-form-item label="瑙勬牸" style="width: 100%;" >
-            <el-input  v-model="form.number" placeholder="璇疯緭鍏ュ瓧姣嶆垨鏁板瓧锛屼笉鍏佽鏈夌┖鏍笺�佷腑鏂�"></el-input>
+        <template v-if="editConfig.infomitton.TabsIndex === 2">
+          <el-form-item prop="name" label="甯﹀彿棰滆壊" style="width: 100%;">
+            <el-input :disabled="editConfig.dialogTitle === '鏌ョ湅'" v-model="editConfig.infomitton.name"
+              placeholder="璇疯緭鍏ュ瓧姣嶆垨鏁板瓧锛屼笉鍏佽鏈夌┖鏍笺�佷腑鏂�"></el-input>
           </el-form-item>
         </template>
 
-        <el-form-item label="鎻忚堪" style="width: 100%;" >
-          <el-input
-            v-model="form.remark"
-            type="textarea"
-            :rows="4"
-            style="resize: none !important;"
-            placeholder="璇疯緭鍏�"
-            >
+        <template v-if="editConfig.infomitton.TabsIndex === 3">
+          <el-form-item prop="name" label="瑙勬牸" style="width: 100%;">
+            <el-input :disabled="editConfig.dialogTitle === '鏌ョ湅'" v-model="editConfig.infomitton.name"
+              placeholder="璇疯緭鍏ュ瓧姣嶆垨鏁板瓧锛屼笉鍏佽鏈夌┖鏍笺�佷腑鏂�"></el-input>
+          </el-form-item>
+        </template>
+
+        <el-form-item label="鎻忚堪" style="width: 100%;">
+          <el-input :disabled="editConfig.dialogTitle === '鏌ョ湅'" v-model="editConfig.infomitton.remark" type="textarea"
+            :rows="4" style="resize: none !important;" placeholder="璇疯緭鍏�">
           </el-input>
         </el-form-item>
-        
+
       </el-form>
-      <span slot="footer" class="dialog-footer">
+      <span slot="footer" class="dialog-footer" v-if="editConfig.dialogTitle != '鏌ョ湅'">
         <el-button @click="editConfig.visible = false">鍙� 娑�</el-button>
-        <el-button type="primary" @click="commitForm">纭� 瀹�</el-button>
+        <el-button type="primary" @click="commitForm('ruleForm')">纭� 瀹�</el-button>
       </span>
     </el-dialog>
   </div>
 </template>
 
 <script>
-import {addDict} from "@/api/systemSetting/dataDictionary"
+import { addDict, editDict } from "@/api/systemSetting/dataDictionary"
 export default {
   props: {
-    editDiaConfig:{
+    editDiaConfig: {
       type: Object,
       default: () => {
         return {
           visible: false,
-          dialogTitle:"娣诲姞",
+          dialogTitle: "娣诲姞",
           infomitton: {
-
           }
         }
       }
     }
   },
   data() {
+    const checkSpace = (rule, value, callback) => {  
+      if (value.includes(' ')) {  
+        callback(new Error('鍚嶇О涓嶈兘鍖呭惈绌烘牸'));  
+      } else {  
+        callback();  
+      }  
+    };  
     return {
-      editConfig:this.editDiaConfig,
-      form: {
-        name: '',
-        number: '',
-        remark:""
+      editConfig: this.editDiaConfig,
+      rules: {
+        number: [
+          { required: true, message: '璇峰~鍐欑紪鐮�', trigger: 'change' }
+        ],
+        name: [
+          {validator: checkSpace, required: true, message: '璇峰~鍐欏悕绉板苟涓斾笉鑳芥湁绌烘牸', trigger: 'change' }
+        ]
       }
     };
   },
@@ -89,49 +95,63 @@
     handleClose(done) {
       done();
     },
-    saveParams(type){
-      let params={}
-      if(type===0||type===1){
-        params={
-          dictType:this.editConfig.infomitton.TabsIndex,
-          name: this.form.name,
-          number: this.form.number,
-          remark:this.form.remark,
+    saveParams(type) {
+      let params = {}
+      if (type === 0 || type === 1) {
+        params = {
+          dictType: this.editConfig.infomitton.TabsIndex,
+          name: this.editConfig.infomitton.name,
+          number: this.editConfig.infomitton.number,
+          remark: this.editConfig.infomitton.remark,
         }
-      }else if(type===2){
-        params={
-          dictType:this.editConfig.infomitton.TabsIndex,
-          name: this.form.name,
-          number: this.form.number,
-          remark:this.form.remark,
+      } else if (type === 2) {
+        params = {
+          dictType: this.editConfig.infomitton.TabsIndex,
+          name: this.editConfig.infomitton.name,
+          remark: this.editConfig.infomitton.remark,
         }
-      }else if(type===3){
-        params={
-          dictType:this.editConfig.infomitton.TabsIndex,
-          name: this.form.name,
-          number: this.form.number,
-          remark:this.form.remark,
+      } else if (type === 3) {
+        params = {
+          dictType: this.editConfig.infomitton.TabsIndex,
+          name: this.editConfig.infomitton.name,
+          remark: this.editConfig.infomitton.remark,
         }
       }
       return params
     },
-    commitForm(){
-      let params=this.saveParams(this.editConfig.infomitton.TabsIndex)
-      if(this.editConfig.dialogTitle==="鏂板"){
-        addDict(params).then((res)=>{
-          if(res&&res.code===200){
-            this.editConfig.visible=false
-            this.$parent.getData()
-            this.$message({
-              message: `鏂板${this.editConfig.dialogTitleType}鎴愬姛!`,
-              type: 'success'
-            });
+    commitForm(formName) {
+      this.$refs[formName].validate((valid) => {
+        if (valid) {
+          let params = this.saveParams(this.editConfig.infomitton.TabsIndex)
+          if (this.editConfig.dialogTitle === "鏂板") {
+            addDict(params).then((res) => {
+              if (res && res.code === 200) {
+                this.editConfig.visible = false
+                this.$parent.getData()
+                this.$message({
+                  message: `鏂板${this.editConfig.dialogTitleType}鎴愬姛!`,
+                  type: 'success'
+                });
+              }
+            })
+          } else if (this.editConfig.dialogTitle === "淇敼") {
+            editDict({ ...params, id: this.editConfig.infomitton.ID }).then((res) => {
+              if (res && res.code === 200) {
+                this.editConfig.visible = false
+                this.$parent.getData()
+                this.$message({
+                  message: `淇敼${this.editConfig.dialogTitleType}鎴愬姛!`,
+                  type: 'success'
+                });
+              }
+            })
           }
-          console.log(res,"res")
-        })
-      }else if(this.editConfig.dialogTitle==="淇敼"){
-        console.log("淇敼")
-      }
+        } else {
+          console.log('error submit!!');
+          return false;
+        }
+      });
+
     }
   },
   components: {
@@ -141,7 +161,7 @@
 </script>
 
 <style scoped lang="scss">
-::v-deep .el-form-item__content{
+::v-deep .el-form-item__content {
   width: 70% !important;
 }
 </style>

--
Gitblit v1.8.0