inspectDtl - 副本.nvue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  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" item-id="0">
  11. <list class="scroll-v list" enableBackToTop="true" scroll-y loadmoreoffset="15" @loadmore="loadMore(0)">
  12. <!-- <refresh class="refresh" @refresh="onrefresh(0)" @pullingdown="onpullingdown" :display="isShowTab0Refresh ? 'show' : 'hide'">
  13. <div class="refresh-view">
  14. <image class="refresh-icon" :src="refreshIcon" :style="{width: (isShowTab0Refresh || pulling) ? 0: '30px'}" :class="{'refresh-icon-active': refreshTab0Flag}"></image>
  15. <loading-indicator class="loading-icon" animating="true" v-if="isShowTab0Refresh"></loading-indicator>
  16. <text class="loading-text">{{refreshTab0Text}}</text>
  17. </div>
  18. </refresh> -->
  19. <cell>
  20. <view class="customDeliver">
  21. <text style="text-align: center;font-weight: bold;">{{"交验单号: " + deliverNo}}</text>
  22. </view>
  23. </cell>
  24. <cell v-for="(newsitem,index2) in data" :key="newsitem.Id">
  25. <view style="border: 1px #cccccc ;border-radius: 5px; margin-top: 1px;">
  26. <view style="flex-direction: row;flex-direction: row;height: 25px;display: flex;padding: 2px;border-radius: 5px 5px;">
  27. <text style="align-self: center;">物料编号:</text>
  28. <text style="align-self: center;">{{newsitem.materialCode}}</text>
  29. <text :class="newsitem.keyFlag ? 'keyFlagRed' : 'keyFlagGray'" style="align-self: center;margin-left: 20px;">{{newsitem.keyFlag ? '★' : '■'}}</text>
  30. </view>
  31. <view class="line-h"></view>
  32. <view style="flex-direction: row;flex-direction: row;display: flex;-webkit-justify-content: space-between;justify-content: space-between;">
  33. <view>
  34. <view style="flex-direction: row;flex-direction: row;display: flex;padding: 2px;">
  35. <text style="align-self: center;color: #555;font-size: 25rpx;">物料名称:</text>
  36. <text style="align-self: center;font-size: 25rpx;word-wrap: break-word;width: 200px;">{{newsitem.materialName}}</text>
  37. </view>
  38. <view style="flex-direction: row;flex-direction: row;display: flex;padding: 2px;">
  39. <text style="align-self: center;color: #555;font-size: 25rpx;">规格型号/图号:</text>
  40. <text style="align-self: center;font-size: 25rpx;word-wrap: break-word;width: 200px;">{{newsitem.materialSpec}}</text>
  41. </view>
  42. <view style="flex-direction: row;flex-direction: row;display: flex;padding: 2px;">
  43. <text style="align-self: center;color: #555;font-size: 25rpx;">生产令号:</text>
  44. <text style="align-self: center;font-size: 25rpx;word-wrap: break-word;width: 200px;">{{newsitem.bomNo}}</text>
  45. </view>
  46. <!-- <view style="flex-direction: row;flex-direction: row;display: flex;padding: 2px;">
  47. <text style="align-self: center;color: #555;font-size: 25rpx;">BN/SN:</text>
  48. <text style="align-self: center;font-size: 25rpx;word-wrap: break-word;width: 200px;">100877-231</text>
  49. </view> -->
  50. <view style="flex-direction: row;flex-direction: row;display: flex;padding: 1px;">
  51. <text style="align-self: center;color: #555;font-size: 25rpx;">交验单数量:</text>
  52. <text style="align-self: center;font-size: 30rpx;font-weight: bold;">{{newsitem.qty}}</text>
  53. </view>
  54. <view style="flex-direction: row;flex-direction: row;display: flex;padding: 1px;">
  55. <text style="align-self: center;color: #555;font-size: 25rpx;">质检合格数量:</text>
  56. <text style="align-self: center;font-size: 30rpx;font-weight: bold;color: blue;">{{newsitem.check_qty}}</text>
  57. </view>
  58. </view>
  59. <view style="border-radius: 35px;width: 35px; background-color: lime;height: 35px;align-self: center;margin-right: 5px;"></view>
  60. </view>
  61. </view>
  62. </cell>
  63. <!-- <cell class="loading-more" v-if="isTab0Loading || data.length > 4">
  64. <text class="loading-more-text">加载更多...</text>
  65. </cell> -->
  66. </list>
  67. <!-- <view> Tab 0</view> -->
  68. </swiper-item>
  69. <swiper-item class="swiper-item" item-id="1">
  70. <view> Tab 1</view>
  71. </swiper-item>
  72. </swiper>
  73. </view>
  74. </template>
  75. <script>
  76. // 引入新闻详细组件
  77. import mediaItem from './news-item.nvue';
  78. // 缓存每页最多
  79. const MAX_CACHE_DATA = 100;
  80. // 缓存Tab页签数量
  81. const MAX_CACHE_PAGE = 3;
  82. // 定义新闻样例数据
  83. const newsData = {
  84. data0: {
  85. "datetime": "40分钟前",
  86. "article_type": 0,
  87. "title": "uni-app行业峰会频频亮相,开发者反响热烈!",
  88. "source": "DCloud",
  89. "comment_count": 639
  90. },
  91. data1: {
  92. "datetime": "一天前",
  93. "article_type": 1,
  94. "title": "DCloud完成B2轮融资,uni-app震撼发布!",
  95. "image_url": "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b7c7f970-517d-11eb-97b7-0dc4655d6e68.jpg",
  96. "source": "DCloud",
  97. "comment_count": 11395
  98. },
  99. data2: {
  100. "datetime": "一天前",
  101. "article_type": 2,
  102. "title": "中国技术界小奇迹:HBuilder开发者突破200万",
  103. "image_url": "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b4cd3000-517d-11eb-a16f-5b3e54966275.jpg",
  104. "source": "DCloud",
  105. "comment_count": 11395
  106. },
  107. data3: {
  108. "article_type": 3,
  109. "image_list": [{
  110. "url": "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b2e201d0-517d-11eb-8a36-ebb87efcf8c0.jpg",
  111. "width": 563,
  112. "height": 316
  113. }, {
  114. "url": "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b4cd3000-517d-11eb-a16f-5b3e54966275.jpg",
  115. "width": 641,
  116. "height": 360
  117. }, {
  118. "url": "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b7c7f970-517d-11eb-97b7-0dc4655d6e68.jpg",
  119. "width": 640,
  120. "height": 360
  121. }],
  122. "datetime": "5分钟前",
  123. "title": "uni-app 支持使用 npm 安装第三方包,生态更趋丰富",
  124. "source": "DCloud",
  125. "comment_count": 11
  126. },
  127. data4: {
  128. "datetime": "2小时前",
  129. "article_type": 4,
  130. "title": "uni-app 支持原生小程序自定义组件,更开放、更自由",
  131. "image_url": "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b2e201d0-517d-11eb-8a36-ebb87efcf8c0.jpg",
  132. "source": "DCloud",
  133. "comment_count": 69
  134. }
  135. };
  136. const testSapDeliverData = [
  137. {
  138. Id: 1,
  139. deliverNo: this.deliverNo,
  140. purchaseOrder: '6200003425',
  141. checkName: 'MM125210',
  142. bomNo: 'T2-22001',
  143. materialCode: '10110-673030A',
  144. materialName: '合页垫板',
  145. materialSpec: 'BME75-01080-03',
  146. keyFlag: 1,
  147. qty: 1,
  148. check_qty: 0
  149. },
  150. {
  151. Id: 2,
  152. deliverNo: this.deliverNo,
  153. purchaseOrder: '6200003425',
  154. checkName: 'MM125210',
  155. bomNo: 'T2-22001',
  156. materialCode: '10110-673031A',
  157. materialName: '旋转开关垫板',
  158. materialSpec: 'BME75-01080-04',
  159. keyFlag: 0,
  160. qty: 1,
  161. check_qty: 0
  162. },
  163. {
  164. Id: 3,
  165. deliverNo: this.deliverNo,
  166. purchaseOrder: '6200003425',
  167. checkName: 'MM125210',
  168. bomNo: 'T1-21344',
  169. materialCode: '10110-673773A',
  170. materialName: '侧板主体2',
  171. materialSpec: 'BMF15-01100-02',
  172. keyFlag: 1,
  173. qty: 4,
  174. check_qty: 0
  175. },
  176. {
  177. Id: 4,
  178. deliverNo: this.deliverNo,
  179. purchaseOrder: '6200003425',
  180. checkName: 'MM125210',
  181. bomNo: 'T2-22001',
  182. materialCode: '10125-067445A',
  183. materialName: '脚轮组件连接件1',
  184. materialSpec: 'BME75-01020-01',
  185. keyFlag: 1,
  186. qty: 4,
  187. check_qty: 0
  188. },
  189. {
  190. Id: 5,
  191. deliverNo: this.deliverNo,
  192. purchaseOrder: '6200003425',
  193. checkName: 'MM125210',
  194. bomNo: 'T2-22001',
  195. materialCode: '10125-067449A',
  196. materialName: '旋转开关垫板',
  197. materialSpec: 'BME75-06000-04',
  198. keyFlag: 1,
  199. qty: 1,
  200. check_qty: 0
  201. }
  202. ];
  203. export default {
  204. components: {
  205. mediaItem
  206. },
  207. data() {
  208. return {
  209. data: [],
  210. deliverNo: '',
  211. newsList: [], // 新闻列表数据
  212. cacheTab: [],
  213. tabIndex: 0, // 当前Tab页的index索引
  214. tabBars: [{
  215. name: '交验单明细',
  216. id: 'jiaoyandan'
  217. },
  218. {
  219. name: '已录入的质检记录',
  220. id: 'zhijianjilu'
  221. }
  222. ], // Tab页初始化数据
  223. scrollInto: "", // Tab滚动到某元素的id
  224. showTips: false,
  225. navigateFlag: false,
  226. pulling: false,
  227. isShowTab0Refresh: false,
  228. isTab0Loading: false,
  229. refreshTab0Text: '',
  230. refreshTab0Flag: false,
  231. refreshIcon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAB5QTFRFcHBw3Nzct7e39vb2ycnJioqK7e3tpqam29vb////D8oK7wAAAAp0Uk5T////////////ALLMLM8AAABxSURBVHja7JVBDoAgDASrjqj//7CJBi90iyYeOHTPMwmFZrHjYyyFYYUy1bwUZqtJIYVxhf1a6u0R7iUvWsCcrEtwJHp8MwMdvh2amHduiZD3rpWId9+BgPd7Cc2LIkPyqvlQvKxKBJ//Qwq/CacAAwDUv0a0YuKhzgAAAABJRU5ErkJggg=="
  232. }
  233. },
  234. onLoad(option) {
  235. this.deliverNo = option.deliverNo;
  236. // setTimeout(()=>{
  237. // this.tabBars.forEach((tabBar) => {
  238. // this.newsList.push({
  239. // data: [],
  240. // isLoading: false,
  241. // refreshText: "",
  242. // loadingText: '加载更多...'
  243. // });
  244. // });
  245. // this.getList(0);
  246. // },350)
  247. setTimeout(()=>{
  248. for(let i = 0; i < testSapDeliverData.length; i++) {
  249. this.data.push(testSapDeliverData[i]);
  250. }
  251. },600)
  252. console.log(this.data)
  253. },
  254. methods: {
  255. getList(index) { // 获取新闻数据
  256. let activeTab = this.newsList[index];
  257. let list = [];
  258. for (let i = 1; i <= 10; i++) {
  259. let item = Object.assign({}, newsData['data' + Math.floor(Math.random() * 5)]);
  260. item.id = this.newGuid();
  261. list.push(item);
  262. }
  263. activeTab.data = activeTab.data.concat(list);
  264. },
  265. goDetail(e) { // 打开新闻详细信息组件
  266. if (this.navigateFlag) {
  267. return;
  268. }
  269. this.navigateFlag = true;
  270. uni.navigateTo({
  271. url: '/pages/Inspect/detail/detail?title=' + e.title
  272. });
  273. setTimeout(() => {
  274. this.navigateFlag = false;
  275. }, 200)
  276. },
  277. close(index1, index2) {
  278. uni.showModal({
  279. content: '是否删除本条信息?',
  280. success: (res) => {
  281. if (res.confirm) {
  282. this.newsList[index1].data.splice(index2, 1);
  283. }
  284. }
  285. })
  286. },
  287. loadMore(e) {
  288. setTimeout(() => {
  289. this.getList(this.tabIndex);
  290. }, 500)
  291. },
  292. ontabtap(e) { // Tab页面点击事件
  293. let index = e.target.dataset.current || e.currentTarget.dataset.current;
  294. this.switchTab(index);
  295. },
  296. ontabchange(e) {
  297. let index = e.target.current || e.detail.current;
  298. this.switchTab(index);
  299. },
  300. switchTab(index) { // 切换Tab页面
  301. if (this.newsList[index].data.length === 0) {
  302. this.getList(index);
  303. }
  304. if (this.tabIndex === index) {
  305. return;
  306. }
  307. // 缓存 tabId
  308. if (this.newsList[this.tabIndex].data.length > MAX_CACHE_DATA) {
  309. let isExist = this.cacheTab.indexOf(this.tabIndex);
  310. if (isExist < 0) {
  311. this.cacheTab.push(this.tabIndex);
  312. //console.log("cache index:: " + this.tabIndex);
  313. }
  314. }
  315. this.tabIndex = index;
  316. this.scrollInto = this.tabBars[index].id;
  317. // 释放 tabId
  318. if (this.cacheTab.length > MAX_CACHE_PAGE) {
  319. let cacheIndex = this.cacheTab[0];
  320. this.clearTabData(cacheIndex);
  321. this.cacheTab.splice(0, 1);
  322. //console.log("remove cache index:: " + cacheIndex);
  323. }
  324. },
  325. clearTabData(e) {
  326. this.newsList[e].data.length = 0;
  327. this.newsList[e].loadingText = "加载更多...";
  328. },
  329. refreshData() {},
  330. onrefresh(e) {
  331. var tab = this.newsList[this.tabIndex];
  332. if (!tab.refreshFlag) {
  333. return;
  334. }
  335. tab.refreshing = true;
  336. tab.refreshText = "正在刷新...";
  337. setTimeout(() => {
  338. this.refreshData();
  339. this.pulling = true;
  340. tab.refreshing = false;
  341. tab.refreshFlag = false;
  342. tab.refreshText = "已刷新";
  343. setTimeout(() => { // TODO fix ios和Android 动画时间相反问题
  344. this.pulling = false;
  345. }, 500);
  346. }, 2000);
  347. },
  348. onpullingdown(e) {
  349. var tab = this.newsList[this.tabIndex];
  350. if (tab.refreshing || this.pulling) {
  351. return;
  352. }
  353. if (Math.abs(e.pullingDistance) > Math.abs(e.viewHeight)) {
  354. tab.refreshFlag = true;
  355. tab.refreshText = "释放立即刷新";
  356. } else {
  357. tab.refreshFlag = false;
  358. tab.refreshText = "下拉可以刷新";
  359. }
  360. },
  361. newGuid() {
  362. let s4 = function() {
  363. return (65536 * (1 + Math.random()) | 0).toString(16).substring(1);
  364. }
  365. return (s4() + s4() + "-" + s4() + "-4" + s4().substr(0, 3) + "-" + s4() + "-" + s4() + s4() + s4()).toUpperCase();
  366. }
  367. }
  368. }
  369. </script>
  370. <style lang="scss">
  371. @import '@/common/uni-nvue.css';
  372. /* #ifndef APP-PLUS */
  373. page {
  374. width: 100%;
  375. min-height: 100%;
  376. display: flex;
  377. }
  378. /* #endif */
  379. .customDeliver {
  380. padding: 5px;
  381. font-weight: bold;
  382. }
  383. .keyFlagRed {
  384. color: red;
  385. }
  386. .keyFlagGray {
  387. color: lightgray;
  388. }
  389. .tabs {
  390. flex: 1;
  391. flex-direction: column;
  392. overflow: hidden;
  393. background-color: white;
  394. /* #ifndef APP-PLUS */
  395. height: 100vh;
  396. /* #endif */
  397. padding: 5px;
  398. }
  399. .scroll-h {
  400. width: 750rpx;
  401. /* #ifdef H5 */
  402. width:100%;
  403. /* #endif */
  404. height: 80rpx;
  405. flex-direction: row;
  406. /* #ifndef APP-PLUS */
  407. white-space: nowrap;
  408. /* #endif */
  409. /* flex-wrap: nowrap; */
  410. /* border-color: #cccccc;
  411. border-bottom-style: solid;
  412. border-bottom-width: 1px; */
  413. }
  414. .line-h {
  415. height: 1rpx;
  416. background-color: #cccccc;
  417. }
  418. .uni-tab-item {
  419. /* #ifndef APP-PLUS */
  420. display: inline-block;
  421. /* #endif */
  422. flex-wrap: nowrap;
  423. padding-left: 60rpx;
  424. padding-right: 60rpx;
  425. }
  426. .uni-tab-item-title {
  427. color: #555;
  428. font-size: 40rpx;
  429. height: 80rpx;
  430. line-height: 80rpx;
  431. flex-wrap: nowrap;
  432. /* #ifndef APP-PLUS */
  433. white-space: nowrap;
  434. /* #endif */
  435. }
  436. .uni-tab-item-title-active {
  437. color: #007AFF;
  438. font-weight: bold;
  439. }
  440. .swiper-box {
  441. flex: 1;
  442. }
  443. .swiper-item {
  444. flex: 1;
  445. flex-direction: row;
  446. }
  447. .scroll-v {
  448. flex: 1;
  449. /* #ifndef MP-ALIPAY */
  450. flex-direction: column;
  451. /* #endif */
  452. width: 750rpx;
  453. width:100%;
  454. }
  455. .update-tips {
  456. position: absolute;
  457. left: 0;
  458. top: 41px;
  459. right: 0;
  460. padding-top: 5px;
  461. padding-bottom: 5px;
  462. background-color: #FDDD9B;
  463. align-items: center;
  464. justify-content: center;
  465. text-align: center;
  466. }
  467. .update-tips-text {
  468. font-size: 14px;
  469. color: #ffffff;
  470. }
  471. .refresh {
  472. width: 850rpx;
  473. /* width:100%; */
  474. height: 64px;
  475. justify-content: center;
  476. }
  477. .refresh-view {
  478. flex-direction: row;
  479. flex-wrap: nowrap;
  480. align-items: center;
  481. /* justify-content: center; */
  482. }
  483. .refresh-icon {
  484. width: 30px;
  485. height: 30px;
  486. transition-duration: .5s;
  487. transition-property: transform;
  488. transform: rotate(0deg);
  489. transform-origin: 15px 15px;
  490. margin-left: 5px;
  491. }
  492. .refresh-icon-active {
  493. transform: rotate(180deg);
  494. }
  495. .loading-icon {
  496. width: 20px;
  497. height: 20px;
  498. margin-right: 5px;
  499. color: #999999;
  500. }
  501. .loading-text {
  502. margin-left: 1px;
  503. font-size: 16px;
  504. color: #999999;
  505. }
  506. .loading-more {
  507. align-items: center;
  508. justify-content: center;
  509. padding-top: 10px;
  510. padding-bottom: 10px;
  511. text-align: center;
  512. }
  513. .loading-more-text {
  514. font-size: 28rpx;
  515. color: #999;
  516. }
  517. </style>