¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * @Descripttion: |
| | | * @version: |
| | | * @Author: zt_lc |
| | | * @Date: 2022-02-10 14:24:32 |
| | | * @LastEditors: zt_lc |
| | | * @LastEditTime: 2022-05-31 17:30:32 |
| | | */ |
| | | /* |
| | | * Copyright (c) 2018-2025, ztt All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the pig4cloud.com developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: ztt |
| | | */ |
| | | |
| | | import request from '@/router/axios' |
| | | |
| | | export function syncLossRecordFile(query) { |
| | | return request({ |
| | | url: '/mes/lossRecordController/syncLossRecordFile', |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | | |
| | | export function recordList(query) { |
| | | return request({ |
| | | url: '/mes/lossRecordController/page', |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | | |
| | | export function downloadLossWord(query) { |
| | | return request({ |
| | | url: '/mes/lossRecordController/downloadLossWord', |
| | | method: 'get', |
| | | responseType: 'blob', |
| | | params: query |
| | | }) |
| | | } |
| | |
| | | document.body.removeChild(elink) |
| | | } |
| | | } |
| | | |
| | | export function transformDoc(response) { |
| | | const relType = ['application/vnd.openxmlformats-officedocument.wordprocessingml.document'] |
| | | let type = response.data.type |
| | | if (relType.includes(type)) { |
| | | const blob = new Blob([response.data], {type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'}) |
| | | const disposition = response.headers["content-disposition"] |
| | | let temp = disposition.substring(disposition.lastIndexOf('=') + 1) |
| | | let filename = decodeURI(temp) |
| | | // å建ä¸ä¸ªè¶
龿¥ï¼å°æä»¶æµèµè¿å»ï¼ç¶åå®ç°è¿ä¸ªè¶
龿¥çåå»äºä»¶ |
| | | const elink = document.createElement('a') |
| | | elink.download = filename |
| | | elink.style.display = 'none' |
| | | elink.href = URL.createObjectURL(blob) |
| | | document.body.appendChild(elink) |
| | | elink.click() |
| | | URL.revokeObjectURL(elink.href) // éæ¾URL 对象 |
| | | document.body.removeChild(elink) |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div class="mod-config"> |
| | | <basic-container> |
| | | <ttable |
| | | :table="table" |
| | | @handleSelectionChange="handleSelectionChange" |
| | | :uploadInfo="uploadInfo" |
| | | :prelang="prelang" |
| | | :options="options" |
| | | :ajaxFun="ajaxFun" |
| | | ref="equipmentTable" |
| | | > |
| | | <template #toolbar></template> |
| | | </ttable> |
| | | </basic-container> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { |
| | | downloadLossWord, |
| | | recordList, |
| | | syncLossRecordFile |
| | | } from '@/api/equipment/lossRecord' |
| | | import { mapGetters } from 'vuex' |
| | | import ttable from '@/views/common/ztt-table.vue' |
| | | import { transformDoc} from '@/util/fileTransform' |
| | | export default { |
| | | data() { |
| | | return { |
| | | ajaxFun: recordList, |
| | | multipleSelection: [], |
| | | uploadInfo: { |
| | | // æ¯å¦å±ç¤ºä¸ä¼ EXCEL以å对åºçurl |
| | | isShow: false, |
| | | url: '/mes/equipment/upload' |
| | | }, |
| | | diaPrintTab: false, |
| | | prelang: 'workstation', |
| | | options: { |
| | | height: 300, // é»è®¤é«åº¦-为äºè¡¨å¤´åºå® |
| | | stripe: true, // æ¯å¦ä¸ºæé©¬çº¹ table |
| | | highlightCurrentRow: false, // æ¯å¦è¦é«äº®å½åè¡ |
| | | border: true, // æ¯å¦æçºµåè¾¹æ¡ |
| | | lazy: false, // æ¯å¦éè¦æå è½½ |
| | | fit: true, // åç宽度æ¯å¦èªæå¼ |
| | | multiSelect: true, // |
| | | seqNo: true, |
| | | isRefresh: true, // æ¯å¦æ¾ç¤ºå·æ°æé® |
| | | isShowHide: true, // æ¯å¦æ¾ç¤ºæ¾å½±æé® |
| | | isSearch: false, // é«çº§æ¥è¯¢æé® |
| | | defaultOrderBy: { column: 'createTime', direction: 'desc' } |
| | | }, |
| | | table: { |
| | | total: 0, |
| | | currentPage: 1, |
| | | pageSize: 20, |
| | | data: [], |
| | | // æ é¢ |
| | | column: [ |
| | | { |
| | | minWidth: '150', |
| | | width: '100', |
| | | prop: 'sourceFile', |
| | | label: 'æ°æ®æ¥æº', |
| | | sort: false, |
| | | isTrue: true, |
| | | isSearch: true |
| | | }, |
| | | { |
| | | minWidth: '150', |
| | | width: '100', |
| | | prop: 'productNum1', |
| | | label: '产åç¼å·1', |
| | | sort: false, |
| | | isTrue: true, |
| | | isSearch: true |
| | | }, |
| | | { |
| | | minWidth: '150', |
| | | width: '100', |
| | | prop: 'productNum2', |
| | | label: '产åç¼å·2', |
| | | sort: false, |
| | | isTrue: true, |
| | | isSearch: true |
| | | }, |
| | | { |
| | | minWidth: '150', |
| | | width: '100', |
| | | prop: 'batchNum1', |
| | | label: 'æ¹æ¬¡ç¼å·1', |
| | | sort: false, |
| | | isTrue: true, |
| | | isSearch: true |
| | | }, |
| | | { |
| | | minWidth: '150', |
| | | width: '100', |
| | | prop: 'batchNum2', |
| | | label: 'æ¹æ¬¡ç¼å·2', |
| | | sort: false, |
| | | isTrue: true, |
| | | isSearch: true |
| | | }, |
| | | { |
| | | minWidth: '150', |
| | | width: '100', |
| | | prop: 'specification1', |
| | | label: 'è§æ ¼', |
| | | sort: false, |
| | | isTrue: true, |
| | | isSearch: true |
| | | }, |
| | | { |
| | | minWidth: '150', |
| | | width: '100', |
| | | prop: 'channel1', |
| | | label: 'é¢é', |
| | | sort: false, |
| | | isTrue: true, |
| | | isSearch: true |
| | | }, |
| | | { |
| | | minWidth: '150', |
| | | width: '100', |
| | | prop: 'insertionLoss1', |
| | | label: 'æå
¥æè', |
| | | sort: false, |
| | | isTrue: true, |
| | | isSearch: true |
| | | }, |
| | | { |
| | | minWidth: '150', |
| | | width: '100', |
| | | prop: 'returnLoss1', |
| | | label: 'åæ³¢æè', |
| | | sort: false, |
| | | isTrue: true, |
| | | isSearch: true |
| | | }, |
| | | { |
| | | minWidth: '150', |
| | | width: '100', |
| | | prop: 'specification2', |
| | | label: 'è§æ ¼', |
| | | sort: false, |
| | | isTrue: true, |
| | | isSearch: true |
| | | }, |
| | | { |
| | | minWidth: '150', |
| | | width: '100', |
| | | prop: 'channel2', |
| | | label: 'é¢é', |
| | | sort: false, |
| | | isTrue: true, |
| | | isSearch: true |
| | | }, |
| | | { |
| | | minWidth: '150', |
| | | width: '100', |
| | | prop: 'insertionLoss2', |
| | | label: 'æå
¥æè', |
| | | sort: false, |
| | | isTrue: true, |
| | | isSearch: true |
| | | }, |
| | | { |
| | | minWidth: '150', |
| | | width: '100', |
| | | prop: 'returnLoss2', |
| | | label: 'åæ³¢æè', |
| | | sort: false, |
| | | isTrue: true, |
| | | isSearch: true |
| | | }, |
| | | { |
| | | minWidth: '150', |
| | | width: '100', |
| | | prop: 'createTime', |
| | | label: 'å建æ¶é´', |
| | | sort: true, |
| | | isTrue: true, |
| | | isSearch: true, |
| | | formatter: this.formatReceiveTime, |
| | | searchInfoType: 'datetimerange' |
| | | } |
| | | ], |
| | | toolbar: [], |
| | | operator: null, |
| | | operatorConfig: { |
| | | fixed: 'right', |
| | | label: 'æä½', |
| | | width: 130, |
| | | minWidth: 130 |
| | | } |
| | | }, |
| | | addOrUpdateVisible: false, |
| | | workshopList: [] |
| | | } |
| | | }, |
| | | components: { |
| | | ttable |
| | | }, |
| | | computed: { |
| | | ...mapGetters(['permissions']) |
| | | }, |
| | | created() { |
| | | this.table.toolbar.push({ |
| | | text: '忥', |
| | | type: 'primary', |
| | | loading: false, |
| | | fun: this.syncFile |
| | | }) |
| | | const arr = [] |
| | | arr.push({ |
| | | text: '导åº', |
| | | icon: 'el-icon-download', |
| | | type: 'text', |
| | | size: 'small', |
| | | fun: this.downloadFile |
| | | }) |
| | | this.table.operator = arr.length > 0 ? arr : null |
| | | }, |
| | | methods: { |
| | | // 忥æä»¶ |
| | | syncFile() { |
| | | syncLossRecordFile().then((res) => {}) |
| | | }, |
| | | |
| | | // æä»¶ä¸è½½ |
| | | downloadFile(row) { |
| | | console.log('row', row) |
| | | downloadLossWord({ id: row.id }).then((res) => { |
| | | transformDoc(res) |
| | | }) |
| | | }, |
| | | |
| | | handleSelectionChange(val) { |
| | | this.multipleSelection = val |
| | | } |
| | | } |
| | | } |
| | | </script> |