From 62729d3d72ecf7d70ba8a7437a43908b73df5870 Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期一, 22 四月 2024 18:15:14 +0800
Subject: [PATCH] 带徒管理模块 列表的接口联调,字段调试+删除的接口联调+添加的接口联调+编辑的接口联调

---
 src/views/employeeSalary/apprenticeshipManage/components/addDialog.vue |  202 +++++++++++++++++++++++++++++++------------------
 1 files changed, 127 insertions(+), 75 deletions(-)

diff --git a/src/views/employeeSalary/apprenticeshipManage/components/addDialog.vue b/src/views/employeeSalary/apprenticeshipManage/components/addDialog.vue
index 3c65114..0cdae53 100644
--- a/src/views/employeeSalary/apprenticeshipManage/components/addDialog.vue
+++ b/src/views/employeeSalary/apprenticeshipManage/components/addDialog.vue
@@ -1,90 +1,92 @@
 <template>
   <div class="add_wordshop">
     <el-dialog
-      :title="editConfig.dialogTitle+'杞﹂棿绠$悊'"
-      :visible.sync="editConfig.visible"
-      width="30%"
-      :before-close="handleClose">
-      <el-form :inline="true" label-width="20%" style="width: 100%;" :model="editConfig.infomitton" :rules="rules" ref="ruleForm" >
-        <el-form-item label="鍛樺伐缂栫爜" style="width: 100%;" 
-            prop="groupNumber"  >
+      :visible.sync="islook"
+      width="40rem" 
+      @close="cancelMethod">
+      <div slot="title" class="tac drawerHeader">{{ editRow.title }}浜哄憳</div>
+      <el-form  label-position="right" label-width="120px" style="width: 100%;" :model="form" :rules="rules" ref="form" >
+        <el-form-item label="鍛樺伐濮撳悕" style="width: 100%;" 
+            prop="name"  >
+            <UserSimpleSearchInput
+            :echoValue="form.workerId"
+            :echoName="form.name"
+            checkedNum="1"
+            request="1"
+            :clearable="true"
+            @select-user="setFormItem($event, 'workerId', 'name')"
+          >
+          </UserSimpleSearchInput>
+        </el-form-item>
+        <el-form-item label="鍛樺伐缂栧彿" style="width: 100%;" prop="workerId" >
           <el-input
-            :disabled="this.editConfig.dialogTitle==='鏌ョ湅'"
-            v-model="editConfig.infomitton.groupNumber"
-            :rows="4"
-            style="resize: none !important;"
-            placeholder="璇疯緭鍏ュ憳宸ョ紪鐮�"
+            v-model="form.workerId"
+            disabled
+            placeholder="璇疯緭鍏ュ憳宸ョ紪鍙�"
             >
           </el-input>
         </el-form-item>
-        <el-form-item label="鍛樺伐濮撳悕" style="width: 100%;" >
-          <el-input
-            :disabled="this.editConfig.dialogTitle==='鏌ョ湅'"
-            v-model="editConfig.infomitton.groupNumber"
-            :rows="4"
-            style="resize: none !important;"
-            placeholder="璇疯緭鍏ュ憳宸ュ鍚�"
-            >
-          </el-input>
-        </el-form-item>
-        <el-form-item label="甯﹀緬澶╂暟" style="width: 100%;" 
-        prop="groupNumber">
+        <el-form-item label="甯﹀緬鏈堜唤" style="width: 100%;" 
+        prop="month">
           <el-date-picker
             style="width:100%"
-            v-model="editConfig.infomitton.groupNumber"
+            v-model="form.month"
             type="month"
-            placeholder="閫夋嫨鏈�">
+            placeholder="閫夋嫨鏈�"
+            value-format="yyyy-MM">
           </el-date-picker>
         </el-form-item>
         <el-form-item label="甯﹀緬澶╂暟" style="width: 100%;" 
-            prop="groupNumber"  >
+            prop="days"  >
           <el-input
-            :disabled="this.editConfig.dialogTitle==='鏌ョ湅'"
-            v-model="editConfig.infomitton.groupNumber"
-            :rows="4"
-            style="resize: none !important;"
-            placeholder="璇疯緭鍏ュ憳宸ョ紪鐮�"
+            v-model="form.days"
+            placeholder="璇疯緭鍏�"
             >
           </el-input>
         </el-form-item>
       </el-form>
       <span slot="footer" class="dialog-footer">
