From 5692bc829ac5cb1b1fbd113a89c44d2d3c3a41ee Mon Sep 17 00:00:00 2001
From: chenrui <1187576398@qq.com>
Date: 星期五, 28 三月 2025 09:45:19 +0800
Subject: [PATCH] 插回损功能开发
---
src/api/equipment/lossRecord.js | 51 ++++++++
src/util/fileTransform.js | 22 +++
src/views/equipment/lossrecord/index.vue | 245 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 317 insertions(+), 1 deletions(-)
diff --git a/src/api/equipment/lossRecord.js b/src/api/equipment/lossRecord.js
new file mode 100644
index 0000000..cc5f1c1
--- /dev/null
+++ b/src/api/equipment/lossRecord.js
@@ -0,0 +1,51 @@
+/*
+ * @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
+ })
+}
diff --git a/src/util/fileTransform.js b/src/util/fileTransform.js
index 6471e85..6f8ccec 100644
--- a/src/util/fileTransform.js
+++ b/src/util/fileTransform.js
@@ -36,4 +36,24 @@
URL.revokeObjectURL(elink.href) // 閲婃斁URL 瀵硅薄
document.body.removeChild(elink)
}
-}
\ No newline at end of file
+}
+
+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)
+ }
+}
diff --git a/src/views/equipment/lossrecord/index.vue b/src/views/equipment/lossrecord/index.vue
new file mode 100644
index 0000000..bea6312
--- /dev/null
+++ b/src/views/equipment/lossrecord/index.vue
@@ -0,0 +1,245 @@
+<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浠ュ強瀵瑰簲鐨剈rl
+ 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>
--
Gitblit v1.9.3