index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar background-color="#157A2C" color="#fff" fixed="true" statusBar="true" left-icon="back" title="售后工单"
  4. @clickLeft="back">
  5. </uni-nav-bar>
  6. <view class="top-wrapper">
  7. <uni-section>
  8. <uni-easyinput @clear="clearSearch" prefixIcon="search" style="width: 460rpx" v-model="searchVal"
  9. placeholder="名称">
  10. </uni-easyinput>
  11. </uni-section>
  12. <button class="search_btn" @click="doSearch">搜索</button>
  13. <image class="menu_icon" src="~@/static/pda/menu.svg" @click="showSearch"></image>
  14. </view>
  15. <view class="">
  16. <view class="tab_box rx-sc">
  17. <view class="tab_item" v-for="(item,index) in tabList" :key="index"
  18. :class="{active: pickTabIndex == item.value}">
  19. <view @click="changeChartsTab(item.value)">
  20. {{item.label}}
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="wrapper">
  26. <u-list @scrolltolower="scrolltolower" class="listContent" style="height: auto;">
  27. <view v-for="(item, index) in tableList" :key="index" style="position: relative;">
  28. <myCard @addSpareItems="addSpareItems(item.id)" @report="edit('report',item.id)"
  29. @edit="edit('edit',item.id)" @details="edit('view',item.id)" @handleAudit="handleAudit(item)"
  30. @checkAndAccept="checkAndAccept(item)" @evaluate="evaluate(item)" :item="item" :index="index+1"
  31. @receive="receive(item)" :columns="columns" :btnList="btnList">
  32. </myCard>
  33. <u-empty v-show="emptyShow && tableList.length==0" width="300" height="300" textSize="30"></u-empty>
  34. </view>
  35. </u-list>
  36. </view>
  37. <CheckAndAccept ref="acceptRef" @getList='doSearch' />
  38. <Evaluate ref="evaluateRef" @getList='doSearch' />
  39. <u-toast ref="uToast"></u-toast>
  40. <MySearch :show.sync="searchShow" :formItems="formItems" @search="confirmSearch"></MySearch>
  41. </view>
  42. </template>
  43. <script>
  44. import {
  45. getByCode
  46. } from '@/api/pda/common.js'
  47. import {
  48. initDict
  49. } from '@/utils/utils.js'
  50. import {
  51. getSalesWorkOrder,
  52. receiveSalesWorkOrder,
  53. checkByWorkId
  54. } from '@/api/salesServiceManagement/workOrder/index.js'
  55. import myCard from '@/pages/saleManage/components/myCard.vue'
  56. import CheckAndAccept from './components/forWork/checkAndAccept.vue'
  57. import Evaluate from './components/forWork/evaluate.vue'
  58. export default {
  59. components: {
  60. myCard,
  61. CheckAndAccept,
  62. Evaluate,
  63. },
  64. watch: {
  65. fault_level_arr: {
  66. handler(val) {
  67. console.log(val);
  68. this.formItems.find(item => item.prop === 'faultLevel').props.localdata = val
  69. },
  70. deep: true
  71. }
  72. },
  73. data() {
  74. return {
  75. searchForm: {},
  76. emptyShow: false,
  77. searchShow: false,
  78. fault_level_obj: {},
  79. fault_level_arr: [],
  80. formItems: [{
  81. label: '工单编号:',
  82. prop: 'code',
  83. component: 'MyInput',
  84. props: {
  85. placeholder: '请输入内容',
  86. }
  87. },
  88. {
  89. label: '客户名称:',
  90. prop: 'contactName',
  91. component: 'MyInput',
  92. props: {
  93. placeholder: '请输入内容',
  94. }
  95. },
  96. {
  97. label: '设备名称:',
  98. prop: 'deviceName',
  99. component: 'MyInput',
  100. props: {
  101. placeholder: '请输入内容',
  102. }
  103. },
  104. {
  105. label: '故障等级:',
  106. prop: 'faultLevel',
  107. component: 'MySelect',
  108. props: {
  109. localdata: [],
  110. dataKey: 'label',
  111. dataValue: 'value'
  112. }
  113. },
  114. {
  115. label: '计划单号:',
  116. prop: 'planCode',
  117. component: 'MyInput',
  118. props: {
  119. placeholder: '请输入内容',
  120. }
  121. },
  122. {
  123. label: '计划名称:',
  124. prop: 'planName',
  125. component: 'MyInput',
  126. props: {
  127. placeholder: '请输入内容',
  128. }
  129. },
  130. {
  131. label: '报工人:',
  132. prop: 'executeUserName',
  133. component: 'MyInput',
  134. props: {
  135. placeholder: '请输入内容',
  136. }
  137. },
  138. {
  139. label: '验收人:',
  140. prop: 'accepterUserName',
  141. component: 'MyInput',
  142. props: {
  143. placeholder: '请输入内容',
  144. }
  145. },
  146. ],
  147. tabList: [{
  148. value: 'all',
  149. label: '全部',
  150. },
  151. {
  152. value: '0',
  153. label: '待执行',
  154. },
  155. {
  156. value: '1',
  157. label: '执行中',
  158. },
  159. {
  160. value: '3',
  161. label: '待验收',
  162. },
  163. {
  164. value: '5',
  165. label: '已完成',
  166. },
  167. ],
  168. workOrderStatus: [
  169. // { code: 0, label: '待接收' },
  170. {
  171. code: 0,
  172. label: '待执行'
  173. },
  174. {
  175. code: 1,
  176. label: '已接收'
  177. },
  178. {
  179. code: 2,
  180. label: '执行中'
  181. },
  182. {
  183. code: 3,
  184. label: '待验收'
  185. },
  186. {
  187. code: 4,
  188. label: '待评价'
  189. },
  190. {
  191. code: 5,
  192. label: '已完成'
  193. },
  194. {
  195. code: 6,
  196. label: '验收不通过'
  197. }
  198. ],
  199. pickTabIndex: 'all',
  200. searchVal: '',
  201. isEnd: false,
  202. page: 1,
  203. size: 10,
  204. tableList: [],
  205. columns: [
  206. [{
  207. label: '工单编号:',
  208. prop: 'code',
  209. type: 'title',
  210. className: 'perce100',
  211. }],
  212. [{
  213. label: '计划单号:',
  214. prop: 'planCode'
  215. }],
  216. [{
  217. label: '计划名称:',
  218. prop: 'planName',
  219. }],
  220. [{
  221. label: '报工人:',
  222. prop: 'executeUserName'
  223. }, {
  224. label: '验收人:',
  225. prop: 'accepterUserName',
  226. }],
  227. [{
  228. label: '故障等级:',
  229. prop: 'faultLevel',
  230. formatter: (row) => {
  231. console.log(this.fault_level_obj);
  232. return this.fault_level_obj[row.faultLevel]
  233. }
  234. }, {
  235. label: '客户名称:',
  236. prop: 'contactName',
  237. }],
  238. [{
  239. label: '设备名称:',
  240. prop: 'categoryName',
  241. formatter: (row) => {
  242. if (!row.deviceDetails) return '';
  243. let str = '';
  244. row.deviceDetails.map((el, idx) => {
  245. if (idx + 1 == row.deviceDetails.length) {
  246. str += el.categoryName;
  247. } else {
  248. str = str + '' + el.categoryName + ',';
  249. }
  250. });
  251. return str;
  252. }
  253. }],
  254. [{
  255. label: '验收时间:',
  256. prop: 'accepterTime'
  257. }, {
  258. label: '开始时间:',
  259. prop: 'acceptTime',
  260. }],
  261. [{
  262. label: '结束时间:',
  263. prop: 'finishTime'
  264. }, {
  265. label: '计划完成时间:',
  266. prop: 'planFinishTime',
  267. }],
  268. [{
  269. label: '实际售后时长:',
  270. prop: 'inFactDuration',
  271. formatter: (row) => {
  272. if (row.inFactDuration || row.inFactDuration == 0) {
  273. let str = ((row.inFactDuration - 0) / 60).toFixed(1);
  274. return str + ' 小时';
  275. }
  276. }
  277. }, {
  278. label: '状态:',
  279. prop: 'orderStatus',
  280. formatter: (row) => {
  281. return this.workOrderStatus.find(
  282. (item) => item.code == row.orderStatus
  283. )?.label;
  284. }
  285. }],
  286. [{
  287. label: '操作:',
  288. prop: 'action',
  289. type: 'action',
  290. className: 'perce100',
  291. }],
  292. ],
  293. btnList: [{
  294. name: '详情',
  295. apiName: 'details',
  296. btnType: 'primary',
  297. type: '2',
  298. pageUrl: '',
  299. }, {
  300. name: '修改',
  301. apiName: 'edit',
  302. btnType: 'primary',
  303. type: '2',
  304. pageUrl: '',
  305. judge: [{
  306. authorities: '',
  307. }, {
  308. key: 'orderStatus',
  309. value: [1, 6],
  310. }],
  311. },
  312. {
  313. name: '报工',
  314. apiName: 'report',
  315. btnType: 'error ',
  316. type: '2',
  317. pageUrl: '',
  318. judge: [{
  319. authorities: '',
  320. }, {
  321. key: 'orderStatus',
  322. value: [1, 6],
  323. }],
  324. }, {
  325. name: '接收',
  326. apiName: 'receive',
  327. btnType: 'error ',
  328. type: '2',
  329. pageUrl: '',
  330. judge: [{
  331. authorities: '',
  332. }, {
  333. key: 'orderStatus',
  334. value: [0],
  335. }],
  336. }, {
  337. name: '转派',
  338. apiName: 'handleAudit',
  339. btnType: 'primary',
  340. type: '2',
  341. pageUrl: '',
  342. judge: [{
  343. authorities: '',
  344. }, {
  345. key: 'orderStatus',
  346. value: [0, 1],
  347. }],
  348. },
  349. {
  350. name: '验收',
  351. apiName: 'checkAndAccept',
  352. btnType: 'primary',
  353. type: '2',
  354. pageUrl: '',
  355. judge: [{
  356. authorities: '',
  357. }, {
  358. key: 'orderStatus',
  359. value: [3, 6],
  360. }],
  361. },
  362. {
  363. name: '评价',
  364. apiName: 'evaluate',
  365. btnType: 'primary',
  366. type: '2',
  367. pageUrl: '',
  368. judge: [{
  369. authorities: '',
  370. }, {
  371. key: 'orderStatus',
  372. value: [4],
  373. }],
  374. },
  375. {
  376. name: '申请配件',
  377. apiName: 'addSpareItems',
  378. btnType: 'primary',
  379. type: '2',
  380. pageUrl: '',
  381. judge: [{
  382. authorities: '',
  383. }, {
  384. key: 'orderStatus',
  385. value: [1, 2],
  386. }],
  387. },
  388. ],
  389. }
  390. },
  391. onLoad() {
  392. this.getDict()
  393. },
  394. onShow() {
  395. this.doSearch();
  396. },
  397. created() {
  398. },
  399. onReachBottom() {
  400. this.getList()
  401. },
  402. methods: {
  403. async getDict() {
  404. let res = await getByCode('fault_level')
  405. let [arr, obj] = initDict(res)
  406. this.fault_level_obj = obj
  407. this.fault_level_arr = arr
  408. console.log(arr, obj);
  409. },
  410. changeChartsTab(value) {
  411. this.pickTabIndex = value;
  412. this.doSearch();
  413. },
  414. doSearch() {
  415. this.isEnd = false;
  416. this.page = 1;
  417. this.getList();
  418. },
  419. //获取列表信息
  420. getList() {
  421. this.emptyShow = false
  422. if (this.isEnd) {
  423. this.$refs.uToast.show({
  424. message: "暂无更多数据",
  425. duration: 1000
  426. })
  427. return
  428. }
  429. uni.showLoading({
  430. title: '加载中'
  431. })
  432. let data = {
  433. pageNum: this.page,
  434. size: this.size,
  435. keyWord: this.searchVal,
  436. ...this.searchForm
  437. }
  438. if (this.pickTabIndex != 'all') {
  439. data.orderStatus = this.pickTabIndex;
  440. }
  441. getSalesWorkOrder(data).then(res => {
  442. if (this.page === 1) {
  443. this.tableList = res.list
  444. if (this.tableList.length === 0) {
  445. this.emptyShow = true
  446. }
  447. } else {
  448. this.tableList.push(...res.list)
  449. }
  450. this.page += 1
  451. this.isEnd = this.tableList.length >= res.count;
  452. uni.hideLoading();
  453. }).catch((e) => {
  454. uni.hideLoading();
  455. })
  456. },
  457. scrolltolower() {
  458. if (this.isEnd) {
  459. return
  460. }
  461. this.getList();
  462. },
  463. // 申请配件
  464. async addSpareItems(id) {
  465. const result = await this.checkId(id)
  466. if (result) {
  467. uni.navigateTo({
  468. url: `/pages/salesServiceManagement/workOrder/components/accessory?id=${id}`
  469. })
  470. }
  471. },
  472. // 验收
  473. checkAndAccept(item) {
  474. this.$refs.acceptRef.open(item.id);
  475. },
  476. // 评价
  477. evaluate(item) {
  478. this.$refs.evaluateRef.open(item.id);
  479. },
  480. // 转派
  481. handleAudit(item) {
  482. console.log(item, 'item ---')
  483. uni.navigateTo({
  484. url: `/pages/salesServiceManagement/workOrder/components/forWork/transfer?id=${item.id}`
  485. })
  486. },
  487. // 报工
  488. async edit(type, id) {
  489. // 判断报工是否可执行
  490. if(type == 'report') {
  491. const result = await this.checkId(id)
  492. if(!result) return
  493. }
  494. uni.navigateTo({
  495. url: `/pages/salesServiceManagement/workOrder/components/editPlan?type=${type}&id=${id}`
  496. })
  497. },
  498. // 接收
  499. async receive(item) {
  500. const data = await uni.showModal({
  501. title: '确认接收',
  502. content: '确定要接收这条数据吗?',
  503. confirmText: '接收',
  504. confirmColor: '#157a2c',
  505. });
  506. if (data[1].confirm) {
  507. const res = await receiveSalesWorkOrder(item);
  508. if (!res) return;
  509. this.$refs.uToast.show({
  510. type: "success",
  511. message: "操作成功",
  512. })
  513. this.doSearch();
  514. }
  515. },
  516. clearSearch() {
  517. this.searchVal = ''
  518. this.doSearch()
  519. },
  520. showSearch() {
  521. this.searchShow = true
  522. },
  523. confirmSearch(e) {
  524. console.log(e);
  525. let data = JSON.parse(JSON.stringify(e))
  526. this.searchForm = data
  527. this.doSearch()
  528. },
  529. async checkId(id) {
  530. try {
  531. await checkByWorkId(id)
  532. return true
  533. } catch (error) {
  534. console.log(error);
  535. return false
  536. }
  537. }
  538. }
  539. }
  540. </script>
  541. <style lang="scss" scoped>
  542. .top-wrapper {
  543. background-color: #fff;
  544. display: flex;
  545. width: 750rpx;
  546. height: 88rpx;
  547. padding: 16rpx 32rpx;
  548. align-items: center;
  549. gap: 16rpx;
  550. /deep/.uni-section {
  551. margin-top: 0px;
  552. }
  553. /deep/.uni-section-header {
  554. padding: 0px;
  555. }
  556. .search_btn {
  557. width: 120rpx;
  558. height: 70rpx;
  559. line-height: 70rpx;
  560. padding: 0 24rpx;
  561. background: $theme-color;
  562. font-size: 32rpx;
  563. color: #fff;
  564. margin: 0;
  565. margin-left: 26rpx;
  566. }
  567. .menu_icon {
  568. width: 44rpx;
  569. height: 44rpx;
  570. margin-left: 14rpx;
  571. }
  572. }
  573. .tab_box {
  574. width: 100%;
  575. height: 68rpx;
  576. border-bottom: 1rpx solid #E1E1E1;
  577. .tab_item {
  578. height: 68rpx;
  579. line-height: 68rpx;
  580. padding: 0 20rpx;
  581. font-size: 32rpx;
  582. color: #979C9E;
  583. }
  584. .active {
  585. box-sizing: border-box;
  586. border-bottom: 6rpx solid $theme-color;
  587. color: $theme-color;
  588. }
  589. }
  590. /deep/ .u-empty {
  591. margin-top: 200px !important;
  592. }
  593. </style>