소스 검색

2021/8/2 zhangyan
1.安全文件分类增加权限和标签

zhangyan 3 년 전
부모
커밋
389681ca9a
1개의 변경된 파일394개의 추가작업 그리고 146개의 파일을 삭제
  1. 394 146
      src/views/energyOperationSupport/components/securitys/Securitys.vue

+ 394 - 146
src/views/energyOperationSupport/components/securitys/Securitys.vue

@@ -172,6 +172,7 @@
                             ></el-table-column>
                             <el-table-column
                                 sortable
+                                fixed
                                 prop="seqno"
                                 type="index"
                                 label="序号"
@@ -180,9 +181,10 @@
                             ></el-table-column>
                             <el-table-column
                                 sortable
+                                fixed
                                 prop="name"
                                 label="分类名称"
-                                width="160px"
+                                width="120px"
                                 :show-overflow-tooltip="true"
                             > <template slot-scope="scope">
                                     <el-form-item
@@ -207,65 +209,108 @@
                                     <span v-else>{{scope.row.name}}</span>
                                 </template>
                             </el-table-column>
-                            <el-table-column
-                                sortable
-                                prop="parentid"
-                                label="上层节点"
-                                width="160px"
-                                :show-overflow-tooltip="true"
-                            ><template slot-scope="scope">
-                                <span>{{ nameObj.parentid.obj[scope.row.parentid] ? nameObj.parentid.obj[scope.row.parentid].name : scope.row.parentid }}</span>
-                            </template></el-table-column>
-                            <el-table-column
-                                sortable
-                                prop="node"
-                                label="级别"
-                                width="50px"
-                                :show-overflow-tooltip="true"
-                            ></el-table-column>
                             <el-table-column
                                 sortable
                                 prop="type"
                                 label="信息类别"
-                                width="160px"
+                                width="320px"
                                 :show-overflow-tooltip="true"
                             > <template slot-scope="scope">
                                     <el-form-item
                                         v-if="scope.row.isSelection"
-                                        :prop="scope.row.id + '.ename'"
-                                        :rules="dialog.editorBox.form.rules.type"
+                                        :prop="scope.row.id + '.type'"
                                     >
+                                        <el-tag
+                                          effect="dark"
+                                          v-for="(tag,key) in tableFormDataObj[scope.row.id].type"
+                                          :key="key"
+                                          closable
+                                          size="small"
+                                          :disable-transitions="true"
+                                          @close="rowhandleClose(tag, scope.row)">
+                                          {{tag}}
+                                        </el-tag>
                                         <el-input
-                                            clearable
-                                            style="width: 100%;"
-                                            v-model="tableFormDataObj[scope.row.id].type"
-                                        ></el-input>
+                                          class="input-new-tag"
+                                          v-if="tableFormDataObj[scope.row.id].showInput"
+                                          v-model="tableFormDataObj[scope.row.id].inputValue"
+                                          ref="saveTagInput"
+                                          size="small"
+                                          @keyup.enter.native="rowhandleInputConfirm(scope.row)"
+                                          @blur="rowhandleInputConfirm(scope.row)"
+                                        >
+                                        </el-input>
+                                        <el-button
+                                        v-else
+                                        class="button-new-tag"
+                                        size="small"
+                                        @click="rowshowInput(scope.row)"
+                                        >+标签</el-button>
                                     </el-form-item>
-                                    <span v-else>{{scope.row.type}}</span>
+                                    <template v-else>
+                                      <el-tag
+                                        effect="dark"
+                                        :disable-transitions="true"
+                                        v-for="(tag,key) in scope.row.type"
+                                        :key="key"
+                                        size="small">
+                                        {{ tag }}
+                                      </el-tag></template>
                                 </template>
                             </el-table-column>
                             <el-table-column
                                 sortable
                                 prop="info"
-                                label="安全信息"
-                                width="160px"
+                                label="安全级别"
+                                width="280px"
                                 :show-overflow-tooltip="true"
                             > <template slot-scope="scope">
                                     <el-form-item
                                         v-if="scope.row.isSelection"
-                                        :prop="scope.row.id + '.qname'"
-                                        :rules="dialog.editorBox.form.rules.info"
+                                        :prop="scope.row.id + '.info'"
                                     >
