| | |
| | | <el-col :span="8"> |
| | | <el-form-item prop="agency.name" label="机构名称"> |
| | | <el-input |
| | | :disabled="isAbleEdit" |
| | | v-model="registerForm.agency.name" |
| | | size="large" |
| | | placeholder="请输入机构名称" |
| | |
| | | <el-col :span="8"> |
| | | <el-form-item prop="agency.creditCode" label="社会信用代码"> |
| | | <el-input |
| | | :disabled="isAbleEdit" |
| | | v-model="registerForm.agency.creditCode" |
| | | size="large" |
| | | placeholder="请输入社会信用代码" |
| | |
| | | <el-input |
| | | v-model="registerForm.agency.certNumber" |
| | | size="large" |
| | | placeholder="请输入机构负责人" |
| | | placeholder="请输入资质证书编号" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item prop="agency.business" label="申请的法定安全评价业务范围"> |
| | | <el-select v-model="registerForm.agency.business" placeholder="请选择业务范围" multiple size="large" style="width: 100%"> |
| | | <el-select :disabled="isAbleEdit" v-model="registerForm.agency.business" placeholder="请选择业务范围" multiple size="large" style="width: 100%"> |
| | | <el-option |
| | | v-for="item in state.busList" |
| | | :key="item.id" |
| | |
| | | <el-col :span="12"> |
| | | <el-form-item prop="username" label="登录用户名(字母+数字,长度在5-16之间)"> |
| | | <el-input |
| | | :disabled="state.title == '编辑'" |
| | | v-model.trim="registerForm.username" |
| | | size="large" |
| | | placeholder="请输入登录用户名" |
| | |
| | | type="primary" |
| | | style="width:40%;margin: 0 auto" |
| | | @click.prevent="handleRegister" |
| | | v-preReClick |
| | | > |
| | | <div v-if="state.title == '新增/注册'"> |
| | | <span v-if="!loading">注 册</span> |
| | |
| | | let { proxy } = getCurrentInstance() |
| | | import { Base64 } from 'js-base64' |
| | | import {getAgencyById} from "../../../api/sysUsers"; |
| | | import Cookies from "js-cookie"; |
| | | const emit = defineEmits(["getList"]); |
| | | |
| | | const props = { |
| | |
| | | confirmPassword: '' |
| | | } |
| | | }) |
| | | const isSuper = ref(false); |
| | | |
| | | const {registerForm} = toRefs(state); |
| | | const startUsername = ref(''); |
| | | const startPhone = ref(''); |
| | |
| | | if(!verifyPhone(value)){ |
| | | callback(new Error('手机号格式有误')) |
| | | }else{ |
| | | checkPhone({phone:value}).then((res)=>{ |
| | | let param = {} |
| | | if(state.title=='新增/注册') { |
| | | param = { |
| | | phone:value |
| | | } |
| | | }else if(state.title=='编辑'){ |
| | | param = { |
| | | phone:value, |
| | | id: state.registerForm.id |
| | | } |
| | | } |
| | | checkPhone(param).then((res)=>{ |
| | | if(res.data == false){ |
| | | callback(new Error('该手机号已被绑定用户,请更换其他手机号')) |
| | | }else{ |
| | |
| | | if(!verifyUsername(value)){ |
| | | callback(new Error('用户名须使用字母+数字,长度在5-16之间')) |
| | | }else{ |
| | | checkUserName({username:value}).then((res)=>{ |
| | | let param = {} |
| | | if(state.title=='新增/注册') { |
| | | param = { |
| | | username:value |
| | | } |
| | | }else if(state.title=='编辑'){ |
| | | param = { |
| | | username:value, |
| | | id: state.registerForm.id |
| | | } |
| | | } |
| | | checkUserName(param).then((res)=>{ |
| | | if(res.data == false){ |
| | | callback(new Error('用户名已被占用,请更换其他用户名')) |
| | | }else{ |
| | |
| | | const registerRef = ref(null) |
| | | |
| | | onMounted(()=>{ |
| | | getBusiness() |
| | | watchEffect(() => { |
| | | // 在副作用中调用 getArea() |
| | | getArea(); |
| | | }); |
| | | }) |
| | | if(getToken()){ |
| | | const userInfo = JSON.parse(Cookies.get('userInfo')) |
| | | if(userInfo.identity == 0){isSuper.value = true} |
| | | } |
| | | |
| | | getBusiness() |
| | | getArea() |
| | | // watchEffect(() => { |
| | | // // 在副作用中调用 getArea() |
| | | // getArea(); |
| | | // }); |
| | | }) |
| | | const isAbleEdit = ref(false); |
| | | const openDialog=(type, value)=>{ |
| | | state.title = type === 'add' ? '新增/注册' : type ==='edit' ? '编辑' : '查看' ; |
| | | getArea() |
| | | if(type === 'edit' || type == 'view') { |
| | | state.registerForm.id = value.id |
| | | state.registerForm.username = value.username |
| | | state.registerForm.phone = value.phone |
| | | startUsername.value = value.username |
| | | startPhone.value = value.phone |
| | | state.registerForm.agency.id = value.agencyId |
| | | startUsername.value = value.username |
| | | startPhone.value = value.phone |
| | | state.registerForm.agency.id = value.agencyId |
| | | if( isSuper.value){ |
| | | isAbleEdit.value = false |
| | | }else{ |
| | | isAbleEdit.value = true |
| | | } |
| | | getAgencyById({agencyId: value.agencyId}).then((res)=>{ |
| | | if(res.code == 200){ |
| | | const info = JSON.parse(JSON.stringify(res.data)) |
| | |
| | | state.registerForm.agency[i] = info[i] |
| | | } |
| | | } |
| | | getArea() |
| | | |
| | | state.registerForm.agency.business = info.business.split(',').map(Number) |
| | | if(state.registerForm.agency.attribute === 0){ |
| | | state.registerForm.agency.area = [info.city,info.district].filter(item => { return item && item.trim() }) |
| | |
| | | if (valid) { |
| | | loading.value = true; |
| | | if(state.title == '新增/注册'){ |
| | | const {confirmPassword, ...data} = state.registerForm |
| | | const {confirmPassword,id, ...data} = JSON.parse(JSON.stringify(state.registerForm)) |
| | | data.password = Base64.encode(data.password) |
| | | data.agency.business = data.agency.business.join(',') |
| | | delete data.agency.area |
| | | delete data.agency.id |
| | | register(data).then(res => { |
| | | if(res.code == 200){ |
| | | const username = state.registerForm.username |
| | |
| | | type: "success", |
| | | }).then(() => { |
| | | emit("getList") |
| | | |
| | | dialogVisible.value = false |
| | | state.registerForm.agency.attribute = 0 |
| | | proxy.$refs.registerRef.resetFields() |
| | | proxy.$refs.registerRef.clearValidate() |
| | | state.fileList = [] |
| | | loading.value = false |
| | | // router.push("/homePage") |
| | | }).catch(() => {}) |
| | | }else{ |
| | |
| | | loading.value = false |
| | | }) |
| | | }else { |
| | | const {confirmPassword, ...data} = state.registerForm |
| | | const {confirmPassword, ...data} = JSON.parse(JSON.stringify(state.registerForm)) |
| | | data.password = Base64.encode(data.password) |
| | | console.log('data',data) |
| | | data.agency.business = data.agency.business.join(',') |
| | |
| | | }) |
| | | emit("getList") |
| | | dialogVisible.value = false |
| | | state.registerForm.agency.attribute = 0 |
| | | proxy.$refs.registerRef.resetFields() |
| | | proxy.$refs.registerRef.clearValidate() |
| | | state.fileList = [] |
| | |
| | | } |
| | | |
| | | const closeDialog = ()=>{ |
| | | state.registerForm.agency.attribute = 0 |
| | | proxy.$refs.registerRef.resetFields() |
| | | proxy.$refs.registerRef.clearValidate() |
| | | state.fileList = [] |