From cd2c2f66d76c4c1af5a15efdd4316b79f49c3169 Mon Sep 17 00:00:00 2001 From: luobisheng <727299681@qq.com> Date: 星期四, 17 十一月 2022 16:27:34 +0800 Subject: [PATCH] 短信修改 --- src/api/operate/messageManagement.js | 2 src/views/operate/sms/smsIndex/createSms/index.vue | 1 src/views/systemSetting/device/bayonet/index.vue | 4 src/api/system/portal/teamConstruction.js | 2 src/components/edit/index.vue | 23 +-- src/http/index.js | 91 +++------------ src/views/operate/message/myIndex/update/index.vue | 59 ++++----- src/api/system/bayonet.js | 2 src/views/layout/components/Header/index.vue | 6 - src/views/operate/log/index.vue | 2 src/views/operate/message/myIndex/index.vue | 124 ++++++------------- src/utils/helper.js | 12 +- 12 files changed, 110 insertions(+), 218 deletions(-) diff --git a/src/api/operate/messageManagement.js b/src/api/operate/messageManagement.js index 5c61cd8..c838dcb 100644 --- a/src/api/operate/messageManagement.js +++ b/src/api/operate/messageManagement.js @@ -1,7 +1,7 @@ import http from "@/http"; export function deleteMessage(params) { - return http.post('/sccg/message/delete', params); + return http.delete('/sccg/message/delete', params); } export function getMessageById(id) { diff --git a/src/api/system/bayonet.js b/src/api/system/bayonet.js index cd834a6..4b86582 100644 --- a/src/api/system/bayonet.js +++ b/src/api/system/bayonet.js @@ -1,7 +1,7 @@ import http from "@/http"; export default { getBayonetList: (params) => { return http.get('/sccg/equipment_bayonet/query', params); }, - exportBayonetList: (params) => { return http.get('/sccg/equipment_bayonet/export', params); }, + exportBayonetList: (params) => { return http.downloadFile('/sccg/equipment_bayonet/export', params); }, addBayonet: (params) => { return http.post('/sccg/equipment_bayonet/addition', params); }, updateBayonet: (params) => { return http.put('/sccg/equipment_bayonet/modification', params) } } diff --git a/src/api/system/portal/teamConstruction.js b/src/api/system/portal/teamConstruction.js index 8f97e82..f033b50 100644 --- a/src/api/system/portal/teamConstruction.js +++ b/src/api/system/portal/teamConstruction.js @@ -9,7 +9,7 @@ } export function exportTeamInfo(params) { - return http.post('/sccg/team_construction/export', {}, params); + return http.downloadFile('/sccg/team_construction/export', params); } export function importTeamInfo(data) { diff --git a/src/components/edit/index.vue b/src/components/edit/index.vue index 731175c..bfd92bf 100644 --- a/src/components/edit/index.vue +++ b/src/components/edit/index.vue @@ -4,27 +4,22 @@ </div> </template> <script> -import E from 'wangeditor' +import wangEditor from 'wangeditor' + export default { data() { return { editor: null } }, - props:['getMyBody'], mounted() { - this.editor = new E('#edit'); - this.editor.config.height = 450; - this.editor.config.colors = [ - '#4b9bb7', - '#09152f' - ] - - this.editor.config.onchange = (html)=>{ - // 绗簩姝ワ紝鐩戞帶鍙樺寲锛屽悓姝ユ洿鏂板埌 textarea - this.$emit('getMyBody', html); - } - this.editor.create(); + this.editor = new wangEditor('#edit'); + this.editor.customConfig = this.editor.config; + this.editor.customConfig.height = 450; + this.editor.customConfig.colors = ['#4b9bb7', '#09152f']; + this.editor.customConfig.placeholder = '璇疯緭鍏�'; + this.editor.customConfig.onchangeTimeout = 500; + this.editor.create(); }, beforeDestroy() { this.editor.destroy(); diff --git a/src/http/index.js b/src/http/index.js index 85f73d8..64dace5 100644 --- a/src/http/index.js +++ b/src/http/index.js @@ -1,12 +1,6 @@ import axios from 'axios' -import { - handleResponseSuccess, - handleResponseFail, - handleRequest -} from './interceptor-handler' -import { - showFullScreenLoading -} from '@/utils/loading' +import {handleRequest, handleResponseFail, handleResponseSuccess} from './interceptor-handler' +import {showFullScreenLoading} from '@/utils/loading' // URL 璁板綍鍣� import urlRecorder from './url-recorder' @@ -101,9 +95,10 @@ return axiosInstance(config) }, // DELETE鏇存柊鏁版嵁 - delete(url, data = {}, throwError) { + delete(url, params = {}, data = {}, throwError) { const config = { method: 'delete', + params, url, data: JSON.stringify(data), errorHandler: (!throwError && this.defaultErrorHandler) || null, @@ -119,79 +114,31 @@ return axiosInstance(config) }, /** - * 閫氳繃琛ㄥ崟get涓嬭浇鏂囦欢銆傚苟缁熶竴澶勭悊甯歌鐨勯敊璇� + * 閫氳繃琛ㄥ崟涓嬭浇鏂囦欢銆傚苟缁熶竴澶勭悊甯歌鐨勯敊璇� * @param {string} url - * @param {String} fileName 鏂囦欢鍚� + * @param params 浼犲弬 * @param {Object?} data 涓婁紶杩涘害鍥炶皟锛屽弬鏁颁负event * @param {Function?} throwError 鏄惁涓嶄娇鐢ㄩ粯璁ょ殑寮傚父澶勭悊鏂规硶锛岃�屾妸寮傚父鎶涘嚭鏉� * @return {Promise} 杩斿洖涓�涓猵romise瀵硅薄 */ - downloadFile(url, params, data = {}, throwError) { - const { - fileName, - type - } = params - return axiosInstance({ - method: 'GET', + downloadFile(url, params= {}, data = {}, throwError) { + const config = { + method: 'POST', url, - responseType: 'arraybuffer', + params, data: JSON.stringify(data), + responseType: 'arraybuffer', errorHandler: (!throwError && this.defaultErrorHandler) || null, - timeout: 50000, headers: { 'Content-Type': 'application/json' - } - }).then(response => { - const blob = new Blob([response], { - type - }) // 涓嶅吋瀹箃ype - // 鍒╃敤a鏍囩瀹炵幇涓嬭浇 - const link = document.createElement('a') - link.style.display = 'none' - link.setAttribute('type', MimeType) // 骞朵笉鏀寔 - const downUrl = window.URL.createObjectURL(blob) - link.href = downUrl - // 娣诲姞鍒版祻瑙堝櫒涓轰簡鍏煎 firefox - document.body.appendChild(link) - // 涓轰簡鍏煎qq娴忚鍣紝fileName涓繀椤诲姞涓婃枃浠跺悗缂� - link.download = fileName - link.click() - document.body.removeChild(link) - }) - }, - /** - * 閫氳繃a鏍囩鎵撳紑鏂囦欢 - * @param {string} url - */ - downloadFileByA(url) { - // const {fileName} = params - // 鍒╃敤a鏍囩瀹炵幇涓嬭浇 - const link = document.createElement('a') - link.style.display = 'none' - link.href = `${process.env.VUE_APP_DOWN_FILE}${url}` - // 娣诲姞鍒版祻瑙堝櫒涓轰簡鍏煎 firefox - document.body.appendChild(link) - // 涓轰簡鍏煎qq娴忚鍣紝fileName涓繀椤诲姞涓婃枃浠跺悗缂� - // link.download = fileName - link.click() - document.body.removeChild(link) - return Promise.resolve() - }, - /** - * 閫氳繃a鏍囩涓嬭浇鏂囦欢 - * @param {string} url - */ - downloadFileByAtag(url) { - // 鍒╃敤a鏍囩瀹炵幇涓嬭浇 - const link = document.createElement('a') - link.download = url - link.target = '_blank' - link.style.display = 'none' - link.href = url - document.body.appendChild(link) - link.click() - document.body.removeChild(link) - return Promise.resolve() + }, + withCredentials: this.withCredentials + } + urlRecorder.add(config) + if (data.showLoading === undefined) { + showFullScreenLoading() + } + return axiosInstance(config) }, /** * 閫氳繃琛ㄥ崟post涓婁紶鏂囦欢骞舵帴鏀秊son鏍煎紡鐨勬暟鎹�傚苟缁熶竴澶勭悊甯歌鐨勯敊璇� diff --git a/src/utils/helper.js b/src/utils/helper.js index 77baab7..621af9a 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -2,7 +2,7 @@ // 娣辨嫹璐� export function deepClone(obj) { let objClone = Array.isArray(obj) ? [] : {}; - if (obj && typeof obj === 'object' && obj != null) { + if (obj && typeof obj === 'object') { for (let key in obj) { if (obj.hasOwnProperty(key)) { if (obj[key] && typeof obj[key] === 'object') { @@ -49,18 +49,18 @@ // data: 鏂囦欢, contentDisposition锛氳姹傚ご涓枃浠剁殑鍚嶅瓧 // 榛樿涓嶇敤淇敼锛岀洿鎺ュ皢杩斿洖鐨剅es浼犲叆鍗冲彲 export function downloadFile(res) { - const blob = new Blob([res.data], { type: '.xlsx' }); + const blob = new Blob([res.data], { type: 'application/octet-stream' }); const fileName = res.contentDisposition.split(`''`)[1]; if (window.navigator && window.navigator.msSaveBlob) { - navigator.msSaveBlob(blob, fileName); + window.navigator.msSaveBlob(blob, fileName); } else { const link = document.createElement('a'); link.style.display = 'none'; - link.href = URL.createObjectURL(blob); - link.setAttribute('download', decodeURI(fileName)); + link.href = window.URL.createObjectURL(blob); + link.download = decodeURI(fileName); document.body.appendChild(link); link.click(); - URL.revokeObjectURL(link.href); + window.URL.revokeObjectURL(link.href); document.body.removeChild(link); } } diff --git a/src/views/layout/components/Header/index.vue b/src/views/layout/components/Header/index.vue index cc861e6..beefaf1 100644 --- a/src/views/layout/components/Header/index.vue +++ b/src/views/layout/components/Header/index.vue @@ -51,12 +51,6 @@ </el-card> </div> </div> - <!-- 璁剧疆 --> - <!-- <div class="menu-right__item btn"> - <el-tooltip effect="dark" content="璐︽埛璁剧疆" placement="bottom-end" :hide-after="1000"> - <i class="el-icon-s-tools"></i> - </el-tooltip> - </div> --> <!-- 閫�鍑虹櫥褰� --> <div class="menu-right__item btn" @click="loginout"> <el-tooltip effect="dark" content="閫�鍑虹櫥褰�" placement="bottom-end" :hide-after="1000"> diff --git a/src/views/operate/log/index.vue b/src/views/operate/log/index.vue index e691a20..adb83e7 100644 --- a/src/views/operate/log/index.vue +++ b/src/views/operate/log/index.vue @@ -147,7 +147,7 @@ </div> </template> <script> -import { getNowDate } from "@/utils/helper"; +import {downloadFile, getNowDate} from "@/utils/helper"; import helper from "@/utils/mydate"; import { parseTime } from "@/utils/index"; import { createNamespacedHelpers } from "vuex"; diff --git a/src/views/operate/message/myIndex/index.vue b/src/views/operate/message/myIndex/index.vue index 0bfa339..c9bcf54 100644 --- a/src/views/operate/message/myIndex/index.vue +++ b/src/views/operate/message/myIndex/index.vue @@ -34,7 +34,7 @@ <div class="mainContent"> <div class="main-nav"> <span>鏁版嵁鍒楄〃</span> - <el-button type="primary" icon="el-icon-plus" @click="dialogCreate = true">娣诲姞</el-button> + <el-button type="primary" icon="el-icon-plus" @click="handleOpera(null, 'create')">娣诲姞</el-button> </div> <!-- 鏁版嵁灞曠ず --> <el-table ref="multipleTable" @@ -48,17 +48,11 @@ </el-table-column> <el-table-column prop="head" label="鏍囬" min-width="10"> </el-table-column> - <el-table-column prop="updateTime" label="淇敼鏃堕棿" min-width="10"> - <template slot-scope="scope"> - <span>{{changeTime(scope.row)}}</span> - </template> + <el-table-column prop="createTime" label="淇敼鏃堕棿" min-width="10"> </el-table-column> - <el-table-column prop="targetFrom" label="鍙戝竷浜哄憳" min-width="15"> + <el-table-column prop="createUser" label="鍙戝竷浜哄憳" min-width="15"> </el-table-column> - <el-table-column prop="channelCode" label="娑堟伅鍒嗙被" min-width="10"> - <template slot-scope="scope"> - <span>{{ getMessageType(scope.row.channelCode) }}</span> - </template> + <el-table-column prop="messageTypeName" label="娑堟伅鍒嗙被" min-width="10"> </el-table-column> <el-table-column prop="status" label="鍙戝竷鐘舵��" min-width="5"> <template slot-scope="scope"> @@ -68,8 +62,8 @@ <el-table-column prop="operation" label="鎿嶄綔" min-width="15"> <template slot-scope="scope"> <div class="operation"> - <el-link icon="el-icon-view" :underline="false" @click="handleView(scope.row)">鏌ョ湅</el-link> - <el-link icon="el-icon-edit" class="leftPx" :underline="false" @click="handleEdit(scope.row)">缂栬緫</el-link> + <el-link icon="el-icon-view" :underline="false" @click="handleOpera(scope.row, 'view')">鏌ョ湅</el-link> + <el-link icon="el-icon-edit" class="leftPx" :underline="false" @click="handleOpera(scope.row, 'update')">缂栬緫</el-link> <el-link class="leftPx" icon="el-icon-delete-solid" :underline="false" @click="handleDelete([scope.row.id])">鍒犻櫎</el-link> </div> @@ -77,19 +71,8 @@ </el-table-column> </el-table> <!-- 鏂板缓娑堟伅 --> - <el-dialog title="鏂板缓娑堟伅" :visible.sync="dialogCreate" width="80%" - :before-close="handleConfirmClose"> - <MyEdit @closeMyDialog="closeDialog" :type="'create'" :myDataRow="null"></MyEdit> - </el-dialog> - <!-- 娑堟伅璇︽儏 --> - <el-dialog title="娑堟伅璇︽儏" :visible.sync="dialogView" v-if="dialogView" width="45%" - :before-close="handleClose"> - <MyView @closeDialog="closeDialog" :myDataRow="tableRowData">></MyView> - </el-dialog> - <!-- 缂栬緫椤甸潰 --> - <el-dialog title="缂栬緫娑堟伅" :visible.sync="dialogEdit" width="80%" - :before-close="handleClose"> - <MyEdit @closeDialog="closeDialog" :myDataRow="tableRowData" :type="'update'"></MyEdit> + <el-dialog :destroy-on-close="true" :key="dialogType" :title="getDialogTitle" :visible.sync="isShowDialog" width="80%"> + <my-edit @closeMyDialog="closeDialog" :type="dialogType" :myDataRow="tableRowData"></my-edit> </el-dialog> <!-- tools --> <div class="tools"> @@ -119,30 +102,41 @@ <el-dialog title="楂樼骇鍙傛暟" :visible.sync="isShowMoreParams" - width="30%" - :before-close="handleClose"> + width="30%"> </el-dialog> </main> </div> </template> <script> -import helper from '@/utils/mydate' import MyView from './myview' import MyEdit from './update' import { deleteMessage, getMessageById, getMessageList } from "@/api/operate/messageManagement"; -import {SUCCESS_CODE} from "@/utils"; export default { components: { MyView, MyEdit }, + computed: { + getDialogTitle() { + if (this.dialogType === 'create') { + return '鍒涘缓'; + } + + if (this.dialogType === 'update') { + return '鏇存柊'; + } + + if (this.dialogType === 'view') { + return '鏌ョ湅'; + } + } + }, data() { return { tableData: [], tableRowData: null, isShowMoreParams: false, - context: '', - dialogEdit: false, - dialogCreate: false, - dialogView: false, + context: null, + isShowDialog: false, + dialogType: false, totalNum: null, pageSize: 10, currentPage: 1, @@ -221,32 +215,24 @@ this.messageStatus = 2; this.messageType = '00'; this.context = ''; + this.getMessageList(); }, // 鏌ョ湅 - handleView(data){ + handleOpera(data, type){ this.tableRowData = data; - this.dialogView = true; - }, - - // 缂栬緫 - handleEdit(data){ - this.tableRowData = data; - this.dialogEdit = true; + this.dialogType = type; + this.isShowDialog = true; }, // 鍒犻櫎淇℃伅 handleDelete(idarr) { this.$confirm('纭鍒犻櫎?') .then(() => { - deleteMessage(idarr) - .then(({ code, message }) => { - if (code === SUCCESS_CODE) { - this.getMessageList(); - this.$message({ type: 'success', message }); - } else { - this.$message({ type: 'error', message }); - } + deleteMessage({ ids: idarr.join(',') }) + .then(() => { + this.getMessageList(); + this.$message.success('鎿嶄綔鎴愬姛'); }) .catch(err => { this.$message({ type: 'error', message: err }) }); }) @@ -262,8 +248,9 @@ head: this.context } getMessageList(messageParam) - .then(({ data }) => { - this.tableData = []; + .then(({ records, total }) => { + this.tableData = records; + this.totalNum = total; }) .catch(err => { this.$message({ type: 'error', message: err }); @@ -325,12 +312,6 @@ }) this.all = list.length === this.tableData.length; }, - - // 淇敼鏃堕棿鏍煎紡 - changeTime({ updateTime }) { - return helper(updateTime); - }, - // 鍏ㄩ�� selectAll() { this.$refs.multipleTable.toggleAllSelection(); @@ -362,33 +343,10 @@ this.isShowMoreParams = true; }, - // 鍏抽棴寮圭獥 - handleClose(done) { - done(); - }, - - // 纭鍏抽棴寮圭獥 - handleConfirmClose(done) { - this.$confirm('纭鍏抽棴?') - .then(_ => { - done(); - }) - .catch(err => { - }) - }, - // 鑷畾涔夊叧闂脊绐� - closeDialog({ flag, index }) { - this.dialogCreate = flag; - this.dialogView = flag; - if (index === 1) { - this.getMessageList(); - } - }, - - getMessageType(id) { - const result = this.typeList.find(item => item.id === id); - return result.columnName; + closeDialog() { + this.isShowDialog = false; + this.getMessageList(); } } } diff --git a/src/views/operate/message/myIndex/update/index.vue b/src/views/operate/message/myIndex/update/index.vue index bfea845..4af4865 100644 --- a/src/views/operate/message/myIndex/update/index.vue +++ b/src/views/operate/message/myIndex/update/index.vue @@ -13,8 +13,8 @@ <!-- 鎻愰啋鏂瑰紡 --> <el-form-item class="optionItem" label="鎻愰啋鏂瑰紡:" prop="channelCode"> <el-radio-group v-model="role.channelCode"> - <el-radio label="01">绔欏唴淇�</el-radio> - <el-radio label="02">閭欢</el-radio> + <el-radio label="01" value="01">绔欏唴淇�</el-radio> + <el-radio label="02" value="02">閭欢</el-radio> </el-radio-group> <span class="message-tip">(鐭俊鍙敤鏁�: 1000鏉�)</span> </el-form-item> @@ -75,7 +75,7 @@ </el-form-item> <!-- 娑堟伅鍐呭 --> <el-form-item class="optionItem" label="娑堟伅鍐呭:" prop="body"> - <MyEditor ref="edit" @getMyBody="getMyBody"></MyEditor> + <MyEditor ref="edit"></MyEditor> </el-form-item> <el-form-item> <div class="optionBtn"> @@ -133,18 +133,24 @@ import MyEditor from "@/components/edit"; import MyColumnAdd from "@/views/operate/message/mycontrol/createUser"; import MyColView from "../messageView"; -import { sendMessage, updateMessage } from "@/api/operate/messageManagement"; +import { sendMessage, updateMessage, getMessageById } from "@/api/operate/messageManagement"; export default { components: { MyEditor, MyColumnAdd, MyColView }, props: ["type", "myDataRow"], data() { + const validateEditor = (rule, value, callback) => { + if (value) { + callback(); + } else { + callback(new Error('璇疯緭鍏�')); + } + }; return { role: { messageType: "", head: "", targetTo: "", - targetFrom: null, body: "", channelCode: "01", }, @@ -163,8 +169,7 @@ body: [ { required: true, - trigger: ["blue", "change"], - message: "璇疯緭鍏ユ秷鎭唴瀹�", + validator: validateEditor }, ], }, @@ -187,8 +192,18 @@ this.getColumnList(); this.getDepartList(); this.getLoginUserInfo(); - if (this.type === "update" && this.myDataRow) { - this.role = this.myDataRow; + if (this.type !== "create" && this.myDataRow) { + getMessageById(this.myDataRow.id) + .then(res => { + this.role = res; + this.role.targetTo = `${this.role.targetTo.split(',').length}浜篳; + }) + .catch(err => this.$message.error(`${err}`)) + } + }, + mounted() { + if (this.type !== 'create') { + this.$refs.edit.editor.txt.append(this.myDataRow.body); } }, methods: { @@ -261,10 +276,10 @@ // 鏂板缓/淇濆瓨娑堟伅(1:鏂板缓,0淇濆瓨娑堟伅) handleSubmit(mystatus) { + this.role.body = this.$refs.edit.editor.txt.html(); this.$refs.user.validate((valid) => { if (valid) { - const { body, head, messageType, targetFrom, channelCode } = - this.role; + const { body, head, messageType, channelCode } = this.role; const params = { body, head, @@ -272,7 +287,6 @@ channelCode: `${channelCode}`, sendTime: new Date(), targetTo: this.checkedList.join(","), - targetFrom: `${targetFrom}`, status: mystatus, }; if (this.type === "create") { @@ -306,15 +320,9 @@ }); }, - // 鑾峰緱娑堟伅浣� - getMyBody(obj) { - this.role.body = obj; - }, - // 閲嶇疆琛ㄥ崟 handleReset() { this.$refs.edit.editor.txt.clear(); - this.setDepartList(); this.$refs.user.resetFields(); }, @@ -345,24 +353,15 @@ : channelCode === "02" ? "閭欢" : "鐭俊", - messageType: this.getColText(this.role.messageType), + messageType: this.role.messageType, targetTo: this.tempNameArr, - targetFrom: this.sendUser, + targetFrom: this.sendUser }; } else { this.$message({ type: "warning", message: "璇锋鏌ュ繀濉」" }); } }); - }, - - // 鑾峰緱鏍忕洰娑堟伅 - getColText(id) { - let str = ""; - this.colList.forEach((item) => { - item.id === id ? (str = item.columnName) : ""; - }); - return str; - }, + } }, }; </script> diff --git a/src/views/operate/sms/smsIndex/createSms/index.vue b/src/views/operate/sms/smsIndex/createSms/index.vue index 1c5fcce..fbc30d2 100644 --- a/src/views/operate/sms/smsIndex/createSms/index.vue +++ b/src/views/operate/sms/smsIndex/createSms/index.vue @@ -197,7 +197,6 @@ if (valid) { const params = Object.assign({}, this.role); params.targetTo = this.checkedList.join(','); - params.targetFrom = this.sendUser; params.status = mystatus; sendMessage(params) .then(() => { diff --git a/src/views/systemSetting/device/bayonet/index.vue b/src/views/systemSetting/device/bayonet/index.vue index 5117c56..1a69872 100644 --- a/src/views/systemSetting/device/bayonet/index.vue +++ b/src/views/systemSetting/device/bayonet/index.vue @@ -30,7 +30,7 @@ </main> <footer> <!-- 娣诲姞鍗″彛 --> - <el-dialog :title="getDialogTitle" :visible.sync="isShowDialog" width="60%" :before-close="handleClose"> + <el-dialog :destroy-on-close="true" :key="dialogType" :title="getDialogTitle" :visible.sync="isShowDialog" width="60%" :before-close="handleClose"> <MyCreate @closeDialog="closeDialog" :originalBayonet="originalBayonet" :isEdit="isEdit"></MyCreate> </el-dialog> </footer> @@ -40,7 +40,7 @@ import MyCreate from './create' import MyTable from '@/components/Table' import bayonet from "@/api/system/bayonet"; -import {downloadFile} from "@/utils/helper"; +import { downloadFile } from "@/utils/helper"; export default { components: { -- Gitblit v1.8.0