| | |
| | | <template> |
| | | <FYForm |
| | | :form-info="_formInfo" |
| | | :form-info="formInfo" |
| | | :rules="rules" |
| | | :reset="active" |
| | | :doClear="active" |
| | | :useCancel="create" |
| | | :useReset="!create" |
| | | :clearAftSubmit="create" |
| | | v-model:is-edit="_edit" |
| | | @updateEdit="(v) => $emit('updateEdit', v)" |
| | | @submit="submit" |
| | | @cancel="cancel" |
| | | @cancel="$emit('onCancel')" |
| | | > |
| | | <template #form-item="{ formObj }"> |
| | | <!-- <el-form-item label="头像url" prop="HeadIconUrl"> |
| | |
| | | v-if="create" |
| | | prop="_locations" |
| | | :allOption="false" |
| | | :level="4" |
| | | :checkStrictly="false" |
| | | :level="5" |
| | | :checkStrictly="true" |
| | | :initValue="false" |
| | | v-model:value="formObj._locations" |
| | | ></FYOptionLocation> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { defineProps, defineEmits, reactive, ref, watch } from 'vue'; |
| | | import { defineProps, defineEmits, reactive, ref, watch, computed } from 'vue'; |
| | | import { getSceneName } from '@/enum/scene'; |
| | | import { enumLocation } from '@/enum/location'; |
| | | import userApi from '@/api/fytz/userApi'; |
| | | import { useMessageBoxTip } from '@/composables/messageBox'; |
| | | |
| | | const props = defineProps({ |
| | | //基本信息 |
| | | formInfo: Object, |
| | | isEdit: Boolean, |
| | | model: { |
| | | type: Object |
| | | // default: () => { |
| | | // return { isenable: true }; |
| | | // } |
| | | }, |
| | | create: { |
| | | type: Boolean, |
| | | default: false |
| | |
| | | } |
| | | }); |
| | | |
| | | const emit = defineEmits(['onSubmit', 'onCancel', 'update:isEdit']); |
| | | const formInfo = ref({ isenable: true }); |
| | | |
| | | const _formInfo = ref({ isenable: true }); |
| | | const _edit = ref(false); |
| | | watch( |
| | | () => props.model, |
| | | (nValue) => { |
| | | formInfo.value = parseUserInfo(nValue); |
| | | } |
| | | ); |
| | | |
| | | const emit = defineEmits(['onSubmit', 'onCancel', 'updateEdit']); |
| | | |
| | | const rules = reactive({ |
| | | acountname: [ |
| | | { |
| | |
| | | message: '用户昵称不能为空', |
| | | trigger: 'blur' |
| | | } |
| | | ], |
| | | ] |
| | | // password: [ |
| | | // { |
| | | // required: props.create, |
| | |
| | | // trigger: 'blur', |
| | | // }, |
| | | // ], |
| | | _usertype: [ |
| | | { |
| | | required: true, |
| | | message: '用户类型不能为空', |
| | | trigger: 'change' |
| | | } |
| | | ], |
| | | _locations: [ |
| | | { |
| | | required: props.create, |
| | | message: '省/市/区/镇不能为空', |
| | | trigger: 'change' |
| | | } |
| | | ], |
| | | _scenetype: [ |
| | | { |
| | | required: true, |
| | | message: '场景类型不能为空', |
| | | trigger: 'change' |
| | | } |
| | | ] |
| | | }); |
| | | |
| | | // 用户基本信息格式化 |
| | | function parseUserInfo(s) { |
| | | s._usertype = { |
| | | label: s.usertype, |
| | | value: s.usertypeid + '' |
| | | }; |
| | | if (s.usertype && s.usertypeid) { |
| | | s._usertype = { |
| | | label: s.usertype, |
| | | value: s.usertypeid + '' |
| | | }; |
| | | } |
| | | |
| | | s._scenetype = getSceneName(s.extension2, 1); |
| | | if (s.extension2) { |
| | | s._scenetype = getSceneName(s.extension2, 1); |
| | | } |
| | | |
| | | s._locations = []; |
| | | s._locations = {}; |
| | | |
| | | return s; |
| | | } |
| | | |
| | | function parseUserInfoReverse(formObj) { |
| | | function parseUserInfoReverse(v) { |
| | | // 行政区划信息填充 |
| | | const a = formObj.value._locations; |
| | | formObj.value.provincecode = a.pCode; |
| | | formObj.value.provincename = a.pName; |
| | | formObj.value.citycode = a.cCode; |
| | | formObj.value.cityname = a.cName; |
| | | formObj.value.districtcode = a.dCode; |
| | | formObj.value.extension1 = a.dName; |
| | | formObj.value.towncode = a.tCode; |
| | | formObj.value.townname = a.tName; |
| | | const a = v._locations; |
| | | v.extension1 = a.dName; |
| | | // 用户类型信息填充 |
| | | const b = formObj.value._usertype; |
| | | formObj.value.usertypeid = b.value; |
| | | formObj.value.usertype = b.label; |
| | | const b = v._usertype; |
| | | v.usertypeid = b.value; |
| | | v.usertype = b.label; |
| | | |
| | | // 场景类型信息填充 |
| | | const c = formObj.value._scenetype; |
| | | formObj.value.extension2 = c.value; |
| | | const c = v._scenetype; |
| | | v.extension2 = c.value; |
| | | |
| | | return formObj; |
| | | return v; |
| | | } |
| | | |
| | | function createUser(formObj, success, fail) { |
| | | function createUser(v, success, fail) { |
| | | const l = v._locations; |
| | | const params = { |
| | | userInfo: formObj.value, |
| | | userInfo: v, |
| | | baseInfo: { |
| | | biProvinceCode: formObj.value.provincecode, |
| | | biProvinceName: formObj.value.provincename, |
| | | biCityCode: formObj.value.citycode, |
| | | biCityName: formObj.value.cityname, |
| | | biDistrictCode: formObj.value.districtcode, |
| | | biDistrictName: formObj.value.extension1, |
| | | biTownCode: formObj.value.towncode, |
| | | biTownName: formObj.value.townname |
| | | // biAreaCode |
| | | // biArea |
| | | // biManagementCompanyId |
| | | // biManagementCompany |
| | | biProvinceCode: l.pCode, |
| | | biProvinceName: l.pName, |
| | | biCityCode: l.cCode, |
| | | biCityName: l.cName, |
| | | biDistrictCode: l.dCode, |
| | | biDistrictName: l.dName, |
| | | biTownCode: l.tCode, |
| | | biTownName: l.tName, |
| | | biAreaCode: l.aCode, |
| | | biArea: l.aName |
| | | // biManagementCompanyId: |
| | | // biManagementCompany: |
| | | // biContact |
| | | // biTelephone |
| | | // biAddress |
| | |
| | | }); |
| | | } |
| | | |
| | | function updateUser(formObj, success, fail) { |
| | | function updateUser(v, success, fail) { |
| | | return userApi |
| | | .updateUserInfo(formObj.value) |
| | | .updateUserInfo(v) |
| | | .then(() => { |
| | | emit('onSubmit', formObj); |
| | | emit('onSubmit', v); |
| | | if (success) success(); |
| | | }) |
| | | .catch((err) => { |
| | |
| | | }); |
| | | } |
| | | |
| | | function submit(formObj, success, fail) { |
| | | parseUserInfoReverse(formObj); |
| | | function submit(v, success, fail) { |
| | | parseUserInfoReverse(v.value); |
| | | |
| | | return props.create ? createUser(formObj, success, fail) : updateUser(formObj, success, fail); |
| | | return props.create ? createUser(v.value, success, fail) : updateUser(v.value, success, fail); |
| | | // parseUserInfoReverse(props.formInfo); |
| | | |
| | | // return props.create |
| | | // ? createUser(props.formInfo, success, fail) |
| | | // : updateUser(props.formInfo, success, fail); |
| | | } |
| | | |
| | | function cancel() { |
| | | emit('onCancel'); |
| | | } |
| | | |
| | | watch( |
| | | () => props.formInfo, |
| | | (nValue) => { |
| | | _formInfo.value = parseUserInfo(nValue); |
| | | } |
| | | ); |
| | | |
| | | // watch( |
| | | // () => props.create, |
| | | // (nValue) => { |
| | | // if (nValue) { |
| | | |
| | | // } |
| | | // }, |
| | | // {immediate:true} |
| | | // ); |
| | | |
| | | watch(_edit, (nValue) => { |
| | | emit('update:isEdit', nValue); |
| | | }); |
| | | |
| | | // 重置密码 |
| | | |
| | | const pwLoading = ref(false); |
| | | |
| | | function onResetPw() { |
| | |
| | | confirmTitle: '重置密码', |
| | | onConfirm: async () => { |
| | | pwLoading.value = true; |
| | | return userApi.resetPassword(props.formInfo.guid).finally(() => { |
| | | return userApi.resetPassword(formInfo.value.guid).finally(() => { |
| | | pwLoading.value = false; |
| | | }); |
| | | } |