Blame view

pages/apply/dynamicModel/components/list/index.vue 10.1 KB
290144e9   易尊强   第一次
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
  <template>
  	<view class="dynamicModel-list-v">
  		<view class="head-warp com-dropdown">
  			<u-dropdown class="u-dropdown" ref="uDropdown">
  				<u-dropdown-item title="排序" :options="sortOptions">
  					<view class="dropdown-slot-content">
  						<view class="dropdown-slot-content-main">
  							<u-cell-group>
  								<u-cell-item @click="cellClick(item)" :arrow="false" :title="item.label"
  									v-for="(item, index) in sortOptions" :key="index" :title-style="{
  									color: sortValue == item.value ? '#2979ff' : '#606266' }">
  									<u-icon v-if="sortValue == item.value" name="checkbox-mark" color="#2979ff"
  										size="32"></u-icon>
  								</u-cell-item>
  							</u-cell-group>
  						</view>
  						<view class="dropdown-slot-bg" @click="$refs.uDropdown.close()"></view>
  					</view>
  				</u-dropdown-item>
  				<u-dropdown-item title="筛选">
  					<view class="dropdown-slot-content">
  						<view class="dropdown-slot-content-main search-main">
  							<view class="u-p-l-32 u-p-r-32 search-form">
  								<Parser :formConf="searchList" ref="searchForm" v-if="showParser"
  									@submit="sumbitSearchForm" />
  							</view>
  							<view class="buttom-actions">
  								<u-button class="buttom-btn" @click="reset">重置</u-button>
9b1c150c   “wangming”   1
29
  								<u-button class="buttom-btn" style="background-color: #e60012;" type="primary" @click="closeDropdown">检索</u-button>
290144e9   易尊强   第一次
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  							</view>
  						</view>
  						<view class="dropdown-slot-bg" @click="$refs.uDropdown.close()"></view>
  					</view>
  				</u-dropdown-item>
  			</u-dropdown>
  			<view class="u-border-bottom"></view>
  			<!-- 			<view class="search-box">
  				<u-search placeholder="请输入关键词搜索" v-model="listQuery.keyword" height="72" :show-action="false"
  					@change="search" bg-color="#f0f2f6" shape="square">
  				</u-search>
  			</view> -->
  		</view>
  		<view class="list-warp">
  			<mescroll-uni ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :fixed="false"
  				:down="downOption" :up="upOption">
  				<view class="list">
9b1c150c   “wangming”   1
47
48
49
50
51
52
  					<view class="list-box" v-for="(item, index) in list" :key="item.id" style="width: 96%;margin: 0 auto;background-color: white;margin-top: 20rpx;padding-bottom: 10rpx; border-radius: 20rpx;">
  						<view class="titleall-box">
  							<view class="titleall-left">
  								<view class="titleall-left-line"></view>填写信息
  							</view>
  						</view>
