IDCDatasync-vue/src/views/datawashing/tempone/rulesModel.vue
2025-06-21 18:28:13 +08:00

189 lines
7.4 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="请输入"></a-input>
</a-form-model-item>
<a-form-model-item label="字段名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="field">
<a-tree-select v-model="form.field" style="width: 100%"
:tree-data="treeData" :show-checked-strategy="SHOW_PARENT" search-placeholder="请选项"
:dropdownStyle="{ maxHeight: '400px', overflowY: 'auto'}"/>
</a-form-model-item>
<a-form-model-item label="识别算法" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="algorithm">
<a-select v-model="form.algorithm">
<a-select-option :value="1">标准差法</a-select-option>
</a-select>
</a-form-model-item>
<a-form-model-item label="替换策略" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="strategy">
<a-select v-model="form.strategy">
<a-select-option :value="1">填充0</a-select-option>
<a-select-option :value="2">取均值</a-select-option>
<a-select-option :value="3">删除</a-select-option>
</a-select>
</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/outlierReplaceRules'
import { TreeSelect } from 'ant-design-vue';
const SHOW_PARENT = TreeSelect.SHOW_PARENT;
export default {
name: "rulesModal",
components: {
JCron,
JSelectMultiple
},
data() {
return {
SHOW_PARENT,
title: "操作",
visible: false,
model: {},
confirmLoading: false,
form: {
tableName: null,
field: null,
algorithm: null,
strategy: null,
schemaName:""
},
rules: {
tableName: [{ required: true, message: '请输入表名', trigger: 'blur' }],
field: [{ required: true, message: '请选择', trigger: 'change' }],
strategy: [{ required: true, message: '请选择', trigger: 'change' }],
algorithm: [{ required: true, message: '请选择', trigger: 'change' }]
},
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
treeData: [],
checkedList: []
}
},
created() {
// this.loadData();
},
methods: {
getQuerytableColumns(dataType, tableName,shipModel,shipNumber) {
querytableColumns({ dataType: dataType, tableName: tableName,shipModel:shipModel,shipNumber:shipNumber }).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(schemaName,tableName, dataType,shipModel,shipNumber) {
this.getQuerytableColumns(dataType, tableName,shipModel,shipNumber)
this.form = {
tableName: tableName,
field: null,
algorithm: null,
strategy: null,
schemaName :schemaName
}
this.checkedList = []
this.visible = true;
},
eidt(record, dataType,shipModel,shipNumber) {
if (record.id) {
queryById({ id: record.id }).then(res => {
if (res.code == 200) {
this.form = res.result
}
})
} else {
this.form = {
id: null,
tableName: record.tableName,
field: null,
algorithm: null,
strategy: null,
schemaName:record.schemaName
}
}
this.getQuerytableColumns(dataType, record.tableName,shipModel,shipNumber)
this.visible = true;
},
close() {
this.visible = false;
},
handleOk() {
this.$refs.ruleForm.validate(valid => {
if (valid) {
this.confirmLoading = true;
this.form.transfFileds = this.checkedList.join(',')
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>
<style scoped></style>