Merge branch 'main' of http://123.132.248.154:10000/HC_YFZX/CaiYuanYiTiHua
commit
bfa1c35647
|
|
@ -94,7 +94,7 @@
|
|||
/>
|
||||
</FormItem>
|
||||
<FormItem label="脚本" v-if="['Button'].includes(formConfig.currentItem.component)">
|
||||
<a-button type="primary" size="mini" @click="handleButtonClick"> 点击脚本 </a-button>
|
||||
<a-button size="mini" @click="handleButtonClick"> 点击脚本 </a-button>
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
|
|
|
|||
|
|
@ -76,7 +76,6 @@
|
|||
<a-space direction="vertical">
|
||||
<a-button
|
||||
v-model:value="formConfig.beforeSetData"
|
||||
type="primary"
|
||||
size="mini"
|
||||
@click="handleBtnClick('beforeSetData')"
|
||||
>
|
||||
|
|
@ -84,7 +83,6 @@
|
|||
</a-button>
|
||||
<a-button
|
||||
v-model:value="formConfig.afterValidateForm"
|
||||
type="primary"
|
||||
size="mini"
|
||||
@click="handleBtnClick('afterValidateForm')"
|
||||
>
|
||||
|
|
@ -92,7 +90,6 @@
|
|||
</a-button>
|
||||
<a-button
|
||||
v-model:value="formConfig.afterSaveEvent"
|
||||
type="primary"
|
||||
size="mini"
|
||||
@click="handleBtnClick('afterSaveEvent')"
|
||||
>
|
||||
|
|
@ -100,7 +97,6 @@
|
|||
</a-button>
|
||||
<a-button
|
||||
v-model:value="formConfig.changeDataEvent"
|
||||
type="primary"
|
||||
size="mini"
|
||||
@click="handleBtnClick('changeDataEvent')"
|
||||
>
|
||||
|
|
@ -209,11 +205,9 @@
|
|||
}
|
||||
// 脚本窗口提交
|
||||
function handleSubmit() {
|
||||
if (formContent.value.indexOf('=>') != -1) {
|
||||
// 表示是老版本,提示其修改为新的版本
|
||||
message.warning('脚本没有更新为最新的版本!');
|
||||
if (!checkChinese(formContent.value)) {
|
||||
message.warning('脚本的代码部分不能含有中文字符!');
|
||||
return;
|
||||
// } else if() {
|
||||
}
|
||||
if (btnClickEvent_now) {
|
||||
if (btnClickEvent_now == 'beforeSetData') {
|
||||
|
|
@ -228,6 +222,33 @@
|
|||
}
|
||||
closeModal();
|
||||
}
|
||||
|
||||
function checkChinese(str) {
|
||||
// 分割字符串为多行
|
||||
const lines = str.split('\n');
|
||||
let flag = true;
|
||||
|
||||
// 遍历每一行
|
||||
for (const line of lines) {
|
||||
// 先检查并移除console.log及其后的内容
|
||||
const consoleIndex = line.indexOf('console.log');
|
||||
let partToCheck = line;
|
||||
if (consoleIndex !== -1) {
|
||||
partToCheck = line.substring(0, consoleIndex).trim(); // 移除console.log及其后的内容,并去掉前导空格
|
||||
}
|
||||
|
||||
// 再检查'//'
|
||||
const commentIndex = partToCheck.indexOf('//');
|
||||
// 如果有'//',检查'//'前的部分并去掉前导空格;如果没有,保留原部分
|
||||
partToCheck =
|
||||
commentIndex !== -1 ? partToCheck.substring(0, commentIndex).trim() : partToCheck;
|
||||
// 代码部分不能含有中文字符
|
||||
if (!/[\u4e00-\u9fa5]/.test(partToCheck)) {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,12 @@
|
|||
<template v-if="tabsColumns.length > 1">
|
||||
<a-tabs style="width: 100%" @change="tabsChange">
|
||||
<a-tab-pane v-for="(colItem, index) in tabsColumns" :tab="colItem.label" :key="index">
|
||||
<BasicForm ref="myDataBaseFormRef" @register="registerForm" />
|
||||
<BasicForm
|
||||
ref="myDataBaseFormRef"
|
||||
@register="registerForm"
|
||||
@click="codeClickFunction('beforeSetData', beforeSetData)"
|
||||
@change="codeClickFunction('changeDataEvent', changeDataEvent)"
|
||||
/>
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
</template>
|
||||
|
|
@ -23,6 +28,8 @@
|
|||
ref="myDataBaseFormRef"
|
||||
@register="registerForm"
|
||||
v-if="formModalVisible && tabsColumns.length < 1"
|
||||
@click="codeClickFunction('beforeSetData', beforeSetData)"
|
||||
@change="codeClickFunction('changeDataEvent', changeDataEvent)"
|
||||
/>
|
||||
<template v-for="(item, index) in cardLayout" :key="index">
|
||||
<a-row style="width: 100%">
|
||||
|
|
@ -44,6 +51,20 @@
|
|||
</a-col>
|
||||
</a-row>
|
||||
</template>
|
||||
<template v-for="(item, index) in buttonLayout" :key="index">
|
||||
<a-row style="width: 100%">
|
||||
<a-col :span="item?.colProps?.span || 24" style="padding: 10px">
|
||||
<a-button
|
||||
:type="item.componentProps.type"
|
||||
:shape="item.componentProps.shape"
|
||||
:size="item.componentProps.size"
|
||||
@click="codeClickFunction('codeClick', item.componentProps.clickCode)"
|
||||
>
|
||||
{{ item.label }}
|
||||
</a-button>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</template>
|
||||
<a-table
|
||||
class="sub-table"
|
||||
:columns="subTableColumns"
|
||||
|
|
@ -86,6 +107,7 @@
|
|||
import { v4 as uuidv4 } from 'uuid';
|
||||
import FormItem from './ShowFormModal/FormItem/index.vue';
|
||||
import CallModalFormItem from './CallModalFormItem/index.vue';
|
||||
|
||||
// import FormRender from '@/views/demo/form-design/components/VFormCreate/components/FormRender.vue';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
|
|
@ -112,8 +134,21 @@
|
|||
const scrollValue = ref();
|
||||
const cardLayout = ref([]);
|
||||
const createOrModifyList = ref([]);
|
||||
// 按钮
|
||||
const buttonLayout = ref([]);
|
||||
// 脚本
|
||||
const beforeSetData = ref('');
|
||||
const afterValidateForm = ref('');
|
||||
const afterSaveEvent = ref('');
|
||||
const changeDataEvent = ref('');
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner((data: any) => {
|
||||
console.log('daaaaa', data);
|
||||
// 脚本
|
||||
beforeSetData.value = data?.beforeSetData;
|
||||
afterValidateForm.value = data?.afterValidateForm;
|
||||
afterSaveEvent.value = data?.afterSaveEvent;
|
||||
changeDataEvent.value = data?.changeDataEvent;
|
||||
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
isDetail.value = !!data?.isDetail;
|
||||
const arr: FormSchema[] = [];
|
||||
|
|
@ -133,6 +168,9 @@
|
|||
if (opt.component === 'Card') {
|
||||
cardLayout.value.push(opt);
|
||||
}
|
||||
if (opt.component === 'Button') {
|
||||
buttonLayout.value.push(opt);
|
||||
}
|
||||
if (['createuser', 'createtime', 'modifyuser', 'modifytime'].includes(opt.type)) {
|
||||
createOrModifyList.value.push(opt);
|
||||
}
|
||||
|
|
@ -203,6 +241,9 @@
|
|||
if (item.component === 'Card') {
|
||||
cardLayout.value.push(item);
|
||||
}
|
||||
if (item.component === 'Button') {
|
||||
buttonLayout.value.push(item);
|
||||
}
|
||||
if (['createuser', 'createtime', 'modifyuser', 'modifytime'].includes(item.type)) {
|
||||
createOrModifyList.value.push(item);
|
||||
}
|
||||
|
|
@ -349,6 +390,8 @@
|
|||
async function ModalSureClick() {
|
||||
try {
|
||||
const values = await validate();
|
||||
// 添加校验后脚本
|
||||
codeClickFunction('afterValidateForm', afterValidateForm.value);
|
||||
console.log('values', values);
|
||||
let query = values;
|
||||
let saveSubTableList = [];
|
||||
|
|
@ -397,6 +440,9 @@
|
|||
}
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
// 添加保存后脚本
|
||||
codeClickFunction('afterSaveEvent', afterSaveEvent.value);
|
||||
closeFunc();
|
||||
}
|
||||
}
|
||||
async function handleCreateFlow(processId) {
|
||||
|
|
@ -420,7 +466,37 @@
|
|||
return createMessage.error('保存草稿失败');
|
||||
}
|
||||
}
|
||||
// 脚本执行方法
|
||||
async function codeClickFunction(code, codeClick) {
|
||||
try {
|
||||
// 动态导入utils模块
|
||||
const { utils } = await import('./utils');
|
||||
eval(codeClick);
|
||||
} catch (e) {
|
||||
switch (code) {
|
||||
case 'codeClick':
|
||||
createMessage.success('【按钮组件脚本】错误:' + e);
|
||||
break;
|
||||
case 'beforeSetData':
|
||||
createMessage.success('【添加赋值前脚本】错误:' + e);
|
||||
break;
|
||||
case 'afterValidateForm':
|
||||
createMessage.success('【添加校验后脚本】错误:' + e);
|
||||
break;
|
||||
case 'afterSaveEvent':
|
||||
createMessage.success('【添加保存后脚本】错误:' + e);
|
||||
break;
|
||||
case 'changeDataEvent':
|
||||
createMessage.success('【添加数据改变脚本】错误:' + e);
|
||||
break;
|
||||
default:
|
||||
createMessage.success('【未知脚本】错误:' + e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
const closeFunc = () => {
|
||||
buttonLayout.value = [];
|
||||
cardLayout.value = [];
|
||||
createOrModifyList.value = [];
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@
|
|||
let chlidKey: any = ref();
|
||||
if (val.type === 'chlid') {
|
||||
getOutKeyList(params).then((res: Recordable) => {
|
||||
console.log('ressss', res)
|
||||
console.log('ressss', res);
|
||||
if (res[0]) {
|
||||
res[0].db_codecolumnsList.forEach((item) => {
|
||||
if (item.isPrimaryKey == 1) {
|
||||
|
|
@ -331,9 +331,9 @@
|
|||
});
|
||||
}
|
||||
setTimeout(() => {
|
||||
console.log('chlidKey', chlidKey.value)
|
||||
console.log('chlidKey', chlidKey.value);
|
||||
}, 500);
|
||||
|
||||
|
||||
if (rel.formInfo.schemas.length > 1) {
|
||||
rel.formInfo.schemas.forEach((item) => {
|
||||
if (
|
||||
|
|
@ -407,6 +407,10 @@
|
|||
},
|
||||
activeKey: 1,
|
||||
status: 'Add',
|
||||
beforeSetData: '',
|
||||
afterValidateForm: '',
|
||||
afterSaveEvent: '',
|
||||
changeDataEvent: '',
|
||||
});
|
||||
|
||||
const handleClickForm = (status) => {
|
||||
|
|
@ -430,7 +434,7 @@
|
|||
if (rows.length > 0) {
|
||||
query.value.keyValue = rows[0][str.value];
|
||||
}
|
||||
console.log('config', config)
|
||||
console.log('config', config);
|
||||
switch (status) {
|
||||
case 'Add':
|
||||
btnList.value.forEach((element) => {
|
||||
|
|
@ -447,6 +451,10 @@
|
|||
query: query.value,
|
||||
addParams: addParamsArr.value,
|
||||
btnList: btnList.value,
|
||||
beforeSetData: config.beforeSetData,
|
||||
afterValidateForm: config.afterValidateForm,
|
||||
afterSaveEvent: config.afterSaveEvent,
|
||||
changeDataEvent: config.changeDataEvent,
|
||||
};
|
||||
if (haveMap.value) {
|
||||
showFormModalData.value = toProps;
|
||||
|
|
@ -481,6 +489,10 @@
|
|||
recordChildren: formData.value,
|
||||
query: query.value,
|
||||
btnList: btnList.value,
|
||||
beforeSetData: config.beforeSetData,
|
||||
afterValidateForm: config.afterValidateForm,
|
||||
afterSaveEvent: config.afterSaveEvent,
|
||||
changeDataEvent: config.changeDataEvent,
|
||||
};
|
||||
if (haveMap.value) {
|
||||
showFormModalData.value = toProps;
|
||||
|
|
@ -649,6 +661,11 @@
|
|||
unref(asyncExpandTreeRef)?.expandAll(true);
|
||||
});
|
||||
formConfig.value.schemas = formObj.formInfo.schemas;
|
||||
// 表单脚本
|
||||
formConfig.value.beforeSetData = formObj.formInfo.beforeSetData;
|
||||
formConfig.value.afterValidateForm = formObj.formInfo.afterValidateForm;
|
||||
formConfig.value.afterSaveEvent = formObj.formInfo.afterSaveEvent;
|
||||
formConfig.value.changeDataEvent = formObj.formInfo.changeDataEvent;
|
||||
});
|
||||
}
|
||||
//弹窗确定后返回调用
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
// utils.ts
|
||||
export const utils = {
|
||||
add: function add(a: number, b: number): number {
|
||||
return a + b;
|
||||
},
|
||||
subtract: function subtract(a: number, b: number): number {
|
||||
return a - b;
|
||||
},
|
||||
};
|
||||
Loading…
Reference in New Issue