From 919cf3e086c89141a2cabd4e92a1776f6b32679a Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Thu, 25 Nov 2021 19:57:18 +0800
Subject: [PATCH] 验收版本
---
pages/message/addMessage.vue | 263 +++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 227 insertions(+), 36 deletions(-)
diff --git a/pages/message/addMessage.vue b/pages/message/addMessage.vue
index c6b5675..743b3be 100644
--- a/pages/message/addMessage.vue
+++ b/pages/message/addMessage.vue
@@ -1,6 +1,8 @@
<template>
<view class="container">
- <view class='initiae-box'>
+
+ <view class="group-chat-box">
+
<u-form :model="form" ref="uForm">
<u-form-item label-width='132' prop="title" label="通知标题" :required="true">
@@ -11,14 +13,54 @@
<u-input type='textarea' v-model="form.content" placeholder="请输入通知内容" />
</u-form-item>
+ <u-form-item label-width='132' label="接收人">
+
+ <u-button slot="right" type="success" size="mini" @click="recipientClick">选择接收人</u-button>
+
+ <u-popup :closeable="true" v-model="recipientShow" mode="bottom" height="50%" border-radius="14">
+
+ <view>
+
+ <u-checkbox-group v-show="recipientList.length > 0" @change="checkboxGroupChange"
+ :wrap='true' :size="40">
+
+ <u-checkbox v-model="item.checked" v-for="(item, index) in recipientList" :key="index"
+ :name="item.id" shape="circle"
+ style="padding: 0 40rpx; height: 92rpx; position: relative; box-sizing: border-box;">
+
+ <view style="margin-left: 22rpx">
+ {{item.real_name}}
+ </view>
+
+ </u-checkbox>
+
+ </u-checkbox-group>
+
+ <view style=" height: 92rpx; padding: 0 40rpx;" v-show="recipientList.length == 0">
+
+ 暂无数据
+
+ </view>
+
+ </view>
+
+ </u-popup>
+
+ </u-form-item>
+
</u-form>
- <view>
- <u-button type="primary" @click="initiateClick" style="margin-top: 4%; width: 60%;">发送</u-button>
- </view>
- <view>
- <u-toast ref="uToast" />
- </view>
+
</view>
+
+ <view class="establish-box">
+ <u-button class="submit" type="primary" @click="initiateClick">发送
+ </u-button>
+ </view>
+
+ <view>
+ <u-toast ref="uToast" />
+ </view>
+
</view>
</template>
@@ -26,10 +68,13 @@
export default {
data() {
return {
+ recipientShow: false,
+ recipientList: [],
form: {
title: '',
- content: ''
+ content: '',
+ recipientData: []
},
rules: {
content: [{
@@ -57,11 +102,95 @@
},
mounted() {},
onReady() {
- this.$refs.uForm.setRules(this.rules);
+ this.$refs.uForm.setRules(this.rules);
},
methods: {
+ recipientClick() {
+
+ if (this.recipientList.length > 0) {
+ this.recipientShow = true;
+ return
+ }
+
+ var data = null;
+
+ if (this.$store.state.UserData.rname[0] ==
+ '保安公司管理员') {
+
+ data = {
+ type: 2,
+ deptid: this.$store.state.UserData.dept_id
+ }
+
+ uni.request({
+ url: this.$store.state.piAPI + "/blade-user/seleL",
+ method: "get",
+ data: data,
+ success: (res) => {
+
+ this.recipientList = []
+ res.data.data.forEach(item => {
+
+ if (item.id != this.$store.state
+ .UserData.user_id
+ ) {
+
+ item.checked = false;
+ this.recipientList.push(item)
+
+ }
+
+ })
+
+ this.recipientShow = true;
+
+ }
+ });
+
+
+ } else {
+
+ uni.request({
+ url: this.$store.state.piAPI + '/blade-user/pages?dispatch=0&jurisdiction=' + this.$store
+ .state.UserData.jurisdiction + '¤t=1&size=999999',
+ method: "get",
+ data: data,
+ success: (res) => {
+
+ console.log(res, 546)
+
+ this.recipientList = []
+ res.data.data.records.forEach(item => {
+
+ if (item.id != this.$store.state
+ .UserData.user_id
+ ) {
+
+ item.checked = false
+ item.real_name = item.realName
+ this.recipientList.push(item)
+
+ }
+
+ })
+
+ this.recipientShow = true;
+
+ }
+ });
+
+
+ }
+
+ },
+
+ checkboxGroupChange(e) {
+
+ this.form.recipientData = e
+
+ },
getCurrentTime() {
let date = new Date();
@@ -81,7 +210,28 @@
this.$refs.uForm.validate(valid => {
if (valid) {
-
+
+ if (this.form.recipientData.length == 0) {
+ this.$refs.uToast.show({
+ title: '请最少选择一个接收人',
+ })
+ return
+ }
+
+ var receivedNameStr = []
+
+ this.form.recipientData.forEach(it => {
+
+ this.recipientList.forEach(item => {
+
+ if (it.id == item.id) {
+ receivedNameStr.push(item.real_name)
+ }
+
+ })
+
+ })
+
uni.request({
url: this.$store.state.piAPI + "/blade-system/dept/detail",
method: "get",
@@ -91,46 +241,87 @@
success: (result) => {
var deptCategory = result.data.data.deptCategory;
-
- uni.request({
- url: this.$store.state.piAPI + "/blade-desk/notice/submit",
- method: "post",
- data: {
- title: this.form.title,
- content: this.form.content,
- category: deptCategory,
- deptId: result.data.data.deptCategory,
- releaseTime: this.getCurrentTime(),
- },
- success: (res) => {
- if (res.data.msg == "操作成功") {
- this.$refs.uToast.show({
- title: '新增通知成功',
- type: 'success',
- url: '/pages/message/message'
- })
- }
+
+ uni.request({
+ url: this.$store.state.piAPI + "/blade-desk/notice/submit",
+ method: "post",
+ data: {
+ type: 1,
+ title: this.form.title,
+ content: this.form.content,
+ category: deptCategory,
+ deptId: this.createData.dept_id,
+ releaseTime: this.getCurrentTime(),
+ receivedName: receivedNameStr.toString(),
+ receivedIds: this.form.recipientData.toString(),
+ },
+ success: (res) => {
+ if (res.data.msg == "操作成功") {
+ this.$refs.uToast.show({
+ title: '新增通知成功',
+ type: 'success',
+ url: '/pages/message/message'
+ })
}
- });
+ }
+ });
}
});
-
-
+
+
} else {
console.log('验证失败');
}
});
},
-
-
+
+
}
};
</script>
<style lang="scss">
- .initiae-box {
- padding: 0 30rpx;
+ .submit {
+ border: none;
+ width: 94%;
+ height: 86rpx;
+ line-height: 86rpx;
+ box-sizing: border-box;
+ border-radius: 15rpx;
+ color: #ffffff;
+ font-size: 38rpx;
+
+ }
+
+ .container {
+ height: 100%;
+
+ .group-chat-box {
+ height: calc(100% - 116rpx);
+ padding: 0 36rpx;
+ box-sizing: border-box;
+ overflow-y: auto;
+ }
+
+ .establish-box {
+ position: relative;
+ height: 116rpx;
+ background: #fff;
+ text-align: center;
+
+ uni-button {
+ margin: 0;
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ margin: auto;
+ }
+
+ }
+
}
</style>
--
Gitblit v1.9.3