|
@@ -0,0 +1,178 @@
|
|
1
|
+<template>
|
|
2
|
+ <view class="consumableList">
|
|
3
|
+ <view class="head">
|
|
4
|
+ <uni-search-bar v-model="dataInfo.keyWord" :placeholder="placeHolder" bgColor="#F8F8F8" @input="search" cancelButton="none" focus :radius="18" />
|
|
5
|
+ </view>
|
|
6
|
+ <view class="body" v-if="dataInfo.list.length">
|
|
7
|
+ <view class="body_item ellipsis" v-for="data in dataInfo.list" :key="data.id" @click="clickItem(data)">
|
|
8
|
+ {{data.name}}<template v-if="data.account">({{data.account}})</template>
|
|
9
|
+ </view>
|
|
10
|
+ </view>
|
|
11
|
+ <view class="zanwu" v-else>
|
|
12
|
+ <text class="newicon newicon-zanwu"></text>
|
|
13
|
+ </view>
|
|
14
|
+ <view class="foot_common_btns">
|
|
15
|
+ <button @click="goBack" type="default" class="primaryButton btn">返回</button>
|
|
16
|
+ </view>
|
|
17
|
+ </view>
|
|
18
|
+</template>
|
|
19
|
+
|
|
20
|
+<script setup>
|
|
21
|
+ import { debounce } from 'lodash-es'
|
|
22
|
+ import { ref, reactive} from 'vue'
|
|
23
|
+ import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
|
24
|
+ import { api_user } from "@/http/api.js"
|
|
25
|
+ import { defaultColor } from '@/static/js/theme.js'
|
|
26
|
+ import { useSetTitle } from '@/share/useSetTitle.js'
|
|
27
|
+ import { useLoginUserStore } from '@/stores/loginUser'
|
|
28
|
+ import { useIncidentBuildStore } from '@/stores/incidentBuild'
|
|
29
|
+ import { useGoBack } from '@/share/useGoBack.js'
|
|
30
|
+
|
|
31
|
+ useSetTitle();
|
|
32
|
+ const loginUserStore = useLoginUserStore();
|
|
33
|
+ const incidentBuildStore = useIncidentBuildStore();
|
|
34
|
+ const { goBack } = useGoBack();
|
|
35
|
+
|
|
36
|
+ // 主题颜色
|
|
37
|
+ const primaryColor = ref(defaultColor)
|
|
38
|
+
|
|
39
|
+ // placeHolder
|
|
40
|
+ const placeHolder = ref('');
|
|
41
|
+
|
|
42
|
+ // 数据
|
|
43
|
+ const dataInfo = reactive({
|
|
44
|
+ list: [],//工单列表
|
|
45
|
+ idx: 0,//页码
|
|
46
|
+ hasMore: true,//是否有更多数据
|
|
47
|
+ incidentData: {},//事件对象
|
|
48
|
+ keyWord: '',//搜索的关键词
|
|
49
|
+ })
|
|
50
|
+
|
|
51
|
+ // 搜索
|
|
52
|
+ const search = debounce(getList.bind(null, 0), 500);
|
|
53
|
+
|
|
54
|
+ // 获取列表信息
|
|
55
|
+ function getList(idx){
|
|
56
|
+ if(dataInfo.keyWord.trim() === ''){
|
|
57
|
+ dataInfo.list = [];
|
|
58
|
+ uni.stopPullDownRefresh();
|
|
59
|
+ return;
|
|
60
|
+ }
|
|
61
|
+
|
|
62
|
+ uni.showLoading({
|
|
63
|
+ title: "加载中",
|
|
64
|
+ mask: true,
|
|
65
|
+ });
|
|
66
|
+
|
|
67
|
+ dataInfo.idx = idx === undefined ? dataInfo.idx : idx;
|
|
68
|
+ if(dataInfo.idx === 0){
|
|
69
|
+ dataInfo.list = [];
|
|
70
|
+ }
|
|
71
|
+
|
|
72
|
+ let postData = {
|
|
73
|
+ idx: dataInfo.idx,
|
|
74
|
+ sum: 20,
|
|
75
|
+ user: {
|
|
76
|
+ simple: true,
|
|
77
|
+ engineer: undefined,
|
|
78
|
+ selectType: "pinyin_all",
|
|
79
|
+ name: dataInfo.keyWord,
|
|
80
|
+ }
|
|
81
|
+ }
|
|
82
|
+
|
|
83
|
+ api_user(postData).then(res => {
|
|
84
|
+ uni.hideLoading();
|
|
85
|
+ uni.stopPullDownRefresh();
|
|
86
|
+ if(res.status == 200){
|
|
87
|
+ let list = res.list || [];
|
|
88
|
+ if(list.length){
|
|
89
|
+ dataInfo.hasMore = true;
|
|
90
|
+ dataInfo.list = dataInfo.idx === 0 ? list : dataInfo.list.concat(list);
|
|
91
|
+ }else{
|
|
92
|
+ dataInfo.hasMore = false;
|
|
93
|
+ }
|
|
94
|
+ }else{
|
|
95
|
+ uni.showToast({
|
|
96
|
+ icon: 'none',
|
|
97
|
+ title: res.msg || '请求数据失败!'
|
|
98
|
+ });
|
|
99
|
+ }
|
|
100
|
+ })
|
|
101
|
+ }
|
|
102
|
+
|
|
103
|
+ // 点击
|
|
104
|
+ function clickItem(data){
|
|
105
|
+ dataInfo.incidentData.requester = data;
|
|
106
|
+ incidentBuildStore.setIncidentBuildData(dataInfo.incidentData, incidentBuildStore.incidentBuild.type, incidentBuildStore.incidentBuild.sign);
|
|
107
|
+ uni.navigateTo({
|
|
108
|
+ url: '/pages/buildIncident/buildIncident'
|
|
109
|
+ })
|
|
110
|
+ }
|
|
111
|
+
|
|
112
|
+ onLoad((option) => {
|
|
113
|
+ if(incidentBuildStore.incidentBuild.data){
|
|
114
|
+ dataInfo.incidentData = incidentBuildStore.incidentBuild.data;
|
|
115
|
+ }
|
|
116
|
+ if(incidentBuildStore.incidentBuild.type === 'buildIncident' && incidentBuildStore.incidentBuild.sign === 'requester'){
|
|
117
|
+ placeHolder.value = '请搜索报修人'
|
|
118
|
+ }
|
|
119
|
+ getList(0);
|
|
120
|
+ })
|
|
121
|
+
|
|
122
|
+ onPullDownRefresh(() => {
|
|
123
|
+ getList(0)
|
|
124
|
+ })
|
|
125
|
+
|
|
126
|
+ onReachBottom(() => {
|
|
127
|
+ dataInfo.idx += 1;
|
|
128
|
+ if (dataInfo.hasMore) {
|
|
129
|
+ getList(); // 当触底时加载更多数据
|
|
130
|
+ }
|
|
131
|
+ })
|
|
132
|
+</script>
|
|
133
|
+
|
|
134
|
+<style lang="scss" scoped>
|
|
135
|
+.consumableList{
|
|
136
|
+ display: flex;
|
|
137
|
+ flex-direction: column;
|
|
138
|
+ justify-content: space-between;
|
|
139
|
+ .head{
|
|
140
|
+ height: 88rpx;
|
|
141
|
+ display: flex;
|
|
142
|
+ align-items: center;
|
|
143
|
+ justify-content: center;
|
|
144
|
+ padding: 0 24rpx;
|
|
145
|
+ position: fixed;
|
|
146
|
+ z-index: 99;
|
|
147
|
+ width: 100%;
|
|
148
|
+ box-sizing: border-box;
|
|
149
|
+ background: linear-gradient( 90deg, #58CF66 0%, #DDE9FC 100%);
|
|
150
|
+ }
|
|
151
|
+ .body{
|
|
152
|
+ margin-bottom: 140rpx;
|
|
153
|
+ margin-top: 88rpx;
|
|
154
|
+ font-size: 26rpx;
|
|
155
|
+ .body_item{
|
|
156
|
+ border-bottom: 1rpx solid #DEDEDE;
|
|
157
|
+ padding: 24rpx;
|
|
158
|
+ }
|
|
159
|
+ }
|
|
160
|
+ .zanwu{
|
|
161
|
+ margin-bottom: 140rpx;
|
|
162
|
+ margin-top: 88rpx;
|
|
163
|
+ display: flex;
|
|
164
|
+ justify-content: center;
|
|
165
|
+ .newicon-zanwu{
|
|
166
|
+ font-size: 256rpx;
|
|
167
|
+ color: #D6D6D6;
|
|
168
|
+ margin-top: 140rpx;
|
|
169
|
+ }
|
|
170
|
+ }
|
|
171
|
+ .foot_common_btns{
|
|
172
|
+ position: fixed;
|
|
173
|
+ left: 0;
|
|
174
|
+ bottom: 0;
|
|
175
|
+ background-color: #fff;
|
|
176
|
+ }
|
|
177
|
+}
|
|
178
|
+</style>
|