UNIVPLMDataIntegration/Web/src/views/system/codeGen/component/verifyDialog.vue

114 lines
3.3 KiB
Vue
Raw Normal View History

<template>
2024-08-28 11:37:37 +08:00
<div class="sys-codeGenConfig-container">
<el-dialog v-model="state.isShowDialog" draggable :close-on-click-modal="false" width="800px">
<template #header>
<div style="color: #fff">
<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit /> </el-icon>
<span> {{ state.title }} </span>
</div>
</template>
<div class="tool-box">
<el-button type="primary" icon="ele-Plus" @click="openRuleDialog"> 新增 </el-button>
</div>
<el-table :data="state.tableData" style="width: 100%" v-loading="state.loading" border>
<el-table-column prop="type" label="类型" width="120" show-overflow-tooltip />
<el-table-column prop="message" label="提示信息" minWidth="180" show-overflow-tooltip />
<el-table-column prop="max" label="最大值" minWidth="100" show-overflow-tooltip />
<el-table-column prop="min" label="最小值" minWidth="100" show-overflow-tooltip />
<el-table-column prop="pattern" label="正则式" minWidth="120" show-overflow-tooltip />
<el-table-column prop="action" label="操作" width="100" align="center" show-overflow-tooltip>
<template #default="scope">
2024-08-28 12:02:50 +08:00
<el-button icon="ele-Delete" text type="danger" @click="handleDeleteRule(scope)">删除</el-button>
2024-08-28 11:37:37 +08:00
</template>
</el-table-column>
</el-table>
<template #footer>
<span class="dialog-footer">
<el-button @click="cancel"> </el-button>
<el-button type="primary" @click="submit"> </el-button>
</span>
</template>
</el-dialog>
<ruleDialog ref="ruleDialogRef" @submitRule="submitRuleOK" />
</div>
</template>
<script lang="ts" setup>
2024-08-28 12:02:50 +08:00
import { reactive, ref, toRaw } from 'vue';
import ruleDialog from '/@/views/system/codeGen/component/ruleDialog.vue';
const emits = defineEmits(['submitVerify']);
const ruleDialogRef = ref();
const state = reactive({
2024-08-28 11:37:37 +08:00
id: 0,
isShowDialog: false,
loading: false,
tableData: [] as any,
title: '',
});
// 打开弹窗
const openDialog = (row: any) => {
2024-08-28 12:02:50 +08:00
state.title = `校验规则 -- ${row.columnComment}`;
2024-08-28 11:37:37 +08:00
state.tableData = new Array();
if (row.rules != '') {
state.tableData = JSON.parse(row.rules);
}
// state.tableData = row.rules;
state.id = row.id;
state.isShowDialog = true;
};
2024-08-28 12:02:50 +08:00
// 打开验证规则弹窗
const openRuleDialog = () => {
2024-08-28 11:37:37 +08:00
ruleDialogRef.value.openDialog(state.id);
};
// 关闭弹窗
const closeDialog = () => {
2024-08-28 11:37:37 +08:00
state.isShowDialog = false;
};
// 取消
const cancel = () => {
2024-08-28 11:37:37 +08:00
state.isShowDialog = false;
};
// 提交
const submit = async () => {
2024-08-28 11:37:37 +08:00
let data = toRaw(state);
let newData = Object.assign({}, data);
let ruleCount = newData.tableData.length > 0 ? `${newData.tableData.length}` : '';
emits('submitVerify', { id: newData.id, rules: JSON.stringify(newData.tableData), ruleCount: ruleCount });
closeDialog();
};
2024-08-28 12:02:50 +08:00
// 添加返回
const submitRuleOK = (data: any) => {
let row = toRaw(data);
if (state.tableData === null) {
state.tableData = [];
}
state.tableData.push(row);
};
2024-08-28 11:37:37 +08:00
// 删除验证规则
const handleDeleteRule = (scope: any) => {
2024-08-28 11:37:37 +08:00
state.tableData.splice(scope.$index, 1);
};
// 导出对象
defineExpose({ openDialog });
</script>
2024-08-28 12:02:50 +08:00
<style lang="scss" scoped>
.tool-box {
padding-bottom: 20px;
display: flex;
gap: 20px;
align-items: center;
// background: red;
}
</style>