sampleList.vue 18 KB

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