From 5506edbe54883b31db3cc8e4a1d9d0795a18a3c9 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期五, 27 十二月 2024 14:37:54 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/2.0.1' into 2.0.1

---
 company/src/components/business/OperaCompanyDepartmentWindow.vue |  138 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 138 insertions(+), 0 deletions(-)

diff --git a/company/src/components/business/OperaCompanyDepartmentWindow.vue b/company/src/components/business/OperaCompanyDepartmentWindow.vue
new file mode 100644
index 0000000..ae1d5d8
--- /dev/null
+++ b/company/src/components/business/OperaCompanyDepartmentWindow.vue
@@ -0,0 +1,138 @@
+<template>
+    <GlobalWindow
+        :title="title"
+        :visible.sync="visible"
+        :confirm-working="isWorking"
+        @confirm="confirm"
+    >
+        <el-form :model="form" ref="form" :rules="rules">
+            <el-form-item label="涓婄骇缁勭粐" prop="parentId">
+                <el-cascader
+                    :options="organization"
+                    v-model="form.parentId"
+                    :disabled="form.disabled"
+                    placeholder="璇烽�夋嫨涓婄骇缁勭粐"
+                    :props="{ label: 'name', value: 'id', checkStrictly: true }"
+                    clearable />
+            </el-form-item>
+            <el-form-item label="缁勭粐鍚嶇О" prop="name">
+                <el-input v-model="form.name" placeholder="璇疯緭鍏ュ悕绉�" v-trim/>
+            </el-form-item>
+        </el-form>
+    </GlobalWindow>
+</template>
+
+<script>
+  import BaseOpera from '@/components/base/BaseOpera'
+  import GlobalWindow from '@/components/common/GlobalWindow'
+  import { tree } from '@/api/business/companyDepartment'
+  import { mapState } from 'vuex'
+  export default {
+    name: 'OperaCompanyDepartmentWindow',
+    extends: BaseOpera,
+    components: { GlobalWindow },
+    computed: {
+      ...mapState(['userInfo'])
+    },
+    data () {
+      return {
+        // 琛ㄥ崟鏁版嵁
+        form: {
+          id: null,
+          name: '',
+          parentId: [],
+          type: '',
+          disabled: false
+        },
+        // 楠岃瘉瑙勫垯
+        rules: {
+          name: [
+            { required: true, message: '璇疯緭鍏ョ粍缁囧悕绉�' }
+          ]
+        },
+        organization: []
+      }
+    },
+    created () {
+      this.config({
+        api: '/business/companyDepartment',
+        'field.id': 'id'
+      })
+    },
+    methods: {
+      __confirmCreate () {
+        this.$refs.form.validate((valid) => {
+          if (!valid) {
+            return
+          }
+          let obj = JSON.parse(JSON.stringify(this.form))
+          obj.parentId = obj.parentId && obj.parentId.length > 0 ? obj.parentId[0] : ''
+          obj.type = this.userInfo.type
+          // 璋冪敤鏂板缓鎺ュ彛
+          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.parentId = obj.parentId && obj.parentId.length > 0 ? obj.parentId[0] : ''
+          obj.type = this.userInfo.type
+          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
+            })
+        })
+      },
+      open (title, target) {
+        this.title = title
+        this.visible = true
+        this.getTree()
+        // 鏂板缓
+        if (target == null) {
+          this.$nextTick(() => {
+            this.$refs.form.resetFields()
+            this.form[this.configData['field.id']] = null
+          })
+          return
+        }
+        // 缂栬緫
+        this.$nextTick(() => {
+          for (const key in this.form) {
+            this.form[key] = target[key]
+          }
+        })
+      },
+      getTree() {
+        tree()
+          .then(records => {
+            this.organization = records
+          })
+      }
+    }
+  }
+</script>

--
Gitblit v1.9.3