instoreDtl.nvue 18 KB

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