From 7df5dc2411b541492e0263ad24b4f5ef9ca092dd Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Tue, 03 Aug 2021 14:29:24 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.105:10010/r/zhba_app

---
 pages/dispatch/issue.vue |  123 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 118 insertions(+), 5 deletions(-)

diff --git a/pages/dispatch/issue.vue b/pages/dispatch/issue.vue
index e72ff1a..932de42 100644
--- a/pages/dispatch/issue.vue
+++ b/pages/dispatch/issue.vue
@@ -1,6 +1,30 @@
 <template>
 	<view class="container">
-		开发中
+		<view class='initiae-box'>
+			<u-form :model="form" ref="uForm">
+
+				<u-form-item label-position='top' prop="content" label="指令内容" :required="true">
+					<u-input type='textarea' v-model="form.content" placeholder="请输入指令内容" />
+				</u-form-item>
+
+				<u-form-item label-position='top' prop="recipientText" label="指令接收人" :required="true">
+
+					<u-input v-model="form.recipientText" type="select" placeholder="请选择接收人" :border="false"
+						@click="recipientClick" />
+					<u-select v-model="recipientShow" mode="mutil-column-auto" :list="recipientList"
+						@confirm="recipientConfirm">
+					</u-select>
+
+				</u-form-item>
+
+			</u-form>
+			<view>
+				<u-button type="primary" @click="initiateClick">发送</u-button>
+			</view>
+			<view>
+				<u-toast ref="uToast" />
+			</view>
+		</view>
 	</view>
 </template>
 
@@ -8,20 +32,109 @@
 	export default {
 		data() {
 			return {
-			
+				recipientShow: false,
+				recipientList: [],
+
+				form: {
+					content: '',
+					recipient: '',
+					recipientText: ''
+				},
+				
+				rules: {
+					content: [{
+						min: 5,
+						required: true,
+						message: '指令内容不能少于5个字',
+						trigger: ['change', 'blur'],
+					}],
+					recipientText: [{
+						required: true,
+						message: '请选择接收人',
+						trigger: ['change', 'blur'],
+					}],
+					
+				},
 			};
 		},
 		onLoad() {
+			console.log(this.$store.state)
 		},
 		onReachBottom() {
 
 		},
-		mounted() {
+		mounted() {},
+		onReady() {
+			this.$refs.uForm.setRules(this.rules);
 		},
-		methods: {}
+		methods: {
+			recipientClick() {
+				uni.request({
+					url: this.$store.state.piAPI + "/blade-system/dept/lazy-tree-user-app?userId=" + this.$store
+						.state
+						.UserData.user_id,
+					method: "get",
+					data: {
+
+					},
+					success: (res) => {
+						this.recipientList = []
+						res.data.forEach(item => {
+							if (item.hasChildren) {
+								this.recipientList.push(item)
+							}
+						})
+						this.recipientShow = true;
+					}
+				});
+
+			},
+			recipientConfirm(e) {
+				if (e.length > 1) {
+					this.form.recipient = e[1].value
+					this.form.recipientText = e[1].label
+				} else {
+					this.form.recipient = e[0].value
+					this.form.recipientText = e[0].label
+				}
+
+			},
+			initiateClick() {
+				this.$refs.uForm.validate(valid => {
+					if (valid) {
+						uni.request({
+							url: this.$store.state.piAPI + "/directive/saveDirectiveAndFile",
+							method: "post",
+							data: {
+								// 接收
+								receiveDirectiveIds: this.form.recipient,
+								// 发送
+								sendDirectiveId: this.$store.state
+									.UserData.user_id,
+								content: this.form.content,
+							},
+							success: (res) => {
+								if (res.data.msg == "操作成功") {
+									this.$refs.uToast.show({
+										title: '指令下发成功',
+										type: 'success',
+										url: '/pages/dispatch/dispatch'
+									})
+								}
+							}
+						});
+					} else {
+						console.log('验证失败');
+					}
+				});
+			}
+		}
 	};
 </script>
 
+
 <style lang="scss">
-	
+	.initiae-box {
+		padding: 0 30rpx;
+	}
 </style>

--
Gitblit v1.9.3