Răsfoiți Sursa

add:物联网卡添加导出功能

zoie 1 zi în urmă
părinte
comite
d503a1e05d

+ 1 - 0
src/api/storehouse/index.ts

@@ -235,4 +235,5 @@ export const Storehouse_IOTNetworkCard_Add = (params: any) => $http.post('/stora
 export const Storehouse_IOTNetworkCard_Edit = (params: any) => $http.post('/storage/IOTNetworkCard/Edit', params)
 export const Storehouse_IOTNetworkCard_Del = (params: any) => $http.post('/storage/IOTNetworkCard/Del', params)
 export const Storehouse_IOTNetworkCard_Import = (params: any) => $http.post('/storage/IOTNetworkCard/Import', params)
+export const Storehouse_IOTNetworkCard_Export = (params: any) => $http.post('/storage/IOTNetworkCard/Export', params, { responseType: 'blob' })
 export const Storehouse_IOTNetworkCard_Edit_Device_Number = (params: any) => $http.post('/storage/IOTNetworkCard/Edit_Device_Number', params)

+ 0 - 9
src/views/purchase/Purchase.vue

@@ -13,15 +13,6 @@ import {
 	Purchase_Stat_Excel
 } from '@/api/purchase/index'
 import { deptOptions } from '@/hooks/useTablePublic'
-import {stockInexcel, Storehouse_VerifyContract_Recover_User_List} from "@/api/storehouse";
-interface UserInfoIn {
-	T_name: string
-	T_type_name: string
-	T_text: string
-	T_uuid: string
-	T_dept_name: string
-	T_post_name: string
-}
 
 const columns: ColumnProps[] = [
 	{type: 'index', label: '序号', width: 80},

+ 39 - 1
src/views/storehouse/inventory/IOTNetworkCard.vue

@@ -6,13 +6,14 @@ import {
 	Storehouse_IOTNetworkCard_Edit, Storehouse_IOTNetworkCard_Edit_Device_Number,
 	Storehouse_IOTNetworkCard_Import,
 	Storehouse_IOTNetworkCard_List,
+	Storehouse_IOTNetworkCard_Export, exportOperationFile,
 } from '@/api/storehouse/index'
 import {nextTick, reactive, ref} from 'vue'
 import Upload from '@/components/Upload/index.vue'
 import Drawer from '@/components/Drawer/index.vue'
 import type {FormInstance, FormRules} from 'element-plus'
 import {ElLoading, ElMessage, ElMessageBox} from 'element-plus'
-import {Delete, Edit,View} from '@element-plus/icons-vue'
+import {Delete, Edit, Finished, View} from '@element-plus/icons-vue'
 import type {ColumnProps} from '@/components/TableBase/interface/index'
 import {useTablePublic} from '@/hooks/useTablePublic'
 import ReceiveUser from "@/views/storehouse/outStock/receiveUser.vue";
@@ -338,6 +339,42 @@ const onclickT_device_number = async (row:any)=>{
 	}
 
 }
+const exportStatExcel = async () => {
+	// const result:any = await Storehouse_IOTNetworkCard_Export({
+	// 	User_tokey: globalStore.GET_User_tokey,
+	// 	T_name: initParam.T_name,
+	// 	T_company_name: initParam.T_company_name,
+	// 	T_state: initParam.T_state,
+	// })
+	// if (result.Code === 200) {
+	// 	window.open(result.Data)
+	// }
+
+	try {
+		const response: any = await Storehouse_IOTNetworkCard_Export({
+				User_tokey: globalStore.GET_User_tokey,
+				T_name: initParam.T_name,
+				T_company_name: initParam.T_company_name,
+				T_state: initParam.T_state,
+			})
+
+		// 处理返回的二进制文件并触发下载
+		const blob = new Blob([response], {type: 'application/vnd.ms-excel;charset=utf8'})
+		const url = window.URL.createObjectURL(blob)
+		const a = document.createElement('a')
+		a.href = url
+		const now = new Date();
+		const formattedDate = `${now.getFullYear()}${(now.getMonth()+1).toString().padStart(2, '0')}${now.getDate().toString().padStart(2, '0')}_${now.getHours().toString().padStart(2, '0')}${now.getMinutes().toString().padStart(2, '0')}`;
+		a.download = `物联网卡_${formattedDate}.xlsx`;
+		document.body.appendChild(a)
+		a.click()
+		a.remove()
+		window.URL.revokeObjectURL(url)
+		ElMessage.success('导出成功')
+	} catch (error) {
+		ElMessage.error('导出失败,请检查网络连接')
+	}
+}
 </script>
 
 <template>
@@ -371,6 +408,7 @@ const onclickT_device_number = async (row:any)=>{
 						<el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id"/>
 					</el-select>
 					<el-button type="primary" @click="searchModelHandle">搜索</el-button>
+					<el-button type="success" @click="exportStatExcel">导出</el-button>
 				</el-col>
 				<el-col :xl="8" :lg="8" :md="11" class="btn">
 					<el-button type="primary" @click="openDrawer('new')">入库</el-button>