spare-store copy.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <view>
  3. <my-add-button @handleClick="handleClick" />
  4. <view class="border-bottom">
  5. <u-tabs class="p-fixed left0 right0 zIndex" :list="list" :is-scroll="false" :current="current" @change="change"></u-tabs>
  6. </view>
  7. <view class="">
  8. <template v-if="listData.length > 0">
  9. <view class="mx3 my2 p3 bg-color-white box p-relative" v-for="(item, index) in listData" :key="index" @longpress="showMask(item.id,$event)">
  10. <common-mask :item="item" :maskId="maskId" @hide="maskId = 0" />
  11. <view class="d-flex j-between border-bottom pb-2 a-center">
  12. <view class="text-color-b f-size-26">{{ item.no }}</view>
  13. <my-badge :text="item.num+''" :status="'success'" />
  14. </view>
  15. <view class="mt-2 d-flex j-between">
  16. <view class="text-color-3 f-size-32 f-weight-bold">{{
  17. item.spareName
  18. }} - 价格:{{
  19. item.price
  20. }}</view>
  21. </view>
  22. <view class="f-size-26 text-color-6 f-weight-4 mt-2">{{
  23. item.storeName
  24. }}</view>
  25. <view class="d-flex j-end edit-box">
  26. <view class="text-color-3 f-size-32 edit mask-red">
  27. <view @click.stop="handleDelSpareStore(item)">删除</view>
  28. </view>
  29. <view class="text-color-3 f-size-32 edit">
  30. <view @click.stop="handleOutStore(item)">出库</view>
  31. </view>
  32. <view class="text-color-3 f-size-32 edit">
  33. <view @click.stop="handleInStore(item)">入库</view>
  34. </view>
  35. <view class="text-color-3 f-size-32 edit">
  36. <view @click.stop="handleTransfer(item)">调拨</view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="py3">
  41. <u-loadmore :status="status" />
  42. </view>
  43. </template>
  44. <template v-else>
  45. <view class="empty">
  46. <u-empty text="暂无数据" mode="list"></u-empty>
  47. </view>
  48. </template>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. list: [
  57. {
  58. name: '全部'
  59. },
  60. {
  61. name: '待接单'
  62. },
  63. {
  64. name: '进行中'
  65. },
  66. {
  67. name: '待验收'
  68. },
  69. {
  70. name: '待支付'
  71. }
  72. ],
  73. current: 0,
  74. // 加载更多
  75. status: 'loadmore',
  76. page: 1,
  77. limit: 10,
  78. spareName: '',
  79. spareNo: '',
  80. type: '',
  81. loadMore: true,
  82. listData: [],
  83. statusMap: {},
  84. maskId: 0
  85. }
  86. },
  87. onPullDownRefresh() {
  88. // 请求结束取消刷新
  89. this.page = 1
  90. this.loadMore = true
  91. this.listData = []
  92. ;(this.detailId = ''), this.initData()
  93. uni.stopPullDownRefresh()
  94. },
  95. onReachBottom() {
  96. if (this.loadMore) {
  97. this.page++
  98. this.initData()
  99. }
  100. },
  101. onLoad(option) {
  102. this.detailId = option.detailId
  103. this.spareName = option.spareName
  104. this.spareNo = option.spareNo
  105. this.statusMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
  106. },
  107. onShow() {
  108. this.page = 1
  109. this.loadMore = true
  110. this.listData = []
  111. this.initData()
  112. },
  113. onHide() {
  114. this.maskId = 0
  115. },
  116. methods: {
  117. showMask(id, e) {
  118. this.maskId = id
  119. // #ifdef H5
  120. e.preventDefault()
  121. // #endif
  122. },
  123. handleOutStore(item) {
  124. const that = this
  125. uni.navigateTo({
  126. url: '/pages/spare/spare-store-out?spareId=' + item.spareId + '&spareName=' + item.spareName + '&spareNo=' + item.no + '&storeId=' + item.storeId + '&storeNum=' + item.num + '&storeName=' + item.storeName + '&price=' + item.price
  127. })
  128. },
  129. // 通过
  130. handleInStore(item) {
  131. const that = this
  132. uni.navigateTo({
  133. url: '/pages/spare/spare-store-in?spareId=' + item.spareId + '&spareName=' + item.spareName + '&spareNo=' + item.no + '&storeId=' + item.storeId + '&storeNum=' + item.num + '&storeName=' + item.storeName + '&price=' + item.price
  134. })
  135. },
  136. handleTransfer(item) {
  137. const that = this
  138. uni.navigateTo({
  139. url: '/pages/spare/spare-store-transfer?spareId=' + item.spareId + '&spareName=' + item.spareName + '&spareNo=' + item.no + '&storeId=' + item.storeId + '&storeNum=' + item.num + '&storeName=' + item.storeName + '&price=' + item.price
  140. })
  141. },
  142. handleDelSpareStore(item) {
  143. const that = this
  144. this.$Http
  145. .deleteSpareStore({
  146. id: item.id
  147. })
  148. .then(res => {
  149. uni.showToast({ icon: 'none', title: '刪除成功!', duration: 2000 })
  150. that.page = 1
  151. that.loadMore = true
  152. that.listData = []
  153. that.initData()
  154. })
  155. },
  156. handleClick() {
  157. const that = this
  158. uni.navigateTo({
  159. url: '/pages/spare/spare-store-add?spareId=' + that.detailId + '&spareName=' + that.spareName + '&spareNo=' + that.spareNo
  160. })
  161. },
  162. // tab
  163. change(index) {
  164. this.current = index
  165. this.type = index
  166. this.page = 1
  167. this.loadMore = true
  168. this.listData = []
  169. this.initData()
  170. },
  171. // 跳转详情
  172. handleDetail(id) {
  173. if (this.maskId != 0) return (this.maskId = 0)
  174. uni.navigateTo({
  175. url: '/pages/repair-detail/repair-detail?detailId=' + id
  176. })
  177. },
  178. // 初始化
  179. initData() {
  180. const that = this
  181. that.status = 'loading'
  182. this.$Http
  183. .getSpareStorePage({
  184. spareId: this.detailId,
  185. pageNum: this.page,
  186. pageSize: this.limit
  187. })
  188. .then(res => {
  189. const data = res.data.rows
  190. if (data && data.length > 0 && data.length < that.limit) {
  191. that.status = 'nomore'
  192. that.loadMore = false
  193. } else if (data.length == that.limit) {
  194. that.status = 'loadmore'
  195. } else {
  196. that.status = 'nomore'
  197. }
  198. that.listData = [...that.listData, ...data]
  199. })
  200. }
  201. }
  202. }
  203. </script>
  204. <style lang="less">
  205. page {
  206. background-color: #f4f4f4;
  207. }
  208. .box {
  209. border-radius: 20rpx;
  210. padding-right: 0;
  211. }
  212. .edit-box {
  213. padding: 0 30rpx;
  214. margin-top: 40rpx;
  215. .edit {
  216. padding: 8rpx 24rpx;
  217. border: 1px solid #ddd;
  218. border-radius: 20rpx;
  219. font-size: 26rpx;
  220. color: #666;
  221. margin-left: 30rpx;
  222. }
  223. }
  224. </style>