outassembleDtl.nvue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. <template>
  2. <view class="tabs">
  3. <scroll-view id="tab-bar" class="scroll-h" :scroll-x="true" :show-scrollbar="false" :scroll-into-view="scrollInto">
  4. <view class="uni-tab-item" v-for="(tab,index) in tabBars" :key="tab.id" :id="tab.id" :data-current="index" @click="ontabtap">
  5. <text class="uni-tab-item-title" :class="tabIndex==index ? 'uni-tab-item-title-active' : ''">{{tab.name}}</text>
  6. </view>
  7. </scroll-view>
  8. <view class="line-h"></view>
  9. <swiper :current="tabIndex" class="swiper-box" style="flex: 1;" :duration="300" @change="ontabchange">
  10. <swiper-item class="swiper-item" v-for="(tab,index1) in newsList" :key="index1">
  11. <!-- Tab0 页面渲染 关键件Bom清单明细-->
  12. <list class="scroll-v list" v-if="index1 === 0" enableBackToTop="true" scroll-y loadmoreoffset="15">
  13. <cell>
  14. <view class="customDeliver">
  15. <text style="text-align: center;font-weight: bold;">{{"关键件Bom单号: " + bomNo}}</text>
  16. </view>
  17. </cell>
  18. <cell v-for="(newsitem,index2) in tab.data" :key="newsitem.id">
  19. <view class="myDeliverDetail" style="border: 1px #cccccc ;border-radius: 5px; margin-top: 1px;" @click="myDeliverDetailClick(newsitem)">
  20. <view style="flex-direction: row;flex-direction: row;height: 25px;display: flex;padding: 2px;border-radius: 5px 5px;">
  21. <text style="align-self: center;">物料编号:</text>
  22. <text style="align-self: center;">{{newsitem.materialCode}}</text>
  23. <text :class="newsitem.keyFlag ? 'keyFlagRed' : 'keyFlagGray'" style="align-self: center;margin-left: 20px;">{{newsitem.keyFlag ? '★' : '■'}}</text>
  24. </view>
  25. <view class="line-h"></view>
  26. <view style="flex-direction: row;flex-direction: row;display: flex;-webkit-justify-content: space-between;justify-content: space-between;">
  27. <view>
  28. <view style="flex-direction: row;flex-direction: row;display: flex;padding: 2px;">
  29. <text style="align-self: center;color: #555;font-size: 25rpx;">物料名称:</text>
  30. <text style="align-self: center;font-size: 25rpx;word-wrap: break-word;width: 200px;">{{newsitem.materialName}}</text>
  31. </view>
  32. <view style="flex-direction: row;flex-direction: row;display: flex;padding: 2px;">
  33. <text style="align-self: center;color: #555;font-size: 25rpx;">规格型号/图号:</text>
  34. <text style="align-self: center;font-size: 25rpx;word-wrap: break-word;width: 200px;">{{newsitem.materialSpec}}</text>
  35. </view>
  36. <!-- <view style="flex-direction: row;flex-direction: row;display: flex;padding: 2px;">
  37. <text style="align-self: center;color: #555;font-size: 25rpx;">生产令号:</text>
  38. <text style="align-self: center;font-size: 25rpx;word-wrap: break-word;width: 200px;">{{newsitem.bomNo}}</text>
  39. </view> -->
  40. <view style="flex-direction: row;flex-direction: row;display: flex;padding: 1px;">
  41. <text style="align-self: center;color: #555;font-size: 25rpx;">需求数量:</text>
  42. <text style="align-self: center;font-size: 30rpx;font-weight: bold;">{{newsitem.qty}}</text>
  43. </view>
  44. <view style="flex-direction: row;flex-direction: row;display: flex;padding: 1px;">
  45. <text style="align-self: center;color: #555;font-size: 25rpx;">已装配数量:</text>
  46. <text style="align-self: center;font-size: 30rpx;font-weight: bold;color: blue;">{{newsitem.assembleQty}}</text>
  47. </view>
  48. </view>
  49. <view v-if="newsitem.assembleQty < newsitem.qty" style="border-radius: 35px;width: 35px; background-color: lime;height: 35px;align-self: center;margin-right: 5px;"></view>
  50. <view v-else style="border-radius: 35px;width: 35px; background-color: lightgray;height: 35px;align-self: center;margin-right: 5px;"></view>
  51. </view>
  52. </view>
  53. </cell>
  54. </list>
  55. <!-- Tab1 页面渲染 已录入的出库记录-->
  56. <list v-else class="scroll-v list">
  57. <cell v-for="(newsitem,index2) in tab.data1" :key="newsitem.Id">
  58. <view class="myDeliverDetail" style="border: 1px #cccccc ;border-radius: 5px; margin-top: 1px;">
  59. <view style="flex-direction: row;flex-direction: row;height: 25px;display: flex;padding: 2px;border-radius: 5px 5px;">
  60. <text style="align-self: center;">物料编号:</text>
  61. <text style="align-self: center;">{{newsitem.materialCode}}</text>
  62. <text :class="newsitem.keyFlag ? 'keyFlagRed' : 'keyFlagGray'" style="align-self: center;margin-left: 20px;">{{newsitem.keyFlag ? '★' : '■'}}</text>
  63. </view>
  64. <view class="line-h"></view>
  65. <view style="flex-direction: row;flex-direction: row;display: flex;-webkit-justify-content: space-between;justify-content: space-between;">
  66. <view>
  67. <view style="flex-direction: row;flex-direction: row;display: flex;padding: 2px;">
  68. <text style="align-self: center;color: #555;font-size: 25rpx;">物料名称:</text>
  69. <text style="align-self: center;font-size: 25rpx;word-wrap: break-word;width: 200px;">{{newsitem.materialName}}</text>
  70. </view>
  71. <view style="flex-direction: row;flex-direction: row;display: flex;padding: 2px;">
  72. <text style="align-self: center;color: #555;font-size: 25rpx;">规格型号/图号:</text>
  73. <text style="align-self: center;font-size: 25rpx;word-wrap: break-word;width: 200px;">{{newsitem.materialSpec}}</text>
  74. </view>
  75. <!-- <view style="flex-direction: row;flex-direction: row;display: flex;padding: 2px;">
  76. <text style="align-self: center;color: #555;font-size: 25rpx;">生产令号:</text>
  77. <text style="align-self: center;font-size: 25rpx;word-wrap: break-word;width: 200px;">{{newsitem.bomNo}}</text>
  78. </view> -->
  79. <view style="flex-direction: row;flex-direction: row;display: flex;padding: 2px;">
  80. <text style="align-self: center;color: #555;font-size: 25rpx;">BN/SN:</text>
  81. <text style="align-self: center;font-size: 30rpx;font-weight: bold;word-wrap: break-word;width: 200px;">{{newsitem.BnSnCode}}</text>
  82. </view>
  83. <view style="flex-direction: row;flex-direction: row;display: flex;padding: 1px;">
  84. <text style="align-self: center;color: #555;font-size: 25rpx;">装配数量:</text>
  85. <text style="align-self: center;font-size: 30rpx;font-weight: bold;">{{newsitem.assembleNum}}</text>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </cell>
  91. </list>
  92. </swiper-item>
  93. </swiper>
  94. </view>
  95. </template>
  96. <script>
  97. // 缓存每页最多
  98. const MAX_CACHE_DATA = 100;
  99. // 缓存Tab页签数量
  100. const MAX_CACHE_PAGE = 3;
  101. export default {
  102. data() {
  103. return {
  104. data: [],
  105. bomNo: '',
  106. newsList: [],
  107. cacheTab: [],
  108. tabIndex: 0, // 当前Tab页的index索引
  109. tabBars: [{
  110. name: '关键件清单明细',
  111. id: 'jiaoyandan'
  112. },
  113. {
  114. name: '已装配记录',
  115. id: 'zhijianjilu'
  116. }
  117. ], // Tab页初始化数据
  118. scrollInto: "", // Tab滚动到某元素的id
  119. showTips: false,
  120. navigateFlag: false,
  121. pulling: false,
  122. imageSrc: '',
  123. refreshIcon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAB5QTFRFcHBw3Nzct7e39vb2ycnJioqK7e3tpqam29vb////D8oK7wAAAAp0Uk5T////////////ALLMLM8AAABxSURBVHja7JVBDoAgDASrjqj//7CJBi90iyYeOHTPMwmFZrHjYyyFYYUy1bwUZqtJIYVxhf1a6u0R7iUvWsCcrEtwJHp8MwMdvh2amHduiZD3rpWId9+BgPd7Cc2LIkPyqvlQvKxKBJ//Qwq/CacAAwDUv0a0YuKhzgAAAABJRU5ErkJggg=="
  124. }
  125. },
  126. onLoad(option) {
  127. this.bomNo = option.bomNo;
  128. this.tabBars.forEach((tabBar) => {
  129. this.newsList.push({
  130. data: [],
  131. data1: [],
  132. isLoading: false,
  133. refreshText: "",
  134. loadingText: '加载更多...'
  135. });
  136. });
  137. this.getList(0);
  138. uni.$on('addAssembleDtlData', this.addAssembleDtlData)
  139. },
  140. onUnload() {
  141. uni.$off('addAssembleDtlData', this.addAssembleDtlData)
  142. },
  143. methods: {
  144. async getList(index) {
  145. let activeTab = this.newsList[index];
  146. let parm = {
  147. url : '/business/SapBomRecord/QuerySapBomRecordList?bomNo=' + this.bomNo,
  148. data: { },
  149. method: 'POST',
  150. isHaveToken : true
  151. }
  152. let retData = await getApp().RequestData(parm)
  153. if(retData.isSuccess) {
  154. if(retData.data.code == 200) {
  155. activeTab.data = retData.data.data;
  156. // console.log(retData.data.data)
  157. }
  158. else {
  159. }
  160. }
  161. else {
  162. }
  163. },
  164. loadMore(e) {
  165. setTimeout(() => {
  166. this.getList(this.tabIndex);
  167. }, 500)
  168. },
  169. ontabtap(e) { // Tab页面点击事件
  170. let index = e.target.dataset.current || e.currentTarget.dataset.current;
  171. this.switchTab(index);
  172. },
  173. ontabchange(e) {
  174. let index = e.target.current || e.detail.current;
  175. this.switchTab(index);
  176. },
  177. switchTab(index) { // 切换Tab页面
  178. if (this.newsList[index].data.length === 0) {
  179. this.getList(index);
  180. }
  181. if (this.tabIndex === index) {
  182. return;
  183. }
  184. // 缓存 tabId
  185. if (this.newsList[this.tabIndex].data.length > MAX_CACHE_DATA) {
  186. // console.log(this.tabIndex)
  187. // console.log('123121!!')
  188. let isExist = this.cacheTab.indexOf(this.tabIndex);
  189. if (isExist < 0) {
  190. this.cacheTab.push(this.tabIndex);
  191. //console.log("cache index:: " + this.tabIndex);
  192. }
  193. }
  194. this.tabIndex = index;
  195. this.scrollInto = this.tabBars[index].id;
  196. // 释放 tabId
  197. if (this.cacheTab.length > MAX_CACHE_PAGE) {
  198. let cacheIndex = this.cacheTab[0];
  199. this.clearTabData(cacheIndex);
  200. this.cacheTab.splice(0, 1);
  201. }
  202. },
  203. clearTabData(e) {
  204. this.newsList[e].data.length = 0;
  205. this.newsList[e].loadingText = "加载更多...";
  206. },
  207. onrefresh(e) {
  208. // console.log('触发下拉完成事件!!!!!!!!!!!')
  209. var tab = this.newsList[this.tabIndex];
  210. if (!tab.refreshFlag) {
  211. return;
  212. }
  213. tab.refreshing = true;
  214. tab.refreshText = "正在刷新...";
  215. setTimeout(() => {
  216. this.pulling = true;
  217. tab.refreshing = false;
  218. tab.refreshFlag = false;
  219. tab.refreshText = "已刷新";
  220. setTimeout(() => { // TODO fix ios和Android 动画时间相反问题
  221. this.pulling = false;
  222. }, 500);
  223. }, 2000);
  224. },
  225. onpullingdown(e) {
  226. // console.log('触发下拉动作事件。')
  227. var tab = this.newsList[this.tabIndex];
  228. if (tab.refreshing || this.pulling) {
  229. return;
  230. }
  231. if (Math.abs(e.pullingDistance) > Math.abs(e.viewHeight)) {
  232. tab.refreshFlag = true;
  233. tab.refreshText = "释放立即刷新";
  234. } else {
  235. tab.refreshFlag = false;
  236. tab.refreshText = "下拉可以刷新";
  237. }
  238. },
  239. myDeliverDetailClick(model) {
  240. model.outTaskNo = this.outTaskNo;
  241. if(model.assembleQty >= model.qty) {
  242. uni.showToast({
  243. title: '已全部装配完成',
  244. icon: 'error',
  245. duration: 1000
  246. })
  247. } else {
  248. uni.navigateTo({
  249. url: '/pages/Outstore/outassembleOperate',
  250. success() {
  251. uni.$emit('sendCheckedDeliverDtlData',model)
  252. }
  253. });
  254. }
  255. },
  256. addAssembleDtlData(data) {
  257. let tabMd = this.newsList[1];
  258. tabMd.data1.push(data);
  259. this.updateSapBomListDtl(data);
  260. // console.log(data)
  261. },
  262. updateSapBomListDtl(data) {
  263. let tabMd0 = this.newsList[0];
  264. tabMd0.data.forEach((item) => {
  265. if(item.id === data.id) {
  266. item.assembleQty += Number(data.assembleNum);
  267. }
  268. })
  269. }
  270. }
  271. }
  272. </script>
  273. <style lang="scss">
  274. @import '@/common/uni-nvue.css';
  275. /* #ifndef APP-PLUS */
  276. page {
  277. width: 100%;
  278. min-height: 100%;
  279. display: flex;
  280. }
  281. /* #endif */
  282. .myDeliverDetail:active {
  283. background-color: aliceblue;
  284. }
  285. .customDeliver {
  286. padding: 5px;
  287. font-weight: bold;
  288. }
  289. .keyFlagRed {
  290. color: red;
  291. }
  292. .keyFlagGray {
  293. color: lightgray;
  294. }
  295. .tabs {
  296. flex: 1;
  297. flex-direction: column;
  298. overflow: hidden;
  299. background-color: white;
  300. /* #ifndef APP-PLUS */
  301. height: 100vh;
  302. /* #endif */
  303. padding: 5px;
  304. }
  305. .scroll-h {
  306. width: 750rpx;
  307. /* #ifdef H5 */
  308. width:100%;
  309. /* #endif */
  310. height: 80rpx;
  311. flex-direction: row;
  312. /* #ifndef APP-PLUS */
  313. white-space: nowrap;
  314. /* #endif */
  315. /* flex-wrap: nowrap; */
  316. /* border-color: #cccccc;
  317. border-bottom-style: solid;
  318. border-bottom-width: 1px; */
  319. }
  320. .line-h {
  321. height: 1rpx;
  322. background-color: #cccccc;
  323. }
  324. .uni-tab-item {
  325. /* #ifndef APP-PLUS */
  326. display: inline-block;
  327. /* #endif */
  328. flex-wrap: nowrap;
  329. padding-left: 60rpx;
  330. padding-right: 60rpx;
  331. }
  332. .uni-tab-item-title {
  333. color: #555;
  334. font-size: 40rpx;
  335. height: 80rpx;
  336. line-height: 80rpx;
  337. flex-wrap: nowrap;
  338. /* #ifndef APP-PLUS */
  339. white-space: nowrap;
  340. /* #endif */
  341. }
  342. .uni-tab-item-title-active {
  343. color: #007AFF;
  344. font-weight: bold;
  345. }
  346. .swiper-box {
  347. flex: 1;
  348. }
  349. .swiper-item {
  350. flex: 1;
  351. flex-direction: row;
  352. }
  353. .scroll-v {
  354. flex: 1;
  355. /* #ifndef MP-ALIPAY */
  356. flex-direction: column;
  357. /* #endif */
  358. width: 750rpx;
  359. width:100%;
  360. }
  361. .update-tips {
  362. position: absolute;
  363. left: 0;
  364. top: 41px;
  365. right: 0;
  366. padding-top: 5px;
  367. padding-bottom: 5px;
  368. background-color: #FDDD9B;
  369. align-items: center;
  370. justify-content: center;
  371. text-align: center;
  372. }
  373. .update-tips-text {
  374. font-size: 14px;
  375. color: #ffffff;
  376. }
  377. .refresh {
  378. width: 850rpx;
  379. /* width:100%; */
  380. height: 64px;
  381. justify-content: center;
  382. }
  383. .refresh-view {
  384. flex-direction: row;
  385. flex-wrap: nowrap;
  386. align-items: center;
  387. /* justify-content: center; */
  388. }
  389. .refresh-icon {
  390. width: 30px;
  391. height: 30px;
  392. transition-duration: .5s;
  393. transition-property: transform;
  394. transform: rotate(0deg);
  395. transform-origin: 15px 15px;
  396. margin-left: 5px;
  397. }
  398. .refresh-icon-active {
  399. transform: rotate(180deg);
  400. }
  401. .loading-icon {
  402. width: 20px;
  403. height: 20px;
  404. margin-right: 5px;
  405. color: #999999;
  406. }
  407. .loading-text {
  408. margin-left: 1px;
  409. font-size: 16px;
  410. color: #999999;
  411. }
  412. .loading-more {
  413. align-items: center;
  414. justify-content: center;
  415. padding-top: 10px;
  416. padding-bottom: 10px;
  417. text-align: center;
  418. }
  419. .loading-more-text {
  420. font-size: 28rpx;
  421. color: #999;
  422. }
  423. </style>