| | |
| | | <template> |
| | | <el-form |
| | | :inline="false" |
| | | :model="formObj" |
| | | ref="formRef" |
| | | <FYForm |
| | | :form-info="_formInfo" |
| | | :rules="rules" |
| | | label-position="right" |
| | | label-width="150px" |
| | | :reset="active" |
| | | v-model:is-edit="_edit" |
| | | @submit="submit" |
| | | @cancel="cancel" |
| | | > |
| | | <!-- <el-form-item label="id" prop="GUID"> |
| | | <el-input clearable v-model="formObj.GUID" placeholder="id" /> |
| | | </el-form-item> --> |
| | | <template #form-item="{ formObj }"> |
| | | <!-- <el-form-item label="头像url" prop="HeadIconUrl"> |
| | | <el-input clearable v-model="formObj.HeadIconUrl" placeholder="头像url" /> |
| | | <el-input |
| | | clearable |
| | | v-model="formObj.HeadIconUrl" |
| | | placeholder="头像url" |
| | | /> |
| | | </el-form-item> --> |
| | | <el-form-item label="账户名" prop="acountname"> |
| | | <el-input clearable v-model="formObj.acountname" placeholder="账户名" /> |
| | |
| | | <el-input clearable v-model="formObj.realname" placeholder="用户昵称" /> |
| | | </el-form-item> |
| | | <el-form-item label="密码" prop="password"> |
| | | <el-col :span="18"> |
| | | <el-input |
| | | :disabled="true" |
| | | clearable |
| | | type="password" |
| | | v-model="formObj.password" |
| | | placeholder="默认密码123456" |
| | | /> |
| | | </el-col> |
| | | <el-col :span="6" v-if="!create"> |
| | | <el-row justify="end"> |
| | | <el-button type="danger" @click="onResetPw" :loading="pwLoading" |
| | | >重置密码</el-button |
| | | > |
| | | </el-row> |
| | | </el-col> |
| | | </el-form-item> |
| | | <!-- <el-form-item label="用户类型id" prop="UserTypeID"> |
| | | <el-input |
| | | clearable |
| | | v-model="formObj.UserTypeID" |
| | | placeholder="用户类型id" |
| | | /> |
| | | </el-form-item> --> |
| | | <el-form-item label="用户类型" prop="_usertype"> |
| | | <el-select v-model="formObj._usertype" placeholder="用户类型"> |
| | | <el-option |
| | | v-for="s in userTypes" |
| | | :key="s.value" |
| | | :label="s.label" |
| | | :value="s" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="所属企业" prop="departmentname"> |
| | | <FYOptionUserType |
| | | :allOption="false" |
| | | :initValue="false" |
| | | v-model:value="formObj._usertype" |
| | | ></FYOptionUserType> |
| | | <!-- <el-form-item label="所属企业" prop="departmentname"> |
| | | <el-input |
| | | clearable |
| | | v-model="formObj.departmentname" |
| | | placeholder="所属企业" |
| | | disabled |
| | | /> |
| | | </el-form-item> |
| | | </el-form-item> --> |
| | | <el-form-item label="是否可用" prop="isenable"> |
| | | <el-switch v-model="formObj.isenable" /> |
| | | <span style="margin-left: 16px">{{ |
| | |
| | | <el-form-item label="工号" prop="workno"> |
| | | <el-input clearable v-model="formObj.workno" placeholder="工号" /> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="手机" prop="telephone"> |
| | | <el-input |
| | | clearable |
| | |
| | | placeholder="手机" |
| | | /> |
| | | </el-form-item> |
| | | <!-- <el-form-item label="微信id" prop="WechatID"> |
| | | <el-input clearable v-model="formObj.WechatID" placeholder="微信id" /> |
| | | </el-form-item> --> |
| | | <el-form-item label="省/市/区/镇" prop="_locations"> |
| | | <!-- <el-form-item label="省/市/区/镇" prop="_locations"> |
| | | <el-cascader |
| | | v-model="formObj._locations" |
| | | :options="locations" |
| | |
| | | style="width: 280px" |
| | | :disabled="!create" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="场景类型" prop="_scenetype"> |
| | | <el-select |
| | | v-model="formObj._scenetype" |
| | | placeholder="场景类型" |
| | | > |
| | | <el-option |
| | | v-for="s in sceneTypes" |
| | | :key="s.value" |
| | | :label="s.label" |
| | | :value="s" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button |
| | | :disabled="!edit" |
| | | type="primary" |
| | | @click="onSubmit" |
| | | :loading="loading" |
| | | >提交</el-button |
| | | > |
| | | <el-button :disabled="!edit" @click="onReset">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </el-form-item> --> |
| | | <FYOptionScene |
| | | :allOption="false" |
| | | :type="1" |
| | | :initValue="false" |
| | | v-model:value="formObj._scenetype" |
| | | ></FYOptionScene> |
| | | </template> |
| | | </FYForm> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { defineProps, defineEmits, reactive, ref, watch } from 'vue'; |
| | | import { useFormConfirm } from '@/composables/formConfirm'; |
| | | import { enumUserNA } from '@/enum/user'; |
| | | import { enumScene, getSceneName } from '@/enum/scene'; |
| | | import { getSceneName } from '@/enum/scene'; |
| | | import { enumLocation } from '@/enum/location'; |
| | | import userApi from '@/api/fytz/userApi'; |
| | | |
| | |
| | | |
| | | const emit = defineEmits(['onSubmit', 'onCancel', 'update:isEdit']); |
| | | |
| | | const { formObj, formRef, edit, onSubmit, onReset } = useFormConfirm({ |
| | | defaultForm: { |
| | | isenable: true, |
| | | }, |
| | | submit: { |
| | | do: submit, |
| | | }, |
| | | cancel: { |
| | | do: cancel, |
| | | }, |
| | | }); |
| | | |
| | | const userTypes = reactive(enumUserNA()); |
| | | const sceneTypes = reactive(enumScene(1, false)); |
| | | const _formInfo = ref(); |
| | | const _edit = ref(false); |
| | | const locations = enumLocation(false); |
| | | const locationsProps = reactive({ |
| | | checkStrictly: true, |
| | | }); |
| | | const loading = ref(false); |
| | | |
| | | const rules = reactive({ |
| | | acountname: [ |
| | | { |
| | |
| | | trigger: 'blur', |
| | | }, |
| | | ], |
| | | password: [ |
| | | { |
| | | required: props.create, |
| | | message: '密码不能为空', |
| | | trigger: 'blur', |
| | | }, |
| | | ], |
| | | // password: [ |
| | | // { |
| | | // required: props.create, |
| | | // message: '密码不能为空', |
| | | // trigger: 'blur', |
| | | // }, |
| | | // ], |
| | | _usertype: [ |
| | | { |
| | | required: true, |
| | |
| | | value: s.usertypeid + '', |
| | | }; |
| | | |
| | | s._scenetype = { |
| | | label: getSceneName(s.extension2, 1), |
| | | value: s.extension2, |
| | | }; |
| | | s._scenetype = getSceneName(s.extension2, 1); |
| | | |
| | | s._locations = []; |
| | | // if (s.provincecode && s.provincecode.length > 0) |
| | | // s._locations.push([s.provincecode, s.provincename]); |
| | | // if (s.citycode && s.citycode.length > 0) |
| | | // s._locations.push([s.citycode, s.cityname]); |
| | | // if (s.districtcode && s.districtcode.length > 0) |
| | | // s._locations.push([s.districtcode, s.districtname]); |
| | | // if (s.towncode && s.towncode.length > 0) |
| | | // s._locations.push([s.towncode, s.townname]); |
| | | |
| | | return s; |
| | | } |
| | | |
| | | function createUser() { |
| | | loading.value = true; |
| | | function createUser(formObj, func) { |
| | | return userApi |
| | | .createUser(formObj.value) |
| | | .then(() => { |
| | | emit('onSubmit', formObj); |
| | | }) |
| | | .finally(() => { |
| | | loading.value = false; |
| | | func(); |
| | | }); |
| | | } |
| | | |
| | | function updateUser() { |
| | | loading.value = true; |
| | | function updateUser(formObj, func) { |
| | | return userApi |
| | | .updateUserInfo(formObj.value) |
| | | .then(() => { |
| | | emit('onSubmit', formObj); |
| | | }) |
| | | .finally(() => { |
| | | loading.value = false; |
| | | func(); |
| | | }); |
| | | } |
| | | |
| | | function submit() { |
| | | function submit(formObj, func) { |
| | | // 行政区划信息填充 |
| | | const a = formObj.value._locations; |
| | | if (a[0]) { |
| | |
| | | const c = formObj.value._scenetype; |
| | | formObj.value.extension2 = c.value; |
| | | |
| | | return props.create ? createUser() : updateUser(); |
| | | return props.create ? createUser(formObj, func) : updateUser(formObj, func); |
| | | } |
| | | |
| | | function cancel() { |
| | |
| | | watch( |
| | | () => props.formInfo, |
| | | (nValue) => { |
| | | formObj.value = parseUserInfo(nValue); |
| | | _formInfo.value = parseUserInfo(nValue); |
| | | } |
| | | ); |
| | | |
| | | watch( |
| | | () => props.active, |
| | | (nValue) => { |
| | | if (!nValue) { |
| | | onReset(); |
| | | } |
| | | } |
| | | ); |
| | | |
| | | watch(edit, (nValue) => { |
| | | watch(_edit, (nValue) => { |
| | | emit('update:isEdit', nValue); |
| | | }); |
| | | |
| | | const pwLoading = ref(false); |
| | | </script> |