瀏覽代碼

no message

aXin-0810 9 月之前
父節點
當前提交
4cac6960c4
共有 1 個文件被更改,包括 175 次插入27 次删除
  1. 175 27
      src/views/setting/departmentManagement/index.vue

+ 175 - 27
src/views/setting/departmentManagement/index.vue

@@ -3,8 +3,8 @@
     <div style="min-width: 220px; height: 100%">
       <zj-page-container>
         <div class="title">
-          <el-button style="margin-right: 5px" size="mini" icon="el-icon-search"></el-button>
-          <el-input size="mini" v-model="inputText" placeholder="请输入内容"></el-input>
+          <el-button style="margin-right: 5px" size="mini" icon="el-icon-search" @click="getTreeListData"></el-button>
+          <el-input size="mini" v-model="filterText" placeholder="请输入内容"></el-input>
         </div>
         <zj-page-fill>
           <el-tree
@@ -14,8 +14,7 @@
             :highlight-current="true"
             :expand-on-click-node="false"
             @node-click="handleNodeClick"
-            current-node-key="ASSIST_UNIT"
-            node-key="dictType"
+            :filter-node-method="filterNode"
             ref="listTree"
           >
             <span class="custom-tree-node" slot-scope="{ node, data }">
@@ -48,16 +47,33 @@
       :exportList="exportList"
     >
       <el-dialog title="设置部门" :visible.sync="dialogVisible" width="500px" :before-close="handleClose">
-        <el-form ref="form" :model="form" label-width="80px" size="mini">
-          <el-form-item label="活动名称">
-            <el-input v-model="form.name"></el-input>
+        <el-form ref="form" :model="form" label-width="100px" size="mini">
+          <el-form-item label="上级部门名称">
+            <el-input disabled v-model="form.pname"></el-input>
           </el-form-item>
-          <el-form-item label="活动名称">
-            <el-input v-model="form.name"></el-input>
+          <el-form-item label="部门名称">
+            <el-input v-model="form.deptName"></el-input>
           </el-form-item>
           <el-form-item>
-            <el-button type="primary">立即创建</el-button>
-            <el-button>取消</el-button>
+            <el-button type="primary" @click="queding">确定</el-button>
+            <el-button @click="handleClose">取消</el-button>
+          </el-form-item>
+        </el-form>
+      </el-dialog>
+      <el-dialog title="添加网点" :visible.sync="dialogVisible2" width="500px" :before-close="handleClose2">
+        <el-form ref="form" :model="form2" label-width="120px" size="mini">
+          <el-form-item label="部门名称">
+            <el-input disabled v-model="form2.deptName"></el-input>
+          </el-form-item>
+          <el-form-item label="管理网点名称">
+            <el-select style="width: 100%" v-model="form2.websitId" placeholder="请选择" @change="gengxin">
+              <el-option v-for="(item, index) in keyixuan" :key="index" :label="item.websitName" :value="item.websitId">
+              </el-option>
+            </el-select>
+          </el-form-item>
+          <el-form-item>
+            <el-button type="primary" @click="queding2">确定</el-button>
+            <el-button @click="handleClose2">取消</el-button>
           </el-form-item>
         </el-form>
       </el-dialog>
@@ -67,7 +83,6 @@
 
 <script>
 import TemplatePage from '@/components/template/template-page-1.vue'
