From 2fc027c8c920f5227be5bf236476c20b97ff1e8f Mon Sep 17 00:00:00 2001 From: liuye Date: Wed, 15 Jun 2022 15:46:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B9=96=E5=8D=97=E5=85=AC=E5=AE=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/AiPagePicker.vue | 5 +- src/components/pages/selectDept.vue | 18 ++- src/components/pages/selectSysUser.vue | 7 +- .../AppMessageNotification.vue | 125 +++++++----------- .../AppMessageNotification/chooseUser.vue | 4 +- 5 files changed, 71 insertions(+), 88 deletions(-) diff --git a/src/components/AiPagePicker.vue b/src/components/AiPagePicker.vue index 78c6e241..d7520978 100644 --- a/src/components/AiPagePicker.vue +++ b/src/components/AiPagePicker.vue @@ -20,6 +20,7 @@ export default { value: {default: ""}, type: {default: "resident"}, nodeKey: {default: "idNumber"}, + isRequire: {default: 1}, selected: {default: () => []}, placeholder: {default: "选择人员"}, ops: {default: () => ({})}, @@ -48,7 +49,7 @@ export default { }, methods: { handleJump() { - let {config, nodeKey, valueObj} = this, + let {config, nodeKey, valueObj, isRequire} = this, selected = (valueObj ? this.value[nodeKey] : this.value) || this.selected?.map(e => e[nodeKey]) uni.$once('pagePicker:' + this.type, data => { console.log('发送', data) @@ -58,7 +59,7 @@ export default { }) let url = `${config.url}`, qsstr = qs.stringify({ - selected, nodeKey, ...this.$attrs + selected, nodeKey, isRequire, ...this.$attrs }) if (!!qsstr) { url += `?${qsstr}` diff --git a/src/components/pages/selectDept.vue b/src/components/pages/selectDept.vue index 8962cb40..b2a1daaa 100644 --- a/src/components/pages/selectDept.vue +++ b/src/components/pages/selectDept.vue @@ -48,6 +48,9 @@ export default { }, nodeKey() { return this.$route.query.nodeKey || "idNumber" + }, + isRequire() { + return this.$route.query.isRequire || 1 } }, onLoad(query) { @@ -86,12 +89,15 @@ export default { checkList.push(item) } }) - - uni.navigateBack({ - success: () => { - uni.$emit("pagePicker:dept", checkList) - } - }) + if (!checkList.length && this.isRequire == 1) { + return this.$u.toast('请先选择部门') + } else { + uni.navigateBack({ + success: () => { + uni.$emit("pagePicker:dept", checkList) + } + }) + } } }, } diff --git a/src/components/pages/selectSysUser.vue b/src/components/pages/selectSysUser.vue index e990c10c..8a69b755 100644 --- a/src/components/pages/selectSysUser.vue +++ b/src/components/pages/selectSysUser.vue @@ -51,7 +51,10 @@ export default { }, nodeKey() { return this.$route.query.nodeKey || "idNumber" - } + }, + isRequire() { + return this.$route.query.isRequire || 1 + }, }, onLoad(query) { if (query.selected) { @@ -92,7 +95,7 @@ export default { checkList.push(item) } }) - if (!checkList.length) { + if (!checkList.length && this.isRequire == 1) { return this.$u.toast('请先选择人员') } else { uni.navigateBack({ diff --git a/src/project/police/AppMessageNotification/AppMessageNotification.vue b/src/project/police/AppMessageNotification/AppMessageNotification.vue index 30b853a2..d6ce89d7 100644 --- a/src/project/police/AppMessageNotification/AppMessageNotification.vue +++ b/src/project/police/AppMessageNotification/AppMessageNotification.vue @@ -48,15 +48,15 @@

图片

- +

视频

- +

附件

- +
@@ -139,23 +139,14 @@ export default { ], form: { content: '', - contentType: 'text', sendType: '0', sendTime: '' }, - formData: { - fileListImg: [], - fileListVideo: [], - fileListFile: [], - fileList: [], - imgList: [], - accessImgurl: '', - accessTitle: '', - accessUrl: '', - accessAppid: '', - file: {}, - mediaId: '' - }, + formData: {}, + fileList: [], + fileListImg: [], + fileListVideo: [], + fileListFile: [], areaIdList: [], tagIdList: [], deptList: [], @@ -169,18 +160,40 @@ export default { minute: true, second: true }, - fileDataImg: null, - fileDataVideo: null, - fileDataFile: null } }, computed: {...mapState(['user'])}, methods: { - radioChange(e) { - // this.$nextTick(() => { - // this.form.contentType = e - // }) - }, + changeImg(e) { + this.$nextTick(() => { + this.fileListImg.map((item) => { + if(item.id == e.file.id) { + item.mediaId = e.media.mediaId + item.contentType = 'image' + } + }) + }) + }, + changeVideo(e) { + this.$nextTick(() => { + this.fileListVideo.map((item) => { + if(item.id == e.file.id) { + item.mediaId = e.media.mediaId + item.contentType = 'video' + } + }) + }) + }, + changeFile(e) { + this.$nextTick(() => { + this.fileListFile.map((item) => { + if(item.id == e.file.id) { + item.mediaId = e.media.mediaId + item.contentType = 'file' + } + }) + }) + }, toSelect() { uni.navigateTo({url: `./chooseUser?tagIdList=${this.tagIdList}&areaList=${this.areaIdList}&deptList=${this.deptList}&userList=${this.userList}`}) }, @@ -195,9 +208,6 @@ export default { } }, confirm() { - // if(!this.areaIdList.length) { - // return this.$u.toast('请选择用户') - // } this.$loading() if(this.form.sendType == 1 && !this.form.sendTime) { return this.$u.toast('请选择群发时间') @@ -205,57 +215,20 @@ export default { if(!this.form.content) { return this.$u.toast('请输入文本内容') } - if(this.form.contentType == 'image' && !this.formData.fileList.length) { - return this.$u.toast('请上传图片') - } - if(this.form.contentType == 'video' && !this.formData.fileList.length) { - return this.$u.toast('请上传视频') - } - if(this.form.contentType == 'file' && !this.formData.fileList.length) { - return this.$u.toast('请上传文件') - } - this.formData.fileList = [] + this.fileList = [] var contentFile = { content: this.form.content, contentType: 'text' } - // if(this.formData.fileList.length) { - // this.formData.file = this.formData.fileList[0] - // this.formData.accessUrl = this.formData.fileList[0].url - // this.formData.mediaId = this.fileData.media.mediaId - // } - this.formData.fileList.push(contentFile) - if(this.formData.fileListImg.length) { - var info = { - contentType: 'image', - mediaId: this.fileDataImg.media.mediaId, - accessUrl: this.formData.fileListImg[0].url - } - this.formData.fileList.push(info) - } - if(this.formData.fileListVideo.length) { - var info = { - contentType: 'video', - mediaId: this.fileDataVideo.media.mediaId, - accessUrl: this.formData.fileListVideo[0].url - } - this.formData.fileList.push(info) - } - if(this.formData.fileListFile.length) { - var info = { - contentType: 'file', - mediaId: this.fileDataFile.media.mediaId, - accessUrl: this.formData.fileListFile[0].url - } - this.formData.fileList.push(info) - } + this.fileList = [...this.fileListImg, ...this.fileListVideo, ...this.fileListFile] + this.fileList.unshift(contentFile) var params = { ...this.form, - ...this.formData, areaId: this.areaIdList.join(','), tag: this.tagIdList.join(','), deptList: this.deptList, - userList: this.userList + userList: this.userList, + fileList: this.fileList } this.$http.post("/app/pushmessage/addOrUpdate", params).then(res => { if (res?.code == 0) { @@ -277,13 +250,13 @@ export default { }) }, formDataInit() { - for(let key in this.formData) { - this.formData[key] = '' + for(let key in this.form) { + this.form[key] = '' } - this.formData.sendType = '0' - this.formData.fileListImg = [] - this.formData.fileListVideo = [] - this.formData.fileListFile = [] + this.form.sendType = '0' + this.fileListImg = [] + this.fileListVideo = [] + this.fileListFile = [] this.areaIdList = [] this.tagIdList = [] this.deptList = [] diff --git a/src/project/police/AppMessageNotification/chooseUser.vue b/src/project/police/AppMessageNotification/chooseUser.vue index a34b7ddc..e44a9b29 100644 --- a/src/project/police/AppMessageNotification/chooseUser.vue +++ b/src/project/police/AppMessageNotification/chooseUser.vue @@ -12,7 +12,7 @@

部门

- +
@@ -20,7 +20,7 @@

人员

- +