johnsen 7 месяцев назад
Родитель
Сommit
341a9f17bb

+ 33 - 12
src/business/platform/data/templaterender/templates/list.vue

@@ -417,6 +417,14 @@ export default {
     }
   },
   mixins: [CustomDataDisplayMixin],
+  inject: {
+    registerGrandChildMethod: {
+      default: () => {
+        // 默认值为一个空函数
+        return () => {}
+      }
+    }
+  },
   props: {
     dataTemplate: Object,
     template: Object,
@@ -491,19 +499,14 @@ export default {
       editButtons: [], // 表单按钮
       editToolbars: [],
       filterConditionKey: '',
-
       templateDialogVisible: false,
       templateDialogKey: '',
       templateDialogDynamicParams: {},
-
       exportColumnsVisible: false,
       action: '',
       selecteds: '',
-
       databaseType: 'lower',
-
       importColumnsVisible: false,
-
       selectionAll: this.multiple ? [] : {}, // 所有选中的数据包含跨页数据
       selection: this.multiple ? [] : {}, // 当前页选中的数据
       dialogTemplate: null,
@@ -514,18 +517,15 @@ export default {
       showPrint: false,
       printType: '',
       printList: [],
-
       importTableDialogVisible: false,
       uploadFileDialogVisible: false,
       position: null,
       importList: [],
       importValue: null,
       snapshotFile: '',
-
       generalShow: false,
       currentType: '',
       generalList: [],
-
       grooveDialogVisible: false,
       grooveData: {
         title: ''
@@ -535,7 +535,8 @@ export default {
       clickCount: 0, // 列表点击次数
       timer: null,
       initOneButtons: [],
-      initDblButtons: []
+      initDblButtons: [],
+      pageInfo: {}
     }
   },
   computed: {
@@ -618,11 +619,29 @@ export default {
     window.onresize = () => {
       this.handleRefreshTable()
     }
+    this.registerGrandChildMethod &&
+      this.registerGrandChildMethod(this.beforSearch)
   },
   updated() {
     this.handleRefreshTable()
   },
   methods: {
+    beforSearch(pageInfo) {
+      console.log('pageInfopageInfopageInfo--->', pageInfo)
+      this.pageInfo = pageInfo
+      // console.log('idddd===>', data)
+      const { searchForm } = this.$refs || {}
+      searchForm.$set(
+        searchForm.params,
+        'Q^parent_id_^SL',
+        pageInfo.parentId !== '-1' ? pageInfo.allSelectedNodeId.join(',') : ''
+      )
+      this.$nextTick(() => {
+        this.handleAction('pageInfo', null, [], [], 0, {
+          button_type: 'search'
+        })
+      })
+    },
     handleRefreshTable() {
       this.$nextTick(() => {
         const table = this.$refs.crud
@@ -1120,7 +1139,8 @@ export default {
       // this.selection = selection
       this.selection = data
       // 前置事件
-      this.beforeScript(command, position, selection, data, async () => {
+      this.beforeScript(command, position, selection, data, async (falg) => {
+        if (!falg) return
         let src = ''
         this.readonly = false
         const { userId } = this.$store.getters || {}
@@ -2255,6 +2275,7 @@ export default {
         callback(flag)
         return
       }
+      console.log('action======================>', action)
       JTemplate._beforeSubmit(this, action, position, selection, data, callback)
     },
     // 后置脚本
@@ -2307,7 +2328,7 @@ export default {
      * @description 行单击时触发的事件
      */
     handleRowOneclick(row, event, column) {
-      if (event.label !== '操作') {
+      if (event && event.label !== '操作') {
         console.log(row)
         this.setRowEvent('单击', row)
       }
@@ -2316,7 +2337,7 @@ export default {
      * @description 行双击时触发的事件
      */
     handleRowDblclick(row, event, column) {
-      if (event.label !== '操作') {
+      if (event && event.label !== '操作') {
         this.setRowEvent('双击', row)
       }
     },

+ 411 - 0
src/views/docManages/clauses.vue

@@ -0,0 +1,411 @@
+<template>
+  <ibps-layout ref="layout">
+    <div slot="west">
+      <ibps-type-tree
+        :width="width"
+        :height="height"
+        :category-key="categoryKey"
+        :has-permission="true"
+        @refresh="refresh"
+        @node-click="handleNodeClick"
+        @expand-collapse="handleExpandCollapse"
+      />
+    </div>
+    <ibps-container :margin-left="width + 'px'" class="page">
+      <template-list
+        :template-id="templateId"
+        :dynamic-params="dynamicParams"
+      />
+    </ibps-container>
+  </ibps-layout>
+</template>
+<script>
+import ActionUtils from '@/utils/action'
+import FixHeight from '@/mixins/height'
+import TemplateList from '@/views/platform/data/dataTemplate/template-list.vue'
+import { queryPaperOpRecod, removePaperOpRecod } from '@/api/business/general'
+
+export default {
+  components: {
+    TemplateList,
+    IbpsTypeTree: () => import('./left-tree.vue')
+  },
+  provide() {
+    return {
+      registerGrandChildMethod: (method) => {
+        this.grandChildMethod = method
+      }
+    }
+  },
+  mixins: [FixHeight],
+  data() {
+    const {
+      userId,
+      isSuper,
+      role,
+      deptList = [],
+      userList = []
+    } = this.$store.getters || {}
+    const { first, second } = this.$store.getters.level || {}
+    const hasRole = localStorage.getItem('hasHighRole') === '1'
+    const userOption = userList.map((item) => ({
+      label: item.userName,
+      value: item.userId
+    }))
+    const deptOption = deptList.map((item) => ({
+      label: item.positionName,
+      value: item.positionId
+    }))
+    const roleList = ['xtgljs', 'wjglzzc', 'wjgly']
+    const hasEditRole = role.some((item) => roleList.includes(item.alias))
+    const filterOption = [
+      {
+        descVal: '2',
+        includeSub: true,
+        old: 'position',
+        partyId: this.$store.getters.userInfo.employee.positions,
+        partyName: '',
+        scriptContent: '',
+        type: 'user',
+        userType: 'position'
+      }
+    ]
+    return {
+      grandChildMethod: null,
+      userId,
+      isSuper,
+      hasRole,
+      userOption,
+      deptOption,
+      filterOption,
+      level: second || first,
+      width: 210,
+      typeId: null,
+      allSelectedNodeId: [],
+      height: document.clientHeight,
+      loading: false,
+      filterText: '',
+      categoryKey: 'FLOW_TYPE',
+      pkKey: 'id', // 主键  如果主键不是pk需要传主键
+      defId: '1072813170935988224', // 以往体系运行记录流程ID
+      formKey: 'ywyxjlb', // 以往体系运行记录表单
+      dialogFormVisible: false,
+      pkValue: '',
+      addDataCont: {},
+      templateKey: 'ywyxjlsc',
+      tableTitle: '',
+      editDialogVisible: false,
+      dynamicParams: {},
+      templateId: '',
+      editToolbars: [
+        {
+          button_type: 'close',
+          label: '关闭',
+          key: 'close'
+        },
+        {
+          button_type: 'save',
+          label: '保存',
+          key: 'save'
+        }
+      ],
+      listData: [],
+      searchParams: {
+        dept: '',
+        submitBy: ''
+      },
+      hasEditRole,
+      listConfig: {
+        // 工具栏
+        toolbars: [{ key: 'search' }, { key: 'add' }, { key: 'remove' }],
+        // 查询条件
+        searchForm: {
+          forms: [
+            // {
+            //   prop: 'Q^nian_du_^SL',
+            //   label: '记录月份',
+            //   fieldType: 'date',
+            //   dateType: 'month',
+            //   dateFormat: 'yyyy-MM',
+            //   itemWidth: 150
+            // },
+            // {
+            //   prop: 'bian_zhi_bu_men_',
+            //   label: '部门',
+            //   fieldType: 'slot',
+            //   slotName: 'dept',
+            //   itemWidth: 120
+            // },
+            { prop: 'Q^biao_dan_ming_che^SL', label: '表单名称', width: 150 }
+            // { prop: 'Q^shi_wu_shuo_ming_^SL', label: '事务说明', width: 150 },
+            // {
+            //   prop: ['Q^bian_zhi_shi_jian^DL', 'Q^bian_zhi_shi_jian^DG'],
+            //   label: '上传时间',
+            //   fieldType: 'daterange'
+            // },
+            // {
+            //   prop: 'bian_zhi_ren_',
+            //   label: '上传人',
+            //   fieldType: 'slot',
+            //   slotName: 'user'
+            // }
+          ]
+        },
+        // 表格字段配置
+        columns: [
+          // { prop: 'fenLei', label: '表单分类', width: 120 },
+          { prop: '', label: '条款号', width: 100 },
+          {
+            prop: 'bianZhiBuMen',
+            label: '条款简称',
+            tags: deptOption,
+            width: 100,
+            sortable: true
+          },
+          { prop: 'biaoDanMingChe', label: '表单名称', width: 200 },
+          { prop: 'fuJian', label: '超链接', slotName: 'file', minWidth: 250 }
+        ],
+        rowHandle: {
+          effect: 'display',
+          actions: [
+            {
+              key: 'edit',
+              label: '编辑',
+              type: 'primary',
+              icon: 'ibps-icon-edit',
+              hidden: function () {
+                return !hasEditRole
+              }
+            }
+          ]
+        }
+      },
+      pagination: {},
+      sorts: {},
+      pageKey: ''
+    }
+  },
+  watch: {
+    filterText(val) {
+      this.$refs.tree.filter(val)
+    }
+  },
+  created() {
+    this.pageKey = this.$route?.meta?.name
+    this.templateId = this.pageKey.split('_')[1] || ''
+  },
+  // mounted() {
+  //   this.loadData()
+  // },
+  methods: {
+    refresh() {
+      this.typeId = ''
+      this.loadData()
+    },
+    handleExpandCollapse(isExpand, readonly = false) {
+      this.width = isExpand ? 200 : 50
+    },
+    search() {
+      this.loadData()
+    },
+    loadData() {
+      if (this.grandChildMethod) {
+        this.grandChildMethod(this.addDataCont)
+      }
+    },
+    handleNodeClick(nodeId, nodeData, treeDatas) {
+      // 避免重复请求
+      if (this.typeId === nodeId) {
+        return
+      }
+
+      // 文件控制-纸质运行记录上传页面,无下级菜单且无添加按钮时显示添加按钮(仅对纸质运行记录上传列表生效)
+      if (this.pageKey === 'ywyxjlsc') {
+        const noChildren = !nodeData.children?.length
+        const hasAddBtn = this.listConfig.toolbars.some(
+          (el) => el.key === 'add'
+        )
+
+        if (!noChildren && hasAddBtn) {
+          // 有下级菜单时,去除添加按钮
+          this.listConfig.toolbars = this.listConfig.toolbars.filter(
+            (el) => el.key !== 'add'
+          )
+        } else if (noChildren && !hasAddBtn && this.depth !== 0) {
+          // 无下级菜单且无添加按钮时,显示添加按钮(排除非根节点)
+          this.listConfig.toolbars.splice(1, 0, { key: 'add' })
+        }
+      }
+      const result = this.getTail(nodeData)
+      // 获取所选节点及所有子节点ID
+      this.allSelectedNodeId = result.map((i) => i.id)
+      this.typeId = nodeId
+      this.addDataCont = {
+        ...nodeData,
+        allSelectedNodeId: this.allSelectedNodeId
+      }
+      this.loadData()
+    },
+    /**
+     * 递归获取所有子节点
+     */
+    getTail(node) {
+      const result = [node] // 将自身信息添加到结果中
+      if (node.children && node.children.length > 0) {
+        // 如果有子节点,则递归获取子节点的信息
+        node.children.forEach((child) => {
+          result.push(...this.getTail(child)) // 将子节点信息添加到结果中
+        })
+      }
+      return result
+    },
+    closeHandle(v) {
+      this.dialogFormVisible = v
+      this.loadData()
+    },
+    editClose(v) {
+      this.editDialogVisible = v
+      this.loadData()
+    },
+    /**
+     * 获取格式化参数
+     */
+    getSearchFormData() {
+      const params = this.$refs['crud']
+        ? this.$refs['crud'].getSearcFormData()
+        : {}
+      params['Q^di_dian_^S'] = this.level
+      if (this.$utils.isNotEmpty(this.typeId)) {
+        params['Q^fen_lei_id_^S'] = this.allSelectedNodeId
+      }
+      const { dept, submitBy } = this.searchParams
+      if (this.$utils.isNotEmpty(dept)) {
+        params[`Q^bian_zhi_bu_men_^S`] = dept.split(',')
+      }
+      if (this.$utils.isNotEmpty(submitBy)) {
+        params[`Q^bian_zhi_ren_^S`] = submitBy.split(',')
+      }
+      if (params['Q^nian_du_^SL']) {
+        params[`Q^nian_du_^SL`] = this.$common.getFormatDate(
+          'string',
+          7,
+          params[`Q^nian_du_^SL`]
+        )
+      }
+      // console.log(params)
+      const result = {
+        parameters: this.formatParameters(params),
+        ...ActionUtils.formatParams(null, this.pagination, this.sorts)
+      }
+      return result
+    },
+    formatParameters(data) {
+      if (this.$utils.isEmpty(data)) {
+        return []
+      }
+      const parameters = Object.entries(data).map(([key, value]) =>
+        Array.isArray(value)
+          ? {
+              relation: 'OR',
+              parameters: value.map((v) => ({
+                key,
+                value: v,
+                param: this.$utils.guid()
+              }))
+            }
+          : { key, value }
+      )
+      return parameters.length === 1
+        ? [parameters[0]]
+        : [{ relation: 'AND', parameters }]
+    },
+    /**
+     * 处理按钮事件
+     */
+    handleAction(command, position, selection, data, index, button) {
+      switch (command) {
+        case 'search': // 查询
+          ActionUtils.setFirstPagination(this.pagination)
+          this.search()
+          break
+        case 'remove':
+          console.log(selection, data)
+          this.handleRemove(selection)
+          break
+        case 'add': // 添加
+          this.dialogFormVisible = true
+          this.pkValue = ''
+          break
+        case 'edit': // 编辑
+          this.editDialogVisible = true
+          this.pkValue = data.id
+          break
+        default:
+          break
+      }
+    },
+    /**
+     * 删除记录
+     */
+    handleRemove(ids) {
+      if (!ids || !ids.length) {
+        return this.$message.warning('请选择要删除的数据!')
+      }
+      this.$confirm(
+        `将删除所选中的 ${ids.length} 条数据,数据删除后无法恢复,确定要继续吗?`,
+        '提示',
+        {
+          confirmButtonText: '确认',
+          cancelButtonText: '取消',
+          type: 'warning',
+          showClose: false,
+          closeOnClickModal: false
+        }
+      ).then(() => {
+        removePaperOpRecod({ ids: ids.join(',') })
+          .then(() => {
+            ActionUtils.removeSuccessMessage()
+            this.search()
+          })
+          .catch(() => {})
+      })
+    },
+    /**
+     * 处理分页事件
+     */
+    handlePaginationChange(page) {
+      ActionUtils.setPagination(this.pagination, page)
+      this.loadData()
+    },
+    /**
+     * 处理排序
+     */
+    handleSortChange(sort) {
+      // 处理字段长度,可能出现排序字段与数据库字段不一致情况
+      sort.sortBy = sort.sortBy.slice(0, 17)
+      ActionUtils.setSorts(this.sorts, sort)
+      this.loadData()
+    }
+  }
+}
+</script>
+<style lang="less" scoped>
+.title {
+  font-size: 14px;
+  margin: 21px 5px 5px;
+  padding: 0;
+}
+
+/deep/ .el-tree-node__content {
+  display: block;
+}
+
+/deep/ .el-form-item__label {
+  text-align: left;
+}
+
+/deep/ .el-dialog__footer {
+  display: flex;
+  justify-content: center;
+}
+</style>

+ 267 - 0
src/views/docManages/left-tree.vue

@@ -0,0 +1,267 @@
+<template>
+  <div class="jbd-tree">
+    <ibps-tree
+      ref="treeIndex"
+      :title="title"
+      :width="width"
+      :height="height"
+      :data="treeData"
+      :location="location"
+      :options="treeOptions"
+      :contextmenus="hasContextmenu ? treeContextmenus : []"
+      :position="position"
+      :has-permission="hasPermission"
+      :category-key="categoryKey"
+      @action-event="handleTreeAction"
+      @node-click="handleNodeClick"
+      @expand-collapse="handleExpandCollapse"
+    />
+  </div>
+</template>
+
+<script>
+import { findTreeData, remove } from '@/api/platform/cat/type'
+import ActionUtils from '@/utils/action'
+
+import TypeEdit from '@/views/platform/cat/type/edit'
+import TypeSort from '@/views/platform/cat/type/sort'
+import TypeMove from '@/views/platform/cat/type/move'
+export default {
+  components: {
+    TypeEdit,
+    TypeSort,
+    TypeMove
+  },
+  props: {
+    title: {
+      type: String
+    },
+    location: {
+      type: String,
+      default: 'initial'
+    },
+    categoryKey: {
+      type: String,
+      required: true
+    },
+    hasContextmenu: {
+      // 是否有右键菜单
+      type: Boolean,
+      default: false
+    },
+    width: {
+      type: [String, Number],
+      default: 200
+    },
+    height: {
+      type: [String, Number],
+      default: 500
+    },
+    position: {
+      type: String,
+      default: 'west'
+    },
+    hasPermission: {
+      // 是否有权限控制
+      type: Boolean,
+      default: true
+    }
+  },
+  data() {
+    return {
+      typeFormVisible: false,
+      sortFormVisible: false,
+      moveFormVisible: false,
+      editId: '', // 编辑dialog需要使用
+      editTitle: '编辑分类',
+      // 树配置
+      treeOptions: { rootPId: '-1' },
+      treeContextmenus: [
+        { icon: 'add', label: '添加分类', value: 'add' },
+        { icon: 'edit', label: '编辑分类', value: 'edit', rights: ['node'] },
+        {
+          icon: 'delete',
+          label: '删除分类',
+          value: 'remove',
+          rights: ['node']
+        },
+        { type: 'divided' },
+        { icon: 'sort', label: '分类排序', value: 'sort' },
+        {
+          icon: 'arrows-v',
+          label: '移动节点',
+          value: 'moveNode',
+          rights: ['node']
+        }
+      ],
+      treeData: [],
+      isPrivate: false,
+      typeData: {} // 记录分类信息
+    }
+  },
+  created() {
+    this.loadTreeData()
+  },
+  methods: {
+    loadTreeData() {
+      const { first = '', second = '' } = this.$store.getters.level || {}
+      const params = { categoryKey: this.categoryKey }
+      if (this.categoryKey === 'FILE_TYPE') {
+        params.diDian = second || first
+      }
+      this.$common
+        .request('query', {
+          key: 'tkcx',
+          params: [null]
+        })
+        .then((res) => {
+          const data = res.variables.data || []
+          data.sort((a, b) => a.tenant_id_ - b.tenant_id_)
+          const treeData = data.map((t) => ({
+            name: t.name_ || t.tiao_kuan_hao_ + t.tiao_kuan_jian_ch,
+            parentId: t.parent_id_,
+            id: t.id_,
+            tiaoKuanHao: t.tiao_kuan_hao_,
+            tiaoKuanJianCheng: t.tiao_kuan_jian_ch,
+            ...t
+          }))
+          if (!data.some((t) => t.parentId === '-1')) {
+            treeData.push({
+              name: '任务分类',
+              id: '1417522060971737088',
+              parentId: '-1'
+            })
+          }
+          console.log('treeData===>', treeData)
+          this.$emit('treeData', treeData)
+          this.treeData = treeData
+        })
+      // findTreeData(params).then((response) => {
+      //   this.treeData = response.data || []
+      //   if (this.hasPermission) {
+      //     this.treeData = this.treeData.filter((i) => i.isShow !== '1')
+      //   }
+      //   // 按照分类过滤
+      //   const routeName = this.$route.name
+      //   const routeMap = {
+      //     jssllb: '体系分类',
+      //     ywtxyxjl: '模板分类',
+      //     'wjkzgl-ywyxjlsc': '模板分类'
+      //   }
+      //   this.treeData = this.treeData.filter((i) => {
+      //     const authorityName = JSON.parse(i.authorityName)
+      //     if (authorityName) {
+      //       if (authorityName.fenLei) {
+      //         return (
+      //           authorityName.fenLei === routeMap[routeName] ||
+      //           authorityName.fenLei === '通用'
+      //         )
+      //       } else {
+      //         return true
+      //       }
+      //     }
+      //     return true
+      //   })
+      //   console.log('response.data===>', response.data)
+      //   this.$emit('treeData', response.data)
+      // })
+    },
+    handleTreeAction(command, position, selection, data) {
+      switch (command) {
+        case 'refresh': // 查询
+          this.loadTreeData()
+          break
+        case 'add': // 添加
+          this.typeData = data // { 'name': data.name, 'id': data.id }
+          this.isPrivate = false
+          this.editTitle = '添加分类'
+          this.handTreeEdit()
+          break
+        case 'addPrivate': // 添加
+          this.typeData = data // { 'name': data.name, 'id': data.id }
+          this.isPrivate = true
+          this.editTitle = '添加私有分类'
+          this.handTreeEdit()
+          break
+        case 'edit': // 编辑
+          this.typeData = data
+          this.isPrivate = true
+          this.editTitle = '编辑分类'
+          this.handTreeEdit(data.id)
+          break
+        case 'moveNode': // 移动节点
+          this.typeData = data
+          this.isPrivate = true
+          this.editTitle = '移动节点'
+          this.handTreeMove(data.id)
+          break
+        case 'remove': // 删除
+          this.handleTreeRemove(data.id)
+          break
+        case 'export': // 导出
+          this.handTreeExport(data.id, data.name)
+          break
+        case 'sort': // 排序
+          this.handTreeSort(data)
+          break
+      }
+    },
+    handleNodeClick(data) {
+      this.$emit(
+        'node-click',
+        data.parentId === '-1' ? '' : data.id,
+        data,
+        this.treeData
+      )
+    },
+    handleExpandCollapse(isExpand) {
+      this.$emit('expand-collapse', isExpand)
+    },
+    handTreeEdit(editId) {
+      this.editId = editId || ''
+      this.typeFormVisible = true
+    },
+    handTreeMove(editId) {
+      this.editId = editId || ''
+      this.moveFormVisible = true
+    },
+    handTreeSort(data) {
+      const children = data.children
+      if (children && children.length > 0) {
+        if (children.length === 1) {
+          ActionUtils.warning('只有一个节点无需排序')
+        } else {
+          this.editId = data.id || ''
+          this.sortFormVisible = true
+        }
+      } else {
+        ActionUtils.warning('无子节点排序')
+      }
+    },
+    handleTreeRemove(ids) {
+      ActionUtils.removeRecord(ids)
+        .then((ids) => {
+          remove({ typeId: ids })
+            .then((response) => {
+              ActionUtils.removeSuccessMessage()
+              this.loadTreeData()
+            })
+            .catch((err) => {
+              console.error(err)
+            })
+        })
+        .catch(() => {})
+    },
+    showTree() {
+      this.$nextTick(() => {
+        this.$refs.treeIndex.handleExpandCollapse()
+      })
+    }
+  }
+}
+</script>
+<style>
+/* .jbd-tree .el-tree > .el-tree-node > .el-tree-node__content {
+        display: none;
+    } */
+</style>