替换表单组件

This commit is contained in:
RenCheng 2025-05-08 21:46:38 +08:00
parent 7673523937
commit 2bd4112f86

View File

@ -10,40 +10,29 @@
cancelText="关闭"> cancelText="关闭">
<a-spin :spinning="confirmLoading"> <a-spin :spinning="confirmLoading">
<a-form :form="form"> <a-form-model ref="ruleForm" :model="form" :rules="rules">
<a-form-item label="索引名称" :labelCol="labelCol" > <a-form-model-item label="索引名称" :labelCol="labelCol" >
<a-input v-decorator="['indexName',{ <a-input v-model="form.indexName" ></a-input>
rules: [ </a-form-model-item>
{ required: true, message: '索引名称不能为空' }, <a-form-model-item label="索引类型" >
{ min: 1, max: 60, message: '长度1-60位' }, <a-select v-model="form.indexTypeId" placeholder="选择索引类型" option-filter-prop="children" size="large">
], <a-select-option :value="0">
validateTrigger: 'change'
}]" ></a-input>
</a-form-item>
<a-form-item label="索引类型" >
<a-select placeholder="选择索引类型" option-filter-prop="children" size="large" v-decorator="['indexTypeId', {
rules: [
{ required: true, message: '选择索引类型' },
],
validateTrigger: 'change'
}]">
<a-select-option key="0" value="0">
普通索引 普通索引
</a-select-option> </a-select-option>
<a-select-option key="1" value="1"> <a-select-option :value="1">
唯一索引 唯一索引
</a-select-option> </a-select-option>
<a-select-option key="2" value="2"> <a-select-option :value="2">
全文索引 全文索引
</a-select-option> </a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-model-item>
<a-form-item label="字段" :labelCol="labelCol" > <a-form-model-item label="字段" :labelCol="labelCol" >
<a-tree-select style="width: 100%" <a-tree-select v-model="checkedList" style="width: 100%"
:tree-data="treeData" multiple search-placeholder="请选项" :tree-data="treeData" multiple search-placeholder="请选项"
:dropdownStyle="{ maxHeight: '400px', overflowY: 'auto'}" v-decorator="['columnName',{}]"/> :dropdownStyle="{ maxHeight: '400px', overflowY: 'auto'}"/>
</a-form-item> </a-form-model-item>
</a-form> </a-form-model>
</a-spin> </a-spin>
</a-modal> </a-modal>
</template> </template>
@ -67,7 +56,15 @@ import pick from 'lodash.pick'
status:'', status:'',
model: {}, model: {},
confirmLoading: false, confirmLoading: false,
form: this.$form.createForm(this), form: {
indexName: '',
columnName: '',
indexTypeId: 0
},
rules: {
indexName: [{ required: true, message: '索引名称', trigger: 'blur' },{ min: 1, max: 60, message: '长度1-60位' },],
indexTypeId: [{ required: true, message: '请选择', trigger: 'change' }]
},
strategys:[], strategys:[],
dataStrategySelected:'', dataStrategySelected:'',
idcDataStrategyId:"", idcDataStrategyId:"",
@ -84,7 +81,8 @@ import pick from 'lodash.pick'
rangeTime:[], rangeTime:[],
treeData: [], treeData: [],
schemaMass:"", schemaMass:"",
tableName:"" tableName:"",
checkedList:[]
} }
}, },
created () { created () {
@ -107,8 +105,10 @@ import pick from 'lodash.pick'
}); });
}, },
add (schemaMass,tableName) { add (schemaMass,tableName) {
console.log(schemaMass,tableName); this.schemaMass = schemaMass;
this.edit(schemaMass,tableName,{}); this.tableName = tableName;
this.visible =true;
this.getQuerytableColumns()
}, },
edit (schemaMass,tableName,record) { edit (schemaMass,tableName,record) {
console.log(schemaMass,tableName); console.log(schemaMass,tableName);
@ -116,12 +116,10 @@ import pick from 'lodash.pick'
this.tableName = tableName; this.tableName = tableName;
this.getQuerytableColumns() this.getQuerytableColumns()
this.visible =true; this.visible =true;
let that = this; this.form.indexName = record.indexName;
that.form.resetFields(); this.checkedList = record.columnName.split(',');
this.model = Object.assign({},record); this.form.indexTypeCode = record.indexTypeId;
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model,'indexName','columnName','indexTypeId'));
});
}, },
close () { close () {
this.visible =false; this.visible =false;
@ -129,13 +127,13 @@ import pick from 'lodash.pick'
handleOk () { handleOk () {
const that = this; const that = this;
// //
this.form.validateFields((err, values) => { this.$refs.ruleForm.validate((valid, values) => {
console.log('values',values) console.log('values',values)
if (!err) { if (valid) {
that.confirmLoading = true; that.confirmLoading = true;
this.model.indexName = values.indexName; this.model.indexName = this.form.indexName;
this.model.columns = values.columnName; this.model.columns = this.checkedList.join(',');
this.model.indexTypeCode = values.indexTypeId; this.model.indexTypeCode = this.form.indexTypeId;
console.log(this.model); console.log(this.model);
postAction("/tableIndex/updateIndexSafe?schemaMass="+this.schemaMass+"&tableName="+this.tableName+"&indexName="+this.model.indexName+"&columns="+this.model.columns+"&indexTypeCode="+this.model.indexTypeCode,{}).then(res => { postAction("/tableIndex/updateIndexSafe?schemaMass="+this.schemaMass+"&tableName="+this.tableName+"&indexName="+this.model.indexName+"&columns="+this.model.columns+"&indexTypeCode="+this.model.indexTypeCode,{}).then(res => {
if (res.success) { if (res.success) {