outstoreDtl.nvue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  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 页面渲染 出库任务单明细-->
  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;">{{"出库任务单号: " + outTaskNo}}</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.outQty}}</text>
  47. </view>
  48. </view>
  49. <view v-if="newsitem.outQty < 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.outStoreQty}}</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. outTaskNo: '',
  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. refreshIcon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAB5QTFRFcHBw3Nzct7e39vb2ycnJioqK7e3tpqam29vb////D8oK7wAAAAp0Uk5T////////////ALLMLM8AAABxSURBVHja7JVBDoAgDASrjqj//7CJBi90iyYeOHTPMwmFZrHjYyyFYYUy1bwUZqtJIYVxhf1a6u0R7iUvWsCcrEtwJHp8MwMdvh2amHduiZD3rpWId9+BgPd7Cc2LIkPyqvlQvKxKBJ//Qwq/CacAAwDUv0a0YuKhzgAAAABJRU5ErkJggg=="
  123. }
  124. },
  125. onLoad(option) {
  126. this.outTaskNo = option.outTaskNo;
  127. this.tabBars.forEach((tabBar) => {
  128. this.newsList.push({
  129. data: [],
  130. data1: [],
  131. isLoading: false,
  132. refreshText: "",
  133. loadingText: '加载更多...'
  134. });
  135. });
  136. this.getList(0);
  137. uni.$on('addOutstoreData', this.addOutstoreData)
  138. },
  139. onUnload() {
  140. uni.$off('addOutstoreData', this.addOutstoreData)
  141. },
  142. methods: {
  143. async getList(index) {
  144. let activeTab = this.newsList[index];
  145. let parm = {
  146. url : '/SapInterface/QuerySapOutTaskRecordList?outTaskNo=' + this.outTaskNo,
  147. data: { },
  148. method: 'POST',
  149. isHaveToken : true
  150. }
  151. let retData = await getApp().RequestData(parm)
  152. if(retData.isSuccess) {
  153. if(retData.data.code == 200) {
  154. activeTab.data = retData.data.data;
  155. }
  156. else {
  157. }
  158. }
  159. else {
  160. }
  161. },
  162. loadMore(e) {
  163. setTimeout(() => {
  164. this.getList(this.tabIndex);
  165. }, 500)
  166. },
  167. ontabtap(e) { // Tab页面点击事件
  168. let index = e.target.dataset.current || e.currentTarget.dataset.current;
  169. this.switchTab(index);
  170. },
  171. ontabchange(e) {
  172. let index = e.target.current || e.detail.current;
  173. this.switchTab(index);
  174. },
  175. switchTab(index) { // 切换Tab页面
  176. if (this.newsList[index].data.length === 0) {
  177. this.getList(index);
  178. }
  179. if (this.tabIndex === index) {
  180. return;
  181. }
  182. // 缓存 tabId
  183. if (this.newsList[this.tabIndex].data.length > MAX_CACHE_DATA) {
  184. // console.log(this.tabIndex)
  185. // console.log('123121!!')
  186. let isExist = this.cacheTab.indexOf(this.tabIndex);
  187. if (isExist < 0) {
  188. this.cacheTab.push(this.tabIndex);
  189. //console.log("cache index:: " + this.tabIndex);
  190. }
  191. }
  192. this.tabIndex = index;
  193. this.scrollInto = this.tabBars[index].id;
  194. // 释放 tabId
  195. if (this.cacheTab.length > MAX_CACHE_PAGE) {
  196. let cacheIndex = this.cacheTab[0];
  197. this.clearTabData(cacheIndex);
  198. this.cacheTab.splice(0, 1);
  199. }
  200. },
  201. clearTabData(e) {
  202. this.newsList[e].data.length = 0;
  203. this.newsList[e].loadingText = "加载更多...";
  204. },
  205. onrefresh(e) {
  206. // console.log('触发下拉完成事件!!!!!!!!!!!')
  207. var tab = this.newsList[this.tabIndex];
  208. if (!tab.refreshFlag) {
  209. return;
  210. }
  211. tab.refreshing = true;
  212. tab.refreshText = "正在刷新...";
  213. setTimeout(() => {
  214. this.pulling = true;
  215. tab.refreshing = false;
  216. tab.refreshFlag = false;
  217. tab.refreshText = "已刷新";
  218. setTimeout(() => { // TODO fix ios和Android 动画时间相反问题
  219. this.pulling = false;
  220. }, 500);
  221. }, 2000);
  222. },
  223. onpullingdown(e) {
  224. // console.log('触发下拉动作事件。')
  225. var tab = this.newsList[this.tabIndex];
  226. if (tab.refreshing || this.pulling) {
  227. return;
  228. }
  229. if (Math.abs(e.pullingDistance) > Math.abs(e.viewHeight)) {
  230. tab.refreshFlag = true;
  231. tab.refreshText = "释放立即刷新";
  232. } else {
  233. tab.refreshFlag = false;
  234. tab.refreshText = "下拉可以刷新";
  235. }
  236. },
  237. newGuid() {
  238. let s4 = function() {
  239. return (65536 * (1 + Math.random()) | 0).toString(16).substring(1);
  240. }
  241. return (s4() + s4() + "-" + s4() + "-4" + s4().substr(0, 3) + "-" + s4() + "-" + s4() + s4() + s4()).toUpperCase();
  242. },
  243. myDeliverDetailClick(model) {
  244. model.outTaskNo = this.outTaskNo;
  245. if(model.outQty >= model.qty) {
  246. uni.showToast({
  247. title: '已全部出库完成',
  248. icon: 'error',
  249. duration: 1000
  250. })
  251. } else {
  252. uni.navigateTo({
  253. url: '/pages/Outstore/outstoreOperate',
  254. success() {
  255. uni.$emit('sendCheckedDeliverDtlData',model)
  256. }
  257. });
  258. }
  259. },
  260. addOutstoreData(data) {
  261. let tabMd = this.newsList[1];
  262. tabMd.data1.push(data);
  263. this.updateDeliverDtl(data);
  264. },
  265. updateDeliverDtl(data) {
  266. let tabMd0 = this.newsList[0];
  267. tabMd0.data.forEach((item) => {
  268. if(item.id === data.id) {
  269. item.outQty += Number(data.outStoreQty);
  270. }
  271. })
  272. }
  273. }
  274. }
  275. </script>
  276. <style lang="scss">
  277. @import '@/common/uni-nvue.css';
  278. /* #ifndef APP-PLUS */
  279. page {
  280. width: 100%;
  281. min-height: 100%;
  282. display: flex;
  283. }
  284. /* #endif */
  285. .myDeliverDetail:active {
  286. background-color: aliceblue;
  287. }
  288. .customDeliver {
  289. padding: 5px;
  290. font-weight: bold;
  291. }
  292. .keyFlagRed {
  293. color: red;
  294. }
  295. .keyFlagGray {
  296. color: lightgray;
  297. }
  298. .tabs {
  299. flex: 1;
  300. flex-direction: column;
  301. overflow: hidden;
  302. background-color: white;
  303. /* #ifndef APP-PLUS */
  304. height: 100vh;
  305. /* #endif */
  306. padding: 5px;
  307. }
  308. .scroll-h {
  309. width: 750rpx;
  310. /* #ifdef H5 */
  311. width:100%;
  312. /* #endif */
  313. height: 80rpx;
  314. flex-direction: row;
  315. /* #ifndef APP-PLUS */
  316. white-space: nowrap;
  317. /* #endif */
  318. /* flex-wrap: nowrap; */
  319. /* border-color: #cccccc;
  320. border-bottom-style: solid;
  321. border-bottom-width: 1px; */
  322. }
  323. .line-h {
  324. height: 1rpx;
  325. background-color: #cccccc;
  326. }
  327. .uni-tab-item {
  328. /* #ifndef APP-PLUS */
  329. display: inline-block;
  330. /* #endif */
  331. flex-wrap: nowrap;
  332. padding-left: 60rpx;
  333. padding-right: 60rpx;
  334. }
  335. .uni-tab-item-title {
  336. color: #555;
  337. font-size: 40rpx;
  338. height: 80rpx;
  339. line-height: 80rpx;
  340. flex-wrap: nowrap;
  341. /* #ifndef APP-PLUS */
  342. white-space: nowrap;
  343. /* #endif */
  344. }
  345. .uni-tab-item-title-active {
  346. color: #007AFF;
  347. font-weight: bold;
  348. }
  349. .swiper-box {
  350. flex: 1;
  351. }
  352. .swiper-item {
  353. flex: 1;
  354. flex-direction: row;
  355. }
  356. .scroll-v {
  357. flex: 1;
  358. /* #ifndef MP-ALIPAY */
  359. flex-direction: column;
  360. /* #endif */
  361. width: 750rpx;
  362. width:100%;
  363. }
  364. .update-tips {
  365. position: absolute;
  366. left: 0;
  367. top: 41px;
  368. right: 0;
  369. padding-top: 5px;
  370. padding-bottom: 5px;
  371. background-color: #FDDD9B;
  372. align-items: center;
  373. justify-content: center;
  374. text-align: center;
  375. }
  376. .update-tips-text {
  377. font-size: 14px;
  378. color: #ffffff;
  379. }
  380. .refresh {
  381. width: 850rpx;
  382. /* width:100%; */
  383. height: 64px;
  384. justify-content: center;
  385. }
  386. .refresh-view {
  387. flex-direction: row;
  388. flex-wrap: nowrap;
  389. align-items: center;
  390. /* justify-content: center; */
  391. }
  392. .refresh-icon {
  393. width: 30px;
  394. height: 30px;
  395. transition-duration: .5s;
  396. transition-property: transform;
  397. transform: rotate(0deg);
  398. transform-origin: 15px 15px;
  399. margin-left: 5px;
  400. }
  401. .refresh-icon-active {
  402. transform: rotate(180deg);
  403. }
  404. .loading-icon {
  405. width: 20px;
  406. height: 20px;
  407. margin-right: 5px;
  408. color: #999999;
  409. }
  410. .loading-text {
  411. margin-left: 1px;
  412. font-size: 16px;
  413. color: #999999;
  414. }
  415. .loading-more {
  416. align-items: center;
  417. justify-content: center;
  418. padding-top: 10px;
  419. padding-bottom: 10px;
  420. text-align: center;
  421. }
  422. .loading-more-text {
  423. font-size: 28rpx;
  424. color: #999;
  425. }
  426. </style>