zhengyiming
20 小时以前 0ca66ba6d5f5d5502211b9d9c7bff036ebd3f1aa
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<template>
  <ProDialog
    :title="form.isDetail ? '人员详情' : '人员信息编辑'"
    v-model="visible"
    @close="onDialogClose"
    destroy-on-close
    draggable
    :width="900"
  >
    <ProForm :model="form" ref="dialogForm" label-width="120px" :is-read="form.isDetail">
      <ProFormCol>
        <ProFormColItem :span="12">
          <ProFormItemV2 label="姓名:" prop="name" :check-rules="[{ message: '请输入姓名' }]">
            <ProFormText placeholder="请输入姓名" v-model.trim="form.name"></ProFormText>
          </ProFormItemV2>
        </ProFormColItem>
        <ProFormColItem :span="12">
          <ProFormItemV2 v-if="form.isDetail" label="报名时间:" prop="regiterTime">
            <div>{{ format(form.regiterTime, 'YYYY-MM-DD HH:mm') }}</div>
          </ProFormItemV2>
        </ProFormColItem>
        <ProFormColItem :span="12">
          <ProFormItemV2
            label="身份证号:"
            prop="identity"
            :check-rules="[{ message: '请输入身份证号', type: 'idCard' }]"
          >
            <ProFormText placeholder="请输入身份证号" v-model.trim="form.identity"></ProFormText>
          </ProFormItemV2>
        </ProFormColItem>
        <ProFormColItem :span="12">
          <ProFormItemV2 v-if="form.isDetail" label="实名时间:" prop="userRealTime">
            <div>{{ format(form.userRealTime, 'YYYY-MM-DD HH:mm') }}</div>
          </ProFormItemV2>
        </ProFormColItem>
        <ProFormColItem :span="12">
          <ProFormItemV2
            label="手机号:"
            prop="contactPhoneNumber"
            :check-rules="[{ message: '请输入手机号', type: 'phone' }]"
          >
            <ProFormText
              placeholder="请输入手机号"
              v-model.trim="form.contactPhoneNumber"
            ></ProFormText>
          </ProFormItemV2>
        </ProFormColItem>
        <ProFormColItem :span="12">
          <ProFormItemV2 v-if="form.isDetail" label="签约时间:" prop="userSignContractTime">
            <div>{{ format(form.userSignContractTime, 'YYYY-MM-DD HH:mm') }}</div>
          </ProFormItemV2>
        </ProFormColItem>
        <ProFormColItem :span="12">
          <ProFormItemV2
            label="性别:"
            prop="gender"
            required
            :check-rules="[{ message: '请选择性别' }]"
          >
            <ProFormRadio
              v-model="form.gender"
              :value-enum="EnumUserGenderTextForPerson"
              :buttonStyle="false"
            ></ProFormRadio>
          </ProFormItemV2>
        </ProFormColItem>
        <ProFormColItem :span="12">
          <ProFormItemV2 v-if="form.isDetail" label="电子合同:" prop="contractUrl">
            <ProFormUpload
              v-model:file-url="form.contractUrl"
              :limit="1"
              :limitFileSize="10"
              accept="jpg/jpeg,png,pdf"
            ></ProFormUpload>
          </ProFormItemV2>
        </ProFormColItem>
        <ProFormColItem :span="12">
          <ProFormItemV2
            label="年龄:"
            prop="age"
            :check-rules="[{ message: '请输入年龄', type: 'number' }]"
          >
            <ProFormInputNumber
              v-model="form.age"
              :controls="false"
              :min="0"
              :max="9999"
              placeholder="请输入年龄"
            >
              <template #readContent>
                <span v-if="form.age">{{ form.age }}岁</span>
                <span v-else></span>
              </template>
            </ProFormInputNumber>
          </ProFormItemV2>
        </ProFormColItem>
      </ProFormCol>
      <ProFormItemV2
        label="身份证正面:"
        prop="identityImg"
        :check-rules="[{ message: '请上传身份证正面', type: 'upload' }]"
      >
        <ProFormImageUpload
          v-model:file-url="form.identityImg"
          :limitFileSize="10"
          :showTip="false"
        >
        </ProFormImageUpload>
      </ProFormItemV2>
      <ProFormItemV2
        label="身份证反面:"
        prop="identityBackImg"
        :check-rules="[{ message: '请上传身份证反面', type: 'upload' }]"
      >
        <ProFormImageUpload
          v-model:file-url="form.identityBackImg"
          :limitFileSize="10"
          :showTip="false"
        >
        </ProFormImageUpload>
      </ProFormItemV2>
    </ProForm>
    <template #footer>
      <span class="dialog-footer">
        <el-button v-if="form.isDetail" @click="emit('onCancel')">关闭</el-button>
        <template v-else>
          <el-button type="primary" @click="handleConfirm">提交</el-button>
          <el-button @click="handleReset">重置</el-button>
          <el-button @click="emit('onCancel')">取消</el-button>
        </template>
      </span>
    </template>
  </ProDialog>
</template>
 
<script setup lang="ts">
import { FormInstance } from 'element-plus';
import {
  ProDialog,
  ProForm,
  ProFormItemV2,
  ProFormText,
  UploadUserFile,
  ProFormCol,
  ProFormColItem,
  ProFormImageUpload,
  ProFormRadio,
  ProFormUpload,
  ProFormInputNumber,
} from '@bole-core/components';
import { deepClone, format } from '@/utils';
import { EnumUserGender, EnumUserGenderTextForPerson } from '@/constants';
 
defineOptions({
  name: 'StaffInfoDialog',
});
 
type Form = {
  title?: string;
  id: string;
  name: string;
  identity: string;
  contactPhoneNumber: string;
  gender: EnumUserGender;
  age: number;
  identityImg: UploadUserFile[];
  identityBackImg: UploadUserFile[];
  contractUrl: UploadUserFile[];
  regiterTime: string;
  userRealTime: string;
  userSignContractTime: string;
  isDetail: boolean;
};
 
const visible = defineModel({ type: Boolean });
 
const form = defineModel<Form>('form');
let defaultForm: Form = null;
 
watch(
  visible,
  (visible) => {
    if (visible) {
      defaultForm = deepClone(unref(form));
    }
  },
  {
    immediate: true,
  }
);
 
const emit = defineEmits<{
  (e: 'onConfirm'): void;
  (e: 'onCancel'): void;
}>();
 
const dialogForm = ref<FormInstance>();
 
function onDialogClose() {
  if (!dialogForm.value) return;
  dialogForm.value.resetFields();
}
 
function handleConfirm() {
  if (!dialogForm.value) return;
  dialogForm.value.validate((valid) => {
    if (valid) {
      emit('onConfirm');
    } else {
      return;
    }
  });
}
 
function handleReset() {
  form.value = { ...defaultForm };
}
</script>