Prechádzať zdrojové kódy

分类设置(系统分类管理,文件夹分类设置)

shenqilong 1 rok pred
rodič
commit
4842923458

+ 513 - 451
src/components/ibps-tree/index.vue

@@ -1,506 +1,568 @@
 <template>
-  <div
-    ref="ibpsTree"
-    :style="{width:width+'px',position: location}"
-    class="ibps-tree"
-  >
     <div
-      v-if="title"
-      ref="header"
-      :class="['layout-header--' +$ELEMENT.size]"
-      class="layout-header"
+        ref="ibpsTree"
+        :style="{ width: width + 'px', position: location }"
+        class="ibps-tree"
     >
-      <div
-        v-show="isExpand"
-        :style="{width:width-55+'px'}"
-        class="layout-header-title ibps-ellipsis"
-      >{{ title }}</div>
-      <div
-        v-if="angleDouble"
-        class="layout-header-tools"
-      >
-       <!-- <el-tooltip
-          :content="isExpand?'收缩':'展开'"
-          placement="bottom-start"
+        <div
+            v-if="title"
+            ref="header"
+            :class="['layout-header--' + $ELEMENT.size]"
+            class="layout-header"
         >
-          <a
-            herf="javascript:void(0);"
-            class="pinBtn"
-            @click="handleExpandCollapse"
-          >
-            <ibps-icon :name="expandCollapseIcon" />
-          </a>
-        </el-tooltip> -->
-      </div>
-    </div>
-  <!--  <div
-      v-if="toolbars"
-      :class="isExpand?'ibps-show-expand':'ibps-show-collapse'"
-    >
-      <div
-        v-if="toolbars"
-        v-show="isExpand"
-        ref="toolbar"
-        class="ibps-tree-toolbar"
-      >
-        <ibps-toolbar
-          :actions="toolbars"
-          type="icon"
-          @action-event="handleActionEvent"
-        />
-      </div>
-    </div> -->
-   <!-- <div
-      v-show="!isExpand"
-      class="ibps-show"
-      :style="{ height:(isExpand?treeHeight:height)-45+'px'}"
-    >&nbsp;</div>
-    <div
-      v-if="$slots.searchForm "
-      v-show="isExpand"
-      ref="searchForm"
-      class="ibps-tree-search-form"
-    >
-      <slot name="searchForm" />
-    </div> -->
-    <div
-      v-show="isExpand"
-      :style="{ height:(isExpand?treeHeight:height)-45+'px'}"
-      class="ibps-tree-main"
-    >
-      <el-scrollbar
-        style="height: 100%;width:100%;"
-        wrap-class="ibps-tree-wrapper"
-      >
-        <el-tree
-          ref="elTree"
-          v-loading="loading"
-          :data="!lazy?treeData:null"
-          :lazy="lazy"
-          :load="load"
-          v-bind="treeOptions"
-          :default-expand-all ="judgeTitle()"
-          node-key="id"
-          :default-expanded-keys="treeExpandData"
-          @node-click="handleNodeClick"
-          @node-contextmenu="handleNodeContextmenu"
+            <div
+                v-show="isExpand"
+                :style="{ width: width - 55 + 'px' }"
+                class="layout-header-title ibps-ellipsis"
+            >
+                {{ title }}
+            </div>
+            <div v-if="angleDouble" class="layout-header-tools">
+                <el-tooltip
+                    :content="isExpand ? '收缩' : '展开'"
+                    placement="bottom-start"
+                >
+                    <a
+                        herf="javascript:void(0);"
+                        class="pinBtn"
+                        @click="handleExpandCollapse"
+                    >
+                        <ibps-icon :name="expandCollapseIcon" />
+                    </a>
+                </el-tooltip>
+            </div>
+        </div>
+        <div
+            v-if="toolbars"
+            :class="isExpand ? 'ibps-show-expand' : 'ibps-show-collapse'"
+        >
+            <div
+                v-if="toolbars"
+                v-show="isExpand"
+                ref="toolbar"
+                class="ibps-tree-toolbar"
+            >
+                <ibps-toolbar
+                    :actions="toolbars"
+                    type="icon"
+                    @action-event="handleActionEvent"
+                />
+            </div>
+        </div>
+        <div
+            v-show="!isExpand"
+            class="ibps-show"
+            :style="{ height: (isExpand ? treeHeight : height) - 45 + 'px' }"
         >
-          <span
-            slot-scope="scope"
-            class="ibps-custom-tree-node"
-          >
-            <ibps-icon
-              v-if="showIcon"
-              :name="getIcon(scope.data)"
+          &nbsp;
+        </div>
+        <div
+            v-if="$slots.searchForm"
+            v-show="isExpand"
+            ref="searchForm"
+            class="ibps-tree-search-form"
+        >
+            <slot name="searchForm" />
+        </div>
+        <div
+            v-show="isExpand"
+            :style="{ height: (isExpand ? treeHeight : height) - 45 + 'px' }"
+            class="ibps-tree-main"
+        >
+            <el-scrollbar
+                style="height: 100%; width: 100%"
+                wrap-class="ibps-tree-wrapper"
+            >
+                <el-tree
+                    v-if="!lazy ? (treeData && treeData.length>0) : lazy "
+                    ref="elTree"
+                    v-loading="loading"
+                    :data="!lazy ? treeData : null"
+                    :lazy="lazy"
+                    :load="load"
+                    v-bind="treeOptions"
+                    :default-expand-all="judgeTitle()"
+                    node-key="id"
+                    :default-expanded-keys="treeExpandData"
+                    @node-click="handleNodeClick"
+                    @node-contextmenu="handleNodeContextmenu"
+                >
+                    <span slot-scope="scope" class="ibps-custom-tree-node" :title="scope.node.label">
+                        <!-- <img
+                          v-if="['FILE_TYPE', 'FLOW_TYPE'].includes(categoryKey) && scope.data.categoryKey"
+                          :src="filePng"
+                          style="vertical-align: middle; height: 20px;"
+                      > -->
+                        <template v-if="['FILE_TYPE', 'FLOW_TYPE'].includes(categoryKey)">
+                            <ibps-icon
+                                v-if="scope.data.templateId"
+                                style="font-size: 12px;"
+                                name="file-text-o"
+                            />
+                            <ibps-icon v-else :name="getFolderIcon(scope)" />
+                        </template>
+                        <ibps-icon
+                            v-else-if="showIcon"
+                            :name="getIcon(scope.data)"
+                        />
+                        <span>{{ scope.node.label }}</span>
+                    </span>
+                </el-tree>
+            </el-scrollbar>
+        </div>
+        <!--右键菜单-->
+        <ibps-contextmenu
+            v-if="contextmenus"
+            ref="contextmenu"
+            :visible.sync="contextmenuFlag"
+            :menulist="contextmenuList"
+            :x="contentmenuX"
+            :y="contentmenuY"
+            :z-index="zIndex"
+        >
+            <ibps-contextmenu-list
+                :menulist="contextmenuList"
+                @row-click="handleContextmenuClick"
             />
-            <span>{{ scope.node.label }}</span>
-          </span>
-        </el-tree>
-      </el-scrollbar>
+        </ibps-contextmenu>
     </div>
-    <!--右键菜单-->
-    <ibps-contextmenu
-      v-if="contextmenus"
-      ref="contextmenu"
-      :visible.sync="contextmenuFlag"
-      :menulist="contextmenuList"
-      :x="contentmenuX"
-      :y="contentmenuY"
-      :z-index="zIndex"
-    >
-      <ibps-contextmenu-list
-        :menulist="contextmenuList"
-        @row-click="handleContextmenuClick"
-      />
-    </ibps-contextmenu>
-  </div>
 </template>
 <script>
 import TreeUtils from '@/utils/tree'
 import PopupManager from '@/utils/popup'
 import IbpsContextmenu from '@/components/ibps-contextmenu'
 import IbpsContextmenuList from '@/components/ibps-contextmenu/components/contentmenu-list'
