sampleList.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. <!-- 样品列表页面 -->
  2. <template>
  3. <view class="mainBox">
  4. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" :title="title" @clickLeft="handleClose">
  5. </uni-nav-bar>
  6. <!-- <view class="nav-placeholder"></view> -->
  7. <view class="wrapper">
  8. <scroll-view class="scroll-wrapper" scroll-y>
  9. <view class="sample-list">
  10. <view class="sample-item"
  11. v-for="(sample, sampleIndex) in projectId?tableData.filter(item=>item.id==projectId):tableData"
  12. :key="sampleIndex">
  13. <view class="sample-header" @click="toggleExpand(sampleIndex)">
  14. <view class="sample-info">
  15. <view class="info-row">
  16. <text class="label">编码:</text>
  17. <text class="value">{{ sample.categoryCode }}</text>
  18. </view>
  19. <view class="info-row">
  20. <text class="label">名称:</text>
  21. <text class="value">{{ sample.categoryName }}</text>
  22. </view>
  23. <view class="info-row" v-if="sample.batchNo">
  24. <text class="label">批次号:</text>
  25. <text class="value">{{ sample.batchNo }}</text>
  26. </view>
  27. <view class="info-row" v-if="sample.packageNo">
  28. <text class="label">包装编码:</text>
  29. <text class="value">{{ sample.packageNo }}</text>
  30. </view>
  31. </view>
  32. <view class="expand-arrow" :class="{ expanded: expandedItems[sampleIndex] }">›</view>
  33. </view>
  34. <view class="quality-table-wrapper" v-if="expandedItems[sampleIndex]">
  35. <scroll-view class="quality-table-scroll" scroll-x>
  36. <view class="quality-table">
  37. <view class="table-header">
  38. <view class="table-cell">质检项名称</view>
  39. <view class="table-cell">质检内容</view>
  40. <view class="table-cell">质检结果</view>
  41. <view class="table-cell">质检方案编码</view>
  42. <view class="table-cell">质检方案名称</view>
  43. <view class="table-cell">质检类型</view>
  44. <view class="table-cell">工艺参数</view>
  45. </view>
  46. <view class="table-body">
  47. <view class="table-row" v-for="(
  48. quality, qualityIndex
  49. ) in sample.qualitySampleTemplateList" :key="qualityIndex">
  50. <view class="table-cell">
  51. <text class="cell-text"
  52. :class="{ warn: quality.qualityResults === 2 }">{{ quality.inspectionName }}</text>
  53. </view>
  54. <view class="table-cell">
  55. <u-input v-model="quality.qualityResultContent" placeholder="请输入"
  56. border="none" @change="
  57. handleInput(
  58. quality,
  59. quality.qualityResultContent,
  60. tableData,
  61. )
  62. " :class="{ warn: quality.qualityResults === 2 }" :disabled="
  63. type === 'detail' ||
  64. ((!pageName||pageName=='myList') && sample.correlationId)
  65. ">
  66. <template #suffix v-if="quality.unitName">
  67. <text class="unit">{{ quality.unitName }}</text>
  68. </template>
  69. </u-input>
  70. </view>
  71. <view class="table-cell">
  72. <u-input disabled placeholder=" " v-if="type === 'detail' ||
  73. ((!pageName||pageName=='myList') && sample.correlationId)" border="surround" :value="
  74. quality.qualityResults &&
  75. qualityResultsList.find(
  76. (item) => item.value == quality.qualityResults,
  77. ).text
  78. ">
  79. </u-input>
  80. <uni-data-picker v-else v-model="quality.qualityResults"
  81. placeholder="请选择" :localdata="qualityResultsList"
  82. @change="qualityResultsListChange(tableData)" :clear-icon="false">
  83. </uni-data-picker>
  84. </view>
  85. <view class="table-cell">
  86. <text class="cell-text"
  87. :class="{ warn: quality.qualityResults === 2 }">{{ quality.qualitySchemeTemplateCode }}</text>
  88. </view>
  89. <view class="table-cell">
  90. <text class="cell-text"
  91. :class="{ warn: quality.qualityResults === 2 }">{{ quality.qualitySchemeTemplateName }}</text>
  92. </view>
  93. <view class="table-cell">
  94. <text class="cell-text"
  95. :class="{ warn: quality.qualityResults === 2 }">{{ quality.categoryLevelClassName }}</text>
  96. </view>
  97. <view class="table-cell parameter-cell">
  98. <text class="cell-text" :class="{ warn: quality.qualityResults === 2 }">
  99. <text v-if="quality.textType == 3">
  100. {{ quality.symbol }}
  101. {{ quality.minValue }}-{{ quality.maxValue }}
  102. </text>
  103. <text v-else>
  104. {{ quality.symbol }} {{ quality.defaultValue }}
  105. </text>
  106. {{ quality.unitName }}
  107. </text>
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. </scroll-view>
  113. </view>
  114. <view class="quality-summary" v-if="sample.qualityResults">
  115. <view style="min-width: 10px;margin-left: 16rpx;">
  116. <text>
  117. {{sample.status==1?'已检':sample.status==2?'已派单':sample.status==3?'已请托':'待检'}}
  118. </text>
  119. </view>
  120. <view>
  121. <text class="summary-label">样品质检结果:</text>
  122. <text class="summary-value" :class="getQualityResultClass(sample.qualityResults)">
  123. {{ formatQualityResult(sample.qualityResults) }}
  124. </text>
  125. </view>
  126. </view>
  127. </view>
  128. <view class="empty-state" v-if="!tableData || tableData.length === 0">
  129. <text>暂无数据</text>
  130. </view>
  131. </view>
  132. </scroll-view>
  133. <view style="height: 84rpx"></view>
  134. <view class="footerButton">
  135. <u-button @click="handleClose" type="default" text="返回"></u-button>
  136. <u-button v-if="type != 'view'&&!isCorrelationId&&workData.status!=1" type="primary" @click="save" text="保存"></u-button>
  137. </view>
  138. </view>
  139. <u-toast ref="uToast"></u-toast>
  140. </view>
  141. </template>
  142. <script>
  143. import {
  144. getById,
  145. update,
  146. queryQualityInventory
  147. } from "@/api/inspectionWork/index.js";
  148. import {
  149. handleInput,
  150. qualityResultsListChange
  151. } from "./unit.js";
  152. export default {
  153. components: {},
  154. data() {
  155. return {
  156. title: "样品列表",
  157. rowIndex: 0,
  158. type: "",
  159. pageName: "",
  160. tableData: [],
  161. handleInput,
  162. qualityResultsListChange,
  163. isCorrelationId: false,
  164. expandedItems: {},
  165. workData: {},
  166. inventoryList: [],
  167. projectId: '',
  168. qualityResultsList: [{
  169. text: "合格",
  170. value: 1,
  171. },
  172. {
  173. text: "不合格",
  174. value: 2,
  175. },
  176. {
  177. text: "让步接收",
  178. value: 3,
  179. },
  180. ],
  181. };
  182. },
  183. onLoad(data) {
  184. if (data.workId) {
  185. this.projectId = data.projectId
  186. this.type = data.type || "";
  187. this.pageName = data.pageName || "";
  188. getById(data.workId).then((res) => {
  189. this.workData = res;
  190. if (data.projectId) {
  191. const qualitySampleList = res.qualitySampleList.filter(
  192. (item) => item.id == data.projectId,
  193. );
  194. if (qualitySampleList[0].correlationId && !['myInspectionProjectEntrusted',
  195. 'myInspectionProjectTask'
  196. ].includes(this.pageName)) {
  197. this.isCorrelationId = true
  198. }else{
  199. qualitySampleList[0].status = 1
  200. }
  201. } else {
  202. this.isCorrelationId = true
  203. res.qualitySampleList.forEach(item => {
  204. if (!item.correlationId || ['myInspectionProjectEntrusted',
  205. 'myInspectionProjectTask'
  206. ].includes(this.pageName)) {
  207. this.isCorrelationId = false
  208. item.status = 1
  209. }
  210. })
  211. }
  212. this.tableData = res.qualitySampleList.map(item => {
  213. if (!item.qualitySampleTemplateList.length && res.templateList.length) {
  214. item.qualitySampleTemplateList = JSON.parse(JSON.stringify(res.templateList))
  215. }
  216. return item
  217. });
  218. });
  219. this.expandedItems = {};
  220. this.getQueryQualityInventory(data.workId)
  221. }
  222. },
  223. methods: {
  224. async getQueryQualityInventory(workId) {
  225. const res = await queryQualityInventory({
  226. qualityWorkerId: workId,
  227. size: -1
  228. });
  229. if (res.list.length > 0) {
  230. this.inventoryList = res.list;
  231. }
  232. },
  233. handleClose() {
  234. uni.navigateBack();
  235. },
  236. handleConfirm() {
  237. this.tableData.forEach((item) => {
  238. if (!this.pageName && item.correlationId) {
  239. return;
  240. }
  241. item.status = 1;
  242. });
  243. const pages = getCurrentPages();
  244. const prevPage = pages[pages.length - 2];
  245. if (prevPage) {
  246. prevPage.$vm.handleConfirm &&
  247. prevPage.$vm.handleConfirm(this.tableData, this.rowIndex);
  248. }
  249. uni.navigateBack();
  250. },
  251. toggleExpand(index) {
  252. this.$set(this.expandedItems, index, !this.expandedItems[index]);
  253. },
  254. setNum() {
  255. let sampleQualifiedNumber = 0; // 样品合格数
  256. let sampleNoQualifiedNumber = 0; // 样品不合格数
  257. let sampleQualificationRate = 0; //样品合格率
  258. let sampleNoQualificationRate = 0; //样品不合格率
  259. let qualifiedNumber = 0; // 合格数
  260. let noQualifiedNumber = 0; // 不合格数
  261. let qualificationRate = 0; // 合格率
  262. let noQualificationRate = 0; //不合格率
  263. this.tableData.forEach(item => {
  264. if (item.qualityResults == 2) {
  265. sampleNoQualifiedNumber += item.measureQuantity
  266. }
  267. })
  268. sampleQualifiedNumber = this.workData.sampleQuantity - sampleNoQualifiedNumber
  269. sampleQualificationRate =
  270. ((sampleQualifiedNumber / this.workData.sampleQuantity) * 100).toFixed(2) || '';
  271. sampleNoQualificationRate =
  272. ((sampleNoQualifiedNumber / this.workData.sampleQuantity) * 100).toFixed(2) || '';
  273. if (this.workData.qualityMode == 2 && this.workData.qualityResults == 2) {
  274. qualifiedNumber = sampleQualifiedNumber
  275. noQualifiedNumber = this.workData.total - sampleQualifiedNumber
  276. } else {
  277. qualifiedNumber = this.workData.total - sampleNoQualifiedNumber
  278. noQualifiedNumber = sampleNoQualifiedNumber
  279. }
  280. qualificationRate =
  281. ((qualifiedNumber / this.workData.total) * 100).toFixed(2) || '';
  282. noQualificationRate =
  283. ((noQualifiedNumber / this.workData.total) * 100).toFixed(2) || '';
  284. this.workData.sampleQualifiedNumber = sampleQualifiedNumber
  285. this.workData.sampleNoQualifiedNumber = sampleNoQualifiedNumber
  286. this.workData.sampleQualificationRate = sampleQualificationRate
  287. this.workData.sampleNoQualificationRate = sampleNoQualificationRate
  288. this.workData.qualifiedNumber = qualifiedNumber
  289. this.workData.noQualifiedNumber = noQualifiedNumber
  290. this.workData.qualificationRate = qualificationRate
  291. this.workData.noQualificationRate = noQualificationRate
  292. // qualityMode
  293. },
  294. /* 保存编辑 */
  295. save() {
  296. this.workData.isUpdate = 1;
  297. this.setNum()
  298. let params = {
  299. ...this.workData,
  300. sampleList: this.tableData,
  301. planTemplateList: this.workData.templateList,
  302. templateList: this.workData.templateList,
  303. qualityInventoryList: this.inventoryList
  304. };
  305. update(params)
  306. .then((msg) => {
  307. uni.$emit('successInit')
  308. this.back()
  309. })
  310. .catch((e) => {});
  311. },
  312. formatQualityResult(value) {
  313. const map = {
  314. 1: "合格",
  315. 2: "不合格",
  316. 3: "让步接收",
  317. };
  318. return map[value] || "";
  319. },
  320. getQualityResultClass(value) {
  321. return {
  322. 1: "result-pass",
  323. 2: "result-fail",
  324. 3: "result-concession",
  325. } [value];
  326. },
  327. },
  328. };
  329. </script>
  330. <style lang="scss" scoped>
  331. .mainBox {
  332. height: 100vh;
  333. display: flex;
  334. flex-direction: column;
  335. background-color: #f3f8fb;
  336. }
  337. .nav-placeholder {
  338. height: calc(var(--status-bar-height, 0px) + 44px);
  339. }
  340. .wrapper {
  341. flex: 1;
  342. display: flex;
  343. flex-direction: column;
  344. overflow: hidden;
  345. }
  346. .scroll-wrapper {
  347. flex: 1;
  348. height: 0;
  349. padding: 20rpx;
  350. .sample-list {
  351. padding-bottom: 20rpx;
  352. .sample-item {
  353. background: #fff;
  354. border-radius: 30rpx;
  355. margin-bottom: 20rpx;
  356. overflow: hidden;
  357. // box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
  358. // border: 1rpx solid #f0f0f0;
  359. .quality-summary {
  360. padding: 24rpx;
  361. background: #fff;
  362. border-top: 1rpx solid #f5f3f3;
  363. display: flex;
  364. align-items: center;
  365. justify-content: space-between;
  366. font-size: 28rpx;
  367. font-weight: bold;
  368. .summary-label {
  369. color: #333;
  370. margin-right: 20rpx;
  371. }
  372. .summary-value {
  373. padding: 8rpx 20rpx;
  374. border-radius: 8rpx;
  375. &.result-pass {
  376. color: #52c41a;
  377. background: #f6ffed;
  378. }
  379. &.result-fail {
  380. color: #ff4d4f;
  381. background: #fff2f0;
  382. }
  383. &.result-concession {
  384. color: #faad14;
  385. background: #fffbe6;
  386. }
  387. }
  388. }
  389. .empty-state {
  390. padding: 100rpx 0;
  391. text-align: center;
  392. font-size: 28rpx;
  393. color: #999;
  394. }
  395. .sample-header {
  396. display: flex;
  397. justify-content: space-between;
  398. align-items: center;
  399. padding: 40rpx 40rpx 20rpx 40rpx;
  400. background: #ffffff;
  401. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
  402. .sample-info {
  403. flex: 1;
  404. }
  405. .info-row {
  406. display: flex;
  407. margin-bottom: 8rpx;
  408. &:last-child {
  409. margin-bottom: 0;
  410. }
  411. .label {
  412. font-size: 28rpx;
  413. color: #333;
  414. font-weight: 800;
  415. margin-right: 10rpx;
  416. min-width: 120rpx;
  417. }
  418. .value {
  419. font-size: 26rpx;
  420. color: #333;
  421. flex: 1;
  422. font-weight: 800;
  423. }
  424. }
  425. .expand-arrow {
  426. font-size: 40rpx;
  427. color: #999;
  428. margin-left: 20rpx;
  429. transform: rotate(0deg);
  430. transition: transform 0.3s;
  431. background: #fff;
  432. width: 48rpx;
  433. height: 48rpx;
  434. border-radius: 50%;
  435. display: flex;
  436. align-items: center;
  437. justify-content: center;
  438. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  439. &.expanded {
  440. transform: rotate(90deg);
  441. }
  442. }
  443. }
  444. .quality-table-wrapper {
  445. // margin: 20rpx;
  446. margin-top: 0;
  447. // border-radius: 12rpx;
  448. overflow: hidden;
  449. // box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  450. }
  451. // 自定义滚动条样式
  452. ::v-deep .quality-table-scroll ::-webkit-scrollbar {
  453. width: 6rpx;
  454. height: 6rpx;
  455. }
  456. ::v-deep .quality-table-scroll ::-webkit-scrollbar-track {
  457. background: #f1f1f1;
  458. border-radius: 3rpx;
  459. }
  460. ::v-deep .quality-table-scroll ::-webkit-scrollbar-thumb {
  461. background: #c1c1c1;
  462. border-radius: 3rpx;
  463. }
  464. ::v-deep .quality-table-scroll ::-webkit-scrollbar-thumb:hover {
  465. background: #a8a8a8;
  466. }
  467. ::v-deep .table-cell:last-child::-webkit-scrollbar {
  468. width: 4rpx;
  469. }
  470. ::v-deep .table-cell:last-child::-webkit-scrollbar-track {
  471. background: #f9f9f9;
  472. border-radius: 2rpx;
  473. }
  474. ::v-deep .table-cell:last-child::-webkit-scrollbar-thumb {
  475. background: #d9d9d9;
  476. border-radius: 2rpx;
  477. }
  478. .quality-table-scroll {
  479. width: 100%;
  480. }
  481. .quality-table {
  482. min-width: 100%;
  483. width: 1540rpx;
  484. background: #fff;
  485. }
  486. .table-header {
  487. display: flex;
  488. background: #f5f5f5;
  489. border-bottom: 2rpx solid #e5e5e5;
  490. .table-cell {
  491. padding: 24rpx 12rpx;
  492. font-size: 26rpx;
  493. font-weight: bold;
  494. color: #333;
  495. text-align: center;
  496. border-right: 1rpx solid #e5e5e5;
  497. white-space: nowrap;
  498. flex-shrink: 0;
  499. display: flex;
  500. align-items: center;
  501. justify-content: center;
  502. background: #f5f5f5;
  503. width: 200rpx;
  504. &:last-child {
  505. border-right: none;
  506. background: #f5f5f5;
  507. }
  508. &:nth-child(2) {
  509. width: 260rpx;
  510. }
  511. &:nth-child(3) {
  512. width: 220rpx;
  513. }
  514. &:nth-child(7) {
  515. width: 260rpx;
  516. }
  517. }
  518. }
  519. .table-body {
  520. .table-row {
  521. display: flex;
  522. border-bottom: 1rpx solid #e5e5e5;
  523. transition: background 0.2s;
  524. &:nth-child(even) {
  525. // background: #fafafa;
  526. }
  527. &:last-child {
  528. border-bottom: none;
  529. }
  530. .table-cell {
  531. padding: 20rpx 12rpx;
  532. font-size: 24rpx;
  533. // color: #666;
  534. text-align: center;
  535. border-right: 1rpx solid #e5e5e5;
  536. white-space: nowrap;
  537. flex-shrink: 0;
  538. display: flex;
  539. align-items: center;
  540. justify-content: center;
  541. width: 200rpx;
  542. &:last-child {
  543. border-right: none;
  544. // background: #f5f5f5;
  545. }
  546. &:nth-child(2) {
  547. width: 260rpx;
  548. }
  549. &:nth-child(3) {
  550. width: 220rpx;
  551. }
  552. &:nth-child(7) {
  553. width: 260rpx !important;
  554. }
  555. .cell-text {
  556. overflow: hidden;
  557. text-overflow: ellipsis;
  558. white-space: nowrap;
  559. max-width: 100%;
  560. &.warn {
  561. color: #ff4d4f;
  562. }
  563. }
  564. .unit {
  565. font-size: 22rpx;
  566. color: #999;
  567. margin-left: 6rpx;
  568. }
  569. &.parameter-cell {
  570. max-height: 120rpx;
  571. overflow-y: auto;
  572. align-items: flex-start;
  573. padding: 16rpx 12rpx;
  574. width: 200rpx;
  575. }
  576. }
  577. }
  578. }
  579. }
  580. }
  581. }
  582. .footerButton {
  583. width: 100%;
  584. height: 84rpx;
  585. display: flex;
  586. position: fixed;
  587. bottom: 0;
  588. z-index: 10;
  589. background-color: #fff;
  590. /deep/.u-button {
  591. height: 100%;
  592. }
  593. >view {
  594. flex: 1;
  595. }
  596. }
  597. .warn {
  598. color: #ff4d4f !important;
  599. }
  600. /deep/.text-color {
  601. font-size: 28rpx;
  602. }
  603. </style>