Files
FreeERP.Applet/miniprogram/pages/purchase/buyInOrderDetail/buyInOrderDetail.ts

114 lines
2.4 KiB
TypeScript
Raw Normal View History

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: '' };
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/info', temp).then((res: any) => {
const info = toObject(res.info);
wx.setNavigationBarTitle({ title: `${info.bill_no} 详情` });
this.setData({
files: toArray(res.files).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;
}),
detail: toArray(res.rows),
info: info,
});
});
},
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.file_name}`;
// console.log(path);
mediaPreview([path], path);
},
/**
* --
*/
onLoad(options) {
const { head_id } = options;
this.data.params.head_id = head_id;
loginStatusPage(this);
},
/**
* --
*/
onReady() {},
/**
* --
*/
onShow() {},
/**
* --
*/
onHide() {},
/**
* --
*/
onUnload() {},
/**
* --
*/
onPullDownRefresh() {},
/**
*
*/
onReachBottom() {},
/**
*
*/
onShareAppMessage() {},
});