zhengyiming
2025-03-17 7ed1e4f30ba4d8204152cb157ceaee07374da080
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<template>
  <NutForm
    :model-value="form"
    ref="formRef"
    :rules="rules"
    label-position="top"
    class="order-bill-recharge electric"
  >
    <slot name="top"></slot>
    <NutFormItem label="所在城市" class="bole-form-item" prop="areaList" required>
      <ChooseInputWithAreaPicker
        :columns="cityAreaTree"
        v-model="form.areaList"
        placeholder="请选择所在城市"
      ></ChooseInputWithAreaPicker>
    </NutFormItem>
    <NutFormItem label="缴费户号" class="bole-form-item" prop="gasAccount" required>
      <NutInput
        v-model.trim="form.gasAccount"
        class="bole-input-text"
        placeholder="请输入缴费户号"
        type="text"
        max-length="13"
      />
    </NutFormItem>
    <slot></slot>
  </NutForm>
</template>
 
<script setup lang="ts">
import { Form as NutForm, FormItem as NutFormItem, Input as NutInput } from '@nutui/nutui-taro';
import { FormRules } from '@nutui/nutui-taro/dist/types/__VUE/form/types';
import { reactive, ref, computed, watch } from 'vue';
import ChooseInputWithAreaPicker from '../../components/Input/ChooseInputWithAreaPicker.vue';
import { useAllAreaList } from '../../hooks/area';
import { FormValidator } from '../../utils';
 
defineOptions({
  name: 'GasBillRechargeBaseForm',
});
 
const { findAreaNameFromCode, cityAreaTree } = useAllAreaList();
 
const form = defineModel<{
  // province: string;
  // city: string;
  gasAccount: string;
  areaList: string[];
}>('form');
 
const rules = reactive<FormRules>({
  province: [{ required: true, message: '请选择所在区域' }],
  city: [{ required: true, message: '请选择所在城市' }],
  // gasAccount: [{ required: true, message: '请输入缴费户号', regex: /^\d{13}$/ }],
  gasAccount: [{ required: true, message: '请输入缴费户号' }],
  areaList: [
    { required: true, message: '请选择所在城市', validator: FormValidator.validatorArray },
  ],
});
 
const formRef = ref<any>(null);
 
defineExpose({
  validate: computed(() => formRef.value.validate),
});
</script>