xusd
7 days ago 998218675eb243d43912c203174a6b72b299c0f8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// pages/materialUpload/index.js
const $$ = require('../../utils/util');
const app = getApp();
 
// 获取附件
function getCaseFilesApi(id) {
    return $$.request({ url: 'paCaseInfo/listCaseFile?caseId=' + id, type: 'get', service: 'mediate' });
}
// 删除附件
function delfileApi(id) {
    return $$.request({ url: 'fileInfo/deleteById?id=' + id, type: 'get', service: 'sys', v1: true });
}
 
Page({
    /**
     * 页面的初始数据
     */
    settimeout: null,
    previewImageVisible: false, // 判断是否进入查看图片
    touchstarttime: '', //触摸开始时间
    caseId: '',
    data: {
        imgUrl: $$.url.img,
        material_data: [
            {
                icon: `${$$.url.img}material-evidence.png`,
                iconActive: `${$$.url.img}material-evidence-active.png`,
                num: 0,
                title: '证据材料',
                type: '22_00018-102',
                explain: '证据材料:包括但不限于物证、书证、证词、鉴定结论等内容,可作为纠纷的重要判断依据,形式主要为图片、word、pdf等。',
                files: [],
            },
            {
                icon: `${$$.url.img}material-apply.png`,
                iconActive: `${$$.url.img}material-apply-active.png`,
                num: 0,
                title: '申请材料',
                type: '22_00018-101',
                explain: '申请材料:申请材料包括但不限于纠纷登记表、送达地址确认书、司法确认申请表等,形式主要为图片、word、pdf等。',
                files: [],
            },
            {
                icon: `${$$.url.img}material-identity.png`,
                iconActive: `${$$.url.img}material-identity-active.png`,
                num: 0,
                title: '身份材料',
                type: '22_00018-202',
                explain:
                    '身份材料:包括但不限于居民身份证、企业工商登记证明(法人时需要)、组织机构代码证(非法人组织时需要)、代理人授权委托书(代理人时需要)等,形式主要为图片、word、pdf等。',
                files: [],
            },
            {
                icon: `${$$.url.img}material-other.png`,
                iconActive: `${$$.url.img}material-other-active.png`,
                num: 0,
                title: '其他材料',
                type: '22_00018-199',
                explain: '其他材料:与案件关系密切的其他材料,形式主要为图片、word、pdf等。',
                files: [],
            },
        ],
        activeMaterial: 0, // 当前选中的材料下标
        editVisible: true, // 是否编辑状态
    },
 
    // 切换显示文件
    handleChangeTab(e) {
        this.setData({
            activeMaterial: e.detail,
        });
    },
 
    // 长按删除文件
    handleTouchstart(e) {
        this.touchstarttime = e.timeStamp;
        let item = e.detail;
        let that = this;
        this.settimeout = setTimeout(() => {
            if (this.touchstarttime && that.data.editVisible) {
                $$.showModal({
                    content: '确定删除' + item.name + '吗?',
                    success: (res) => {
                        if (res.confirm) {
                            that.delfile(item.id);
                        }
                    },
                });
            }
        }, 1500);
    },
 
    // 长按结束
    handleTouchend(e) {
        let item = e.detail;
        if (e.timeStamp - this.touchstarttime < 1000) {
            // 判断用户为点击
            let imgUrl = $$.baseUrl + $$.url.fileShowUrl + item.id;
            const visible = $$.openFiles(item.cat, imgUrl, [imgUrl]);
            if (visible) {
                this.previewImageVisible = true;
            }
        }
        if (this.settimeout) {
            clearTimeout(this.settimeout);
        }
        this.touchstarttime = false;
    },
 
    // 跳转至上传文件页面
    handleGoUpload() {
        wx.navigateTo({
            url: '../../pages/materialUpload/index?activeMaterial=' + this.data.activeMaterial + '&caseId=' + this.caseId,
        });
    },
 
    // 删除附件
    async delfile(id) {
        $$.showLoading();
        const res = await delfileApi(id);
        $$.hideLoading();
        if (res.type) {
            this.getCaseFiles(this.caseId, 'delete');
        }
    },
 
    // 查询案件附件
    async getCaseFiles(id, type) {
        $$.showLoading();
        const res = await getCaseFilesApi(id);
        $$.hideLoading();
        if (res.type) {
            if (type) {
                $$.showToast({ icon: 'success', title: '删除成功', duration: 500 });
            }
            let arr = ['evidenceFile', 'applyFile', 'identityFile', 'otherFile'];
            arr.forEach((x, t) => {
                this.data.material_data[t].num = res.data[x]?.size || 0;
                this.data.material_data[t].files = res.data[x]?.dataList || [];
            });
            app.globalData.material.data = this.data.material_data;
            this.setData({ activeMaterial: this.data.activeMaterial || 0, material_data: this.data.material_data });
        }
    },
 
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        if (options.caseId) {
            this.caseId = options.caseId;
            this.getCaseFiles(this.caseId);
        }L
        this.setData({ editVisible: !!options?.editVisible });
    },
 
    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {
        if (this.caseId && !this.previewImageVisible && app.globalData.material.uploadVisible) {
            app.globalData.material.uploadVisible = false;
            this.getCaseFiles(this.caseId);
        }
        if (this.previewImageVisible) {
            this.previewImageVisible = false;
        }
    },
});