Commit dc424717 authored by 罗林杰's avatar 罗林杰

修改数据标准

parent 730272a6
<template>
<BasicModal width="40%" v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit">
<BasicModal
width="40%"
v-bind="$attrs"
@register="registerModal"
:title="getTitle"
@ok="handleSubmit"
>
<BasicForm @register="registerForm" />
<BasicTable @register="registerTable1"/>
<BasicTable @register="registerTable1" />
</BasicModal>
</template>
<script lang="ts" setup>
import {ref, computed, unref, reactive} from 'vue';
import { ref, computed, unref, reactive } from 'vue';
import { BasicModal, useModalInner } from '@/components/Modal';
import { BasicForm, useForm } from '@/components/Form';
import {relatedQualityColumns, relatedQualitySchema, relatedRelationshipColumns1} from './indicatorStandards.data';
import {
relatedQualityColumns,
relatedQualitySchema,
relatedRelationshipColumns1,
} from './indicatorStandards.data';
import { useMessage } from '@/hooks/web/useMessage';
import {
qualityTreeData,
relatedQualityData,
relatedRelationshipsData1,
TreeData
} from "./indicatorStandardsData";
TreeData,
} from './indicatorStandardsData';
import { BasicTable, useTable, TableAction } from '@/components/Table';
defineOptions({ name: 'AccountModal' });
const emit = defineEmits(['success', 'register']);
const { createMessage } = useMessage();
const rowId = ref('');
const getTitle = computed(() => ('关联质量模版'));
const selectedQualityId = ref<string | undefined>(undefined);
const getTitle = computed(() => '关联质量模版');
//获取接口数据并放在下拉框里(这里是打开了一个弹框)
//初始化表单
const [registerForm, { setFieldsValue, updateSchema, resetFields, validate }] = useForm({
......@@ -40,65 +52,91 @@
setModalProps({ confirmLoading: false });
setFieldsValue({
...data.record,
})
const treeList = handleTree(qualityTreeData, 'businessId',undefined,undefined,undefined)
});
const treeList = handleTree(qualityTreeData, 'businessId', undefined, undefined, undefined);
updateSchema([
{
field: 'QualityId',
componentProps: {
treeData: treeList
treeData: treeList,
onChange: handleTreeSelectChange,
},
},
]);
});
const [registerTable1] = useTable({
const [registerTable1, { reload }] = useTable({
title: '参数配置',
api: async (params) => {
const response = {
pageNu: "1",
pageSize: "10",
pages: "1",
pageNu: '1',
pageSize: '10',
pages: '1',
total: relatedQualityData.length,
code:'',
message:'',
code: '',
message: '',
data: [],
};
//过滤data中的数据,取出等于params.deptId的数据
return { ...response,data: [] };
if (selectedQualityId.value !== undefined) {
response.data = [
{
parameter: 'value_a',
templateType: '数值类',
templateDescription: '数值类:大于n',
value: '0',
},
];
}
return response;
},
columns:relatedQualityColumns,
columns: relatedQualityColumns,
useSearchForm: false,
showTableSetting: false,
showIndexColumn:false,
pagination:false,
showIndexColumn: false,
pagination: false,
bordered: true,
});
/**确定按钮*/
async function handleSubmit() {
createMessage.success('移动成功');
closeModal()
closeModal();
}
/**数组对象转成树*/
function handleTree(data, id, parentId, children, rootId) {
id = id || 'id'
parentId = parentId || 'parentId'
children = children || 'children'
rootId = rootId || Math.min.apply(Math, data.map(item => { return item[parentId] })) || 0
id = id || 'id';
parentId = parentId || 'parentId';
children = children || 'children';
rootId =
rootId ||
Math.min.apply(
Math,
data.map((item) => {
return item[parentId];
}),
) ||
0;
// 对源数据深度克隆
const cloneData = JSON.parse(JSON.stringify(data))
const cloneData = JSON.parse(JSON.stringify(data));
// 循环所有项
const treeData = cloneData.filter(father => {
const branchArr = cloneData.filter(child => {
const treeData = cloneData.filter((father) => {
const branchArr = cloneData.filter((child) => {
// 返回每一项的子级数组
return father[id] === child[parentId]
})
branchArr.length > 0 ? father.children = branchArr : ''
return father[id] === child[parentId];
});
branchArr.length > 0 ? (father.children = branchArr) : '';
// 返回第一层
return father[parentId] === rootId
})
return treeData !== '' ? treeData : data
return father[parentId] === rootId;
});
return treeData !== '' ? treeData : data;
}
/** 树选择变化处理 */
function handleTreeSelectChange(value) {
selectedQualityId.value = value;
reload(); // 重新加载表格数据
}
</script>
......@@ -34,6 +34,7 @@
const { createMessage } = useMessage();
const rowId = ref('');
const tableData = ref([]);
const selectedQualityId = ref<string | undefined>(undefined);
const getTitle = computed(() => '关联质量模版');
//获取接口数据并放在下拉框里(这里是打开了一个弹框)
//初始化表单
......@@ -60,6 +61,7 @@
field: 'QualityId',
componentProps: {
treeData: treeList,
onChange: handleTreeSelectChange,
},
},
]);
......@@ -75,10 +77,21 @@
total: 0,
code: '',
message: '',
data: tableData.value,
data: [],
};
//过滤data中的数据,取出等于params.deptId的数据
return { ...response };
if (selectedQualityId.value !== undefined) {
response.data = [
{
parameter: 'value_a',
templateType: '数值类',
templateDescription: '数值类:大于n',
value: '0',
},
];
}
return response;
},
columns: relatedQualityColumns,
useSearchForm: false,
......@@ -122,4 +135,10 @@
});
return treeData !== '' ? treeData : data;
}
/** 树选择变化处理 */
function handleTreeSelectChange(value) {
selectedQualityId.value = value;
reload(); // 重新加载表格数据
}
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment