inspectionRecord.vue
5.64 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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<template>
<!-- 巡检记录列表页面 -->
<view class="inspection-record">
<!-- 搜索页面 -->
<view class="inspection-search">
<PageOptions :options="indicatorsList" :has-today="true" :options-props="indicatorsOptions" @change="handleStoreChange"></PageOptions>
<!-- <DatePicker @change="handleDateChange"></DatePicker> -->
</view>
<!-- 列表内容 -->
<view class="inspection-record-container">
<!-- 此为循环项 -->
<template v-if="recordDataList.length > 0">
<view
v-for="item in recordDataList"
:key="item.id"
class="record-item"
@click="handleDetail(item)"
>
<view class="record-item-header">
<view class="header-left-part">
<view class="header-icon">
<uv-icon name="order" size="18px"></uv-icon>
</view>
<view class="record-number">
{{item.sn}}
</view>
</view>
<view class="header-right-part">
<uv-tags
:text="getStatusInfo(item.status)[0]"
:color="getStatusInfo(item.status)[2]"
:bgColor="getStatusInfo(item.status)[1]"
:borderColor="getStatusInfo(item.status)[1]"
plain
shape="circle"
></uv-tags>
</view>
</view>
<view class="record-item-body">
<view class="record-detail">
<view
v-for="rItem in detailList"
:key="rItem.key"
class="record-detail-row"
>
<view class="detail-title">
{{rItem.label}}
</view>
<view class="detail-content">
{{getDetailValue(rItem.key, item)}}
</view>
</view>
</view>
</view>
</view>
</template>
<uv-empty v-else mode="list" marginTop="100"></uv-empty>
</view>
</view>
</template>
<script setup>
import { ref, } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { getStageObj } from '@/utils'
import { doGetInspectionListApi } from '@/api';
// import DatePicker from '@/components/DatePicker.nvue'
import PageOptions from '@/components/PageOptions.vue'
// import MockDataList from './mockData.json'
import { getDetailOptions, getStatusOptions, getDetailValueByKey } from './config.js'
import { t } from '@/plugins/index.js'
const waitMe = ref(false) // 是否是待我处理
const indicatorsList = ref(getStatusOptions())
const indicatorsOptions = {
label: 'indexName',
value: 'indexKey'
}
const stashData = ref({
val:'',
type:''
})
const onPageLoad = ref(true)
onShow(()=>{
if(onPageLoad.value){
onPageLoad.value = false
return
}
handleStoreChange(stashData.value.val, stashData.value.type)
})
const handleStoreChange = (val, type) => {
stashData.value = {
val,
type
}
console.log('handleStoreChange', val, type)
getInspectionList({
startDate: val.range[0],
endDate: val.range[1],
mallId: val.storeId,
// mallId: undefined,
// mallId: 9218,
status: val.indicatorKey || '',
waitMe: waitMe.value,
})
}
const detailList = ref(getDetailOptions())
const recordDataList = ref([])
function getInspectionList(data) {
const storeInfo = getStageObj('store') || {}
const params = Object.assign({
// mallId: storeInfo.id,
accountId: storeInfo.accountId,
// accountId: 337, // 临时定为 337
// TODO: 需要按需加载,暂时设置为999
pageNum: 1,
pageSize: 999,
// startDate: '',
// endDate: '',
patrolType: waitMe.value ? '' : 1,
}, data)
doGetInspectionListApi(params).then(res => {
console.log('doGetInspectionListApi', res)
// console.log('MockDataList', MockDataList)
// recordDataList.value = MockDataList
recordDataList.value = res.data.list || []
})
}
function getDetailValue(key, data) {
return getDetailValueByKey(key, data)
}
function getStatusInfo(status) {
switch (status){
case 1:
return [t('dictionary.pending'), '#FDEEEE', '#F32C2C']
case 2:
return [t('dictionary.reexamine'), '#FFF7E8', '#FF7E01']
case 3:
return [t('dictionary.completed'), '#DDE9FF', '#387CF5']
default:
return [t('maintenance.common.unknown'), '', '']
}
}
function handleDetail(item) {
console.log('handleDetail', item)
const origin = waitMe.value ? 'processing' : 'record'
uni.navigateTo({
url: `/subPackages/accountGroup/pages/inspection/inspectionDetail?id=${item.id}&origin=${origin}`,
})
}
onLoad((options) => {
console.log('options', options)
// getInspectionList()
waitMe.value = (options.origin === 'processing')
uni.setNavigationBarTitle({
title: t('Management.storeInspectionRecord')
})
// 设置页面标题
if (waitMe.value) {
uni.setNavigationBarTitle({
title: t('app.home.waitMeDeal'),
});
}
})
</script>
<style lang="scss" scoped>
.inspection-record {
min-height: 100vh;
background-color: #F2F3F6;
}
.inspection-search {
}
.inspection-record-container {
// margin-top: 10px;
padding: 0px 10px 10px 10px;
.record-item {
background-color: #FFF;
border-radius: 8px;
margin-bottom: 10px;
font-size: 14px;
}
.record-item-header {
height: 42px;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid #EEF0F3;
padding: 0px 10px;
.header-left-part {
display: flex;
flex-direction: row;
/* justify-content: center; */
align-items: center;
.header-icon {
margin-right: 6px;
}
}
}
.record-item-body {
.record-detail {
padding: 10px;
}
.record-detail-row {
display: flex;
margin-bottom: 6px;
.detail-title {
margin-right: 10px;
color: #202328;
/* font-size: 13px; */
}
.detail-content {
color: #6D778F;
}
}
}
}
</style>