-        <el-button @click="editConfig.visible = false">鍙� 娑�</el-button>
-        <el-button type="primary" @click="commitForm('ruleForm')">纭� 瀹�</el-button>
+        <el-button @click="cancelMethod()">鍙� 娑�</el-button>
+        <el-button  type="primary" @click="submitForm('form')">纭� 瀹�</el-button>
       </span>
     </el-dialog>
   </div>
 </template>
 
 <script>
-// import {} from "@/api/systemSetting/workshopManage"
+import { createMentorInfo, updateMentorInfo } from "@/api/employeeSalary/apprenticeshipManage.js"
+import UserSimpleSearchInput from "@/components/common/UserSimpleSearchInput"
 export default {
+  components: {
+    UserSimpleSearchInput
+  },
   props: {
-    editDiaConfig:{
+    editRow: {
       type: Object,
-      default: () => {
-        return {
-          visible: false,
-          dialogTitle:"娣诲姞",
-          isReadonly:true,
-          infomitton: {
-          },
-        }
-      }
     }
   },
   data() {
     return {
-      editConfig:this.editDiaConfig,
-      workshopList:[],
-      carFlagList:[
-      ],
+      islook:false,
+      form:{
+        workerId:'',
+        days:null,
+        month:'', 
+        name:'',
+      },
       rules: {
-        workshopNumber: [
-          { required: true, message: '璇烽�夋嫨杞﹂棿', trigger: 'change' }
+        name: [
+          { required: true, message: '璇烽�夋嫨', trigger: ['change','blur']  }
         ],
-        groupNumber: [
-          { required: true, message: '璇峰~鍐欑粍鍒�', trigger: 'change' }
+        month: [
+          { required: true, message: '璇烽�夋嫨', trigger: ['change','blur'] }
+        ],
+        days: [
+          { required: true, message: '璇峰~鍐�', trigger:  ['change','blur'] },
+          {
+            validator: this.validatorNum,
+            trigger: ["blur", "change"],
+          },
         ]
       },
     };
@@ -97,39 +99,89 @@
 
   },
   watch: {
-
+    islook(newVal) {
+      if (newVal) {
+        this.formInfo()
+      }
+    },
+    editRow() {
+      this.formInfo()
+    },
   },
   methods: {
-    handleClose(done) {
-      done();
-    },
-    setParams(){
-      let params={
-        workshopNumber:this.editConfig.infomitton.workshopNumber+'',
-        groupNumber:Number(this.editConfig.infomitton.groupNumber),
-        startCarNumber:Number(this.editConfig.infomitton.startCarNumber),
-        endCarNumber:Number(this.editConfig.infomitton.endCarNumber),
-        carFlag:Number(this.editConfig.infomitton.carFlag),
-        notes:this.editConfig.infomitton.notes,
-        // id:Number(this.editConfig.infomitton.workshopId),
+    formInfo() {
+      if (this.islook) {
+        this.form = {
+          workerId:'',
+          days:null,
+          month:'', 
+          name:'',
+        };
+        this.$nextTick(()=>{
+          this.$refs["form"].resetFields();
+          if (this.editRow.id) {
+            this.form = JSON.parse(JSON.stringify(this.editRow));
+          }
+        })
       }
-      return params
     },
-    async commitForm(formName){
+    setFormItem(val, itemMark, itemName) {
+      this.$set(this.form, itemMark, val.id);
+      this.$set(this.form, itemName, val.name);
+    },
+    validatorNum(rule, value, callback) {
+        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();
+          }
+        }
+    },
+    cancelMethod(val) {
+      this.$refs["form"].resetFields();
+      this.islook = false;
+      if(val){
+        this.$emit('refresh')
+      }
+      
+    },
+    submitForm(formName) {
       this.$refs[formName].validate((valid) => {
         if (valid) {
-          console.log("鏍¢獙閫氳繃")
+          let form = JSON.parse(JSON.stringify(this.form));
+          form.days=Number(form.days)
+          if (this.editRow.type == "add") {
+            createMentorInfo(form).then((res) => {
+              if (res.code == 200) {
+                this.$message({
+                  message: "娣诲姞鎴愬姛锛�",
+                  type: "success",
+                });
+                this.cancelMethod(true);
+              }
+            });
+          } else {
+            updateMentorInfo(form).then((res) => {
+              if (res.code == 200) {
+                this.$message({
+                  message: "缂栬緫鎴愬姛锛�",
+                  type: "success",
+                });
+                this.cancelMethod(true);
+              }
+            });
+          }
         } else {
           console.log('error submit!!');
           return false;
         }
       });
-
-
-    }
-  },
-  components: {
-
+    },
   },
 };
 </script>

--
Gitblit v1.8.0