290144e9   易尊强   第一次
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
  						<u-swipe-action :index="index" :show="item.show" @click="handleClick" @open="open"
  							:options="options" @content-click="goDetail(item.id,item.flowState)">
  							<view class="item">
  								<view class="item-cell u-line-1" v-for="(column,i) in columnList" :key="i">
  									<text>{{column.label}}:</text>
  									<text>{{item[column.prop]}}</text>
  								</view>
  								<view class="item-cell" v-if="config.webType==3">
  									<text>审批状态:</text>
  									<text :class="getFlowStatus(item.flowState).statusCss">
  										{{getFlowStatus(item.flowState).text}}
  									</text>
  								</view>
  							</view>
  						</u-swipe-action>
  					</view>
  				</view>
  			</mescroll-uni>
  		</view>
  		<view class="com-addBtn" @click="goDetail()">
  			<u-icon name="plus" size="60" color="#fff" />
  		</view>
  	</view>
  </template>
  
  <script>
  	import resources from '@/libs/resources.js'
  	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  	import Parser from '../parser/index.vue'
  	import {
  		getModelList,
  		deteleModel
  	} from '@/api/apply/visualDev'
  	export default {
  		mixins: [MescrollMixin],
  		props: ['config', 'modelId', 'isPreview', 'title'],
  		components: {
  			Parser
  		},
  		data() {
  			return {
  				sortValue: '',
  				downOption: {
  					use: true,
  					auto: false
  				},
  				upOption: {
  					page: {
  						num: 0,
  						size: 20,
  						time: null
  					},
  					empty: {
  						use: true,
  						icon: resources.message.nodata,
  						tip: "暂无数据",
  						fixed: true,
  						top: "300rpx",
  						zIndex: 5
  					},
  					textNoMore: '没有更多数据',
  					toTop: {
  						bottom: 250
  					}
  				},
  				list: [],
  				listQuery: {
  					sort: 'desc',
  					sidx: '',
  					keyword: '',
  					json: ''
  				},
  				options: [{
  					text: '删除',
  					style: {
  						backgroundColor: '#dd524d'
  					}
  				}],
  				showParser: false,
  				columnData: {},
  				columnList: [],
  				sortOptions: [],
  				searchList: []
  			}
  		},
  		created() {
  			this.init()
  			uni.$on('refresh', () => {
  				this.list = [];
  				this.mescroll.resetUpScroll();
  			})
  		},
  		beforeDestroy() {
  			uni.$off('refresh')
  		},
  		methods: {
  			init() {
  				this.columnData = JSON.parse(this.config.columnData)
  				this.upOption.page.size = this.columnData.hasPage ? this.columnData.pageSize : 1000000
  				this.setDefaultQuery()
  				this.columnList = this.columnData.columnList
  				this.searchList = this.columnData.searchList
  				const sortList = this.columnData.sortList
  				let sortOptions = [];
  				for (let i = 0; i < sortList.length; i++) {
  					let ascItem = {
  						label: sortList[i].label + '升序',
  						value: sortList[i].prop + 'asc',
  						sidx: sortList[i].prop,
  						sort: 'asc'
  					}
  					let descItem = {
  						label: sortList[i].label + '降序',
  						sidx: sortList[i].prop,
  						value: sortList[i].prop + 'desc',
  						sort: 'desc'
  					}
  					sortOptions.push(ascItem, descItem)
  				}
  				this.sortOptions = sortOptions
  				this.showParser = true
  			},
  			setDefaultQuery() {
  				this.listQuery.sort = this.columnData.sort
  				this.listQuery.sidx = this.columnData.defaultSidx
  			},
  			upCallback(page) {
  				if (this.isPreview == '1') return this.mescroll.endSuccess(0, false);
  				const query = {
  					currentPage: page.num,
  					pageSize: page.size,
  					...this.listQuery
  				}
  				getModelList(this.modelId, query, {
  					load: page.num == 1
  				}).then(res => {
  					if (this.columnData.hasPage) {
  						this.mescroll.endSuccess(res.data.list.length);
  					} else {
  						this.mescroll.endSuccess(res.data.list.length, false);
  					}
  					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 (this.config.webType == 3 && [1, 2, 3, 5].includes(item.flowState)) {
  					this.$u.toast("流程正在审核,请勿删除")
  					this.list[index].show = false
  					return
  				}
  				deteleModel(this.modelId, 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() {
  				if (this.isPreview == '1') return
  				this.searchTimer && clearTimeout(this.searchTimer)
  				this.searchTimer = setTimeout(() => {
  					this.list = [];
  					this.mescroll.resetUpScroll();
  				}, 300)
  			},
  			goDetail(id, status) {
  				if (this.config.webType == 3) {
  					let opType = '-1'
  					if ([1, 2, 3, 5].includes(status)) opType = 0
  					const config = {
  						id: id || '',
  						enCode: this.config.flowEnCode,
  						flowId: this.config.flowId,
  						formType: 2,
  						type: 1,
  						opType,
  						status: status || '',
  						isPreview: this.isPreview,
  						fullName: id ? '编辑' : '新增'
  					}
  					uni.navigateTo({
  						url: '/pages/workFlow/flowBefore/index?config=' + encodeURIComponent(JSON.stringify(
  							config))
  					})
  				} else {
  					uni.navigateTo({
  						url: '/pages/apply/dynamicModel/form?modelId=' + this.modelId + '&isPreview=' +
  							this.isPreview + (id ? '&id=' + id : '')
  					})
  				}
  			},
  			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
  			},
  			cellClick(item) {
  				if (this.sortValue === item.value) return
  				this.listQuery.sort = item.sort
  				this.listQuery.sidx = item.sidx
  				this.sortValue = item.value
  				this.$refs.uDropdown.close();
  				if (this.isPreview == '1') return
  				this.$nextTick(() => {
  					this.list = [];
  					this.mescroll.resetUpScroll();
  				})
  			},
  			reset() {
  				this.$nextTick(() => {
  					this.showParser = false
  					this.$nextTick(() => {
  						this.showParser = true
  						this.$refs.searchForm && this.$refs.searchForm.resetForm()
  					})
  				})
  			},
  			closeDropdown() {
  				if (this.isPreview == '1') {
  					uni.showToast({
  						title: '功能预览不支持检索',
  						icon: 'none'
  					})
  					return
  				}
  				this.$refs.searchForm && this.$refs.searchForm.submitForm()
  			},
  			sumbitSearchForm(data) {
  				const json = data || {}
  				this.listQuery.json = JSON.stringify(json) !== '{}' ? JSON.stringify(json) : ''
  				this.$refs.uDropdown.close();
  				this.$nextTick(() => {
  					this.list = [];
  					this.mescroll.resetUpScroll();
  				})
  			}
  		}
  	}
  </script>
  
  <style lang="scss">
  	page {
9b1c150c   “wangming”   1
351
  		background-color: #f6f6f6;
290144e9   易尊强   第一次
352
353
354
355
356
  		height: 100%;
  		/* #ifdef MP-ALIPAY */
  		position: absolute;
  		top: 0;
  		left: 0;
9b1c150c   “wangming”   1
357
  		width: 96%;
290144e9   易尊强   第一次
358
359
  		/* #endif */
  	}
9b1c150c   “wangming”   1
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
  	.titleall-box {
  		display: flex;
  		justify-content: space-between;
  		padding: 40rpx 20rpx 20rpx 0;
  		.titleall-left {
  			font-size: 32rpx;
  			font-weight: bold;
  			display: flex;
  			align-items: center;
  			.titleall-left-line {
  				width: 14rpx;
  				height: 36rpx;
  				border-radius: 0 10rpx 10rpx 0;
  				background-color: #E60012;
  				box-shadow: 0 0 10rpx 5rpx #fbdadc;
  				margin-right: 20rpx;
  			}
  			text {
  				font-size: 28rpx;
  				color: #999999;
  			}
  		}
  	}
290144e9   易尊强   第一次
383
  </style>