index.vue 6.3 KB

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