123 lines
2.7 KiB
TypeScript
123 lines
2.7 KiB
TypeScript
import { OSSBaseUrl } from '@/utils/config';
|
|
import { loginStatusPage, post } from '@/utils/https';
|
|
import {
|
|
cloneLite,
|
|
formatFileSize,
|
|
getAuthInfo,
|
|
getDataSet,
|
|
getFileType,
|
|
mediaPreview,
|
|
toArray,
|
|
toObject,
|
|
} from '@/utils/util';
|
|
|
|
const defaultParams = { head_id: '', head_type: '' };
|
|
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
params: cloneLite(defaultParams) as any,
|
|
list: [] as any[],
|
|
count: 0,
|
|
info: {} as any,
|
|
files: [] as any,
|
|
detail: [] as any,
|
|
},
|
|
handleLogin(e: any) {
|
|
this.setData({ isLogin: e.detail });
|
|
if (e.detail) {
|
|
this.init();
|
|
}
|
|
},
|
|
init() {
|
|
this.setData({ authInfo: getAuthInfo() });
|
|
this.getList();
|
|
},
|
|
|
|
getList() {
|
|
this.setData({ params: this.data.params });
|
|
const temp = cloneLite(this.data.params);
|
|
post('ErpDepot/depotItemList', temp).then((res: any) => {
|
|
this.setData({ detail: toArray(res.data) });
|
|
});
|
|
post('ErpDepot/fileList', { head_id: temp.head_id }).then((res: any) => {
|
|
this.setData({
|
|
files: toArray(res.data).map((el) => {
|
|
el._file_type = getFileType(el.file_name);
|
|
el.file_path = `${OSSBaseUrl}${el.file_path}`;
|
|
el._file_size = formatFileSize(el.file_size);
|
|
return el;
|
|
}),
|
|
});
|
|
});
|
|
},
|
|
onPreview(e: any) {
|
|
const data = getDataSet(e);
|
|
const index = data.index;
|
|
const item = this.data.files[index];
|
|
if (item._file_type != 'file') {
|
|
mediaPreview([item.file_path], item.file_path);
|
|
}
|
|
},
|
|
onPreview2() {
|
|
const path = `${OSSBaseUrl}${this.data.info.excel_path}`;
|
|
// console.log(path);
|
|
mediaPreview([path], path);
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
const { head_id } = options;
|
|
this.data.params.head_id = head_id;
|
|
const eventChannel: any = this.getOpenerEventChannel();
|
|
if (eventChannel) {
|
|
eventChannel.on('requestOrderDetail', (res: any) => {
|
|
const record = toObject(res.data);
|
|
wx.setNavigationBarTitle({ title: `${record.bill_no} 详情` });
|
|
this.setData({ info: record });
|
|
loginStatusPage(this);
|
|
});
|
|
} else {
|
|
loginStatusPage(this);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {},
|
|
});
|