shish 1 год назад
Родитель
Сommit
c836ccd142
1 измененных файлов с 36 добавлено и 4 удалено
  1. 36 4
      ghsApp/src/admin/stat/stock.vue

+ 36 - 4
ghsApp/src/admin/stat/stock.vue

@@ -4,9 +4,10 @@
 			<view class="input-wrap">
 				<view style="padding:0 0upx 0 20upx;" >
 					<button class="admin-button-com middle blue" 
-					style="background-color:green;border:1upx solid green;margin-right:60upx;"
-					@click="allOutSelectShop(1)">全部调拨出库</button>
-					<button class="admin-button-com middle default" @click="clearAll()">清空全部库存</button>
+					style="background-color:green;border:1upx solid green;margin-right:20upx;"
+					@click="allOutSelectShop(1)">全部调拨出库到</button>
+					<button class="admin-button-com middle default" @click="clearAll()" style="margin-right:20upx;">清空全部库存</button>
+					<button class="admin-button-com middle default" @click="downStock()">下载Excel</button>
 				</view>
 			</view>
 			<view class="top-bar" style="margin-left:80upx;">实时库存</view>
@@ -94,7 +95,7 @@
 <script>
 import AppWrapperEmpty from "@/components/app-wrapper-empty";
 import SelectList from "@/components/plugin/selectList";
-import { getProductDataApi } from "@/api/product";
+import { getProductDataApi,generateItemTable } from "@/api/product";
 import { allOut } from "@/api/stock-out"
 import { clearStock } from "@/api/inventory";
 import { list } from "@/mixins";
@@ -148,6 +149,37 @@ export default {
 		this.showStock()
 	},
 	methods: {
+		downStock(){
+			uni.showLoading({title:'下载中',mask:true})
+			generateItemTable().then(res => {
+				if(res.code == 1){
+					uni.hideLoading()
+					let file = res.data.file
+					let shortFile = res.data.shortFile
+					uni.downloadFile({
+						url: file,
+						header: {"Content-Type": 'application/vnd.ms-excel'},
+						filePath: `${wx.env.USER_DATA_PATH}/${shortFile}`,
+						success: (res) => {
+							if (res.statusCode === 200) {
+								wx.saveFileToDisk({
+									filePath: res.filePath,
+									success: function(res) {
+										console.log(res)
+									},
+									fail:function(res) {
+										console.log(res)
+									}
+								})
+							}
+						},
+						fail:()=>{
+							uni.showToast({title:'请用电脑打开小程序下载',mask:true,icon:'none'})
+						}
+					});
+				}					
+			})
+		},
 		clearAllStock(){
 			let that = this
 			that.$util.confirmModal({content:'确认全部清除?'},() => {