IDCDatasync-vue/src/views/datawashing/deEmphasisRules/modules/rulesModel.vue
2025-04-24 23:05:46 +08:00

183 lines
6.9 KiB
Vue

<template>
<a-modal :title="title" :width="800" :visible="visible" :confirmLoading="confirmLoading" @ok="handleOk"
@cancel="handleCancel" okText="保存" cancelText="关闭">
<a-spin :spinning="confirmLoading">
<a-form-model ref="ruleForm" :model="form" :rules="rules">
<a-form-model-item label="表名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tableName">
<a-input v-model="form.tableName" placeholder="请输入" v-decorator="['tableName',{
rules: [
{ required: true, message: '表名不能为空' },
{ min: 1, max: 60, message: '长度1-60位' },
],
validateTrigger: 'change'
}]"></a-input>
</a-form-model-item>
<a-form-model-item label="去重类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="duplicationType">
<a-select v-model="form.duplicationType" @change="handleChange">
<a-select-option :value="1">
完全去重
</a-select-option>
<a-select-option :value="2">
关键列去重
</a-select-option>
</a-select>
</a-form-model-item>
<a-form-model-item label="判定字段" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input v-if="form.duplicationType == 1" disabled v-model="allText" placeholder="请输入"></a-input>
<a-tree-select v-if="form.duplicationType == 2" v-model="checkedList" style="width: 100%"
:tree-data="treeData" multiple :show-checked-strategy="SHOW_PARENT" search-placeholder="请选项"
:dropdownStyle="{ maxHeight: '400px', overflowY: 'auto'}"/>
</a-form-model-item>
</a-form-model>
</a-spin>
</a-modal>
</template>
<script>
import JCron from "@/components/jeecg/JCron";
import JSelectMultiple from '@/components/jeecg/JSelectMultiple'
import { createRules, updateRules, queryById, querytableColumns } from '@/api/deEmphasisRules'
import { TreeSelect } from 'ant-design-vue';
const SHOW_PARENT = TreeSelect.SHOW_PARENT;
export default {
name: "rulesModal",
components: {
JCron,
JSelectMultiple
},
data() {
return {
SHOW_PARENT,
title: "操作",
allText: 'ALL',
dataType: null,
visible: false,
model: {},
confirmLoading: false,
form: {
tableName: null,
duplicationType: 1,
judgmentField: null
},
rules: {
tableName: [{ required: true, message: '请输入表名', trigger: 'blur' }],
duplicationType: [{ required: true, message: '请选择去重类型', trigger: 'change' }]
},
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
treeData: [],
checkedList: []
}
},
created() {
},
methods: {
getQuerytableColumns(dataType, tableName) {
querytableColumns({ dataType: dataType, tableName: tableName }).then(res => {
if (res.code == 200) {
this.treeData = []
res.result.forEach(element => {
this.treeData.push({
title: element,
value: element,
key: element,
})
});
}
})
},
handleChange(value) {
if (value == 1) {
this.form.judgmentField = 'ALL'
} else {
}
},
add() {
this.form = {
tableName: null,
duplicationType: 1,
judgmentField: null
}
this.visible = true;
},
eidt(record, dataType) {
this.form = {
id: null,
tableName: record.tableName,
duplicationType: 1,
judgmentField: null
}
if (record.id) {
queryById({ id: record.id }).then(res => {
if (res.code == 200) this.form = res.result
})
}
this.getQuerytableColumns(dataType, record.tableName)
this.visible = true;
},
close() {
this.visible = false;
},
handleOk() {
this.$refs.ruleForm.validate(valid => {
if (valid) {
this.confirmLoading = true;
this.form.judgmentField = this.checkedList.join(',')
console.log('提交', this.form)
if (!this.form.id) {
createRules(this.form).then(res => {
if (res.code === 200) {
this.$notification.success({
message: '系统提示',
description: res.message
})
this.confirmLoading = false
this.$emit('fatherMethod')
this.handleCancel()
} else {
this.$notification.error({
message: '系统提示',
description: res.message
})
this.confirmLoading = false
}
})
} else {
updateRules(this.form).then(res => {
if (res.code === 200) {
this.$notification.success({
message: '系统提示',
description: res.message
})
this.confirmLoading = false
this.$emit('fatherMethod')
this.handleCancel()
} else {
this.$notification.error({
message: '系统提示',
description: res.message
})
this.confirmLoading = false
}
})
}
}
});
},
handleCancel() {
this.close()
},
}
}
</script>