|
@ -9,36 +9,33 @@ |
|
|
<ns-button type="primary" @click="operateForm" :disabled="!formDisabled">确定</ns-button> |
|
|
<ns-button type="primary" @click="operateForm" :disabled="!formDisabled">确定</ns-button> |
|
|
</template> |
|
|
</template> |
|
|
</ns-drawer> |
|
|
</ns-drawer> |
|
|
<ns-drawer |
|
|
<ns-drawer v-bind="boundaryDrawer"> |
|
|
:width="600" |
|
|
|
|
|
:visible="borderVisible" |
|
|
|
|
|
:body-style="{ paddingBottom: '80px' }" |
|
|
|
|
|
:footer-style="{ textAlign: 'right' }" |
|
|
|
|
|
destroyOnClose |
|
|
|
|
|
@close="onClose"> |
|
|
|
|
|
<ns-button type="primary" @click="borderAdd">新增</ns-button> |
|
|
<ns-button type="primary" @click="borderAdd">新增</ns-button> |
|
|
<ns-button type="primary" style="margin-left: 10px; margin-bottom: 10px" @click="borderAddSon" |
|
|
<ns-button type="primary" style="margin-left: 10px; margin-bottom: 10px" @click="borderAdd" |
|
|
>新增子集</ns-button |
|
|
>新增子集</ns-button |
|
|
> |
|
|
> |
|
|
<a-directory-tree @select="handleSelect" multiple :tree-data="treeData"> |
|
|
<a-tree v-if="linkTree?.length" v-bind="boundaryTree" class="boundaryTree"> |
|
|
<template #title="{ title, key }"> |
|
|
<template #title="data"> |
|
|
{{ title }} |
|
|
<span>{{ data.orgInfo.orgName }}</span> |
|
|
<ns-button type="link" @click="editTree(title, key)">编辑</ns-button> |
|
|
<!-- <ns-button type="link" danger >删除</ns-button> --> |
|
|
<ns-button type="link" danger @click="deleteTree(title, key)">删除</ns-button> |
|
|
|
|
|
|
|
|
<span v-if="data.orgInfo.orgId !== currentBoundaryRecord.orgId" class="nodeDelete"> |
|
|
|
|
|
<DeleteOutlined @click="deleteTree(data)" |
|
|
|
|
|
/></span> |
|
|
</template> |
|
|
</template> |
|
|
</a-directory-tree> |
|
|
</a-tree> |
|
|
</ns-drawer> |
|
|
</ns-drawer> |
|
|
|
|
|
|
|
|
<ns-drawer v-bind="serverDrawer"> |
|
|
<ns-drawer v-bind="serverDrawer"> |
|
|
<ns-input-search |
|
|
<!-- <ns-input-search |
|
|
placeholder="请选择开通模块" |
|
|
placeholder="请选择开通模块" |
|
|
v-model:value="searchValue" |
|
|
v-model:value="searchValue" |
|
|
style="margin-bottom: 8px" |
|
|
style="margin-bottom: 8px" |
|
|
@search="onSearch" /> |
|
|
@search="onSearch" /> --> |
|
|
<a-tree v-if="treeData?.length" v-model:checkedKeys="checkedKeys" v-bind="serverTree" /> |
|
|
<a-tree v-if="treeData?.length" v-model:checkedKeys="checkedKeys" v-bind="serverTree" /> |
|
|
</ns-drawer> |
|
|
</ns-drawer> |
|
|
|
|
|
|
|
|
<TreeAdd ref="treeAdd" /> |
|
|
<TreeAdd ref="treeAdd" @ok="handleOk" /> |
|
|
</template> |
|
|
</template> |
|
|
<script lang="ts" setup> |
|
|
<script lang="ts" setup> |
|
|
import { Modal } from 'ant-design-vue'; |
|
|
import { Modal } from 'ant-design-vue'; |
|
@ -46,10 +43,10 @@ |
|
|
import { http } from '/nerv-lib/util/http'; |
|
|
import { http } from '/nerv-lib/util/http'; |
|
|
import { cloneDeep } from 'lodash-es'; |
|
|
import { cloneDeep } from 'lodash-es'; |
|
|
import TreeAdd from './TreeAdd.vue'; |
|
|
import TreeAdd from './TreeAdd.vue'; |
|
|
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'; |
|
|
import { DeleteOutlined } from '@ant-design/icons-vue'; |
|
|
import { h } from 'vue'; |
|
|
import { h } from 'vue'; |
|
|
import { formConfig } from './config'; |
|
|
import { formConfig } from './config'; |
|
|
import { NsMessage } from '/nerv-lib/component'; |
|
|
import { NsMessage, NsModal } from '/nerv-lib/component'; |
|
|
import { mockData, treeData } from './mock'; |
|
|
import { mockData, treeData } from './mock'; |
|
|
import { enterPrise } from '/@/api/origanizemanage'; |
|
|
import { enterPrise } from '/@/api/origanizemanage'; |
|
|
import { tableConfig as insertConfig } from './config'; |
|
|
import { tableConfig as insertConfig } from './config'; |
|
@ -69,14 +66,31 @@ |
|
|
const serviceVisible = ref(false); |
|
|
const serviceVisible = ref(false); |
|
|
const treeAddVisible = ref(false); |
|
|
const treeAddVisible = ref(false); |
|
|
const formSchema = formConfig; |
|
|
const formSchema = formConfig; |
|
|
|
|
|
const currentServerRecord = ref({}); |
|
|
|
|
|
const currentBoundaryRecord = ref({}); |
|
|
|
|
|
const currentSelectBoundaryNode = ref({}); |
|
|
|
|
|
const linkTree = ref([]); |
|
|
|
|
|
const totalCheckedKeys = ref([]); |
|
|
const opType = ref<string>('add'); |
|
|
const opType = ref<string>('add'); |
|
|
const calMap = { |
|
|
const calMap = { |
|
|
add: enterPrise.save, |
|
|
add: enterPrise.save, |
|
|
edit: enterPrise.edit, |
|
|
edit: enterPrise.edit, |
|
|
|
|
|
serverAdd: enterPrise.orgPermission, |
|
|
}; |
|
|
}; |
|
|
const comApi = computed(() => { |
|
|
const comApi = computed(() => { |
|
|
return calMap[opType.value as keyof typeof calMap]; |
|
|
return calMap[opType.value as keyof typeof calMap]; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 公共请求方法,包含tablereload,drawerclose |
|
|
|
|
|
const fetch = (params, isReload = true) => { |
|
|
|
|
|
http.post(comApi.value, params).then(() => { |
|
|
|
|
|
NsMessage.success('操作成功'); |
|
|
|
|
|
onClose(); |
|
|
|
|
|
isReload && mainRef.value?.nsTableRef.reload(); |
|
|
|
|
|
}); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 表格配置 |
|
|
const tableConfig = computed(() => { |
|
|
const tableConfig = computed(() => { |
|
|
return insertConfig({ |
|
|
return insertConfig({ |
|
|
visible, |
|
|
visible, |
|
@ -87,21 +101,31 @@ |
|
|
serviceVisible, |
|
|
serviceVisible, |
|
|
server: { |
|
|
server: { |
|
|
getTree, |
|
|
getTree, |
|
|
|
|
|
currentServerRecord, |
|
|
|
|
|
getPermissionData, |
|
|
|
|
|
}, |
|
|
|
|
|
boundary: { |
|
|
|
|
|
getBoundaryTree, |
|
|
|
|
|
currentBoundaryRecord, |
|
|
}, |
|
|
}, |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 随机组织id |
|
|
const getOrgRandomCode = () => { |
|
|
const getOrgRandomCode = () => { |
|
|
http.post(enterPrise.getCode).then((res) => { |
|
|
http.post(enterPrise.getCode).then((res) => { |
|
|
formData.value.orgCode = res.data; |
|
|
formData.value.orgCode = res.data; |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
getOrgRandomCode(); |
|
|
// getOrgRandomCode(); |
|
|
|
|
|
|
|
|
|
|
|
// 公共关闭及后续处理逻辑 |
|
|
const onClose = () => { |
|
|
const onClose = () => { |
|
|
visible.value = false; |
|
|
visible.value = false; |
|
|
borderVisible.value = false; |
|
|
borderVisible.value = false; |
|
|
serviceVisible.value = false; |
|
|
serviceVisible.value = false; |
|
|
|
|
|
checkedKeys.value = []; |
|
|
|
|
|
linkTree.value = []; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// 企业表单drawer |
|
|
// 企业表单drawer |
|
@ -113,6 +137,7 @@ |
|
|
onClose: onClose, |
|
|
onClose: onClose, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 表单form配置 |
|
|
const formDisabled = computed(() => { |
|
|
const formDisabled = computed(() => { |
|
|
return formRef.value?.validateResult; |
|
|
return formRef.value?.validateResult; |
|
|
}); |
|
|
}); |
|
@ -121,62 +146,138 @@ |
|
|
const operateForm = () => { |
|
|
const operateForm = () => { |
|
|
formRef.value?.triggerSubmit().then((res) => { |
|
|
formRef.value?.triggerSubmit().then((res) => { |
|
|
console.log(formData.value, 'formData.value'); |
|
|
console.log(formData.value, 'formData.value'); |
|
|
http.post(comApi.value, res).then(() => { |
|
|
fetch(res); |
|
|
NsMessage.success('操作成功'); |
|
|
|
|
|
visible.value = false; |
|
|
|
|
|
mainRef.value?.nsTableRef.reload(); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// 服务操作逻辑区域 |
|
|
// 服务操作逻辑区域 |
|
|
const serverOK = () => { |
|
|
const serverOK = () => { |
|
|
serviceVisible.value = false; |
|
|
const params = { |
|
|
|
|
|
orgId: currentServerRecord.value?.orgId, |
|
|
|
|
|
orgName: currentServerRecord.value?.orgName, |
|
|
|
|
|
permissionVoList: totalCheckedKeys.value, |
|
|
|
|
|
}; |
|
|
|
|
|
fetch(params, false); |
|
|
}; |
|
|
}; |
|
|
const ServiceSelect = (selectedKeys: any, info: any) => { |
|
|
const ServiceSelect = (selectedKeys: any, info: any) => { |
|
|
console.log(selectedKeys, 'selectedKeys'); |
|
|
console.log(selectedKeys, 'selectedKeys'); |
|
|
console.log(info, 'info'); |
|
|
console.log(info, 'info'); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 服务树配置 |
|
|
const serverTree = ref({ |
|
|
const serverTree = ref({ |
|
|
checkable: true, |
|
|
checkable: true, |
|
|
|
|
|
selectable: false, |
|
|
onSelect: ServiceSelect, |
|
|
onSelect: ServiceSelect, |
|
|
defaultExpandAll: true, |
|
|
defaultExpandAll: true, |
|
|
treeData: treeData, |
|
|
treeData: treeData, |
|
|
fieldNames: { children: 'menus', title: 'label', key: 'code' }, |
|
|
fieldNames: { children: 'menus', title: 'label', key: 'code' }, |
|
|
|
|
|
onCheck: (checked, { halfCheckedKeys }) => { |
|
|
|
|
|
const result = checked.map((item) => { |
|
|
|
|
|
return { |
|
|
|
|
|
halfCheck: false, |
|
|
|
|
|
permissionId: item, |
|
|
|
|
|
}; |
|
|
|
|
|
}); |
|
|
|
|
|
const finalResult = halfCheckedKeys |
|
|
|
|
|
.map((item) => { |
|
|
|
|
|
return { |
|
|
|
|
|
halfCheck: true, |
|
|
|
|
|
permissionId: item, |
|
|
|
|
|
}; |
|
|
|
|
|
}) |
|
|
|
|
|
.concat(result); |
|
|
|
|
|
totalCheckedKeys.value = finalResult; |
|
|
|
|
|
}, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 获取服务权限树 |
|
|
const getTree = (params) => { |
|
|
const getTree = (params) => { |
|
|
http.post(enterPrise.permissionTree, params).then((res) => { |
|
|
return http.post(enterPrise.permissionTree, params).then((res) => { |
|
|
treeData.value = res.data.data; |
|
|
treeData.value = res.data?.data; |
|
|
|
|
|
}); |
|
|
|
|
|
}; |
|
|
|
|
|
getTree({}); |
|
|
|
|
|
|
|
|
|
|
|
// 获取当前企业拥有的权限数据 |
|
|
|
|
|
const getPermissionData = (params) => { |
|
|
|
|
|
http.post(enterPrise.queryOrgPermission, params).then((res) => { |
|
|
|
|
|
checkedKeys.value = res.data |
|
|
|
|
|
?.filter((item) => !item.halfCheck) |
|
|
|
|
|
.map((item) => { |
|
|
|
|
|
return item.permissionId; |
|
|
|
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// 开通服务模块drawer |
|
|
// 开通服务模块drawer |
|
|
const serverDrawer = ref({ |
|
|
const serverDrawer = ref({ |
|
|
width: '450', |
|
|
width: 520, |
|
|
visible: serviceVisible, |
|
|
visible: serviceVisible, |
|
|
footerStyle: { textAlign: 'right' }, |
|
|
footerStyle: { textAlign: 'right' }, |
|
|
|
|
|
destroyOnClose: true, |
|
|
ok: serverOK, |
|
|
ok: serverOK, |
|
|
|
|
|
onClose: onClose, |
|
|
cancel: onClose, |
|
|
cancel: onClose, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// drawer form |
|
|
// 边界drawer配置 |
|
|
const opMap: any = { |
|
|
const boundaryDrawer = ref({ |
|
|
type: 'add', |
|
|
width: 520, |
|
|
fuc: () => {}, |
|
|
visible: borderVisible, |
|
|
record: {}, |
|
|
footerStyle: { textAlign: 'right' }, |
|
|
}; |
|
|
destroyOnClose: true, |
|
|
|
|
|
ok: onClose, |
|
|
watch(checkedKeys, () => { |
|
|
onClose, |
|
|
console.log('checkedKeys', checkedKeys.value); |
|
|
cancel: onClose, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const handleSelect = (selectedKeys: any, info: any) => { |
|
|
const handleSelect = (selectedKeys: any, info: any) => { |
|
|
console.log(selectedKeys, 'selectedKeys'); |
|
|
currentSelectBoundaryNode.value = info; |
|
|
console.log(info, 'info'); |
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 获取边界树 |
|
|
|
|
|
const getBoundaryTree = (params) => { |
|
|
|
|
|
http.post(enterPrise.queryOrgTree, params).then((res) => { |
|
|
|
|
|
const otherOrg = res.data[0].listOrg; |
|
|
|
|
|
linkTree.value = res.data; |
|
|
|
|
|
otherOrg?.map((item) => { |
|
|
|
|
|
linkTree.value.push({ orgInfo: item } as never); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 边界树配置 |
|
|
|
|
|
const boundaryTree = ref({ |
|
|
|
|
|
defaultExpandAll: true, |
|
|
|
|
|
onSelect: handleSelect, |
|
|
|
|
|
treeData: linkTree, |
|
|
|
|
|
// blockNode: true, |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 新增边界 |
|
|
|
|
|
const handleOk = (res) => { |
|
|
|
|
|
const params = { |
|
|
|
|
|
...res, |
|
|
|
|
|
linkOrgVoList: [ |
|
|
|
|
|
{ |
|
|
|
|
|
linkOrgId: res.orgId, |
|
|
|
|
|
point: res.point, |
|
|
|
|
|
type: 1, //1子集 2 关联 |
|
|
|
|
|
}, |
|
|
|
|
|
], |
|
|
|
|
|
|
|
|
|
|
|
orgId: currentBoundaryRecord.value.orgId || '', |
|
|
|
|
|
}; |
|
|
|
|
|
http.post(enterPrise.link, params).then(() => { |
|
|
|
|
|
treeAdd.value?.toggle(); |
|
|
|
|
|
NsMessage.success('操作成功'); |
|
|
|
|
|
getBoundaryTree({ |
|
|
|
|
|
orgId: currentBoundaryRecord.value.orgId, |
|
|
|
|
|
orgName: currentBoundaryRecord.value.orgName, |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}; |
|
|
const borderAdd = () => { |
|
|
const borderAdd = () => { |
|
|
treeAddVisible.value = true; |
|
|
treeAddVisible.value = true; |
|
|
treeAdd.value?.toggle(); |
|
|
treeAdd.value?.toggle(); |
|
@ -191,14 +292,19 @@ |
|
|
console.log(key, 'key'); |
|
|
console.log(key, 'key'); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const deleteTree = (title: any, key: any) => { |
|
|
const deleteTree = (node: any) => { |
|
|
console.log(title, 'title'); |
|
|
console.log(node, 'node'); |
|
|
console.log(key, 'key'); |
|
|
|
|
|
Modal.confirm({ |
|
|
NsModal.confirm({ |
|
|
title: '是否确定删除', |
|
|
title: '是否确定删除', |
|
|
icon: createVNode(ExclamationCircleOutlined), |
|
|
|
|
|
content: createVNode('div', { style: 'color:red;' }, ''), |
|
|
content: createVNode('div', { style: 'color:red;' }, ''), |
|
|
onOk() { |
|
|
onOk() { |
|
|
|
|
|
const flag = !!node?.children?.length; |
|
|
|
|
|
|
|
|
|
|
|
if (flag) { |
|
|
|
|
|
NsMessage.error('请先删除子集'); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
// http |
|
|
// http |
|
|
// .post('/api/parking_merchant/objs/gateInfo/delete', { |
|
|
// .post('/api/parking_merchant/objs/gateInfo/delete', { |
|
|
// uuid: record.uuid, |
|
|
// uuid: record.uuid, |
|
@ -218,3 +324,21 @@ |
|
|
console.log(searchValue.value); |
|
|
console.log(searchValue.value); |
|
|
}; |
|
|
}; |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
<style lang="less" scoped> |
|
|
|
|
|
.nodeDelete { |
|
|
|
|
|
// display: none; |
|
|
|
|
|
margin-left: 40px; |
|
|
|
|
|
} |
|
|
|
|
|
.boundaryTree { |
|
|
|
|
|
background-color: red !important; |
|
|
|
|
|
} |
|
|
|
|
|
:deep(.ant-tree) { |
|
|
|
|
|
background-color: red !important; |
|
|
|
|
|
|
|
|
|
|
|
// &:hover { |
|
|
|
|
|
.nodeDelete { |
|
|
|
|
|
display: block; |
|
|
|
|
|
} |
|
|
|
|
|
// } |
|
|
|
|
|
} |
|
|
|
|
|
</style> |
|
|