Ver Fonte

修改树节点传参

林倩 há 3 anos atrás
pai
commit
fa214fac6a

+ 10 - 0
src/api/permission-selfhelp-manage.js

@@ -16,6 +16,16 @@ export function savePermissionApply(data) {
   });
 }
 
+// 更新申请
+export function updateApply(data) {
+  return request({
+    url: `${baseUrl}/funApplyUpdate`,
+    method: 'POST',
+    data
+  })
+
+}
+
 // 权限自助列表ul
 export const tableUrl = `${baseUrl}/authApplySearch`
 

+ 1 - 1
src/pages/common/transfer-tree/index.vue

@@ -501,7 +501,7 @@ export default {
      */
     addToTarget() {
       let keys = this.$refs['from-tree'].getCheckedKeys(true);
-
+      //  let aa =  this.$refs['from-tree'].getCheckedNodes(false, true);
       let _newValue = _.union(this.value, keys);
 
       // 触发输入框的改变

+ 0 - 1
src/pages/common/transfer-tree/mixin.js

@@ -216,7 +216,6 @@ export default {
 
       // 执行方法
       getAllKeyValue(_treeData);
-
       return _treeAllKey;
     }
   }

+ 3 - 2
src/pages/list-manage/red-list-manage/component/app-func.vue

@@ -112,7 +112,6 @@ export default {
       const selectedData = this.$refs.vxeGrid.getCheckboxRecords(true).filter((item) => !item.isTreeNode);
       this.$refs.vxeGrid.reloadData(selectedData);
       this.getList();
-
     },
     /**
      * 重置
@@ -125,7 +124,9 @@ export default {
     // 打开弹窗
     openLayer(title, content, operate) {
       const vm = this;
-      const selectedData = vm.$refs.vxeGrid.getCheckboxRecords(true).filter((item) => !item.isTreeNode);
+      const checkboxRecords = this.$refs.vxeGrid.getCheckboxRecords(true);
+      const indeterminateRecords = this.$refs.vxeGrid.getCheckboxIndeterminateRecords(true);
+      const selectedData = [...checkboxRecords, ...indeterminateRecords].filter((item) => item.pid);
       const layer = this.$dgLayer({
         title,
         content,

+ 7 - 3
src/pages/list-manage/red-list-manage/component/batch-add-appfunc.vue

@@ -66,9 +66,13 @@ export default {
       this.$emit('close');
     },
     handleSubmit() {
-       const selectedData = this.$refs.vxeGrid.getCheckboxRecords(true).filter(item =>!item.isTreeNode );
-      if (selectedData.length > 0) {
-        this.setLevel(selectedData);
+      // 获取全选和半选的节点
+       const checkboxRecords = this.$refs.vxeGrid.getCheckboxRecords(true);
+       const indeterminateRecords = this.$refs.vxeGrid.getCheckboxIndeterminateRecords(true);
+       const totalRecords = [...checkboxRecords,...indeterminateRecords].filter(item => item.appId);
+       
+      if (totalRecords.length > 0) {
+        this.setLevel(totalRecords);
       } else {
         this.$message.warning('请至少选择一个应用功能!');
       }

+ 1 - 0
src/pages/list-manage/red-list-manage/component/batch-setlevel-appfunc.vue

@@ -85,6 +85,7 @@ export default {
     },
     // 保存
     save() {
+      console.log("选中的数据", this.selectedData);
       const params = this.handlerValues(this.selectedData).map((item) => {
         return {
           ...item,

+ 68 - 10
src/pages/permission-selfhelp-manage/component/app-func-form.vue

@@ -49,18 +49,24 @@ function findIndexArray(data, id, indexArray) {
 
 export default {
   props: {
-    selectKeys: [Array]
+    selectKeys: [Array],
+    // 是否需要过滤父节点
+    needFilter: {
+      type: Boolean,
+      default: false
+    }
   },
   components: { transferTree },
   data() {
     return {
       approveContent: this.value,
-      selectedValue: this.selectKeys,
+      selectedValue: [],
       data: []
     };
   },
   computed: {},
   methods: {
+    // 树节点转成文字
     nodeTransferLabel() {
       const funcAttr = this.selectedValue.map((item) => {
         return findIndexArray(this.$refs.transferTree.targetData, item, []);
@@ -79,16 +85,19 @@ export default {
       if (this.selectedValue.length == 0) {
         this.$message.warning('请至少选择一条功能资源!');
       } else {
-       
         const approveContent = this.nodeTransferLabel();
-        const resourceInfos = this.selectedValue
+        // 获取目标树所有的key
+        const allKeys = this.$refs.transferTree.allKeyValue(false, this.$refs.transferTree.targetData);
+        const resourceInfos = allKeys
           .map((item) => this.$refs.transferTree.$refs['to-tree'].getNode(item).data)
           .map((item) => {
             return {
-              appId: item.pid,
+              appId: item.appId,
               funId: item.id
             };
-          });
+          })
+          .filter((item) => item.appId);
+
         this.$emit('success', approveContent, this.selectedValue, resourceInfos);
       }
     },
@@ -96,12 +105,61 @@ export default {
       console.log(value, data.label);
       if (!value) return true;
       return data.label.indexOf(value) !== -1;
+    },
+    // 获取申请人已被授权得功能id
+    getSetFunIdsByUser() {
+      return new Promise((resolve) => {
+        const params = {
+          userId: this.$store.getters.user.id
+        };
+        userHasAuthFunIds(params).then((res) => {
+          resolve(res.data.content);
+        });
+      });
+    },
+    // 获取全量的菜单树
+    getAllTree() {
+      return new Promise((resolve) => {
+        allAppFuncTree().then((res) => {
+          resolve(res.data.content);
+        });
+      });
+    },
+    // 获取子节点,去除父节点key
+    getChildKeys(data, val) {
+      let keys = [];
+
+      function filterParentKey(_data, key) {
+        _data.filter((item) => {
+          if (item.id == key && !item.isTreeNode) {
+            keys.push(key);
+            return;
+          } else {
+            if (item.child.length > 0) {
+              filterParentKey(item.child, key);
+            } else {
+              return
+            }
+          }
+        });
+      }
+
+      for (let i = 0; i < val.length; i++) {
+        const key = val[i];
+        filterParentKey(data, key);
+      }
+
+      return keys
     }
   },
-  created() {
-    allAppFuncTree().then((res) => {
-      this.data = res.data.content;
-    });
+
+  async created() {
+    this.data = await this.getAllTree();
+    const funIds = await this.getSetFunIdsByUser();
+    this.selectedValue = [...this.selectKeys, ...funIds];  
+    if (this.needFilter) {
+     this.selectedValue = this.getChildKeys(this.data, [...this.selectKeys, ...funIds]);
+    }
   },
   mounted() {}
 };

+ 76 - 37
src/pages/permission-selfhelp-manage/component/basic-form.vue

@@ -14,8 +14,8 @@
               <dg-select
                 :data="applyType"
                 v-model="sizeForm.applyType"
-                @change="handleChangeApproveType"
                 :disabled="type == 'edit'"
+                @change="handleChangeApplyType"
               ></dg-select>
             </div>
           </el-form-item>
@@ -28,6 +28,7 @@
                 :data="processNameType"
                 v-model="sizeForm.processName"
                 @change="handleChangeProcessName"
+                :disabled="type == 'edit'"
               ></dg-select>
             </div>
           </el-form-item>
@@ -44,10 +45,10 @@
         </dg-col>
         <dg-col :span="12">
           <!-- 流程名称+申请人姓名+日期 -->
-          <el-form-item label="审批单标题:" prop="applyTitle">
-            <div v-if="isDetail">{{ sizeForm.applyTitle }}</div>
+          <el-form-item label="审批单标题:" prop="flowTitle">
+            <div v-if="isDetail">{{ sizeForm.flowTitle }}</div>
             <div v-else>
-              <el-input v-model="sizeForm.applyTitle" :disabled="true"></el-input>
+              <el-input v-model="sizeForm.flowTitle" :disabled="true"></el-input>
             </div>
           </el-form-item>
         </dg-col>
@@ -247,9 +248,11 @@
             </dg-row> -->
     </el-form>
     <div v-footer>
-      <dg-button @click="handleCancel">取消</dg-button>
-      <dg-button type="primary" @click="handleSave">保存</dg-button>
-      <dg-button type="primary" @click="handleSubmit">提交</dg-button>
+      <div v-if="type !== 'detail'">
+        <dg-button @click="handleCancel">取消</dg-button>
+        <dg-button type="primary" @click="handleSave">保存</dg-button>
+        <dg-button type="primary" @click="handleSubmit">提交</dg-button>
+      </div>
     </div>
   </div>
 </template>
@@ -260,7 +263,8 @@ import appFuncForm from './app-func-form.vue';
 import serviceSourceForm from './service-source-form.vue';
 import dataSourceForm from './data-source-form.vue';
 import moment from 'moment';
-import { savePermissionApply } from '@/api/permission-selfhelp-manage';
+// import { savePermissionApply, applyDetail, updateApply } from '@/api/permission-selfhelp-manage';
+import * as Api from '@/api/permission-selfhelp-manage';
 
 export default {
   name: 'FormItem',
@@ -361,7 +365,8 @@ export default {
           value: '测试应用',
           label: '测试应用'
         }
-      ]
+      ],
+      applyContentCom: appFuncForm
     };
   },
   components: {},
@@ -374,7 +379,7 @@ export default {
     'sizeForm.processName': {
       handler(val) {
         if (val) {
-          this.sizeForm.applyTitle =
+          this.sizeForm.flowTitle =
             this.processNameType.find((item) => item.value == val).label +
             '-' +
             this.sizeForm.applicantName +
@@ -387,13 +392,26 @@ export default {
     'sizeForm.applyType': {
       handler(val) {
         this.sizeForm.applicantId = val;
+        let component;
+        if (val == '2') {
+          component = dataSourceForm;
+        } else if (val == '1') {
+          component = serviceSourceForm;
+        } else {
+          component = appFuncForm;
+        }
+        this.applyContentCom = component;
       }
     }
   },
   methods: {
     // 改变流程名称
     handleChangeProcessName() {},
-    // 取消
+    handleChangeApplyType() {
+      this.sizeForm.flowContent = '';
+      this.sizeForm.resourceInfoDTO = [];
+    },
+    // 取消/关闭
     handleCancel() {
       this.$emit('close');
     },
@@ -413,11 +431,33 @@ export default {
     },
     save() {
       const { resourceInfos, applyId, userType, userName, userCode, ...otherInfo } = this.sizeForm;
-      const params = {
-        resourceInfos,
-        workFlow: otherInfo
+      let params = {
+        resourceInfos
       };
-      savePermissionApply(params).then((res) => {
+      let api = '';
+
+      if (this.type == 'add') {
+        params['workFlow'] = otherInfo;
+        api = 'savePermissionApply';
+      } else {
+        const { permissionValidType, operateType, applicantPhoneNo, applyReason, startTime, endTime, flowContent  } = this.sizeForm;
+      // 只选可编辑的字段
+        params = {
+          resourceInfos,
+          permissionValidType,
+          operateType,
+          applicantPhoneNo,
+          applyReason,
+          startTime,
+          endTime,
+          flowContent,
+          id: this.id
+
+        };
+        api = 'updateApply';
+      }
+
+      Api[api](params).then((res) => {
         if (this.sizeForm.operateType == '2') {
           this.$message.success('提交成功!');
         } else {
@@ -429,24 +469,15 @@ export default {
     // 选择
     handleChoice() {
       const vm = this;
-      const applyType = vm.sizeForm.applyType;
-      // 审批内容选择
-      let component;
-      if (applyType == '0') {
-        component = appFuncForm;
-      } else if (applyType == '1') {
-        component = serviceSourceForm;
-      } else {
-        component = dataSourceForm;
-      }
-
+      const keys = [...this.applySelectKeys, ...this.sizeForm.resourceInfos.map((item) => item.funId)];
       const layer = this.$dgLayer({
         title: '选择资源',
         shadow: [0.4, '#fff'],
         props: {
-          selectKeys: this.applySelectKeys
+          selectKeys: keys,
+          needFilter: true
         },
-        content: component,
+        content: this.applyContentCom,
         area: ['1200px', '700px'],
         on: {
           success(approveContent, selectKeys, resourceInfos = []) {
@@ -465,14 +496,6 @@ export default {
         }
       });
     },
-    // 切换审批类型
-    handleChangeApproveType(val) {
-      this.sizeForm.flowContent = '';
-      this.sizeForm.resourceInfoDTO = [];
-      if (val == '0') {
-        this.approveComponent = 'appFuncForm';
-      }
-    },
     /**
      * 下载附件
      */
@@ -509,6 +532,20 @@ export default {
         return;
       }
       return this.$confirm(`确定移除 ${file.name}?`);
+    },
+    getDetail() {
+      const params = {
+        id: this.id,
+        needFlowInfo: true
+      };
+      Api.applyDetail(params).then((res) => {
+        const { workFlow, resourceInfos, ...otherInfo } = res.data.content;
+        this.sizeForm = {
+          ...workFlow,
+          resourceInfos,
+          ...otherInfo
+        };
+      });
     }
   },
   created() {
@@ -516,7 +553,7 @@ export default {
     if (!this.id) {
       this.sizeForm = {
         // 流程标题
-        applyTitle: '',
+        flowTitle: '',
         applicantId: '0', // id
         applicantIdcard: idcard, // 申请人身份证号
         applicantName: name, // 申请人姓名
@@ -538,6 +575,8 @@ export default {
         userName: '',
         userCode: ''
       };
+    } else {
+      this.getDetail();
     }
   },
   mounted() {}

+ 7 - 1
src/pages/permission-selfhelp-manage/component/detail.vue

@@ -19,6 +19,9 @@
         <process-status></process-status>
       </el-tab-pane>
     </el-tabs>
+    <div v-footer>
+      <dg-button @click="handleCancel">关闭</dg-button>
+    </div>
   </div>
 </template>
 
@@ -26,7 +29,7 @@
 import flowChart from './flow-chart';
 import processStatus from './process-status';
 import basicForm from './basic-form.vue';
-import commentsTable from "./comments-table"
+import commentsTable from './comments-table';
 export default {
   props: {
     id: [String]
@@ -49,6 +52,9 @@ export default {
       if (tab.name == 'second' && this.chartKey == 0) {
         this.chartKey++;
       }
+    },
+    handleCancel() {
+      this.$emit("close");
     }
   },
   created() {},

+ 2 - 7
src/pages/permission-selfhelp-manage/index.vue

@@ -63,7 +63,7 @@
 <script>
 import Table from '@/pages/common/table';
 import { tableHeader } from './DataConfig';
-import { tableUrl, applyDetail, delApply } from '@/api/permission-selfhelp-manage';
+import { tableUrl, applyDetail, delApply, userHasAuthFunIds } from '@/api/permission-selfhelp-manage';
 export default {
   components: {
     Table
@@ -131,15 +131,10 @@ export default {
       });
     },
     handleViewDetail(row) {
-      const params = {
-        id: row.id,
-        needFlowInfo: true
-      };
-      applyDetail(params).then((res) => {});
       const layer = this.$dgLayer({
         title: '详情',
         props: {
-          id: '1111',
+          id: row.id,
           type: 'detail'
         },
         content: require('./component/detail.vue'),