sparepart.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <view>
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" leftText="选择备品备件" @clickLeft="back"></uni-nav-bar>
  4. <SparePart @submitList="submit" :list="list" v-if="list && list.length!==0"></SparePart>
  5. <view class="" v-else>
  6. <view class="no_data">
  7. <view class="center">
  8. <uni-icons type="chat-filled" size="36"></uni-icons>
  9. </view>
  10. <view class="center">
  11. 暂无数据
  12. </view>
  13. </view>
  14. <view class="footer footer-right">
  15. <view class="center">
  16. <text class="footer-span-btn" @click="resetEqui">选择备品备件</text>
  17. </view>
  18. </view>
  19. </view>
  20. <uni-data-picker ref="pickerDeptName" :localdata="treeList" @change="handleChange"
  21. :map="{text:'name','value':'id'}" v-show="pickerDeptShow">
  22. </uni-data-picker>
  23. </view>
  24. </template>
  25. <script>
  26. import SparePart from '@/components/SparePart.vue'
  27. import {
  28. get,
  29. postJ,
  30. post
  31. } from "@/utils/api.js"
  32. let [page, size, isEnd] = [1, 10, true];
  33. export default {
  34. components: {
  35. SparePart
  36. },
  37. data() {
  38. return {
  39. pageId: '',
  40. pickerDeptShow: false,
  41. list: [],
  42. treeList: [],
  43. classificationId:""
  44. }
  45. },
  46. onShow() {
  47. this.getTreeList()
  48. },
  49. onLoad(options) {
  50. },
  51. onReachBottom: function() {
  52. if (isEnd) {
  53. return;
  54. }
  55. // 显示加载图标
  56. uni.showLoading({
  57. title: "数据加载中"
  58. });
  59. this.getMoreLists();
  60. },
  61. methods: {
  62. resetEqui(){
  63. this.pickerDeptShow = true
  64. this.$refs.pickerDeptName.show()
  65. },
  66. handleChange(e) {
  67. let data = e.detail.value[e.detail.value.length - 1]
  68. this.classificationId = data.value
  69. page = 1;
  70. isEnd = true;
  71. uni.showLoading({
  72. title: "数据加载中"
  73. });
  74. this.getList();
  75. },
  76. getTreeList() {
  77. postJ(this.apiUrl + "/classificationTree/list", [4]).then(res => {
  78. // console.log(res)
  79. if (res.success) {
  80. this.treeList = res.data
  81. this.pickerDeptShow = true
  82. this.$refs.pickerDeptName.show()
  83. }
  84. })
  85. },
  86. getFirstList: function() {
  87. page = 1;
  88. isEnd = true;
  89. uni.showLoading({
  90. title: "数据加载中"
  91. });
  92. this.getList();
  93. },
  94. getMoreLists: function() {
  95. //获取更多数据
  96. page++;
  97. this.getList();
  98. },
  99. //获取列表数据
  100. getList() {
  101. post(this.apiUrl + "/classificationSpareParts/classificationSpare/list",{
  102. page,
  103. size,
  104. code:"",
  105. classificationId:this.classificationId
  106. }).then(res => {
  107. // console.log(res)
  108. let data = res.data.records;
  109. let pageTotal = res.data.pages;
  110. if (page === 1) {
  111. data.forEach(el => {
  112. el.num = 0
  113. })
  114. this.list = data;
  115. } else {
  116. data.forEach(element => {
  117. element.num = 0;
  118. this.list.push(element);
  119. });
  120. }
  121. page < pageTotal ? (isEnd = false) : (isEnd = true);
  122. }).then(() => {
  123. uni.hideLoading()
  124. })
  125. },
  126. submit(data) {
  127. let list = data;
  128. let pickData = list.filter((item) => {
  129. return item.checked && !item.disabled && (item.num > 0)
  130. })
  131. if (pickData.length == 0) {
  132. uni.showToast({
  133. title: "请选择备品备件数量",
  134. icon: 'none',
  135. duration: 2000
  136. })
  137. return
  138. }
  139. this.$store.dispatch("tour_tally/setSparepart", pickData);
  140. this.back()
  141. // console.log(pickData)
  142. // pickData.forEach(el => {
  143. // el.goodsName = el.sparepartTypeCode.name
  144. // el.goodsBatch = el.batchNo
  145. // if (el.type) {
  146. // el.goodsTypeCode = el.sparepartTypeCode?.id;
  147. // }
  148. // // el.manageType = el.manageType.id;
  149. // delete el.type;
  150. // delete el.status;
  151. // })
  152. // let form = {
  153. // "goodsType": 3,
  154. // "supplier": {
  155. // "id": "7",
  156. // "name": "回到家撒卡卡"
  157. // },
  158. // "executor": {
  159. // "id": 4,
  160. // "name": "欧阳峰"
  161. // },
  162. // "warehouse": {
  163. // "id": "5",
  164. // "name": "凯凯仓库"
  165. // },
  166. // "attaments": [],
  167. // "outType": 2,
  168. // "receiveName": "黄凯",
  169. // "receiveTime": "2023-05-26 00:00:00",
  170. // "receivePhone": "15512341234",
  171. // "remark": "出库备注",
  172. // "details": pickData
  173. // }
  174. //this.$store.dispatch("tour_tally/setSparepart", sparepartInfo);
  175. // postJ(this.apiWebUrl + "/api/feature/worksheet/applyspare?id=" + this.pageId, form).then(res => {
  176. // // console.log(res)
  177. // this.back()
  178. // }).catch(err => {
  179. // uni.showToast({
  180. // title: '操作失败',
  181. // icon: 'none'
  182. // })
  183. // })
  184. //this.$store.dispatch("tour_tally/setSparepart", sparepartInfo);
  185. },
  186. }
  187. }
  188. </script>
  189. <style lang="scss" scoped>
  190. /deep/.uni-data-tree-input {
  191. display: none;
  192. }
  193. .no_data {
  194. position: fixed;
  195. top: 50%;
  196. left: 50%;
  197. transform: translate(-50%, -50%);
  198. .center {
  199. text-align: center;
  200. color: #555;
  201. font-size: $uni-font-size-base;
  202. }
  203. }
  204. .footer {
  205. position: fixed;
  206. display: flex;
  207. justify-content: space-between;
  208. align-items: center;
  209. bottom: 0;
  210. width: 100%;
  211. height: 90rpx;
  212. text-align: center;
  213. border-top: 1rpx solid #eeecec;
  214. background-color: #FFFFFF;
  215. .bottom {
  216. font-size: $uni-font-size-lg;
  217. margin-left: 20rpx;
  218. .select-all {
  219. color: $j-primary-green;
  220. }
  221. }
  222. .footer-span-btn {
  223. height: 30rpx;
  224. line-height: 30rpx;
  225. font-size: $uni-font-size-lg;
  226. color: #ffffff;
  227. margin-right: 20rpx;
  228. padding: 10rpx 20rpx;
  229. text-align: center;
  230. background-color: $j-primary-green;
  231. border-radius: 40rpx;
  232. }
  233. }
  234. .footer-right {
  235. justify-content: flex-end;
  236. }
  237. </style>