index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  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" @click="showSearch" src="~@/static/pda/menu.svg"></image>
  14. </view>
  15. <view class="wrapper">
  16. <u-list @scrolltolower="scrolltolower" class="listContent">
  17. <view v-for="(item, index) in tableList" :key="index" style="position: relative;">
  18. <myCard @del="del(item)" @handleAudit="handleAudit(item)" @handleRevoke="handleRevoke(item)"
  19. @edit="add('edit',item.id)" @details="add('view',item.id)" :item="item" :index="index+1"
  20. :columns="columns" :btnList="btnList">
  21. </myCard>
  22. </view>
  23. </u-list>
  24. </view>
  25. <view style='margin-top: 20vh;' v-if="tableList.length==0">
  26. <u-empty iconSize='150' textSize='32' text='暂无数据'>
  27. </u-empty>
  28. </view>
  29. <view class="add" @click="add('add','')">
  30. <u-icon name="plus" color="#fff"></u-icon>
  31. </view>
  32. <ba-tree-picker ref="treePicker" :multiple="false" @select-change="confirm" :localdata="listData" valueKey="id"
  33. textKey="name" childrenKey="children" />
  34. <u-toast ref="uToast"></u-toast>
  35. <u-modal @confirm="handleSubmit" ref="popup" type="center" :show="modalShow" @cancel="modalShow=false"
  36. :showCancelButton="true" :closeOnClickOverlay="true">
  37. <view class="popup-content">
  38. <form>
  39. <view class="form-item">
  40. <label class="form-label">*部门</label>
  41. <u--input placeholder="部门" @click.native="showPicker"
  42. v-model="addForm.planExecuteGroupName"></u--input>
  43. </view>
  44. <view class="form-item">
  45. <label class="form-label">*计划执行人</label>
  46. <uni-data-picker v-model="addForm.planExecuteUserId" placeholder="请选择" :localdata="userList"
  47. @change="industryOnchange">
  48. </uni-data-picker>
  49. </view>
  50. </form>
  51. </view>
  52. </u-modal>
  53. <u-toast ref="uToast"></u-toast>
  54. <MySearch :show.sync="searchShow" :formItems="formItems" @search="confirmSearch" ref="mySearchRef">
  55. </MySearch>
  56. </view>
  57. </template>
  58. <script>
  59. import {
  60. getByCode
  61. } from '@/api/pda/common.js'
  62. import {
  63. initDict
  64. } from '@/utils/utils.js'
  65. import {
  66. listOrganizations,
  67. getUserPage
  68. } from '@/api/myTicket/index.js'
  69. import {
  70. getTableList,
  71. revokeSalesDemand,
  72. deleteSalesDemand,
  73. demanDispatch,
  74. auditSalesDemand
  75. } from '@/api/salesServiceManagement/demandList/index.js'
  76. import myCard from '@/pages/saleManage/components/myCard.vue'
  77. import {
  78. processInstanceCreateAPI,
  79. processInstancePage
  80. } from '@/api/wt/index.js'
  81. export default {
  82. components: {
  83. myCard,
  84. },
  85. watch: {
  86. fault_level_arr: {
  87. handler(val) {
  88. console.log(val);
  89. this.formItems.find(item => item.prop === 'faultLevel').props.localdata = val
  90. },
  91. deep: true
  92. }
  93. },
  94. data() {
  95. return {
  96. addForm: {
  97. planExecuteUserId: '',
  98. planExecuteUserName: '',
  99. planExecuteGroupId: '',
  100. planExecuteGroupName: '',
  101. id: ''
  102. },
  103. modalShow: false,
  104. userList: [],
  105. listData: [],
  106. searchForm: {},
  107. emptyShow: false,
  108. searchShow: false,
  109. fault_level_obj: {},
  110. fault_level_arr: [],
  111. formItems: [{
  112. label: '客户名称:',
  113. prop: 'contactName',
  114. component: 'MyInput',
  115. props: {
  116. placeholder: '请输入内容',
  117. }
  118. },
  119. {
  120. label: '编码:',
  121. prop: 'code',
  122. component: 'MyInput',
  123. props: {
  124. placeholder: '请输入内容',
  125. }
  126. },
  127. {
  128. label: '客户编码:',
  129. prop: 'contactCode',
  130. component: 'MyInput',
  131. props: {
  132. placeholder: '请输入内容',
  133. }
  134. },
  135. {
  136. label: '创建人:',
  137. prop: 'createUserName',
  138. component: 'MyInput',
  139. props: {
  140. placeholder: '请输入内容',
  141. }
  142. },
  143. {
  144. label: '故障等级:',
  145. prop: 'faultLevel',
  146. component: 'MySelect',
  147. props: {
  148. localdata: [],
  149. dataKey: 'label',
  150. dataValue: 'value'
  151. }
  152. },
  153. {
  154. label: '状态:',
  155. prop: 'demandStatus',
  156. component: 'MySelect',
  157. props: {
  158. localdata: [{
  159. label: '待提交',
  160. value: 0
  161. }, {
  162. label: '已提交',
  163. value: 1
  164. }, {
  165. label: '已关闭',
  166. value: 3
  167. }, {
  168. label: '已撤回',
  169. value: 4
  170. }],
  171. dataKey: 'label',
  172. dataValue: 'value',
  173. }
  174. },
  175. ],
  176. tableList: [],
  177. searchVal: '',
  178. page: 1,
  179. size: 10,
  180. isEnd: false,
  181. current: {},
  182. examForm: {
  183. auditOpinion: '',
  184. auditResult: '',
  185. id: ''
  186. },
  187. btnList: [{
  188. name: '详情',
  189. apiName: 'details',
  190. btnType: 'primary',
  191. type: '2',
  192. pageUrl: '',
  193. }, {
  194. name: '修改',
  195. apiName: 'edit',
  196. btnType: 'primary',
  197. type: '2',
  198. pageUrl: '',
  199. judge: [{
  200. authorities: '',
  201. }, {
  202. key: 'demandStatus',
  203. fn: (row) => {
  204. if (row?.afterSalesType == 3) {
  205. return (
  206. (row?.approvalResult == 0 || row?.approvalResult == 3) &&
  207. row?.demandStatus != 2
  208. );
  209. } else {
  210. return row?.demandStatus == 0;
  211. }
  212. },
  213. }],
  214. },
  215. {
  216. name: '删除',
  217. apiName: 'del',
  218. btnType: 'error ',
  219. type: '2',
  220. pageUrl: '',
  221. judge: [{
  222. authorities: '',
  223. }, {
  224. fn: (row) => {
  225. if (row?.afterSalesType == 3) {
  226. return (
  227. (row?.approvalResult == 0 || row?.approvalResult == 3) &&
  228. row?.demandStatus != 2
  229. );
  230. } else {
  231. return row?.demandStatus == 0;
  232. }
  233. },
  234. }],
  235. }, {
  236. name: '提交',
  237. apiName: 'handleAudit',
  238. btnType: 'primary',
  239. type: '2',
  240. pageUrl: '',
  241. judge: [{
  242. authorities: '',
  243. }, {
  244. fn: (row) => {
  245. if (row?.afterSalesType == 3) {
  246. return (
  247. (row?.approvalResult == 0 || row?.approvalResult == 3) &&
  248. row?.demandStatus != 2
  249. );
  250. } else {
  251. return row?.demandStatus == 0;
  252. }
  253. },
  254. }],
  255. },
  256. ],
  257. columns: [
  258. [{
  259. label: '名称:',
  260. prop: 'name',
  261. type: 'title',
  262. className: 'perce100',
  263. }],
  264. [{
  265. label: '编码:',
  266. prop: 'code'
  267. }, {
  268. label: '客户编码:',
  269. prop: 'contactCode'
  270. }],
  271. [{
  272. label: '客户名称:',
  273. prop: 'contactName'
  274. }, {
  275. label: '故障等级:',
  276. prop: 'faultLevel',
  277. formatter: (row) => {
  278. return this.fault_level_obj && this.fault_level_obj[row.faultLevel] || ''
  279. }
  280. }],
  281. [{
  282. label: '创建人:',
  283. prop: 'createUserName'
  284. }, {
  285. label: '创建时间:',
  286. prop: 'createTime',
  287. }],
  288. [{
  289. label: '状态:',
  290. prop: 'demandStatus',
  291. formatter: (row) => {
  292. const reviewStatus = {
  293. 0: '未提交',
  294. 1: '审核中',
  295. 2: '已审核',
  296. 3: '审核不通过'
  297. }
  298. let cellValue = row.demandStatus;
  299. if (row.afterSalesType == 3) {
  300. return cellValue == 2 ? '已关闭' : reviewStatus[row.approvalResult];
  301. } else {
  302. return cellValue == 0 ?
  303. '待提交' :
  304. cellValue == 1 ?
  305. '已提交' :
  306. cellValue == 2 ?
  307. '已关闭' :
  308. cellValue == 3 ?
  309. '已完成' :
  310. '';
  311. }
  312. }
  313. }],
  314. [{
  315. label: '操作:',
  316. prop: 'action',
  317. type: 'action',
  318. className: 'perce100',
  319. }],
  320. ]
  321. }
  322. },
  323. onReachBottom() {
  324. console.log('123');
  325. this.getList()
  326. },
  327. onLoad() {
  328. this.getDict()
  329. this.getDept()
  330. },
  331. onShow() {
  332. this.doSearch();
  333. },
  334. methods: {
  335. handleAudit(row) {
  336. this.current = row
  337. if(row.afterSalesType==3){
  338. this.listSubmit()
  339. }else{
  340. this.modalShow = true
  341. }
  342. console.log(this.modalShow, 'dsds')
  343. },
  344. // 显示选择器
  345. showPicker() {
  346. this.$refs.treePicker._show();
  347. },
  348. // btnShow(row) {
  349. // },
  350. confirm(data, name) {
  351. this.addForm.planExecuteGroupName = name
  352. this.addForm.planExecuteGroupId = data[0]
  353. this.addForm.planExecuteUserName = ''
  354. this.addForm.planExecuteUserId = ''
  355. this.getUser(data[0])
  356. },
  357. industryOnchange(obj) {
  358. this.addForm.planExecuteUserName = obj.detail.value[0].text
  359. },
  360. getDept() {
  361. listOrganizations(1).then(data => {
  362. this.listData = data
  363. })
  364. },
  365. getUser(deptCode) {
  366. getUserPage({
  367. pageNum: 1,
  368. size: -1,
  369. groupId: deptCode
  370. }).then(data => {
  371. this.userList = data.list.map(item => {
  372. item.text = item.name
  373. item.value = item.id
  374. return item
  375. })
  376. })
  377. },
  378. handleSubmit() {
  379. auditSalesDemand({
  380. ...this.addForm,
  381. submitSource: 3,
  382. id: this.current.id
  383. })
  384. .then((res) => {
  385. if (res) {
  386. this.modalShow = false
  387. this.$refs.uToast.show({
  388. type: "success",
  389. message: "操作成功",
  390. })
  391. this.doSearch();
  392. }
  393. })
  394. .catch((err) => {
  395. this.modalShow = false
  396. });
  397. },
  398. async getDict() {
  399. let res = await getByCode('fault_level')
  400. let [arr, obj] = initDict(res)
  401. this.fault_level_obj = obj
  402. this.fault_level_arr = arr
  403. console.log(this.fault_level_obj);
  404. // console.log(arr, obj);
  405. },
  406. doSearch() {
  407. this.isEnd = false
  408. this.page = 1
  409. this.getList()
  410. },
  411. //获取列表信息
  412. getList() {
  413. if (this.isEnd) {
  414. this.$refs.uToast.show({
  415. message: "暂无更多数据",
  416. duration: 1000
  417. })
  418. return
  419. }
  420. uni.showLoading({
  421. title: '加载中'
  422. })
  423. let data = {
  424. pageNum: this.page,
  425. size: this.size,
  426. keyWord: this.searchVal,
  427. ...this.searchForm
  428. }
  429. getTableList(data).then(res => {
  430. if (this.page === 1) {
  431. this.tableList = res.list
  432. if (this.tableList.length === 0) {
  433. this.emptyShow = true
  434. }
  435. } else {
  436. this.tableList.push(...res.list)
  437. }
  438. this.page += 1
  439. this.isEnd = this.tableList.length >= res.count
  440. uni.hideLoading();
  441. }).catch((e) => {
  442. uni.hideLoading()
  443. })
  444. },
  445. hidePopup() {
  446. this.$refs.popup.close();
  447. this.examForm = {
  448. auditOpinion: '',
  449. auditResult: '',
  450. id: ''
  451. };
  452. },
  453. async listSubmit() {
  454. try {
  455. //后台不提供接口
  456. let list = await processInstancePage({
  457. pageNo: 1,
  458. pageSize: 1,
  459. reset: true,
  460. key: 'after_sale_quality_issues_feedback'
  461. })
  462. let params = {
  463. businessId: this.current.id,
  464. businessKey: 'after_sale_quality_issues_feedback',
  465. formCreateUserId: this.current.createUserId,
  466. processDefinitionId: list?.list[0]?.processDefinition.id,
  467. variables: {
  468. businessCode: this.current.code,
  469. businessName: this.current.name,
  470. businessType: '质量问题反馈',
  471. },
  472. }
  473. await processInstanceCreateAPI(params)
  474. uni.showModal({
  475. title: `提交成功`,
  476. content: '',
  477. confirmText: '确认',
  478. showCancel: false, // 是否显示取消按钮,默认为 true
  479. success: () => {
  480. this.doSearch()
  481. }
  482. })
  483. } catch {
  484. }
  485. },
  486. // 撤回
  487. async handleRevoke(row) {
  488. const res = await uni.showModal({
  489. title: '确认撤回',
  490. content: '确定要撤回该条数据吗?',
  491. confirmText: '撤回',
  492. confirmColor: '#FF4D4F',
  493. });
  494. if (res[1].confirm) {
  495. const data = await revokeSalesDemand({
  496. id: row.id
  497. });
  498. if (!data) return
  499. this.$refs.uToast.show({
  500. type: "success",
  501. message: "操作成功",
  502. })
  503. this.doSearch();
  504. } else if (res.cancel) {
  505. console.log('用户取消');
  506. }
  507. },
  508. add(type, id) {
  509. uni.navigateTo({
  510. url: `/pages/salesServiceManagement/demandList/add?type=${type}&id=${id}`
  511. })
  512. },
  513. scrolltolower() {
  514. if (this.isEnd) {
  515. return
  516. }
  517. this.getList();
  518. },
  519. async del(row) {
  520. const res = await uni.showModal({
  521. title: '确认删除',
  522. content: '确定要删除该条数据吗?',
  523. confirmText: '删除',
  524. confirmColor: '#FF4D4F',
  525. });
  526. if (res[1].confirm) {
  527. const data = await deleteSalesDemand([row.id])
  528. if (!data) return
  529. this.$refs.uToast.show({
  530. type: "success",
  531. message: "操作成功",
  532. })
  533. this.doSearch();
  534. } else if (res.cancel) {
  535. console.log('用户取消');
  536. }
  537. // deleteInformation([item.id]).then(res => {
  538. // this.isEnd = false
  539. // this.page = 1
  540. // this.$refs.uToast.show({
  541. // type: "success",
  542. // message: "操作成功",
  543. // })
  544. // this.getList(this.where)
  545. // })
  546. },
  547. clearSearch() {
  548. this.searchVal = ''
  549. this.doSearch()
  550. },
  551. showSearch() {
  552. this.searchShow = true
  553. },
  554. confirmSearch(e) {
  555. console.log(e);
  556. let data = JSON.parse(JSON.stringify(e))
  557. this.searchForm = data
  558. this.doSearch()
  559. },
  560. }
  561. }
  562. </script>
  563. <style lang="scss" scoped>
  564. .add {
  565. width: 96rpx;
  566. height: 96rpx;
  567. border-radius: 48rpx;
  568. background: #3c9cff;
  569. position: fixed;
  570. bottom: 100rpx;
  571. right: 24rpx;
  572. display: flex;
  573. align-items: center;
  574. justify-content: center;
  575. }
  576. .wrapper {}
  577. .top-wrapper {
  578. background-color: #fff;
  579. display: flex;
  580. width: 750rpx;
  581. height: 88rpx;
  582. padding: 16rpx 32rpx;
  583. align-items: center;
  584. gap: 16rpx;
  585. /deep/.uni-section {
  586. margin-top: 0px;
  587. }
  588. /deep/.uni-section-header {
  589. padding: 0px;
  590. }
  591. .search_btn {
  592. width: 120rpx;
  593. height: 70rpx;
  594. line-height: 70rpx;
  595. padding: 0 24rpx;
  596. background: $theme-color;
  597. font-size: 32rpx;
  598. color: #fff;
  599. margin: 0;
  600. margin-left: 26rpx;
  601. }
  602. .menu_icon {
  603. width: 44rpx;
  604. height: 44rpx;
  605. margin-left: 14rpx;
  606. }
  607. }
  608. </style>