From 0e0216cbe4e070206cb702db227aac42366fc543 Mon Sep 17 00:00:00 2001 From: zichen1019 <1510748736@qq.com> Date: Sun, 15 Aug 2021 17:35:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B9=B3=E8=A1=A1=E7=B3=BB?= =?UTF-8?q?=E6=95=B0=E8=A1=A8=E8=B0=83=E6=95=B4=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/upload.js | 16 +++++++++ src/service/uploadService.js | 12 +++++++ src/views/ysjl/3000/common/index.vue | 45 ++++++++++++++++++------- src/views/ysjl/3000/dj/common/phxsb.vue | 15 ++++----- 4 files changed, 66 insertions(+), 22 deletions(-) create mode 100644 src/api/upload.js create mode 100644 src/service/uploadService.js diff --git a/src/api/upload.js b/src/api/upload.js new file mode 100644 index 0000000..f550b5b --- /dev/null +++ b/src/api/upload.js @@ -0,0 +1,16 @@ +import preview from '@/utils/preview' + +export default { + /** + * 上传平衡系数Base64图片 + * @param data + * @return {AxiosPromise} + */ + uploadPhxsBase64File(data) { + return preview({ + url: '/upload/uploadPhxsBase64File', + method: 'post', + data + }) + } +} diff --git a/src/service/uploadService.js b/src/service/uploadService.js new file mode 100644 index 0000000..fa79644 --- /dev/null +++ b/src/service/uploadService.js @@ -0,0 +1,12 @@ +import upload from '@/api/upload' + +export default { + /** + * 上传平衡系数Base64图片 + * @param data + * @return {AxiosPromise} + */ + uploadPhxsBase64File(data) { + return upload.uploadPhxsBase64File(data) + } +} diff --git a/src/views/ysjl/3000/common/index.vue b/src/views/ysjl/3000/common/index.vue index 71c6a01..ebfb4ec 100644 --- a/src/views/ysjl/3000/common/index.vue +++ b/src/views/ysjl/3000/common/index.vue @@ -666,7 +666,7 @@ - + @@ -950,6 +950,13 @@ export default { this.signNameValue(data) }, saveYsjl(operation) { + if (operation !== 'add' && this.pic) { + this.uploadPhxsBase64File(operation) + } else { + this.buildSaveData(operation) + } + }, + buildSaveData(operation) { const tableData = [] let fubiao if (this.fromType === 5) { @@ -975,20 +982,14 @@ export default { this.save(operation, 'post', tableData, fubiao) } else if (operation === 'build') { this.ysjl.baogaobianhao = this.ysjl.jilubianhao - if ( - this.ysjl.jilubianhao && - this.ysjl.jilubianhao.indexOf('COPY') > -1 - ) { + if (this.ysjl.jilubianhao && this.ysjl.jilubianhao.indexOf('COPY') > -1) { this.$message({ type: 'error', message: '请先修改报告编号,不允许携带COPY标志生成报告!' }) return false } - if ( - this.ysjl.jianyanrenyuan === null || - this.ysjl.jianyanrenyuan === '' - ) { + if (this.ysjl.jianyanrenyuan === null || this.ysjl.jianyanrenyuan === '') { this.$message({ type: 'error', message: '请先签名再生成报告!' @@ -997,9 +998,7 @@ export default { } for (let i = 0; i < this.bgfyData.length; i++) { if (!this.bgfyData[i].jianjianyuan || !this.bgfyData[i].querenriqi) { - this.$message.error( - '请将检验项目中的监检人员及监检日期填写完毕,再生成报告!' - ) + this.$message.error('请将检验项目中的监检人员及监检日期填写完毕,再生成报告!') return false } } @@ -1008,7 +1007,6 @@ export default { this.save(operation, 'put', tableData, fubiao) } }, - save(operation, type, jyxm, fubiao) { if (this.fromType !== 5) this.ysjl.imagePath = this.$refs.table1.imgPath @@ -1043,6 +1041,7 @@ export default { this.ysjl.id = data this.param.ysjlId = data this.$message({ message: '保存成功', type: 'success' }) + this.uploadPhxsBase64File() // 刷新路由网址 this.common.reloadViewToUpdateYsjl(this.ysjl) } else if (operation === 'upd') { @@ -1070,6 +1069,23 @@ export default { } }, + /** + * 上传平衡系数表 + */ + uploadPhxsBase64File(operation) { + if (!this.pic) { + return false + } + this.uploadService.uploadPhxsBase64File({ + ysjlId: this.ysjl.id, + base64File: this.pic + }).then(() => { + if (operation !== 'add') { + this.buildSaveData(operation) + } + }) + }, + /** * 格式化监检员 */ @@ -1175,6 +1191,9 @@ export default { }, querySearchGzjz: function(queryString, cb, $index) { cb([this.dicGzjz[$index]]) + }, + loadPhxsImage(data) { + this.pic = data } } } diff --git a/src/views/ysjl/3000/dj/common/phxsb.vue b/src/views/ysjl/3000/dj/common/phxsb.vue index ac71651..42b424c 100644 --- a/src/views/ysjl/3000/dj/common/phxsb.vue +++ b/src/views/ysjl/3000/dj/common/phxsb.vue @@ -56,10 +56,6 @@ export default { type: Array, required: true }, - pic: { - type: String, - required: true - }, ysjlParam: { type: Object, required: true @@ -86,7 +82,6 @@ export default { chart: undefined, phxsX: [], phxsY: [], - imgPath: '', xAxis: ['30', '40', '45', '50', '60'], chartDataX: [], chartDataY: [] @@ -216,10 +211,12 @@ export default { ] } this.chart.setOption(option) - this.imgPath = this.chart.getDataURL({ - type: 'png', - pixelRatio: 1, - backgroundColor: '#fff' + this.chart.on('finished', () => { + this.$emit('loadPhxsImage', this.chart.getDataURL({ + type: 'png', + pixelRatio: 1, + backgroundColor: '#fff' + })) }) } }