From 6efbb509b876e5e4ec634efa8820bd7b288c2283 Mon Sep 17 00:00:00 2001
From: zhouwenxuan <1175765986@qq.com>
Date: Tue, 06 Feb 2024 09:16:37 +0800
Subject: [PATCH] 分组
---
src/views/Admin/components/sameLevelMod.vue | 49 +++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 41 insertions(+), 8 deletions(-)
diff --git a/src/views/Admin/components/sameLevelMod.vue b/src/views/Admin/components/sameLevelMod.vue
index a86fd14..4c715cf 100644
--- a/src/views/Admin/components/sameLevelMod.vue
+++ b/src/views/Admin/components/sameLevelMod.vue
@@ -50,18 +50,34 @@
>
</a-tree-select>
</a-form-model-item>
+ <a-form-model-item label="选择分组" prop="peerRecipientGroupId">
+ <a-select v-model="form.peerRecipientGroupId" style="width: 100%">
+ <a-select-option v-for="item in groupData" :value="item.id" :key="item.id">{{item.name}}</a-select-option>
+ </a-select>
+ </a-form-model-item>
</a-form-model>
</a-modal>
</template>
<script>
-import {addRecipient, addUser, updateRecipient, updateUser} from "@/api/user";
-
+import {addRecipient, addUser, getSameLevelGroupList, updateRecipient, updateUser} from "@/api/user";
+import {verifySimplePhone} from "@/util/validate";
export default {
name: 'userMod',
props: [],
data () {
+ let validatePhone = (rule, value, callback)=>{
+ if(value === ''){
+ callback(new Error('请输入手机号'))
+ }else{
+ if(!verifySimplePhone(value)){
+ callback(new Error('手机号格式有误'))
+ }else{
+ callback()
+ }
+ }
+ }
return {
title: '新增用户',
visible: false,
@@ -69,6 +85,12 @@
labelCol: { span: 4 },
wrapperCol: { span: 14 },
areaData: [],
+ groupData: [
+ {
+ id: '',
+ name: '未分类'
+ }
+ ],
replaceFields: {
children:'children',
title:'name',
@@ -82,17 +104,19 @@
company: '',
phone: '',
unittype: null,
- districtId: null
+ districtId: null,
+ peerRecipientGroupId: null
},
rules: {
recipientName: [{ required: true, message: '请输入姓名或称呼', trigger: 'blur'}],
company: [{ required: true, message: '请输入单位名称(备注)', trigger: 'blur'}],
- phone: [{ required: true, message: '请输入手机号', trigger: 'blur'}]
+ phone: [{ required: true, validator: validatePhone, trigger: 'blur'}],
}
}
},
created() {
const t = this
+ t.getGroupList();
},
methods:{
openDialog(type,data){
@@ -105,7 +129,8 @@
company: '',
phone: '',
unittype: null,
- districtId: null
+ districtId: null,
+ peerRecipientGroupId: null
}
}else{
t.title = '编辑用户'
@@ -114,6 +139,7 @@
t.form[i] = data[i]
}
}
+ t.form.peerRecipientGroupId = data.peerRecipientGroupId ? data.peerRecipientGroupId: ''
}
t.visible = true
},
@@ -121,7 +147,15 @@
isValidKey(key, object){
return key in object;
},
-
+ async getGroupList () {
+ const t = this
+ const res = await getSameLevelGroupList();
+ if(res.data.code == 100){
+ t.groupData = t.groupData.concat(res.data.data)
+ }else{
+ this.$message.error(res.data.msg)
+ }
+ },
clearMod(){
this.$refs.ruleForm.clearValidate()
this.$refs.ruleForm.resetFields()
@@ -132,7 +166,6 @@
if (valid) {
if(this.title == '新增用户'){
const { id,...data } = this.form
- console.log(data,'data')
addRecipient(data).then((res)=>{
if(res.data.code == 100){
this.$message.success('新增平级接收人成功')
@@ -164,7 +197,7 @@
t.form.districtId = value
const code = t.findCodeById(t.areaData,value).code
if(code.length == 2){
- t.form.company = '自治区自然灾害预警中心'
+ t.form.company = '自治区自然灾害综合监测预警中心'
// t.form.province = t.findNodeByCode(t.areaData,code).name
// t.form.city = ''
// t.form.area = ''
--
Gitblit v1.9.2