yxk-20260527-巡视整改提升台账,问题清单树形结构改造
This commit is contained in:
@@ -13,6 +13,7 @@ enum Api {
|
||||
loadTreeData = '/dqinspectproblem/dqInspectProblem/loadTreeRoot',
|
||||
getChildList = '/dqinspectproblem/dqInspectProblem/childList',
|
||||
getChildListBatch = '/dqinspectproblem/dqInspectProblem/getChildListBatch',
|
||||
parentOptions = '/dqinspectproblem/dqInspectProblem/parentOptions',
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,3 +92,9 @@ export const getChildList = (params) => defHttp.get({ url: Api.getChildList, par
|
||||
* @param params
|
||||
*/
|
||||
export const getChildListBatch = (params) => defHttp.get({ url: Api.getChildListBatch, params },{ isTransformResponse:false });
|
||||
|
||||
/**
|
||||
* 查询当前节点类型可选择的父级问题
|
||||
* @param params
|
||||
*/
|
||||
export const parentOptions = (params) => defHttp.get({ url: Api.parentOptions, params });
|
||||
|
||||
@@ -5,6 +5,14 @@ import { render } from '/@/utils/common/renderUtils';
|
||||
import { getWeekMonthQuarterYear } from '/@/utils';
|
||||
//列表数据
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: '类型',
|
||||
align: 'center',
|
||||
dataIndex: 'nodeType',
|
||||
customRender: ({ text }) => {
|
||||
return render.renderDict(text, 'super_dq_ins_type');
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '密级',
|
||||
align: 'center',
|
||||
@@ -25,11 +33,7 @@ export const columns: BasicColumn[] = [
|
||||
align: 'center',
|
||||
dataIndex: 'hasChild'
|
||||
},
|
||||
{
|
||||
title: '节点类型:category/surface/specific',
|
||||
align: 'center',
|
||||
dataIndex: 'nodeType'
|
||||
},
|
||||
|
||||
{
|
||||
title: '问题名称',
|
||||
align: 'left',
|
||||
|
||||
@@ -75,6 +75,9 @@
|
||||
import JSelectUser from '/@/components/Form/src/jeecg/components/JSelectUser.vue';
|
||||
import JInput from "/@/components/Form/src/jeecg/components/JInput.vue";
|
||||
const { createMessage } = useMessage();
|
||||
const NODE_TYPE_CATEGORY = 'category';
|
||||
const NODE_TYPE_SURFACE = 'surface';
|
||||
const NODE_TYPE_SPECIFIC = 'specific';
|
||||
const expandedRowKeys = ref([]);
|
||||
const queryParam = ref<any>({});
|
||||
const toggleSearchStatus = ref<boolean>(false);
|
||||
@@ -181,8 +184,18 @@
|
||||
* 添加下级
|
||||
*/
|
||||
function handleAddSub(record) {
|
||||
if (record.nodeType === NODE_TYPE_SPECIFIC) {
|
||||
createMessage.warning('具体问题下不能新增问题节点');
|
||||
return;
|
||||
}
|
||||
const childNodeType = record.nodeType === NODE_TYPE_CATEGORY ? NODE_TYPE_SURFACE : NODE_TYPE_SPECIFIC;
|
||||
registerModal.value.disableSubmit = false;
|
||||
registerModal.value.add(record);
|
||||
registerModal.value.add({
|
||||
pid: record.id,
|
||||
nodeType: childNodeType,
|
||||
secretLevel: record.secretLevel,
|
||||
year: record.year,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,7 +354,8 @@
|
||||
},
|
||||
{
|
||||
label: '添加下级',
|
||||
onClick: handleAddSub.bind(null, { pid: record.id }),
|
||||
onClick: handleAddSub.bind(null, record),
|
||||
ifShow: () => record.nodeType !== NODE_TYPE_SPECIFIC,
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
|
||||
@@ -15,26 +15,22 @@
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="父级节点" v-bind="validateInfos.pid">
|
||||
<j-tree-select
|
||||
placeholder="请选择父节点ID"
|
||||
<a-form-item label="问题种类" v-bind="validateInfos.nodeType" id="DqInspectProblemForm-nodeType" name="nodeType">
|
||||
<j-dict-select-tag v-model:value="formData.nodeType" dictCode="super_dq_ins_type" type="radioButton" :disabled="disabled" @change="handleNodeTypeChange" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col v-if="showParentSelect" :span="24">
|
||||
<a-form-item :label="parentLabel" v-bind="validateInfos.pid" id="DqInspectProblemForm-pid" name="pid">
|
||||
<a-tree-select
|
||||
v-model:value="formData.pid"
|
||||
dict="dq_inspect_problem,problem_name,id"
|
||||
pidField="pid"
|
||||
pidValue="0"
|
||||
hasChildField="has_child"
|
||||
:disabled="disabled">
|
||||
</j-tree-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="是否有子节点" v-bind="validateInfos.hasChild" id="DqInspectProblemForm-hasChild" name="hasChild">
|
||||
<a-input v-model:value="formData.hasChild" placeholder="请输入是否有子节点" allow-clear ></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="节点类型:category/surface/specific" v-bind="validateInfos.nodeType" id="DqInspectProblemForm-nodeType" name="nodeType">
|
||||
<a-input v-model:value="formData.nodeType" placeholder="请输入节点类型:category/surface/specific" allow-clear ></a-input>
|
||||
:tree-data="parentTreeData"
|
||||
:placeholder="parentPlaceholder"
|
||||
:disabled="disabled || loadingParentOptions"
|
||||
:loading="loadingParentOptions"
|
||||
allow-clear
|
||||
tree-default-expand-all
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
@@ -52,17 +48,17 @@
|
||||
<a-input-number v-model:value="formData.sortNo" placeholder="请输入排序" style="width: 100%" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-col v-if="isSpecificNode" :span="24">
|
||||
<a-form-item label="巡视建议" v-bind="validateInfos.inspectAdvice" id="DqInspectProblemForm-inspectAdvice" name="inspectAdvice">
|
||||
<a-input v-model:value="formData.inspectAdvice" placeholder="请输入巡视建议" allow-clear ></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-col v-if="isSpecificNode" :span="24">
|
||||
<a-form-item label="问题责任领导" v-bind="validateInfos.questionResLeader" id="DqInspectProblemForm-questionResLeader" name="questionResLeader">
|
||||
<j-select-dept v-model:value="formData.questionResLeader" :multiple="true" checkStrictly allow-clear />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-col v-if="isSpecificNode" :span="24">
|
||||
<a-form-item label="问题责任部门" v-bind="validateInfos.questionResDept" id="DqInspectProblemForm-questionResDept" name="questionResDept">
|
||||
<j-select-user v-model:value="formData.questionResDept" allow-clear />
|
||||
</a-form-item>
|
||||
@@ -75,15 +71,13 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, defineExpose, nextTick, unref, defineProps, computed, onMounted } from 'vue';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { ref, reactive, defineExpose, nextTick, unref, defineProps, computed } from 'vue';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
|
||||
import JSelectDept from '/@/components/Form/src/jeecg/components/JSelectDept.vue';
|
||||
import JSelectUser from '/@/components/Form/src/jeecg/components/JSelectUser.vue';
|
||||
import JTreeSelect from '/@/components/Form/src/jeecg/components/JTreeSelect.vue';
|
||||
import { getValueType } from '/@/utils';
|
||||
import {loadTreeData, saveOrUpdateDict} from '../DqInspectProblem.api';
|
||||
import {loadTreeData, parentOptions, saveOrUpdateDict} from '../DqInspectProblem.api';
|
||||
import { Form } from 'ant-design-vue';
|
||||
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
|
||||
const useForm = Form.useForm;
|
||||
@@ -91,9 +85,13 @@
|
||||
const isUpdate = ref(true);
|
||||
const expandedRowKeys = ref([]);
|
||||
const treeData = ref([]);
|
||||
const pidField = ref<string>('pid');
|
||||
const parentTreeData = ref<any[]>([]);
|
||||
const loadingParentOptions = ref(false);
|
||||
const emit = defineEmits(['register', 'ok']);
|
||||
let model: Nullable<Recordable> = null;
|
||||
const NODE_TYPE_CATEGORY = 'category';
|
||||
const NODE_TYPE_SURFACE = 'surface';
|
||||
const NODE_TYPE_SPECIFIC = 'specific';
|
||||
const formData = reactive<Record<string, any>>({
|
||||
id: '',
|
||||
secretLevel: '',
|
||||
@@ -112,9 +110,25 @@
|
||||
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
|
||||
const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } });
|
||||
const confirmLoading = ref<boolean>(false);
|
||||
const isSpecificNode = computed(() => formData.nodeType === NODE_TYPE_SPECIFIC);
|
||||
const showParentSelect = computed(() => formData.nodeType === NODE_TYPE_SURFACE || formData.nodeType === NODE_TYPE_SPECIFIC);
|
||||
const parentLabel = computed(() => (formData.nodeType === NODE_TYPE_SPECIFIC ? '上级面上问题' : '上级问题分类'));
|
||||
const parentPlaceholder = computed(() => `请选择${parentLabel.value}`);
|
||||
//表单验证
|
||||
const validatorRules = reactive({
|
||||
secretLevel: [{ required: true, message: '请输入密级!'},],
|
||||
nodeType: [{ required: true, message: '请选择问题种类' }],
|
||||
problemName: [{ required: true, message: '请输入问题名称' }],
|
||||
pid: [
|
||||
{
|
||||
validator: async (_rule, value) => {
|
||||
if (showParentSelect.value && !value) {
|
||||
return Promise.reject('请选择上一级问题');
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false });
|
||||
const props = defineProps({
|
||||
@@ -159,7 +173,8 @@
|
||||
})
|
||||
//赋值
|
||||
Object.assign(formData,tmpData);
|
||||
model = tmpData
|
||||
model = tmpData;
|
||||
await loadParentOptions(false);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -185,6 +200,7 @@
|
||||
* 提交数据
|
||||
*/
|
||||
async function submitForm() {
|
||||
normalizeByNodeType();
|
||||
try {
|
||||
// 触发表单验证
|
||||
await validate();
|
||||
@@ -236,16 +252,56 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 值改变事件触发
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
function handleFormChange(key, value) {
|
||||
formData[key] = value;
|
||||
function handleNodeTypeChange(value: any) {
|
||||
const nextType = typeof value === 'string' ? value : value?.target?.value;
|
||||
if (nextType !== undefined) {
|
||||
formData.nodeType = nextType;
|
||||
}
|
||||
formData.pid = formData.nodeType === NODE_TYPE_CATEGORY ? '0' : '';
|
||||
normalizeByNodeType();
|
||||
void loadParentOptions(true);
|
||||
}
|
||||
|
||||
async function loadParentOptions(clearPid: boolean) {
|
||||
if (!showParentSelect.value) {
|
||||
parentTreeData.value = [];
|
||||
formData.pid = '0';
|
||||
return;
|
||||
}
|
||||
loadingParentOptions.value = true;
|
||||
try {
|
||||
const data = await parentOptions({ nodeType: formData.nodeType });
|
||||
parentTreeData.value = Array.isArray(data) ? data : data?.result || [];
|
||||
if (clearPid && !hasParentOption(parentTreeData.value, formData.pid)) {
|
||||
formData.pid = '';
|
||||
}
|
||||
} finally {
|
||||
loadingParentOptions.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function hasParentOption(options: any[], value: string) {
|
||||
if (!value) {
|
||||
return false;
|
||||
}
|
||||
return (options || []).some((item) => {
|
||||
if (!item.disabled && item.value === value) {
|
||||
return true;
|
||||
}
|
||||
return hasParentOption(item.children, value);
|
||||
});
|
||||
}
|
||||
|
||||
function normalizeByNodeType() {
|
||||
if (formData.nodeType === NODE_TYPE_CATEGORY) {
|
||||
formData.pid = '0';
|
||||
}
|
||||
if (formData.nodeType !== NODE_TYPE_SPECIFIC) {
|
||||
formData.inspectAdvice = '';
|
||||
formData.questionResLeader = '';
|
||||
formData.questionResDept = '';
|
||||
}
|
||||
}
|
||||
defineExpose({
|
||||
add,
|
||||
edit,
|
||||
|
||||
Reference in New Issue
Block a user