update 树形通过接口获取数据

This commit is contained in:
赵霄
2023-09-13 11:23:10 +08:00
parent aa3509b77a
commit a75812fd2f
4 changed files with 82 additions and 122 deletions
@@ -18,27 +18,28 @@
@click="handleSelectTreeNode(record)">
<a-tooltip>
<template #title>
{{ record.nodeName }}
{{ record.title }}
</template>
<span class="tree-node-custom-title">{{ record.nodeName }}</span>
<span class="tree-node-custom-title">{{ record.title }}</span>
</a-tooltip>
<template v-if="record.key === mouseInNodeKey">
<!-- 新增-->
<a-button icon="plus"
class="tree-operate-node-btn"
@click.stop="handleAddTreeNode(record)"
v-if="record.nodeType !== StandardSystemTreeNodeType.NOT_OPERATE_NODE.value"
v-has="'domesticStandard:tree:add'"></a-button>
<!-- 编辑根节点不能编辑-->
<a-button class="tree-operate-node-btn"
@click.stop="handleEditTreeNode(record)"
v-has="'domesticStandard:tree:edit'"
v-if="record.nodeType !== StandardSystemTreeNodeType.ROOT_NODE.value">
v-if="record.nodeType !== StandardSystemTreeNodeType.ROOT_NODE.value && record.nodeType !== StandardSystemTreeNodeType.NOT_OPERATE_NODE.value">
<i class="iconfont icon-bianji" />
</a-button>
<!-- 删除根节点不能删除-->
<a-button class="tree-operate-node-btn"
v-has="'domesticStandard:tree:delete'"
v-if="record.nodeType !== StandardSystemTreeNodeType.ROOT_NODE.value"
v-if="record.nodeType !== StandardSystemTreeNodeType.ROOT_NODE.value && record.nodeType !== StandardSystemTreeNodeType.NOT_OPERATE_NODE.value"
@click.stop="handleDelTreeNode(record)">
<i class="iconfont icon-shanchu_" />
</a-button>
@@ -29,7 +29,12 @@
<script>
import AddForm from '../../../../components/customField/AddForm.vue'
import { postAction } from '@api/manage'
import { getDomesticStandardDocumentInfo, getDomesticStandardFormModal } from '../../../../api/standardRegulationLibraryApi'
import {
getDomesticStandardDocumentInfo,
getDomesticStandardFormModal,
addDomesticStandard,
editDomesticStandard
} from '../../../../api/standardRegulationLibraryApi'
export default {
name: 'DomesticStandardModal',
@@ -43,13 +48,7 @@ export default {
form: {},
confirmLoading: false,
getFormFunc: getDomesticStandardFormModal,
getDocumentInfoFunc: getDomesticStandardDocumentInfo,
url: {
getAddForm: '/laws/standard/domestic/getFormModel',
getDocumentInfo: '/laws/standard/domestic/getByIdAndModule',
add: '/laws/standard/domestic/commonAdd',
edit: '/laws/standard/domestic/commonEdit'
}
getDocumentInfoFunc: getDomesticStandardDocumentInfo
}
},
methods: {
@@ -61,6 +60,9 @@ export default {
},
edit (record) {
this.visible = true
this.$nextTick(() => {
this.$refs.addForm.edit(record)
})
},
handleOk () {
this.confirmLoading = true
@@ -68,20 +70,17 @@ export default {
},
// 表单提交的回调,获取表单数据
submitFormData (formInline) {
let url = ''
let submitFunc
if (formInline.id) {
url = this.url.edit
submitFunc = editDomesticStandard
} else {
url = this.url.add
submitFunc = addDomesticStandard
}
postAction(url, formInline).then((res) => {
submitFunc(formInline).then((res) => {
if (res.success) {
this.$message.success(this.$t('operationSuccessful'))
if (this.formInline.id) {
this.$emit('ok')
} else {
this.$emit('ok')
}
this.$message.success(res.message)
this.$emit('ok')
this.close()
} else {
this.$message.warning(res.message)
}