Commit f6a621e7 authored by 王纵's avatar 王纵

低代码表单校验

parent df2d5daa
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: zong.wang01@hand-china.com * @Author: zong.wang01@hand-china.com
* @Date: 2024-08-01 09:55:12 * @Date: 2024-08-01 09:55:12
* @LastEditors: zong.wang01@hand-china.com * @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-08-09 18:18:35 * @LastEditTime: 2024-08-09 22:36:54
* @Version: 1.0.0 * @Version: 1.0.0
* @Description: 动态渲染-Lov * @Description: 动态渲染-Lov
* @Copyright: Copyright (c) 2021, Hand-RongJing * @Copyright: Copyright (c) 2021, Hand-RongJing
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
:key="item[lovConfig.valueField]" :key="item[lovConfig.valueField]"
> >
<fragment v-if="multiple"> <fragment v-if="multiple">
<van-checkbox shape="square" v-model="item._selected" @click="selectData(item)"> <van-checkbox shape="square" v-model="item._selected">
<div class="item-content"> <div class="item-content">
<fragment v-for="(td, index) in lovConfig.tableFields" :key="td.dataIndex"> <fragment v-for="(td, index) in lovConfig.tableFields" :key="td.dataIndex">
<span v-if="index < 2">{{item[td.dataIndex]}}</span> <span v-if="index < 2">{{item[td.dataIndex]}}</span>
...@@ -137,7 +137,7 @@ export default { ...@@ -137,7 +137,7 @@ export default {
}, },
multiple: { // 是否多选 multiple: { // 是否多选
type: Boolean, type: Boolean,
default: true, default: false,
}, },
clearable: { clearable: {
type: Boolean, type: Boolean,
...@@ -206,17 +206,10 @@ export default { ...@@ -206,17 +206,10 @@ export default {
} }
} }
}, },
onInput (val) {
this.$emit('input', val);
},
selectData(val) { selectData(val) {
if(!this.multiple) {
this.currentValue = val; this.currentValue = val;
this.changeVisible(false); this.changeVisible(false);
this.inputValue(this.currentValue); this.inputValue(this.currentValue);
} else {
val._selected = true;
}
}, },
// 确定 // 确定
confirm() { confirm() {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: zong.wang01@hand-china.com * @Author: zong.wang01@hand-china.com
* @Date: 2024-08-01 09:55:12 * @Date: 2024-08-01 09:55:12
* @LastEditors: zong.wang01@hand-china.com * @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-08-09 18:20:44 * @LastEditTime: 2024-08-09 22:36:43
* @Version: 1.0.0 * @Version: 1.0.0
* @Description: 动态渲染-Select * @Description: 动态渲染-Select
* @Copyright: Copyright (c) 2021, Hand-RongJing * @Copyright: Copyright (c) 2021, Hand-RongJing
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
</van-cell> --> </van-cell> -->
<van-field <van-field
v-model="currentValue.meaning" v-model="fieldValue"
:disabled="disabled" :disabled="disabled"
:required="required" :required="required"
:rules="[{ required, message: `请选择${label}` }]" :rules="[{ required, message: `请选择${label}` }]"
...@@ -85,7 +85,7 @@ export default { ...@@ -85,7 +85,7 @@ export default {
}, },
multiple: { multiple: {
type: Boolean, type: Boolean,
default: true default: false
}, },
help: { help: {
type: String, type: String,
...@@ -114,6 +114,7 @@ export default { ...@@ -114,6 +114,7 @@ export default {
}, },
data () { data () {
return { return {
fieldValue: '', // 该变量纯粹用来判断是否有选值,给form校验用
currentValue: this.multiple ? [] : { currentValue: this.multiple ? [] : {
meaning: '', meaning: '',
value: '' value: ''
...@@ -177,6 +178,7 @@ export default { ...@@ -177,6 +178,7 @@ export default {
this.$set(this.options[index], 'selected', !this.options[index].selected); this.$set(this.options[index], 'selected', !this.options[index].selected);
}, },
inputValue(val) { inputValue(val) {
this.fieldValue = val ? JSON.stringify(val) : '';
this.$emit('input', val); this.$emit('input', val);
this.$emit('change', val); this.$emit('change', val);
}, },
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: zong.wang01@hand-china.com * @Author: zong.wang01@hand-china.com
* @Date: 2024-07-29 10:51:56 * @Date: 2024-07-29 10:51:56
* @LastEditors: zong.wang01@hand-china.com * @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-08-09 18:06:06 * @LastEditTime: 2024-08-09 22:40:43
* @Version: 1.0.0 * @Version: 1.0.0
* @Description: 表单渲染 * @Description: 表单渲染
* @Copyright: Copyright (c) 2021, Hand-RongJing * @Copyright: Copyright (c) 2021, Hand-RongJing
...@@ -45,16 +45,6 @@ ...@@ -45,16 +45,6 @@
@change="fieldChange" @change="fieldChange"
/> />
<d-url
v-if="field.validationTypeDisplay === 'UrlField'"
:label="field.description"
:help="field.help"
v-model="fieldsObj[field.columnName]"
:disabled="field.readOnly"
:required="field.required"
@change="fieldChange"
/>
<d-select <d-select
v-if="field.validationTypeDisplay === 'Select'" v-if="field.validationTypeDisplay === 'Select'"
v-model="fieldsObj[field.columnName]" v-model="fieldsObj[field.columnName]"
...@@ -64,6 +54,7 @@ ...@@ -64,6 +54,7 @@
:disabled="field.readOnly" :disabled="field.readOnly"
:required="field.required" :required="field.required"
:clearable="field.clearFlag" :clearable="field.clearFlag"
:multiple="field.multiple === 1"
@change="fieldChange" @change="fieldChange"
/> />
...@@ -78,6 +69,7 @@ ...@@ -78,6 +69,7 @@
:required="field.required" :required="field.required"
:clearable="field.clearFlag" :clearable="field.clearFlag"
:cascadesParams="getCascadesParams(field)" :cascadesParams="getCascadesParams(field)"
:multiple="field.multiple === 1"
@change="fieldChange" @change="fieldChange"
/> />
...@@ -91,6 +83,16 @@ ...@@ -91,6 +83,16 @@
:required="field.required" :required="field.required"
:clearable="field.clearFlag" :clearable="field.clearFlag"
/> />
<d-url
v-if="field.validationTypeDisplay === 'UrlField'"
:label="field.description"
:help="field.help"
v-model="fieldsObj[field.columnName]"
:disabled="field.readOnly"
:required="field.required"
@change="fieldChange"
/>
</fragment> </fragment>
</van-form> </van-form>
</fragment> </fragment>
......
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