index.vue 12 KB

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