index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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')"
  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. export default {
  39. components: {
  40. myCard
  41. },
  42. data() {
  43. return {
  44. searchForm: {},
  45. emptyShow: false,
  46. searchShow: false,
  47. formItems: [{
  48. label: '编码:',
  49. prop: 'code',
  50. component: 'MyInput',
  51. props: {
  52. placeholder: '请输入内容'
  53. }
  54. },
  55. {
  56. label: '工单编码:',
  57. prop: 'workCode',
  58. component: 'MyInput',
  59. props: {
  60. placeholder: '请输入内容',
  61. }
  62. },
  63. {
  64. label: '回收人:',
  65. prop: 'recycleName',
  66. component: 'MyInput',
  67. props: {
  68. placeholder: '请输入内容',
  69. }
  70. },
  71. {
  72. label: '客户名称:',
  73. prop: 'contactName',
  74. component: 'MyInput',
  75. props: {
  76. placeholder: '请输入内容',
  77. }
  78. },
  79. {
  80. label: '设备名称:',
  81. prop: 'deviceName',
  82. component: 'MyInput',
  83. props: {
  84. placeholder: '请输入内容',
  85. }
  86. },
  87. {
  88. label: '物品名称:',
  89. prop: 'categoryName',
  90. component: 'MyInput',
  91. props: {
  92. placeholder: '请输入内容',
  93. }
  94. },
  95. {
  96. label: '创建时间:',
  97. prop: 'creatTime',
  98. component: 'MyDateRange',
  99. props: {
  100. type: 'daterange',
  101. }
  102. }
  103. ],
  104. columns: [
  105. [{
  106. label: '编号:',
  107. prop: 'code',
  108. type: 'title',
  109. className: 'perce100',
  110. }],
  111. [{
  112. label: '工单编码:',
  113. prop: 'orderWorkCode'
  114. }],
  115. [{
  116. label: '物品名称:',
  117. prop: 'categoryName',
  118. formatter: (row) => {
  119. if (!row.details) return '';
  120. let str = '';
  121. row.details.map((el, idx) => {
  122. if (idx + 1 == row.details.length) {
  123. str += el.categoryName;
  124. } else {
  125. str = str + '' + el.categoryName + ',';
  126. }
  127. });
  128. return str;
  129. }
  130. }],
  131. [{
  132. label: '客户名称:',
  133. prop: 'contactName',
  134. }],
  135. [{
  136. label: '设备名称:',
  137. prop: 'categoryName',
  138. formatter: (row) => {
  139. if (!row.deviceDetails) return '';
  140. let str = '';
  141. row.deviceDetails.map((el, idx) => {
  142. if (idx + 1 == row.deviceDetails.length) {
  143. str += el.categoryName;
  144. } else {
  145. str = str + '' + el.categoryName + ',';
  146. }
  147. });
  148. return str;
  149. }
  150. }],
  151. [{
  152. label: '回收部门:',
  153. prop: 'recycleDeptName',
  154. }, {
  155. label: '回收人:',
  156. prop: 'recycleName',
  157. }],
  158. [{
  159. label: '创建时间:',
  160. prop: 'createTime'
  161. }, {
  162. label: '回收时间:',
  163. prop: 'usageTime',
  164. }],
  165. [{
  166. label: '操作:',
  167. prop: 'action',
  168. type: 'action',
  169. className: 'perce100',
  170. }],
  171. ],
  172. btnList: [{
  173. name: '详情',
  174. apiName: 'details',
  175. btnType: 'primary',
  176. type: '2',
  177. pageUrl: '',
  178. }, {
  179. name: '修改',
  180. apiName: 'edit',
  181. btnType: 'primary',
  182. type: '2',
  183. pageUrl: '',
  184. judge: [{
  185. authorities: '',
  186. }, {
  187. key: 'source',
  188. value: [0],
  189. }],
  190. }, {
  191. name: '删除',
  192. apiName: 'delete',
  193. btnType: 'primary',
  194. type: '2',
  195. pageUrl: '',
  196. judge: [{
  197. authorities: '',
  198. }, {
  199. key: 'source',
  200. value: [0],
  201. }],
  202. }],
  203. page: 1,
  204. size: 10,
  205. isEnd: false,
  206. tableList: [],
  207. searchVal: ''
  208. }
  209. },
  210. created() {
  211. },
  212. onShow() {
  213. this.doSearch();
  214. },
  215. onReachBottom() {
  216. this.getList()
  217. },
  218. methods: {
  219. doSearch() {
  220. this.isEnd = false;
  221. this.page = 1;
  222. this.getList();
  223. },
  224. //获取列表信息
  225. getList() {
  226. this.emptyShow = false
  227. if (this.isEnd) {
  228. this.$refs.uToast.show({
  229. message: "暂无更多数据",
  230. duration: 1000
  231. })
  232. return;
  233. }
  234. uni.showLoading({
  235. title: '加载中'
  236. })
  237. let data = {
  238. pageNum: this.page,
  239. size: this.size,
  240. keyWord: this.searchVal,
  241. ...this.searchForm
  242. }
  243. recyclePage(data).then(res => {
  244. if (this.page === 1) {
  245. this.tableList = res.list;
  246. if (this.tableList.length === 0) {
  247. this.emptyShow = true
  248. }
  249. } else {
  250. this.tableList.push(...res.list);
  251. }
  252. this.page += 1;
  253. this.isEnd = this.tableList.length >= res.count;
  254. const height = uni.getSystemInfoSync()
  255. console.log(height);
  256. uni.hideLoading();
  257. }).catch((e) => {
  258. uni.hideLoading();
  259. })
  260. },
  261. scrolltolower() {
  262. if (this.isEnd) {
  263. return;
  264. }
  265. this.getList();
  266. },
  267. add(item, type) {
  268. uni.navigateTo({
  269. url: `/pages/salesServiceManagement/recycle/recycleAdd?type=${type}&id=${item?item.id:''}`
  270. })
  271. },
  272. async deleteRow(row) {
  273. const res = await uni.showModal({
  274. title: '确认删除',
  275. content: '确定要删除该条数据吗?',
  276. confirmText: '删除',
  277. confirmColor: '#FF4D4F',
  278. });
  279. if (res[1].confirm) {
  280. const data = await recycleDelete([row.id]);
  281. if (!data) return;
  282. this.$refs.uToast.show({
  283. type: "success",
  284. message: "操作成功",
  285. })
  286. this.doSearch();
  287. } else if (res.cancel) {
  288. console.log('用户取消');
  289. }
  290. },
  291. clearSearch() {
  292. this.searchVal = ''
  293. this.doSearch()
  294. },
  295. showSearch() {
  296. this.searchShow = true
  297. },
  298. confirmSearch(e) {
  299. console.log(e);
  300. let data = JSON.parse(JSON.stringify(e))
  301. if (data.creatTime) {
  302. var [startTime, endTime] = data.creatTime
  303. delete data.creatTime
  304. this.searchForm = {
  305. ...data,
  306. startTime,
  307. endTime
  308. }
  309. } else {
  310. this.searchForm = data
  311. }
  312. this.doSearch()
  313. }
  314. }
  315. }
  316. </script>
  317. <style scoped lang="scss">
  318. .top-wrapper {
  319. background-color: #fff;
  320. display: flex;
  321. width: 750rpx;
  322. height: 88rpx;
  323. padding: 16rpx 32rpx;
  324. align-items: center;
  325. gap: 16rpx;
  326. /deep/.uni-section {
  327. margin-top: 0px;
  328. }
  329. /deep/.uni-section-header {
  330. padding: 0px;
  331. }
  332. .search_btn {
  333. width: 120rpx;
  334. height: 70rpx;
  335. line-height: 70rpx;
  336. padding: 0 24rpx;
  337. background: $theme-color;
  338. font-size: 32rpx;
  339. color: #fff;
  340. margin: 0;
  341. margin-left: 26rpx;
  342. }
  343. .menu_icon {
  344. width: 44rpx;
  345. height: 44rpx;
  346. margin-left: 14rpx;
  347. }
  348. }
  349. .add {
  350. width: 96rpx;
  351. height: 96rpx;
  352. border-radius: 48rpx;
  353. background: #3c9cff;
  354. position: fixed;
  355. bottom: 100rpx;
  356. right: 24rpx;
  357. display: flex;
  358. align-items: center;
  359. justify-content: center;
  360. }
  361. /deep/ .u-empty {
  362. margin-top: 200px !important;
  363. }
  364. </style>