update: 设备功能调试, 精简模式新增字段必填验证

This commit is contained in:
JiangQiming 2023-02-23 14:30:03 +08:00
parent 7000ccd85b
commit b239bfc8b2
1 changed files with 101 additions and 72 deletions

View File

@ -14,16 +14,21 @@
> >
<a-row :gutter="30"> <a-row :gutter="30">
<a-col :span="15"> <a-col :span="15">
<a-form :ref="`${func.id}Ref`" :model="func">
<a-table <a-table
:columns="columns" :columns="columns"
:data-source="func.table" :data-source="func.table"
:pagination="false" :pagination="false"
rowKey="id" rowKey="id"
> >
<template #bodyCell="{ column, text, record }"> <template #bodyCell="{ column, record, index }">
<template v-if="column.dataIndex === 'type'"> <template
v-if="column.dataIndex === 'type'"
>
<span>{{ record.type }}</span> <span>{{ record.type }}</span>
<a-tooltip v-if="record.type === 'object'"> <a-tooltip
v-if="record.type === 'object'"
>
<template slot="title"> <template slot="title">
请按照json格式输入 请按照json格式输入
</template> </template>
@ -37,10 +42,22 @@
/> />
</a-tooltip> </a-tooltip>
</template> </template>
<template v-if="column.dataIndex === 'value'"> <template
v-if="column.dataIndex === 'value'"
>
<a-form-item
:name="['table', index, 'value']"
:rules="{
required: true,
message: '',
}"
has-feedback
>
<ValueItem <ValueItem
:ref="`valueItemRef${record.id}`" :ref="`valueItemRef${record.id}`"
v-model:modelValue="record.value" v-model:modelValue="
record.value
"
:itemType="record.type" :itemType="record.type"
:options=" :options="
record.type === 'enum' record.type === 'enum'
@ -65,9 +82,11 @@
: undefined : undefined
" "
/> />
</a-form-item>
</template> </template>
</template> </template>
</a-table> </a-table>
</a-form>
<div class="editor-btn"> <div class="editor-btn">
<a-space> <a-space>
<a-button <a-button
@ -180,6 +199,9 @@ const newFunctions = computed(() => {
* 执行 * 执行
*/ */
const handleExecute = async (func: any) => { const handleExecute = async (func: any) => {
proxy?.$refs[`${func.id}Ref`][0]
.validate()
.then(async () => {
const obj = {}; const obj = {};
func.table.forEach((item: any) => { func.table.forEach((item: any) => {
if (item.type === 'object') { if (item.type === 'object') {
@ -197,19 +219,26 @@ const handleExecute = async (func: any) => {
message.success('操作成功'); message.success('操作成功');
func.executeResult = result instanceof Array ? result[0] : result; func.executeResult = result instanceof Array ? result[0] : result;
proxy?.$forceUpdate(); proxy?.$forceUpdate();
})
.catch((err: any) => {
console.log('err: ', err);
});
}; };
/** /**
* 清空 * 清空
*/ */
const handleClear = (func: any) => { const handleClear = (func: any) => {
func.table.forEach((item: any) => { proxy?.$refs[`${func.id}Ref`][0].resetFields();
item.value = undefined;
proxy.$refs[`valueItemRef${item.id}`][0].myValue = undefined;
});
}; };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
:deep(.ant-table-cell .ant-form-item) {
margin-bottom: 0;
}
:deep(.ant-form-item-with-help .ant-form-item-explain) {
min-height: 0;
}
.wrapper { .wrapper {
.tips { .tips {
margin-bottom: 10px; margin-bottom: 10px;