-import { required } from '@/components/template/rules_verify.js'
 import {
   adminDeptList,
   adminDeptListExport,
@@ -87,8 +102,6 @@ export default {
   mixins: [operation_mixin],
   data() {
     return {
-      // 事件组合
-      optionsEvensGroup: [],
       // 表格属性
       tableAttributes: {},
       // 表格事件
@@ -100,20 +113,67 @@ export default {
         children: 'children',
         label: 'deptName'
       },
-      inputText: '',
+      filterText: '',
       dialogVisible: false,
-      form: {}
+      form: {
+        pid: '',
+        pname: '',
+        deptName: ''
+      },
+      dialogVisible2: false,
+      form2: {
+        adminDeptId: '',
+        deptName: '',
+        adminDeptWebsitId: '',
+        websitId: '',
+        websitName: ''
+      },
+      adminDept: null,
+      keyixuan: []
     }
   },
   mounted() {
     this.getTreeListData()
   },
   computed: {
-    formItems() {
-      return []
+    // 事件组合
+    optionsEvensGroup() {
+      return [
+        [
+          this?.keyixuan?.length
+            ? [
+                this.optionsEvensAuth('add', {
+                  click: () => {
+                    if (this.adminDept) {
+                      this.form2 = {
+                        deptName: this.adminDept.deptName,
+                        adminDeptId: this.adminDept.adminDeptId,
+                        adminDeptWebsitId: '',
+                        websitId: '',
+                        websitName: ''
+                      }
+                      this.dialogVisible2 = true
+                    } else {
+                      this.$message.warning('请先选择部门')
+                    }
+                  }
+                })
+              ]
+            : []
+        ]
+      ]
+    }
+  },
+  watch: {
+    filterText(val) {
+      this?.$refs?.listTree?.filter?.(val)
     }
   },
   methods: {
+    filterNode(value, data) {
+      if (!value) return true
+      return data.deptName.indexOf(value) !== -1
+    },
     // 请求属性数据
     getTreeListData() {
       adminDeptTree().then(res => {
@@ -122,9 +182,32 @@ export default {
       })
     },
     // 树形选中
-    handleNodeClick(e) {},
+    handleNodeClick(e) {
+      this.adminDept = { ...e }
+      adminDeptList({
+        pageNum: 1,
+        pageSize: -1,
+        params: [{ param: 'admin_dept_id', compare: '=', value: this?.adminDept?.pid }]
+      }).then(res => {
+        this.keyixuan = res.data.records
+      })
+      this.$refs.pageRef.refreshList()
+    },
+    gengxin(val) {
+      this.form2.websitName = this.keyixuan?.find(item => item.websitId == val)?.websitName
+    },
     // 列表请求函数
-    getList: adminDeptList,
+    getList(pam, cb) {
+      try {
+        if (this?.adminDept?.adminDeptId) {
+          pam.params.push({ param: 'admin_dept_id', compare: '=', value: this?.adminDept?.adminDeptId })
+        }
+        cb && cb(pam)
+        return adminDeptList(pam)
+      } catch (err) {
+      } finally {
+      }
+    },
     // 列表导出函数
     exportList: adminDeptListExport,
     // 表格列解析渲染数据更改
@@ -133,21 +216,86 @@ export default {
     },
     operation() {
       return this.operationBtn({
-        save: {
-          click: ({ row, index, column }) => {}
-        },
         del: {
-          click: ({ row, index, column }) => {}
+          click: ({ row, index, column }) => {
+            adminDeptDelWebsit({
+              adminDeptWebsitId: row.adminDeptWebsitId
+            }).then(res => {
+              this.$refs.pageRef.refreshList()
+              this.$message({
+                type: 'success',
+                message: '删除成功'
+              })
+            })
+          }
         }
       })
     },
     addbumen(data) {
+      this.form.pid = data.adminDeptId
+      this.form.pname = data.deptName
       this.dialogVisible = true
     },
-    eidbumen(data) {},
-    delbumen(data) {},
+    eidbumen(data) {
+      this.form = { ...data }
+      this.dialogVisible = true
+    },
+    delbumen(data) {
+      adminDeptDel({ adminDeptId: data.adminDeptId }).then(res => {
+        this.getTreeListData()
+        this.$message({
+          type: 'success',
+          message: '删除成功'
+        })
+      })
+    },
+    queding() {
+      if (!this.form.deptName) {
+        this.$message.warning('名字不能为空')
+      }
+      ;(this.form.adminDeptId ? adminDeptUpdate : adminDeptAdd)(this.form).then(res => {
+        this.getTreeListData()
+        this.handleClose()
+        this.$message({
+          type: 'success',
+          message: '设置成功'
+        })
+      })
+    },
     handleClose() {
       this.dialogVisible = false
+      this.form = {
+        pid: '',
+        pname: '',
+        deptName: ''
+      }
+    },
+    queding2() {
+      if (!this.form2.websitId) {
+        this.$message.warning('请选择网点')
+      }
+      ;(this.form2.id ? adminDeptUpdateWebsit : adminDeptAddWebsit)({
+        ...this.form2,
+        adminDeptId: this.adminDept.adminDeptId,
+        adminDeptWebsitId: this?.form2?.adminDeptWebsitId
+      }).then(res => {
+        this.$refs.pageRef.refreshList()
+        this.handleClose2()
+        this.$message({
+          type: 'success',
+          message: '设置成功'
+        })
+      })
+    },
+    handleClose2() {
+      this.dialogVisible2 = false
+      this.form2 = {
+        deptName: '',
+        adminDeptId: '',
+        adminDeptWebsitId: '',
+        websitId: '',
+        websitName: ''
+      }
     }
   }
 }
@@ -167,6 +315,6 @@ export default {
   flex: 1;
   display: flex;
   justify-content: space-between;
-  align-content: center;
+  align-items: center;
 }
 </style>