Authored by 王涛

Merge branch 'master-v32-lushangqing' into 'master'

【#1162】 变更负责人相关业务-表格树结构更改,资源类型权限页面 #5



See merge request !624
@@ -158,4 +158,11 @@ custom-class="config-dialog" @@ -158,4 +158,11 @@ custom-class="config-dialog"
158 box-shadow: 0 0 20px red, inset 0 0 10px red, 0 0px 5px red; 158 box-shadow: 0 0 20px red, inset 0 0 10px red, 0 0px 5px red;
159 } 159 }
160 } 160 }
  161 +.tree-table .el-table td.el-table__cell div{
  162 + display: flex;
  163 + align-items: center;
  164 +}
  165 +.tree-table .el-table .el-table__cell.is-center div{
  166 + justify-content: center;
  167 +}
161 168
1 <div > 1 <div >
2 <!-- 表格--> 2 <!-- 表格-->
3 <el-table :border="showBorder" v-loading="loading" :size="size" ref="multipleTable" @selection-change="handleSelectionChange" :data="dataList" stripe header-row-class-name="tbl-header-class" :height="height" 3 <el-table :border="showBorder" v-loading="loading" :size="size" ref="multipleTable" @selection-change="handleSelectionChange" :data="dataList" stripe header-row-class-name="tbl-header-class" :height="height"
4 - style="width: 100%;margin: 0px 0px; font-size:13.5px;" :row-key="getRowKeys" :expand-row-keys="expands"> 4 + style="width: 100%;margin: 0px 0px; font-size:13.5px;" :row-key="getRowKeys" :expand-row-keys="expands" :default-expand-all="defaultExpand">
5 5
6 <el-table-column type="expand" v-if="showExpand"> 6 <el-table-column type="expand" v-if="showExpand">
7 <template #default="scope"> 7 <template #default="scope">
@@ -98,10 +98,15 @@ export default { @@ -98,10 +98,15 @@ export default {
98 type: String, 98 type: String,
99 default: 'id' 99 default: 'id'
100 }, 100 },
101 - //是否默认展开所有 101 + //默认展开哪
102 expands:{ 102 expands:{
103 type: Array, 103 type: Array,
104 default: [] 104 default: []
  105 + },
  106 + //是否默认展开所有行
  107 + defaultExpand:{
  108 + type:Boolean,
  109 + default:false
105 } 110 }
106 }, 111 },
107 data() { 112 data() {
  1 +<el-row>
  2 + <el-col :span="24" class="search">
  3 + <div class="condition" >
  4 + <el-form ref=“form” style="display: flex;">
  5 + <el-form-item style="margin-right: 6px;margin-bottom: 10px;">
  6 + <el-input v-model="search.keyword" placeholder="请输入关键字"></el-input>
  7 + </el-form-item>
  8 + <el-form-item style="margin-right: 6px;margin-bottom: 10px;">
  9 + <el-select filterable clearable v-model="search.resType" placeholder="请选择资源类型">
  10 + <el-option
  11 + v-for="item in resTypeOptions"
  12 + :key="item.resTypeCode"
  13 + :label="item.resTypeName"
  14 + :value="item.resTypeCode">
  15 + </el-option>
  16 + </el-select>
  17 + </el-form-item>
  18 + <el-form-item style="margin-right: 6px;margin-bottom: 10px;">
  19 + <el-button @click="getListData" type="primary">查询</el-button>
  20 + </el-form-item>
  21 + </el-form>
  22 + </div>
  23 + </el-col>
  24 +</el-row>
  25 +<el-row style="margin-bottom: 10px;">
  26 + <div class="flex-div-start">
  27 + <el-button type="primary" @click="changeCancel()" size="small">取消</el-button>
  28 + <el-button type="primary" @click="changeAdmin()" size="small" style="margin-left: 6px">变更</el-button>
  29 + </div>
  30 +</el-row>
  31 +<el-row class="margin-bottom-50" style="margin-top: 3px">
  32 + <el-col :span="24" class="table-height tree-table">
  33 + <cm-table-page :columns="columns"
  34 + :dataList="resourceData"
  35 + :total="count"
  36 + :layout="'total, prev,pager,next,sizes, jumper'"
  37 + :pageSize="pageSize"
  38 + @loaddata="loadTableDataList"
  39 + @selectionChange="selectionChange"
  40 + :showIndex="true"
  41 + :showSelection="true"
  42 + :showBorder="true"
  43 + :loading="loading"
  44 + :showPage="true"
  45 + :showTools="false"
  46 + :getRowKeys="'resTypeId'"
  47 + :defaultExpand="true"
  48 + :height="(height - 200)">
  49 + <template #default="{row,prop,column}">
  50 + <div v-if="prop == 'paramDesc'">
  51 + <el-select v-if="row.resType == 'HOST_X86SERVER'" v-model="row.showType" placeholder="">
  52 + <el-option
  53 + v-for="item in showTypeList"
  54 + :key="item.value"
  55 + :label="item.name"
  56 + :value="item.value"
  57 + >
  58 + </el-option>
  59 + </el-select>
  60 + </div>
  61 + </template>
  62 + </cm-table-page>
  63 + </el-col>
  64 +</el-row>
  65 +
  66 +<ChangeUsersList :show="show" :isTwoGroup="isTwoGroup" :isMulti="isMulti" @hideDialog="hideDialog" @savebtn="savebtn"></ChangeUsersList>
@@ -12,11 +12,325 @@ export default { @@ -12,11 +12,325 @@ export default {
12 }, 12 },
13 setup: function (props, {attrs, slots, emit}) { 13 setup: function (props, {attrs, slots, emit}) {
14 const {proxy} = Vue.getCurrentInstance(); 14 const {proxy} = Vue.getCurrentInstance();
  15 + //变更人员弹框
  16 + let show=Vue.ref(false);
  17 + //变更人员列表是否多选
  18 + let isMulti=Vue.ref(false);
  19 + //变更人员列表是否是两组
  20 + let isTwoGroup=Vue.ref(false);
  21 + //配置列表总数
  22 + let count = Vue.ref(0);
  23 + //列表高度
  24 + let height = Vue.ref(window.innerHeight);
  25 + //列表分页
  26 + let limit = Vue.ref(400);
  27 + //加载
  28 + let loading = Vue.ref(true);
  29 + //选中数据
  30 + let pitch = Vue.ref([]);
  31 + //展示类型
  32 + let showTypeList=Vue.ref([]);
  33 + //采集类型
  34 + let ddicCollType = Vue.ref([]);
15 35
  36 + let search = Vue.ref({
  37 + resType: '',
  38 + keyword: '',
  39 + page: 1,
  40 + limit: 20,
  41 + });
  42 + let resTypeOptions=Vue.ref([])
  43 + const columns = [
  44 + {
  45 + prop: 'resTypeName',
  46 + label: '资源类型名称',
  47 + sortable: true,
  48 + align: 'center',
  49 + },
  50 + {
  51 + prop: 'resTypeCode',
  52 + label: '编码',
  53 + sortable: true,
  54 + align: 'center',
  55 + },
  56 + {
  57 + prop: 'resTypeDesc',
  58 + label: '类别',
  59 + sortable: true,
  60 + align: 'center',
  61 + },
  62 + {
  63 + prop: 'collType',
  64 + label: '采集类型',
  65 + sortable: true,
  66 + align: 'center',
  67 + render: function (row) {
  68 + let collType='';
  69 + ddicCollType.value.map(item=>{
  70 + if(row.collType==item.value){
  71 + collType=item.name
  72 + }
  73 + })
  74 + return collType;
  75 + }
  76 + },
  77 + {
  78 + prop: 'forbidden',
  79 + label: '是否启用',
  80 + sortable: true,
  81 + align: 'center',
  82 + render: function (row) {
  83 + let str='';
  84 + if(row.forbidden==0){
  85 + str='启用';
  86 + }else{
  87 + str='禁用';
  88 + }
  89 + return str;
  90 + }
  91 + },
  92 + {
  93 + prop: 'showType',
  94 + label: '展示类型',
  95 + sortable: true,
  96 + align: 'center',
  97 + /* render: function (row) {
  98 +
  99 + }*/
  100 + },
  101 + {
  102 + prop: 'createTime',
  103 + label: '创建时间',
  104 + align: 'center'
  105 + },
  106 +
  107 + ];
  108 +
  109 + //列表数据
  110 + let resourceData = Vue.ref([]);
  111 + //获取列表数据
  112 + const getListData = () => {
  113 + let username=proxy.$route.query.username;
  114 + let resTypeName=proxy.$route.query.resTypeName;
  115 + //定义列表参数
  116 + let getParams = {
  117 + resType:search.value.resType,
  118 + keyword:search.value.keyword,
  119 + resTypeName: resTypeName,
  120 + userAccount: username,
  121 + // page: search.value.page,
  122 + // limit: search.value.limit
  123 + };
  124 + proxy.$http.get("/api-web/manage/restype/listAll", getParams, function (res) {
  125 + if (res && res.data) {
  126 + resourceData.value = handleTree(res.data, 'resTypeCode', 'parentId')
  127 +
  128 + console.log("(()",resourceData.value)
  129 + count.value = res.count;
  130 + loading.value = false;
  131 + }else{
  132 + resourceData.value=[];
  133 + }
  134 + })
  135 + }
  136 + //组装树结构
  137 + let handleTree=(data, id, parentId, children)=> {
  138 + let config = {
  139 + id: id || 'id',
  140 + parentId: parentId || 'parentId',
  141 + childrenList: children || 'children'
  142 + };
  143 +
  144 + var childrenListMap = {};
  145 + var nodeIds = {};
  146 + var tree = [];
  147 +
  148 + for (let d of data) {
  149 + let parentId = d[config.parentId];
  150 + if (childrenListMap[parentId] == null) {
  151 + childrenListMap[parentId] = [];
  152 + }
  153 + nodeIds[d[config.id]] = d;
  154 + childrenListMap[parentId].push(d);
  155 + }
  156 +
  157 + for (let d of data) {
  158 + let parentId = d[config.parentId];
  159 + if (nodeIds[parentId] == null) {
  160 + tree.push(d);
  161 + }
  162 + }
  163 +
  164 + for (let t of tree) {
  165 + adaptToChildrenList(t);
  166 + }
  167 +
  168 + function adaptToChildrenList(o) {
  169 + if (childrenListMap[o[config.id]] !== null) {
  170 + o[config.childrenList] = childrenListMap[o[config.id]];
  171 + }
  172 + if (o[config.childrenList]) {
  173 + for (let c of o[config.childrenList]) {
  174 + adaptToChildrenList(c);
  175 + }
  176 + }
  177 + }
  178 + return tree;
  179 + }
  180 + //重新加载表格数据
  181 + let loadTableDataList = ({page, limit}) => {
  182 + search.value.page=page;
  183 + search.value.limit=limit;
  184 + getListData();
  185 + }
  186 + let resIds=Vue.ref('');//选中的ids
  187 + //表格全选事件
  188 + let selectionChange = (val) => {
  189 + pitch.value = val;
  190 + let arr=[];
  191 + pitch.value.map(item=>{
  192 + arr.push(item.resId)
  193 + })
  194 + resIds.value=arr.join(",");//选中的值
  195 + proxy.resourceData.map((v, i) => {
  196 + v.checked = false;
  197 + });
  198 + let selectData = val;
  199 + if (selectData.length > 0) {
  200 + selectData.map((item, index) => {
  201 + proxy.resourceData.map((v, i) => {
  202 + if (item.id == v.id) {
  203 + v.checked = true;
  204 + }
  205 + })
  206 + })
  207 + } else {
  208 + proxy.resourceData.map((v, i) => {
  209 + v.checked = false;
  210 + })
  211 + }
  212 + }
  213 + //获取资源类型数据
  214 + let getResourceTypoe=()=>{
  215 + proxy.$http.get(`/api-web/manage/restype/list`, {}, function (res) {
  216 + if (res && res.data) {
  217 + resTypeOptions.value=res.data
  218 + }
  219 + })
  220 + }
  221 + //获取展示类型的字典数据
  222 + let initShowType=()=>{
  223 + proxy.$http.post("/api-web/manage/ddic/findSucDdics/DETAILS_POWER", {}, function (res) {
  224 + if (res && res.data) {
  225 + let arr=res.data;
  226 + if(arr && arr.length>0){
  227 + arr.map(v=>{
  228 + showTypeList.value.push({
  229 + name: v.ddicName
  230 + ,value: v.ddicCode.substring(v.ddicCode.lastIndexOf("_")+1,v.ddicCode.length)
  231 + });
  232 + })
  233 + }
  234 +
  235 + }
  236 + })
  237 + }
  238 + //获取采集类型的字典数据
  239 + let initCollType=()=>{
  240 + proxy.$http.post("/api-web/manage/ddic/findSucDdics/collType", {}, function (res) {
  241 + if (res && res.data) {
  242 + let arr=res.data;
  243 + if(arr && arr.length>0){
  244 + arr.map(v=>{
  245 + ddicCollType.value.push({
  246 + name: v.ddicName
  247 + ,value: v.ddicCode
  248 + });
  249 + })
  250 + }
  251 +
  252 + }
  253 + })
  254 + }
  255 + //批量取消负责的相关资源
  256 + let changeCancel = () => {
  257 + if(pitch.value.length<1){
  258 + proxy.$global.showMsg('请至少选择一项','warning');
  259 + }else{
  260 + proxy.$global.confirm("确定取消负责的相关资源?", function () {
  261 + proxy.$global.showMsg('取消成功!');
  262 + // proxy.$http.get(`/api-web/`, {resIds:resIds.value}, function (res) {
  263 + // if (res && res.data) {
  264 + // proxy.$global.showMsg('取消成功!');
  265 + // getListData()
  266 + // }
  267 + // })
  268 + });
  269 + }
  270 + }
  271 + //变更负责人
  272 + let changeAdmin = () => {
  273 + if(pitch.value.length<1){
  274 + proxy.$global.showMsg('请至少选择一项','warning');
  275 +
  276 + }else{
  277 + show.value=true;
  278 + }
  279 +
  280 + }
  281 + //变更人员的弹框关闭后
  282 + let hideDialog =(flag)=>{
  283 + show.value=flag;
  284 + // getListData();
  285 + }
  286 + //变更人员的弹框保存后
  287 + let savebtn =(obj)=>{
  288 + show.value=false;
  289 + //obj.selectModel 选中的用户组(一个/主负责人) obj.selectModelSecond 辅负责人,都是数组
  290 + let params={
  291 + resIds:resIds.value,
  292 + selectModel:obj.selectModel,
  293 + }
  294 + // proxy.$http.get(`/api-web/`, {}, function (res) {
  295 + // if (res && res.data) {
  296 + // proxy.$global.showMsg('变更成功!');
  297 + // getListData()
  298 + // }
  299 + // })
  300 + }
16 // 挂载完 301 // 挂载完
17 Vue.onMounted(() => { 302 Vue.onMounted(() => {
  303 + initShowType();
  304 + initCollType();
  305 + getResourceTypoe();
  306 + getListData();
18 }) 307 })
19 return { 308 return {
  309 + isMulti,
  310 + isTwoGroup,
  311 + show,
  312 + initShowType,
  313 + initCollType,
  314 + showTypeList,
  315 + ddicCollType,
  316 + search,
  317 + resTypeOptions,
  318 + changeCancel,
  319 + count,
  320 + hideDialog,
  321 + savebtn,
  322 + changeAdmin,
  323 + getResourceTypoe,
  324 +
  325 + resourceData,
  326 + columns,
  327 + height,
  328 + loading,
  329 +
  330 + selectionChange,
  331 +
  332 + getListData,
  333 + loadTableDataList,
20 334
21 } 335 }
22 } 336 }