Sfoglia il codice sorgente

fix:调整文件权限控制,内部文件查阅

liujiayin 2 anni fa
parent
commit
55e645e2a0

+ 260 - 182
src/views/infosManage/externalFiles/externalFiles.vue

@@ -1,212 +1,290 @@
 <template>
-    <ibps-layout ref="layout">
-        <!-- 外部 -->
-        <div slot="west">
-            <div class="box">
-                <p class="title">文件类型</p>
-                <el-input placeholder="输入关键字进行过滤" v-model="filterText">
-                </el-input>
-                <div class="treeDiv">
-                    <el-tree ref="tree" :data="typeData" :props="defaultProps" @node-click="handleNodeClick"
-                        :filter-node-method="filterNode"></el-tree>
-                </div>
-            </div>
-            <ibps-container :margin-left="width + 'px'" class="page">
-                <el-alert v-if="!show" :closable="false" title="请选择左边菜单右键进行操作!" type="warning" show-icon
-                    style="height:50px;" />
-                <template v-else>
-                    <ibps-crud key="istree" ref="crud" :data="tableData" :toolbars="listConfig.toolbars"
-                        :search-form="listConfig.searchForm" :pk-key="pkKey" :columns="listConfig.columns"
-                        :loading="loading" @action-event="handleAction">
-                        <template slot="wenjinachayue" slot-scope="scope">
-                            <ibps-attachment :value="scope.row.wen_jian_id_" readonly allow-download :download="false" />
-                        </template>
-                    </ibps-crud>
-                </template>
-            </ibps-container>
-
+  <ibps-layout ref="layout">
+    <!-- 外部 -->
+    <div slot="west">
+      <div class="box">
+        <p class="title">文件类型</p>
+        <el-input placeholder="输入关键字进行过滤"
+                  v-model="filterText">
+        </el-input>
+        <div class="treeDiv">
+          <el-tree ref="tree"
+                   :width="width"
+                   :data="typeData"
+                   :props="defaultProps"
+                   @node-click="handleNodeClick"
+                   :filter-node-method="filterNode"></el-tree>
         </div>
-    </ibps-layout>
+      </div>
+      <ibps-container :margin-left="width + 'px'"
+                      class="page">
+        <el-alert v-if="!show"
+                  :closable="false"
+                  title="请选择左边菜单右键进行操作!"
+                  type="warning"
+                  show-icon
+                  style="height:50px;" />
+        <template v-else>
+          <ibps-crud key="istree"
+                     ref="crud"
+                     :data="tableData"
+                     :toolbars="listConfig.toolbars"
+                     :search-form="listConfig.searchForm"
+                     :pk-key="pkKey"
+                     :columns="listConfig.columns"
+                     :loading="loading"
+                     @sort-change="handleSortChange"
+                     @action-event="handleAction"
+                     @pagination-change="handlePaginationChange">
+            <template slot="wenjinachayue"
+                      slot-scope="scope">
+              <ibps-attachment :value="scope.row.wen_jian_id_"
+                               readonly
+                               allow-download
+                               :download="false" />
+            </template>
+          </ibps-crud>
+        </template>
+      </ibps-container>
+
+    </div>
+  </ibps-layout>
 </template>
 <script>
 import ActionUtils from '@/utils/action'
 import { getFileType, getFileByUserId } from '@/api/permission/file'
 import IbpsAttachment from '@/business/platform/file/attachment/selector'
+import curdPost from '@/business/platform/form/utils/custom/joinCURD.js'
 export default {
-    components: {
-        'ibps-attachment': IbpsAttachment
-    },
-    data() {
-        return {
-            show: '',
-            rightsArr: ['join', 'delete'],
-            rowHandle: true,
-            width: 230,
-            orgId: '',
-            oldorgId: '',
-            orgName: '',
-            loading: false,
-            typeData: [
-                { id: '0', label: 'CNAS相关文件' },
-                { id: '1', label: 'CMA相关文件' },
-                { id: '2', label: '法律法规' },
-                { id: '3', label: '检测标准' },
-                { id: '4', label: '设备说明书' },
-                { id: '5', label: '试剂耗材说明书' },
-                { id: '6', label: '标准物质证书' },
-                { id: '7', label: '参考技术文献(受限)' },
-                { id: '8', label: '客户技术资料(受限)' },
-            ],
-            filterText: '',
-            defaultProps: {
-                children: 'children',
-                label: 'label'
-            },
-            pkKey: 'id', // 主键  如果主键不是pk需要传主键
-            loading: false,
-            tableData: [],
-            listTreeData: [],
-            listConfig: {
-                // 工具栏
-                toolbars: [
-                    { key: 'search' }
-                ],
-                // 查询条件
-                searchForm: {
-                    forms: [
-                        { prop: 'fileCode', label: '文件编号' },
-                        { prop: 'fileName', label: '文件名称' },
-                        // { prop: 'deptName', label: '部门' },
-                    ]
-                },
-                // 表格字段配置
-                columns: [
-                    // { prop: 'zi_duan_yi_', label: '部门' },
-                    { prop: 'wen_jian_bian_hao', label: '文件编号' },
-                    { prop: 'wen_jian_ming_che', label: '文件名称' },
-                    { prop: 'ban_ben_hao_', label: '版本号' },
-                    { prop: 'fa_bu_ri_qi_', label: '发布日期' },
-                    { prop: 'wen_jian_id_', label: '查阅', slotName: "wenjinachayue" }
-                ]
-            },
-            listOptions: {
-                border: true,
-                stripe: true
-            },
-            pagination: {},
-            sorts: {},
-            // testData: [{
-            //     zi_duan_yi_: '1',
-            //     wen_jian_bian_hao: '2',
-            //     wen_jian_ming_che: '3',
-            //     ban_ben_hao_: '4',
-            //     fa_bu_ri_qi_: '5',
-            //     wen_jian_id_: '880481571788816384'
-            // }]
+  components: {
+    'ibps-attachment': IbpsAttachment
+  },
+  data() {
+    return {
+      show: '',
+      rightsArr: ['join', 'delete'],
+      rowHandle: true,
+      width: 230,
+      orgId: '',
+      oldorgId: '',
+      orgName: '',
+      loading: false,
+      typeData: [
+        { id: '0', label: 'CNAS相关文件' },
+        { id: '1', label: 'CMA相关文件' },
+        { id: '2', label: '法律法规' },
+        { id: '3', label: '检测标准' },
+        { id: '4', label: '设备说明书' },
+        { id: '5', label: '试剂耗材说明书' },
+        { id: '6', label: '标准物质证书' },
+        { id: '7', label: '参考技术文献(受限)' },
+        { id: '8', label: '客户技术资料(受限)' },
+      ],
+      filterText: '',
+      defaultProps: {
+        children: 'children',
+        label: 'label'
+      },
+      pkKey: 'id', // 主键  如果主键不是pk需要传主键
+      loading: false,
+      tableData: [],
+      listTreeData: [],
+      bianlistData: {
+        dataResult: [],
+        pageResult: {
+          limit: 0,
+          page: 0,
+          totalCount: 0,
+          totalPages: 0
         }
+      },
+      listConfig: {
+        // 工具栏
+        toolbars: [
+          { key: 'search' }
+        ],
+        // 查询条件
+        searchForm: {
+          forms: [
+            { prop: 'fileCode', label: '文件编号' },
+            { prop: 'fileName', label: '文件名称' },
+            // { prop: 'deptName', label: '部门' },
+          ]
+        },
+        // 表格字段配置
+        columns: [
+          // { prop: 'zi_duan_yi_', label: '部门' },
+          { prop: 'wen_jian_bian_hao', label: '文件编号', sortable: 'custom', width: 150 },
+          { prop: 'wen_jian_ming_che', label: '文件名称', width: 400 },
+          { prop: 'ban_ben_hao_', label: '版本号', sortable: 'custom', width: 100 },
+          { prop: 'fa_bu_ri_qi_', label: '发布日期', sortable: 'custom', width: 100 },
+          { prop: 'wen_jian_id_', label: '查阅', slotName: "wenjinachayue", width: 400 }
+        ]
+      },
+      listOptions: {
+        border: true,
+        stripe: true
+      },
+      bianlistData: {
+        dataResult: [],
+        pageResult: {
+          limit: 0,
+          page: 0,
+          totalCount: 0,
+          totalPages: 0
+        }
+      },
+      pagination: {
+        limit: 20, page: 1
+      },
+      sorts: {},
+      // testData: [{
+      //     zi_duan_yi_: '1',
+      //     wen_jian_bian_hao: '2',
+      //     wen_jian_ming_che: '3',
+      //     ban_ben_hao_: '4',
+      //     fa_bu_ri_qi_: '5',
+      //     wen_jian_id_: '880481571788816384'
+      // }]
+    }
+  },
+  mounted() {
+    // this.loadNode()
+  },
+  methods: {
+    filterNode(value, data) {
+      if (!value) return true;
+      return data.label.indexOf(value) !== -1;
     },
-    mounted() {
-        // this.loadNode()
+    loadNode() {
+      this.loading = true
     },
-    methods: {
-        filterNode(value, data) {
-            if (!value) return true;
-            return data.label.indexOf(value) !== -1;
-        },
-        loadNode() {
-            this.loading = true
-            // getFileType("外部文件").then(res => {
-            //     this.loading = false
-            //     for (let i in res.variables.data) {
-            //         let data = {}
-            //         data["id"] = i
-            //         data["label"] = res.variables.data[i]
-            //         this.typeData.push(data)
-            //     }
-            // }).catch(res => {
-            //     this.loading = false
-            // })
-        },
-        refreshData() {
-            this.tableData = []
-            getFileByUserId(this.getSearcFormData()).then(res => {
-                this.tableData = res.variables.data
-            }).catch(res => {
-                this.loading = false
-                this.tableData = []
-            })
-        },
+    getDatas(sorts) {
+      this.listData = []
+      let wheres = ''
+      if (sorts.fileCode) {
+        wheres = wheres + ` and wj.wen_jian_bian_hao like '%${sorts.fileCode}%'`
+      }
 
-        handleNodeClick(data) {
-            this.show = 'detail'
-            if (this.oldorgId == data.id) {
-                return
-            } else {
-                getFileByUserId({
-                    deptName: "1",
-                    fileCode: "",
-                    fileName: "",
-                    fileType: data.label,
-                    userId: this.$store.getters.userInfo.employee.id
-                }).then(res => {
-                    this.oldorgId = data.id
-                    this.tableData = res.variables.data
-                }).catch(res => {
-                    this.loading = false
-                    this.tableData = []
-                })
-            }
-        },
+      if (sorts.fileType) {
+        wheres = wheres + ` and wj.wen_jian_lie_xing = '${sorts.fileType}'`
+      }
+      if (sorts.fileName) {
+        wheres = wheres + ` and wj.wen_jian_ming_che like '%${sorts.fileName}%'`
+      }
+      if (sorts.sorts) {
+        if (JSON.stringify(sorts.sorts) !== "{}") {
+          wheres = wheres + ` order by  ${Object.keys(sorts.sorts)}  ${Object.values(sorts.sorts)}`
+        }
+      }
+      // 重复发放的文件,在权限表会存在重复的文件信息
+      let sql = `select  wj.wen_jian_bian_hao,wj.wen_jian_ming_che,wj.ban_ben_hao_,qx.create_time_,wj.wen_jian_id_,qx.fa_bu_ri_qi_ FROM  t_wjcysqb qx 
+      LEFT JOIN t_wjgl wj ON qx.wen_jian_id_=wj.wen_jian_id_ WHERE qx.yong_hu_id_='${sorts.userId}' ${wheres}`
 
-        /**
-         * 获取格式化参数
-         */
-        getSearcFormData() {
-            const params = this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {}
-            params['fileType'] = this.typeData[this.oldorgId].label
-            params['userId'] = this.$store.getters.userInfo.employee.id
-            return params
-        },
-        /**
-     * 处理按钮事件
-     */
-        handleAction(command, position, selection, data) {
-            switch (command) {
-                case 'search':// 查询
-                    this.refreshData()
-                    break
-                default:
-                    break
-            }
-        },
+      curdPost('sql', sql).then(res => {
+        let tableDatas = res.variables.data
+        this.selectListData = JSON.parse(JSON.stringify(tableDatas))
+        let filterDatas = []
+        this.bianlistData.pageResult.totalCount = tableDatas.length
+        this.bianlistData.pageResult.totalPages = Math.ceil(tableDatas.length / this.pagination.limit)
+        this.bianlistData.pageResult.limit = this.pagination.limit
+        this.bianlistData.pageResult.page = this.pagination.page
+        if (this.pagination.limit > tableDatas.length) {
+          filterDatas = JSON.parse(JSON.stringify(tableDatas))
+        } else {
+          for (let index = 0; index < 20; index++) {
+            filterDatas.push(tableDatas[index])
+          }
+        }
+        this.bianlistData.dataResult = filterDatas
+        ActionUtils.handleListData(this, this.bianlistData)
+      }).catch(res => {
+        this.loading = false
+        this.listData = []
+      })
+    },
+    refreshData() {
+      this.listData = []
+      this.getDatas(this.getSearcFormData())
+    },
 
+    handleNodeClick(data) {
+      this.oldorgId = data
+      this.show = 'detail'
+      if (this.oldorgId == data.id) {
+        return
+      } else {
+        this.getDatas({
+          fileType: this.typeData[data.id].label,
+          userId: this.$store.getters.userInfo.employee.id,
+          sorts: { 'wen_jian_bian_hao': 'desc' }
+        })
+      }
     },
-    watch: {
-        filterText(val) {
-            this.$refs.tree.filter(val);
+
+    /**
+      * 获取格式化参数
+      */
+    getSearcFormData() {
+      const params = this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {}
+      params['fileType'] = this.typeData[this.oldorgId.id].label
+      params['userId'] = this.$store.getters.userInfo.employee.id
+      params['sorts'] = this.sorts
+      return params
+    },
+    // 处理分页事件
+    handlePaginationChange(page) {
+      ActionUtils.setPagination(this.pagination, page)
+      this.bianlistData.pageResult.limit = page.limit
+      this.bianlistData.pageResult.page = page.page
+      let filterDatas = []
+      if (this.selectListData.length >= (page.limit * page.page)) {
+        for (let index = (page.limit * page.page) - page.limit; index < (page.limit * page.page); index++) {
+          filterDatas.push(this.selectListData[index])
+        }
+        this.bianlistData.dataResult = JSON.parse(JSON.stringify(filterDatas))
+      } else {
+        for (let index = (page.limit * page.page) - page.limit; index < this.selectListData.length; index++) {
+          filterDatas.push(this.selectListData[index])
         }
+        this.bianlistData.dataResult = JSON.parse(JSON.stringify(filterDatas))
+      }
+      ActionUtils.handleListData(this, this.bianlistData)
     },
+    /**
+     * 处理按钮事件
+     */
+    handleAction(command, position, selection, data) {
+      switch (command) {
+        case 'search':// 查询
+          this.refreshData()
+          break
+        default:
+          break
+      }
+    },
+
+  },
+  watch: {
+    filterText(val) {
+      this.$refs.tree.filter(val);
+    }
+  },
 }
 </script>
 <style lang="less" scoped>
 .box {
-    width: 210px;
+  width: 210px;
 }
 
-
 .title {
-    font-size: 14px;
-    margin: 21px 5px 5px;
-    padding: 0;
-}
-
-.treeDiv {
-    height: 800px;
-    overflow-y: auto;
+  font-size: 14px;
+  margin: 21px 5px 5px;
+  padding: 0;
 }
 
 /deep/ .el-tree-node__content {
-    display: block;
+  display: block;
 }
 </style>
   

+ 281 - 192
src/views/infosManage/internalFiles/internalFiles.vue

@@ -1,222 +1,311 @@
 <template>
-    <ibps-layout ref="layout">
-        <!-- 外部 -->
-        <div slot="west">
-            <div class="box">
-                <p class="title">文件类型</p>
-                <el-input placeholder="输入关键字进行过滤" v-model="filterText">
-                </el-input>
-                <div class="treeDiv">
-                    <el-tree ref="tree" :data="typeData" :props="defaultProps" @node-click="handleNodeClick"
-                        :filter-node-method="filterNode"></el-tree>
-                </div>
-            </div>
-            <ibps-container :margin-left="width + 'px'" class="page">
-                <el-alert v-if="!show" :closable="false" title="请选择左边菜单右键进行操作!" type="warning" show-icon
-                    style="height:50px;" />
-                <template v-else>
-                    <ibps-crud key="istree" ref="crud" :data="tableData" :toolbars="listConfig.toolbars"
-                        :search-form="listConfig.searchForm" :pk-key="pkKey" :columns="listConfig.columns"
-                        :loading="loading" @action-event="handleAction">
-                        <template slot="wenjinachayue" slot-scope="scope">
-                            <ibps-attachment :value="scope.row.wen_jian_id_" readonly allow-download :download="false" />
-                        </template>
-                    </ibps-crud>
-                </template>
-            </ibps-container>
-
+  <ibps-layout ref="layout">
+    <!-- 外部 -->
+    <div slot="west">
+      <div class="box">
+        <p class="title">文件类型</p>
+        <el-input placeholder="输入关键字进行过滤"
+                  v-model="filterText">
+        </el-input>
+        <div class="treeDiv">
+          <el-tree ref="tree"
+                   :width="width"
+                   :data="typeData"
+                   :props="defaultProps"
+                   @node-click="handleNodeClick"
+                   :filter-node-method="filterNode"></el-tree>
         </div>
-    </ibps-layout>
+      </div>
+      <ibps-container :margin-left="width + 'px'"
+                      class="page">
+        <el-alert v-if="!show"
+                  :closable="false"
+                  title="请选择左边菜单右键进行操作!"
+                  type="warning"
+                  show-icon
+                  style="height:50px;" />
+        <template v-else>
+          <ibps-crud key="istree"
+                     ref="crud"
+                     :data="tableData"
+                     :toolbars="listConfig.toolbars"
+                     :search-form="listConfig.searchForm"
+                     :pk-key="pkKey"
+                     :columns="listConfig.columns"
+                     :loading="loading"
+                     @sort-change="handleSortChange"
+                     @action-event="handleAction"
+                     @pagination-change="handlePaginationChange">
+            <template slot="wenjinachayue"
+                      slot-scope="scope">
+              <ibps-attachment :value="scope.row.wen_jian_id_"
+                               readonly
+                               allow-download
+                               :download="false" />
+            </template>
+          </ibps-crud>
+        </template>
+      </ibps-container>
+
+    </div>
+  </ibps-layout>
+
 </template>
 <script>
 import ActionUtils from '@/utils/action'
 import { getFileType, getFileByUserId } from '@/api/permission/file'
 import IbpsAttachment from '@/business/platform/file/attachment/selector'
+import curdPost from '@/business/platform/form/utils/custom/joinCURD.js'
 export default {
-    components: {
-        'ibps-attachment': IbpsAttachment
-    },
-    data() {
-        return {
-            show: '',
-            rightsArr: ['join', 'delete'],
-            rowHandle: true,
-            width: 230,
-            orgId: '',
-            oldorgId: '',
-            orgName: '',
-            loading: false,
-            typeData: [
-                { id: '0', label: '质量手册' },
-                { id: '1', label: '程序文件' },
-                { id: '2', label: '程序文件表单' },
-                { id: '3', label: '检测方法SOP' },
-                { id: '4', label: '设备操作维护SOP' },
-                { id: '5', label: '设备设施验证SOP' },
-                { id: '6', label: '检测方法验证SOP' },
-                { id: '7', label: '管理类SOP' },
-                { id: '8', label: '检测方法SOP表单' },
-                { id: '9', label: '设备操作维护SOP表单' },
-                { id: '10', label: '设备设施验证SOP表单' },
-                { id: '11', label: '检测方法验证SOP表单' },
-                { id: '12', label: '管理类SOP表单' },
-                { id: '13', label: '公司管理制度' },
-                { id: '14', label: '非检测方法SOP' },
-                { id: '15', label: '检测方法确认SOP' },
-                { id: '16', label: '非标确认规定' },
-                { id: '17', label: '非检测方法SOP表单' },
-                { id: '18', label: '非检测方法确认SOP表单' },
-            ],
-            filterText: '',
-            defaultProps: {
-                children: 'children',
-                label: 'label'
-            },
-            pkKey: 'id', // 主键  如果主键不是pk需要传主键
-            loading: false,
-            tableData: [],
-            listTreeData: [],
-            listConfig: {
-                // 工具栏
-                toolbars: [
-                    { key: 'search' }
-                ],
-                // 查询条件
-                searchForm: {
-                    forms: [
-                        { prop: 'fileCode', label: '文件编号' },
-                        { prop: 'fileName', label: '文件名称' },
-                        // { prop: 'deptName', label: '部门' },
-                    ]
-                },
-                // 表格字段配置
-                columns: [
-                    // { prop: 'zi_duan_yi_', label: '部门' },
-                    { prop: 'wen_jian_bian_hao', label: '文件编号' },
-                    { prop: 'wen_jian_ming_che', label: '文件名称' },
-                    { prop: 'ban_ben_hao_', label: '版本号' },
-                    { prop: 'fa_bu_ri_qi_', label: '发布日期' },
-                    { prop: 'wen_jian_id_', label: '查阅', slotName: "wenjinachayue" }
-                ]
-            },
-            listOptions: {
-                border: true,
-                stripe: true
-            },
-            pagination: {},
-            sorts: {},
-            // testData: [{
-            //     zi_duan_yi_: '1',
-            //     wen_jian_bian_hao: '2',
-            //     wen_jian_ming_che: '3',
-            //     ban_ben_hao_: '4',
-            //     fa_bu_ri_qi_: '5',
-            //     wen_jian_id_: '880481571788816384'
-            // }]
+  components: {
+    'ibps-attachment': IbpsAttachment
+  },
+  data() {
+    return {
+      show: '',
+      rightsArr: ['join', 'delete'],
+      rowHandle: true,
+      width: 230,
+      orgId: '',
+      oldorgId: '',
+      orgName: '',
+      loading: false,
+      typeData: [
+        { id: '0', label: '质量手册' },
+        { id: '1', label: '程序文件' },
+        { id: '2', label: '程序文件表单' },
+        { id: '3', label: '检测方法SOP' },
+        { id: '4', label: '设备操作维护SOP' },
+        { id: '5', label: '设备设施验证SOP' },
+        { id: '6', label: '检测方法验证SOP' },
+        { id: '7', label: '管理类SOP' },
+        { id: '8', label: '检测方法SOP表单' },
+        { id: '9', label: '设备操作维护SOP表单' },
+        { id: '10', label: '设备设施验证SOP表单' },
+        { id: '11', label: '检测方法验证SOP表单' },
+        { id: '12', label: '管理类SOP表单' },
+        { id: '13', label: '公司管理制度' },
+        { id: '14', label: '非检测方法SOP' },
+        { id: '15', label: '检测方法确认SOP' },
+        { id: '16', label: '非标确认规定' },
+        { id: '17', label: '非检测方法SOP表单' },
+        { id: '18', label: '非检测方法确认SOP表单' },
+      ],
+      filterText: '',
+      defaultProps: {
+        children: 'children',
+        label: 'label'
+      },
+      pkKey: 'id', // 主键  如果主键不是pk需要传主键
+      loading: false,
+      tableData: [],
+      listTreeData: [],
+      bianlistData: {
+        dataResult: [],
+        pageResult: {
+          limit: 0,
+          page: 0,
+          totalCount: 0,
+          totalPages: 0
         }
+      },
+      listConfig: {
+        // 工具栏
+        toolbars: [
+          { key: 'search' }
+        ],
+        // 查询条件
+        searchForm: {
+          forms: [
+            { prop: 'fileCode', label: '文件编号' },
+            { prop: 'fileName', label: '文件名称' },
+            // { prop: 'deptName', label: '部门' },
+          ]
+        },
+        // 表格字段配置
+        columns: [
+          // { prop: 'zi_duan_yi_', label: '部门' },
+          { prop: 'wen_jian_bian_hao', label: '文件编号', sortable: 'custom', width: 150 },
+          { prop: 'wen_jian_ming_che', label: '文件名称', width: 400 },
+          { prop: 'ban_ben_hao_', label: '版本号', sortable: 'custom', width: 100 },
+          { prop: 'fa_bu_ri_qi_', label: '发布日期', sortable: 'custom', width: 100 },
+          { prop: 'wen_jian_id_', label: '查阅', slotName: "wenjinachayue", width: 400 }
+        ]
+      },
+      listOptions: {
+        border: true,
+        stripe: true
+      },
+      pagination: {
+        limit: 20, page: 1
+      },
+      sorts: {},
+      // testData: [{
+      //     zi_duan_yi_: '1',
+      //     wen_jian_bian_hao: '2',
+      //     wen_jian_ming_che: '3',
+      //     ban_ben_hao_: '4',
+      //     fa_bu_ri_qi_: '5',
+      //     wen_jian_id_: '880481571788816384'
+      // }]
+    }
+  },
+  mounted() {
+    // this.loadNode()
+  },
+  methods: {
+    filterNode(value, data) {
+      if (!value) return true;
+      return data.label.indexOf(value) !== -1;
     },
-    mounted() {
-        // this.loadNode()
+    loadNode() {
+      this.loading = true
+      // getFileType("内部文件").then(res => {
+      //     this.loading = false
+      //     for (let i in res.variables.data) {
+      //         let data = {}
+      //         data["id"] = i
+      //         data["label"] = res.variables.data[i]
+      //         this.typeData.push(data)
+      //     }
+      // }).catch(res => {
+      //     this.loading = false
+      // })
     },
-    methods: {
-        filterNode(value, data) {
-            if (!value) return true;
-            return data.label.indexOf(value) !== -1;
-        },
-        loadNode() {
-            this.loading = true
-            // getFileType("内部文件").then(res => {
-            //     this.loading = false
-            //     for (let i in res.variables.data) {
-            //         let data = {}
-            //         data["id"] = i
-            //         data["label"] = res.variables.data[i]
-            //         this.typeData.push(data)
-            //     }
-            // }).catch(res => {
-            //     this.loading = false
-            // })
-        },
-        refreshData() {
-            this.tableData = []
-            getFileByUserId(this.getSearcFormData()).then(res => {
-                this.tableData = res.variables.data
-            }).catch(res => {
-                this.loading = false
-                this.tableData = []
-            })
-        },
+    getDatas(sorts) {
+      this.listData = []
+      let wheres = ''
+      if (sorts.fileCode) {
+        wheres = wheres + ` and wen_jian_bian_hao like '%${sorts.fileCode}%'`
+      }
 
-        handleNodeClick(data) {
-            this.show = 'detail'
-            if (this.oldorgId == data.id) {
-                return
-            } else {
-                getFileByUserId({
-                    deptName: "0",
-                    fileCode: "",
-                    fileName: "",
-                    fileType: data.label,
-                    userId: this.$store.getters.userInfo.employee.id
-                }).then(res => {
-                    this.oldorgId = data.id
-                    this.tableData = res.variables.data
-                }).catch(res => {
-                    this.loading = false
-                    this.tableData = []
-                })
-            }
-        },
+      if (sorts.fileType) {
+        wheres = wheres + ` and wen_jian_lie_xing = '${sorts.fileType}'`
+      }
+      if (sorts.fileName) {
+        wheres = wheres + ` and wen_jian_ming_che like '%${sorts.fileName}%'`
+      }
+      if (sorts.sorts) {
+        if (JSON.stringify(sorts.sorts) !== "{}") {
+          wheres = wheres + ` order by  ${Object.keys(sorts.sorts)}  ${Object.values(sorts.sorts)}`
+        }
+      }
 
-        /**
-         * 获取格式化参数
-         */
-        getSearcFormData() {
-            const params = this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {}
-            params['fileType'] = this.typeData[this.oldorgId].label
-            params['userId'] = this.$store.getters.userInfo.employee.id
-            return params
-        },
-        /**
-     * 处理按钮事件
-     */
-        handleAction(command, position, selection, data) {
-            switch (command) {
-                case 'search':// 查询
-                    this.refreshData()
-                    break
-                default:
-                    break
-            }
-        },
+      let sql = `select * FROM t_wjgl
+      WHERE wen_jian_zhuang_t = '已发放' AND yi_gai_zuo_fei_ = '否' ${wheres}`
+
+      curdPost('sql', sql).then(res => {
+        let tableDatas = res.variables.data
+        this.tableData = JSON.parse(JSON.stringify(tableDatas))
+        let filterDatas = []
+        this.bianlistData.pageResult.totalCount = tableDatas.length
+        this.bianlistData.pageResult.totalPages = Math.ceil(tableDatas.length / this.pagination.limit)
+        this.bianlistData.pageResult.limit = this.pagination.limit
+        this.bianlistData.pageResult.page = this.pagination.page
+        if (this.pagination.limit > tableDatas.length) {
+          filterDatas = JSON.parse(JSON.stringify(tableDatas))
+        } else {
+          for (let index = 0; index < 20; index++) {
+            filterDatas.push(tableDatas[index])
+          }
+        }
+        this.bianlistData.dataResult = filterDatas
+        ActionUtils.handleListData(this, this.bianlistData)
+      }).catch(res => {
+        this.loading = false
+        this.listData = []
+      })
+    },
+    /**
+    * 处理排序
+    */
+    handleSortChange(sort) {
+      ActionUtils.setSorts(this.sorts, sort)
+      this.getDatas(this.getSearcFormData())
+    },
 
+    refreshData() {
+      this.listData = []
+      this.getDatas(this.getSearcFormData())
     },
-    watch: {
-        filterText(val) {
-            this.$refs.tree.filter(val);
+
+    handleNodeClick(data) {
+      this.oldorgId = data
+      this.show = 'detail'
+      if (this.oldorgId == data.id) {
+        return
+      } else {
+        this.getDatas({
+          fileType: this.typeData[data.id].label,
+          userId: this.$store.getters.userInfo.employee.id,
+          sorts: { 'wen_jian_bian_hao': 'desc' }
+        })
+      }
+    },
+    // 处理分页事件
+    handlePaginationChange(page) {
+      ActionUtils.setPagination(this.pagination, page)
+      this.bianlistData.pageResult.limit = page.limit
+      this.bianlistData.pageResult.page = page.page
+      let filterDatas = []
+      if (this.tableData.length >= (page.limit * page.page)) {
+        for (let index = (page.limit * page.page) - page.limit; index < (page.limit * page.page); index++) {
+          filterDatas.push(this.tableData[index])
+        }
+        this.bianlistData.dataResult = JSON.parse(JSON.stringify(filterDatas))
+      } else {
+        for (let index = (page.limit * page.page) - page.limit; index < this.tableData.length; index++) {
+          filterDatas.push(this.tableData[index])
         }
+        this.bianlistData.dataResult = JSON.parse(JSON.stringify(filterDatas))
+      }
+      ActionUtils.handleListData(this, this.bianlistData)
+    },
+
+    /**
+     * 获取格式化参数
+     */
+    getSearcFormData() {
+      const params = this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {}
+      params['fileType'] = this.typeData[this.oldorgId.id].label
+      params['userId'] = this.$store.getters.userInfo.employee.id
+      params['sorts'] = this.sorts
+      return params
     },
+    /**
+ * 处理按钮事件
+ */
+    handleAction(command, position, selection, data) {
+      switch (command) {
+        case 'search':// 查询
+          this.refreshData()
+          break
+        default:
+          break
+      }
+    },
+
+  },
+  watch: {
+    filterText(val) {
+      this.$refs.tree.filter(val);
+    }
+  },
 }
 </script>
 <style lang="less" scoped>
 .box {
-    width: 230px;
+  width: 230px;
 }
 
-
 .title {
-    font-size: 14px;
-    margin: 21px 5px 5px;
-    padding: 0;
-}
-
-.treeDiv {
-    height: 800px;
-    overflow-y: auto;
+  font-size: 14px;
+  margin: 21px 5px 5px;
+  padding: 0;
 }
 
 /deep/ .el-tree-node__content {
-    display: block;
+  display: block;
 }
 </style>
   

+ 158 - 116
src/views/permissions/details/fileEchart.vue

@@ -1,159 +1,201 @@
 <template>
-    <div>
-        <div style="text-align: center">
-            <!--表头-->
-            <div class="form-header">
-                <div class="title ibps-tc">用户查阅文件授权</div>
-            </div>
-            <el-transfer style="text-align: left; display: inline-block" v-model="permissionFilesKey" filterable
-                :render-content="renderFunc" :titles="['受限文件', '可查阅文件']" :button-texts="['受限', '可查阅']" :format="{
+  <div>
+    <div style="text-align: center">
+      <!--表头-->
+      <div class="form-header">
+        <div class="title ibps-tc">用户查阅文件授权</div>
+      </div>
+      <el-transfer style="text-align: left; display: inline-block"
+                   v-model="permissionFilesKey"
+                   filterable
+                   :filter-method="filterMethod"
+                   :render-content="renderFunc"
+                   :titles="['受限文件', '可查阅文件']"
+                   :button-texts="['受限', '可查阅']"
+                   :format="{
                     noChecked: '${total}',
                     hasChecked: '${checked}/${total}'
-                }" @change="handleChange" :data="allFiles">
-            </el-transfer>
-        </div>
+                    }"
+                   @change="handleChange"
+                   :data="allFilesDatas">
+      </el-transfer>
     </div>
+  </div>
 </template>
-
-
-
-
 <script>
 import { getLmitedFile, getUserByFile, saveUserByFile } from '@/api/permission/file'
+import curdPost from '@/business/platform/form/utils/custom/joinCURD.js'
 
 export default {
-    props: {
-        id: {
-            type: [String, Number]
-        },
+  props: {
+    id: {
+      type: [String, Number]
     },
-    data() {
-        return {
-            idT: '',
-            allFilesDatas: [],// 所有受控文件,与个人无关
-            allFiles: [],
-            noPermissionFiles: [],
-            permissionFiles: [],
-            permissionFilesKey: [],
-            renderFunc(h, option) {
-                return <span>{option.label}</span>;
-            }
-        };
+  },
+  data() {
+    return {
+      idT: '',
+      allFilesDatas: [],// 所有受控文件,与个人无关
+      permissionFilesKey: [],
+      initpermissionFilesKey: [],
+      permissionFiles: [],
+      renderFunc(h, option) {
+        return <span>{option.type}-{option.label}</span>;
+      },
+      filterMethod(query, item) {
+        let name = item.type + '-' + item.label
+        return name.includes(query);
+      }
+    };
+  },
+
+  methods: {
+    handleChange(value, direction, movedKeys) {
+      let params = []
+      let deleteParams = '1'
+      for (var i of this.getArrDif(this.initpermissionFilesKey, value)) {
+        let param = {}
+        param.yong_hu_id_ = this.idT
+        param.wen_jian_id_ = i
+        params.push(param)
+        // 多条件删除有问题,通过单条件去删除
+        if (this.initpermissionFilesKey.length > value.length) {
+          console.log('this.permissionFiles', this.permissionFiles)
+
+          let idParams = this.permissionFiles.filter(fil => {
+            return fil.key == i && fil.yongHuId == this.idT
+          })
+          // 删除权限
+          let params = `{"tableName": "t_wjcysqb","paramWhere":{"id_":"${idParams[0].qxId}"}}`
+          curdPost('delete', params).then(() => { }).catch(res => {
+            this.getFormData(this.idT)
+          })
+        }
+      }
+      if (this.initpermissionFilesKey.length < value.length) {
+        // 新增权限
+        curdPost('add',
+          '{"tableName": "t_wjcysqb","paramWhere":' + JSON.stringify(params) + '}'
+        ).then(response => {
+          this.getFormData(this.idT)
+        }).catch(error => {
+        })
+      }
+      this.initpermissionFilesKey = value
+
+
+      console.log('this.permissionFiles1111', this.permissionFiles)
+      console.log('this.initpermissionFilesKey', this.initpermissionFilesKey)
     },
-
-    methods: {
-        handleChange(value, direction, movedKeys) {
-            let paramsDatas = []
-            for (let i of value) {
-                let paramsData = {}
-                let filterDatas = this.allFilesDatas.filter(item => item.wenJianId == i)
-                paramsData["yongHuId"] = this.idT
-                paramsData["wenJianId"] = filterDatas[0].wenJianId
-                paramsData["wenJianMingChe"] = filterDatas[0].wenJianMingChe
-                paramsDatas.push(paramsData)
-            }
-            saveUserByFile(paramsDatas).then(res => {
-            }).catch(res => {
-            })
-        },
-        getFormData(id) {
-            getLmitedFile(id).then(res => {
-                for (let i of res.variables.data) {
-                    this.allFilesDatas.push(i)
-                    let fileData = {}
-                    fileData["key"] = i.wenJianId
-                    fileData["label"] = i.wenJianMingChe
-                    fileData["yongHuId"] = id
-                    this.noPermissionFiles.push(fileData)
-                    this.allFiles.push(fileData)
-                }
-            }).catch(res => {
-            })
-            getUserByFile(id).then(res => {
-                for (let i of res.variables.data) {
-                    this.allFilesDatas.push(i)
-                    let filterFile = {}
-                    filterFile["key"] = i.wenJianId
-                    filterFile["label"] = i.wenJianMingChe
-                    filterFile["yongHuId"] = id
-                    this.permissionFiles.push(filterFile)
-                    this.permissionFilesKey.push(i.wenJianId)
-                    this.allFiles.push(filterFile)
-
-                }
-            }).catch(res => {
-            })
-        },
+    getArrDif(arr1, arr2) {
+      return arr1.concat(arr2).filter((v, i, arr) => {
+        return arr.indexOf(v) === arr.lastIndexOf(v)
+      })
     },
-    watch: {
-        id: {
-            immediate: true,
-            handler: function (val, oldVal) {
-                this.allFilesDatas = []
-                this.permissionFiles = []
-                this.noPermissionFiles = []
-                this.allFiles = []
-                this.permissionFilesKey = []
-                this.idT = val
-                this.getFormData(val)
-            },
+    async getFormData(id) {
+      this.allFilesDatas = []
+      this.permissionFilesKey = []
+      this.permissionFiles = []
+      this.initpermissionFilesKey = []
+      // 受限文件信息
+      let permSql = `select wj.id_,wj.wen_jian_ming_che,wj.wai_bu_wen_jian_l,qx.id_ as id_qx_ FROM t_wjcysqb qx LEFT JOIN t_wjgl wj ON qx.wen_jian_id_ = wj.id_ where qx.yong_hu_id_ = '${id}'`
+      await curdPost('sql', permSql).then(res => {
+        for (let i of res.variables.data) {
+          let permissionFile = {}
+          permissionFile["key"] = i.id_
+          permissionFile["label"] = i.wen_jian_ming_che
+          permissionFile["type"] = i.wai_bu_wen_jian_l
+          permissionFile["yongHuId"] = id
+          permissionFile["qxId"] = i.id_qx_
+          this.permissionFiles.push(permissionFile)
+          this.permissionFilesKey.push(i.id_)
+          this.initpermissionFilesKey.push(i.id_)
         }
+      }).catch(res => {
+      })
+
+      let wjSql = `select id_,wen_jian_ming_che,wai_bu_wen_jian_l FROM t_wjgl
+      WHERE wen_jian_zhuang_t = '已发放' AND yi_gai_zuo_fei_ = '否' and wai_bu_wen_jian_l IN ('参考技术文献(受限)','客户技术资料(受限)')  ORDER BY FIELD(wai_bu_wen_jian_l,'参考技术文献(受限)','客户技术资料(受限)')`
+      await curdPost('sql', wjSql).then(res => {
+        for (let i of res.variables.data) {
+          let allFile = {}
+          allFile["key"] = i.id_
+          allFile["label"] = i.wen_jian_ming_che
+          allFile["type"] = i.wai_bu_wen_jian_l
+          allFile["yongHuId"] = id
+          this.allFilesDatas.push(allFile)
+        }
+      }).catch(res => {
+      })
+    },
+  },
+  watch: {
+    id: {
+      immediate: true,
+      handler: function (val, oldVal) {
+        this.allFilesDatas = []
+        this.permissionFilesKey = []
+        this.permissionFiles = []
+        this.idT = val
+        this.getFormData(val)
+      },
     }
+  }
 };
 </script>
   
 
 <style  scoped lang="less">
 .form-header {
-    border-bottom: 1px solid #2b34410d;
-    margin-bottom: 5px;
-
-    .title {
-        font-size: 16px;
-        font-weight: bold;
-        color: #222;
-        text-align: left;
-        padding: 8px 10px 10px;
-        margin: 0;
-    }
-
-    .desc {
-        word-wrap: break-word;
-        word-break: normal;
-        text-indent: 0;
-        line-height: 1.6;
-        margin: 0 0 11px;
-        padding: 3px 30px 8px;
-    }
+  border-bottom: 1px solid #2b34410d;
+  margin-bottom: 5px;
+
+  .title {
+    font-size: 16px;
+    font-weight: bold;
+    color: #222;
+    text-align: left;
+    padding: 8px 10px 10px;
+    margin: 0;
+  }
+
+  .desc {
+    word-wrap: break-word;
+    word-break: normal;
+    text-indent: 0;
+    line-height: 1.6;
+    margin: 0 0 11px;
+    padding: 3px 30px 8px;
+  }
 }
 
 .transfer-footer {
-    margin-left: 20px;
-    padding: 6px 5px;
+  margin-left: 20px;
+  padding: 6px 5px;
 }
 
 /deep/.el-transfer {
-    width: 100%;
+  width: 100%;
 }
 
 /deep/ .el-transfer-panel {
-    width: 40%;
+  width: 40%;
 }
 
 /deep/ .el-transfer__buttons {
-    width: 10%;
-    padding: 0 10px;
+  width: 10%;
+  padding: 0 10px;
 }
 
 /deep/ .el-transfer-panel__body {
-    height: auto;
+  height: auto;
 }
 
 /deep/.el-transfer-panel__list {
-    height: 650px;
+  height: 650px;
 }
 
 /deep/ .el-button {
-    width: 100%;
+  width: 100%;
 }
 </style>