-                                        <el-input
-                                            clearable
-                                            style="width: 100%;"
-                                            v-model="tableFormDataObj[scope.row.id].info"
-                                        ></el-input>
+                                        <el-select
+                                        v-model="tableFormDataObj[scope.row.id].info"
+                                        filterable
+                                        multiple
+                                        collapse-tags
+                                        @change="select_status"
+                                        placeholder="请选择可访问角色,默认公开"
+                                        size="small"><el-option
+                                            v-for="item in nameObj.roleList.arr"
+                                            :key="item.roleId"
+                                            :label="item.roleName"
+                                            :value="item.roleId">
+                                            </el-option>
+                                        </el-select>
                                     </el-form-item>
-                                    <span v-else>{{scope.row.info}}</span>
+                                    <template v-else>
+                                      <el-tag
+                                        effect="plain"
+                                        :disable-transitions="true"
+                                        v-for="(tag,key) in scope.row.info"
+                                        :key="key"
+                                        size="small">
+                                        {{ nameObj.roleList.obj[tag] ? nameObj.roleList.obj[tag].name : tag }}
+                                      </el-tag></template>
                                 </template>
                             </el-table-column>
                             <el-table-column
+                                sortable
+                                prop="parentid"
+                                label="上层节点"
+                                width="120px"
+                            ><template slot-scope="scope">
+                                <span>{{ nameObj.parentid.obj[scope.row.parentid] ? nameObj.parentid.obj[scope.row.parentid].name : scope.row.parentid }}</span>
+                            </template></el-table-column>
+                            <el-table-column
+                                sortable
+                                prop="node"
+                                label="级别"
+                                width="50px"
+                                :show-overflow-tooltip="true"
+                            ></el-table-column>
+                            <!-- <el-table-column
                                 sortable
                                 prop="seqno"
                                 label="顺序号"
@@ -293,12 +338,12 @@
                                     </el-form-item>
                                     <span v-else>{{scope.row.seqno}}</span>
                                 </template>
-                            </el-table-column>
+                            </el-table-column> -->
                             <el-table-column
                                 sortable
                                 prop="url"
                                 label="分类路径"
-                                width="360px"
+                                width="320px"
                                 :show-overflow-tooltip="true"
                             ></el-table-column>
                             <el-table-column
@@ -384,7 +429,7 @@
                     label-width="120px"
                 >
                     <el-row>
-                        <el-col :span="12">
+                        <el-col :span="14">
                             <el-form-item
                                 label="分类名称"
                                 prop="name"
@@ -396,35 +441,7 @@
                                 ></el-input>
                             </el-form-item>
                         </el-col>
-                        <el-col :span="12">
-                            <el-form-item
-                                label="安全类别"
-                                prop="type"
-                            >
-                                <el-input
-                                    clearable
-                                    style="width: 100%;"
-                                    v-model="dialog.editorBox.form.data.type"
-                                    :disabled="dialog.editorBox.type !== 'add'"
-                                ></el-input>
-                            </el-form-item>
-                        </el-col>
-                    </el-row>
-                                        <el-row>
-                    <el-col :span="12">
-                        <el-form-item
-                            label="安全信息"
-                            prop="info"
-                        >
-                            <el-input
-                                clearable
-                                style="width: 100%;"
-                                v-model="dialog.editorBox.form.data.info"
-                                :disabled="dialog.editorBox.type !== 'add'"
-                            ></el-input>
-                        </el-form-item>
-                    </el-col>
-                        <el-col :span="12">
+                        <el-col :span="10">
                             <el-form-item
                                 label="上层节点"
                                 prop="parentid"
@@ -445,9 +462,30 @@
                                 </el-select>
                             </el-form-item>
                         </el-col>
-                        </el-row>
-                        <el-row>
-                        <el-col :span="12">
+                    </el-row>
+                    <el-row>
+                        <el-col :span="14">
+                        <el-form-item
+                            label="安全级别"
+                            prop="info"
+                        >
+                            <el-select
+                            v-model="dialog.editorBox.form.data.info"
+                            filterable
+                            multiple
+                            collapse-tags
+                            @change="select_status"
+                            placeholder="请选择可访问角色,默认公开"
+                            size="small"><el-option
+                                v-for="item in nameObj.roleList.arr"
+                                :key="item.roleId"
+                                :label="item.roleName"
+                                :value="item.roleId">
+                                </el-option>
+                            </el-select>
+                        </el-form-item>
+                        </el-col>
+                        <el-col :span="10">
                             <el-form-item
                                 label="级别"
                                 prop="node"
