pending.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. <template>
  2. <scroll-view class="container" :scroll-y="scrollY" @scrolltolower="scrolltolower">
  3. <view class="top_bg" v-if="dataList.length"></view>
  4. <view class="body" v-if="dataList.length">
  5. <!-- 每一个订单区域 -->
  6. <view class="body_item" :class="{ body_events: isClick }" v-for="item in dataList" :key="item.id" @click="handleGoDetail(item)">
  7. <!-- 工单编号 -->
  8. <view class="item_title">
  9. <img src="../../static/images/repairsImg/order.png" />
  10. <view class="title_info">工单编号:{{ item.recordNo }}</view>
  11. </view>
  12. <!-- 报修时间 -->
  13. <view class="item_time">
  14. <view class="time_msg">
  15. 报修时间:
  16. <text>{{ item.reportTime }}</text>
  17. </view>
  18. <view class="time_type">{{ item.state }}</view>
  19. </view>
  20. <!-- 报修姓名 -->
  21. <view class="item_box">
  22. <view class="box_key">报修姓名:</view>
  23. <view class="box_value">{{ item.userName }}</view>
  24. </view>
  25. <!-- 报修电话 -->
  26. <view class="item_box">
  27. <view class="box_key">报修电话:</view>
  28. <view class="box_value phone" @click.stop="handleCallPhone(item.userPhone)">
  29. {{ item.userPhone }}
  30. <img src="../../static/images/repairsImg/phone.png" />
  31. </view>
  32. </view>
  33. <!-- 报修区域 -->
  34. <view class="item_box">
  35. <view class="box_key">报修区域:</view>
  36. <view class="box_value">{{ item.areaName }}</view>
  37. </view>
  38. <!-- 详细地址 -->
  39. <view class="item_box">
  40. <view class="box_key">详细地址:</view>
  41. <view class="box_value">{{ item.address }}</view>
  42. </view>
  43. <!-- 报修物品 -->
  44. <view class="item_box">
  45. <view class="box_key">报修物品:</view>
  46. <view class="box_value">{{ item.articleName }}</view>
  47. </view>
  48. <!-- 故障描述 -->
  49. <view class="item_box" v-if="item.description">
  50. <view class="box_key">故障描述:</view>
  51. <view class="box_value">{{ item.description }}</view>
  52. </view>
  53. <!-- 报修录音 -->
  54. <view class="item_box" v-if="item.voice">
  55. <view class="box_key">报修录音:</view>
  56. <view class="box_value">
  57. <view class="recording" @click.stop="handlePlayRecording(item)">
  58. <img class="voiceImg" :src="item.status ? '../../static/images/repairsImg/play_active.png' : '../../static/images/repairsImg/play.png'" />
  59. {{ item.voiceLength }}″
  60. </view>
  61. </view>
  62. </view>
  63. <!-- 上传图片 -->
  64. <view class="item_img">
  65. <view class="img_key">上传图片:</view>
  66. <img class="img_value" mode="aspectFill" :src="item.images[0]" @click.stop="handleLookImgs(item.images)" />
  67. </view>
  68. <!-- 按钮区域 -->
  69. <view class="item_btn">
  70. <img src="../../static/images/repairsImg/close.png" @click.stop="handleClose(item)" />
  71. <view class="btn_box type" v-if="btns.includes('延时')" @click.stop="handleDelay(item)">延时</view>
  72. <view class="btn_box type" v-if="btns.includes('接单')" @click.stop="handleOrderReceiving(item)">接单</view>
  73. <view class="btn_box type2" v-if="btns.includes('派单')" @click.stop="handleSendOrder(item)">派单</view>
  74. </view>
  75. </view>
  76. <!-- 关闭按钮弹窗 -->
  77. <uni-popup ref="popup_close" :is-mask-click="false">
  78. <view class="popup_close" @click.stop="">
  79. <view
  80. :class="[{ active: activeIndex === index }, { radius: index === 0 }]"
  81. class="close_box"
  82. v-for="(ele, index) in closeList"
  83. :key="ele.id"
  84. @click="handleChangeItem(index)"
  85. >
  86. {{ ele.name }}
  87. </view>
  88. <view class="close_btn">
  89. <view
  90. class="btn_box cancel"
  91. @click="
  92. $refs.popup_close.close()
  93. isClick = false
  94. "
  95. >
  96. 取消
  97. </view>
  98. <view class="btn_box confirm" @click="handleCloseConfirm">确定</view>
  99. </view>
  100. </view>
  101. </uni-popup>
  102. </view>
  103. <!-- 没有数据时展示的图片 -->
  104. <view class="no_data" v-if="dataList.length === 0">
  105. <img src="../../pagesClockIn/static/imgs/nodata.png" />
  106. <view>暂无数据</view>
  107. </view>
  108. </scroll-view>
  109. </template>
  110. <script>
  111. const innerAudioContext = uni.createInnerAudioContext()
  112. export default {
  113. data() {
  114. return {
  115. scrollY: true,
  116. // 按钮权限
  117. btns: [],
  118. // 关闭按钮弹窗当前索引
  119. activeIndex: 0,
  120. // 关闭按钮弹窗选项数组
  121. closeList: [],
  122. // 工单数据数组
  123. dataList: [],
  124. // 当前页
  125. currentPage: 1,
  126. // 每页多少条
  127. pageCount: 4,
  128. // 总条数
  129. total: null,
  130. // 用户ID
  131. userId: '',
  132. // 订单id
  133. orderId: '',
  134. // 校区Id
  135. schoolId: '',
  136. // 每一个订单点击时是否触发事件 true 不触发 false 触发
  137. isClick: false
  138. }
  139. },
  140. mounted() {
  141. const repairsUserInfo = uni.getStorageSync('repairsUserInfo')
  142. this.userId = repairsUserInfo.userId
  143. this.btns = repairsUserInfo.btns
  144. this.schoolId = repairsUserInfo.schoolId
  145. this.getData()
  146. this.getCloseList()
  147. },
  148. methods: {
  149. // 滚动到底部触发回调
  150. scrolltolower() {
  151. if (this.total > this.dataList.length) {
  152. this.currentPage++
  153. this.getData()
  154. } else {
  155. uni.showToast({
  156. title: '没有更多数据了',
  157. icon: 'none'
  158. })
  159. }
  160. },
  161. // 获取关闭订单原因数组
  162. async getCloseList() {
  163. const res = await this.$myRequest_repairs({
  164. url: '/repairClose/queryRepairCloses'
  165. })
  166. // console.log(res)
  167. if (res.code === '200') {
  168. this.closeList = res.data
  169. }
  170. },
  171. // 获取待处理订单数据
  172. async getData() {
  173. const res = await this.$myRequest_repairs({
  174. url: '/repairRecord/queryPendingOrder',
  175. data: {
  176. currentPage: this.currentPage,
  177. pageCount: this.pageCount,
  178. schoolId: this.schoolId
  179. }
  180. })
  181. // console.log(res)
  182. if (res.code === '200') {
  183. this.total = res.data.totalCount
  184. res.data.list.forEach((ele) => {
  185. return (ele.status = false)
  186. })
  187. this.dataList = [...this.dataList, ...res.data.list]
  188. }
  189. },
  190. // 接单按钮回调
  191. handleOrderReceiving(item) {
  192. uni.showModal({
  193. content: '确定接单吗?',
  194. title: '提示',
  195. success: async (res) => {
  196. if (res.confirm) {
  197. const res = await this.$myRequest_repairs({
  198. url: '/repairRecord/receiveOrders',
  199. data: {
  200. recordId: item.id,
  201. userId: this.userId
  202. }
  203. })
  204. // console.log(res)
  205. if (res.code === '200') {
  206. uni.showToast({
  207. title: '接单成功',
  208. icon: 'success',
  209. mask: true
  210. })
  211. setTimeout(() => {
  212. this.dataList = []
  213. this.currentPage = 1
  214. this.getData()
  215. }, 1500)
  216. }
  217. }
  218. }
  219. })
  220. },
  221. // 关闭图标点击回调
  222. handleClose(item) {
  223. this.isClick = true
  224. this.orderId = item.id
  225. this.activeIndex = 0
  226. this.$refs.popup_close.open('center')
  227. },
  228. // 关闭弹窗确定按钮回调
  229. handleCloseConfirm() {
  230. uni.showModal({
  231. title: '提示',
  232. content: '确定关闭订单吗?',
  233. success: async (res) => {
  234. if (res.confirm) {
  235. const res = await this.$myRequest_repairs({
  236. url: '/repairRecord/closeOrder',
  237. data: {
  238. recordId: this.orderId,
  239. userId: this.userId,
  240. reason: this.closeList[this.activeIndex].name
  241. }
  242. })
  243. // console.log(res)
  244. if (res.code === '200') {
  245. uni.showToast({
  246. title: '关单成功',
  247. icon: 'success',
  248. mask: true
  249. })
  250. this.$refs.popup_close.close()
  251. setTimeout(() => {
  252. this.dataList = []
  253. this.currentPage = 1
  254. this.getData()
  255. }, 1500)
  256. }
  257. this.isClick = false
  258. }
  259. }
  260. })
  261. },
  262. // 关闭按钮弹窗选中按钮时回调
  263. handleChangeItem(val) {
  264. this.activeIndex = val
  265. },
  266. // 延时按钮回调
  267. handleDelay(item) {
  268. uni.navigateTo({
  269. url: `/pagesRepairs/delay/delay?id=${item.id}`
  270. })
  271. },
  272. // 派单按钮回调
  273. handleSendOrder(item) {
  274. uni.navigateTo({
  275. url: `/pagesRepairs/helpPeople/helpPeople?type=1&id=${item.id}`
  276. })
  277. },
  278. // 点击电话号码回调
  279. handleCallPhone(phone) {
  280. // console.log(phone)
  281. uni.makePhoneCall({
  282. phoneNumber: phone
  283. })
  284. },
  285. // 点击图片回调
  286. handleLookImgs(img) {
  287. // console.log(img)
  288. uni.previewImage({
  289. urls: img
  290. })
  291. },
  292. // 点击录音播放回调
  293. handlePlayRecording(item) {
  294. this.dataList.forEach((ele) => {
  295. if (ele.id !== item.id) {
  296. ele.status = false
  297. }
  298. })
  299. innerAudioContext.src = item.voice
  300. if (!item.status) {
  301. item.status = true
  302. innerAudioContext.play()
  303. //播放结束
  304. innerAudioContext.onEnded(() => {
  305. item.status = false
  306. })
  307. } else {
  308. item.status = false
  309. innerAudioContext.stop()
  310. }
  311. },
  312. // 点击每一个订单回调
  313. handleGoDetail(item) {
  314. uni.navigateTo({
  315. url: `/pagesRepairs/repairDetails/repairDetails?id=${item.id}`
  316. })
  317. }
  318. }
  319. }
  320. </script>
  321. <style lang="scss" scoped>
  322. .container {
  323. width: 100vw;
  324. height: calc(100vh - 152rpx);
  325. font-size: 32rpx;
  326. overflow-y: auto;
  327. .top_bg {
  328. height: 165rpx;
  329. background-color: #6fb6b8;
  330. }
  331. .body {
  332. box-sizing: border-box;
  333. margin: auto;
  334. margin-top: -100rpx;
  335. padding: 2rpx;
  336. width: 690rpx;
  337. border-radius: 11rpx 11rpx 0 0;
  338. background-color: #fff;
  339. overflow-y: auto;
  340. .body_item {
  341. margin-bottom: 20rpx;
  342. padding-bottom: 35rpx;
  343. border-radius: 11rpx;
  344. box-shadow: 0 0 8rpx #d9d9d9;
  345. .item_title {
  346. display: flex;
  347. align-items: center;
  348. padding: 0 30rpx;
  349. height: 87rpx;
  350. border-bottom: 1rpx solid #e6e6e6;
  351. img {
  352. width: 30rpx;
  353. height: 30rpx;
  354. }
  355. .title_info {
  356. margin: 0 21rpx 0 13rpx;
  357. // font-size: 28rpx;
  358. }
  359. }
  360. .item_time {
  361. display: flex;
  362. justify-content: space-between;
  363. align-items: center;
  364. padding: 0 30rpx;
  365. height: 79rpx;
  366. .time_msg {
  367. color: #808080;
  368. text {
  369. color: #000000;
  370. }
  371. }
  372. .time_type {
  373. font-size: 32rpx;
  374. color: #ff5733;
  375. }
  376. }
  377. .item_box {
  378. display: flex;
  379. align-items: center;
  380. padding: 0 30rpx;
  381. line-height: 60rpx;
  382. .box_key {
  383. width: 160rpx;
  384. color: #808080;
  385. }
  386. .box_value {
  387. flex: 1;
  388. max-width: calc(100% - 160rpx);
  389. display: flex;
  390. align-items: center;
  391. img {
  392. margin-left: 10rpx;
  393. width: 45rpx;
  394. height: 45rpx;
  395. }
  396. .recording {
  397. display: flex;
  398. align-items: center;
  399. margin: 15rpx 0;
  400. width: 130rpx;
  401. height: 40rpx;
  402. color: #000;
  403. border-radius: 100rpx;
  404. border: 1rpx solid #cccccc;
  405. .voiceImg {
  406. margin: 0 12rpx;
  407. width: 30rpx;
  408. height: 30rpx;
  409. }
  410. }
  411. }
  412. .phone {
  413. color: #6fb6b8;
  414. }
  415. }
  416. .item_img {
  417. display: flex;
  418. align-items: center;
  419. padding: 0 30rpx;
  420. height: 120rpx;
  421. color: #808080;
  422. // font-size: 28rpx;
  423. .img_key {
  424. }
  425. .img_value {
  426. width: 120rpx;
  427. height: 120rpx;
  428. border-radius: 14rpx;
  429. }
  430. }
  431. .item_btn {
  432. display: flex;
  433. align-items: center;
  434. justify-content: flex-end;
  435. padding: 0 30rpx;
  436. margin-top: 35rpx;
  437. img {
  438. margin-right: auto;
  439. width: 56rpx;
  440. height: 56rpx;
  441. }
  442. .btn_box {
  443. display: flex;
  444. justify-content: center;
  445. align-items: center;
  446. margin-left: 16rpx;
  447. width: 174rpx;
  448. height: 68rpx;
  449. border-radius: 11rpx;
  450. }
  451. .type {
  452. color: #fff;
  453. background-color: #6fb6b8;
  454. }
  455. .type2 {
  456. color: #6fb6b8;
  457. background-color: #fff;
  458. border: 1rpx solid #6fb6b8;
  459. }
  460. }
  461. }
  462. .popup_close {
  463. width: 690rpx;
  464. border-radius: 19rpx;
  465. background-color: #fff;
  466. .close_box {
  467. height: 100rpx;
  468. line-height: 100rpx;
  469. text-align: center;
  470. font-size: 32rpx;
  471. border: 1rpx solid #e6e6e6;
  472. }
  473. .radius {
  474. border-radius: 19rpx 19rpx 0 0;
  475. }
  476. .active {
  477. color: #fff;
  478. background-color: #6fb6b8;
  479. }
  480. .close_btn {
  481. display: flex;
  482. align-items: center;
  483. justify-content: space-evenly;
  484. margin-top: 100rpx;
  485. height: 121rpx;
  486. .btn_box {
  487. display: flex;
  488. justify-content: center;
  489. align-items: center;
  490. width: 203rpx;
  491. height: 72rpx;
  492. border-radius: 9rpx;
  493. font-size: 32rpx;
  494. }
  495. .cancel {
  496. background-color: #e5e5e5;
  497. color: #6fb6b8;
  498. }
  499. .confirm {
  500. background-color: #6fb6b8;
  501. color: #fff;
  502. }
  503. }
  504. }
  505. .body_events {
  506. pointer-events: none;
  507. }
  508. }
  509. .no_data {
  510. text-align: center;
  511. color: #b3b3b3;
  512. font-size: 24rpx;
  513. img {
  514. margin: 215rpx auto 0;
  515. width: 480rpx;
  516. height: 508rpx;
  517. }
  518. }
  519. }
  520. </style>