<template>
|
<view class="container">
|
|
<view class="group-chat-box">
|
|
<u-form :model="form" ref="uForm">
|
|
<u-form-item label-width='132' prop="content" label="指令内容" :required="true">
|
<u-input type='textarea' v-model="form.content" placeholder="请输入指令内容" />
|
</u-form-item>
|
|
<u-form-item label-width='132' label="下发时间" :required="true">
|
<u-picker v-model="Timeshow" mode="time" :params="params" @confirm="setTime"></u-picker>
|
<u-input type='textarea' v-model="form.reportTime" placeholder="请选择下发时间" @click="Timeshow = true" />
|
</u-form-item>
|
|
<u-form-item label-width='158' prop="recipientText" label="指令接收人" :required="true">
|
|
<u-input type='textarea' v-model="form.recipientPeople" placeholder="请选择指令接收人"
|
@click="recipientClick" autoHeight />
|
|
<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>
|
|
<view class="establish-box">
|
|
<u-button class="submit" type="primary" @click="initiateClick">发送</u-button>
|
|
</view>
|
|
<view>
|
<u-toast ref="uToast" />
|
</view>
|
|
</view>
|
</template>
|
|
<script>
|
export default {
|
|
data() {
|
return {
|
recipientShow: false,
|
recipientList: [],
|
Timeshow:false,
|
params: {
|
year: true,
|
month: true,
|
day: true,
|
hour: true,
|
minute: false,
|
second: false
|
},
|
form: {
|
content: '',
|
recipient: '',
|
recipientData: [],
|
recipientPeople: '',
|
reportTime:""
|
},
|
rules: {
|
|
content: [{
|
min: 5,
|
required: true,
|
message: '指令内容不能少于5个字',
|
trigger: ['change', 'blur'],
|
}],
|
|
},
|
};
|
},
|
onLoad() {},
|
onReachBottom() {
|
|
},
|
mounted() {},
|
onReady() {
|
this.$refs.uForm.setRules(this.rules);
|
},
|
methods: {
|
setTime(res){
|
this.form.reportTime = res.year + "-" + res.month + "-" + res.day + " " + res.hour + ":00:00"
|
},
|
recipientClick() {
|
if (this.recipientList.length > 0) {
|
this.recipientShow = true;
|
return;
|
}
|
uni.request({
|
url: this.$store.state.piAPI + "/blade-user/seleL",
|
method: "get",
|
data: {
|
type: 1,
|
jurisdiction: this.$store.state
|
.UserData.jurisdiction,
|
},
|
success: (res) => {
|
this.recipientList = []
|
|
res.data.data.forEach(item => {
|
var flag = true
|
|
if (this.recipientList.length > 0) {
|
this.recipientList.forEach(it => {
|
if (item.id == it.id) flag = false
|
})
|
}
|
|
if (flag == true) {
|
if (item.id != this.$store.state
|
.UserData.user_id
|
) {
|
item.checked = false;
|
this.recipientList.push(item)
|
}
|
}
|
})
|
|
this.recipientShow = true;
|
}
|
});
|
|
},
|
|
initiateClick() {
|
|
this.$refs.uForm.validate(valid => {
|
if (valid) {
|
|
if (this.form.recipientData.length == 0) {
|
this.$refs.uToast.show({
|
title: '请最少选择一个接收人',
|
})
|
return
|
}
|
|
var str = '';
|
|
this.form.recipientData.forEach(item => {
|
str += item + ','
|
})
|
|
str = str.substr(0, str.length - 1);
|
|
uni.request({
|
url: this.$store.state.piAPI + "/directive/saveDirectiveAndFile",
|
method: "post",
|
data: {
|
// 接收
|
receiveDirectiveIds: str,
|
// 发送
|
sendDirectiveId: this.$store.state
|
.UserData.user_id,
|
content: this.form.content,
|
sendTime:this.form.reportTime
|
},
|
success: (res) => {
|
if (res.data.msg.indexOf('成功') != -1) {
|
this.$refs.uToast.show({
|
title: '指令下发成功',
|
type: 'success',
|
url: '/pages/dispatch/index'
|
})
|
}
|
}
|
});
|
} else {
|
console.log('验证失败');
|
}
|
});
|
},
|
|
checkboxGroupChange(e) {
|
var that = this
|
|
this.form.recipientData = e
|
|
var str = ""
|
var num = 0
|
|
that.form.recipientData.forEach((item, index) => {
|
that.recipientList.forEach((it, index) => {
|
if (item == it.id) {
|
if (num > 0) {
|
str += '、';
|
str += it.real_name;
|
} else {
|
str += it.real_name
|
}
|
num += 1
|
return
|
}
|
})
|
})
|
|
this.form.recipientPeople = str
|
},
|
|
}
|
};
|
</script>
|
|
|
<style lang="scss">
|
.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>
|