动态表单设置rules
<template>
<app-container :padding-y="0">
<uv-gap :height="16" />
<uv-form
labelPosition="left"
:model="props.modelValue"
labelAlign="right"
labelWidth="auto"
ref="form"
>
<uv-form-item
v-for="(item,index) in hasTank"
:key="index"
:label="item.tankNumber + '#' + item.tankUse + '实收数量' "
:prop="item.tankNumber + '#' + item.tankUse + '实收数量'"
borderBottom
required
>
<uv-input
v-model="props.modelValue[item.tankNumber+'#'+item.tankUse + '实收数量']"
:placeholder="'请输入' + item.tankNumber + '#' + item.tankUse + '实收数量' "
></uv-input>
</uv-form-item>
<uv-gap :height="16" />
</uv-form>
<view style="text-align: right;">———— 发包装酒数量(KG): {{ props.number }}</view>
</app-container>
</template>
<script setup>
import { onPullDownRefresh, onLoad } from '@dcloudio/uni-app';
import { isEmpty, isNil } from 'lodash-es';
import { computed, reactive, ref } from 'vue';
const props = defineProps({
hasTank: Array,
number: Number,
modelValue: {
// 表单字段
type: Object,
default: () => {}
}
});
const form = ref(null);
const emit = defineEmits(['update:modelValue']);
defineExpose({
handleSubmits: () => {
form.value
.validate()
.then(res => {
console.log(112131);
})
.catch(err => {
console.log(243222);
});
}
});
// 下拉刷新
onPullDownRefresh(async () => {
uni.stopPullDownRefresh();
});
</script>
<style scoped lang="scss">
.rules{
display: inline-block;
color:red;
position: relative;
top: 28px;
}
.bottom-button {
display: flex;
justify-content: space-around;
}
.btns {
position: fixed;
z-index: 10;
bottom: 35px;
left: 16px;
padding: 0 8px;
width: 90%;
display: flex;
justify-content: flex-end;
}
.container {
position: relative;
background: #fff;
border-radius: 8px;
padding: 0 8px;
overflow: hidden;
.popup {
padding: 0 16px;
}
.bottomBtn {
display: flex;
justify-content: space-around;
}
}
</style>