车间能级提升-智能设备管理系统
zhuguifei
2025-04-27 d7862b2890b68743ec9c4fc05800bb23ec9b412e
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
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
<route lang="json5">
{
  layout: 'default',
  needLogin: true,
  style: {
    navigationBarTitleText: '设备维修',
    'app-plus': {
      titleNView: {
        buttons: [
          {
            text: '接单',
            fontSize: '14px',
            color: '#FFFFFF',
          },
          {
            text: '',
            fontSize: '24px',
            color: '#FFFFFF',
          },
        ],
      },
    },
  },
}
</route>
<template>
  <z-paging ref="paging" v-model="dataList" @query="queryList" show-refresher-update-time>
    <template #top>
      <wd-drop-menu>
        <wd-drop-menu-item
          v-model="resTypeId"
          label-key="dictLabel"
          value-key="dictValue"
          :options="resTypeList"
          @change="handleResType"
        />
        <wd-drop-menu-item
          v-model="status"
          label-key="dictLabel"
          value-key="dictValue"
          :options="statusList"
          @change="handleResStatu"
        />
      </wd-drop-menu>
    </template>
 
    <view class="bg-base">
      <wd-card type="rectangle" v-for="(item, index) in dataList" :key="item.id">
        <template #title>
          <view class="flex justify-between items-center">
            <view class="flex items-center menu-title-box">
              <view class="menu-indicator"></view>
              <text class="ml-1 text-xs">{{ item.resCode }}</text>
              <text class="text-color-gray ml-2 text-mini">接单:{{ item.createTime }}</text>
            </view>
 
            <view>
              <wd-tag size="small" v-if="item.status === '1'" type="warning">已接单</wd-tag>
              <wd-tag size="small" v-else-if="item.status === '2'" type="primary">维修中</wd-tag>
              <wd-tag size="small" v-else-if="item.status === '3'" type="success">已完成</wd-tag>
            </view>
          </view>
        </template>
        <view class="flex h-[240rpx] items-center" @click.stop="itemClick(item)">
          <image
            v-if="item.reqType === '1'"
            class="slot-img text-center"
            src="/static/ico/ico-huiyi.png"
          />
          <image
            v-else-if="item.reqType === '2'"
            class="slot-img text-center"
            src="/static/ico/ico-setting.png"
          />
          <image
            v-else-if="item.reqType === '3'"
            class="slot-img text-center"
            src="/static/ico/ico-faxian.png"
          />
          <view class="flex-1 mt-1">
            <view class="text-color-base">
              <template v-if="item.reqType === '1'">
                <text>设备类型</text>
                <text class="mx-2">|</text>
                <text>{{ item.equName }}</text>
              </template>
 
              <template v-if="item.reqType === '2'">
                <text>工具类型</text>
                <text class="mx-2">|</text>
                <text>{{ item.fixtureName }}</text>
              </template>
 
              <template v-if="item.reqType === '3'">
                <text>其他类型</text>
              </template>
              <view class="text-color-gray mt-1 text-mini">
                <text>报修人: {{ item.reqUserName }}</text>
              </view>
              <view class="text-color-gray mt-1 text-mini">
                <text>报修时间: {{ item.reqTime }}</text>
              </view>
 
              <view class="text-color-gray mt-1 text-mini">
                <text>开始时间: {{ item.startTime }}</text>
              </view>
              <view class="text-color-gray mt-1 text-mini">
                <text>完成时间: {{ item.endTime }}</text>
              </view>
              <view class="text-color-gray mt-1 text-mini">
                <text>维修人: {{ item.resUserName }}</text>
              </view>
            </view>
          </view>
          <view>
            <wd-button v-if="item.status === '1'"  size="small" icon="edit-outline">开始维修</wd-button>
            <wd-button v-if="item.status === '2'"  size="small" icon="edit-outline">维修中</wd-button>
            <wd-button v-if="item.status === '3'"  size="small" icon="edit-outline">已完成</wd-button>
          </view>
        </view>
      </wd-card>
    </view>
  </z-paging>
