From bf2338f5cc71890cda247d46edcffa42e21871f6 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期四, 07 十一月 2024 09:44:42 +0800
Subject: [PATCH] 优化需求

---
 company/src/components/system/user/OperaUserWindow.vue |   78 ++++++++++++++++++++++++++++++++++++---
 1 files changed, 72 insertions(+), 6 deletions(-)

diff --git a/company/src/components/system/user/OperaUserWindow.vue b/company/src/components/system/user/OperaUserWindow.vue
index a64d417..46df45a 100644
--- a/company/src/components/system/user/OperaUserWindow.vue
+++ b/company/src/components/system/user/OperaUserWindow.vue
@@ -23,6 +23,14 @@
           <el-button type="primary" style="flex-shrink: 0; margin-left: 15px;" v-else>{{num}}s</el-button>
         </div>
       </el-form-item>
+      <el-form-item label="閮ㄩ棬" prop="departmentId">
+        <el-cascader
+          :options="organization"
+          v-model="form.departmentId"
+          placeholder="璇烽�夋嫨"
+          :props="{ label: 'name', value: 'id', checkStrictly: true }"
+          clearable />
+      </el-form-item>
       <el-form-item label="鎶勯�佹枃浠堕偖绠�" prop="email">
         <el-input v-model="form.email" placeholder="璇疯緭鍏�" v-trim />
       </el-form-item>
@@ -37,7 +45,7 @@
 import PositionSelect from '@/components/common/PositionSelect'
 import { checkMobile, checkEmail } from '@/utils/form'
 import { sendSms } from '@/api/business/smsEmail'
-
+import { tree } from '@/api/business/companyDepartment'
 export default {
   name: 'OperaUserWindow',
   extends: BaseOpera,
@@ -51,10 +59,12 @@
         realname: '', // 濮撳悕
         mobile: '', // 鎵嬫満鍙风爜
         email: '',
-        captcha: ''
+        captcha: '',
+        departmentId: ''
       },
       num: 0,
       timer: null,
+      organization: [],
       // 楠岃瘉瑙勫垯
       rules: {
         username: [
@@ -66,6 +76,9 @@
         mobile: [
           { required: true, validator: checkMobile }
         ],
+        departmentId: [
+          { required: true, message: '璇烽�夋嫨閮ㄩ棬' }
+        ],
         email: [
           { required: true, message: '璇疯緭鍏ラ偖绠�' }
         ]
@@ -73,6 +86,52 @@
     }
   },
   methods: {
+    __confirmCreate () {
+      this.$refs.form.validate((valid) => {
+        if (!valid) {
+          return
+        }
+        let obj = JSON.parse(JSON.stringify(this.form))
+        obj.departmentId = obj.departmentId[0]
+        // 璋冪敤鏂板缓鎺ュ彛
+        this.isWorking = true
+        this.api.create(obj)
+          .then(() => {
+            this.visible = false
+            this.$tip.apiSuccess('鏂板缓鎴愬姛')
+            this.$emit('success')
+          })
+          .catch(e => {
+            this.$tip.apiFailed(e)
+          })
+          .finally(() => {
+            this.isWorking = false
+          })
+      })
+    },
+    __confirmEdit () {
+      this.$refs.form.validate((valid) => {
+        if (!valid) {
+          return
+        }
+        let obj = JSON.parse(JSON.stringify(this.form))
+        obj.departmentId = obj.departmentId[0]
+        // 璋冪敤鏂板缓鎺ュ彛
+        this.isWorking = true
+        this.api.updateById(obj)
+          .then(() => {
+            this.visible = false
+            this.$tip.apiSuccess('淇敼鎴愬姛')
+            this.$emit('success')
+          })
+          .catch(e => {
+            this.$tip.apiFailed(e)
+          })
+          .finally(() => {
+            this.isWorking = false
+          })
+      })
+    },
     send() {
       if (!this.form.mobile) {
         this.$message.warning('璇疯緭鍏ユ墜鏈哄彿')
@@ -82,6 +141,12 @@
         .then(res => {
           this.num = 60
           this.setTime()
+        })
+    },
+    getTree() {
+      tree()
+        .then(records => {
+          this.organization = records
         })
     },
     setTime() {
@@ -100,6 +165,7 @@
     open (title, target) {
       this.title = title
       this.visible = true
+      this.getTree()
       clearInterval(this.timer)
       this.num = 0
       // 鏂板缓
@@ -107,8 +173,8 @@
         this.$nextTick(() => {
           this.$refs.form.resetFields()
           this.form.id = null
-          this.form.departmentId = null
-          this.form.positionIds = []
+          // this.form.departmentId = null
+          // this.form.positionIds = []
         })
         return
       }
@@ -117,8 +183,8 @@
         for (const key in this.form) {
           this.form[key] = target[key]
         }
-        this.form.departmentId = target.department == null ? null : target.department.id
-        this.form.positionIds = target.positions == null ? [] : target.positions.map(p => p.id)
+        // this.form.departmentId = target.department == null ? null : target.department.id
+        // this.form.positionIds = target.positions == null ? [] : target.positions.map(p => p.id)
       })
     }
   },

--
Gitblit v1.9.3