修复bug

This commit is contained in:
Jerry
2024-08-14 23:31:15 +08:00
parent 24ba8f571c
commit 3a347a3a1a
19 changed files with 261 additions and 105 deletions

View File

@@ -314,6 +314,7 @@ import { useLayoutStore } from '@/store';
import OnlineFilterBox from '../OnlineQueryForm/OnlineFilterBox.vue';
import { useDict } from '../../hooks/useDict';
import { useForm } from '../hooks/useForm';
import { useFormExpose } from '../hooks/useFormExpose';
const { fetchUpload } = useUpload();
@@ -411,6 +412,7 @@ provide('form', () => {
filter: {
name: leftFilter.value,
},
instanceData: () => useFormExpose(formData),
};
});
@@ -775,7 +777,7 @@ const onOperationClick = (operation: ANY_OBJECT | null, row: ANY_OBJECT | null =
} else if (operation.type === SysCustomWidgetOperationType.EXPORT) {
onExport(operation);
} else if (operation.type === SysCustomWidgetOperationType.PRINT) {
onPrint(operation, row, queryTable.value.showName + '.pdf');
onPrint(operation, row, selectRows.value, queryTable.value.showName + '.pdf');
} else if (operation.type === SysCustomWidgetOperationType.START_FLOW) {
onStartFlow(operation, row);
} else {

View File

@@ -284,6 +284,7 @@ provide('form', () => {
return props.currentWidget === widget;
},
getWidgetObject: widgetData.getWidgetObject,
instanceData: () => useFormExpose(formData),
};
});
@@ -301,7 +302,7 @@ const onOperationClick = (operation: ANY_OBJECT) => {
} else {
keyName = masterTable.value.relation.variableName;
}
onPrint(operation, formData[keyName], form.value.formName + '.pdf');
onPrint(operation, formData[keyName], null, form.value.formName + '.pdf');
};
const onCancel = () => {

View File

@@ -169,6 +169,7 @@ provide('form', () => {
return props.currentWidget === widget;
},
getWidgetObject: widgetData.getWidgetObject,
instanceData: () => useFormExpose(formData),
};
});
@@ -495,7 +496,7 @@ const onOperationClick = (operation: ANY_OBJECT, row: ANY_OBJECT | null) => {
} else if (operation.type === SysCustomWidgetOperationType.EXPORT) {
onExport(operation);
} else if (operation.type === SysCustomWidgetOperationType.PRINT) {
if (row) onPrint(operation, row, queryTable.value.showName + '.pdf');
if (row) onPrint(operation, row, null, queryTable.value.showName + '.pdf');
} else {
handlerOperation(operation, {
isEdit: dialogParams.value.isEdit,

View File

@@ -239,7 +239,6 @@ const {
} = useForm(props);
provide('form', () => {
console.log('provide form5', props, form);
return {
...form.value,
mode: props.mode || 'pc',
@@ -263,6 +262,7 @@ provide('form', () => {
return props.currentWidget === widget;
},
getWidgetObject: widgetData.getWidgetObject,
instanceData: () => useFormExpose(formData),
};
});
@@ -582,7 +582,7 @@ const onOperationClick = (operation: ANY_OBJECT, row: ANY_OBJECT | null) => {
} else if (operation.type === SysCustomWidgetOperationType.EXPORT) {
onExport(operation);
} else if (operation.type === SysCustomWidgetOperationType.PRINT) {
onPrint(operation, row, queryTable.value.showName + '.pdf');
onPrint(operation, row, selectRows.value, queryTable.value.showName + '.pdf');
} else if (operation.type === SysCustomWidgetOperationType.START_FLOW) {
console.log('启动流程');
onStartFlow(operation, row);

View File

@@ -134,6 +134,7 @@ provide('form', () => {
return props.currentWidget === widget;
},
getWidgetObject: widgetData.getWidgetObject,
instanceData: () => useFormExpose(formData),
formAuth: () => {
return formAuth.value;
},

View File

@@ -128,6 +128,7 @@ import { FlowEntryController, FlowOperationController } from '@/api/flow';
import widgetData from '@/online/config/index';
import { useLayoutStore } from '@/store';
import { useForm } from '../hooks/useForm';
import { useFormExpose } from '../hooks/useFormExpose';
const emit = defineEmits<{
tableClick: [ANY_OBJECT];
@@ -160,6 +161,7 @@ const {
isReady,
dialogParams,
form,
formData,
checkOperationPermCode,
checkOperationDisabled,
checkOperationVisible,
@@ -180,6 +182,7 @@ provide('form', () => {
return props.currentWidget === widget;
},
getWidgetObject: widgetData.getWidgetObject,
instanceData: () => useFormExpose(formData),
};
});

View File

@@ -25,9 +25,10 @@ import { useFormConfig } from '@/pages/online/hooks/useFormConfig';
import widgetData from '@/online/config/index';
import combinedDict from '@/common/staticDict/combined';
import { pattern } from '@/common/utils/validate';
import { post } from '@/common/http/request';
//import { API_CONTEXT } from '@/api/config';
import { post, downloadBlob } from '@/common/http/request';
import { API_CONTEXT } from '@/api/config';
import { useThirdParty } from '@/components/thirdParty/hooks';
import { useFormExpose } from './useFormExpose';
const StaticDict = { ...combinedDict };
@@ -143,8 +144,9 @@ export const useForm = (props: ANY_OBJECT, formRef: Ref<FormInstance> | null = n
}
};
const getWidgetVisible = widget => {
const formWidgetAuth: ANY_OBJECT | null =
formAuth.value && formAuth.value.pc ? formAuth.value.pc[widget.variableName] : null;
const formWidgetAuth: ANY_OBJECT | null = formAuth.value && formAuth.value.pc
? formAuth.value.pc[widget.variableName]
: null;
if (formWidgetAuth && formWidgetAuth.hide) return false;
return true;
};
@@ -815,50 +817,79 @@ export const useForm = (props: ANY_OBJECT, formRef: Ref<FormInstance> | null = n
// });
// });
};
const getPrintParamItem = (row, printParamList) => {
let param;
if (Array.isArray(printParamList)) {
param = printParamList
.map(item => {
const columnId = item.paramValue;
if (columnId != null) {
const column = dialogParams.value.formConfig.columnMap.get(columnId);
const value = row ? (row || {})[column.columnName] : getWidgetValueByColumn(column);
if (item.paramName != null && value != null) {
return {
paramName: item.paramName,
paramValue: value,
};
}
}
return null;
})
.filter(item => item != null);
}
return param;
};
// TODO onPrint
const onPrint = (operation: ANY_OBJECT, row: ANY_OBJECT | null, fileName: string) => {
const onPrint = (
operation: ANY_OBJECT,
row: ANY_OBJECT | null,
selectRows: ANY_OBJECT[] | undefined | null,
fileName: string,
) => {
console.log('onPrint', operation, row, fileName);
if (operation == null) return;
// let printParam
// if (row != null) {
// let temp = getPrintParamItem(row, operation.printParamList)
// printParam = temp ? [temp] : []
// } else {
// if (this.selectRows.length <= 0) {
// ElMessage.error('请选择要打印的数据!')
// return
// }
// printParam = this.selectRows
// .map((row) => {
// return this.getPrintParamItem(row, operation.printParamList)
// })
// .filter((item) => item != null)
// }
// let params = {
// datasourceId: masterTable.value.datasource.datasourceId,
// printId: operation.printTemplateId,
// printParams: printParam,
// }
// post(
// API_CONTEXT + '/online/onlineOperation/print/' +
// masterTable.value.datasource.variableName,
// params
// )
// .then((res) => {
// let downloadUrl = res.data
// ajax
// .fetchDownloadBlob(downloadUrl, {}, fileName, 'get')
// .then((blobData) => {
// let pdfUrl = window.URL.createObjectURL(blobData)
// window.open('./lib/pdfjs/web/viewer.html?file=' + pdfUrl)
// })
// .catch((e) => {
// console.log(e)
// ElMessage.error(e)
// })
// })
// .catch((e) => {})
let printParam;
if (row != null) {
const temp = getPrintParamItem(row, operation.printParamList);
printParam = temp ? [temp] : [];
} else {
if (selectRows == null || selectRows?.length <= 0) {
ElMessage.error('请选择要打印的数据!');
return;
}
printParam = selectRows
.map(row => {
return getPrintParamItem(row, operation.printParamList);
})
.filter(item => item != null);
}
const params = {
datasourceId: masterTable.value.datasource.datasourceId,
printId: operation.printTemplateId,
printParams: printParam,
};
post(
API_CONTEXT + '/online/onlineOperation/print/' + masterTable.value.datasource.variableName,
params,
)
.then(res => {
const downloadUrl = res.data;
console.log('downloadUrl', downloadUrl);
downloadBlob(downloadUrl as string, {}, 'get')
.then(blobData => {
const pdfUrl = window.URL.createObjectURL(blobData as Blob);
window.open('./lib/pdfjs/web/viewer.html?file=' + pdfUrl);
})
.catch(e => {
console.log(e);
ElMessage.error(e);
});
})
.catch(e => {
console.log(e);
});
};
const masterTablePrimaryKey = computed(() => {

View File

@@ -28,7 +28,6 @@
:value="item.id"
:label="item.name"
/>
:key="item.id" :value="item.id" :label="item.name" />
</el-select>
</el-form-item>
<el-form-item
@@ -37,8 +36,8 @@
key="express"
>
<el-input
:value="flowConditionForm.body"
@input="onExpressionBodyChange"
:model-value="flowConditionForm.body"
@update:modelValue="onExpressionBodyChange"
clearable
type="textarea"
:disabled="flowConditionForm.type === 'operation'"

View File

@@ -80,10 +80,6 @@
<vxe-column title="按钮名称" min-width="100px">
<template v-slot="scope">
<span style="font-size: 12px">{{ scope.row.label }}</span>
<!-- <el-button class="table-btn" link style="text-decoration: underline;"
@click="onEditOperation(scope.row)">
{{scope.row.label}}
</el-button> -->
</template>
</vxe-column>
<vxe-column title="按钮类型" min-width="100px">
@@ -237,7 +233,9 @@ const onSetOnlineFormAuth = () => {
formWidgetConfig.mobile.widgetList.length > 0
) {
tempConfig.mobile = {
widgetList: formWidgetConfig.mobile.widgetList.map(subWidget => formatOnlineFormInfo(subWidget))
widgetList: formWidgetConfig.mobile.widgetList.map(subWidget =>
formatOnlineFormInfo(subWidget),
),
};
}
}
@@ -246,12 +244,12 @@ const onSetOnlineFormAuth = () => {
'设置表单权限',
FormSetOnlineFormAuth,
{
area: ['1000px', '700px']
area: ['1000px', '700px'],
},
{
formAuth: formData.value.formAuth || {},
formWidgetConfig: tempConfig,
path: 'thirdSetOnlineFormAuth'
path: 'thirdSetOnlineFormAuth',
},
{
width: '1000px',

View File

@@ -101,7 +101,7 @@ const buildWidgetAuthInfo = (widget, authData) => {
const onSubmit = () => {
let authData = {
pc: {},
mobile: {}
mobile: {},
};
pcFormWidgetList.value.forEach(item => {
buildWidgetAuthInfo(item, authData.pc);
@@ -124,7 +124,7 @@ const setParentStatus = (widget, fieldName, val) => {
activeTableData.value,
widget.formId,
'formId',
'children'
'children',
);
if (Array.isArray(parentPath)) {
parentPath.forEach(parent => {
@@ -146,9 +146,7 @@ const setChildStatus = (widget, fieldName, val) => {
const onWidgetDisableChange = (widget, val) => {
// 当val为true时当前组件的所有子组件都禁用当val为false时当前组件的父组件都启用
val
? setChildStatus(widget, 'disabled', val)
: setParentStatus(widget, 'disabled', val);
val ? setChildStatus(widget, 'disabled', val) : setParentStatus(widget, 'disabled', val);
if (activeName.value === 'pc') {
pcFormWidgetList.value = [...pcFormWidgetList.value];
} else {
@@ -158,9 +156,7 @@ const onWidgetDisableChange = (widget, val) => {
const onWidgetHideChange = (widget, val) => {
// 当val为true时当前组件的所有子组件都隐藏当val为false时当前组件的父组件都显示
val
? setChildStatus(widget, 'hidden', val)
: setParentStatus(widget, 'hidden', val);
val ? setChildStatus(widget, 'hidden', val) : setParentStatus(widget, 'hidden', val);
if (activeName.value === 'pc') {
pcFormWidgetList.value = [...pcFormWidgetList.value];
} else {