@@ -461,6 +499,41 @@
                             </el-form-item>
                         </el-col>
                     </el-row>
+                    <el-row>
+                        <el-col :span="24">
+                            <el-form-item
+                                label="安全类别"
+                                prop="type"
+                            >
+                                <el-tag
+                                  :key="tag"
+                                  effect="dark"
+                                  v-for="tag in dynamicTags"
+                                  closable
+                                  size="small"
+                                  :disable-transitions="true"
+                                  @close="handleClose(tag)">
+                                  {{tag}}
+                                </el-tag>
+                                <el-input
+                                  class="input-new-tag"
+                                  v-if="inputVisible"
+                                  v-model="inputValue"
+                                  ref="saveTagInput"
+                                  size="small"
+                                  @keyup.enter.native="handleInputConfirm"
+                                  @blur="handleInputConfirm"
+                                >
+                                </el-input>
+                                <el-button
+                                v-else
+                                class="button-new-tag"
+                                size="small"
+                                @click="showInput"
+                                >+标签</el-button>
+                                </el-form-item>
+                            </el-col>
+                    </el-row>
                 </el-form>
             </div>
             <span
@@ -483,6 +556,7 @@
 
 <script>
 import { zCheckNumber1 } from '@/utils/validator.js';
+import store from '@/store/index.js';
 export default {
     name: 'processInformation',
     data () {
@@ -550,7 +624,11 @@ export default {
                 seqno: {
                     obj: {},
                     arr: []
-                }
+                },
+                roleList: {
+                    obj: {},
+                    arr: []
+                } // 角色信息
             },
             loading: false,
             tableLoading: false,
@@ -569,7 +647,7 @@ export default {
                             parentid: '',
                             node: '',
                             type: '',
-                            info: '',
+                            info: [],
                             seqno: ''
                         },
                         rules: {
@@ -598,7 +676,14 @@ export default {
                         }
                     }
                 }
-            }
+            },
+            dynamicTags: [],
+            inputVisible: false,
+            inputValue: '',
+            store,
+            userInfo: {}, // 用户信息
+            qrRole: [],
+            userRoles: []
         }
     },
     created () {
@@ -623,9 +708,10 @@ export default {
                 that.singleTableHeight = that.getRoleHeight(that.$refs['singleTable'].$el) - 45;
             }, 1);
         });
+        that.getRoles();
         that.getNodeData();
