index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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 prefixIcon="search" style="width: 460rpx" v-model="searchVal" placeholder="名称">
  9. </uni-easyinput>
  10. </uni-section>
  11. <button class="search_btn" @click="doSearch">搜索</button>
  12. <image class="menu_icon" src="~@/static/pda/menu.svg"></image>
  13. </view>
  14. <view class="wrapper">
  15. <u-list @scrolltolower="scrolltolower" class="listContent" style="height: auto;">
  16. <view v-for="(item, index) in tableList" :key="index" style="position: relative;">
  17. <myCard :columns="columns" :btnList="btnList" @details="add(item,'view')" @edit="add(item,'edit')"
  18. @delete="deleteRow(item)" :item="item">
  19. </myCard>
  20. </view>
  21. </u-list>
  22. </view>
  23. <view class="add" @click="add('','add')">
  24. <u-icon name="plus" color="#fff"></u-icon>
  25. </view>
  26. <u-toast ref="uToast"></u-toast>
  27. </view>
  28. </template>
  29. <script>
  30. import {
  31. recyclePage,
  32. recycleDelete
  33. } from '@/api/salesServiceManagement/accessory/index.js';
  34. import myCard from '@/pages/saleManage/components/myCard.vue';
  35. export default {
  36. components: {
  37. myCard
  38. },
  39. data() {
  40. return {
  41. columns: [
  42. [{
  43. label: '编号:',
  44. prop: 'code',
  45. type: 'title',
  46. className: 'perce100',
  47. }],
  48. [{
  49. label: '工单编码:',
  50. prop: 'orderWorkCode'
  51. }],
  52. [{
  53. label: '物品名称:',
  54. prop: 'categoryName',
  55. formatter: (row) => {
  56. if (!row.details) return '';
  57. let str = '';
  58. row.details.map((el, idx) => {
  59. if (idx + 1 == row.details.length) {
  60. str += el.categoryName;
  61. } else {
  62. str = str + '' + el.categoryName + ',';
  63. }
  64. });
  65. return str;
  66. }
  67. }],
  68. [{
  69. label: '客户名称:',
  70. prop: 'contactName',
  71. }],
  72. [{
  73. label: '设备名称:',
  74. prop: 'categoryName',
  75. formatter: (row) => {
  76. if (!row.deviceDetails) return '';
  77. let str = '';
  78. row.deviceDetails.map((el, idx) => {
  79. if (idx + 1 == row.deviceDetails.length) {
  80. str += el.categoryName;
  81. } else {
  82. str = str + '' + el.categoryName + ',';
  83. }
  84. });
  85. return str;
  86. }
  87. }],
  88. [{
  89. label: '回收部门:',
  90. prop: 'recycleDeptName',
  91. }, {
  92. label: '回收人:',
  93. prop: 'recycleName',
  94. }],
  95. [{
  96. label: '创建时间:',
  97. prop: 'createTime'
  98. }, {
  99. label: '回收时间:',
  100. prop: 'usageTime',
  101. }],
  102. [{
  103. label: '操作:',
  104. prop: 'action',
  105. type: 'action',
  106. className: 'perce100',
  107. }],
  108. ],
  109. btnList: [{
  110. name: '详情',
  111. apiName: 'details',
  112. btnType: 'primary',
  113. type: '2',
  114. pageUrl: '',
  115. }, {
  116. name: '修改',
  117. apiName: 'edit',
  118. btnType: 'primary',
  119. type: '2',
  120. pageUrl: '',
  121. judge: [{
  122. authorities: '',
  123. }, {
  124. key: 'source',
  125. value: [0],
  126. }],
  127. }, {
  128. name: '删除',
  129. apiName: 'delete',
  130. btnType: 'primary',
  131. type: '2',
  132. pageUrl: '',
  133. judge: [{
  134. authorities: '',
  135. }, {
  136. key: 'source',
  137. value: [0],
  138. }],
  139. }],
  140. page: 1,
  141. size: 10,
  142. isEnd: false,
  143. tableList: [],
  144. searchVal: ''
  145. }
  146. },
  147. created() {
  148. },
  149. onShow(){
  150. this.doSearch();
  151. },
  152. methods: {
  153. doSearch() {
  154. this.isEnd = false;
  155. this.page = 1;
  156. this.getList();
  157. },
  158. //获取列表信息
  159. getList() {
  160. if (this.isEnd) {
  161. return;
  162. }
  163. uni.showLoading({
  164. title: '加载中'
  165. })
  166. let data = {
  167. pageNum: this.page,
  168. size: this.size,
  169. }
  170. recyclePage(data).then(res => {
  171. if (this.page === 1) {
  172. this.tableList = res.list;
  173. } else {
  174. this.tableList.push(...res.list);
  175. }
  176. this.page += 1;
  177. this.isEnd = this.tableList.length >= res.count;
  178. uni.hideLoading();
  179. }).catch((e) => {
  180. uni.hideLoading();
  181. })
  182. },
  183. scrolltolower() {
  184. if (this.isEnd) {
  185. return;
  186. }
  187. this.getList();
  188. },
  189. add(item, type) {
  190. uni.navigateTo({
  191. url: `/pages/salesServiceManagement/recycle/recycleAdd?type=${type}&id=${item?item.id:''}`
  192. })
  193. },
  194. async deleteRow(row) {
  195. const res = await uni.showModal({
  196. title: '确认删除',
  197. content: '确定要删除该条数据吗?',
  198. confirmText: '删除',
  199. confirmColor: '#FF4D4F',
  200. });
  201. if (res[1].confirm) {
  202. const data = await recycleDelete([row.id]);
  203. if (!data) return;
  204. this.$refs.uToast.show({
  205. type: "success",
  206. message: "操作成功",
  207. })
  208. this.doSearch();
  209. } else if (res.cancel) {
  210. console.log('用户取消');
  211. }
  212. }
  213. }
  214. }
  215. </script>
  216. <style scoped lang="scss">
  217. .top-wrapper {
  218. background-color: #fff;
  219. display: flex;
  220. width: 750rpx;
  221. height: 88rpx;
  222. padding: 16rpx 32rpx;
  223. align-items: center;
  224. gap: 16rpx;
  225. /deep/.uni-section {
  226. margin-top: 0px;
  227. }
  228. /deep/.uni-section-header {
  229. padding: 0px;
  230. }
  231. .search_btn {
  232. width: 120rpx;
  233. height: 70rpx;
  234. line-height: 70rpx;
  235. padding: 0 24rpx;
  236. background: $theme-color;
  237. font-size: 32rpx;
  238. color: #fff;
  239. margin: 0;
  240. margin-left: 26rpx;
  241. }
  242. .menu_icon {
  243. width: 44rpx;
  244. height: 44rpx;
  245. margin-left: 14rpx;
  246. }
  247. }
  248. .add {
  249. width: 96rpx;
  250. height: 96rpx;
  251. border-radius: 48rpx;
  252. background: #3c9cff;
  253. position: fixed;
  254. bottom: 100rpx;
  255. right: 24rpx;
  256. display: flex;
  257. align-items: center;
  258. justify-content: center;
  259. }
  260. </style>