index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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" 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. onReachBottom() {
  153. this.getList()
  154. },
  155. methods: {
  156. doSearch() {
  157. this.isEnd = false;
  158. this.page = 1;
  159. this.getList();
  160. },
  161. //获取列表信息
  162. getList() {
  163. if (this.isEnd) {
  164. this.$refs.uToast.show({
  165. message: "暂无更多数据",
  166. duration:1000
  167. })
  168. return;
  169. }
  170. uni.showLoading({
  171. title: '加载中'
  172. })
  173. let data = {
  174. pageNum: this.page,
  175. size: this.size,
  176. keyWord: this.searchVal
  177. }
  178. recyclePage(data).then(res => {
  179. if (this.page === 1) {
  180. this.tableList = res.list;
  181. } else {
  182. this.tableList.push(...res.list);
  183. }
  184. this.page += 1;
  185. this.isEnd = this.tableList.length >= res.count;
  186. const height=uni.getSystemInfoSync()
  187. console.log(height);
  188. uni.hideLoading();
  189. }).catch((e) => {
  190. uni.hideLoading();
  191. })
  192. },
  193. scrolltolower() {
  194. if (this.isEnd) {
  195. return;
  196. }
  197. this.getList();
  198. },
  199. add(item, type) {
  200. uni.navigateTo({
  201. url: `/pages/salesServiceManagement/recycle/recycleAdd?type=${type}&id=${item?item.id:''}`
  202. })
  203. },
  204. async deleteRow(row) {
  205. const res = await uni.showModal({
  206. title: '确认删除',
  207. content: '确定要删除该条数据吗?',
  208. confirmText: '删除',
  209. confirmColor: '#FF4D4F',
  210. });
  211. if (res[1].confirm) {
  212. const data = await recycleDelete([row.id]);
  213. if (!data) return;
  214. this.$refs.uToast.show({
  215. type: "success",
  216. message: "操作成功",
  217. })
  218. this.doSearch();
  219. } else if (res.cancel) {
  220. console.log('用户取消');
  221. }
  222. },
  223. clearSearch() {
  224. this.searchVal = ''
  225. this.doSearch()
  226. }
  227. }
  228. }
  229. </script>
  230. <style scoped lang="scss">
  231. .top-wrapper {
  232. background-color: #fff;
  233. display: flex;
  234. width: 750rpx;
  235. height: 88rpx;
  236. padding: 16rpx 32rpx;
  237. align-items: center;
  238. gap: 16rpx;
  239. /deep/.uni-section {
  240. margin-top: 0px;
  241. }
  242. /deep/.uni-section-header {
  243. padding: 0px;
  244. }
  245. .search_btn {
  246. width: 120rpx;
  247. height: 70rpx;
  248. line-height: 70rpx;
  249. padding: 0 24rpx;
  250. background: $theme-color;
  251. font-size: 32rpx;
  252. color: #fff;
  253. margin: 0;
  254. margin-left: 26rpx;
  255. }
  256. .menu_icon {
  257. width: 44rpx;
  258. height: 44rpx;
  259. margin-left: 14rpx;
  260. }
  261. }
  262. .add {
  263. width: 96rpx;
  264. height: 96rpx;
  265. border-radius: 48rpx;
  266. background: #3c9cff;
  267. position: fixed;
  268. bottom: 100rpx;
  269. right: 24rpx;
  270. display: flex;
  271. align-items: center;
  272. justify-content: center;
  273. }
  274. </style>