myTicket.vue 16 KB

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