feat: 部门联调
This commit is contained in:
@@ -64,11 +64,10 @@
|
||||
class="drawerTable"
|
||||
:model="data"
|
||||
:pagination="false"
|
||||
ref="mainRef"
|
||||
rowKey="uuid" />
|
||||
<template #footer>
|
||||
<a-button style="margin-right: 8px" @click="onClose">取消</a-button>
|
||||
<a-button type="primary" @click="onEdit">确定</a-button>
|
||||
<a-button :disabled="!dynamicDisabled" type="primary" @click="onEdit">确定</a-button>
|
||||
</template>
|
||||
</a-drawer>
|
||||
|
||||
@@ -79,12 +78,12 @@
|
||||
cancelText="取消"
|
||||
@ok="handleOk"
|
||||
@cancel="handleClose">
|
||||
<ns-form :schemas="formSchema2" :model="formData2" formLayout="vertical" />
|
||||
<ns-form ref="modalFormRef" :schemas="formSchema2" :model="formData2" formLayout="vertical" />
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { createVNode, defineComponent, reactive, ref } from 'vue';
|
||||
import { computed, createVNode, defineComponent, nextTick, reactive, ref } from 'vue';
|
||||
import { http } from '/nerv-lib/util/http';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
@@ -100,6 +99,7 @@
|
||||
let formData = ref({});
|
||||
let formData2 = ref({ userRoleList: [1, 1, 3] });
|
||||
const formRef = ref();
|
||||
const modalFormRef = ref();
|
||||
const visible = ref(false);
|
||||
const addformvisible = ref(false);
|
||||
const searchValue = ref<string>('');
|
||||
@@ -112,6 +112,9 @@
|
||||
const userAuthList = ref([]);
|
||||
const orgId = JSON.parse(sessionStorage.getItem('userInfo')).orgId;
|
||||
|
||||
const dynamicDisabled = computed(() => {
|
||||
return formRef.value?.validateResult && userAuthList.value?.length;
|
||||
});
|
||||
const fetch = (api, params = { orgId }) => {
|
||||
return http.post(api, params);
|
||||
};
|
||||
@@ -147,8 +150,10 @@
|
||||
};
|
||||
|
||||
const tableFetch = (params) => {
|
||||
console.log(mainRef.value);
|
||||
|
||||
tableConfig.value.params = {
|
||||
...tableConfig.value.params,
|
||||
...mainRef.value.params,
|
||||
...params,
|
||||
};
|
||||
|
||||
@@ -168,6 +173,8 @@
|
||||
|
||||
const onClose = () => {
|
||||
visible.value = false;
|
||||
formData.value = {};
|
||||
userAuthList.value.splice(0);
|
||||
};
|
||||
|
||||
const onEdit = () => {
|
||||
@@ -184,19 +191,21 @@
|
||||
};
|
||||
|
||||
const handleOk = () => {
|
||||
console.log(formData2.value, 'formData2.value');
|
||||
console.log(casData.value, 'formData2.value');
|
||||
if (casData.value?.length !== 3) {
|
||||
NsMessage.error('未选择角色');
|
||||
}
|
||||
const str = casData.value.map((item) => item?.label).join('/');
|
||||
userAuthList.value.push({
|
||||
userAuthList: cloneDeep(casData.value),
|
||||
deptRoleInfoList: str,
|
||||
roleId: casData.value[2].value,
|
||||
roleName: casData.value[2].label,
|
||||
});
|
||||
addformvisible.value = false;
|
||||
} as never);
|
||||
handleClose();
|
||||
};
|
||||
const handleClose = () => {
|
||||
addformvisible.value = false;
|
||||
modalFormRef.value.reset();
|
||||
};
|
||||
|
||||
const tableConfig = ref({
|
||||
@@ -213,9 +222,10 @@
|
||||
handle: () => {
|
||||
opMap.type = 'add';
|
||||
opMap.fuc = (formData: any) => {
|
||||
console.log(formData, 'formData');
|
||||
http.post(origanizemanage.addUser, formData).then(() => {
|
||||
mainRef.value?.nsTableRef.reload();
|
||||
visible.value = false;
|
||||
NsMessage.success('操作成功');
|
||||
});
|
||||
};
|
||||
visible.value = true;
|
||||
@@ -297,11 +307,11 @@
|
||||
},
|
||||
{
|
||||
title: '部门/角色',
|
||||
dataIndex: 'deptRoleInfoList',
|
||||
dataIndex: 'userRoleInfos',
|
||||
customRender: ({ value }) => {
|
||||
if (!value) return '-';
|
||||
return createVNode('div', {}, [
|
||||
createVNode('span', {}, value[0]),
|
||||
createVNode('span', {}, value[0]?.deptRoleInfoList),
|
||||
value.length > 1 &&
|
||||
createVNode(
|
||||
'a',
|
||||
@@ -309,7 +319,9 @@
|
||||
onClick: () =>
|
||||
NsModal.info({
|
||||
icon: null,
|
||||
content: createVNode('div', { innerHTML: value.join('<br>') }),
|
||||
content: createVNode('div', {
|
||||
innerHTML: value.map((item) => item?.deptRoleInfoList).join('<br>'),
|
||||
}),
|
||||
}),
|
||||
},
|
||||
`+${value.length}`,
|
||||
@@ -331,14 +343,18 @@
|
||||
name: 'RoleTypeEdit',
|
||||
// dynamicParams: 'uuid',
|
||||
handle: (record: any) => {
|
||||
console.log(record, 'record');
|
||||
formData.value = record;
|
||||
userAuthList.value.splice(0);
|
||||
setTimeout(() => {
|
||||
formData.value = record;
|
||||
userAuthList.value.push(...record.userRoleInfos);
|
||||
}, 10);
|
||||
opMap.type = 'edit';
|
||||
opMap.fuc = (formData: any) => {
|
||||
Object.assign(
|
||||
mockData.value.filter((item) => item.id === record.id)[0],
|
||||
formData,
|
||||
);
|
||||
http.post(origanizemanage.editUser, formData).then(() => {
|
||||
mainRef.value?.nsTableRef.reload();
|
||||
visible.value = false;
|
||||
NsMessage.success('操作成功');
|
||||
});
|
||||
};
|
||||
visible.value = true;
|
||||
},
|
||||
@@ -449,11 +465,6 @@
|
||||
name: 'RoleTypeAdd',
|
||||
type: 'primary',
|
||||
handle: () => {
|
||||
// opMap.type = 'add';
|
||||
// opMap.fuc = (formData2: any) => {
|
||||
// console.log(formData2, 'formData2');
|
||||
// userAuthList.value.push(cloneDeep(formData2));
|
||||
// };
|
||||
addformvisible.value = true;
|
||||
},
|
||||
},
|
||||
@@ -464,11 +475,11 @@
|
||||
dataIndex: 'userRoleList',
|
||||
customRender: ({ record }) => {
|
||||
if (record) {
|
||||
const res = record.userAuthList.reduce((pre, cur) => {
|
||||
pre.push(cur.label);
|
||||
return pre;
|
||||
}, []);
|
||||
return res.join('/');
|
||||
// const res = record.userAuthList.reduce((pre, cur) => {
|
||||
// pre.push(cur.label);
|
||||
// return pre;
|
||||
// }, []);
|
||||
return record.deptRoleInfoList;
|
||||
}
|
||||
return '-';
|
||||
},
|
||||
@@ -537,6 +548,8 @@
|
||||
onSearch2,
|
||||
handleOk,
|
||||
handleClose,
|
||||
dynamicDisabled,
|
||||
modalFormRef,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
Reference in New Issue
Block a user