</template>
 
<script setup lang="ts">
import { onMounted, getCurrentInstance, ref } from 'vue'
import { useToast, useMessage } from 'wot-design-uni'
import { getRepairResList, addRepairRes } from '@/service/repair'
import { DICT_REPAIR_RES_STATUS, DICT_REPAIR_REQ_TYPE, getDictInfo } from '@/service/dict'
import { useUserStore } from '@/store'
const userStore = useUserStore()
 
const message = useMessage()
const toast = useToast()
// 维修单类型
const resTypeId = ref<number>(0)
// 维修单处理状态
const status = ref<number>(0)
 
const isSelectRes = ref(false)
 
const resTypeList = ref<any>([{ dictLabel: '所有类型', dictValue: 0 }])
const statusList = ref<any>([{ dictLabel: '所有状态', dictValue: 0 }])
function handleResType({ value }) {
  reloadData()
}
function handleResStatu({ value }) {
  reloadData()
}
 
const paging = ref(null)
const dataList = ref([])
 
const queryList = (pageNum?: number, pageSize?: number) => {
  const parmams = {
    pageNum,
    pageSize,
    reqType: resTypeId.value,
    status: status.value,
  }
  if (resTypeId.value === 0) {
    delete parmams.reqType
  }
  if (status.value === 0) {
    delete parmams.status
  }
  getRepairResList(parmams)
    .then((res: any) => {
      paging.value.completeByTotal(res.rows, res.total)
    })
    .catch((res) => {
      paging.value.complete(false)
    })
}
function reloadData() {
  paging.value.reload()
}
 
/**
 * 条目点击事件
 * @param item
 */
function itemClick(item: any) {}
 
onNavigationBarButtonTap((e) => {
  if (e.index === 0) {
    handleSelectReq()
  }
})
 
/**
 * 选择报修单
 */
function handleSelectReq() {
  uni.navigateTo({
    url: '/pages/repair/req-list',
    events: {
      // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
      selectReq: function (data) {
        console.error(data)
        // 选择报修单后,修改报修单状态和新增维修工单
        const resCode = `WXD${data.data.code.slice(3)}`
        const deptId = userStore?.userInfo?.deptId
        const userId = userStore?.userInfo?.userId
        const resData = {
          reqId: data.data.id,
          reqCode: data.data.code,
          reqUser: data.data.reqUser,
          reqDept: data.data.reqDept,
          resCode,
          status: '1',
          resUser: userId,
          resDept: deptId,
        }
        addRepairRes(resData)
          .then((res: any) => {
            if (res.code === 200) {
              toast.success(res?.msg || '操作成功')
              reloadData()
            } else {
              toast.error(res?.msg || '生成维修工单失败,请重试')
            }
          })
          .catch((res) => {
            toast.error(res?.msg || '生成维修工单失败,请重试')
          })
      },
    },
    success: function (res) {
      // 通过eventChannel向被打开页面传送数据
      res.eventChannel.emit('OnSelectReq', { data: '维修单页面选择报修单' })
    },
  })
}
 
async function initData() {
  const rList: any = await getDictInfo(DICT_REPAIR_REQ_TYPE)
  resTypeList.value.push(...rList)
  const sList: any = await getDictInfo(DICT_REPAIR_RES_STATUS)
  statusList.value.push(...sList)
}
onLoad((options) => {
  initData()
})
</script>
 
<style scoped lang="scss">
.menu-title-box {
  height: 30rpx;
  line-height: 30rpx;
}
 
.slot-img {
  width: 72rpx;
  height: 72rpx;
  margin-right: 24rpx;
}
.text-mini {
  font-size: 22rpx;
}
 
.menu-indicator {
  width: 6rpx;
  height: 22rpx;
  border-radius: 10rpx;
  background-color: $uni-color-primary;
}
:deep(.wd-card__title-content) {
  padding: 16rpx !important;
}
:deep(.wd-card__content) {
  padding: 16rpx !important;
}
:deep(.wd-card__footer) {
  padding: 10rpx !important;
}
</style>