| | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="5"> |
| | | <el-form-item label="别名" prop="aliasName"> |
| | | <el-form-item label="别名" prop="alias"> |
| | | <el-input |
| | | v-model="form.aliasName" |
| | | v-model="form.alias" |
| | | placeholder="请输入" |
| | | clearable |
| | | maxlength="50" |
| | |
| | | placeholder="请选择" |
| | | style="width: 100%" |
| | | clearable |
| | | @change="handleBirthDateChange" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="5"> |
| | | <el-form-item label="年龄" prop="age"> |
| | | <el-input-number |
| | | disabled |
| | | v-model="form.age" |
| | | :min="0" |
| | | :max="150" |
| | |
| | | clearable |
| | | style="width: 100%" |
| | | > |
| | | <el-option label="未婚" value="single" /> |
| | | <el-option label="已婚" value="married" /> |
| | | <el-option label="离异" value="divorced" /> |
| | | <el-option label="丧偶" value="widowed" /> |
| | | <el-option label="未婚" value="未婚" /> |
| | | <el-option label="已婚" value="已婚" /> |
| | | <el-option label="离异" value="离异" /> |
| | | <el-option label="丧偶" value="丧偶" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | |
| | | <el-row :gutter="24"> |
| | | <el-col :span="10"> |
| | | <el-form-item label="角色" prop="roleId"> |
| | | <el-select |
| | | v-model="form.roleId" |
| | | placeholder="请选择" |
| | | clearable |
| | | style="width: 100%" |
| | | > |
| | | <el-option |
| | | v-for="item in roleOptions" |
| | | :key="item.roleId" |
| | | :label="item.roleName" |
| | | :value="item.roleId" |
| | | :disabled="item.status == 1" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | |
| | | <script setup> |
| | | import { toRefs } from "vue"; |
| | | import dayjs from "dayjs"; |
| | | |
| | | const props = defineProps({ |
| | | form: { type: Object, required: true }, |
| | | operationType: { type: String, default: "add" }, |
| | | roleOptions: { type: Array, default: () => [] }, |
| | | }); |
| | | |
| | | const { form, operationType } = toRefs(props); |
| | | const { form, operationType, roleOptions } = toRefs(props); |
| | | |
| | | const calcAge = (birth) => { |
| | | if (!birth) return undefined; |
| | | const birthDay = dayjs(birth); |
| | | const now = dayjs(); |
| | | let age = now.year() - birthDay.year(); |
| | | if (now.month() < birthDay.month() || (now.month() === birthDay.month() && now.date() < birthDay.date())) { |
| | | age--; |
| | | } |
| | | return age; |
| | | }; |
| | | |
| | | const handleBirthDateChange = (val) => { |
| | | form.value.age = calcAge(val); |
| | | }; |
| | | </script> |
| | | |
| | | <style scoped> |