-        that.getNodeTreeData();
-        that.getTableData();
+        // that.getNodeTreeData();
+        // that.getTableData();
     },
     methods: {
         //  计算树区域高度
@@ -660,8 +746,8 @@ export default {
         },
         // 获取安全类别节点树
         getNodeTreeData () {
-            let that = this
-            let url = 'pass/ems/v1/securitytypes/gettree/';
+            let that = this;
+            let url = 'pass/ems/v1/securitytypes/gettree/?securityInfo=' + that.qrRole;
             that.listTopicTree.loading = true;
             that.axios.get(url)
                 .then(function (res) {
@@ -675,6 +761,8 @@ export default {
                         that.$message.error(res.message);
                     }
                     that.listTopicTree.loading = false;
+                }).catch(function () {
+                    that.listTopicTree.loading = false;
                 });
         },
         // 获取表格中的数据
@@ -687,31 +775,55 @@ export default {
             that.pageNum = pageNum || that.pageNum;
             that.tableLoading = true;
             that.dialog.editorBox.form.default.parentid = that.filterForm.data.parentid;
-            let url = 'pass/ems/v1/securitytypes/like/?pageNum=' + that.pageNum + '&pageSize=' + that.pageSize;
+            let url = 'pass/ems/v1/securitytypes/like/?pageNum=' + that.pageNum + '&pageSize=' + that.pageSize + '&Info=' + that.qrRole;
             that.axios.get(url, {
                 params: params
             })
                 .then(function (res) {
                     if (res.code === '0') {
                         let arr = [];
+                        let tagData = [];
+                        let infoArr = [];
+                        let map = {};
+                        let total = 0;
+                        for (var key of that.qrRole) {
+                            map[key] = true;
+                        }
+                        // let map = that.qrRole.reduce(i => (r[i] = true));
                         for (let item of res.data.list) {
-                            arr.push({
-                                id: item.id,
-                                name: item.securityName,
-                                parentid: item.securityParentid,
-                                node: item.securityNode,
-                                type: item.securityType,
-                                info: item.securityInfo,
-                                url: item.securityUploadUrl,
-                                seqno: item.seqno,
-                                createman: item.createMan,
-                                createtime: item.createTime,
-                                updateman: item.updateMan,
-                                updatetime: item.updateTime
-                            })
+                            tagData = [];
+                            infoArr = [];
+                            let result = true;
+                            if (item.securityType !== null) {
+                                tagData = item.securityType.split(';');
+                            }
+                            if (item.securityInfo !== null) {
+                            infoArr = item.securityInfo.split(',');
+                            result = infoArr.some(i => map[i]);
+                            }
+                            if (result) {
+                                arr.push({
+                                    id: item.id,
+                                    name: item.securityName,
+                                    parentid: item.securityParentid,
+                                    node: item.securityNode,
+                                    type: tagData,
+                                    info: infoArr,
+                                    url: item.securityUploadUrl,
+                                    seqno: item.seqno,
+                                    createman: item.createMan,
+                                    createtime: item.createTime,
+                                    updateman: item.updateMan,
+                                    updatetime: item.updateTime,
+                                    showInput: false,
+                                    inputValue: ''
+                                })
+                            } else {
+                                total++;
+                            }
                         }
                         that.tableData = arr;
-                        that.total = res.data.total;
+                        that.total = res.data.total - total;
                     } else {
                         that.$message.error(res.message);
                     }
@@ -754,7 +866,7 @@ export default {
                 }
                 item.isSelection = true;
             }
-            that.tableFormDataObj = tableFormDataObj;
+            that.tableFormDataObj = JSON.parse(JSON.stringify(tableFormDataObj));
             that.multipleSelection = val;
         },
         // 批量修改
@@ -765,11 +877,27 @@ export default {
                     if (valid) {
                         let SubmitData = [];
                         for (let key in that.tableFormDataObj) {
+                            let types = '';
+                            for (let item in that.tableFormDataObj[key].type) {
+                                if (Number(item) === that.tableFormDataObj[key].type.length - 1) {
+                                    types += that.tableFormDataObj[key].type[item];
+                                } else {
+                                    types += that.tableFormDataObj[key].type[item] + ';';
+                                }
+                            }
+                                let infos = '';
+                                for (let item in that.tableFormDataObj[key].info) {
+                                    if (Number(item) === that.tableFormDataObj[key].info.length - 1) {
+                                        infos += that.tableFormDataObj[key].info[item];
+                                    } else {
+                                        infos += that.tableFormDataObj[key].info[item] + ',';
+                                    }
+                                };
                             SubmitData.push({
                                 id: that.tableFormDataObj[key].id,
-                                securityType: that.tableFormDataObj[key].type,
+                                securityType: types,
                                 securityName: that.tableFormDataObj[key].name,
-                                securityInfo: that.tableFormDataObj[key].info,
+                                securityInfo: infos,
                                 securityParentid: that.tableFormDataObj[key].parentid,
                                 securityNode: that.tableFormDataObj[key].node,
                                 seqno: that.tableFormDataObj[key].seqno
@@ -863,13 +991,14 @@ export default {
                 }
             that.dialog.editorBox.form.data.id = that.nameObj.id.obj[that.dialog.editorBox.form.data.id];
             console.log('这里有什么用');
-            that.dialog.editorBox.form.data.name = that.nameObj.id.obj[that.dialog.editorBox.form.data.name];
+            // that.dialog.editorBox.form.data.name = that.nameObj.id.obj[that.dialog.editorBox.form.data.name];
+            that.dialog.editorBox.form.data.name = '';
             that.dialog.editorBox.form.data.seqno = 0;
             }
             that.dialog.editorBox.form.data.parentid = that.dialog.editorBox.form.default.parentid;
             that.dialog.editorBox.form.data.node = +(that.nameObj.parentid.obj[that.dialog.editorBox.form.default.parentid] ? that.nameObj.parentid.obj[that.dialog.editorBox.form.default.parentid].node : '0') + 1 + '';
-            that.dialog.editorBox.form.data.ename = '';
-            that.dialog.editorBox.form.data.qname = '';
+            that.dialog.editorBox.form.data.type = '';
+            that.dialog.editorBox.form.data.info = [];
             that.dialog.editorBox.form.data.isreal = '0';
             that.dialog.editorBox.form.data.isplan = '0';
             that.dialog.editorBox.form.data.isbalance = '0';
@@ -887,6 +1016,13 @@ export default {
         },
         dataSave () {
             let that = this;
+            for (let key in that.dynamicTags) {
+                if (Number(key) === that.dynamicTags.length - 1) {
+                    that.dialog.editorBox.form.data.type += that.dynamicTags[key];
+                } else {
+                    that.dialog.editorBox.form.data.type += that.dynamicTags[key] + ';';
+                }
+            }
             let SubmitData = {
                 securityType: that.dialog.editorBox.form.data.type,
                 securityName: that.dialog.editorBox.form.data.name,
@@ -953,6 +1089,102 @@ export default {
             let that = this;
             that.filterForm.data.parentid = data.id;
             that.getTableData(1);
+        },
+        // 标签删除
+        handleClose (tag) {
+          let that = this;
+          this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);
+        },
+        // 标签新增
+        showInput () {
+          let that = this;
+          that.inputVisible = true;
+          that.$nextTick(_ => {
+            this.$refs.saveTagInput.$refs.input.focus();
+          });
+        },
+        // 标签新增
+        handleInputConfirm () {
+          let that = this;
+          let inputValue = this.inputValue;
+          if (inputValue) {
+            this.dynamicTags.push(inputValue);
+          }
+          this.inputVisible = false;
+          this.inputValue = '';
+        },
+        // 行内标签删除
+        rowhandleClose (tag, row) {
+          let that = this;
+          that.tableFormDataObj[row.id].type.splice(that.tableFormDataObj[row.id].type.indexOf(tag), 1);
+        },
+        // 行内标签新增
+        rowhandleInputConfirm (row) {
+          let that = this;
+          let inputValue = that.tableFormDataObj[row.id].inputValue;
+          if (inputValue) {
+            that.tableFormDataObj[row.id].type.push(inputValue);
+          }
+          that.tableFormDataObj[row.id].showInput = false;
+          that.tableFormDataObj[row.id].inputValue = '';
+        },
+        // 行内input获取焦点
+        rowshowInput (row) {
+          let that = this;
+          that.tableFormDataObj[row.id].showInput = true;
+          // setTimeout(function(){
+          //    that.$nextTick(_ => {
+          //      this.$refs.saveTagInput.$refs.input.focus();
+          //    });
+          // },500)
+        },
+        // console.log(this.$store.state.userInfo.userId);
+        getRoles () {
+            let that = this;
+            // 获取用户信息
+            this.store.dispatch('getUserInfo').then((res) => {
+                this.userInfo = res.data;
+                that.axios.get('pass/v1/sysuserroles/?userId=' + res.data.userId + '&pageNum=1&pageSize=100').then(rest => {
+                  if (rest) {
+                    for (let i = 0; i < rest.data.list.length; i++) {
+                      that.qrRole.push(rest.data.list[i].roleId)
+                    }
+                    that.userRoles = rest.data.list; // 获取用户角色关联信息
+                  }
+                  that.getNodeTreeData();
+                  that.getTableData();
+                })
+            });
+            // 获取角色信息
+            this.store.dispatch('system/rolesManage/list').then(res => {
+              if (res.code === '0') {
+                this.nameObj.roleList.arr = res.data;
+                for (let obj of res.data) {
+                    this.nameObj.roleList.obj[obj.id] = {
+                        name: obj.roleName,
+                        id: obj.id
+                    };
+                }
+                } else {
+              this.$message.error(res.message);
+            }
+            });
+        },
+        // 获取当前用户角色
+        getUserRole (userid) {
+          let that = this;
+          that.axios.get('pass/v1/sysuserroles/?userId=' + userid + '&pageNum=1&pageSize=100').then(res => {
+            if (res) {
+              for (let i = 0; i < res.data.list.length; i++) {
+                that.qrRole.push(res.data.list[i].roleId)
+              }
+              that.userRoles = res.data.list; // 获取用户角色关联信息
+            }
+          })
+        },
+        // 手动刷新下拉框数据
+        select_status (val) {
+            this.$forceUpdate();
         }
         // but_edit (row) {
         //     let that = this;
@@ -1012,62 +1244,62 @@ export default {
     .box {
         height: 100%;
         padding: 15px 15px 0 15px;
-        .box-left {
-            float: left;
-            width: 200px;
-            height: calc(100% - 3px);
-            overflow: auto;
-            .box-left-bt {
-                line-height: 35px;
-                font-size: 16px;
-                border-bottom: 1px solid #ccc;
-            }
-            .box-left-tree {
-                height: calc(100% - 50px);
-                overflow: auto;
-                padding: 7px 7px 0 0;
-                .tree-row-on {
-                    color: #3279e8;
-                    font-weight: 600;
-                }
+    .box-left {
+        float: left;
+        width: 200px;
+        height: calc(100% - 3px);
+        overflow: auto;
+        .box-left-bt {
+        line-height: 35px;
+        font-size: 16px;
+        border-bottom: 1px solid #ccc;
+        }
+        .box-left-tree {
+        height: calc(100% - 50px);
+        overflow: auto;
+        padding: 7px 7px 0 0;
+            .tree-row-on {
+                color: #3279e8;
+                font-weight: 600;
             }
         }
-        .box-right {
-            border-left: 1px solid #ccc;
-            margin-left: 200px;
-            .box-top {
-                .box-top-form {
-                    padding-left: 7px;
-                    .el-form-item {
-                        margin-bottom: 7px;
-                    }
-                }
-                .box-top-gjl {
-                    overflow: hidden;
-                    // margin-top: -7px;
-                    padding: 7px 0 7px 7px;
-                    border-top: 1px solid #ccc;
-                    // border-bottom: 1px solid #ccc;
-                    // margin-bottom: 6px;
+    }
+    .box-right {
+        border-left: 1px solid #ccc;
+        margin-left: 200px;
+        .box-top {
+            .box-top-form {
+                padding-left: 7px;
+                .el-form-item {
+                    margin-bottom: 7px;
                 }
             }
-            .box-bottom {
-                padding-left: 7px;
+            .box-top-gjl {
+                overflow: hidden;
+                // margin-top: -7px;
+                padding: 7px 0 7px 7px;
+                border-top: 1px solid #ccc;
+                // border-bottom: 1px solid #ccc;
+                // margin-bottom: 6px;
             }
         }
-        .el-table .el-table__row {
-            height: 35px;
+        .box-bottom {
+            padding-left: 7px;
         }
-        .el-table__body .el-form-item--mini.el-form-item {
-            margin: 0px;
-            .error {
-                overflow: hidden;
-                color: #f56c6c;
-                font-size: 12px;
-                line-height: 1;
-            }
+    }
+    .el-table .el-table__row {
+        height: 35px;
+    }
+    .el-table__body .el-form-item--mini.el-form-item {
+        margin: 0px;
+        .error {
+            overflow: hidden;
+            color: #f56c6c;
+            font-size: 12px;
+            line-height: 1;
         }
     }
+    }
     .color_no {
         color: #7a7a7a;
     }
@@ -1075,4 +1307,20 @@ export default {
         color: #1a9f17;
     }
 }
+    .el-tag + .el-tag {
+    margin-left: 5px;
+    margin-top: 5px;
+    }
+    .button-new-tag {
+    margin-left: 5px;
+    height: 26px;
+    line-height: 26px;
+    padding-top: 0;
+    padding-bottom: 0;
+    }
+    .input-new-tag {
+    width: 90px;
+    margin-left: 10px;
+    vertical-align: bottom;
+    }
 </style>