index.vue 6.0 KB

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