Authored by wangtao

业务授权优化;业务负责人批量修改功能;

@@ -880,21 +880,30 @@ layui.define(['table', 'form', 'admin', 'layer', 'laytpl', 'common', 'view', 'se @@ -880,21 +880,30 @@ layui.define(['table', 'form', 'admin', 'layer', 'laytpl', 'common', 'view', 'se
880 } 880 }
881 //获取选中的数据 881 //获取选中的数据
882 function getCheckData() { 882 function getCheckData() {
  883 + debugger
883 if(mode){ 884 if(mode){
884 - //获取改变的值  
885 - var str='';  
886 - var $tr=$('#bustype-table').next().find('tbody tr');  
887 - $.each($tr,function (i,v) {  
888 - var $btn=$(this).find('.btn-bustype-unbind');  
889 - var showType=$(this).find('.resourceType_showType') && $(this).find('.resourceType_showType').eq(0) && $(this).find('.resourceType_showType').eq(0).val() ? $(this).find('.resourceType_showType').eq(0).val():'<';  
890 - if(!$btn.hasClass('hide')){  
891 - str += $btn.attr("data-id")+'_'+showType+','; 885 + let arr = [];
  886 + $.each($('[data-type="checkbox"] input'),function (i,v) {
  887 + var that = $(this);
  888 + if(that.is(':checked')){
  889 + arr.push(that.val());
892 } 890 }
893 - });  
894 - if(str!=''){  
895 - str=str.substring(0,str.length-1);  
896 - }  
897 - return str; 891 + })
  892 + return arr.join(',');
  893 + // //获取改变的值
  894 + // var str='';
  895 + // var $tr=$('#bustype-table').next().find('tbody tr');
  896 + // $.each($tr,function (i,v) {
  897 + // var $btn=$(this).find('.btn-bustype-unbind');
  898 + // var showType=$(this).find('.resourceType_showType') && $(this).find('.resourceType_showType').eq(0) && $(this).find('.resourceType_showType').eq(0).val() ? $(this).find('.resourceType_showType').eq(0).val():'<';
  899 + // if(!$btn.hasClass('hide')){
  900 + // str += $btn.attr("data-id")+'_'+showType+',';
  901 + // }
  902 + // });
  903 + // if(str!=''){
  904 + // str=str.substring(0,str.length-1);
  905 + // }
  906 + // return str;
898 }else{ 907 }else{
899 return busTypeTable.checkStatus(false); 908 return busTypeTable.checkStatus(false);
900 } 909 }
@@ -903,4 +912,4 @@ layui.define(['table', 'form', 'admin', 'layer', 'laytpl', 'common', 'view', 'se @@ -903,4 +912,4 @@ layui.define(['table', 'form', 'admin', 'layer', 'laytpl', 'common', 'view', 'se
903 912
904 return {getData: getCheckData}; 913 return {getData: getCheckData};
905 }); 914 });
906 -});  
  915 +});
@@ -1107,6 +1107,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'upload', 'common', 'sessions', @@ -1107,6 +1107,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'upload', 'common', 'sessions',
1107 btn: ['完成'], 1107 btn: ['完成'],
1108 content: laytpl(res.body).render(JSON.stringify({username:usernames})), 1108 content: laytpl(res.body).render(JSON.stringify({username:usernames})),
1109 yes: function (index, layero) {//保存业务授权 1109 yes: function (index, layero) {//保存业务授权
  1110 + debugger
1110 var busType = layui.bustype({username:usernames[0], mode: 'bind'}); 1111 var busType = layui.bustype({username:usernames[0], mode: 'bind'});
1111 var busTypeData = busType.getData(); 1112 var busTypeData = busType.getData();
1112 var loding = layer.load(2); 1113 var loding = layer.load(2);
@@ -1370,4 +1371,4 @@ layui.define(['table', 'form', 'admin', 'layer', 'upload', 'common', 'sessions', @@ -1370,4 +1371,4 @@ layui.define(['table', 'form', 'admin', 'layer', 'upload', 'common', 'sessions',
1370 }); 1371 });
1371 } 1372 }
1372 }) 1373 })
1373 -})  
  1374 +})
  1 +<el-row>
  2 + <el-col :span="24" class="search">
  3 + <div class="condition" style="display: flex;">
  4 + <el-form-item style="margin-right: 6px;margin-bottom: 10px;width: 300px">
  5 + <el-input v-model="data.searchParams.keywords" placeholder="关键字支持:名称、负责人、业务描述"></el-input>
  6 + </el-form-item>
  7 + <el-form-item style="margin-right: 6px;margin-bottom: 10px;">
  8 + <el-button @click="getList">查询</el-button>
  9 + </el-form-item>
  10 +
  11 + <el-form-item style="margin-right: 6px;margin-bottom: 10px;">
  12 + <el-button type="primary" @click="removeRel">取消</el-button>
  13 + </el-form-item>
  14 +
  15 + <el-form-item style="margin-right: 6px;margin-bottom: 10px;">
  16 + <el-button type="primary" @click="changeUser">变更</el-button>
  17 + </el-form-item>
  18 +
  19 + </div>
  20 + </el-col>
  21 +</el-row>
  22 +<el-row class="margin-bottom-50" style="margin-top: 3px">
  23 + <el-col :span="24" class="table-height">
  24 + <cm-table-page :columns="data.columns"
  25 + :dataList="data.tableData"
  26 + :treeProps="{ children: 'children', hasChildren: 'hasChildren' }"
  27 + :total="count"
  28 + :pageSize="pageSize"
  29 + @loaddata="loadTableDataList"
  30 + @selectionChange="selectionChange"
  31 + :showIndex="true"
  32 + :showSelection="true"
  33 + :showBorder="true"
  34 + :loading="loading"
  35 + :showPage="true"
  36 + :showTools="false"
  37 + :height="(height - 200)">
  38 + <template #default="{row,prop,column}">
  39 + </template>
  40 + </cm-table-page>
  41 + </el-col>
  42 +</el-row>
  43 +
  44 +<ChangeUsersList :show="data.userDialogFlag" title="业务关系变更用户" @hideDialog="showUserDialog" @savebtn="saveRel"></ChangeUsersList>
