zhengnaiwen_citu преди 6 месеца
родител
ревизия
c5b35bd433
променени са 2 файла, в които са добавени 78 реда и са изтрити 24 реда
  1. 5 0
      src/api/system.js
  2. 73 24
      src/views/system/workflow/workflowApproved.vue

+ 5 - 0
src/api/system.js

@@ -169,6 +169,11 @@ export function getOrganizationAtlasEmployee (params) {
   return http.post('/organization/employee/atlas', params)
 }
 
+// 机构图钻取岗位图例
+export function getOrganizationAtlasPostName (params) {
+  return http.post('/digitizationData/employee/postName/atlas', params)
+}
+
 // 组织结构 导入
 export function importOrganization (params) {
   return http.upload('/organization/upload', params)

+ 73 - 24
src/views/system/workflow/workflowApproved.vue

@@ -14,20 +14,14 @@
           </el-select>
         </el-form-item>
         <el-form-item label="处理方">
-          <el-select v-if="item.handleType === 0" v-model="item.handleValue" placeholder="请选择处理方">
-            <el-option
-              v-for="item in personOptions"
-              :key="item.value"
-              :label="item.label"
-              :value="item.value">
-            </el-option>
-          </el-select>
           <el-cascader
-            v-if="item.handleType === 1"
             v-model="item.handleValue"
+            :ref="`cascader_${index}`"
             placeholder="请选择处理方"
-            :props="organizationProp"
-            :options="organizationTree"
+            :show-all-levels="false"
+            :props="item.handleType === 0 ? personOptions : organizationProp"
+            :options="item.handleType === 0 ? personOrganizationTree : postOrganizationTree"
+            @change="onChangeCascader(item, `cascader_${index}`)"
           ></el-cascader>
         </el-form-item>
         <div class="button-group">
@@ -47,10 +41,23 @@
 import {
   saveWorkflow
 } from '@/api/workflow'
+import {
+  getOrganizationAtlasEmployee,
+  getOrganizationAtlasPostName
+} from '@/api/system'
 import { mapGetters } from 'vuex'
+import { cloneDeep } from 'lodash'
 export default {
   name: 'workflowApproved',
   data () {
+    const defaultOptions = {
+      lazy: true,
+      emitPath: false,
+      value: 'organizationNo',
+      label: 'organizationName',
+      children: 'child'
+    }
+    const _this = this
     return {
       key: 0,
       formValues: {
@@ -64,24 +71,28 @@ export default {
         ]
       },
       item: {},
-      personOptions: [],
+      personOptions: {
+        ...defaultOptions,
+        async lazyLoad (node, resolve) {
+          _this.onSearch(node, resolve, getOrganizationAtlasEmployee)
+        }
+      },
       organizationProp: {
-        lazy: true,
-        value: 'organizationNo',
-        label: 'organizationName',
-        children: 'child',
-        checkStrictly: true,
-        lazyLoad (node, resolve) {
-          if (node.children) {
-            return resolve(node.children)
-          }
-          console.log(11)
+        ...defaultOptions,
+        async lazyLoad (node, resolve) {
+          _this.onSearch(node, resolve, getOrganizationAtlasPostName)
         }
       }
     }
   },
   computed: {
-    ...mapGetters(['organizationTree'])
+    ...mapGetters(['organizationTree']),
+    personOrganizationTree () {
+      return cloneDeep(this.organizationTree)
+    },
+    postOrganizationTree () {
+      return cloneDeep(this.organizationTree)
+    }
   },
   methods: {
     open (item) {
@@ -126,9 +137,45 @@ export default {
     onDelete (index) {
       this.formValues.items.splice(index, 1)
     },
+    // 情况选项
     onChange (item) {
       item.handleValue = null
     },
+    async onSearch (node, resolve, api) {
+      const nodeData = node.data
+      if (!nodeData.hasChildren) {
+        return resolve()
+      }
+      try {
+        const { data } = await api({
+          organizationNo: node.value
+        })
+        resolve(data.nodes.map(e => {
+          return {
+            organizationNo: e.id,
+            organizationName: e.text,
+            leaf: true
+          }
+        }))
+      } catch (error) {
+        resolve()
+        this.$message.error(error)
+      }
+    },
+    // 提交参数格式化
+    onChangeCascader (item, ref) {
+      if (item.handleType === 0) {
+        item.handleValueData = {
+          userId: item.handleValue
+        }
+        return
+      }
+      const node = this.$refs[ref][0].getCheckedNodes()[0]
+      item.handleValueData = {
+        organizationNo: node.parent.value,
+        postName: node.value
+      }
+    },
     async onSure () {
       try {
         await saveWorkflow({
@@ -139,7 +186,9 @@ export default {
               sort: index
             }
           }),
-          workFlowTmplate: this.item.workFlowTmplate
+          workFlowTmplate: {
+            workFlowTmplateId: this.item.workFlowTmplate.workFlowTmplateId
+          }
         })
         this.$message.success('保存成功')
       } catch (error) {