Commit 92492547 authored by 王纵's avatar 王纵

表单新增字段配置功能

parent 1e780e6d
......@@ -2,7 +2,7 @@
* @Author: zong.wang01@hand-china.com
* @Date: 2024-07-29 10:51:56
* @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-10-12 15:25:23
* @LastEditTime: 2024-10-12 15:30:05
* @Version: 1.0.0
* @Description: 表单渲染
* @Copyright: Copyright (c) 2021, Hand-RongJing
......@@ -13,7 +13,7 @@
v-if="formType === 'normal'"
:title="tabInfo.description"
:tabButtons="tabInfo.tabButtons || []"
:showBtns="!readOnly"
:showBtns="true"
:buttonsFun="buttonsClick"
/>
......@@ -133,7 +133,7 @@
</template>
<script>
import { Field, Form, Button, Cell } from 'vant';
import { Field, Form, Button, Cell, Toast } from 'vant';
import DCurrency from './FormItem/DCurrency';
import DField from './FormItem/DField';
import DSwitch from './FormItem/DSwitch';
......@@ -257,7 +257,9 @@ export default {
},
async loadData() {
if (this.tabInfo.readUrl) {
const toastIns = Toast.loading({forbidClick: true});
const res = await getFormData(this.tabInfo.readUrl, this.queryParams)
toastIns.clear();
this.fieldsObj = res.content.length ? res.content[0] : {};
this.dataLoadHandle(this.fieldsObj, this.tabInfo.tabCode); // 数据查询后的回调
this.setDataSetData(this.tabInfo.tabCode, {...this.fieldsObj}); // 保存一份原始数据
......@@ -298,8 +300,7 @@ export default {
return {};
},
fieldChange (name, val) {
this.dynamicInfo().formUpdate(this.tabInfo.tabCode, this, name, val, this.fieldsObj)
// console.log(val)
this.dynamicInfo().formUpdate(this.tabInfo ? this.tabInfo.tabCode : null, this, name, val, this.fieldsObj, this.formType)
},
validate() {
return new Promise((resolve, rejcet) => {
......@@ -372,13 +373,30 @@ export default {
setFieldsValue(fieldsValue) {
this.fieldsObj = {...this.fieldsObj, ...fieldsValue};
},
setFieldConfig (columnName, config) {
setFieldConfig (columnName, config, isBefore = false, positionField) {
const index = this.fieldList.findIndex(o => o.columnName === columnName);
if (index > -1) {
this.fieldList[index] = {
...this.fieldList[index],
...config
}
} else {
const afterIndex = this.fieldList.findIndex(o => o.columnName === positionField)
if (afterIndex > -1) {
this.fieldList.splice(isBefore ? afterIndex : afterIndex + 1, 0, config);
} else {
this.fieldList.push(config);
}
}
this.fieldList = [].concat(this.fieldList);
},
deleteField (columnName, deleteValue = true) { // 移除字段
const index = this.fieldList.findIndex(o => o.columnName === columnName);
if (index > -1) {
this.fieldList.splice(index, 1);
if (deleteValue) {
delete this.fieldsObj[columnName]
}
}
},
buttonsClick(btn) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment