index.vue
4.77 KB
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<template>
<view class="flowLaunch-v">
<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :sticky="true"
:down="downOption" :up="upOption">
<view class="search-box search-box_sticky">
<u-search placeholder="请输入关键词搜索" v-model="keyword" height="72" :show-action="false" @change="search"
bg-color="#f0f2f6" shape="square">
</u-search>
</view>
<view class="flow-list">
<view class="flow-list-box" v-for="(item, index) in list" :key="item.id">
<u-swipe-action :index="index" :show="item.show" @click="handleClick" @open="open"
:options="options" @content-click="goDetail(item)">
<view class="item">
<view class="item-cell item-title u-border-bottom">
<text class="title u-line-1">{{item.fullName}}</text>
</view>
<view class="item-cell">
<text class="time">{{item.creatorTime | date('yyyy-mm-dd hh:MM')}}</text>
<text :class="'status '+getFlowStatus(item.status).statusCss">
{{getFlowStatus(item.status).text}}
</text>
</view>
</view>
</u-swipe-action>
</view>
</view>
</mescroll-body>
</view>
</template>
<script>
import resources from '@/libs/resources.js'
import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
import {
FlowLaunchList,
Delete
} from '@/api/workFlow/flowLaunch'
export default {
mixins: [MescrollMixin],
data() {
return {
downOption: {
use: true,
auto: true
},
upOption: {
page: {
num: 0,
size: 20,
time: null
},
empty: {
use: true,
icon: resources.message.nodata,
tip: "暂无数据",
fixed: true,
top: "300rpx",
},
textNoMore: '没有更多数据',
},
keyword: '',
list: [],
options: [{
text: '删除',
style: {
backgroundColor: '#dd524d'
}
}]
}
},
onLoad() {
uni.$on('refresh', () => {
this.list = [];
this.mescroll.resetUpScroll();
})
},
onUnload() {
uni.$off('refresh')
},
methods: {
upCallback(page) {
let query = {
currentPage: page.num,
pageSize: page.size,
keyword: this.keyword
}
FlowLaunchList(query, {
load: page.num == 1
}).then(res => {
this.mescroll.endSuccess(res.data.list.length);
if (page.num == 1) this.list = [];
const list = res.data.list.map(o => ({
show: false,
...o
}));
this.list = this.list.concat(list);
}).catch(() => {
this.mescroll.endErr();
})
},
handleClick(index, index1) {
const item = this.list[index]
if ([1, 2, 3, 5].includes(item.status)) {
this.$u.toast("流程正在审核,请勿删除")
this.list[index].show = false
return
}
Delete(item.id).then(res => {
this.$u.toast(res.msg)
this.list.splice(index, 1)
if (!this.list.length) this.mescroll.showEmpty()
})
},
open(index) {
this.list[index].show = true;
this.list.map((val, idx) => {
if (index != idx) this.list[idx].show = false;
})
},
search() {
// 节流,避免输入过快多次请求
this.searchTimer && clearTimeout(this.searchTimer)
this.searchTimer = setTimeout(() => {
this.list = [];
this.mescroll.resetUpScroll();
}, 300)
},
goDetail(item) {
let opType = '-1'
if ([1, 2, 3, 5].includes(item.status)) opType = 0
const config = {
id: item.id,
enCode: item.flowCode,
flowId: item.flowId,
formType: item.formType,
opType: opType,
status: item.status,
taskNodeId: '',
fullName: item.fullName
}
uni.navigateTo({
url: '/pages/workFlow/flowBefore/index?config=' + encodeURIComponent(JSON.stringify(config))
})
},
getFlowStatus(val) {
let status
switch (val) {
case 0:
status = {
text: '等待提交',
statusCss: 'u-type-info'
}
break;
case 1:
status = {
text: '等待审核',
statusCss: 'u-type-primary'
}
break;
case 2:
status = {
text: '审核通过',
statusCss: 'u-type-success'
}
break;
case 3:
status = {
text: '审核驳回',
statusCss: 'u-type-error'
}
break;
case 4:
status = {
text: '流程撤回',
statusCss: 'u-type-warning'
}
break;
case 5:
status = {
text: '审核终止',
statusCss: 'u-type-info'
}
break;
default:
status = {
text: '等待提交',
statusCss: 'u-type-info'
}
break;
}
return status
}
}
}
</script>
<style lang="scss">
page {
background-color: #f0f2f6;
}
.flowLaunch-v {
.flow-list-box {
width: 100%;
margin-bottom: 20rpx;
}
}
</style>