-
+// import filePng from '@/assets/images/form/file.png'
 export default {
-  components: {
-    IbpsContextmenu,
-    IbpsContextmenuList
-  },
-  props: {
-    title: String,
-    angleDouble: {
-      type: Boolean,
-      default: true
-    },
-    width: {
-      type: Number,
-      default: 200
-    },
-    height: {
-      type: Number,
-      default: 400
-    },
-    position: {
-      type: String,
-      default: 'west'
-    },
-    location: {
-      type: String,
-      default: 'initial'
-    },
-    loading: {
-      type: Boolean,
-      default: false
-    },
-    data: {
-      type: Array
-    },
-    dataType: { // 数据类型,tree:树形,list:列表
-      type: String,
-      default: 'list'
-    },
-    customZindex: {
-      type: Number,
-      default: 2003
-    },
-    options: {
-      type: Object,
-      default: () => {
-        return {}
-      }
-    },
-    toolbars: {
-      type: [Array, Boolean],
-      default: () => {
-        return [{
-          key: 'refresh'
-        }, {
-          key: 'expand'
-        }, {
-          key: 'compress'
-        }]
-      }
-    },
-    contextmenus: {
-      type: Array,
-      default: () => {
-        return []
-      }
-    },
-    load: Function,
-    lazy: {
-      type: Boolean,
-      default: false
-    }
-  },
-  data() {
-    return {
-      treeHeight: this.height,
-      isExpand: true,
-      autoPlacement: true,
-      contextmenuFlag: false,
-      contentmenuX: 0,
-      contentmenuY: 0,
-      contextmenuData: {},
-      contextmenuList: [],
-      zIndex: 2003,
-      treeExpandData:[],
-    }
-  },
-  computed: {
-    treeData() {
-      if (!this.data || this.data.length === 0) return []
-      this.data.map(item => {
-        if (item.name === '任务分类') {
-            item.name = '事务分类'
+    components: {
+        IbpsContextmenu,
+        IbpsContextmenuList
+    },
+    props: {
+        title: String,
+        angleDouble: {
+            type: Boolean,
+            default: true
+        },
+        width: {
+            type: Number,
+            default: 200
+        },
+        height: {
+            type: Number,
+            default: 400
+        },
+        position: {
+            type: String,
+            default: 'west'
+        },
+        location: {
+            type: String,
+            default: 'initial'
+        },
+        loading: {
+            type: Boolean,
+            default: false
+        },
+        data: {
+            type: Array
+        },
+        dataType: {
+            // 数据类型,tree:树形,list:列表
+            type: String,
+            default: 'list'
+        },
+        customZindex: {
+            type: Number,
+            default: 2003
+        },
+        options: {
+            type: Object,
+            default: () => {
+                return {}
+            }
+        },
+        toolbars: {
+            type: [Array, Boolean],
+            default: () => {
+                return [
+                    {
+                        key: 'refresh'
+                    },
+                    {
+                        key: 'expand'
+                    },
+                    {
+                        key: 'compress'
+                    }
+                ]
+            }
+        },
+        contextmenus: {
+            type: Array,
+            default: () => {
+                return []
+            }
+        },
+        load: Function,
+        lazy: {
+            type: Boolean,
+            default: false
+        },
+        categoryKey: {
+            type: String,
+            default: ''
         }
-      })
-      if (this.dataType === 'list') {
-        return TreeUtils.transformToTreeFormat(JSON.parse(JSON.stringify(this.data)), {
-          idKey: this.treeOptions['node-key'],
-          pIdKey: this.pidKey,
-          childrenKey: this.treeOptions['props']['children']
-        })
-      } else {
-        return JSON.parse(JSON.stringify(this.data))
-      }
     },
-    treeOptions() {
-      const defaultOptions = {
-        'rootPId': null,
-        'node-key': 'id',
-        'pid-key': 'parentId',
-        'default-expand-all': true,
-        'expand-on-click-node': false,
-        'highlight-current': true,
-        props: {
-          children: 'children',
-          label: 'name'
+    data () {
+        return {
+            treeHeight: this.height,
+            isExpand: true,
+            autoPlacement: true,
+            contextmenuFlag: false,
+            contentmenuX: 0,
+            contentmenuY: 0,
+            contextmenuData: {},
+            contextmenuList: [],
+            zIndex: 2003,
+            treeExpandData: [],
+            activedId: ''
+            // filePng
         }
-      }
-      return Object.assign(defaultOptions, this.options)
-    },
-    pidKey() {
-      return this.treeOptions['pid-key']
-    },
-    rootPId() {
-      return this.treeOptions['rootPId'] || null
-    },
-    showIcon() {
-      return this.treeOptions['showIcon'] || false
     },
-    expandCollapseIcon() {
-      if (this.position === 'west') {
-        return this.isExpand ? 'angle-double-left' : 'angle-double-right'
-      } else {
-        return this.isExpand ? 'angle-double-right' : 'angle-double-left'
-      }
-    }
-  },
-  watch: {
-    height() {
-      this.handleTreeHeight()
-    },
-    customZindex(val) {
-      this.zIndex = val
-    },
-    treeData(val){
-     if(val && val[0] &&  val[0].children){
-        this.treeExpandData.push(val[0].children[0].id)
-        }
-    }
-  },
-  mounted() {
-    this.handleTreeHeight()
-    if (this.contextmenus && this.contextmenus.length > 0) {
-      this.fixZIndex()
-    }
-  },
-  methods: {
-    /**
-     * 判斷tree是否展开
-     */
-    judgeTitle(){
-      if(this.title == '业务对象管理'||this.title == undefined){
-        return true
+    computed: {
+        treeData () {
+            if (!this.data || this.data.length === 0) return []
+            this.data.map((item) => {
+                if (item.name === '任务分类') {
+                    item.name = '记录分类'
+                }
+            })
+            if (this.dataType === 'list') {
+                return TreeUtils.transformToTreeFormat(
+                    JSON.parse(JSON.stringify(this.data)),
+                    {
+                        idKey: this.treeOptions['node-key'],
+                        pIdKey: this.pidKey,
+                        childrenKey: this.treeOptions['props']['children']
+                    }
+                )
+            } else {
+                return JSON.parse(JSON.stringify(this.data))
+            }
+        },
+        treeOptions () {
+            const defaultOptions = {
+                rootPId: null,
+                'node-key': 'id',
+                'pid-key': 'parentId',
+                'default-expand-all': true,
+                'expand-on-click-node': false,
+                'highlight-current': true,
+                props: {
+                    children: 'children',
+                    label: 'name'
+                }
+            }
+            return Object.assign(defaultOptions, this.options)
+        },
+        pidKey () {
+            return this.treeOptions['pid-key']
+        },
+        rootPId () {
+            return this.treeOptions['rootPId'] || null
+        },
+        showIcon () {
+            return this.treeOptions['showIcon'] || false
+        },
+        expandCollapseIcon () {
+            if (this.position === 'west') {
+                return this.isExpand ? 'angle-double-left' : 'angle-double-right'
+            } else {
+                return this.isExpand ? 'angle-double-right' : 'angle-double-left'
+            }
         }
-      return this.lazy
-    },
-    /**
-     * zxh 修复zindex 不是最高的被遮住
-     */
-    fixZIndex() {
-      this.zIndex = PopupManager.getZIndex()
-    },
-    getIcon(data) {
-      let icon = data ? data[this.treeOptions['iconKey'] || 'icon'] : 'list-alt'
-      if (icon) { return icon }
-      if (data[this.pidKey] === this.rootPId) {
-        icon = this.treeOptions['rootIcon'] || 'home'
-      } else {
-        icon = this.treeOptions['nodeIcon'] || 'list-alt'
-      }
-    },
-    handleTreeHeight() {
-      this.treeHeight = this.height
-      if (this.$refs.header) {
-        this.treeHeight -= this.$refs.header.clientHeight
-      }
-      if (this.$refs.toolbar) {
-        this.treeHeight -= this.$refs.toolbar.clientHeight
-      }
-      if (this.$refs.searchForm) {
-        this.treeHeight -= this.$refs.searchForm.clientHeight
-      }
-    },
-    handleActionEvent(action, position, data) {
-      const command = action.key
-      if (command === 'expand') {
-        this.expandCompressTree(true)
-      } else if (command === 'compress') {
-        this.expandCompressTree(false)
-      }
-      this.$emit('action-event', command, position, data)
     },
-    expandCompressTree(expanded) {
-      for (var i = 0; i < this.$refs.elTree.store._getAllNodes().length; i++) {
-        this.$refs.elTree.store._getAllNodes()[i].expanded = expanded
-      }
-    },
-    handleNodeClick(data) {
-      this.$emit('node-click', data)
-    },
-    refreshNode(id) {
-      const node = this.$refs.elTree.getNode(id) // 通过节点id找到对应树节点对象
-      node.loaded = false
-      node.expand() // 主动调用展开节点方法,重新查询该节点下的所有子节点
-    },
-    /**
-     * 处理节点右键菜单
-     */
-    handleNodeContextmenu(event, data) {
-      if (!this.contextmenus || this.contextmenus.length === 0) return
-      let target = event.target
-      let flag = false
-      if ((target && target.className.indexOf('el-tree-node__content') > -1) ||
-        (target && target.className.indexOf('ibps-custom-tree-node') > -1)) {
-        flag = true
-      } else if ((target && target.parentNode.className.indexOf('el-tree-node__content') > -1) ||
-       (target && target.parentNode.className.indexOf('ibps-custom-tree-node') > -1)) {
-        target = target.parentNode
-        flag = true
-      }
-      if (flag) {
-        event.preventDefault()
-        event.stopPropagation()
-        this.handleContextmenuList(data)
-        this.contextmenuData = data
-        this.contextmenuFlag = true
-        this.handleReferenceContextmenu(event)
-      }
-    },
-    handleContextmenuList(data) {
-      this.contextmenuList = []
-      const isRoot = data[this.pidKey] === this.rootPId
-      this.contextmenus.forEach((menu) => {
-        if (!menu.rights) {
-          this.contextmenuList.push(menu)
-        } else {
-          if (Array.isArray(menu.rights)) {
-            if (menu.rights.indexOf('node') > -1 && !isRoot) {
-              this.contextmenuList.push(menu)
+    watch: {
+        height () {
+            this.handleTreeHeight()
+        },
+        customZindex (val) {
+            this.zIndex = val
+        },
+        treeData (val) {
+            // if (val && val[0] && val[0].children) {
+            //     this.treeExpandData.push(val[0].children[0].id)
+            // }
+            // 如果是部门管理里只显示一个医院的,那么就展开所有的节点
+            if (val && val[0] && val[0].children && val[0].children.length === 1 &&
+              this.title === '部门管理') {
+                return
             }
-          } else if (typeof menu.rights === 'function') {
-            if (menu.rights.call(this, menu, data, isRoot)) {
-              this.contextmenuList.push(menu)
+            if (val && val[0] && val[0].children && val[0].children.length && val[0].children.length !== 1) {
+                // 默认打开第三层
+                for (const i of val[0].children) {
+                    if (i.children) {
+                        this.treeExpandData.push(
+                            i.children.length ? i.children[0].id : i.id
+                        )
+                    }
+                }
             }
-          }
         }
-      })
     },
-    // 处理菜单位置
-    handleReferenceContextmenu(event) {
-      const eventX = event.pageX
-      const eventY = event.pageY
-      this.$nextTick(() => {
-        const contextmenuPosition = {
-          top: eventY,
-          left: eventX
-        }
-        if (this.autoPlacement) {
-          const el = this.$refs.contextmenu.$el
-          const contextmenuWidth = el.clientWidth
-          const contextmenuHeight = el.clientHeight
-          if (contextmenuHeight + eventY >= window.innerHeight) {
-            contextmenuPosition.top -= contextmenuHeight
-          }
-          if (contextmenuWidth + eventX >= window.innerWidth) {
-            contextmenuPosition.left -= contextmenuWidth
-          }
+    mounted () {
+        this.handleTreeHeight()
+        if (this.contextmenus && this.contextmenus.length > 0) {
+            this.fixZIndex()
         }
-
-        this.contentmenuX = contextmenuPosition.left
-        this.contentmenuY = contextmenuPosition.top
-      })
     },
-    handleContextmenuClick(command) {
-     this.contextmenuFlag = false
-      this.$emit('action-event', command, 'contextmenu', this.contextmenuData[this.pkKey], this.contextmenuData)
-    },
-    handleExpandCollapse() {
-      this.isExpand = !this.isExpand
-      this.$emit('expand-collapse', this.isExpand)
-    },
-    remove(data) {
-      this.$refs.elTree.remove(data)
-    },
-    getCurrentKey() {
-      return this.$refs.elTree.getCurrentKey()
+    methods: {
+        /**
+       * 判斷tree是否展开
+       */
+        judgeTitle () {
+            if (this.title === '业务对象管理' || this.title === undefined || (this.treeData[0] && this.treeData[0].children && this.treeData[0].children.length === 1 && this.title === '部门管理')) {
+                return true
+            }
+            return this.lazy
+        },
+        /**
+       * zxh 修复zindex 不是最高的被遮住
+       */
+        fixZIndex () {
+            this.zIndex = PopupManager.getZIndex()
+        },
+        getIcon (data) {
+            let icon = data ? data[this.treeOptions['iconKey'] || 'icon'] : 'list-alt'
+            if (icon) {
+                return icon
+            }
+            if (data[this.pidKey] === this.rootPId) {
+                icon = this.treeOptions['rootIcon'] || 'home'
+            } else {
+                icon = this.treeOptions['nodeIcon'] || 'list-alt'
+            }
+        },
+        getFolderIcon ({ data, node }) {
+            const { expanded, childNodes = [] } = node
+            const { id } = data
+            return (expanded && childNodes.length) || id === this.activedId ? 'folder-open-o' : 'folder-o'
+        },
+        handleTreeHeight () {
+            this.treeHeight = this.height
+            if (this.$refs.header) {
+                this.treeHeight -= this.$refs.header.clientHeight
+            }
+            if (this.$refs.toolbar) {
+                this.treeHeight -= this.$refs.toolbar.clientHeight
+            }
+            if (this.$refs.searchForm) {
+                this.treeHeight -= this.$refs.searchForm.clientHeight
+            }
+        },
+        handleActionEvent (action, position, data) {
+            const command = action.key
+            if (command === 'expand') {
+                this.expandCompressTree(true)
+            } else if (command === 'compress') {
+                this.expandCompressTree(false)
+            }
+            this.$emit('action-event', command, position, data)
+        },
+        expandCompressTree (expanded) {
+            for (
+                var i = 0;
+                i < this.$refs.elTree.store._getAllNodes().length;
+                i++
+            ) {
+                this.$refs.elTree.store._getAllNodes()[i].expanded = expanded
+            }
+        },
+        handleNodeClick (data) {
+            this.activedId = data.id
+            this.$emit('node-click', data)
+        },
+        refreshNode (id) {
+            const node = this.$refs.elTree.getNode(id) // 通过节点id找到对应树节点对象
+            node.loaded = false
+            node.expand() // 主动调用展开节点方法,重新查询该节点下的所有子节点
+        },
+        /**
+       * 处理节点右键菜单
+       */
+        handleNodeContextmenu (event, data) {
+            if (!this.contextmenus || this.contextmenus.length === 0) return
+            let target = event.target
+            let flag = false
+            if ((target && target.className.indexOf('el-tree-node__content') > -1) || (target && target.className.indexOf('ibps-custom-tree-node') > -1)) {
+                flag = true
+            } else if ((target && target.parentNode.className.indexOf('el-tree-node__content') > -1) || (target && target.parentNode.className.indexOf('ibps-custom-tree-node') > -1)) {
+                target = target.parentNode
+                flag = true
+            }
+            if (flag) {
+                event.preventDefault()
+                event.stopPropagation()
+                this.handleContextmenuList(data)
+                this.contextmenuData = data
+                this.contextmenuFlag = true
+                this.handleReferenceContextmenu(event)
+            }
+        },
+        handleContextmenuList (data) {
+            this.contextmenuList = []
+            const isRoot = data[this.pidKey] === this.rootPId
+            this.contextmenus.forEach((menu) => {
+                if (!menu.rights) {
+                    this.contextmenuList.push(menu)
+                } else {
+                    if (Array.isArray(menu.rights)) {
+                        if (menu.rights.indexOf('node') > -1 && !isRoot) {
+                            this.contextmenuList.push(menu)
+                        }
+                    } else if (typeof menu.rights === 'function') {
+                        if (menu.rights.call(this, menu, data, isRoot)) {
+                            this.contextmenuList.push(menu)
+                        }
+                    }
+                }
+            })
+        },
+        // 处理菜单位置
+        handleReferenceContextmenu (event) {
+            const eventX = event.pageX
+            const eventY = event.pageY
+            this.$nextTick(() => {
+                const contextmenuPosition = {
+                    top: eventY,
+                    left: eventX
+                }
+                if (this.autoPlacement) {
+                    const el = this.$refs.contextmenu.$el
+                    const contextmenuWidth = el.clientWidth
+                    const contextmenuHeight = el.clientHeight
+                    if (contextmenuHeight + eventY >= window.innerHeight) {
+                        contextmenuPosition.top -= contextmenuHeight
+                    }
+                    if (contextmenuWidth + eventX >= window.innerWidth) {
+                        contextmenuPosition.left -= contextmenuWidth
+                    }
+                }
+
+                this.contentmenuX = contextmenuPosition.left
+                this.contentmenuY = contextmenuPosition.top
+            })
+        },
+        handleContextmenuClick (command) {
+            this.contextmenuFlag = false
+            this.$emit(
+                'action-event',
+                command,
+                'contextmenu',
+                this.contextmenuData[this.pkKey],
+                this.contextmenuData
+            )
+        },
+        handleExpandCollapse () {
+            this.isExpand = !this.isExpand
+            this.$emit('expand-collapse', this.isExpand)
+        },
+        remove (data) {
+            this.$refs.elTree.remove(data)
+        },
+        getCurrentKey () {
+            return this.$refs.elTree.getCurrentKey()
+        }
     }
-  }
 }
 </script>
 
-<style lang="scss" >
+<style lang="scss" scoped>
 $border-color: #e5e6e7;
 .ibps-tree {
   .layout-header {
-    background: #FFFFFF;
-    height: 35px;
-    border-left: 1px solid $border-color;
-    border-bottom: 1px solid $border-color;
-    font-weight: bold;
-    text-align: center;
-    padding: 5px;
-    position: relative;
-    overflow: hidden;
-    overflow-y: none;
-    &--medium {
-      height: 40px;
-    }
-    &--small {
-        height: 35px;
-    }
-    &--mini {
-        height: 30px;
-    }
-    .layout-header-title {
-      float: left;
-      text-align: left;
-      font-size: 14px;
-      margin: 10px 5px 5px;
-      padding: 0;
-    }
-    .layout-header-tools {
-      float: right;
-      margin-top: 5px;
+      background: #ffffff;
+      height: 35px;
+      border-left: 1px solid $border-color;
+      border-bottom: 1px solid $border-color;
+      font-weight: bold;
+      text-align: center;
+      padding: 5px;
       position: relative;
-      padding: 0;
-      .pinBtn {
-        cursor: pointer;
-        margin-left: 5px;
-        color: #c4c4c4;
-        font-size: 25px;
+      overflow: hidden;
+      overflow-y: none;
+      &--medium {
+          height: 40px;
+      }
+      &--small {
+          height: 35px;
+      }
+      &--mini {
+          height: 30px;
+      }
+      .layout-header-title {
+          float: left;
+          text-align: left;
+          font-size: 14px;
+          margin: 10px 5px 5px;
+          padding: 0;
+      }
+      .layout-header-tools {
+          float: right;
+          margin-top: 5px;
+          position: relative;
+          padding: 0;
+          .pinBtn {
+              cursor: pointer;
+              margin-left: 5px;
+              color: #c4c4c4;
+              font-size: 25px;
+          }
       }
-    }
   }
   .ibps-show {
-    background: #ffffff;
+      background: #ffffff;
   }
-  .ibps-show-expand{
-    height: 42px;
-    background: #ffffff;
-    border-bottom: 1px solid $border-color;
+  .ibps-show-expand {
+      height: 42px;
+      background: #ffffff;
+      border-bottom: 1px solid $border-color;
   }
 
-  .ibps-show-collapse{
-     background: #ffffff;
+  .ibps-show-collapse {
+      background: #ffffff;
   }
 
   .ibps-tree-toolbar {
-    border: 1px solid $border-color;
-    height: 35px;
-    padding: 5px;
+      border: 1px solid $border-color;
+      height: 35px;
+      padding: 5px;
   }
 
   .ibps-tree-search-form {
-    padding: 5px;
-    border-right: 1px solid $border-color;
-    background: #ffffff;
+      padding: 5px;
+      border-right: 1px solid $border-color;
+      background: #ffffff;
   }
   .ibps-tree-main {
-    border: 1px solid $border-color;
-    background: #ffffff;
+      border: 1px solid $border-color;
+      background: #ffffff;
   }
   .ibps-tree-wrapper {
-    background: #ffffff;
-    .el-tree > .el-tree-node {
-      display: inline-block;
-    }
+      background: #ffffff;
+      ::v-deep {
+          .el-tree > .el-tree-node {
+              display: block;
+          }
+      }
   }
   .ibps-custom-tree-node {
-    font-size: 14px;
-    padding-right: 8px;
+      font-size: 13px;
+      padding-right: 8px;
+      .ibps-icon {
+          margin-right: 2px;
+      }
   }
 }
 </style>

+ 492 - 260
src/views/platform/cat/type/edit.vue

@@ -1,285 +1,517 @@
 <template>
-  <!--对话框-->
-  <el-dialog
-    v-if="displayType ==='dialog'"
-    :title="title"
-    :visible.sync="dialogVisible"
-    :close-on-click-modal="false"
-    :close-on-press-escape="false"
-    append-to-body
-    class="dialog"
-    :class="className"
-    @open="getFormData"
-    @close="closeDialog"
-  >
-    <el-form
-      ref="typeForm"
-      v-loading="dialogLoading"
-      :element-loading-text="$t('common.loading')"
-      :model="type"
-      :rules="rules"
-      :label-width="formLabelWidth"
-      @submit.native.prevent
+    <!--对话框-->
+    <el-dialog
+        v-if="displayType ==='dialog'"
+        :title="title"
+        :visible.sync="dialogVisible"
+        :close-on-click-modal="false"
+        :close-on-press-escape="false"
+        append-to-body
+        class="dialog"
+        :class="className"
+        @open="getFormData"
+        @close="closeDialog"
     >
-      <!-- <el-form-item  v-show="!formId" label="父节点名称:">
-        <span>{{ parentData.name }}</span>
-      </el-form-item> -->
+        <el-form
+            ref="typeForm"
+            v-loading="dialogLoading"
+            :element-loading-text="$t('common.loading')"
+            :model="type"
+            :rules="rules"
+            :label-width="formLabelWidth"
+            @submit.native.prevent
+        >
+            <!-- <el-form-item v-show="!formId" label="父节点名称:">
+                <span>{{ parentData.name }}</span>
+            </el-form-item> -->
 
-      <el-form-item label="分类名称:" prop="name">
-        <el-input v-model="type.name" v-pinyin="{vm:type,key:'typeKey'}" />
-      </el-form-item>
-      <el-form-item label="分类Key:" prop="typeKey">
-        <el-input v-model="type.typeKey" :disabled="$utils.isNotEmpty(formId)" />
-      </el-form-item>
+            <el-form-item label="分类名称:" prop="name">
+                <el-input
+                    v-model="type.name"
+                    v-pinyin="{vm:type,key:'typeKey'}"
+                />
+            </el-form-item>
+            <el-form-item label="分类Key:" prop="typeKey">
+                <el-input
+                    v-model="type.typeKey"
+                    :disabled="$utils.isNotEmpty(formId)"
+                />
+            </el-form-item>
+            <el-form-item
+                v-show="categoryKey==='DIC_TYPE'"
+                label="分类类型:"
+                prop="struType"
+            >
+                <el-radio-group v-model="type.struType">
+                    <el-radio
+                        v-for="option in srtuOptions"
+                        :key="option.value"
+                        :label="option.value"
+                    >{{ option.label }}
+                    </el-radio>
+                </el-radio-group>
+            </el-form-item>
+        </el-form>
+        <div slot="footer" class="el-dialog--center">
+            <ibps-toolbar
+                :actions="toolbars"
+                @action-event="handleActionEvent"
+            />
+        </div>
+    </el-dialog>
+    <!--默认形式-->
+    <div v-else class="main-container">
+        <ibps-container type="full" class="page">
+            <template slot="header">
+                <el-button
+                    type="primary"
+                    :disabled="readonly"
+                    icon="ibps-icon-save"
+                    @click="handleSave()"
+                >保存</el-button>
+            </template>
+            <el-form
+                ref="typeForm"
+                :model="type"
+                :rules="rules"
+                :label-width="formLabelWidth"
+            >
+                <el-form-item label="分类:">
+                    <span>{{ isPrivateLocal ? '私有分类' : '普通分类' }}</span>
+                </el-form-item>
+                <el-form-item v-show="!formId" label="父节点名称:">
+                    <span>{{ parentData.name }}</span>
+                </el-form-item>
+                <el-form-item label="分类名称:" prop="name">
+                    <el-input
+                        v-if="!readonly"
+                        v-model="type.name"
+                        v-pinyin="{vm:type,key:'typeKey'}"
+                    />
+                    <span v-else>{{ type.name }}</span>
+                </el-form-item>
+                <el-form-item label="分类Key:" prop="typeKey">
+                    <el-input
+                        v-if="!readonly"
+                        v-model="type.typeKey"
+                        :disabled="$utils.isNotEmpty(formId)"
+                    />
+                    <span v-else>{{ type.typeKey }}</span>
+                </el-form-item>
+                <el-form-item
+                    v-show="categoryKey==='FILE_TYPE'"
+                    label="查阅权限:"
+                    prop="authorityObject.chaYue"
+                >
+                    <el-radio-group
+                        v-if="!readonly"
+                        v-model="type.authorityObject.chaYue"
+                        @change="radioChangeHandle"
+                    >
+                        <el-radio label="公用查阅">公用查阅</el-radio>
+                        <el-radio label="部门查阅">部门查阅</el-radio>
+                        <el-radio label="受限查阅">受限查阅</el-radio>
+                    </el-radio-group>
+                    <span v-else>{{ type.authorityObject.chaYue }}</span>
+                </el-form-item>
+                <el-form-item
+                    v-show="categoryKey==='FILE_TYPE' && type.authorityObject.chaYue=='部门查阅'"
+                    label="部门:"
+                    prop="authorityObject.buMen"
+                >
+                    <el-cascader
+                        v-model="type.authorityObject.buMen"
+                        placeholder="请选择部门"
+                        :options="cascaderOptions"
+                        :props="cascaderProps"
+                        filterable
+                        :disabled="readonly"
+                    />
+                </el-form-item>
+                <el-form-item
+                    v-show="categoryKey==='DIC_TYPE'"
+                    label="字典类型:"
+                    prop="struType"
+                >
+                    <el-radio-group v-model="type.struType">
+                        <el-radio
+                            v-for="option in srtuOptions"
+                            :key="option.value"
+                            :label="option.value"
+                        >{{ option.label }}
+                        </el-radio>
+                    </el-radio-group>
+                </el-form-item>
+                <el-form-item
+                    v-show="categoryKey==='FILE_TYPE'"
+                    label="体系审查:"
+                    prop="authorityObject.shenCha"
+                >
+                    <el-radio-group
+                        v-if="!readonly"
+                        v-model="type.authorityObject.shenCha"
+                    >
+                        <el-radio label="需要">需要</el-radio>
+                        <el-radio label="不需要">不需要</el-radio>
+                    </el-radio-group>
+                    <span v-else>{{ type.authorityObject.shenCha }}</span>
+                </el-form-item>
+                <el-form-item v-show="categoryKey==='FILE_TYPE'">
+                    <span>需要进行体系文件审查的文件类型请选择“需要”,子节点有需要进行文件审查的话,父节点也需要选择“需要”</span>
+                </el-form-item>
+                <el-form-item
+                    v-show="categoryKey==='FILE_TYPE'"
+                    label="审核审批走向:"
+                    prop="authorityObject.shenHeZouXiang"
+                >
+                    <el-radio-group
+                        v-if="!readonly"
+                        v-model="type.authorityObject.shenHeZouXiang"
+                    >
+                        <el-radio label="shspgz">审核、审批、盖章</el-radio>
+                        <el-radio label="jspgz">仅审批、盖章</el-radio>
+                        <el-radio label="jspbgz">仅审批、不盖章</el-radio>
+                    </el-radio-group>
+                    <span v-else>{{ zouXiang[type.authorityObject.shenHeZouXiang] }}</span>
+                </el-form-item>
 
-
-
-      <el-form-item v-show="categoryKey==='DIC_TYPE'" label="分类类型:" prop="struType">
-        <el-radio-group v-model="type.struType">
-          <el-radio
-            v-for="option in srtuOptions"
-            :key="option.value"
-            :label="option.value"
-          >{{ option.label }}
-          </el-radio>
-        </el-radio-group>
-      </el-form-item>
-    </el-form>
-    <div slot="footer" class="el-dialog--center">
-      <ibps-toolbar
-        :actions="toolbars"
-        @action-event="handleActionEvent"
-      />
+                <el-form-item v-show="categoryKey==='FLOW_TYPE'" label="分类类型:" prop="authorityObject.fenLei">
+                    <el-radio-group v-model="type.authorityObject.fenLei" :disabled="readonly">
+                        <el-radio label="通用">通用</el-radio>
+                        <el-radio label="体系分类">体系分类</el-radio>
+                        <el-radio label="模板分类">模板分类</el-radio>
+                    </el-radio-group>
+                </el-form-item>
+            </el-form>
+        </ibps-container>
     </div>
-  </el-dialog>
-  <!--默认形式-->
-  <div v-else class="main-container">
-    <ibps-container type="full" class="page">
-      <template slot="header">
-        <el-button type="primary" :disabled="readonly" icon="ibps-icon-save" @click="handleSave()">保存</el-button>
-      </template>
-      <el-form ref="typeForm" :model="type" :rules="rules" :label-width="formLabelWidth">
-        <el-form-item label="分类:">
-          <span>{{ isPrivateLocal ? '私有分类' : '普通分类' }}</span>
-        </el-form-item>
-        <el-form-item v-show="!formId" label="父节点名称:">
-          <span>{{ parentData.name }}</span>
-        </el-form-item>
-        <el-form-item label="分类名称:" prop="name">
-          <el-input v-if="!readonly" v-model="type.name" v-pinyin="{vm:type,key:'typeKey'}" />
-          <span v-else>{{ type.name }}</span>
-        </el-form-item>
-        <el-form-item label="分类Key:" prop="typeKey">
-          <el-input v-if="!readonly" v-model="type.typeKey" :disabled="$utils.isNotEmpty(formId)" />
-          <span v-else>{{ type.typeKey }}</span>
-        </el-form-item>
-        <el-form-item v-show="categoryKey==='DIC_TYPE'" label="字典类型:" prop="struType">
-          <el-radio-group v-model="type.struType">
-            <el-radio
-              v-for="option in srtuOptions"
-              :key="option.value"
-              :label="option.value"
-            >{{ option.label }}
-            </el-radio>
-          </el-radio-group>
-        </el-form-item>
-      </el-form>
-    </ibps-container>
-  </div>
 </template>
 <script>
 import { save, get } from '@/api/platform/cat/type'
 import ActionUtils from '@/utils/action'
 import { srtuOptions } from './constants'
 import { validateKey } from '@/utils/validate'
+import curdPost from '@/business/platform/form/utils/custom/joinCURD.js'
+
 export default {
-  props: {
-    className: String,
-    id: {
-      type: String
-    },
-    parentData: Object, // 父类数据
-    categoryKey: String, // 分类标识key
-    isPrivate: Boolean, // 是否是私有的
-    data: Array,
-    visible: {
-      type: Boolean,
-      default: false
-    },
-    title: {
-      type: String
-    },
-    readonly: {
-      type: Boolean,
-      default: false
-    },
-    displayType: {
-      type: String,
-      default: 'dialog'
-    },
-    randomNum: [String, Number] // 时间戳,用于保证点击请求数据
-  },
-  data() {
-    return {
-      formName: 'typeForm',
-      formLabelWidth: '120px',
-      dialogVisible: false,
-      dialogLoading: false,
-      isPrivateLocal: false,
-      topKey:'',
+    props: {
+        className: String,
+        id: {
+            type: String
+        },
+        parentData: Object, // 父类数据
+        categoryKey: String, // 分类标识key
+        isPrivate: Boolean, // 是否是私有的
+        data: Array,
 
-      srtuOptions: srtuOptions,
-      defaultForm: {},
-      type: {
-        struType: '1',
-        name: '',
-        typeKey: '',
-        ownerId: '0'
-      },
-      rules: {
-        name: [{ required: true, message: this.$t('validate.required') }],
-        typeKey: [{ required: true, validator: validateKey }]
-      },
-      toolbars: [
-        { key: 'save', hidden: () => { return this.readonly } },
-        { key: 'cancel' }
-      ]
-    }
-  },
-  computed: {
-    formId() {
-      return this.id
-    },
-    random() {
-      return this.randomNum
-    }
-  },
-  watch: {
-    random() {
-      if (this.displayType !== 'dialog') {
-        this.getFormData()
-        if (!this.id) this.type = JSON.parse(JSON.stringify(this.defaultForm))
-      }
-    },
-    visible: {
-      handler: function(val, oldVal) {
-        this.dialogVisible = this.visible
-        this.isPrivateLocal = this.isPrivate
-      },
-      immediate: true
-   },
-    /* formId() {
-       if (this.displayType !== 'dialog') {
-         this.getFormData()
-         if (!this.id) this.type = JSON.parse(JSON.stringify(this.defaultForm))
-       }
-    }, */
-    isPrivate: {
-      handler: function(val, oldVal) {
-        this.isPrivateLocal = this.isPrivate
-      },
-      immediate: true
-    }
-  },
-  created() {
-    this.topKey = ''
-    this.defaultForm = JSON.parse(JSON.stringify(this.type))
-  },
-  methods: {
-    handleActionEvent({ key }) {
-      switch (key) {
-        case 'save':
-          this.handleSave()
-          break
-        case 'cancel':
-          this.closeDialog()
-          break
-        default:
-          break
-      }
+        visible: {
+            type: Boolean,
+            default: false
+        },
+        title: {
+            type: String
+        },
+        readonly: {
+            type: Boolean,
+            default: false
+        },
+        displayType: {
+            type: String,
+            default: 'dialog'
+        },
+        randomNum: [String, Number] // 时间戳,用于保证点击请求数据
     },
-    closeDialog() {
-      this.$emit('close', false)
-    },
-    // 保存数据
-    handleSave() {
-      this.$refs[this.formName].validate(valid => {
-        if (valid) {
-          this.saveData()
-        } else {
-          ActionUtils.saveErrorMessage()
+    data () {
+        return {
+
+            rules: {
+                name: [{ required: true, message: this.$t('validate.required') }],
+                typeKey: [{ required: true, validator: validateKey }]
+            },
+            formName: 'typeForm',
+            formLabelWidth: '120px',
+            dialogVisible: false,
+            dialogLoading: false,
+            isPrivateLocal: false,
+            topKey: '',
+            srtuOptions: srtuOptions,
+            defaultForm: {},
+            type: {
+                struType: '1',
+                name: '',
+                typeKey: '',
+                ownerId: '0',
+                authorityObject: {
+                    chaYue: '',
+                    buMen: '',
+                    shenCha: '',
+                    shenHeZouXiang: '',
+                    fenLei: '通用'
+                }
+            },
+            toolbars: [
+                { key: 'save', hidden: () => { return this.readonly } },
+                { key: 'cancel' }
+            ],
+            cascaderOptions: [],
+            cascaderProps: {
+                multiple: true,
+                children: 'children', // 匹配响应数据中的children
+                label: 'NAME_', // 匹配响应数据中的name
+                value: 'ID_'
+            },
+            zouXiang: { shspgz: '审核、审批、盖章', jspgz: '仅审批、盖章', jspbgz: '仅审批、不盖章' }
         }
-      })
     },
-    // 提交保存数据
-    saveData() {
-      if (this.$utils.isEmpty(this.formId)) {
-        if (this.parentData.depth === 0 || this.parentData.depth === '0') {
-          this.type.path = this.parentData.id + '.'
-          this.isRoot = true
-        } else {
-          this.type.path = this.parentData.path
+    computed: {
+        formId () {
+            return this.id
+        },
+        random () {
+            return this.randomNum
         }
-        this.type.parentId = this.parentData.id
-        this.type.categoryKey = this.categoryKey
-        this.type.isPrivate = this.isPrivate
-
-        if (this.$utils.isEmpty(this.type.id) && (this.type.isPrivate === true || this.type.isPrivate === 'true')) {
-          this.type.ownerId = this.$store.getters.userId
-        }
-        if (!this.displayType === 'DIC_TYPE') {
-          this.type.struType = this.parentData.struType || '0'
+    },
+    watch: {
+        categoryKey: {
+            handler (val) {
+                if (val === 'FILE_TYPE') {
+                    this.rules.authorityObject = {
+                        chaYue: [{ required: true, message: this.$t('validate.required') }],
+                        shenCha: [{ required: true, message: this.$t('validate.required') }],
+                        shenHeZouXiang: [{ required: true, message: this.$t('validate.required') }]
+                    }
+                } else {
+                    delete this.rules.authorityObject
+                }
+            },
+            immediate: true
+        },
+        random () {
+            if (this.displayType !== 'dialog') {
+                this.getFormData()
+                if (!this.id) this.type = JSON.parse(JSON.stringify(this.defaultForm))
+            }
+        },
+        visible: {
+            handler: function (val, oldVal) {
+                this.dialogVisible = this.visible
+                this.isPrivateLocal = this.isPrivate
+                if (this.categoryKey === 'FILE_TYPE' && this.parentData.authorityName !== undefined) {
+                    this.type.authorityObject = JSON.parse(this.parentData.authorityName)
+                    console.log(this.type.authorityObject, 'aaaaaaaa')
+                }
+            },
+            immediate: true
+        },
+        parentData: {
+            handler: function (val, oldVal) {
+                if (this.categoryKey === 'FILE_TYPE' && (this.$route.name !== 'nbwj' || this.$route.name !== 'wjkzgl-ywyxjlsc') && val.authorityName !== undefined) {
+                    this.getRadioOptions()
+                    this.type.authorityObject = JSON.parse(val.authorityName)
+                }
+            },
+            immediate: true
+        },
+        // formId () {
+        //     if (this.displayType !== 'dialog') {
+        //         this.getFormData()
+        //         if (!this.id) this.type = JSON.parse(JSON.stringify(this.defaultForm))
+        //     }
+        // },
+        isPrivate: {
+            handler: function (val, oldVal) {
+                this.isPrivateLocal = this.isPrivate
+            },
+            immediate: true
         }
-      }
-      save(JSON.stringify(this.type)).then(response => {
-        if (this.displayType === 'dialog') {
-          ActionUtils.saveSuccessMessage(response.message, (rtn) => {
+    },
+    created () {
+        this.topKey = ''
+        this.defaultForm = JSON.parse(JSON.stringify(this.type))
+    },
+    methods: {
+        handleActionEvent ({ key }) {
+            switch (key) {
+                case 'save':
+                    this.handleSave()
+                    break
+                case 'cancel':
+                    this.closeDialog()
+                    break
+                default:
+                    break
+            }
+        },
+        closeDialog () {
+            this.$emit('close', false)
+        },
+        // 保存数据
+        handleSave () {
+            if (this.categoryKey === 'FILE_TYPE') {
+                const { chaYue, buMen } = this.type.authorityObject
+                if (chaYue === '部门查阅' && this.$utils.isEmpty(buMen)) {
+                    this.rules.authorityObject.buMen = [{ required: true, message: '部门选择不得为空!' }]
+                } else {
+                    this.rules.authorityObject.buMen = [{ required: false }]
+                }
+            }
+            this.$refs[this.formName].validate(valid => {
+                if (valid) {
+                    this.saveData()
+                } else {
+                    ActionUtils.saveErrorMessage()
+                }
+            })
+        },
+        // 提交保存数据
+        saveData () {
+            if (this.$utils.isEmpty(this.formId)) {
+                if (this.parentData.depth === 0 || this.parentData.depth === '0') {
+                    this.type.path = this.parentData.id + '.'
+                    this.isRoot = true
+                } else {
+                    this.type.path = this.parentData.path
+                }
+                this.type.parentId = this.parentData.id
+                this.type.categoryKey = this.categoryKey
+                this.type.isPrivate = this.isPrivate
+                if (this.$utils.isEmpty(this.type.id) && (this.type.isPrivate === true || this.type.isPrivate === 'true')) {
+                    this.type.ownerId = this.$store.getters.userId
+                }
+                if (!this.displayType === 'DIC_TYPE') {
+                    this.type.struType = this.parentData.struType || '0'
+                }
+            }
+            save(JSON.stringify(this.type)).then(response => {
+                if (this.displayType === 'dialog') {
+                    ActionUtils.saveSuccessMessage(response.message, (rtn) => {
+                        if (this.$utils.isEmpty(this.formId)) {
+                            this.$refs[this.formName].resetFields()
+                        }
+                        if (rtn) {
+                            this.closeDialog()
+                        }
+                        this.$emit('callback', true)
+                    })
+                } else {
+                    ActionUtils.removeSuccessMessage('保存成功')
+                    if (this.$utils.isEmpty(this.formId)) {
+                        this.$refs[this.formName].resetFields()
+                    }
+                    this.$emit('callback', true)
+                }
+            }).catch((err) => {
+                console.error(err)
+            })
+        },
+        /**
+         * 表单验证
+         */
+        formValidate () {
+            if (this.readonly) return
+            this.$nextTick(() => {
+                this.$refs[this.formName].validate(() => { })
+            })
+        },
+        /**
+         * 获取表单数据
+         */
+        getFormData () {
             if (this.$utils.isEmpty(this.formId)) {
-              this.$refs[this.formName].resetFields()
+                // 重置表单
+                this.type = JSON.parse(JSON.stringify(this.defaultForm))
+                this.formValidate()
+                return
             }
-            if (rtn) {
-              this.closeDialog()
+            get({ typeId: this.formId }).then(response => {
+                this.$refs[this.formName].clearValidate()
+                this.type = response.data
+                console.log('bbb')
+
+                this.type.authorityObject = response.data.authorityObject ? JSON.parse(response.data.authorityObject) : { chaYue: '', buMen: '', shenCha: '', shenHeZouXiang: '', fenLei: '通用' }
+
+                this.isPrivateLocal = !((this.$utils.isEmpty(this.type.ownerId) || this.type.ownerId === '0'))
+            }).catch(() => { })
+        },
+        getRadioOptions () {
+            this.type.authorityObject.buMen = ''
+            const sql = `select * FROM  ibps_party_entity WHERE party_type_='position' )`
+            curdPost('sql', sql).then(res => {
+                const datas = res.variables.data
+                const treeDatas = this.buildTree(datas, 'ID_', 'PARENT_ID_')
+                const tree = []
+                for (const i in treeDatas) {
+                    tree.push(treeDatas[i])
+                }
+                this.cascaderOptions = tree
+            })
+        },
+        radioChangeHandle (h) {
+            if (h === '部门查阅') {
+                this.type.authorityObject.buMen = JSON.parse(this.parentData.authorityName).buMen
+                if (this.cascaderOptions.length === 0) {
+                    this.getRadioOptions()
+                }
+            } else {
+                this.type.authorityObject.buMen = ''
+            }
+        },
+        // 数据扁平化处理
+        buildTree (array, id, parent_id) {
+            // 创建临时对象
+            const temp = {}
+            // 创建需要返回的树形对象
+            const tree = {}
+            // 先遍历数组,将数组的每一项添加到temp对象中
+            for (const i in array) {
+                temp[array[i][id]] = array[i]
             }
-            this.$emit('callback', true)
-          })
-        } else {
-          ActionUtils.removeSuccessMessage('保存成功')
-          if (this.$utils.isEmpty(this.formId)) {
-            this.$refs[this.formName].resetFields()
-          }
-          this.$emit('callback', true)
+            // 遍历temp对象,将当前子节点与父节点建立连接
+            for (const i in temp) {
+                // 判断是否是根节点下的项
+                if (temp[i][parent_id] !== '0') {
+                    if (!temp[temp[i][parent_id]].children) {
+                        // eslint-disable-next-line no-array-constructor
+                        temp[temp[i][parent_id]].children = new Array()
+                    }
+                    temp[temp[i][parent_id]].children.push(temp[i])
+                } else {
+                    tree[temp[i][id]] = temp[i]
+                }
+            }
+            return tree
         }
-      }).catch((err) => {
-        console.error(err)
-      })
-    },
-    /**
-     * 表单验证
-     */
-    formValidate() {
-      if (this.readonly) return
-      this.$nextTick(() => {
-        this.$refs[this.formName].validate(() => {})
-      })
-    },
-    /**
-     * 获取表单数据
-     */
-    getFormData() {
-      if (this.$utils.isEmpty(this.formId)) {
-        // 重置表单
-        this.type = JSON.parse(JSON.stringify(this.defaultForm))
-        this.formValidate()
-        return
-      }
-      get({
-        typeId: this.formId
-      }).then(response => {
-        this.$refs[this.formName].clearValidate()
-        this.type = response.data
-        this.isPrivateLocal = !((this.$utils.isEmpty(this.type.ownerId) || this.type.ownerId === '0'))
-      }).catch(() => { })
     }
-  }
 }
 </script>
+<style lang="scss">
+.el-cascader {
+    width: 100%;
+}
+.gy-cascader {
+    max-width: 500px;
+    overflow-x: auto;
+    &::-webkit-scrollbar-track-piece {
+        background-color: #f8f8f800;
+    }
+    &::-webkit-scrollbar {
+        transition: all 2s;
+        height: 6px;
+    }
+    &::-webkit-scrollbar-thumb {
+        background-color: #ebeaef;
+        border-radius: 10px;
+    }
+    &::-webkit-scrollbar-thumb:hover {
+        background-color: #bbb;
+    }
+    &::-webkit-scrollbar-track {
+        background: #ffffff;
+        border-radius: 10px;
+    }
+    &::-webkit-scrollbar-corner {
+        background-color: rgba(255, 255, 255, 0);
+    }
+}
+</style>
+

+ 15 - 0
src/views/platform/cat/type/fileType.vue

@@ -0,0 +1,15 @@
+<template>
+    <manage category-key="FILE_TYPE" />
+</template>
+<script>
+import Manage from './manage'
+export default {
+    components: {
+        Manage
+    },
+    data () {
+        return {
+        }
+    }
+}
+</script>

+ 175 - 175
src/views/platform/cat/type/import-xml.vue

@@ -1,51 +1,51 @@
 <template>
-  <el-dialog
-    :title="title"
-    :visible.sync="dialogVisible"
-    :close-on-click-modal="false"
-    :close-on-press-escape="false"
-    append-to-body
-    class="dialog type-import-dialog"
-    @close="closeDialog"
-  >
-    <el-form
-      ref="importForm"
-      v-loading="dialogLoading"
-      :element-loading-text="$t('common.loading')"
-      :label-width="formLabelWidth"
-      class="import-form"
-      @submit.native.prevent
+    <el-dialog
+        :title="title"
+        :visible.sync="dialogVisible"
+        :close-on-click-modal="false"
+        :close-on-press-escape="false"
+        append-to-body
+        class="dialog type-import-dialog"
+        @close="closeDialog"
     >
-      <el-form-item label="选择文件:">
-        <el-upload
-          ref="uploader"
-          :before-upload="beforeUpload"
-          :on-success="handleSuccess"
-          :on-error="handleError"
-          :on-change="handleChange"
-          :file-list="fileList"
-          :auto-upload="false"
-          name="file"
-          action="https://www.bpmhome.cn/post"
-          accept=".xml"
+        <el-form
+            ref="importForm"
+            v-loading="dialogLoading"
+            :element-loading-text="$t('common.loading')"
+            :label-width="formLabelWidth"
+            class="import-form"
+            @submit.native.prevent
         >
-          <el-button slot="trigger" size="small" type="primary" icon="el-icon-upload">选择文件</el-button>
-          <div slot="tip" class="el-upload__tip">请导入xml文件!</div>
-        </el-upload>
-      </el-form-item>
+            <el-form-item label="选择文件:">
+                <el-upload
+                    ref="uploader"
+                    :before-upload="beforeUpload"
+                    :on-success="handleSuccess"
+                    :on-error="handleError"
+                    :on-change="handleChange"
+                    :file-list="fileList"
+                    :auto-upload="false"
+                    name="file"
+                    action="https://www.bpmhome.cn/post"
+                    accept=".xml"
+                >
+                    <el-button slot="trigger" size="small" type="primary" icon="el-icon-upload">选择文件</el-button>
+                    <div slot="tip" class="el-upload__tip">请导入xml文件!</div>
+                </el-upload>
+            </el-form-item>
 
-      <el-form-item>
-        <el-input v-model="formId" :name="'typeId'" type="hidden" />
-      </el-form-item>
+            <el-form-item>
+                <el-input v-model="formId" :name="'typeId'" type="hidden" />
+            </el-form-item>
 
-    </el-form>
-    <div slot="footer" class="el-dialog--center">
-      <ibps-toolbar
-        :actions="toolbars"
-        @action-event="handleActionEvent"
-      />
-    </div>
-  </el-dialog>
+        </el-form>
+        <div slot="footer" class="el-dialog--center">
+            <ibps-toolbar
+                :actions="toolbars"
+                @action-event="handleActionEvent"
+            />
+        </div>
+    </el-dialog>
 </template>
 
 <script>
@@ -53,151 +53,151 @@ import { importXml } from '@/api/platform/cat/type'
 import ActionUtils from '@/utils/action'
 
 export default {
-  props: {
-    visible: {
-      type: Boolean,
-      default: false
+    props: {
+        visible: {
+            type: Boolean,
+            default: false
+        },
+        id: String
     },
-    id: String
-  },
-  data() {
-    return {
-      title: '分类导入',
-      formName: 'importForm',
-      formLabelWidth: '120px',
-      dialogVisible: this.visible,
-      dialogLoading: false,
-      fileList: [],
-      file: {},
-      toolbars: [
-        { key: 'save' },
-        { key: 'cancel' }
-      ]
-    }
-  },
-  computed: {
-    formId() {
-      return this.id
-    }
-  },
-  watch: {
-    visible: {
-      handler: function(val, oldVal) {
-        this.dialogVisible = this.visible
-        this.fileList = []
-        this.file = {}
-      },
-      immediate: true
-    },
-    fileList: {
-      handler: function(val, oldVal) {
-        // console.log(val)
-      },
-      deep: true
-    }
-  },
-  methods: {
-    handleActionEvent({ key }) {
-      switch (key) {
-        case 'save':
-          this.handleSave()
-          break
-        case 'cancel':
-          this.closeDialog()
-          break
-        default:
-          break
-      }
-    },
-    /**
-     * 文件上传
-     */
-    httpRequest(options) {
-      return importXml(options.file, this.id)
+    data () {
+        return {
+            title: '分类导入',
+            formName: 'importForm',
+            formLabelWidth: '120px',
+            dialogVisible: this.visible,
+            dialogLoading: false,
+            fileList: [],
+            file: {},
+            toolbars: [
+                { key: 'save' },
+                { key: 'cancel' }
+            ]
+        }
     },
-    // 保存数据
-    handleSave(options) {
-      const file = this.$refs.uploader.uploadFiles[0].raw
-      if (this.$utils.isEmpty(file) || file.type !== 'text/xml') {
-        ActionUtils.saveErrorMessage('请导入xml件!')
-        return
-      }
-      importXml(file, this.id).then(response => {
-        this.$emit('callback', this)
-        this.closeDialog()
-      }).catch((err) => {
-        console.error(err)
-      })
+    computed: {
+        formId () {
+            return this.id
+        }
     },
-    // 关闭当前窗口
-    closeDialog() {
-      this.$emit('close', false)
-      this.$refs[this.formName].resetFields()
+    watch: {
+        visible: {
+            handler: function (val, oldVal) {
+                this.dialogVisible = this.visible
+                this.fileList = []
+                this.file = {}
+            },
+            immediate: true
+        },
+        fileList: {
+            handler: function (val, oldVal) {
+                console.log(val)
+            },
+            deep: true
+        }
     },
-    handleSuccess(res, file) {
-      console.log('handleSuccess')
-    },
-    handleError(err, file, fileList) {
-      if (!(err instanceof Error)) {
-        const data = this.$utils.parseJSON(err.message)
-        ActionUtils.success(this.$utils.isNotEmpty(data.message) ? data.message : data.cause)
-      }
-    },
-    handleChange(file, fileList) {
-      if (fileList.length > 1) {
-        this.file = file
-        fileList.splice(0, 1)
-      }
-    },
-    beforeUpload(file) {
-      return true
+    methods: {
+        handleActionEvent ({ key }) {
+            switch (key) {
+                case 'save':
+                    this.handleSave()
+                    break
+                case 'cancel':
+                    this.closeDialog()
+                    break
+                default:
+                    break
+            }
+        },
+        /**
+   * 文件上传
+   */
+        httpRequest (options) {
+            return importXml(options.file, this.id)
+        },
+        // 保存数据
+        handleSave (options) {
+            const file = this.$refs.uploader.uploadFiles[0].raw
+            if (this.$utils.isEmpty(file) || file.type !== 'text/xml') {
+                ActionUtils.saveErrorMessage('请导入xml件!')
+                return
+            }
+            importXml(file, this.id).then(response => {
+                this.$emit('callback', this)
+                this.closeDialog()
+            }).catch((err) => {
+                console.error(err)
+            })
+        },
+        // 关闭当前窗口
+        closeDialog () {
+            this.$emit('close', false)
+            this.$refs[this.formName].resetFields()
+        },
+        handleSuccess (res, file) {
+            console.log('handleSuccess')
+        },
+        handleError (err, file, fileList) {
+            if (!(err instanceof Error)) {
+                const data = this.$utils.parseJSON(err.message)
+                ActionUtils.success(this.$utils.isNotEmpty(data.message) ? data.message : data.cause)
+            }
+        },
+        handleChange (file, fileList) {
+            if (fileList.length > 1) {
+                this.file = file
+                fileList.splice(0, 1)
+            }
+        },
+        beforeUpload (file) {
+            return true
+        }
     }
-  }
 
 }
 </script>
 
 <style lang="scss" >
 .type-import-dialog{
-  .el-dialog__body{
-    height:  calc(27vh - 80px) !important;
-  }
+.el-dialog__body{
+  height:  calc(27vh - 80px) !important;
+}
+}
+.avatar-uploader .el-upload {
+    /* margin-top: 5px; */
+    border: 1px dashed #d9d9d9;
+    border-radius: 6px;
+    cursor: pointer;
+    position: relative;
+    overflow: hidden;
+}
+.avatar-uploader .el-upload:hover {
+  border-color: #409EFF;
+}
+.avatar-uploader-icon {
+  font-size: 28px;
+  color: #8c939d;
+  width: 178px;
+  height: 178px;
+  line-height: 178px;
+  text-align: center;
+}
+.avatar {
+  width: 178px;
+  height: 178px;
+  display: block;
 }
-  .avatar-uploader .el-upload {
-      /* margin-top: 5px; */
-      border: 1px dashed #d9d9d9;
-      border-radius: 6px;
-      cursor: pointer;
-      position: relative;
-      overflow: hidden;
-  }
-  .avatar-uploader .el-upload:hover {
-    border-color: #409EFF;
-  }
-  .avatar-uploader-icon {
-    font-size: 28px;
-    color: #8c939d;
-    width: 178px;
-    height: 178px;
-    line-height: 178px;
-    text-align: center;
-  }
-  .avatar {
-    width: 178px;
-    height: 178px;
-    display: block;
-  }
 
-  .import-form{
-    .el-upload-list{
-      position: relative;
-      height: 40px;
-      overflow: hidden;
-      .el-upload-list__item{
-        margin:0;
-        position: absolute;
-        top:0;
-      }
+.import-form{
+  .el-upload-list{
+    position: relative;
+    height: 40px;
+    overflow: hidden;
+    .el-upload-list__item{
+      margin:0;
+      position: absolute;
+      top:0;
     }
   }
+}
 </style>

+ 338 - 235
src/views/platform/cat/type/manage.vue

@@ -1,58 +1,77 @@
 <template>
-  <ibps-layout ref="layout">
-    <!--  -->
-    <div slot="west">
-      <ibps-tree :width="width"
-                 :height="height"
-                 :data="treeData"
-                 :options="treeOptions"
-                 :contextmenus="treeContextmenus"
-                 title="分类管理"
-                 @action-event="handleTreeAction"
-                 @node-click="handleNodeClick"
-                 @expand-collapse="handleExpandCollapse">
-        <el-select slot="searchForm"
-                   v-model="categoryKey"
-                   @change="loadTreeData(false)">
-          <el-option v-for="item in categoryOptions"
-                     :key="item.id"
-                     :label="item.name"
-                     :value="item.categoryKey" />
-        </el-select>
-      </ibps-tree>
-    </div>
+    <ibps-layout ref="layout">
+        <!--  -->
+        <div slot="west">
+            <ibps-tree
+                :width="width"
+                :height="height"
+                :data="treeData"
+                :options="treeOptions"
+                :contextmenus="treeContextmenus"
+                title="分类管理"
+                :category-key="categoryKey"
+                @action-event="handleTreeAction"
+                @node-click="handleNodeClick"
+                @expand-collapse="handleExpandCollapse"
+            >
 
-    <ibps-container :margin-left="width+'px'"
-                    class="page">
-      <edit v-show="show"
-            :id="editId"
-            ref="editForm"
-            :readonly="readonly"
-            :category-key="categoryKey"
-            :parent-data="nodeData"
-            :is-private="isPrivate"
-            :random-num="randomNum"
-            display-type="edit"
-            @callback="loadTreeData" />
-      <el-alert v-show="!show"
+                <el-select
+                    slot="searchForm"
+                    v-model="categoryKey"
+                    @change="loadTreeData(false)"
+                >
+                    <el-option
+                        v-for="item in categoryOptions"
+                        :key="item.id"
+                        :label="item.name"
+                        :value="item.categoryKey"
+                    />
+                </el-select>
+            </ibps-tree>
+        </div>
+
+        <ibps-container
+            :margin-left="width+'px'"
+            class="page"
+        >
+            <edit
+                v-show="show"
+                :id="editId"
+                ref="editForm"
+                :readonly="readonly"
+                :category-key="categoryKey"
+                :parent-data="nodeData"
+                :is-private="isPrivate"
+                :random-num="randomNum"
+                display-type="edit"
+                @callback="loadTreeData"
+            />
+            <el-alert
+                v-show="!show"
                 :closable="false"
                 title="请选择左边菜单右键进行操作!"
                 type="warning"
                 show-icon
-                style="height:50px;" />
-    </ibps-container>
+                style="height:50px;"
+            />
+        </ibps-container>
 
-    <!-- 数据字典 -->
-    <import-xml :id="editId"
-                :visible="importFormVisible"
-                @callback="callback"
-                @close="visible => importFormVisible = visible" />
-    <sort :id="editId"
-          :visible="sortFormVisible"
-          title="分类排序"
-          @callback="callback"
-          @close="visible => sortFormVisible = visible" />
-  </ibps-layout>
+        <!-- 数据字典 -->
+        <import-xml
+            :id="editId"
+            :visible="importFormVisible"
+            @callback="callback"
+            @close="visible => importFormVisible = visible"
+        />
+        <sort
+            :id="editId"
+            :visible="sortFormVisible"
+            title="分类排序"
+            :category-key="categoryKey"
+            @callback="callback"
+            @close="visible => sortFormVisible = visible"
+        />
+    </ibps-layout>
 </template>
 <script>
 import { queryPageList } from '@/api/platform/cat/category'
@@ -64,201 +83,285 @@ import Sort from './sort'
 import Edit from './edit'
 
 export default {
-  components: {
-    ImportXml,
-    Sort,
-    Edit
-  },
-  mixins: [FixHeight],
-  props: {
-    categoryKey: {
-      type: String,
-      default: 'FLOW_TYPE'
+    components: {
+        ImportXml,
+        Sort,
+        Edit
     },
-  },
-  data() {
-    return {
-      width: 200,
-      height: document.clientHeight,
-      importFormVisible: false,
-      sortFormVisible: false,
-      editId: '0', // 编辑dialog需要使用
-      readonly: false, // 是否只读
-      randomNum: '',
-      loading: false,
-      // 树配置
-      treeOptions: { 'rootPId': '-1' },
-      treeContextmenus: [
-        {
-          icon: 'add',
-          label: '添加分类',
-          value: 'add',
-          rights: function (menu, data, isRoot) {
-            if (isRoot) return true
-            if (data.struType === '0') return false // 平铺结构类型不允许添加子分类
-            if (!(data.ownerId === '0' || this.$utils.isEmpty(data.ownerId))) {
-              return false
+    mixins: [FixHeight],
+    data () {
+        const { first, second } = this.$store.getters.level || {}
+        return {
+            width: 200,
+            level: second || first,
+            height: document.clientHeight,
+            importFormVisible: false,
+            sortFormVisible: false,
+            editId: '0', // 编辑dialog需要使用
+            readonly: false, // 是否只读
+            randomNum: '',
+            loading: false,
+            // 树配置
+            treeOptions: { 'rootPId': '-1' },
+            treeContextmenus: [
+                {
+                    icon: 'add',
+                    label: '添加分类',
+                    value: 'add',
+                    rights: function (menu, data, isRoot) {
+                        if (isRoot) return true
+                        if (data.struType === '0') return false // 平铺结构类型不允许添加子分类
+                        if (!(data.ownerId === '0' || this.$utils.isEmpty(data.ownerId))) {
+                            return false
+                        }
+                        return true
+                    }
+                },
+                {
+                    icon: 'add',
+                    label: '添加私有分类',
+                    value: 'addPrivate',
+                    rights: function (menu, data, isRoot) {
+                        if (data.struType === '0') return false // 平铺结构类型不允许添加子分类
+                        return true
+                    }
+                },
+                { icon: 'edit', label: '编辑分类', value: 'edit', rights: ['node'] },
+                { icon: 'delete', label: '删除分类', value: 'remove', rights: ['node'] },
+                { type: 'divided' },
+                { icon: 'export',
+                    label: '导出',
+                    value: 'export',
+                    rights: function (menu, data, isRoot) {
+                        if (!this.$store.getters.isSuper) return false
+                        return true
+                    }
+                },
+                { icon: 'import',
+                    label: '导入',
+                    value: 'import',
+                    rights: function (menu, data, isRoot) {
+                        if (!this.$store.getters.isSuper) return false
+                        return true
+                    } },
+                {
+                    type: 'divided',
+                    rights: function (menu, data, isRoot) {
+                        if (isRoot) return true
+                        if (data.isLeaf === 'Y') return false
+                        return true
+                    }
+                },
+                {
+                    icon: 'sort',
+                    label: '子节点排序',
+                    value: 'sort',
+                    rights: function (menu, data, isRoot) {
+                        if (isRoot) return true
+                        if (data.isLeaf === 'Y') return false
+                        return true
+                    }
+                }
+            ],
+            treeData: [],
+            nodeData: {},
+            isPrivate: false,
+            type: {},
+            categoryKey: '',
+            categoryOptions: [],
+            show: false
+        }
+    },
+    created () {
+        this.loadCategoryData()
+        this.loadTreeData()
+    },
+    methods: {
+        // 加载下拉框 分类标识数据
+        loadCategoryData () {
+            this.loading = true
+            let whereParams = {}
+            const allRequests = []
+            if (this.$router.currentRoute.fullPath === '/wjkzgl/wjjflsz') {
+                this.categoryKey = 'FILE_TYPE'
+                const keys = ['FILE_TYPE', 'FLOW_TYPE']
+                keys.forEach(item => {
+                    whereParams = {
+                        parameters: [
+                            {
+                                key: 'Q^category_key_^SL',
+                                value: item
+                            }
+                        ]
+                    }
+                    allRequests.push(queryPageList(whereParams))
+                })
+            } else {
+                this.categoryKey = 'FLOW_TYPE'
+                allRequests.push(queryPageList(whereParams))
             }
-            return true
-          }
+            Promise.all(allRequests).then(responses => {
+                this.categoryOptions = []
+                responses.forEach(response => {
+                    this.categoryOptions.push(...response.data.dataResult)
+                })
+                this.loading = false
+            }).catch(() => {
+                this.loading = false
+            })
         },
-        {
-          icon: 'add',
-          label: '添加私有分类',
-          value: 'addPrivate',
-          rights: function (menu, data, isRoot) {
-            if (data.struType === '0') return false // 平铺结构类型不允许添加子分类
-            return true
-          }
+        // 加载具体分类数据
+        loadTreeData (isEdit) {
+            //  文件分类获取文件类型需要根据地点进行数据过滤
+            const whereParams = {
+                'categoryKey': this.categoryKey
+            }
+            if (this.categoryKey === 'FILE_TYPE') {
+                whereParams.diDian = this.level
+            }
+            findTreeData(whereParams).then(response => {
+                const data = response.data
+                this.treeData = data
+                this.show = isEdit
+            })
         },
-        { icon: 'edit', label: '编辑分类', value: 'edit', rights: ['node'] },
-        { icon: 'delete', label: '删除分类', value: 'remove', rights: ['node'] },
-        { type: 'divided' },
-        { icon: 'export', label: '导出', value: 'export' },
-        { icon: 'import', label: '导入', value: 'import' },
-        {
-          type: 'divided',
-          rights: function (menu, data, isRoot) {
-            if (isRoot) return true
-            if (data.isLeaf === 'Y') return false
-            return true
-          }
+        handleTreeAction (command, position, selection, data) {
+            if (data?.sn === 0 && data?.name === '文件分类') {
+                const object = {
+                    diDian: this.level,
+                    buMen: '',
+                    chaYue: '公用查阅',
+                    shenCha: '不需要',
+                    shenHeZouXiang: ''
+                }
+                data.authorityName = JSON.stringify(object)
+            }
+            if (position === 'toolbar') {
+                if (command === 'refresh') {
+                    this.loadTreeData()
+                }
+            } else {
+                if (command === 'add') { // 添加
+                    if (this.isSpecial(data.name, 0)) {
+                        return
+                    }
+                    if (this.isSpecial(data.name, 3)) {
+                        return
+                    }
+                    this.editId = null
+                    this.nodeData = data
+                    this.isPrivate = false
+                    this.handTreeEdit()
+                } else if (command === 'addPrivate') {
+                    if (this.isSpecial(data.name, 0)) {
+                        return
+                    }
+                    if (this.isSpecial(data.name, 3)) {
+                        return
+                    }
+
+                    this.editId = null
+                    this.isPrivate = true
+                    this.nodeData = data
+                    this.handTreeEdit()
+                } else if (command === 'edit') {
+                    if (this.isSpecial(data.name, 1)) {
+                        return
+                    }
+                    this.handleNodeClick(data, false)
+                } else if (command === 'remove') {
+                    if (this.isSpecial(data.name, 1)) {
+                        return
+                    }
+                    this.handleTreeRemove(data.id)
+                } else if (command === 'export') {
+                    this.handTreeExport(data.id, data.name)
+                } else if (command === 'import') {
+                    this.handTreeImport(data.id)
+                } else if (command === 'sort') {
+                    this.handTreeSort(data)
+                }
+            }
         },
-        {
-          icon: 'sort',
-          label: '子节点排序',
-          value: 'sort',
-          rights: function (menu, data, isRoot) {
-            if (isRoot) return true
-            if (data.isLeaf === 'Y') return false
-            return true
-          }
-        }
-      ],
-      treeData: [],
-      nodeData: {},
-      isPrivate: false,
-      type: {},
-      categoryOptions: [],
-      show: false
-    }
-  },
-  created() {
-    this.loadCategoryData()
-    this.loadTreeData()
-  },
-  methods: {
-    // 加载下拉框 分类标识数据
-    loadCategoryData() {
-      this.loading = true
-      queryPageList({}).then(response => {
-        this.categoryOptions = response.data.dataResult
-        this.loading = false
-      }).catch(() => {
-        this.loading = false
-      })
-    },
-    // 加载具体分类数据
-    loadTreeData(isEdit) {
-      findTreeData({ 'categoryKey': this.categoryKey }).then(response => {
-        const data = response.data
-        this.treeData = data
-        this.show = isEdit
-      })
-    },
-    handleTreeAction(command, position, selection, data) {
-      if (position === 'toolbar') {
-        if (command === 'refresh') {
-          this.loadTreeData()
-        }
-      } else {
-        if (command === 'add') { // 添加
-          this.editId = null
-          this.nodeData = data
-          this.isPrivate = false
-          this.handTreeEdit()
-        } else if (command === 'addPrivate') {
-          this.editId = null
-          this.isPrivate = true
-          this.nodeData = data
-          this.handTreeEdit()
-        } else if (command === 'edit') {
-          this.handleNodeClick(data, false)
-        } else if (command === 'remove') {
-          this.handleTreeRemove(data.id)
-        } else if (command === 'export') {
-          this.handTreeExport(data.id, data.name)
-        } else if (command === 'import') {
-          this.handTreeImport(data.id)
-        } else if (command === 'sort') {
-          this.handTreeSort(data)
-        }
-      }
-    },
-    handleNodeClick(data, readonly = true) {
-      if (data.depth === 0 || data.parentId === '-1') {
-        return
-      }
-      this.readonly = readonly
-      this.nodeData = data
-      this.editId = data.id
-      this.show = true
-      this.randomNum = (new Date()).getTime()
-    },
-    handleExpandCollapse(isExpand, readonly = false) {
-      this.width = isExpand ? 200 : 50
-    },
-    handTreeEdit(editId, readonly = false) {
-      this.editId = editId || ''
-      this.readonly = readonly
-      this.show = true
-      this.randomNum = (new Date()).getTime()
-    },
-    handTreeImport(editId) {
-      this.editId = editId || ''
-      this.importFormVisible = 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('无子节点排序')
-      }
-    },
-    handTreeExport(editId, name) {
-      // 获取数据
-      exportXml({ typeId: editId }).then(response => {
-        ActionUtils.exportFile(response.data, name + '.xml')
-      }).catch(() => {
+        handleNodeClick (data, readonly = true) {
+            if (data.depth === 0 || data.parentId === '-1') {
+                return
+            }
+            this.readonly = readonly
+            this.nodeData = data
+            this.editId = data.id
+            this.show = true
+            this.randomNum = (new Date()).getTime()
+        },
+        handleExpandCollapse (isExpand, readonly = false) {
+            this.width = isExpand ? 200 : 50
+        },
+        handTreeEdit (editId, readonly = false) {
+            this.editId = editId || ''
+            this.readonly = readonly
+            this.show = true
+            this.randomNum = (new Date()).getTime()
+        },
+        handTreeImport (editId) {
+            this.editId = editId || ''
+            this.importFormVisible = 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('无子节点排序')
+            }
+        },
+        handTreeExport (editId, name) {
+            // 获取数据
+            exportXml({ typeId: editId }).then(response => {
+                ActionUtils.exportFile(response.data, name + '.xml')
+            }).catch(() => {
 
-      })
-    },
-    handleTreeRemove(ids) {
-      // 获取数据
-      remove({ typeId: ids }).then(response => {
-        ActionUtils.removeSuccessMessage()
-        this.loadTreeData()
-      }).catch(() => {
+            })
+        },
+        handleTreeRemove (ids) {
+            // 获取数据
+            remove({ typeId: ids }).then(response => {
+                ActionUtils.removeSuccessMessage()
+                this.loadTreeData()
+            }).catch(() => {
 
-      })
-    },
-    getSelectedData(id, list) {
-      for (let index = 0; index < list.length; index++) {
-        if (list[index].id === id) {
-          return list[index]
+            })
+        },
+        getSelectedData (id, list) {
+            for (let index = 0; index < list.length; index++) {
+                if (list[index].id === id) {
+                    return list[index]
+                }
+            }
+        },
+        callback (data) {
+            this.loadTreeData()
+        },
+        isSpecial (name, type) {
+            const fileType = ['内部文件', '外部文件', '记录表单']
+            // if (this.categoryKey === 'FILE_TYPE' && name=='文件分类' && type == '0') {
+            //     ActionUtils.warning('请不要操作文件分类!!如果需要更改,请联系管理员。')
+            //     return true
+            // }
+            if (this.categoryKey === 'FILE_TYPE' && fileType.includes(name) && type === '1') {
+                ActionUtils.warning('涉及系统代码逻辑,请谨慎操作内部文件、外部文件、记录表单分类!!如果需要更改,请联系管理员。')
+                return false
+            }
+            if (this.categoryKey === 'FILE_TYPE' && name === '记录表单' && type === '3') {
+                ActionUtils.warning('涉及系统代码逻辑,请谨慎操作记录表单!!如果需要更改,请联系管理员。')
+                return false
+            }
+            return false
         }
-      }
-    },
-    callback(data) {
-      this.loadTreeData()
     }
-
-  }
 }
 </script>

+ 282 - 281
src/views/platform/cat/type/move.vue

@@ -1,309 +1,310 @@
 <template>
-  <!--对话框-->
-  <el-dialog
-    v-if="displayType ==='dialog'"
-    :title="title"
-    :visible.sync="dialogVisible"
-    :close-on-click-modal="false"
-    :close-on-press-escape="false"
-    append-to-body
-    class="dialog"
-    :class="className"
-    @open="getFormData"
-    @close="closeDialog"
-  >
-    <el-form
-      ref="typeForm"
-      v-loading="dialogLoading"
-      :element-loading-text="$t('common.loading')"
-      :model="type"
-      :rules="rules"
-      :label-width="formLabelWidth"
-      @submit.native.prevent
+    <!--对话框-->
+    <el-dialog
+        v-if="displayType ==='dialog'"
+        :title="title"
+        :visible.sync="dialogVisible"
+        :close-on-click-modal="false"
+        :close-on-press-escape="false"
+        append-to-body
+        class="dialog"
+        :class="className"
+        @open="getFormData"
+        @close="closeDialog"
     >
-      <!-- <el-form-item  v-show="!formId" label="父节点名称:">
-        <span>{{ parentData.name }}</span>
-      </el-form-item> -->
+        <el-form
+            ref="typeForm"
+            v-loading="dialogLoading"
+            :element-loading-text="$t('common.loading')"
+            :model="type"
+            :rules="rules"
+            :label-width="formLabelWidth"
+            @submit.native.prevent
+        >
+            <!-- <el-form-item v-show="!formId" label="父节点名称:">
+              <span>{{ parentData.name }}</span>
+          </el-form-item> -->
 
-     <el-form-item label="更换上级目录:">
-       
-           <el-select v-model="topKey" style="width: 100%;" filterable placeholder="请选择">
-              <el-option
-                v-for="item in data"
-                :key="item.id"
-                :label="item.name"
-                :value="item.id">
-              </el-option>
-            </el-select>
-            
-       </el-form-item>
+            <el-form-item label="更换上级目录:">
 
-    <!--  <el-form-item label="分类名称:" prop="name">
-        <el-input v-model="type.name" v-pinyin="{vm:type,key:'typeKey'}" />
-      </el-form-item>
-      <el-form-item label="分类Key:" prop="typeKey">
-        <el-input v-model="type.typeKey" :disabled="$utils.isNotEmpty(formId)" />
-      </el-form-item> -->
+                <el-select v-model="topKey" style="width: 100%;" filterable placeholder="请选择">
+                    <el-option
+                        v-for="item in data"
+                        :key="item.id"
+                        :label="item.name"
+                        :value="item.id"
+                    />
+                </el-select>
 
+            </el-form-item>
 
+            <!-- <el-form-item label="分类名称:" prop="name">
+              <el-input v-model="type.name" v-pinyin="{vm:type,key:'typeKey'}" />
+          </el-form-item>
+          <el-form-item label="分类Key:" prop="typeKey">
+              <el-input v-model="type.typeKey" :disabled="$utils.isNotEmpty(formId)" />
+          </el-form-item> -->
 
-      <el-form-item v-show="categoryKey==='DIC_TYPE'" label="分类类型:" prop="struType">
-        <el-radio-group v-model="type.struType">
-          <el-radio
-            v-for="option in srtuOptions"
-            :key="option.value"
-            :label="option.value"
-          >{{ option.label }}
-          </el-radio>
-        </el-radio-group>
-      </el-form-item>
-    </el-form>
-       <div style="height: 100px;"></div>
-    <div slot="footer" class="el-dialog--center">
-      <ibps-toolbar
-        :actions="toolbars"
-        @action-event="handleActionEvent"
-      />
+            <el-form-item v-show="categoryKey==='DIC_TYPE'" label="分类类型:" prop="struType">
+                <el-radio-group v-model="type.struType">
+                    <el-radio
+                        v-for="option in srtuOptions"
+                        :key="option.value"
+                        :label="option.value"
+                    >{{ option.label }}
+                    </el-radio>
+                </el-radio-group>
+            </el-form-item>
+        </el-form>
+        <div style="height: 100px;" />
+        <div slot="footer" class="el-dialog--center">
+            <ibps-toolbar
+                :actions="toolbars"
+                @action-event="handleActionEvent"
+            />
+        </div>
+    </el-dialog>
+    <!--默认形式-->
+    <div v-else class="main-container">
+        <ibps-container type="full" class="page">
+            <template slot="header">
+                <el-button type="primary" :disabled="readonly" icon="ibps-icon-save" @click="handleSave()">保存</el-button>
+            </template>
+            <el-form ref="typeForm" :model="type" :rules="rules" :label-width="formLabelWidth">
+                <el-form-item label="分类:">
+                    <span>{{ isPrivateLocal ? '私有分类' : '普通分类' }}</span>
+                </el-form-item>
+                <el-form-item v-show="!formId" label="父节点名称:">
+                    <span>{{ parentData.name }}</span>
+                </el-form-item>
+                <el-form-item label="分类名称:" prop="name">
+                    <el-input v-if="!readonly" v-model="type.name" v-pinyin="{vm:type,key:'typeKey'}" />
+                    <span v-else>{{ type.name }}</span>
+                </el-form-item>
+                <el-form-item label="分类Key:" prop="typeKey">
+                    <el-input v-if="!readonly" v-model="type.typeKey" :disabled="$utils.isNotEmpty(formId)" />
+                    <span v-else>{{ type.typeKey }}</span>
+                </el-form-item>
+                <el-form-item v-show="categoryKey==='DIC_TYPE'" label="字典类型:" prop="struType">
+                    <el-radio-group v-model="type.struType">
+                        <el-radio
+                            v-for="option in srtuOptions"
+                            :key="option.value"
+                            :label="option.value"
+                        >{{ option.label }}
+                        </el-radio>
+                    </el-radio-group>
+                </el-form-item>
+            </el-form>
+        </ibps-container>
     </div>
-  </el-dialog>
-  <!--默认形式-->
-  <div v-else class="main-container">
-    <ibps-container type="full" class="page">
-      <template slot="header">
-        <el-button type="primary" :disabled="readonly" icon="ibps-icon-save" @click="handleSave()">保存</el-button>
-      </template>
-      <el-form ref="typeForm" :model="type" :rules="rules" :label-width="formLabelWidth">
-        <el-form-item label="分类:">
-          <span>{{ isPrivateLocal ? '私有分类' : '普通分类' }}</span>
-        </el-form-item>
-        <el-form-item v-show="!formId" label="父节点名称:">
-          <span>{{ parentData.name }}</span>
-        </el-form-item>
-        <el-form-item label="分类名称:" prop="name">
-          <el-input v-if="!readonly" v-model="type.name" v-pinyin="{vm:type,key:'typeKey'}" />
-          <span v-else>{{ type.name }}</span>
-        </el-form-item>
-        <el-form-item label="分类Key:" prop="typeKey">
-          <el-input v-if="!readonly" v-model="type.typeKey" :disabled="$utils.isNotEmpty(formId)" />
-          <span v-else>{{ type.typeKey }}</span>
-        </el-form-item>
-        <el-form-item v-show="categoryKey==='DIC_TYPE'" label="字典类型:" prop="struType">
-          <el-radio-group v-model="type.struType">
-            <el-radio
-              v-for="option in srtuOptions"
-              :key="option.value"
-              :label="option.value"
-            >{{ option.label }}
-            </el-radio>
-          </el-radio-group>
-        </el-form-item>
-      </el-form>
-    </ibps-container>
-  </div>
 </template>
 <script>
 import { save, get } from '@/api/platform/cat/type'
 import ActionUtils from '@/utils/action'
 import { srtuOptions } from './constants'
 import { validateKey } from '@/utils/validate'
-import curdPost from '@/business/platform/form/utils/custom/joinCURD.js' //增删改查规则
+import curdPost from '@/business/platform/form/utils/custom/joinCURD.js' // 增删改查规则
 export default {
-  props: {
-    className: String,
-    id: {
-      type: String
+    props: {
+        className: String,
+        id: {
+            type: String
+        },
+        parentData: Object, // 父类数据
+        categoryKey: String, // 分类标识key
+        isPrivate: Boolean, // 是否是私有的
+        data: Array,
+        visible: {
+            type: Boolean,
+            default: false
+        },
+        title: {
+            type: String
+        },
+        readonly: {
+            type: Boolean,
+            default: false
+        },
+        displayType: {
+            type: String,
+            default: 'dialog'
+        },
+        randomNum: [String, Number] // 时间戳,用于保证点击请求数据
     },
-    parentData: Object, // 父类数据
-    categoryKey: String, // 分类标识key
-    isPrivate: Boolean, // 是否是私有的
-    data: Array,
-    visible: {
-      type: Boolean,
-      default: false
-    },
-    title: {
-      type: String
-    },
-    readonly: {
-      type: Boolean,
-      default: false
-    },
-    displayType: {
-      type: String,
-      default: 'dialog'
-    },
-    randomNum: [String, Number] // 时间戳,用于保证点击请求数据
-  },
-  data() {
-    return {
-      formName: 'typeForm',
-      formLabelWidth: '120px',
-      dialogVisible: false,
-      dialogLoading: false,
-      isPrivateLocal: false,
-      topKey:'',
+    data () {
+        return {
+            formName: 'typeForm',
+            formLabelWidth: '120px',
+            dialogVisible: false,
+            dialogLoading: false,
+            isPrivateLocal: false,
+            topKey: '',
 
-      srtuOptions: srtuOptions,
-      defaultForm: {},
-      type: {
-        struType: '1',
-        name: '',
-        typeKey: '',
-        ownerId: '0'
-      },
-      rules: {
-        name: [{ required: true, message: this.$t('validate.required') }],
-        typeKey: [{ required: true, validator: validateKey }]
-      },
-      toolbars: [
-        { key: 'save', hidden: () => { return this.readonly } },
-        { key: 'cancel' }
-      ]
-    }
-  },
-  computed: {
-    formId() {
-      return this.id
-    },
-    random() {
-      return this.randomNum
-    }
-  },
-  watch: {
-    random() {
-      if (this.displayType !== 'dialog') {
-        this.getFormData()
-        if (!this.id) this.type = JSON.parse(JSON.stringify(this.defaultForm))
-      }
-    },
-    visible: {
-      handler: function(val, oldVal) {
-        this.dialogVisible = this.visible
-        this.isPrivateLocal = this.isPrivate
-      },
-      immediate: true
-   },
-    /* formId() {
-       if (this.displayType !== 'dialog') {
-         this.getFormData()
-         if (!this.id) this.type = JSON.parse(JSON.stringify(this.defaultForm))
-       }
-    }, */
-    isPrivate: {
-      handler: function(val, oldVal) {
-        this.isPrivateLocal = this.isPrivate
-      },
-      immediate: true
-    }
-  },
-  created() {
-    this.topKey = ''
-    this.defaultForm = JSON.parse(JSON.stringify(this.type))
-  },
-  methods: {
-    handleActionEvent({ key }) {
-      switch (key) {
-        case 'save':
-          this.handleSave()
-          break
-        case 'cancel':
-          this.closeDialog()
-          break
-        default:
-          break
-      }
+            srtuOptions: srtuOptions,
+            defaultForm: {},
+            type: {
+                struType: '1',
+                name: '',
+                typeKey: '',
+                ownerId: '0'
+            },
+            rules: {
+                name: [{ required: true, message: this.$t('validate.required') }],
+                typeKey: [{ required: true, validator: validateKey }]
+            },
+            toolbars: [
+                { key: 'save', hidden: () => { return this.readonly } },
+                { key: 'cancel' }
+            ]
+        }
     },
-    closeDialog() {
-      this.$emit('close', false)
+    computed: {
+        formId () {
+            return this.id
+        },
+        random () {
+            return this.randomNum
+        }
     },
-    // 修改数据
-    handleSave() {
-          this.Update('ibps_cat_type',{"id_":this.type.id},{"parent_id_":this.topKey}).then(response => {
-                     this.$emit('callback', true)
-                     this.dialogVisible = false
-                     this.$message({
-                               message: '修改成功',
-                               type: 'warning'
-                             });
-                   })
-
+    watch: {
+        random () {
+            if (this.displayType !== 'dialog') {
+                this.getFormData()
+                if (!this.id) this.type = JSON.parse(JSON.stringify(this.defaultForm))
+            }
+        },
+        visible: {
+            handler: function (val, oldVal) {
+                this.dialogVisible = this.visible
+                this.isPrivateLocal = this.isPrivate
+            },
+            immediate: true
+        },
+        // formId () {
+        //     if (this.displayType !== 'dialog') {
+        //         this.getFormData()
+        //         if (!this.id) this.type = JSON.parse(JSON.stringify(this.defaultForm))
+        //     }
+        // },
+        isPrivate: {
+            handler: function (val, oldVal) {
+                this.isPrivateLocal = this.isPrivate
+            },
+            immediate: true
+        }
     },
-    Update(name,where,cond){
-      let cont = {}
-      cont['tableName'] = name
-      cont['paramWhere'] = where
-      cont['paramCond'] = cond
-      return curdPost('update',JSON.stringify(cont))
+    created () {
+        this.topKey = ''
+        this.defaultForm = JSON.parse(JSON.stringify(this.type))
     },
-    // 提交保存数据
-    saveData() {
-      if (this.$utils.isEmpty(this.formId)) {
-        if (this.parentData.depth === 0 || this.parentData.depth === '0') {
-          this.type.path = this.parentData.id + '.'
-          this.isRoot = true
-        } else {
-          this.type.path = this.parentData.path
-        }
-        this.type.parentId = this.parentData.id
-        this.type.categoryKey = this.categoryKey
-        this.type.isPrivate = this.isPrivate
-
-        if (this.$utils.isEmpty(this.type.id) && (this.type.isPrivate === true || this.type.isPrivate === 'true')) {
-          this.type.ownerId = this.$store.getters.userId
-        }
-        if (!this.displayType === 'DIC_TYPE') {
-          this.type.struType = this.parentData.struType || '0'
-        }
-      }
-      save(JSON.stringify(this.type)).then(response => {
-        if (this.displayType === 'dialog') {
-          ActionUtils.saveSuccessMessage(response.message, (rtn) => {
+    methods: {
+        handleActionEvent ({ key }) {
+            switch (key) {
+                case 'save':
+                    this.handleSave()
+                    break
+                case 'cancel':
+                    this.closeDialog()
+                    break
+                default:
+                    break
+            }
+        },
+        closeDialog () {
+            this.$emit('close', false)
+        },
+        // 修改数据
+        handleSave () {
+            const params = {
+                tableName: 'ibps_cat_type',
+                updList: [{
+                    where: {
+                        id_: this.type.id
+                    },
+                    param: {
+                        parent_id_: this.topKey
+                    }
+                }]
+            }
+            curdPost('update', params).then(() => {
+                this.$emit('callback', true)
+                this.dialogVisible = false
+                this.$message({
+                    message: '修改成功',
+                    type: 'warning'
+                })
+            })
+        },
+        // 提交保存数据
+        saveData () {
             if (this.$utils.isEmpty(this.formId)) {
-              this.$refs[this.formName].resetFields()
+                if (this.parentData.depth === 0 || this.parentData.depth === '0') {
+                    this.type.path = this.parentData.id + '.'
+                    this.isRoot = true
+                } else {
+                    this.type.path = this.parentData.path
+                }
+                this.type.parentId = this.parentData.id
+                this.type.categoryKey = this.categoryKey
+                this.type.isPrivate = this.isPrivate
+
+                if (this.$utils.isEmpty(this.type.id) && (this.type.isPrivate === true || this.type.isPrivate === 'true')) {
+                    this.type.ownerId = this.$store.getters.userId
+                }
+                if (!this.displayType === 'DIC_TYPE') {
+                    this.type.struType = this.parentData.struType || '0'
+                }
             }
-            if (rtn) {
-              this.closeDialog()
+            save(JSON.stringify(this.type)).then(response => {
+                if (this.displayType === 'dialog') {
+                    ActionUtils.saveSuccessMessage(response.message, (rtn) => {
+                        if (this.$utils.isEmpty(this.formId)) {
+                            this.$refs[this.formName].resetFields()
+                        }
+                        if (rtn) {
+                            this.closeDialog()
+                        }
+                        this.$emit('callback', true)
+                    })
+                } else {
+                    ActionUtils.removeSuccessMessage('保存成功')
+                    if (this.$utils.isEmpty(this.formId)) {
+                        this.$refs[this.formName].resetFields()
+                    }
+                    this.$emit('callback', true)
+                }
+            }).catch((err) => {
+                console.error(err)
+            })
+        },
+        /**
+       * 表单验证
+       */
+        formValidate () {
+            if (this.readonly) return
+            this.$nextTick(() => {
+                this.$refs[this.formName].validate(() => {})
+            })
+        },
+        /**
+       * 获取表单数据
+       */
+        getFormData () {
+            if (this.$utils.isEmpty(this.formId)) {
+                // 重置表单
+                this.type = JSON.parse(JSON.stringify(this.defaultForm))
+                this.formValidate()
+                return
             }
-            this.$emit('callback', true)
-          })
-        } else {
-          ActionUtils.removeSuccessMessage('保存成功')
-          if (this.$utils.isEmpty(this.formId)) {
-            this.$refs[this.formName].resetFields()
-          }
-          this.$emit('callback', true)
+            get({
+                typeId: this.formId
+            }).then(response => {
+                this.$refs[this.formName].clearValidate()
+                this.type = response.data
+                this.isPrivateLocal = !((this.$utils.isEmpty(this.type.ownerId) || this.type.ownerId === '0'))
+            }).catch(() => { })
         }
-      }).catch((err) => {
-        console.error(err)
-      })
-    },
-    /**
-     * 表单验证
-     */
-    formValidate() {
-      if (this.readonly) return
-      this.$nextTick(() => {
-        this.$refs[this.formName].validate(() => {})
-      })
-    },
-    /**
-     * 获取表单数据
-     */
-    getFormData() {
-      if (this.$utils.isEmpty(this.formId)) {
-        // 重置表单
-        this.type = JSON.parse(JSON.stringify(this.defaultForm))
-        this.formValidate()
-        return
-      }
-      get({
-        typeId: this.formId
-      }).then(response => {
-        this.$refs[this.formName].clearValidate()
-        this.type = response.data
-        this.isPrivateLocal = !((this.$utils.isEmpty(this.type.ownerId) || this.type.ownerId === '0'))
-      }).catch(() => { })
     }
-  }
 }
 </script>

+ 205 - 175
src/views/platform/cat/type/sort.vue

@@ -1,43 +1,68 @@
 <template>
-  <el-dialog
-    :title="title"
-    :visible.sync="dialogVisible"
-    :close-on-click-modal="false"
-    :close-on-press-escape="false"
-    append-to-body
-    class="dialog type-sort-dialog"
-    @open="getFormData"
-    @close="closeDialog"
-  >
-    <el-container
-      v-loading="dialogLoading"
-      :element-loading-text="$t('common.loading')"
+    <el-dialog
+        :title="title"
+        :visible.sync="dialogVisible"
+        :close-on-click-modal="false"
+        :close-on-press-escape="false"
+        append-to-body
+        class="dialog type-sort-dialog"
+        @open="getFormData"
+        @close="closeDialog"
     >
-      <el-main>
-        <div v-for="option in data" :key="option.id">
-          <el-checkbox v-model="option.checked" @change="onClick(option)">
-            {{ option.name }}
-          </el-checkbox>
-        </div>
+        <el-container
+            v-loading="dialogLoading"
+            :element-loading-text="$t('common.loading')"
+        >
+            <el-main>
+                <div
+                    v-for="option in data"
+                    :key="option.id"
+                >
+                    <el-checkbox
+                        v-model="option.checked"
+                        @change="onClick(option)"
+                    >
+                        {{ option.name }}
+                    </el-checkbox>
+                </div>
 
-      </el-main>
-      <el-aside width="150px">
-        <el-button type="primary" icon="el-icon-upload2" @click="top">顶部</el-button><br>
-        <div class="button-padding" />
-        <el-button type="primary" icon="el-icon-top" @click="up">向上</el-button><br>
-        <div class="button-padding" />
-        <el-button type="primary" icon="el-icon-bottom" @click="down">向下</el-button><br>
-        <div class="button-padding" />
-        <el-button type="primary" icon="el-icon-download" @click="buttom">底部</el-button><br>
-      </el-aside>
-    </el-container>
-    <div slot="footer" class="el-dialog--center">
-      <ibps-toolbar
-        :actions="toolbars"
-        @action-event="handleActionEvent"
-      />
-    </div>
-  </el-dialog>
+            </el-main>
+            <el-aside width="150px">
+                <el-button
+                    type="primary"
+                    icon="el-icon-upload2"
+                    @click="top"
+                >顶部</el-button><br>
+                <div class="button-padding" />
+                <el-button
+                    type="primary"
+                    icon="el-icon-top"
+                    @click="up"
+                >向上</el-button><br>
+                <div class="button-padding" />
+                <el-button
+                    type="primary"
+                    icon="el-icon-bottom"
+                    @click="down"
+                >向下</el-button><br>
+                <div class="button-padding" />
+                <el-button
+                    type="primary"
+                    icon="el-icon-download"
+                    @click="buttom"
+                >底部</el-button><br>
+            </el-aside>
+        </el-container>
+        <div
+            slot="footer"
+            class="el-dialog--center"
+        >
+            <ibps-toolbar
+                :actions="toolbars"
+                @action-event="handleActionEvent"
+            />
+        </div>
+    </el-dialog>
 </template>
 
 <script>
@@ -46,154 +71,159 @@ import ActionUtils from '@/utils/action'
 import { moveUp, moveDown, moveTop, moveButtom } from '@/utils/move'
 
 export default {
-  props: {
-    visible: {
-      type: Boolean,
-      default: false
-    },
-    id: String,
-    title: String
-
-  },
-  data() {
-    return {
-      formName: 'dictionaryForm',
-      formLabelWidth: '120px',
-      dialogVisible: this.visible,
-      dialogLoading: false,
-      data: [],
-      ids: [],
-      sortForm: {
-        name: '',
-        typeKey: '',
-        struType: '1'
-      },
-      rules: {},
-      checkedIds: [],
-      toolbars: [
-        { key: 'save' },
-        { key: 'cancel' }
-      ]
-    }
-  },
-  computed: {
-    formId() {
-      return this.id
-    }
-  },
-  watch: {
-    visible: {
-      handler: function(val, oldVal) {
-        this.dialogVisible = this.visible
-        // 关闭清除数据,刷新树
-        this.data = []
-        this.checkedIds = []
-      },
-      immediate: true
-    }
-  },
-  methods: {
-    handleActionEvent({ key }) {
-      switch (key) {
-        case 'save':
-          this.handleSave()
-          break
-        case 'cancel':
-          this.closeDialog()
-          break
-        default:
-          break
-      }
-    },
-    // 保存数据
-    handleSave() {
-      const data = this.data
-      const ids = []
-      data.forEach(function(v) { ids.push(v.id) })
-      this.ids = ids
-
-      this.saveData()
-    },
-    // 提交保存数据
-    saveData() {
-      sortSave({ 'typeIds': this.ids.join(',') }).then(response => {
-        this.$emit('callback', this)
-        ActionUtils.saveSuccessMessage(response.message, (rtn) => {
-          if (rtn) {
-            this.closeDialog()
-          }
-        })
-      }).catch((err) => {
-        console.error(err)
-      })
-    },
-    // 关闭当前窗口
-    closeDialog() {
-      this.$emit('close', false)
+    props: {
+        visible: {
+            type: Boolean,
+            default: false
+        },
+        id: String,
+        title: String,
+        categoryKey: String
     },
-    /**
-     * 获取表单数据
-     */
-    getFormData() {
-      if (this.$utils.isEmpty(this.formId)) {
-        return
-      }
-      this.dialogLoading = true
-      sortList({
-        typeId: this.formId
-      }).then(response => {
-        this.data = response.data
-        this.dialogLoading = false
-      }).catch(() => {
-        this.dialogLoading = false
-      })
+    data () {
+        const { first, second } = this.$store.getters.level || {}
+        return {
+            level: second || first,
+            formName: 'dictionaryForm',
+            formLabelWidth: '120px',
+            dialogVisible: this.visible,
+            dialogLoading: false,
+            data: [],
+            ids: [],
+            sortForm: {
+                name: '',
+                typeKey: '',
+                struType: '1'
+            },
+            rules: {},
+            checkedIds: [],
+            toolbars: [
+                { key: 'save' },
+                { key: 'cancel' }
+            ]
+        }
     },
-    onClick(option) {
-      const index = this.checkedIds.indexOf(option.id)
-      if (index > -1) {
-        this.checkedIds.splice(index, 1)
-      } else {
-        this.checkedIds.push(option.id)
-      }
+    computed: {
+        formId () {
+            return this.id
+        }
     },
-    // 顶部
-    top() {
-      const data = this.data
-      this.data = moveTop(data, this.checkedIds, 'id')
+    watch: {
+        visible: {
+            handler: function (val, oldVal) {
+                this.dialogVisible = this.visible
+                // 关闭清除数据,刷新树
+                this.data = []
+                this.checkedIds = []
+            },
+            immediate: true
+        }
     },
-    // 向上
-    up() {
-      const data = this.data
-      this.data = moveUp(data, 1)
-    },
-    //  向下
-    down() {
-      const data = this.data
-      this.data = moveDown(data, 1)
-    },
-    // 底部
-    buttom() {
-      const data = this.data
-      this.data = moveButtom(data, this.checkedIds, 'id')
+    methods: {
+        handleActionEvent ({ key }) {
+            switch (key) {
+                case 'save':
+                    this.handleSave()
+                    break
+                case 'cancel':
+                    this.closeDialog()
+                    break
+                default:
+                    break
+            }
+        },
+        // 保存数据
+        handleSave () {
+            const data = this.data
+            const ids = []
+            data.forEach(function (v) { ids.push(v.id) })
+            this.ids = ids
+
+            this.saveData()
+        },
+        // 提交保存数据
+        saveData () {
+            sortSave({ 'typeIds': this.ids.join(',') }).then(response => {
+                this.$emit('callback', this)
+                ActionUtils.saveSuccessMessage(response.message, (rtn) => {
+                    if (rtn) {
+                        this.closeDialog()
+                    }
+                })
+            }).catch((err) => {
+                console.error(err)
+            })
+        },
+        // 关闭当前窗口
+        closeDialog () {
+            this.$emit('close', false)
+        },
+        /**
+       * 获取表单数据
+       */
+        getFormData () {
+            if (this.$utils.isEmpty(this.formId)) {
+                return
+            }
+            this.dialogLoading = true
+            const whererParams = {
+                typeId: this.formId
+            }
+            if (this.categoryKey === 'FILE_TYPE') {
+                whererParams.diDian = this.level
+            }
+            sortList(whererParams).then(response => {
+                this.data = response.data
+                this.dialogLoading = false
+            }).catch(() => {
+                this.dialogLoading = false
+            })
+        },
+        onClick (option) {
+            const index = this.checkedIds.indexOf(option.id)
+            if (index > -1) {
+                this.checkedIds.splice(index, 1)
+            } else {
+                this.checkedIds.push(option.id)
+            }
+        },
+        // 顶部
+        top () {
+            const data = this.data
+            this.data = moveTop(data, this.checkedIds, 'id')
+        },
+        // 向上
+        up () {
+            const data = this.data
+            this.data = moveUp(data, 1)
+        },
+        //  向下
+        down () {
+            const data = this.data
+            this.data = moveDown(data, 1)
+        },
+        // 底部
+        buttom () {
+            const data = this.data
+            this.data = moveButtom(data, this.checkedIds, 'id')
+        }
     }
-  }
 
 }
 </script>
 <style lang="scss">
-.type-sort-dialog{
+.type-sort-dialog {
   // .el-dialog__body{
-  //   height:  calc(27vh - 120px) !important;
+  //     height:  calc(27vh - 120px) !important;
   // }
-  .button-padding{
-  height: 5px;
-}
-.el-main{
-  border: 1px #d4d4de solid;
-}
-.el-aside{
-  padding-left: 20px;
-}
+  .button-padding {
+      height: 5px;
+  }
+  .el-main {
+      border: 1px #d4d4de solid;
+  }
+  .el-aside {
+      padding-left: 20px;
+  }
 }
-
 </style>