|
@@ -7,10 +7,27 @@
|
|
:destroy-on-close="false"
|
|
:destroy-on-close="false"
|
|
:close-on-click-modal="false"
|
|
:close-on-click-modal="false"
|
|
>
|
|
>
|
|
- <el-form ref="form" :rules="rules" :model="form" label-position="left" label-width="90px">
|
|
|
|
- <el-form-item prop="id" style="margin-bottom: 0;"> </el-form-item>
|
|
|
|
- <el-form-item v-if="checkRole([1])" label="绑定账号" prop="adminId" required>
|
|
|
|
- <el-select v-model="form.adminId" class="filter-item" placeholder="请选择账号" clearable filterable>
|
|
|
|
|
|
+ <el-form
|
|
|
|
+ ref="form"
|
|
|
|
+ :rules="rules"
|
|
|
|
+ :model="form"
|
|
|
|
+ label-position="left"
|
|
|
|
+ label-width="90px"
|
|
|
|
+ >
|
|
|
|
+ <el-form-item prop="id" style="margin-bottom: 0"> </el-form-item>
|
|
|
|
+ <el-form-item
|
|
|
|
+ v-if="checkRole([1])"
|
|
|
|
+ label="绑定账号"
|
|
|
|
+ prop="adminId"
|
|
|
|
+ required
|
|
|
|
+ >
|
|
|
|
+ <el-select
|
|
|
|
+ v-model="form.adminId"
|
|
|
|
+ class="filter-item"
|
|
|
|
+ placeholder="请选择账号"
|
|
|
|
+ clearable
|
|
|
|
+ filterable
|
|
|
|
+ >
|
|
<el-option
|
|
<el-option
|
|
v-for="item in userList"
|
|
v-for="item in userList"
|
|
:key="item.adminId"
|
|
:key="item.adminId"
|
|
@@ -20,39 +37,92 @@
|
|
</el-select>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label="姓名" prop="name">
|
|
<el-form-item label="姓名" prop="name">
|
|
- <el-input v-model="form.name" :disabled="nameReadOnly" placeholder="请输入姓名" maxlength="10" show-word-limit />
|
|
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="form.name"
|
|
|
|
+ :disabled="nameReadOnly"
|
|
|
|
+ placeholder="请输入姓名"
|
|
|
|
+ maxlength="10"
|
|
|
|
+ show-word-limit
|
|
|
|
+ />
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label="手机号" prop="phone">
|
|
<el-form-item label="手机号" prop="phone">
|
|
- <el-input v-model="form.phone" :disabled="phoneReadOnly" placeholder="请输入手机号" maxlength="11" show-word-limit />
|
|
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="form.phone"
|
|
|
|
+ :disabled="phoneReadOnly"
|
|
|
|
+ placeholder="请输入手机号"
|
|
|
|
+ maxlength="11"
|
|
|
|
+ show-word-limit
|
|
|
|
+ />
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label="身份证号" prop="idNumber">
|
|
<el-form-item label="身份证号" prop="idNumber">
|
|
- <el-input v-model="form.idNumber" :disabled="idNumberReadOnly" placeholder="请输入身份证号" maxlength="18" show-word-limit />
|
|
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="form.idNumber"
|
|
|
|
+ :disabled="idNumberReadOnly"
|
|
|
|
+ placeholder="请输入身份证号"
|
|
|
|
+ maxlength="18"
|
|
|
|
+ show-word-limit
|
|
|
|
+ />
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label="单位名称" prop="company">
|
|
<el-form-item label="单位名称" prop="company">
|
|
- <el-input v-model="form.company" placeholder="请输入单位名称" maxlength="20" show-word-limit />
|
|
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="form.company"
|
|
|
|
+ placeholder="请输入单位名称"
|
|
|
|
+ maxlength="20"
|
|
|
|
+ show-word-limit
|
|
|
|
+ />
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label="部门" prop="unitName">
|
|
<el-form-item label="部门" prop="unitName">
|
|
- <el-input v-model="form.unitName" placeholder="请输入部门" maxlength="20" show-word-limit />
|
|
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="form.unitName"
|
|
|
|
+ placeholder="请输入部门"
|
|
|
|
+ maxlength="20"
|
|
|
|
+ show-word-limit
|
|
|
|
+ />
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label="楼层" prop="floor" required>
|
|
<el-form-item label="楼层" prop="floor" required>
|
|
- <el-input v-model="form.floor" placeholder="请输入楼层" maxlength="10" />
|
|
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="form.floor"
|
|
|
|
+ placeholder="请输入楼层"
|
|
|
|
+ maxlength="10"
|
|
|
|
+ />
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label="房间号" prop="room">
|
|
<el-form-item label="房间号" prop="room">
|
|
- <el-input v-model="form.room" placeholder="请输入房间号" maxlength="20" show-word-limit />
|
|
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="form.room"
|
|
|
|
+ placeholder="请输入房间号"
|
|
|
|
+ maxlength="20"
|
|
|
|
+ show-word-limit
|
|
|
|
+ />
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label="显示标题" prop="showTitle" required>
|
|
<el-form-item label="显示标题" prop="showTitle" required>
|
|
- <el-input v-model="form.showTitle" placeholder="请输入显示标题" maxlength="20" show-word-limit />
|
|
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="form.showTitle"
|
|
|
|
+ placeholder="请输入显示标题"
|
|
|
|
+ maxlength="20"
|
|
|
|
+ show-word-limit
|
|
|
|
+ />
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label="区域" prop="selectAreaList" required>
|
|
<el-form-item label="区域" prop="selectAreaList" required>
|
|
- <el-select v-model="form.selectAreaList" class="filter-item" placeholder="请选择区域" @change="areaChange" clearable multiple filterable>
|
|
|
|
- <el-option v-for="item in areaList" :key="item.id" :label="item.name" :value="item.id" />
|
|
|
|
|
|
+ <el-select
|
|
|
|
+ v-model="form.selectAreaList"
|
|
|
|
+ class="filter-item"
|
|
|
|
+ placeholder="请选择区域"
|
|
|
|
+ @change="areaChange"
|
|
|
|
+ clearable
|
|
|
|
+ multiple
|
|
|
|
+ filterable
|
|
|
|
+ >
|
|
|
|
+ <el-option
|
|
|
|
+ v-for="item in areaList"
|
|
|
|
+ :key="item.id"
|
|
|
|
+ :label="item.name"
|
|
|
|
+ :value="item.id"
|
|
|
|
+ />
|
|
</el-select>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</el-form>
|
|
</el-form>
|
|
<div slot="footer" class="dialog-footer">
|
|
<div slot="footer" class="dialog-footer">
|
|
- <el-button @click="visible = false">
|
|
|
|
- 取消
|
|
|
|
- </el-button>
|
|
|
|
|
|
+ <el-button @click="visible = false"> 取消 </el-button>
|
|
<el-button type="primary" :loading="submitLoading" @click="submit">
|
|
<el-button type="primary" :loading="submitLoading" @click="submit">
|
|
确定
|
|
确定
|
|
</el-button>
|
|
</el-button>
|
|
@@ -61,19 +131,19 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import { checkRole } from '@/utils/checkRole'
|
|
|
|
-import { addOrUpdate } from '@/api/visitee'
|
|
|
|
|
|
+import { checkRole } from "@/utils/checkRole";
|
|
|
|
+import { addOrUpdate } from "@/api/visitee";
|
|
|
|
|
|
export default {
|
|
export default {
|
|
props: {
|
|
props: {
|
|
userList: {
|
|
userList: {
|
|
type: Array,
|
|
type: Array,
|
|
- default: () => []
|
|
|
|
|
|
+ default: () => [],
|
|
},
|
|
},
|
|
areaList: {
|
|
areaList: {
|
|
type: Array,
|
|
type: Array,
|
|
- default: () => []
|
|
|
|
- }
|
|
|
|
|
|
+ default: () => [],
|
|
|
|
+ },
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
@@ -91,171 +161,207 @@ export default {
|
|
floor: null,
|
|
floor: null,
|
|
room: null,
|
|
room: null,
|
|
showTitle: null,
|
|
showTitle: null,
|
|
- selectAreaList: []
|
|
|
|
|
|
+ selectAreaList: [],
|
|
},
|
|
},
|
|
visible: false,
|
|
visible: false,
|
|
submitLoading: false,
|
|
submitLoading: false,
|
|
- isEdit: false
|
|
|
|
- }
|
|
|
|
|
|
+ isEdit: false,
|
|
|
|
+ };
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
rules() {
|
|
rules() {
|
|
return {
|
|
return {
|
|
adminId: [
|
|
adminId: [
|
|
- { required: true, type: 'number', message: '不能为空!', trigger: ['change', 'blur'] }
|
|
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ type: "number",
|
|
|
|
+ message: "不能为空!",
|
|
|
|
+ trigger: ["change", "blur"],
|
|
|
|
+ },
|
|
],
|
|
],
|
|
phone: [
|
|
phone: [
|
|
- { required: false, len: 11, trigger: ['change', 'blur'], validator: (rule, value, callback) => {
|
|
|
|
- if (!value || this.phoneReadOnly) {
|
|
|
|
- return callback()
|
|
|
|
- }
|
|
|
|
- const reg = /^1[3-9]\d{9}$/
|
|
|
|
- if (!reg.test(value)) {
|
|
|
|
- return callback('手机号格式错误!')
|
|
|
|
- }
|
|
|
|
- return callback()
|
|
|
|
- } }
|
|
|
|
|
|
+ {
|
|
|
|
+ required: false,
|
|
|
|
+ len: 11,
|
|
|
|
+ trigger: ["change", "blur"],
|
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
|
+ if (!value || this.phoneReadOnly) {
|
|
|
|
+ return callback();
|
|
|
|
+ }
|
|
|
|
+ const reg = /^1[3-9]\d{9}$/;
|
|
|
|
+ if (!reg.test(value)) {
|
|
|
|
+ return callback("手机号格式错误!");
|
|
|
|
+ }
|
|
|
|
+ return callback();
|
|
|
|
+ },
|
|
|
|
+ },
|
|
],
|
|
],
|
|
idNumber: [
|
|
idNumber: [
|
|
- { required: false, max: 18, trigger: ['change', 'blur'], validator: (rule, value, callback) => {
|
|
|
|
- if (!value || this.idNumberReadOnly) {
|
|
|
|
- return callback()
|
|
|
|
- }
|
|
|
|
- if (value.length === 15) {
|
|
|
|
- const idreg = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/
|
|
|
|
- if (!idreg.test(value)) {
|
|
|
|
- return callback('身份证号格式错误!')
|
|
|
|
|
|
+ {
|
|
|
|
+ required: false,
|
|
|
|
+ max: 18,
|
|
|
|
+ trigger: ["change", "blur"],
|
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
|
+ if (!value || this.idNumberReadOnly) {
|
|
|
|
+ return callback();
|
|
}
|
|
}
|
|
- } else if (value.length === 18) {
|
|
|
|
- const idreg = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/
|
|
|
|
- if (!idreg.test(value)) {
|
|
|
|
- return callback('身份证号格式错误!')
|
|
|
|
|
|
+ if (value.length === 15) {
|
|
|
|
+ const idreg =
|
|
|
|
+ /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/;
|
|
|
|
+ if (!idreg.test(value)) {
|
|
|
|
+ return callback("身份证号格式错误!");
|
|
|
|
+ }
|
|
|
|
+ } else if (value.length === 18) {
|
|
|
|
+ const idreg =
|
|
|
|
+ /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
|
|
|
|
+ if (!idreg.test(value)) {
|
|
|
|
+ return callback("身份证号格式错误!");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return callback("身份证号位数错误!");
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- return callback('身份证号位数错误!')
|
|
|
|
- }
|
|
|
|
- return callback()
|
|
|
|
- } }
|
|
|
|
|
|
+ return callback();
|
|
|
|
+ },
|
|
|
|
+ },
|
|
],
|
|
],
|
|
floor: [
|
|
floor: [
|
|
{ required: true, whitespace: true, message: '不能为空!', trigger: ['change', 'blur'] },
|
|
{ required: true, whitespace: true, message: '不能为空!', trigger: ['change', 'blur'] },
|
|
|
|
+ {
|
|
|
|
+ pattern: /^[a-zA-Z0-9]+$/,
|
|
|
|
+ message: '楼层只能为整数或英文字母组合!',
|
|
|
|
+ trigger: ['change', 'blur']
|
|
|
|
+ }
|
|
],
|
|
],
|
|
showTitle: [
|
|
showTitle: [
|
|
- { required: true, whitespace: true, message: '不能为空!', trigger: ['change', 'blur'] }
|
|
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ whitespace: true,
|
|
|
|
+ message: "不能为空!",
|
|
|
|
+ trigger: ["change", "blur"],
|
|
|
|
+ },
|
|
],
|
|
],
|
|
selectAreaList: [
|
|
selectAreaList: [
|
|
- { required: true, type: 'array', message: '不能为空!', trigger: ['change', 'blur'] }
|
|
|
|
- ]
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ type: "array",
|
|
|
|
+ message: "不能为空!",
|
|
|
|
+ trigger: ["change", "blur"],
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ };
|
|
|
|
+ },
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
checkRole,
|
|
checkRole,
|
|
areaChange(e) {
|
|
areaChange(e) {
|
|
- this.$forceUpdate()
|
|
|
|
|
|
+ this.$forceUpdate();
|
|
},
|
|
},
|
|
open(obj) {
|
|
open(obj) {
|
|
- this.visible = true
|
|
|
|
- this.submitLoading = false
|
|
|
|
|
|
+ this.visible = true;
|
|
|
|
+ this.submitLoading = false;
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
- this.$refs.form.resetFields()
|
|
|
|
|
|
+ this.$refs.form.resetFields();
|
|
if (obj && Object.keys(obj).length > 0) {
|
|
if (obj && Object.keys(obj).length > 0) {
|
|
- const areas = obj.zoneIds
|
|
|
|
- delete obj.zoneIds
|
|
|
|
- delete obj.zoneNames
|
|
|
|
- this.form = obj
|
|
|
|
|
|
+ const areas = obj.zoneIds;
|
|
|
|
+ delete obj.zoneIds;
|
|
|
|
+ delete obj.zoneNames;
|
|
|
|
+ this.form = obj;
|
|
if (areas) {
|
|
if (areas) {
|
|
- this.form.selectAreaList = JSON.parse(areas)
|
|
|
|
|
|
+ this.form.selectAreaList = JSON.parse(areas);
|
|
} else {
|
|
} else {
|
|
- this.form.selectAreaList = [0]
|
|
|
|
|
|
+ this.form.selectAreaList = [0];
|
|
}
|
|
}
|
|
// console.info('form-->', this.form)
|
|
// console.info('form-->', this.form)
|
|
- this.isEdit = true
|
|
|
|
|
|
+ this.isEdit = true;
|
|
if (obj.name) {
|
|
if (obj.name) {
|
|
- this.nameReadOnly = true
|
|
|
|
|
|
+ this.nameReadOnly = true;
|
|
} else {
|
|
} else {
|
|
- this.nameReadOnly = false
|
|
|
|
|
|
+ this.nameReadOnly = false;
|
|
}
|
|
}
|
|
if (obj.phone) {
|
|
if (obj.phone) {
|
|
- this.phoneReadOnly = true
|
|
|
|
|
|
+ this.phoneReadOnly = true;
|
|
} else {
|
|
} else {
|
|
- this.phoneReadOnly = false
|
|
|
|
|
|
+ this.phoneReadOnly = false;
|
|
}
|
|
}
|
|
if (obj.idNumber) {
|
|
if (obj.idNumber) {
|
|
- this.idNumberReadOnly = true
|
|
|
|
|
|
+ this.idNumberReadOnly = true;
|
|
} else {
|
|
} else {
|
|
- this.idNumberReadOnly = false
|
|
|
|
|
|
+ this.idNumberReadOnly = false;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- this.isEdit = false
|
|
|
|
- this.nameReadOnly = false
|
|
|
|
- this.phoneReadOnly = false
|
|
|
|
- this.idNumberReadOnly = false
|
|
|
|
- this.form.selectAreaList = []
|
|
|
|
|
|
+ this.isEdit = false;
|
|
|
|
+ this.nameReadOnly = false;
|
|
|
|
+ this.phoneReadOnly = false;
|
|
|
|
+ this.idNumberReadOnly = false;
|
|
|
|
+ this.form.selectAreaList = [];
|
|
}
|
|
}
|
|
- })
|
|
|
|
|
|
+ });
|
|
},
|
|
},
|
|
submit(e) {
|
|
submit(e) {
|
|
- e.preventDefault()
|
|
|
|
- this.$refs.form.validate(async(valid) => {
|
|
|
|
|
|
+ e.preventDefault();
|
|
|
|
+ this.$refs.form.validate(async (valid) => {
|
|
if (!valid) {
|
|
if (!valid) {
|
|
- return false
|
|
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
if (this.submitLoading) {
|
|
if (this.submitLoading) {
|
|
- return
|
|
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
// if (!this.form.adminId) {
|
|
// if (!this.form.adminId) {
|
|
// this.form.adminId = this.$store.getters.adminId
|
|
// this.form.adminId = this.$store.getters.adminId
|
|
// }
|
|
// }
|
|
- delete this.form.createTime
|
|
|
|
- this.submitLoading = true
|
|
|
|
- let zoneIds = null
|
|
|
|
- let zoneNames = null
|
|
|
|
|
|
+ delete this.form.createTime;
|
|
|
|
+ this.submitLoading = true;
|
|
|
|
+ let zoneIds = null;
|
|
|
|
+ let zoneNames = null;
|
|
if (this.form.selectAreaList && this.form.selectAreaList.length > 0) {
|
|
if (this.form.selectAreaList && this.form.selectAreaList.length > 0) {
|
|
if (this.form.selectAreaList.indexOf(0) > -1) {
|
|
if (this.form.selectAreaList.indexOf(0) > -1) {
|
|
// 全部
|
|
// 全部
|
|
- zoneIds = null
|
|
|
|
- zoneNames = null
|
|
|
|
|
|
+ zoneIds = null;
|
|
|
|
+ zoneNames = null;
|
|
} else {
|
|
} else {
|
|
- const selectAreaList = this.areaList.filter(item => {
|
|
|
|
- return this.form.selectAreaList.findIndex(items => items && items === item.id) > -1
|
|
|
|
- })
|
|
|
|
- zoneIds = selectAreaList.map(item => item.id)
|
|
|
|
- zoneNames = selectAreaList.map(item => item.name)
|
|
|
|
|
|
+ const selectAreaList = this.areaList.filter((item) => {
|
|
|
|
+ return (
|
|
|
|
+ this.form.selectAreaList.findIndex(
|
|
|
|
+ (items) => items && items === item.id
|
|
|
|
+ ) > -1
|
|
|
|
+ );
|
|
|
|
+ });
|
|
|
|
+ zoneIds = selectAreaList.map((item) => item.id);
|
|
|
|
+ zoneNames = selectAreaList.map((item) => item.name);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
const params = {
|
|
const params = {
|
|
...this.form,
|
|
...this.form,
|
|
selectAreaList: null,
|
|
selectAreaList: null,
|
|
- zoneIds: zoneIds ? `[${zoneIds.join(',')}]` : null,
|
|
|
|
- zoneNames: zoneNames ? zoneNames.join(',') : null
|
|
|
|
- }
|
|
|
|
|
|
+ zoneIds: zoneIds ? `[${zoneIds.join(",")}]` : null,
|
|
|
|
+ zoneNames: zoneNames ? zoneNames.join(",") : null,
|
|
|
|
+ };
|
|
if (this.isEdit) {
|
|
if (this.isEdit) {
|
|
if (this.nameReadOnly) {
|
|
if (this.nameReadOnly) {
|
|
- params.name = null
|
|
|
|
|
|
+ params.name = null;
|
|
}
|
|
}
|
|
if (this.phoneReadOnly) {
|
|
if (this.phoneReadOnly) {
|
|
- params.phone = null
|
|
|
|
|
|
+ params.phone = null;
|
|
}
|
|
}
|
|
if (this.idNumberReadOnly) {
|
|
if (this.idNumberReadOnly) {
|
|
- params.idNumber = null
|
|
|
|
|
|
+ params.idNumber = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- await addOrUpdate(params)
|
|
|
|
- this.visible = false
|
|
|
|
- this.form.selectAreaList = []
|
|
|
|
- this.$emit('success', this.isEdit)
|
|
|
|
|
|
+ await addOrUpdate(params);
|
|
|
|
+ this.visible = false;
|
|
|
|
+ this.form.selectAreaList = [];
|
|
|
|
+ this.$emit("success", this.isEdit);
|
|
} catch (e) {
|
|
} catch (e) {
|
|
- this.$refs.form.resetFields()
|
|
|
|
- console.info('add', e)
|
|
|
|
|
|
+ this.$refs.form.resetFields();
|
|
|
|
+ console.info("add", e);
|
|
} finally {
|
|
} finally {
|
|
- this.submitLoading = false
|
|
|
|
|
|
+ this.submitLoading = false;
|
|
}
|
|
}
|
|
- })
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+};
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
<style scoped>
|