Commit 3377b82c by 张恒

feat(jcsj): 添加数据采集方案管理功能

- 新增MesCollectionScheme和MesCollectionSchemeItem数据模型定义
- 实现数据采集方案的增删改查界面功能
- 集成采集项选择和批量添加功能
- 完善表单验证和数据绑定机制
- 优化界面组件配置和交互体验
- 添加工作流权限控制和按钮权限过滤
parent 2686386c
......@@ -28,7 +28,93 @@ export interface MesCollectionSchemePageModel {
note: string;
}
0;
/**
* @description: MesCollectionScheme表类型
*/
export interface MesCollectionSchemeModel {
id: string;
code: string;
name: string;
contentType: string;
companyId: string;
note: string;
deleteMark: string;
createDate: string;
createUserId: string;
modifyDate: string;
modifyUserId: string;
mesCollectionSchemeItemList?: MesCollectionSchemeItemModel;
}
/**
* @description: MesCollectionSchemeItem表类型
*/
export interface MesCollectionSchemeItemModel {
id: string;
schemeId: string;
code: string;
name: string;
required: string;
categoryId: string;
contentType: string;
dataType: string;
dictId: string;
relatedModelId: string;
relatedModelName: string;
relatedModelDomain: string;
standardValue: string;
upperValue: string;
lowerValue: string;
note: string;
companyId: string;
qualityCategoryId: string;
analysisMethod: string;
qualityMethodId: string;
destructive: string;
keyItem: string;
deleteMark: string;
createDate: string;
createUserId: string;
modifyDate: string;
modifyUserId: string;
}
/**
* @description: MesCollectionScheme分页返回值结构
......
......@@ -9,7 +9,6 @@
:isCamelCase="true"
@model-change="handleChange"
/>
<SelectCollectionItemModal @register="registerSelectModal" @success="handleSelectSuccess" />
</div>
</template>
<script lang="ts" setup>
......@@ -20,17 +19,14 @@
import { cloneDeep, isString } from 'lodash-es';
import { FormDataProps } from '/@/components/Designer/src/types';
import { usePermission } from '/@/hooks/web/usePermission';
import CustomButtonModal from '/@/components/Form/src/components/CustomButtonModal.vue';
import { FromPageType } from '/@/enums/workflowEnum';
import { createFormEvent, getFormDataEvent, loadFormEvent, submitFormEvent,} from '/@/hooks/web/useFormEvent';
import { changeWorkFlowForm, changeSchemaDisabled } from '/@/hooks/web/useWorkFlowForm';
import { WorkFlowFormParams } from '/@/model/workflow/bpmnConfig';
import { useRouter } from 'vue-router';
import { useModal } from '/@/components/Modal';
import SelectCollectionItemModal from './SelectCollectionItemModal.vue';
import { useMessage } from '/@/hooks/web/useMessage';
const { filterFormSchemaAuth } = usePermission();
const { notification } = useMessage();
const RowKey = 'id';
const emits = defineEmits(['changeUploadComponentIds','loadingCompleted', 'update:value']);
......@@ -41,21 +37,14 @@
},
});
const systemFormRef = ref();
const formDataPropsValue = cloneDeep(formProps);
if (!formDataPropsValue.buttonList) {
formDataPropsValue.buttonList = [];
}
const data: { formDataProps: FormDataProps & { buttonList: any[] } } = reactive({
formDataProps: formDataPropsValue as FormDataProps & { buttonList: any[] },
const data: { formDataProps: FormDataProps } = reactive({
formDataProps: cloneDeep(formProps),
});
const state = reactive({
formModel: {} as any,
formInfo:{formId:'',formName:''},
subFormRef: null as any,
formModel: {},
formInfo:{formId:'',formName:''}
});
const { currentRoute } = useRouter();
const [registerSelectModal, { openModal: openSelectModal }] = useModal();
watch(
() => state.formModel,
(val) => {
......@@ -65,186 +54,11 @@
deep: true,
},
);
// 监听采集内容变化,更新SubForm配置
watch(
() => state.formModel.contentType,
() => {
updateSubFormConfig();
},
);
// 更新SubForm配置,添加自定义新增逻辑
function updateSubFormConfig() {
const schemas = data.formDataProps.schemas;
if (!schemas) return;
// 查找SubForm组件
const tabSchema = schemas.find((s) => s.component === 'Tab');
if (!tabSchema || !tabSchema.children) return;
const tabPane = tabSchema.children[0];
if (!tabPane || !tabPane.list) return;
const subFormSchema = tabPane.list.find((s: any) => s.component === 'SubForm');
if (!subFormSchema || !subFormSchema.componentProps) return;
// 修改SubForm配置,添加addBefore钩子来拦截新增
subFormSchema.componentProps.addBefore = (formModel: any, pushObj: any) => {
// 检查是否选择了采集内容
const currentContentType = formModel?.contentType;
if (!currentContentType) {
notification.warning({
message: '提示',
description: '请先选择采集内容',
});
// 标记为需要取消,但在addBefore中无法阻止,需要在addAfter中处理
pushObj._shouldCancel = true;
return;
}
// 设置标志,表示需要打开选择弹窗而不是直接添加
pushObj._customAdd = true;
};
// 在addAfter中处理自定义添加逻辑
subFormSchema.componentProps.addAfter = (formModel: any, pushObj: any) => {
// 如果需要取消(未选择采集内容),移除刚添加的行
if (pushObj._shouldCancel) {
nextTick(() => {
const currentList = state.formModel.mesCollectionSchemeItemList || [];
// 使用key属性或对象引用来查找并移除
const index = pushObj.key !== undefined
? currentList.findIndex((item: any) => item.key === pushObj.key)
: currentList.findIndex((item: any) => item === pushObj);
// 如果找不到,尝试移除最后一个元素(通常是刚添加的)
if (index < 0 && currentList.length > 0) {
currentList.pop();
} else if (index >= 0) {
currentList.splice(index, 1);
}
// 更新表单数据
if (systemFormRef.value) {
systemFormRef.value.setFieldsValue(state.formModel);
}
});
return;
}
// 如果是自定义添加(需要打开选择弹窗),移除刚添加的空行并打开选择弹窗
if (pushObj._customAdd) {
nextTick(() => {
const currentList = state.formModel.mesCollectionSchemeItemList || [];
// 使用key属性或对象引用来查找并移除
const index = pushObj.key !== undefined
? currentList.findIndex((item: any) => item.key === pushObj.key)
: currentList.findIndex((item: any) => item === pushObj);
// 如果找不到,尝试移除最后一个元素(通常是刚添加的)
if (index < 0 && currentList.length > 0) {
currentList.pop();
} else if (index >= 0) {
currentList.splice(index, 1);
}
// 更新表单数据
if (systemFormRef.value) {
systemFormRef.value.setFieldsValue(state.formModel);
}
// 打开选择弹窗
const currentContentType = formModel?.contentType;
if (currentContentType) {
openSelectModal(true, { contentType: currentContentType });
}
});
}
};
}
// 处理选择采集项成功
function handleSelectSuccess(selectedItems: any[]) {
if (!selectedItems || selectedItems.length === 0) return;
// 获取当前的采集项列表
const currentList = state.formModel.mesCollectionSchemeItemList || [];
// 获取已存在的采集项ID和编码,避免重复添加
const existingIds = new Set(currentList.map((item: any) => item.id).filter(Boolean));
const existingCodes = new Set(currentList.map((item: any) => item.code).filter(Boolean));
// 记录重复的项
const duplicateItems: string[] = [];
const addedItems: any[] = [];
// 检查并添加选中的采集项
selectedItems.forEach((item) => {
// 检查是否已存在(通过ID或编码判断)
const isDuplicateById = item.id && existingIds.has(item.id);
const isDuplicateByCode = item.code && existingCodes.has(item.code);
if (isDuplicateById || isDuplicateByCode) {
// 记录重复项的名称
duplicateItems.push(item.name || item.code || '未知项');
} else {
// 添加新项
const newItem = {
code: item.code,
name: item.name,
contentType: item.contentType,
note: item.note,
id: item.id,
schemeId: state.formModel.id || '',
};
currentList.push(newItem);
addedItems.push(newItem);
// 更新已存在的ID和编码集合
if (item.id) {
existingIds.add(item.id);
}
if (item.code) {
existingCodes.add(item.code);
}
}
});
// 如果有重复项,提示用户
if (duplicateItems.length > 0) {
notification.warning({
message: '提示',
description: `以下采集项已存在,已跳过:${duplicateItems.join('、')}`,
duration: 3,
});
}
// 如果没有成功添加任何项,直接返回
if (addedItems.length === 0) {
return;
}
// 更新表单模型
state.formModel.mesCollectionSchemeItemList = currentList;
// 更新表单数据,触发表单刷新
nextTick(() => {
if (systemFormRef.value) {
systemFormRef.value.setFieldsValue(state.formModel);
// 触发表单更新事件,让SubForm组件重新渲染
emits('update:value', state.formModel);
}
});
}
onMounted(async () => {
try {
if (props.fromPage == FromPageType.MENU) {
setMenuPermission();
// 更新SubForm配置,添加自定义新增逻辑
updateSubFormConfig();
if(currentRoute.value.meta){
state.formInfo.formName = currentRoute.value.meta.title&&isString(currentRoute.value.meta.title)?currentRoute.value.meta.title:'';
state.formInfo.formId = currentRoute.value.meta.formId&&isString(currentRoute.value.meta.formId)?currentRoute.value.meta.formId:'';
......@@ -299,8 +113,6 @@
const record = await getMesCollectionScheme(rowId);
setFieldsValue(record);
state.formModel = record;
// 编辑模式下,数据加载后需要重新更新SubForm配置
updateSubFormConfig();
await getFormDataEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:获取表单数据
......@@ -376,8 +188,6 @@
}
state.formModel = formModels;
setFieldsValue(formModels);
// 工作流模式下,数据加载后需要重新更新SubForm配置
updateSubFormConfig();
} catch (error) {}
await createFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
......@@ -389,7 +199,6 @@
function handleChange(val) {
emits('update:value', val);
}
async function sendMessageForAllIframe() {
try {
if (systemFormRef.value && systemFormRef.value.sendMessageForAllIframe) {
......@@ -409,7 +218,8 @@
setWorkFlowForm,
getRowKey,
getFieldsValue,
sendMessageForAllIframe,
sendMessageForAllIframe
});
</script>
\ No newline at end of file
......@@ -185,7 +185,6 @@ export const formProps: FormProps = {
span: 7,
defaultValue: '',
placeholder: '自动生成',
maxlength: null,
prefix: '',
suffix: '',
addonBefore: '',
......@@ -223,8 +222,7 @@ export const formProps: FormProps = {
width: '100%',
span: 7,
defaultValue: '',
placeholder: '请输入名称',
maxlength: null,
placeholder: '请输入名称名称',
prefix: '',
suffix: '',
addonBefore: '',
......@@ -260,7 +258,7 @@ export const formProps: FormProps = {
componentProps: {
width: '100%',
span: 7,
placeholder: '请选择下拉选择采集内容',
placeholder: '请选择采集内容',
showLabel: true,
showSearch: false,
isMultiple: false,
......@@ -271,7 +269,6 @@ export const formProps: FormProps = {
{ key: 2, label: 'Option 2', value: 'Option 2' },
{ key: 3, label: 'Option 3', value: 'Option 3' },
],
defaultSelect: null,
datasourceType: 'dic',
params: { itemId: '2004076110966001666' },
labelField: 'name',
......@@ -282,12 +279,13 @@ export const formProps: FormProps = {
apiId: '93d735dcb7364a0f8102188ec4d77ac7',
},
dicOptions: [],
required: false,
required: true,
rules: [],
events: {},
isShow: true,
tooltipConfig: { visible: false, title: '提示文本' },
itemId: '2004076110966001666',
defaultSelect: '1',
style: { width: '100%' },
},
},
......@@ -331,7 +329,6 @@ export const formProps: FormProps = {
span: 7,
defaultValue: '',
placeholder: '请输入备注',
maxlength: null,
rows: 4,
autoSize: false,
showCount: false,
......@@ -403,8 +400,7 @@ export const formProps: FormProps = {
width: '100%',
span: '',
defaultValue: '',
placeholder: '请输入单行文本单行文本编码',
maxlength: null,
placeholder: '',
prefix: '',
suffix: '',
addonBefore: '',
......@@ -422,6 +418,7 @@ export const formProps: FormProps = {
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
prestrainField: 'code',
},
},
{
......@@ -434,8 +431,7 @@ export const formProps: FormProps = {
width: '100%',
span: '',
defaultValue: '',
placeholder: '请输入单行文本单行文本名称',
maxlength: null,
placeholder: '',
prefix: '',
suffix: '',
addonBefore: '',
......@@ -453,45 +449,7 @@ export const formProps: FormProps = {
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
},
},
{
key: '804817728f184b4483a44cfea3aff654',
title: '采集内容',
dataIndex: 'contentType',
componentType: 'XjrSelect',
componentProps: {
width: '100%',
span: '',
placeholder: '请选择下拉选择',
showLabel: true,
showSearch: false,
isMultiple: false,
clearable: false,
disabled: true,
staticOptions: [
{ key: 1, label: 'Option 1', value: 'Option 1' },
{ key: 2, label: 'Option 2', value: 'Option 2' },
{ key: 3, label: 'Option 3', value: 'Option 3' },
],
defaultSelect: null,
datasourceType: 'dic',
params: { itemId: '2004076110966001666' },
labelField: 'name',
valueField: 'value',
apiConfig: {
path: 'CodeGeneration/selection',
method: 'GET',
apiId: '93d735dcb7364a0f8102188ec4d77ac7',
},
dicOptions: [],
required: false,
rules: [],
events: {},
isShow: true,
tooltipConfig: { visible: false, title: '提示文本' },
itemId: '2004076110966001666',
listStyle: "return 'border: 0'",
prestrainField: 'name',
},
},
{
......@@ -504,13 +462,12 @@ export const formProps: FormProps = {
width: '100%',
span: '',
defaultValue: '',
placeholder: '请输入单行文本单行文本备注',
maxlength: null,
placeholder: '',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: true,
disabled: false,
allowClear: false,
showLabel: true,
required: false,
......@@ -523,6 +480,7 @@ export const formProps: FormProps = {
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
prestrainField: 'note',
},
},
{
......@@ -535,8 +493,7 @@ export const formProps: FormProps = {
width: '100%',
span: '',
defaultValue: '',
placeholder: '请输入单行文本单行文本采集id采集id',
maxlength: null,
placeholder: '',
prefix: '',
suffix: '',
addonBefore: '',
......@@ -560,18 +517,54 @@ export const formProps: FormProps = {
],
span: '24',
preloadType: 'api',
apiConfig: {},
apiConfig: {
path: '/jcxx/getCollectionItemList',
method: 'GET',
apiId: 'copy1766653524481d9018',
apiParams: [
{
key: '1',
title: 'Query Params',
tableInfo: [
{
name: 'contentType',
value:
'{"bindField":"content_type","fieldKey":"58bb5935bfbc4bf8a6c6d2b9b68c9013"}',
description: null,
required: true,
dataType: 'String',
type: null,
defaultValue: null,
validateType: null,
error: null,
expression: null,
children: null,
bindType: 'data',
},
],
},
{ key: '2', title: 'Header', tableInfo: [] },
{ key: '3', title: 'Body' },
],
script:
'var sql="select * from mes_collection_item where content_type = #{contentType} and delete_mark = 0";\r\nreturn db.select(sql);',
outputParams: [
{ name: 'code', tableTitle: '编码' },
{ name: 'name', tableTitle: '名称' },
{ name: 'note', tableTitle: '备注' },
],
},
itemId: '',
dicOptions: [],
useSelectButton: false,
buttonName: '选择数据',
useSelectButton: true,
buttonName: '新增',
showLabel: true,
showComponentBorder: true,
showBorder: false,
bordercolor: '#f0f0f0',
bordershowtype: [true, true, true, true],
borderwidth: 1,
showIndex: false,
showIndex: true,
isShow: true,
multipleHeads: [],
buttonList: [],
......@@ -603,12 +596,58 @@ export const formProps: FormProps = {
checked: false,
},
],
isShowAdd: true,
isShowAdd: false,
isShowDelete: true,
hasCheckedCol: true,
events: {},
showPagenation: true,
showColunmSet: false,
widths: [
{
key: 'b2f7b13aa68f433ea4f7a2003d01e3ef',
name: '编码',
bindField: 'code',
width: null,
minWidth: null,
maxWidth: null,
resizable: false,
unit: null,
isEdit: true,
},
{
key: '0f1a47a5a2aa40cfb4c9b1002c9ea4e2',
name: '名称',
bindField: 'name',
width: null,
minWidth: null,
maxWidth: null,
resizable: false,
unit: null,
isEdit: true,
},
{
key: '86f3efc523aa4e559d09e31e8e1501e4',
name: '备注',
bindField: 'note',
width: null,
minWidth: null,
maxWidth: null,
resizable: false,
unit: null,
isEdit: true,
},
{
key: '8ad391c032064da98fb6abd39e5276ee',
name: '采集id',
bindField: 'scheme_id',
width: null,
minWidth: null,
maxWidth: null,
resizable: false,
unit: null,
isEdit: false,
},
],
},
},
],
......@@ -635,7 +674,6 @@ export const formButtons = [
isShow: true,
index: 2,
type: 1,
modal: null,
},
{
key: 'cancel',
......@@ -646,7 +684,6 @@ export const formButtons = [
isShow: true,
index: 1,
type: 1,
modal: null,
},
{
key: 'reset',
......@@ -657,6 +694,5 @@ export const formButtons = [
isShow: true,
index: 0,
type: 1,
modal: null,
},
];
......@@ -17,7 +17,7 @@ export const permissionList = [
defaultValue: '',
},
{
required: false,
required: true,
view: true,
edit: true,
disabled: false,
......@@ -34,7 +34,7 @@ export const permissionList = [
defaultValue: '',
},
{
required: false,
required: true,
view: true,
edit: true,
disabled: false,
......@@ -48,6 +48,7 @@ export const permissionList = [
key: '58bb5935bfbc4bf8a6c6d2b9b68c9013',
children: [],
options: {},
defaultValue: '1',
},
{
required: false,
......@@ -118,21 +119,6 @@ export const permissionList = [
isSaveTable: false,
showChildren: false,
tableName: 'mesCollectionSchemeItemList',
fieldName: '采集内容',
fieldId: 'contentType',
type: 'XjrSelect',
key: '804817728f184b4483a44cfea3aff654',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesCollectionSchemeItemList',
fieldName: '备注',
fieldId: 'note',
type: 'Input',
......
......@@ -133,7 +133,7 @@
//展示在列表内的按钮
const actionButtons = ref<string[]>(["view","edit","delete"]);
const buttonConfigs = computed(()=>{
const list = [{"isUse":true,"name":"查看","code":"view","icon":"ant-design:eye-outlined","isDefault":true},{"isUse":true,"name":"新增","code":"add","icon":"ant-design:plus-outlined","isDefault":true},{"isUse":true,"name":"编辑","code":"edit","icon":"ant-design:form-outlined","isDefault":true,"isEnableLock":true},{"isUse":true,"name":"删除","code":"delete","icon":"ant-design:delete-outlined","isDefault":true}]
const list = [{"buttonId":"2004369071721181184","name":"查看","code":"view","icon":"ant-design:eye-outlined","isDefault":true,"isUse":true},{"buttonId":"2004369071721181185","name":"新增","code":"add","icon":"ant-design:plus-outlined","isDefault":true,"isUse":true},{"buttonId":"2004369071721181186","name":"编辑","code":"edit","icon":"ant-design:form-outlined","isDefault":true,"isUse":true,"isEnableLock":true},{"buttonId":"2004369071721181187","name":"删除","code":"delete","icon":"ant-design:delete-outlined","isDefault":true,"isUse":true}]
return filterButtonAuth(list);
})
......
......@@ -36,10 +36,13 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
root,
server: {
https: false,
// Listening on all local IPs
host: true,
port: VITE_PORT,
// Load proxy configuration from .env
port: 3100,
// 添加这行,允许所有主机访问
// allowedHosts: ['rustdx.com', '103.97.177.73', '.rustdx.com'],
// 或者允许所有
allowedHosts: true,
proxy: createProxy(VITE_PROXY),
},
resolve: {
......
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