@@ -2,20 +2,229 @@ export default { @@ -2,20 +2,229 @@ export default {
2 name: 'resourceTypePer', 2 name: 'resourceTypePer',
3 template: '', 3 template: '',
4 components: { 4 components: {
5 - 5 + 'ChangeUsersList': Vue.defineAsyncComponent(
  6 + () => myImport('views/batchChangeLeaders/changeUsersList/index')
  7 + ),
6 }, 8 },
7 data() { 9 data() {
8 }, 10 },
9 - props: {  
10 - }, 11 + props: {},
11 setup: function (props, {attrs, slots, emit}) { 12 setup: function (props, {attrs, slots, emit}) {
12 const {proxy} = Vue.getCurrentInstance(); 13 const {proxy} = Vue.getCurrentInstance();
  14 + //列表高度
  15 + let height = Vue.ref(window.innerHeight);
  16 + let data = Vue.ref({
  17 + searchParams: {
  18 + "page": 1,
  19 + "limit": 50,
  20 + "keywords": "",
  21 + "userName": proxy.$route.query.username,
  22 + "busId": ""
  23 + },
  24 + userDialogFlag : false,
  25 + count: 0,
  26 + columns: [{
  27 + prop: "busTypeName",
  28 + label: "名称",
  29 + width: "250",
  30 + sortable: true,
  31 + align: 'center'
  32 + }, {
  33 + prop: "nickname",
  34 + label: "负责人",
  35 + width: "120",
  36 + sortable: true,
  37 + align: 'center'
  38 + }, {
  39 + prop: "busTypeDesc",
  40 + label: "业务描述",
  41 + width: "200",
  42 + sortable: true,
  43 + align: 'center'
  44 + }, {
  45 + prop: "isUse",
  46 + label: "是否使用",
  47 + sortable: true,
  48 + align: 'center',
  49 + render: (row) => {
  50 + switch (row.isUse) {
  51 + case 0:
  52 + return '否';
  53 + case 1:
  54 + return '是';
  55 + default:
  56 + return '';
  57 + }
  58 + }
  59 + }, {
  60 + prop: "important",
  61 + label: "重要程度",
  62 + sortable: true,
  63 + align: 'center',
  64 + render: (row) => {
  65 + switch (row.important) {
  66 + case 1:
  67 + return '核心';
  68 + case 2:
  69 + return '重要';
  70 + case 3:
  71 + return '一般';
  72 + case 9:
  73 + return '虚拟业务';
  74 + default:
  75 + return '';
  76 + }
  77 + }
  78 + }, {
  79 + prop: "sort",
  80 + label: "排序",
  81 + sortable: true,
  82 + align: 'center'
  83 + }],
  84 + tableData: [],
  85 + // 表格选中
  86 + checkArr:[]
  87 + })
  88 +
  89 +
  90 + const getList = () => {
  91 + proxy.$http.post(`/api-web/personnelChange/getList/bizPer`, data.value.searchParams, function (res) {
  92 + if (res && res.data) {
  93 + let dataVal = data.value;
  94 + let list = res.data;
  95 + let count = res.count;
  96 +
  97 + let tableData = list.filter(function (v) {
  98 + if (v.parentId == '0') {
  99 + // 获取子节点
  100 + let childs = list.filter(function (v1) {
  101 + if (v1.parentId != '0' && v1.parentId == v.busId) {
  102 + // 获取子节点
  103 + return v1;
  104 + }
  105 + }).sort(function (a, b) {
  106 + return a.sort - b.sort
  107 + })
  108 + v.children = childs;
  109 + return v;
  110 + }
  111 + }).sort(function (a, b) {
  112 + return a.sort - b.sort
  113 + })
  114 +
  115 + dataVal.tableData = tableData;
  116 + dataVal.count = count;
  117 + }
  118 + })
  119 + }
  120 +
  121 + // 展示用户选择
  122 + let showUserDialog = (flg) =>{
  123 + data.value.userDialogFlag = flg;
  124 + }
  125 +
  126 + let saveRel = (obj) =>{
  127 + // 获取选中
  128 + let arr = data.value.checkArr;
  129 + if(arr.length == 0){
  130 + proxy.$global.showMsg('请至少选择一项','warning');
  131 + return;
  132 + }
  133 +
  134 + let params = {
  135 + targetUserName: obj.selectModel.join(''),
  136 + "userName": proxy.$route.query.username,
  137 + "busId": arr.join(',')
  138 + }
  139 + if(params.targetUserName == params.userName){
  140 + proxy.$global.showMsg('变更用户不能与变更前用户一致,请修改!','warning');
  141 + return;
  142 + }
  143 + proxy.$http.post(`/api-web/personnelChange/update/bizPer`,params, function (res) {
  144 + if (res && res.success) {
  145 + proxy.$global.showMsg('变更成功!');
  146 + showUserDialog(false);
  147 + // 刷新表格
  148 + getList();
  149 + }
  150 + })
  151 + }
  152 +
  153 + // 变更
  154 + let changeUser = () =>{
  155 + // 获取选中
  156 + let arr = data.value.checkArr;
  157 + if(arr.length == 0){
  158 + proxy.$global.showMsg('请至少选择一项','warning');
  159 + return;
  160 + }
  161 +
  162 + showUserDialog(true);
  163 + }
  164 +
  165 + /**
  166 + * 取消
  167 + */
  168 + let removeRel = () =>{
  169 + let arr = data.value.checkArr;
  170 + if(arr.length == 0){
  171 + proxy.$global.showMsg('请至少选择一项','warning');
  172 + return;
  173 + }
  174 +
  175 + data.value.searchParams.busId = arr.join(',')
  176 + proxy.$global.confirm("确定取消相关资源?", function () {
  177 + proxy.$global.showMsg('取消成功!');
  178 + proxy.$http.post(`/api-web/personnelChange/remove/bizPer`, data.value.searchParams , function (res) {
  179 + if (res && res.data) {
  180 + proxy.$global.showMsg('取消成功!');
  181 + getList()
  182 + }
  183 + })
  184 + });
  185 + }
  186 +
  187 + //重新加载表格数据
  188 + let loadTableDataList = ({page, limit}) => {
  189 + let dataVal = data.value;
  190 + dataVal.page = page;
  191 + dataVal.limit = limit;
  192 + getList();
  193 + }
  194 +
  195 + // 表格全选事件
  196 + let selectionChange = (val) => {
  197 + let checkArr = [];
  198 + val.map(item => {
  199 + checkArr.push(item.busId)
  200 + })
  201 + data.value.checkArr = checkArr;
  202 + let isCheck = (list, checkArr) => {
  203 + list.forEach((v, i) => {
  204 + v.checked = checkArr.includes(v.busId);
  205 + if (v.children) {
  206 + isCheck(v.children, checkArr);
  207 + }
  208 + });
  209 + }
  210 + isCheck(data.value.tableData, checkArr);
  211 + }
13 212
14 // 挂载完 213 // 挂载完
15 Vue.onMounted(() => { 214 Vue.onMounted(() => {
  215 + getList();
16 }) 216 })
17 - return {  
18 217
  218 + return {
  219 + height,
  220 + data,
  221 + getList,
  222 + changeUser,
  223 + showUserDialog,
  224 + removeRel,
  225 + loadTableDataList,
  226 + selectionChange,
  227 + saveRel
19 } 228 }
20 } 229 }
21 -}  
  230 +}