|
@@ -16,8 +16,7 @@
|
|
|
size="mini"
|
|
|
placeholder="请输入手机号"
|
|
|
/>
|
|
|
- <el-select v-model="type" placeholder="请输入人员类型" size="mini">
|
|
|
- <el-option label="管理员" value="0" />
|
|
|
+ <el-select v-model="type" clearable placeholder="请输入人员类型" size="mini">
|
|
|
<el-option label="安装员" value="1" />
|
|
|
<el-option label="维护员" value="2" />
|
|
|
</el-select>
|
|
@@ -80,8 +79,8 @@
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
<el-dialog :title="title" :visible.sync="dialogFormVisible">
|
|
|
- <el-form ref="form" :model="form" label-width="120px">
|
|
|
- <el-form-item v-for="item in addInput" :key="item.type" :label="item.name" label-width="120px">
|
|
|
+ <el-form ref="form" :model="form" :rules="formRules" label-width="120px">
|
|
|
+ <el-form-item v-for="item in addInput" :key="item.type" :prop="item.type" :label="item.name" label-width="120px">
|
|
|
<el-input v-if="!item.select" v-model="form[item.type]" autocomplete="off" />
|
|
|
<el-select v-else v-model="form[item.type]" multiple :placeholder="item.select">
|
|
|
<el-option label="安装员" value="1" />
|
|
@@ -112,7 +111,7 @@
|
|
|
</el-form>
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
<el-button @click="dialogFormVisible = false">取 消</el-button>
|
|
|
- <el-button type="primary" @click="handleOk">确 定</el-button>
|
|
|
+ <el-button type="primary" @click="handleOk('form')">确 定</el-button>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
<el-dialog title="修改密码" :visible.sync="dialogFormPassVisible">
|
|
@@ -159,6 +158,7 @@ export default {
|
|
|
}
|
|
|
return {
|
|
|
form: {},
|
|
|
+ formRules: {},
|
|
|
addInput: [],
|
|
|
dialogFormVisible: false,
|
|
|
gridData: [],
|
|
@@ -232,18 +232,43 @@ export default {
|
|
|
loginName: '',
|
|
|
type: []
|
|
|
}
|
|
|
+ this.formRules = {
|
|
|
+ name: [
|
|
|
+ { required: true, message: '请输入人员名称', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ mobile: [
|
|
|
+ { required: true, message: '请输入人员手机', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ password: [
|
|
|
+ { required: true, message: '请输入人员密码', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ loginName: [
|
|
|
+ { required: true, message: '请输入人员登录名', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ type: [
|
|
|
+ { type: 'array', required: true, message: '请至少选择一个人员状态', trigger: 'change' }
|
|
|
+ ]
|
|
|
+ }
|
|
|
this.title = '添加人员'
|
|
|
this.handleType = 'add'
|
|
|
},
|
|
|
- handleOk() {
|
|
|
- this.form.type = this.form.type.join(',')
|
|
|
- if (this.handleType === 'add') {
|
|
|
- this.$store.dispatch('admin/addDeviceModifierData', this.form)
|
|
|
- }
|
|
|
- if (this.handleType === 'set') {
|
|
|
- this.$store.dispatch('admin/setDeviceModifierData', this.form)
|
|
|
- }
|
|
|
- this.dialogFormVisible = false
|
|
|
+ handleOk(formName) {
|
|
|
+ this.$refs[formName].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ this.form.type = this.form.type.join(',')
|
|
|
+ if (this.handleType === 'add') {
|
|
|
+ this.$store.dispatch('admin/addDeviceModifierData', this.form)
|
|
|
+ }
|
|
|
+ if (this.handleType === 'set') {
|
|
|
+ this.$store.dispatch('admin/setDeviceModifierData', this.form)
|
|
|
+ }
|
|
|
+ this.formRules = {}
|
|
|
+ this.dialogFormVisible = false
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
handlePassOk(formName) {
|
|
|
this.$refs[formName].validate((valid) => {
|
|
@@ -280,6 +305,17 @@ export default {
|
|
|
type: 'type',
|
|
|
select: '请选择人员类型'
|
|
|
}]
|
|
|
+ this.formRules = {
|
|
|
+ name: [
|
|
|
+ { required: true, message: '请输入人员名称', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ mobile: [
|
|
|
+ { required: true, message: '请输入人员手机', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ type: [
|
|
|
+ { type: 'array', required: true, message: '请至少选择一个人员状态', trigger: 'change' }
|
|
|
+ ]
|
|
|
+ }
|
|
|
this.form = {
|
|
|
id: row.id,
|
|
|
name: row.name,
|