<template>
|
<div class="add-quotation">
|
<el-dialog
|
:title="editConfig.title + '用户'"
|
:visible.sync="isvisible"
|
:width="dialogWidth"
|
:before-close="handleClose"
|
append-to-body
|
custom-class="iframe-dialog"
|
>
|
<div class="drawerContent" style="overflow: auto">
|
<el-form ref="form" :rules="rules" :model="editConfig.form" label-position="right" label-width="100px">
|
<el-form-item label="用户名:" prop="userName">
|
<el-input
|
v-model="editConfig.form.userName"
|
:placeholder="editConfig.title == '添加' ? '请输入用户名' : '--'"
|
:disabled="editConfig.title == '添加' ? false : true"
|
></el-input>
|
</el-form-item>
|
<el-form-item v-if="editConfig.title == '添加'" label="密码:" prop="passWord">
|
<el-input v-model="editConfig.form.passWord" :placeholder="'请输入密码'"></el-input>
|
</el-form-item>
|
<el-form-item v-else label="密码:" prop="password">
|
<el-input v-model="editConfig.form.passsord" :placeholder="'******'" disabled></el-input>
|
</el-form-item>
|
<el-form-item label="手机号:" prop="phone">
|
<el-input
|
v-model="editConfig.form.phone"
|
:placeholder="editConfig.title == '添加' ? '请输入手机号' : '--'"
|
:disabled="editConfig.title == '添加' ? false : true"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="公司名称:" prop="companyName">
|
<el-input
|
v-model="editConfig.form.company"
|
:placeholder="editConfig.title == '添加' ? '请输入公司名称' : '--'"
|
:disabled="editConfig.title == '添加' ? false : true"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="联系人名称:" prop="companyContact">
|
<el-input
|
v-model="editConfig.form.companyContact"
|
:placeholder="editConfig.title == '添加' ? '请输入联系人名称' : '--'"
|
:disabled="editConfig.title == '添加' ? false : true"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="邮箱:" prop="companyEmail">
|
<el-input
|
v-model="editConfig.form.email"
|
:placeholder="editConfig.title == '添加' ? '请输入邮箱' : '--'"
|
:disabled="editConfig.title == '添加' ? false : true"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="行业:" prop="companyTrade">
|
<el-input
|
v-model="editConfig.form.companyTrade"
|
:placeholder="editConfig.title == '添加' ? '请输入行业' : '--'"
|
:disabled="editConfig.title == '添加' ? false : true"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="地区:" prop="companyProvince">
|
<el-input
|
v-model="editConfig.form.companyProvince"
|
:placeholder="editConfig.title == '添加' ? '请输入地区' : '--'"
|
:disabled="editConfig.title == '添加' ? false : true"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="用户等级:" prop="roleIDs">
|
<el-checkbox-group v-model="editConfig.form.roleIDs" :disabled="editConfig.title == '查看' ? true : false">
|
<el-checkbox v-for="role in roleList" :label="role.id" :key="role.id">{{ role.name }}</el-checkbox>
|
</el-checkbox-group>
|
</el-form-item>
|
</el-form>
|
</div>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="handleClose">取消</el-button>
|
<el-button v-if="editConfig.title == '查看' ? false : true" type="primary" @click="onSubmit('form')"
|
>确定</el-button
|
>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import { getRoleIDs, setUser, register } from "@/api/unifiedManage/userManage"
|
export default {
|
name: "EditUserInfo",
|
props: {
|
editCommonConfig: {
|
type: Object,
|
default: () => {
|
return {
|
visible: false,
|
title: "新建",
|
form: {
|
roleIDs: []
|
}
|
}
|
}
|
}
|
},
|
components: {},
|
computed: {},
|
data() {
|
return {
|
dialogWidth: "30%",
|
isvisible: false,
|
editConfig: this.editCommonConfig,
|
// form: {},
|
rules: {
|
userName: [{ required: true, message: "请输入用户名", trigger: "blur" }],
|
passWord: [{ required: true, message: "请输入密码", trigger: "blur" }],
|
phone: [{ required: true, message: "请输入手机号", trigger: "blur" }],
|
// companyName: [{ required: true, message: "请输入公司名称", trigger: "blur" }],
|
companyContact: [{ required: true, message: "请输入联系人名称", trigger: "blur" }],
|
roleIDs: [{ required: true, message: "请选择用户等级", trigger: "change" }]
|
},
|
roleList: [] // 用户等级
|
}
|
},
|
watch: {
|
isvisible(val) {
|
console.log("ssss")
|
if (val) {
|
// this.formInfo()
|
console.log(val)
|
// this.$refs.form.resetFields()
|
}
|
}
|
},
|
created() {
|
this.getDataInfo()
|
},
|
methods: {
|
handleClose() {
|
this.isvisible = false
|
},
|
// 获取等级信息
|
async getDataInfo() {
|
const rsp = await getRoleIDs({ useType: 1 })
|
if (rsp.code == 200) {
|
this.roleList = rsp.data ? rsp.data : []
|
}
|
},
|
// 确定
|
onSubmit(formName) {
|
this.$refs[formName].validate((valid) => {
|
console.log(valid)
|
if (valid) {
|
let requestUrl = this.editConfig.title == "添加" ? register : setUser
|
let param = this.saveParams()
|
requestUrl(param).then((reply) => {
|
if (reply && reply.code === 200) {
|
this.$message.success("保存成功")
|
this.handleClose()
|
this.$parent.getData()
|
}
|
})
|
}
|
})
|
},
|
saveParams() {
|
let params = {
|
userName: this.editConfig.form.userName || "",
|
passWord: this.editConfig.form.passWord || "",
|
dutyIDs: this.editConfig.form.dutyIDs,
|
id: this.editConfig.form.id,
|
nickName: this.editConfig.form.nickName || "",
|
phone: this.editConfig.form.phone || "",
|
roleIDs: this.editConfig.form.roleIDs,
|
companyCity: this.editConfig.form.companyCity || "",
|
companyContact: this.editConfig.form.companyContact || "",
|
companyEmail: this.editConfig.form.companyEmail || "",
|
companyName: this.editConfig.form.companyName || "",
|
companyProvince: this.editConfig.form.companyProvince || "",
|
companyTrade: this.editConfig.form.companyTrade || ""
|
}
|
return params
|
}
|
}
|
}
|
</script>
|
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
<style lang="scss" scoped>
|
::v-deep {
|
.iframe-dialog .el-dialog__body {
|
.drawerContent {
|
width: 80%;
|
padding: 20px 0;
|
margin: auto;
|
overflow: hidden;
|
margin-top: 15px;
|
// 溢出隐藏滚动条
|
scrollbar-width: none; /* firefox */
|
-ms-overflow-style: none; /* IE 10+ */
|
}
|
}
|
.el-dialog__footer {
|
background-color: #f5f5f5;
|
height: 55px;
|
line-height: 55px;
|
text-align: right;
|
padding-right: 20px;
|
}
|
.el-input__inner {
|
text-align: left;
|
}
|
}
|
</style>
|