|
|
export default {
|
|
|
name: 'resourceTypePer',
|
|
|
template: '',
|
|
|
components: {
|
|
|
'ChangeUsersList': Vue.defineAsyncComponent(
|
|
|
() => myImport('views/batchChangeLeaders/changeUsersList/index')
|
|
|
),
|
|
|
},
|
|
|
data() {
|
|
|
},
|
|
|
props: {
|
|
|
item:{
|
|
|
type:Object,
|
|
|
default:{}
|
|
|
}
|
|
|
},
|
|
|
setup: function (props, {attrs, slots, emit}) {
|
|
|
const {proxy} = Vue.getCurrentInstance();
|
|
|
//接收从用户列表中选中的用户
|
|
|
let userName=Vue.ref(proxy.$route.query.username);
|
|
|
//变更人员弹框
|
|
|
let show=Vue.ref(false);
|
|
|
//变更人员列表是否多选
|
|
|
let isMulti=Vue.ref(false);
|
|
|
//变更人员列表是否是两组
|
|
|
let isTwoGroup=Vue.ref(false);
|
|
|
//配置列表总数
|
|
|
let count = Vue.ref(0);
|
|
|
//列表高度
|
|
|
let height = Vue.ref(window.innerHeight);
|
|
|
//加载
|
|
|
let loading = Vue.ref(true);
|
|
|
//选中数据
|
|
|
let pitch = Vue.ref([]);
|
|
|
//展示类型
|
|
|
let showTypeList=Vue.ref([]);
|
|
|
//采集类型
|
|
|
let ddicCollType = Vue.ref([]);
|
|
|
|
|
|
let search = Vue.ref({
|
|
|
resType: '',
|
|
|
keyword: '',
|
|
|
page: 1,
|
|
|
limit: 50,
|
|
|
});
|
|
|
let resTypeOptions=Vue.ref([])
|
|
|
const columns = [
|
|
|
{
|
|
|
prop: 'resTypeName',
|
|
|
label: '资源类型名称',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
},
|
|
|
{
|
|
|
prop: 'resTypeCode',
|
|
|
label: '编码',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
},
|
|
|
{
|
|
|
prop: 'resTypeDesc',
|
|
|
label: '类别',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
},
|
|
|
{
|
|
|
prop: 'collType',
|
|
|
label: '采集类型',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
render: function (row) {
|
|
|
let collType='';
|
|
|
ddicCollType.value.map(item=>{
|
|
|
if(row.collType==item.value){
|
|
|
collType=item.name
|
|
|
}
|
|
|
})
|
|
|
return collType;
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
prop: 'forbidden',
|
|
|
label: '是否启用',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
render: function (row) {
|
|
|
let str='';
|
|
|
if(row.forbidden==0){
|
|
|
str='启用';
|
|
|
}else{
|
|
|
str='禁用';
|
|
|
}
|
|
|
return str;
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
prop: 'showType',
|
|
|
label: '展示类型',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
/* render: function (row) {
|
|
|
|
|
|
}*/
|
|
|
},
|
|
|
{
|
|
|
prop: 'createTime',
|
|
|
label: '创建时间',
|
|
|
align: 'center'
|
|
|
},
|
|
|
|
|
|
];
|
|
|
|
|
|
//列表数据
|
|
|
let resourceData = Vue.ref([]);
|
|
|
//获取列表数据
|
|
|
const getListData = () => {
|
|
|
// resourceData.value=[];
|
|
|
loading.value = true;
|
|
|
//定义列表参数
|
|
|
let getParams = {
|
|
|
resType:search.value.resType,
|
|
|
keywords:search.value.keyword,
|
|
|
userName: userName.value,
|
|
|
page: search.value.page,
|
|
|
limit: search.value.limit
|
|
|
};
|
|
|
proxy.$http.post("/api-web/personnelChange/getList/resourceTypePer", getParams, function (res) {
|
|
|
if (res && res.data) {
|
|
|
resourceData.value = handleTree(res.data, 'resTypeCode', 'parentId')
|
|
|
count.value = res.count;
|
|
|
loading.value = false;
|
|
|
}else{
|
|
|
resourceData.value=[];
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
//组装树结构
|
|
|
let handleTree=(data, id, parentId, children)=> {
|
|
|
let config = {
|
|
|
id: id || 'id',
|
|
|
parentId: parentId || 'parentId',
|
|
|
childrenList: children || 'children'
|
|
|
};
|
|
|
|
|
|
var childrenListMap = {};
|
|
|
var nodeIds = {};
|
|
|
var tree = [];
|
|
|
|
|
|
for (let d of data) {
|
|
|
let parentId = d[config.parentId];
|
|
|
if (childrenListMap[parentId] == null) {
|
|
|
childrenListMap[parentId] = [];
|
|
|
}
|
|
|
nodeIds[d[config.id]] = d;
|
|
|
childrenListMap[parentId].push(d);
|
|
|
}
|
|
|
|
|
|
for (let d of data) {
|
|
|
let parentId = d[config.parentId];
|
|
|
if (nodeIds[parentId] == null) {
|
|
|
tree.push(d);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (let t of tree) {
|
|
|
adaptToChildrenList(t);
|
|
|
}
|
|
|
|
|
|
function adaptToChildrenList(o) {
|
|
|
if (childrenListMap[o[config.id]] !== null) {
|
|
|
o[config.childrenList] = childrenListMap[o[config.id]];
|
|
|
}
|
|
|
if (o[config.childrenList]) {
|
|
|
for (let c of o[config.childrenList]) {
|
|
|
adaptToChildrenList(c);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return tree;
|
|
|
}
|
|
|
//重新加载表格数据
|
|
|
let loadTableDataList = ({page, limit}) => {
|
|
|
search.value.page=page;
|
|
|
search.value.limit=limit;
|
|
|
selectionChange([])
|
|
|
getListData();
|
|
|
}
|
|
|
let resTypeId=Vue.ref('');//选中的ids
|
|
|
//表格全选事件
|
|
|
let selectionChange = (val) => {
|
|
|
pitch.value = val;
|
|
|
let arr=[];
|
|
|
pitch.value.map(item=>{
|
|
|
arr.push(item.resTypeId)
|
|
|
})
|
|
|
resTypeId.value=arr.join(",");//选中的值
|
|
|
}
|
|
|
|
|
|
//获取资源类型数据
|
|
|
let getResourceTypoe=()=>{
|
|
|
proxy.$http.get(`/api-web/manage/restype/list`, {}, function (res) {
|
|
|
if (res && res.data) {
|
|
|
resTypeOptions.value=res.data
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
//获取展示类型的字典数据
|
|
|
let initShowType=()=>{
|
|
|
proxy.$http.post("/api-web/manage/ddic/findSucDdics/DETAILS_POWER", {}, function (res) {
|
|
|
if (res && res.data) {
|
|
|
let arr=res.data;
|
|
|
if(arr && arr.length>0){
|
|
|
arr.map(v=>{
|
|
|
showTypeList.value.push({
|
|
|
name: v.ddicName
|
|
|
,value: v.ddicCode.substring(v.ddicCode.lastIndexOf("_")+1,v.ddicCode.length)
|
|
|
});
|
|
|
})
|
|
|
}
|
|
|
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
//获取采集类型的字典数据
|
|
|
let initCollType=()=>{
|
|
|
proxy.$http.post("/api-web/manage/ddic/findSucDdics/collType", {}, function (res) {
|
|
|
if (res && res.data) {
|
|
|
let arr=res.data;
|
|
|
if(arr && arr.length>0){
|
|
|
arr.map(v=>{
|
|
|
ddicCollType.value.push({
|
|
|
name: v.ddicName
|
|
|
,value: v.ddicCode
|
|
|
});
|
|
|
})
|
|
|
}
|
|
|
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
//批量取消负责的相关资源
|
|
|
let changeCancel = () => {
|
|
|
if(pitch.value.length<1){
|
|
|
proxy.$global.showMsg('请至少选择一项','warning');
|
|
|
}else{
|
|
|
proxy.$global.confirm("确定取消负责的相关资源?", function () {
|
|
|
let parmas={
|
|
|
userName:userName.value,
|
|
|
resTypeId:resTypeId.value
|
|
|
}
|
|
|
proxy.$http.post(`/api-web/personnelChange/remove/resourceTypePer`, parmas, function (res) {
|
|
|
if (res && res.success) {
|
|
|
proxy.$global.showMsg('取消成功!');
|
|
|
getListData()
|
|
|
}
|
|
|
})
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
//变更负责人
|
|
|
let changeAdmin = () => {
|
|
|
if(pitch.value.length<1){
|
|
|
proxy.$global.showMsg('请至少选择一项','warning');
|
|
|
|
|
|
}else{
|
|
|
show.value=true;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
//变更人员的弹框关闭后
|
|
|
let hideDialog =(flag)=>{
|
|
|
show.value=flag;
|
|
|
}
|
|
|
//变更人员的弹框保存后
|
|
|
let savebtn =(obj)=>{
|
|
|
show.value=false;
|
|
|
//obj.selectModel 选中的用户组(一个/主负责人) obj.selectModelSecond 辅负责人,都是数组
|
|
|
let targetUserName='';
|
|
|
if(obj.selectModel){
|
|
|
targetUserName=obj.selectModel.join(',')
|
|
|
}
|
|
|
let params={
|
|
|
resTypeId:resTypeId.value,
|
|
|
targetUserName:targetUserName,
|
|
|
userName:userName.value,
|
|
|
}
|
|
|
proxy.$http.post(`/api-web/personnelChange/update/resourceTypePer`, params, function (res) {
|
|
|
if (res && res.success) {
|
|
|
proxy.$global.showMsg('变更成功!');
|
|
|
getListData()
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
// 挂载完
|
|
|
Vue.onMounted(() => {
|
|
|
initShowType();
|
|
|
initCollType();
|
|
|
getResourceTypoe();
|
|
|
getListData();
|
|
|
})
|
|
|
return {
|
|
|
isMulti,
|
|
|
isTwoGroup,
|
|
|
show,
|
|
|
initShowType,
|
|
|
initCollType,
|
|
|
showTypeList,
|
|
|
ddicCollType,
|
|
|
search,
|
|
|
resTypeOptions,
|
|
|
changeCancel,
|
|
|
count,
|
|
|
hideDialog,
|
|
|
savebtn,
|
|
|
changeAdmin,
|
|
|
getResourceTypoe,
|
|
|
|
|
|
resourceData,
|
|
|
columns,
|
|
|
height,
|
|
|
loading,
|
|
|
selectionChange,
|
|
|
|
|
|
getListData,
|
|
|
loadTableDataList,
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|