index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar background-color="#157A2C" color="#fff" fixed="true" statusBar="true" left-icon="back"
  4. title="配件回收记录" @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="wrapper">
  16. <u-list @scrolltolower="scrolltolower" class="listContent" style="height: auto;">
  17. <view v-for="(item, index) in tableList" :key="index" style="position: relative;">
  18. <myCard :columns="columns" :btnList="btnList" @details="add(item,'view')" @edit="add(item,'edit')" @auSubmit="auSubmit(item)"
  19. @delete="deleteRow(item)" :item="item">
  20. </myCard>
  21. </view>
  22. <u-empty v-show="emptyShow && tableList.length==0" width="300" height="300" textSize="30"></u-empty>
  23. </u-list>
  24. </view>
  25. <view class="add" @click="add('','add')">
  26. <u-icon name="plus" color="#fff"></u-icon>
  27. </view>
  28. <u-toast ref="uToast"></u-toast>
  29. <MySearch :show.sync="searchShow" :formItems="formItems" @search="confirmSearch"></MySearch>
  30. </view>
  31. </template>
  32. <script>
  33. import {
  34. recyclePage,
  35. recycleDelete
  36. } from '@/api/salesServiceManagement/accessory/index.js';
  37. import myCard from '@/pages/saleManage/components/myCard.vue';
  38. import {
  39. processInstanceCreateAPI,
  40. processInstancePage,getWarehouseListByIdsAPI
  41. } from '@/api/wt/index.js'
  42. import {
  43. recycleDetails,
  44. } from '@/api/salesServiceManagement/workOrder/index.js'
  45. export default {
  46. components: {
  47. myCard
  48. },
  49. data() {
  50. return {
  51. searchForm: {},
  52. emptyShow: false,
  53. searchShow: false,
  54. formItems: [{
  55. label: '编码:',
  56. prop: 'code',
  57. component: 'MyInput',
  58. props: {
  59. placeholder: '请输入内容'
  60. }
  61. },
  62. {
  63. label: '工单编码:',
  64. prop: 'workCode',
  65. component: 'MyInput',
  66. props: {
  67. placeholder: '请输入内容',
  68. }
  69. },
  70. {
  71. label: '回收人:',
  72. prop: 'recycleName',
  73. component: 'MyInput',
  74. props: {
  75. placeholder: '请输入内容',
  76. }
  77. },
  78. {
  79. label: '客户名称:',
  80. prop: 'contactName',
  81. component: 'MyInput',
  82. props: {
  83. placeholder: '请输入内容',
  84. }
  85. },
  86. {
  87. label: '设备名称:',
  88. prop: 'deviceName',
  89. component: 'MyInput',
  90. props: {
  91. placeholder: '请输入内容',
  92. }
  93. },
  94. {
  95. label: '物品名称:',
  96. prop: 'categoryName',
  97. component: 'MyInput',
  98. props: {
  99. placeholder: '请输入内容',
  100. }
  101. },
  102. {
  103. label: '创建时间:',
  104. prop: 'creatTime',
  105. component: 'MyDateRange',
  106. props: {
  107. type: 'daterange',
  108. }
  109. }
  110. ],
  111. columns: [
  112. [{
  113. label: '编号:',
  114. prop: 'code',
  115. type: 'title',
  116. className: 'perce100',
  117. }],
  118. [{
  119. label: '工单编码:',
  120. prop: 'orderWorkCode'
  121. }],
  122. [{
  123. label: '物品名称:',
  124. prop: 'categoryName',
  125. formatter: (row) => {
  126. if (!row.details) return '';
  127. let str = '';
  128. row.details.map((el, idx) => {
  129. if (idx + 1 == row.details.length) {
  130. str += el.categoryName;
  131. } else {
  132. str = str + '' + el.categoryName + ',';
  133. }
  134. });
  135. return str;
  136. }
  137. }],
  138. [{
  139. label: '客户名称:',
  140. prop: 'contactName',
  141. }],
  142. [{
  143. label: '设备名称:',
  144. prop: 'categoryName',
  145. formatter: (row) => {
  146. if (!row.deviceDetails) return '';
  147. let str = '';
  148. row.deviceDetails.map((el, idx) => {
  149. if (idx + 1 == row.deviceDetails.length) {
  150. str += el.categoryName;
  151. } else {
  152. str = str + '' + el.categoryName + ',';
  153. }
  154. });
  155. return str;
  156. }
  157. }],
  158. [{
  159. label: '回收部门:',
  160. prop: 'recycleDeptName',
  161. }, {
  162. label: '回收人:',
  163. prop: 'recycleName',
  164. }],
  165. [{
  166. label: '创建时间:',
  167. prop: 'createTime'
  168. }, {
  169. label: '回收时间:',
  170. prop: 'usageTime',
  171. }],
  172. [{
  173. label: '状态:',
  174. prop: 'approvalStatus',
  175. formatter: (row) => {
  176. const reviewStatus = {
  177. 0: '未提交',
  178. 1: '审核中',
  179. 2: '已审核',
  180. 3: '审核不通过'
  181. }
  182. let cellValue = row.approvalStatus;
  183. return reviewStatus[cellValue]
  184. }
  185. }],
  186. [{
  187. label: '操作:',
  188. prop: 'action',
  189. type: 'action',
  190. className: 'perce100',
  191. }],
  192. ],
  193. btnList: [{
  194. name: '详情',
  195. apiName: 'details',
  196. btnType: 'primary',
  197. type: '2',
  198. pageUrl: '',
  199. }, {
  200. name: '修改',
  201. apiName: 'edit',
  202. btnType: 'primary',
  203. type: '2',
  204. pageUrl: '',
  205. judge: [{
  206. authorities: '',
  207. }, {
  208. key: 'source',
  209. value: [0],
  210. },{
  211. key: 'approvalStatus',
  212. value: [0, 3],
  213. }],
  214. }, {
  215. name: '提交',
  216. apiName: 'auSubmit',
  217. btnType: 'primary',
  218. type: '2',
  219. pageUrl: '',
  220. judge: [{
  221. authorities: '',
  222. }, {
  223. key: 'approvalStatus',
  224. value: [0, 3],
  225. }],
  226. }, {
  227. name: '删除',
  228. apiName: 'delete',
  229. btnType: 'primary',
  230. type: '2',
  231. pageUrl: '',
  232. judge: [{
  233. authorities: '',
  234. }, {
  235. key: 'approvalStatus',
  236. value: [0, 3],
  237. },{
  238. key: 'source',
  239. value: [0],
  240. }],
  241. }],
  242. page: 1,
  243. size: 10,
  244. isEnd: false,
  245. tableList: [],
  246. searchVal: ''
  247. }
  248. },
  249. created() {
  250. },
  251. onShow() {
  252. this.doSearch();
  253. },
  254. onReachBottom() {
  255. this.getList()
  256. },
  257. methods: {
  258. doSearch() {
  259. this.isEnd = false;
  260. this.page = 1;
  261. this.getList();
  262. },
  263. //获取列表信息
  264. getList() {
  265. this.emptyShow = false
  266. if (this.isEnd) {
  267. this.$refs.uToast.show({
  268. message: "暂无更多数据",
  269. duration: 1000
  270. })
  271. return;
  272. }
  273. uni.showLoading({
  274. title: '加载中'
  275. })
  276. let data = {
  277. pageNum: this.page,
  278. size: this.size,
  279. keyWord: this.searchVal,
  280. workOrderIsReport:1,
  281. ...this.searchForm
  282. }
  283. recyclePage(data).then(res => {
  284. if (this.page === 1) {
  285. this.tableList = res.list;
  286. if (this.tableList.length === 0) {
  287. this.emptyShow = true
  288. }
  289. } else {
  290. this.tableList.push(...res.list);
  291. }
  292. this.page += 1;
  293. this.isEnd = this.tableList.length >= res.count;
  294. const height = uni.getSystemInfoSync()
  295. console.log(height);
  296. uni.hideLoading();
  297. }).catch((e) => {
  298. uni.hideLoading();
  299. })
  300. },
  301. scrolltolower() {
  302. if (this.isEnd) {
  303. return;
  304. }
  305. this.getList();
  306. },
  307. add(item, type) {
  308. uni.navigateTo({
  309. url: `/pages/salesServiceManagement/recycle/recycleAdd?type=${type}&id=${item?item.id:''}`
  310. })
  311. },
  312. async auSubmit(res) {
  313. try {
  314. //后台不提供接口
  315. const data = await recycleDetails(res.id);
  316. let storemanIds = '';
  317. let ids = data.detailList.map((item) => item.warehouseId);
  318. let warehouseList = await getWarehouseListByIdsAPI(ids || []);
  319. storemanIds = warehouseList.map((item) => item.ownerId);
  320. let list = await processInstancePage({
  321. pageNo: 1,
  322. pageSize: 1,
  323. reset: true,
  324. key: 'after_sale_accessory_apply'
  325. })
  326. let params = {
  327. businessId: res.id,
  328. businessKey: 'after_sale_accessory_apply',
  329. formCreateUserId: res.createUserId,
  330. processDefinitionId: list?.list[0]?.processDefinition.id,
  331. variables: {
  332. businessCode: res.code,
  333. businessName: res.recycleDeptName,
  334. businessType: '售后配件回收入库',
  335. storemanIds:storemanIds.toString()
  336. },
  337. }
  338. await processInstanceCreateAPI(params)
  339. uni.showModal({
  340. title: `提交成功`,
  341. content: '',
  342. confirmText: '确认',
  343. showCancel: false, // 是否显示取消按钮,默认为 true
  344. success: () => {
  345. this.doSearch()
  346. }
  347. })
  348. } catch {
  349. }
  350. },
  351. async deleteRow(row) {
  352. const res = await uni.showModal({
  353. title: '确认删除',
  354. content: '确定要删除该条数据吗?',
  355. confirmText: '删除',
  356. confirmColor: '#FF4D4F',
  357. });
  358. if (res[1].confirm) {
  359. const data = await recycleDelete([row.id]);
  360. if (!data) return;
  361. this.$refs.uToast.show({
  362. type: "success",
  363. message: "操作成功",
  364. })
  365. this.doSearch();
  366. } else if (res.cancel) {
  367. console.log('用户取消');
  368. }
  369. },
  370. clearSearch() {
  371. this.searchVal = ''
  372. this.doSearch()
  373. },
  374. showSearch() {
  375. this.searchShow = true
  376. },
  377. confirmSearch(e) {
  378. console.log(e);
  379. let data = JSON.parse(JSON.stringify(e))
  380. if (data.creatTime) {
  381. var [startTime, endTime] = data.creatTime
  382. delete data.creatTime
  383. this.searchForm = {
  384. ...data,
  385. startTime,
  386. endTime
  387. }
  388. } else {
  389. this.searchForm = data
  390. }
  391. this.doSearch()
  392. }
  393. }
  394. }
  395. </script>
  396. <style scoped lang="scss">
  397. .top-wrapper {
  398. background-color: #fff;
  399. display: flex;
  400. width: 750rpx;
  401. height: 88rpx;
  402. padding: 16rpx 32rpx;
  403. align-items: center;
  404. gap: 16rpx;
  405. /deep/.uni-section {
  406. margin-top: 0px;
  407. }
  408. /deep/.uni-section-header {
  409. padding: 0px;
  410. }
  411. .search_btn {
  412. width: 120rpx;
  413. height: 70rpx;
  414. line-height: 70rpx;
  415. padding: 0 24rpx;
  416. background: $theme-color;
  417. font-size: 32rpx;
  418. color: #fff;
  419. margin: 0;
  420. margin-left: 26rpx;
  421. }
  422. .menu_icon {
  423. width: 44rpx;
  424. height: 44rpx;
  425. margin-left: 14rpx;
  426. }
  427. }
  428. .add {
  429. width: 96rpx;
  430. height: 96rpx;
  431. border-radius: 48rpx;
  432. background: #3c9cff;
  433. position: fixed;
  434. bottom: 100rpx;
  435. right: 24rpx;
  436. display: flex;
  437. align-items: center;
  438. justify-content: center;
  439. }
  440. /deep/ .u-empty {
  441. margin-top: 200px !important;
  442. }
  443. </style>