myTicket.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. <template>
  2. <view class="kd-work-container">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" :title="orderType == 1 ? '工单待办' : '工单已办'" right-icon="scan" @clickLeft="back">
  4. <view slot="right">
  5. <view @click="HandlScanCode" class="scan_btn"></view>
  6. </view>
  7. </uni-nav-bar>
  8. <view class="top-wrapper">
  9. <view class="top-tabs">
  10. <u-tabs
  11. :list="tabList"
  12. :current="tabsCurrent"
  13. @change="handleTabChange"
  14. lineWidth="0"
  15. :activeStyle="{
  16. color: '#157a2c',
  17. fontWeight: 'bold'
  18. }"></u-tabs>
  19. </view>
  20. <view class="more_search">
  21. <image src="~@/static/moreSearch.svg" mode="" @click="searchShow = true"></image>
  22. </view>
  23. <!-- <view class="slide-search">
  24. <view class="more-search" v-show="moreSearch">
  25. <view class="cell">
  26. <view class="label">编号</view>
  27. <input type="text" placeholder="请输入" v-model="searchFrom.code" />
  28. </view>
  29. <view v-if="orderType == 1" class="cell">
  30. <view class="label">状态</view> -->
  31. <!-- <uni-data-select :key="activeType" :localdata="statusRange[activeType]" v-model="searchFrom.orderStatus"></uni-data-select> -->
  32. <!-- <u-checkbox-group v-model="searchFrom.orderStatus" placement="row" size="30" @change="statusChange">
  33. <u-checkbox
  34. v-for="(item, index) in statusRange[activeType]"
  35. :customStyle="{ marginRight: '8px' }"
  36. :label="item.text"
  37. :name="item.value"
  38. labelSize="30"
  39. iconSize="30"
  40. activeColor="#157A2C"></u-checkbox>
  41. </u-checkbox-group>
  42. </view> -->
  43. <!-- <view class="cell">
  44. <view class="label">紧急程度</view>
  45. <uni-data-select :localdata="doneRange" @change="doneChange" v-model="searchFrom.urgent" :clear="false"></uni-data-select>
  46. </view> -->
  47. <!-- <view class="btn-search">
  48. <button @click="reset">重置</button>
  49. <button class="primary" @click="doSearch">搜索</button>
  50. </view>
  51. </view>
  52. </view> -->
  53. </view>
  54. <view class="work-list">
  55. <u-list @scrolltolower="scrolltolower" :key="activeType" :preLoadScreen="page * 10">
  56. <u-list-item v-for="(item, index) in dataList" :key="index">
  57. <CardTime :time="item.createTime" />
  58. <KdCard :orderTitle="orderTitle" :title="item.code" @handleDetail="handleDetail" :status="true" :item="item" :type="activeType" />
  59. </u-list-item>
  60. <u-list-item v-if="dataList.length === 0">
  61. <view class="nodata">暂无数据</view>
  62. </u-list-item>
  63. </u-list>
  64. </view>
  65. <SearchPopup mode="top" v-if="searchShow">
  66. <template v-slot:list>
  67. <view class="search_list">
  68. <u-form labelPosition="left" :model="formData" labelWidth="180" labelAlign="left" class="baseForm">
  69. <u-form-item v-if="orderType == 1" label="类型:" class="required-form" borderBottom prop="assetType">
  70. <u-checkbox-group v-model="searchFrom.orderStatus" placement="row" size="30" @change="statusChange">
  71. <u-checkbox
  72. v-for="(item, index) in statusRange[activeType]"
  73. :customStyle="{ marginRight: '8px' }"
  74. :label="item.text"
  75. :name="item.value"
  76. labelSize="30"
  77. iconSize="30"
  78. activeColor="#157A2C"></u-checkbox>
  79. </u-checkbox-group>
  80. </u-form-item>
  81. <u-form-item label="编号:" class="required-form" borderBottom prop="assetType">
  82. <input type="text" placeholder="请输入编号" v-model="searchFrom.code" />
  83. </u-form-item>
  84. </u-form>
  85. </view>
  86. </template>
  87. <template v-slot:operate>
  88. <view class="operate_box rx-bc">
  89. <u-button size="small" class="u-reset-button mg-20" @click="searchShow = false">取消</u-button>
  90. <u-button type="warning" size="small" class="u-reset-button mg-20" @click="reset">重置</u-button>
  91. <u-button type="success" size="small" class="u-reset-button" @click="doSearch">确定</u-button>
  92. </view>
  93. </template>
  94. </SearchPopup>
  95. </view>
  96. </template>
  97. <script>
  98. import SearchPopup from '@/pages/pda/components/searchPopup.vue'
  99. import { getWorkOrderList, statistics } from '@/api/myTicket'
  100. import KdCard from '../components/KdCard/index.vue'
  101. import CardTime from '../components/CardTime.vue'
  102. import { getByFixCode } from '@/api/repair'
  103. import { nextTick } from 'vue'
  104. // import { postJ } from '@/utils/api'
  105. let [isEnd] = [false]
  106. export default {
  107. components: {
  108. KdCard,
  109. CardTime,
  110. SearchPopup
  111. },
  112. data() {
  113. return {
  114. formData: {},
  115. orderTitle: '',
  116. tabsCurrent: 0, // tabs初始位置
  117. doneRange: [
  118. {
  119. value: 1,
  120. text: '普通'
  121. },
  122. {
  123. value: 2,
  124. text: '紧急'
  125. },
  126. {
  127. value: 3,
  128. text: '重要'
  129. }
  130. ],
  131. tabList: [
  132. // {
  133. // name: '计划维修工单',
  134. // type: 'repair',
  135. // workOrderType: 4,
  136. // url: `/pages/maintain_service/detail/detail?`,
  137. // badge: {
  138. // value: 0
  139. // }
  140. // },
  141. {
  142. name: '保养工单',
  143. type: 'maintenance',
  144. workOrderType: 2,
  145. index: 0,
  146. url: `/pages/maintenance/detail/detail?`,
  147. badge: {
  148. value: 0
  149. }
  150. },
  151. {
  152. name: '巡点检工单',
  153. type: 'patrol',
  154. workOrderType: 1,
  155. index: 1,
  156. url: `/pages/tour_tally/detail/detail?`,
  157. badge: {
  158. value: 0
  159. }
  160. },
  161. // {
  162. // name: '量具送检工单',
  163. // type: 'quantity',
  164. // workOrderType: 5,
  165. // index: 2,
  166. // url: `/pages/quantity/detail/detail?`,
  167. // badge: {
  168. // value: 0
  169. // }
  170. // },
  171. {
  172. name: '维修工单',
  173. type: 'repair',
  174. workOrderType: 3,
  175. index: 2,
  176. // url: `/pages/maintain_service/detail/detail?`,
  177. url: `/pages/maintenanceWorkorder/detail/detail?`,
  178. badge: {
  179. value: 0
  180. }
  181. }
  182. ],
  183. activeType: 'maintenance',
  184. activeIndex: 0,
  185. dataList: [],
  186. searchShow: false,
  187. statusRange: {
  188. repair: [
  189. {
  190. value: 0,
  191. text: '待接收'
  192. },
  193. {
  194. value: 2,
  195. text: '执行中'
  196. }
  197. // {
  198. // value: 0,
  199. // text: '待接收'
  200. // },
  201. // {
  202. // value: 2,
  203. // text: '待审核'
  204. // },
  205. // {
  206. // value: 4,
  207. // text: '已撤回'
  208. // },
  209. // {
  210. // value: 6,
  211. // text: '已驳回'
  212. // },
  213. // {
  214. // value: 8,
  215. // text: '已派单'
  216. // },
  217. // {
  218. // value: 1,
  219. // text: '执行中'
  220. // },
  221. // {
  222. // value: 5,
  223. // text: '待验收'
  224. // },
  225. // {
  226. // value: 3,
  227. // text: '已完成'
  228. // },
  229. // {
  230. // value: 7,
  231. // text: '未修复'
  232. // }
  233. ],
  234. maintenance: [
  235. {
  236. value: 0,
  237. text: '待接收'
  238. },
  239. {
  240. value: 2,
  241. text: '执行中'
  242. }
  243. // {
  244. // value: 3,
  245. // text: '完成'
  246. // }
  247. ],
  248. patrol: [
  249. {
  250. value: 0,
  251. text: '待接收'
  252. },
  253. {
  254. value: 2,
  255. text: '执行中'
  256. }
  257. // {
  258. // value: 3,
  259. // text: '完成'
  260. // }
  261. ],
  262. quantity: [
  263. {
  264. value: 0,
  265. text: '待接收'
  266. },
  267. {
  268. value: 2,
  269. text: '执行中'
  270. },
  271. {
  272. value: 3,
  273. text: '完成'
  274. }
  275. ],
  276. check: [
  277. {
  278. value: 0,
  279. text: '待接收'
  280. },
  281. {
  282. value: 1,
  283. text: '执行中'
  284. },
  285. {
  286. value: 2,
  287. text: '待审核'
  288. },
  289. {
  290. value: 3,
  291. text: '完成'
  292. },
  293. {
  294. value: 4,
  295. text: '已撤回'
  296. },
  297. {
  298. value: 5,
  299. text: '待验收'
  300. },
  301. {
  302. value: 6,
  303. text: '已驳回'
  304. },
  305. {
  306. value: 7,
  307. text: '未修复'
  308. },
  309. {
  310. value: 8,
  311. text: '已派单'
  312. }
  313. ]
  314. },
  315. searchFrom: {
  316. code: '',
  317. orderStatus: []
  318. },
  319. page: 1,
  320. isInstall: true, // 是否首次进入页面
  321. orderType: 1
  322. }
  323. },
  324. onLoad(e) {
  325. this.$nextTick(() => {
  326. console.log(this)
  327. this.isInstall = false
  328. this.orderType = e.orderType // 1待办 2完成
  329. this.tabsCurrent = Number(e.index) ? Number(e.index) : 0
  330. this.$nextTick(async () => {
  331. if (this.orderType == 1) {
  332. await this.getCount()
  333. }
  334. this.handleTabChange(this.tabList[this.tabsCurrent])
  335. // console.log(this.tabList[this.tabsCurrent],5656)
  336. })
  337. })
  338. },
  339. onShow(e) {
  340. if (this.isInstall) return
  341. this.dataList = []
  342. this.getList()
  343. this.getCount()
  344. },
  345. methods: {
  346. // 相机扫码
  347. HandlScanCode() {
  348. uni.scanCode({
  349. success: res => {
  350. console.log('res------------------------')
  351. console.log(res.result)
  352. let obj = {}
  353. if (res.result.includes('/')) {
  354. let dataArray = res.result.split('/')
  355. obj = {
  356. fixCode: dataArray[0],
  357. code: ''
  358. }
  359. } else {
  360. obj = {
  361. fixCode: '',
  362. code: res.result
  363. }
  364. }
  365. getByFixCode(obj).then(res => {
  366. uni.navigateTo({
  367. url: `/pages/home/myTicket/detail?deviceId=${res.id}&type=${this.tabList[this.activeIndex].workOrderType}`
  368. })
  369. })
  370. }
  371. })
  372. },
  373. // 紧急度选择
  374. doneChange(id) {},
  375. doSearch() {
  376. this.dataList = []
  377. this.page = 1
  378. this.getList()
  379. this.searchShow = false
  380. },
  381. reset() {
  382. this.searchFrom = {
  383. code: '',
  384. orderStatus: []
  385. }
  386. if (this.orderType == 1) {
  387. // 待办 执行中
  388. this.searchFrom.orderStatus = [0, 2, 3]
  389. } else {
  390. // 已完成
  391. this.searchFrom.orderStatus = [4]
  392. }
  393. this.doSearch()
  394. },
  395. statusChange(value) {
  396. console.log(value)
  397. this.searchFrom.orderStatus = value
  398. },
  399. handleDetail(item) {
  400. let url = this.tabList[this.activeIndex]?.url
  401. if (!url) return
  402. // url += `id=${item.id}&workOrderCode=${item.workOrderCode}&BizType=${item.bizType}`
  403. url += `id=${item.id}&planId=${item.planId}&code=${item.code}&&orderType=${this.orderType}`
  404. console.log(url)
  405. uni.navigateTo({
  406. url
  407. })
  408. },
  409. scrolltolower() {
  410. if (isEnd) return
  411. this.page++
  412. this.getList()
  413. },
  414. handleTabChange(item) {
  415. console.log(item)
  416. this.activeType = item.type
  417. this.activeIndex = item.index
  418. this.dataList = []
  419. this.page = 1
  420. this.reset()
  421. this.searchShow = false
  422. },
  423. getCount() {
  424. statistics().then(data => {
  425. console.log('onsole.log(data)-----------')
  426. console.log(data)
  427. this.tabList = this.tabList.map(item => {
  428. switch (item.type) {
  429. case 'maintenance':
  430. return { ...item, badge: { value: data.maintenanceNum } }
  431. case 'patrol':
  432. return { ...item, badge: { value: data.patrolInspection } }
  433. case 'quantity':
  434. return { ...item, badge: { value: data.quantityNum } }
  435. case 'repair':
  436. return { ...item, badge: { value: data.repairsNum } }
  437. }
  438. })
  439. })
  440. // Promise.all(
  441. // this.tabList.map(item =>
  442. // getWorkOrderList(
  443. // {
  444. // type: item.workOrderType
  445. // },
  446. // false
  447. // )
  448. // )
  449. // ).then(res => {
  450. // res.forEach((item, index) => {
  451. // console.log(item)
  452. // // if (item?.success) {
  453. // // this.tabList[index].badge.value = item.data.count
  454. // // }
  455. // })
  456. // })
  457. },
  458. getList() {
  459. uni.showLoading({
  460. title: '加载中'
  461. })
  462. console.log('this.searchFrom-----------------')
  463. console.log(this.searchFrom)
  464. const params = {
  465. type: this.tabList[this.activeIndex].workOrderType,
  466. pageNum: this.page,
  467. size: 10,
  468. ...this.searchFrom
  469. }
  470. // 维修
  471. if (this.tabList[this.activeIndex].workOrderType == 3) {
  472. let userInfo = uni.getStorageSync('userInfo')
  473. params.executeUserId = userInfo.userId
  474. if (this.orderType == 1) {
  475. if (!params.orderStatus.includes(3)) {
  476. params.orderStatus.push(3)
  477. }
  478. }
  479. } else {
  480. if (this.orderType == 1) {
  481. if (params.orderStatus.includes(3)) {
  482. let index = params.orderStatus.indexOf(3)
  483. params.orderStatus.splice(index, 1)
  484. }
  485. } else {
  486. params.orderStatus = [3]
  487. }
  488. }
  489. isEnd = false
  490. getWorkOrderList(params)
  491. .then(res => {
  492. if (res.list?.length > 0 && params.type === this.tabList[this.activeIndex].workOrderType) {
  493. // if (params.page === 1) {
  494. // this.dataList = []
  495. // }
  496. // this.dataList.push(...res.data.list.records)
  497. this.dataList = this.dataList.concat(res.list)
  498. isEnd = this.dataList.length >= res.count
  499. } else {
  500. this.dataList = []
  501. }
  502. console.log(this.dataList)
  503. uni.hideLoading()
  504. })
  505. .catch(() => {
  506. uni.hideLoading()
  507. })
  508. }
  509. //(1:巡点检;2:保养;3:维修;4:盘点)
  510. // _getMyWorkOrderList(params, loading = true) {
  511. // let str = ''
  512. // for (let key in params) {
  513. // str += '&' + key + '=' + params[key]
  514. // }
  515. // return postJ(this.apiUrl + `/eam/PdaWorkOrder/list?${str.substr(1)}`, {}, loading)
  516. // }
  517. }
  518. }
  519. </script>
  520. <style lang="scss" scoped>
  521. scroll-view ::v-deep ::-webkit-scrollbar {
  522. width: 0;
  523. height: 0;
  524. color: transparent;
  525. }
  526. .scan_btn {
  527. background: url('../../../static/scan.png');
  528. background-size: 100% 100%;
  529. background-repeat: no-repeat;
  530. width: 50rpx;
  531. height: 50rpx;
  532. }
  533. .kd-work-container {
  534. height: 100vh;
  535. overflow: hidden;
  536. display: flex;
  537. flex-direction: column;
  538. .work-list {
  539. flex: 1;
  540. overflow: hidden;
  541. padding: 16rpx 24rpx;
  542. background-color: $page-bg;
  543. .u-list {
  544. height: 100% !important;
  545. }
  546. }
  547. .nodata {
  548. font-size: 40rpx;
  549. text-align: center;
  550. padding-top: 30rpx;
  551. }
  552. }
  553. .top-wrapper {
  554. display: flex;
  555. align-items: center;
  556. background-color: #fff;
  557. position: relative;
  558. .slide-search {
  559. position: absolute;
  560. top: 100%;
  561. left: 0;
  562. right: 0;
  563. z-index: 10;
  564. background-color: #fff;
  565. .timerange {
  566. width: 90%;
  567. margin: 0 auto 10rpx;
  568. }
  569. .select-box {
  570. display: flex;
  571. padding: 0 10rpx;
  572. .uni-stat__select + .uni-stat__select {
  573. margin-left: 10rpx;
  574. }
  575. }
  576. .more-search {
  577. padding-bottom: 20rpx;
  578. .cell {
  579. display: flex;
  580. align-items: center;
  581. padding-right: 20rpx;
  582. & + .cell {
  583. margin-top: 10rpx;
  584. }
  585. /deep/uni-input {
  586. flex: 1;
  587. height: 70rpx;
  588. border: 1rpx solid #e5e5e5;
  589. border-radius: 8rpx;
  590. font-size: 28rpx;
  591. padding-left: 20rpx;
  592. box-sizing: border-box;
  593. }
  594. .label {
  595. width: 180rpx;
  596. text-align: right;
  597. padding-right: 20rpx;
  598. }
  599. }
  600. /deep/.uni-date__x-input {
  601. height: 70rpx !important;
  602. }
  603. .btn-search {
  604. text-align: right;
  605. padding: 10rpx 10rpx 0;
  606. button {
  607. display: inline-block;
  608. width: 200rpx;
  609. height: 60rpx;
  610. line-height: 58rpx;
  611. font-size: 28rpx;
  612. margin-left: 20rpx;
  613. &.primary {
  614. background-color: $j-primary-border-green;
  615. color: #fff;
  616. }
  617. }
  618. }
  619. }
  620. }
  621. .top-tabs {
  622. flex: 1;
  623. }
  624. .more_search {
  625. padding: 0 20rpx;
  626. }
  627. /deep/.u-input {
  628. border: 1rpx solid #ccc;
  629. .u-input__content__field-wrapper__field {
  630. height: 40rpx !important;
  631. }
  632. }
  633. image {
  634. width: 52rpx;
  635. height: 52rpx;
  636. margin-left: 10rpx;
  637. }
  638. }
  639. .search_list {
  640. min-height: 100rpx;
  641. /deep/ .baseForm {
  642. padding: 10rpx 20rpx;
  643. }
  644. }
  645. .operate_box {
  646. padding: 10rpx;
  647. box-sizing: border-box;
  648. }
  649. .mg-20 {
  650. margin-right: 20rpx;
  651. }
  652. </style>