From 142ba3ed00220dcadf2a94e59664d5f1f027dbf4 Mon Sep 17 00:00:00 2001 From: licp <lichunping@guanfang.com.cn> Date: 星期三, 05 六月 2024 14:58:26 +0800 Subject: [PATCH] 新增附件上传 --- src/components/do/b1-ins-order/add.vue | 105 ++++++++++++++++- src/view/notice.vue | 4 src/main.js | 10 + src/util/file.js | 20 +++ src/components/do/b1-inspect-order-plan/Inspection.vue | 171 +++++++++++++++++++++++++++ src/components/do/b3-work-time-management/work-time-management.vue | 1 src/components/do/b3-work-time-management/work-time-statistics.vue | 30 ++++- src/components/view/a6-device-management.vue | 2 src/assets/api/controller.js | 6 + 9 files changed, 326 insertions(+), 23 deletions(-) diff --git a/src/assets/api/controller.js b/src/assets/api/controller.js index e4d62e7..2f5338c 100644 --- a/src/assets/api/controller.js +++ b/src/assets/api/controller.js @@ -180,6 +180,11 @@ submitPlan: "/insOrderPlan/submitPlan", //妫�楠屼换鍔℃彁浜� inspectionOrderDetailsTaskSwitching: "/insOrderPlan/inspectionOrderDetailsTaskSwitching", // 妫�楠屽崟璇︽儏-浠诲姟鍒囨崲 getInsProduct: "/insOrderPlan/getInsProduct", // 鑾峰彇妫�楠岄」鐩拰妯℃澘鍐呭 + getFileList: "/insOrderPlan/getFileList", // 鏌ョ湅妫�楠屽崟涓嬬殑闄勪欢鍒楄〃 + delfile: "/insOrderPlan/delfile", // 闄勪欢鍒犻櫎 + uploadFile: "/insOrderPlan/uploadFile", // 闄勪欢涓婁紶 + downFile: "/insOrderPlan/downFile", // 闄勪欢涓嬭浇 + checkSubmitPlan: "/insOrderPlan/checkSubmitPlan", // 鏍¢獙妫�楠屼换鍔℃彁浜� } const systemLog = { @@ -341,4 +346,5 @@ const auxiliaryOriginalHours = { selectAuxiliaryOriginalHours: "/auxiliaryOriginalHours/selectAuxiliaryOriginalHours", //鏌ヨ鍘熷宸ユ椂 + exportOriginalHours: "/auxiliaryOriginalHours/exportOriginalHours", //瀵煎嚭鍘熷宸ユ椂 } diff --git a/src/components/do/b1-ins-order/add.vue b/src/components/do/b1-ins-order/add.vue index f712e9b..c33889d 100644 --- a/src/components/do/b1-ins-order/add.vue +++ b/src/components/do/b1-ins-order/add.vue @@ -281,6 +281,12 @@ v-model="addObj.remark" :readonly="active>1"></el-input> </div> </el-col> + <el-col class="search_thing" :span="6" v-if="active==1"> + <div class="search_label">RTS锛�</div> + <div class="search_input"> + <el-input size="small" placeholder="璇疯緭鍏�" clearable v-model="RTS"></el-input> + </div> + </el-col> </el-row> </div> <div v-show="!configShow"> @@ -631,6 +637,8 @@ bsm1Val: null, bsm1Dia: false, total:0, + RTS:'', + totalArr:[] } }, watch: { @@ -726,6 +734,32 @@ this.addObj.companyId = selects.id this.selectUserDia = false }, + handleAsk(ask){ + let code = [">","<","=","锛�","锛�","鈮�","鈮�","卤"]; + if(ask.includes('RTS')){ + if(ask.includes('&')){ + // 澶氫釜鏉′欢 + let arr0 = ask.split('&') + arr0.forEach(m=>{ + let index = code.findIndex(b=>m.includes(b)) + if(index>-1){ + let arr = m.split(code[index]).find(b=>b) + let num = eval(arr[0].replace(/RTS/g, this.RTS)) + m = code[index] + ''+ num + } + }) + return arr0.join('&') + }else{ + // 鍗曚釜鏉′欢 + let index = code.findIndex(b=>ask.includes(b)) + if(index>-1){ + let arr = ask.split(code[index]).find(b=>b) + let num = eval(arr[0].replace(/RTS/g, this.RTS)) + return code[index] + ''+ num + } + } + } + }, save() { if (!this.addObj.companyId) { this.$message.error('鏈�夋嫨瀹㈡埛鍗曚綅') @@ -749,11 +783,68 @@ this.$message.error('璇疯緭鍏ユ牱鍝佸瀷鍙�') } else if (!this.sampleList.every(m => m.standardMethodListId)) { this.$message.error('璇烽�夋嫨妫�楠屾爣鍑�') + }else if (this.totalArr.find(a=>a.ask.includes('RTS'))&&!this.RTS) { + this.$message.error('璇疯緭鍏TS') } else { + let sampleList = this.HaveJson(this.sampleList) + let isRTS = this.totalArr.find(a=>a.ask.includes('RTS')) + if(isRTS){ + sampleList.forEach(item=>{ + if(item.insProduct&&item.insProduct.length>0){ + item.insProduct.forEach(a=>{ + let ask = this.handleAsk(a.ask) + if(ask){ + a.ask = ask + } + }) + } + // 鍏夌氦甯﹂」鐩� + if(item.bushing&&item.bushing.length>0){ + item.bushing.forEach(a=>{ + if(a.fiber&&a.fiber.length>0){ + a.fiber.forEach(b=>{ + if(b.productList&&b.productList.length>0){ + b.productList.forEach(c=>{ + let ask = this.handleAsk(c.ask) + if(ask){ + c.ask = ask + } + }) + } + }) + } + if(a.fibers&&a.fibers.length>0){ + a.fibers.forEach(b=>{ + if(b.productList&&b.productList.length>0){ + b.productList.forEach(c=>{ + let ask = this.handleAsk(c.ask) + if(ask){ + c.ask = ask + } + }) + } + if(b.fiber&&b.fiber.length>0){ + b.fiber.forEach(c=>{ + if(c.productList&&c.productList.length>0){ + c.productList.forEach(d=>{ + let ask = this.handleAsk(d.ask) + if(ask){ + d.ask = ask + } + }) + } + }) + } + }) + } + }) + } + }) + } this.saveLoad = true this.$axios.post(this.$api.insOrder.addInsOrder, { insOrder: this.addObj, - list: JSON.stringify(this.sampleList.map(a => { + list: JSON.stringify(sampleList.map(a => { a.model = a.model + ((a.modelNum == null || a.modelNum == '' || a.modelNum == 'null') ? '' : ( '-' + a.modelNum)) return a @@ -1352,12 +1443,12 @@ done() }, getTotal(){ - let arr = [] + this.totalArr = [] this.total = 0; this.sampleList.forEach(item=>{ if(item.insProduct&&item.insProduct.length>0){ item.insProduct.forEach(a=>{ - arr.push(a) + this.totalArr.push(a) }) } if(item.bushing&&item.bushing.length>0){ @@ -1366,7 +1457,7 @@ a.fiber.forEach(b=>{ if(b.productList&&b.productList.length>0){ b.productList.forEach(c=>{ - arr.push(c) + this.totalArr.push(c) }) } }) @@ -1375,14 +1466,14 @@ a.fibers.forEach(b=>{ if(b.productList&&b.productList.length>0){ b.productList.forEach(c=>{ - arr.push(c) + this.totalArr.push(c) }) } if(b.fiber&&b.fiber.length>0){ b.fiber.forEach(c=>{ if(c.productList&&c.productList.length>0){ c.productList.forEach(d=>{ - arr.push(d) + this.totalArr.push(d) }) } }) @@ -1393,7 +1484,7 @@ } }) let mySet = new Set(); - let arr0 = arr.filter(item=>{ + let arr0 = this.totalArr.filter(item=>{ if(item.state == 1){ let num1= mySet.size if(item.manHourGroup===''||!item.manHourGroup){ diff --git a/src/components/do/b1-inspect-order-plan/Inspection.vue b/src/components/do/b1-inspect-order-plan/Inspection.vue index 9b56e5b..ba5a5bb 100644 --- a/src/components/do/b1-inspect-order-plan/Inspection.vue +++ b/src/components/do/b1-inspect-order-plan/Inspection.vue @@ -320,6 +320,19 @@ </tbody> </table> </div> + <el-upload :action="action" + :data="{ + orderId:id + }" + v-show="state==1" + :on-success="handleSuccessUp" :show-file-list="false" + accept='.jpg,.jpeg,.png,.gif,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.zip,.rar' :headers="headers" :on-change="beforeUpload" + :on-error="onError" ref='upload'> + <el-button size="small" type="primary" :loading="upLoading">闄勪欢涓婁紶</el-button></el-upload> + <ValueTable class="value-table" ref="fileList" :url="$api.insOrderPlan.getFileList" + :componentData="componentData0" + :delUrl="$api.insOrderPlan.delfile" + :key="upIndex" style="height: 100%;margin-top: 16px;"/> </div> <el-drawer title="鍏夌氦鍒囨崲" :visible.sync="fiberOpticVisible" :size="500"> <el-table class="el-table" ref="fiberOpticTable" :data="fiberOptic" height="100%" tooltip-effect="dark" border @@ -422,6 +435,7 @@ <script> import ValueTable from '../../tool/value-table.vue' + import file from '../../../util/file' export default { props: ['sonLaboratory', 'orderId', 'state'], components: { @@ -457,6 +471,53 @@ insState: { select: [] }, + }, + currentId: '', + selectField: {}, + requiredAdd: [], + requiredUp: [] + }, + componentData0: { + entity: { + insOrderId:'' + }, + isIndex: true, + showSelect: false, + select: false, + selectMethod: '', + sort: false, + init:false, + do: [ + { + id: 'delete', + font: '鍒犻櫎', + type: 'text', + method: 'doDiy', + disabFun: (row, index) => { + return this.state!=1 + } + }, { + id: 'handleDown', + font: '涓嬭浇', + type: 'text', + method: 'handleDown' + }, + ], + isPage: false, + linkEvent: {}, + tagField: { + type:{ + select:[ + { + value: 1, + label: '鍥剧墖' + }, + { + value: 2, + label: '鏂囦欢' + } + ] + } }, currentId: '', selectField: {}, @@ -499,8 +560,19 @@ currentFiberOptic:null,//褰撳墠鍏夌氦 currentBushing:null,//褰撳墠濂楃 tableLoading:false, + upLoading:false } }, + computed: { + headers() { + return { + 'token': sessionStorage.getItem('token') + } + }, + action() { + return this.javaApi + this.$api.insOrderPlan.uploadFile + } + }, created() { this.componentData.entity.sonLaboratory = this.sonLaboratory; this.id = this.orderId; @@ -521,6 +593,8 @@ laboratory: this.sonLaboratory }).then(async res => { this.insOrder = res.data.insOrder; + this.componentData0.entity.insOrderId = val; + this.$refs.fileList.selectList() this.urgentList.forEach(m => { if (m.value == this.insOrder.type) { this.insOrder.typeName = m.label @@ -1414,20 +1488,67 @@ } this.addVerifyDia = false this.submitLoading = true; - this.$axios.post(this.$api.insOrderPlan.submitPlan, { + this.$axios.post(this.$api.insOrderPlan.checkSubmitPlan, { orderId: this.orderId, laboratory: this.sonLaboratory, - verifyUser: this.verifyUser }).then(res => { if (res.code === 200) { - this.$message.success("鎿嶄綔鎴愬姛") - this.$emit('goback') + console.log(res.data) + if(!res.data||res.data.length==0){ + this.$axios.post(this.$api.insOrderPlan.submitPlan, { + orderId: this.orderId, + laboratory: this.sonLaboratory, + verifyUser: this.verifyUser + }).then(res => { + if (res.code === 200) { + this.$message.success("鎿嶄綔鎴愬姛") + this.$emit('goback') + } + this.submitLoading = false; + }).catch(error => { + console.error(error) + this.submitLoading = false; + }) + }else{ + let newData = [] + const h = this.$createElement + for (let i in res.data) { + const lastChar = res.data[i].slice(-1); + if(lastChar=='-'){ + res.data[i] = res.data[i].slice(0, -1); + } + newData.push(h('p', {style: 'font-size: 12px;'}, (Number(i)+1)+'銆�'+res.data[i])) + } + newData.push(h('p', { style: 'font-size: 16px;color:#000;margin-top:12px' },'浠ヤ笂椤圭洰涓嶅悎鏍硷紝纭畾鎻愪氦锛�')) + this.$confirm('鎻愮ず',{ + title:'鎻愮ず', + message: h('div', null, newData), + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "" + }).then(() => { + this.$axios.post(this.$api.insOrderPlan.submitPlan, { + orderId: this.orderId, + laboratory: this.sonLaboratory, + verifyUser: this.verifyUser + }).then(res => { + if (res.code === 200) { + this.$message.success("鎿嶄綔鎴愬姛") + this.$emit('goback') + } + }).catch(error => { + console.error(error) + }) + }).catch(() => {}) + } + } this.submitLoading = false; }).catch(error => { console.error(error) this.submitLoading = false; }) + return }, saveInsContext() { this.$axios.post(this.$api.insOrderPlan.saveInsContext, { @@ -1515,6 +1636,48 @@ } }) this.getTableLists() + }, + handleSuccessUp(response, ) { + this.upLoading = false; + if (response.code == 200) { + this.$message.success('涓婁紶鎴愬姛'); + this.$refs.fileList.selectList() + } + }, + beforeUpload(file) { + if (file.size > 1024 * 1024 * 10) { + this.$message.error('涓婁紶鏂囦欢涓嶈秴杩�10M'); + this.$refs.upload.clearFiles() + return false; + } else { + this.upLoading = true; + return true; + } + }, + onError(err, file, fileList) { + this.$message.error('涓婁紶澶辫触') + this.$refs.upload.clearFiles() + }, + handleDown(row){ + this.$axios.post(this.$api.insOrderPlan.downFile, { + id: row.id, + }).then(res => { + if (res.code === 200) { + let url = ''; + if(res.data.type==1){ + url = this.javaApi+'/img/'+res.data.url + file.downloadIamge(url,row.fileName) + }else{ + url = this.javaApi+'/word/'+res.data.url + const link = document.createElement('a'); + link.href = url; + link.download = row.fileName; + link.click(); + } + } + }).catch(error => { + + }) } } } diff --git a/src/components/do/b3-work-time-management/work-time-management.vue b/src/components/do/b3-work-time-management/work-time-management.vue index b36de84..86d3e07 100644 --- a/src/components/do/b3-work-time-management/work-time-management.vue +++ b/src/components/do/b3-work-time-management/work-time-management.vue @@ -333,6 +333,7 @@ requiredAdd: [], requiredUp: [] }, + addFileVisible:false, entityCopy1: {}, upIndex1:100, weekList:[ diff --git a/src/components/do/b3-work-time-management/work-time-statistics.vue b/src/components/do/b3-work-time-management/work-time-statistics.vue index 8ffa444..380987a 100644 --- a/src/components/do/b3-work-time-management/work-time-statistics.vue +++ b/src/components/do/b3-work-time-management/work-time-statistics.vue @@ -10,7 +10,8 @@ format="yyyy-MM" value-format="yyyy-MM" placeholder="閫夋嫨鏈�" size="small" style="width: 100%;" - :clearable="false"> + :clearable="false" + @change="refreshTable()"> </el-date-picker> </div> </div> @@ -39,8 +40,8 @@ <el-button size="small" type="primary" @click="refreshTable()">鏌� 璇�</el-button> </div> <div class="search_thing"> - <el-button size="small" type="primary" @click="handleDown" v-show="currentTable == 'value0'">瀵� 鍑�</el-button> - <el-button size="small" type="primary" @click="handleUp" v-show="currentTable == 'value1'">瀵� 鍏�</el-button> + <el-button size="small" type="primary" @click="handleDown" v-show="currentTable == 'value0'" :loading="outLoading">瀵� 鍑�</el-button> + <el-button size="small" type="primary" @click="handleUp" v-show="currentTable == 'value1'">瀵� 鍏�</el-button> </div> </div> <el-radio-group v-model="currentTable" size="small" :key="'111'" style="margin-top: 10px;"> @@ -55,7 +56,7 @@ <ValueTable ref="ValueTable0" v-if="currentTable == 'value0'" :url="$api.auxiliaryOriginalHours.selectAuxiliaryOriginalHours" - :componentData="componentData" :downUrl="$api.auxiliaryWorkingHours.selectAuxiliaryWorkingHours" :key="upIndex" /> + :componentData="componentData" :key="upIndex" /> <ValueTable ref="ValueTable1" v-if="currentTable == 'value1'" :url="$api.auxiliaryCorrectionHours.selectAuxiliaryCorrectionHours" @@ -130,7 +131,8 @@ upIndex1:100, weekList:[], personList:[], - currentTable:'value0' + currentTable:'value0', + outLoading:false } }, mounted(){ @@ -185,7 +187,23 @@ }) }, handleDown(){ - this.$refs.ValueTable0.downFile(false) + // this.$refs.ValueTable0.downFile(false) + let entity = {...this.entity} + entity.month = entity.month.split('-')[0]+'-'+entity.month.split('-')[1] + this.outLoading = true + this.$axios.get(this.$api.auxiliaryOriginalHours.exportOriginalHours,{ + params:entity, + },{responseType: "blob"}).then(res => { + this.outLoading = false + this.$message.success('瀵煎嚭鎴愬姛') + const blob = new Blob([res],{ type: 'application/octet-stream' }); + console.log(blob) + const url = URL.createObjectURL(blob); + const link = document.createElement('a'); + link.href = url; + link.download = entity.month+'宸ユ椂缁熻琛�.xlsx'; + link.click(); + }) }, handleUp(){ this.$refs.ValueTable1.openUpload() diff --git a/src/components/view/a6-device-management.vue b/src/components/view/a6-device-management.vue index a44150a..dfe4981 100644 --- a/src/components/view/a6-device-management.vue +++ b/src/components/view/a6-device-management.vue @@ -750,7 +750,7 @@ delete this.formData.updateTime delete this.formData.createUser delete this.formData.updateUser - this.formData.insProductIds = this.formData.insProductIds.join() + this.formData.insProductIds = this.formData.insProductIds?this.formData.insProductIds.join():'' this.upLoad = true; this.$axios.post(this.$api.deviceScope.upDeviceParameter, this.formData, { headers: { diff --git a/src/main.js b/src/main.js index 72b15e5..fd0ce3c 100644 --- a/src/main.js +++ b/src/main.js @@ -13,8 +13,8 @@ //鏈湴 Vue.prototype.LOCATIONVUE = "http://127.0.0.1:80"; -const javaApi = 'http://192.168.11.200:8001';//鏉� -// const javaApi = 'http://192.168.11.249:8001';//寮� +// const javaApi = 'http://192.168.11.200:8001';//鏉� +const javaApi = 'http://192.168.11.249:8001';//寮� // const javaApi = 'http://172.20.10.3:8001';//濮� // const javaApi = 'http://192.168.11.2:8001';//鏌� // const javaApi = 'http://127.0.0.1:8001';//鏅� @@ -68,7 +68,11 @@ axios.interceptors.response.use(res => { if(res.data.code === 201){ - Message.error(res.data.message) + Message({ + type: 'error', + dangerouslyUseHTMLString: true, + message: `${res.data.message}` + }) } return res.data }, async function(err) { diff --git a/src/util/file.js b/src/util/file.js index 3757902..c3a3e7b 100644 --- a/src/util/file.js +++ b/src/util/file.js @@ -38,4 +38,24 @@ }) return await xhrPromise }, + downloadIamge(imgsrc, name) {//涓嬭浇鍥剧墖鍦板潃鍜屽浘鐗囧悕 + var image = new Image(); + // 瑙e喅璺ㄥ煙 Canvas 姹℃煋闂 + image.setAttribute("crossOrigin", "anonymous"); + image.onload = function() { + var canvas = document.createElement("canvas"); + canvas.width = image.width; + canvas.height = image.height; + var context = canvas.getContext("2d"); + context.drawImage(image, 0, 0, image.width, image.height); + var url = canvas.toDataURL("image/png"); //寰楀埌鍥剧墖鐨刡ase64缂栫爜鏁版嵁 + + var a = document.createElement("a"); // 鐢熸垚涓�涓猘鍏冪礌 + var event = new MouseEvent("click"); // 鍒涘缓涓�涓崟鍑讳簨浠� + a.download = name || "photo"; // 璁剧疆鍥剧墖鍚嶇О + a.href = url; // 灏嗙敓鎴愮殑URL璁剧疆涓篴.href灞炴�� + a.dispatchEvent(event); // 瑙﹀彂a鐨勫崟鍑讳簨浠� + }; + image.src = imgsrc; + } }; diff --git a/src/view/notice.vue b/src/view/notice.vue index c4beade..00bc85e 100644 --- a/src/view/notice.vue +++ b/src/view/notice.vue @@ -11,9 +11,9 @@ class="notice-content-item" v-for="(m,i) in list" :key="i" - :class="{readStyle:!m.viewStatus}" + :class="{readStyle:m.viewStatus}" @click="goNoticeDetail(m)"> - <img :src="`../../static/img/notice-${m.viewStatus?0:1}-${m.messageType}.svg`" alt="" style="margin-right: 6px;"> + <img :src="`../../static/img/notice-${m.viewStatus?1:0}-${m.messageType}.svg`" alt="" style="margin-right: 6px;"> <div class="notice-content-item-left"> <p>{{ m.theme }}</p> <p style="width: 100%;display: flex;align-items: center;justify-content: space-between;"> -- Gitblit v1.9.3