添加页面及附件查看
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"t-cell": "tdesign-miniprogram/cell/cell",
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group",
|
||||
"t-image": "tdesign-miniprogram/image/image"
|
||||
},
|
||||
"navigationBarTitleText": "附件列表"
|
||||
}
|
||||
125
miniprogram/pages/base/viewAttachment/viewAttachment.ts
Normal file
125
miniprogram/pages/base/viewAttachment/viewAttachment.ts
Normal file
@@ -0,0 +1,125 @@
|
||||
import { OSSBaseUrl } from '@/utils/config';
|
||||
import { loginStatus, post } from '@/utils/https';
|
||||
import {
|
||||
formatFileSize,
|
||||
getAuthInfo,
|
||||
getDataSet,
|
||||
getFileType,
|
||||
mediaPreview,
|
||||
toArray,
|
||||
} from '@/utils/util';
|
||||
|
||||
Page({
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
order_no: '',
|
||||
head_id: '',
|
||||
head_id2: '',
|
||||
list: [] as any[],
|
||||
fileIcon: { file: 'file', excel: 'file-excel', pdf: 'file-pdf' },
|
||||
},
|
||||
handleLogin(e: any) {
|
||||
this.setData({ isLogin: e.detail });
|
||||
if (e.detail) {
|
||||
this.init();
|
||||
}
|
||||
},
|
||||
init() {
|
||||
this.setData({ authInfo: getAuthInfo() });
|
||||
this.getList();
|
||||
},
|
||||
formatData(data: any) {
|
||||
const list = toArray(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;
|
||||
});
|
||||
this.setData({ list });
|
||||
},
|
||||
getList() {
|
||||
if (this.data.order_no) {
|
||||
// 销售订单
|
||||
post('Orders/getOrderFiles', { order_no: this.data.order_no }).then((res: any) => {
|
||||
this.formatData(res.files);
|
||||
});
|
||||
} else if (this.data.head_id) {
|
||||
// 仓库采购
|
||||
post('ErpDepot/fileList', { head_id: this.data.head_id }).then((res: any) => {
|
||||
this.formatData(res.data);
|
||||
});
|
||||
} else if (this.data.head_id2) {
|
||||
// 财务
|
||||
post('ErpFinance/fileList', { head_id: this.data.head_id2 }).then((res: any) => {
|
||||
this.formatData(res.data);
|
||||
});
|
||||
}
|
||||
},
|
||||
onPreview(e: any) {
|
||||
const data = getDataSet(e);
|
||||
const index = data.index;
|
||||
const item = this.data.list[index];
|
||||
if (item._file_type != 'file') {
|
||||
mediaPreview([item.file_path], item.file_path);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
const { title, order_no = '', head_id = '', head_id2 = '' } = options || {};
|
||||
if (title) {
|
||||
wx.setNavigationBarTitle({ title: decodeURIComponent(title) });
|
||||
}
|
||||
this.data.order_no = order_no;
|
||||
this.data.head_id = head_id;
|
||||
this.data.head_id2 = head_id2;
|
||||
this.setData({ loading: true });
|
||||
loginStatus()
|
||||
.then(() => {
|
||||
this.setData({ isLogin: true, loading: false });
|
||||
this.init();
|
||||
})
|
||||
.catch((err) => {
|
||||
this.setData({ isLogin: false, loading: false });
|
||||
console.log('调用登录状态请求失败', err);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {},
|
||||
});
|
||||
14
miniprogram/pages/base/viewAttachment/viewAttachment.wxml
Normal file
14
miniprogram/pages/base/viewAttachment/viewAttachment.wxml
Normal file
@@ -0,0 +1,14 @@
|
||||
<page-plugin isAuth="{{true}}" loading="{{loading}}" is-login="{{isLogin}}"
|
||||
bind:handleLogin="handleLogin">
|
||||
<t-cell-group custom-style="margin: 0">
|
||||
<block wx:for="{{list}}" wx:key="index">
|
||||
<t-cell title="{{item.file_name}}" image="{{item._file_type == 'image' ? item.file_path: ''}}"
|
||||
hover="{{item._file_type != 'file'}}" arrow="{{item._file_type != 'file'}}"
|
||||
description="{{item._file_size}}" bind:tap="onPreview" data-index="{{index}}">
|
||||
<block wx:if="{{item._file_type != 'image'}}">
|
||||
<t-icon slot="left-icon" name="{{fileIcon[item._file_type]}}" color="#999" size="96rpx" />
|
||||
</block>
|
||||
</t-cell>
|
||||
</block>
|
||||
</t-cell-group>
|
||||
</page-plugin>
|
||||
@@ -0,0 +1 @@
|
||||
/* pages/other/viewAttachment/viewAttachment.wxss */
|
||||
Reference in New Issue
Block a user