list.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar
  4. v-if="way != 'todo' && way != 'done'"
  5. fixed="true"
  6. statusBar="true"
  7. left-icon="back"
  8. :title="
  9. pageName == 'myList'
  10. ? '我的质检工单'
  11. : pageName == 'myInspectionProjectTask'
  12. ? '我的质检任务单'
  13. : pageName == 'myInspectionProjectEntrusted'
  14. ? '我的质检受托单'
  15. : '质检工单'
  16. "
  17. @clickLeft="back"
  18. >
  19. </uni-nav-bar>
  20. <view class="top-wrapper">
  21. <uni-section>
  22. <uni-easyinput
  23. prefixIcon="search"
  24. style="width: 100%"
  25. v-model="keyWord"
  26. placeholder="名称、批次号、工单编码"
  27. >
  28. </uni-easyinput>
  29. </uni-section>
  30. <button class="search_btn" @click="doSearch">搜索</button>
  31. </view>
  32. <div style="height: 100rpx; width: 475rpx"></div>
  33. <view class="wrapper">
  34. <u-list @scrolltolower="scrolltolower" class="listContent">
  35. <view
  36. v-for="(item, index) in tableList"
  37. :key="index + item.id"
  38. style="position: relative"
  39. >
  40. <view class="item">
  41. <view class="herder_item">
  42. <view class="herder_text"></view>
  43. <view class="herder_view">
  44. {{ getDictValue("质检计划类型", item.qualityType + "") }}/{{
  45. item.code
  46. }}/{{ item.productCode }}/{{ item.productName }}
  47. <text v-if="!pageName || pageName == 'myList'">
  48. ({{
  49. item.isPendingSample == 1
  50. ? "待收样"
  51. : statusList.find((row) => row.value == item.status)
  52. .label
  53. }})
  54. </text>
  55. <text v-else>
  56. ({{
  57. statusList1.find((row) => row.value == item.status).label
  58. }})
  59. </text>
  60. <text>
  61. ({{ item.recordingMethod == 1 ? "按质检项检" : "按样品检" }})
  62. </text>
  63. <text v-if="item.productLineName">
  64. {{ item.productLineName }}
  65. </text>
  66. </view>
  67. </view>
  68. <view class="text">检验项目:</view>
  69. <view class="item_value" v-if="item.recordingMethod == 1">
  70. <view
  71. @click="
  72. goTo(item.id, row.id, item.sampleMeasureUnit, item, row)
  73. "
  74. v-for="(row, _index) in item.templateList"
  75. :key="item.inspectionName + index + '_' + _index"
  76. :style="{
  77. background:
  78. row.status == 1
  79. ? '#19be6b'
  80. : row.status == 2
  81. ? '#ff9900'
  82. : row.status == 3
  83. ? '#ff9900'
  84. : '#909399',
  85. }"
  86. >
  87. {{ row.inspectionName }}
  88. </view>
  89. </view>
  90. <view class="item_value" v-else>
  91. <view
  92. @click="
  93. goTo(item.id, row.id, item.sampleMeasureUnit, item, row)
  94. "
  95. v-for="(row, _index) in item.qualitySampleList"
  96. :key="item.sampleCode + index + '_' + _index"
  97. :style="{
  98. background:
  99. row.status == 1
  100. ? '#19be6b'
  101. : row.status == 2
  102. ? '#ff9900'
  103. : row.status == 3
  104. ? '#ff9900'
  105. : '#909399',
  106. }"
  107. >
  108. {{ row.sampleCode }}
  109. </view>
  110. </view>
  111. <view
  112. class="text btnlist"
  113. v-if="
  114. ![1, 2].includes(item.status) &&
  115. (pageName == 'myList' || !pageName)
  116. "
  117. >
  118. 操作:
  119. <view style="display: flex">
  120. <u-button
  121. v-if="item.isPendingSample == 1"
  122. type="primary"
  123. text="收样"
  124. @click="sampleCollection(item)"
  125. ></u-button>
  126. <u-button
  127. style="margin-left: 5px"
  128. v-if="
  129. item.sampleQuantity < item.total &&
  130. item.isPendingSample != 1 &&
  131. (pageName == 'myList' || !pageName)
  132. "
  133. type="primary"
  134. text="请样"
  135. @click="addSampleOpen(item)"
  136. ></u-button>
  137. <u-button
  138. style="margin-left: 5px"
  139. v-if="item.recordingMethod != 1"
  140. type="primary"
  141. text="批量质检"
  142. @click="goTo(item.id, '', item.sampleMeasureUnit, item, {})"
  143. >
  144. </u-button>
  145. </view>
  146. </view>
  147. <view class="text btnlist" v-if="isReportReady(item)">
  148. <text>质检报告:</text>
  149. <view style="display: flex">
  150. <uni-data-picker
  151. v-if="!hasReport(item)"
  152. :localdata="templateOptions"
  153. placeholder="生成质检报告"
  154. popup-title="选择报告模板"
  155. @change="onTemplateChange($event, item)"
  156. ></uni-data-picker>
  157. <u-button
  158. v-if="
  159. Object.keys(item.reportTemplateJson).length &&
  160. (!item.reportApprovalStatus ||
  161. item.reportApprovalStatus == 3)
  162. "
  163. type="primary"
  164. text="质检报告审批"
  165. @click="listSubmit(item)"
  166. ></u-button>
  167. <u-button
  168. v-if="
  169. Object.keys(item.reportTemplateJson).length &&
  170. item.reportApprovalStatus
  171. "
  172. type="primary"
  173. text="查看质检报告"
  174. @click="viewReport(item)"
  175. ></u-button>
  176. </view>
  177. </view>
  178. <!-- <view
  179. class="text btnlist"
  180. v-if="
  181. ![2].includes(item.status) && pageName && pageName != 'myList'
  182. "
  183. >
  184. 操作:
  185. <view style="display: flex">
  186. <u-button
  187. style="margin-left: 5px"
  188. v-if="item.recordingMethod != 1"
  189. type="primary"
  190. text="批量质检"
  191. @click="goTo(item.id, '', item.sampleMeasureUnit, item, {})"
  192. >
  193. </u-button>
  194. </view>
  195. </view> -->
  196. </view>
  197. </view>
  198. <view style="width: 100%; height: 40rpx"></view>
  199. <view style="margin-top: 20vh" v-if="tableList.length == 0">
  200. <u-empty iconSize="150" textSize="32" text="暂无数据"> </u-empty>
  201. </view>
  202. </u-list>
  203. </view>
  204. <u-toast ref="uToast"></u-toast>
  205. <addSample ref="addSampleRef" @reload="doSearch"></addSample>
  206. </view>
  207. </template>
  208. <script>
  209. import dictMixns from "@/mixins/dictMixins";
  210. import addSample from "./addSample.vue";
  211. import {
  212. getList,
  213. getRequestentrustList,
  214. sampleCollection,
  215. getTaskmonadList,
  216. verificationQualityInspector,
  217. checkByQualityWorkOrderId,
  218. } from "@/api/inspectionWork/index.js";
  219. import {
  220. processInstanceCreateAPI,
  221. processInstancePage
  222. } from '@/api/wt/index.js'
  223. import { getQmsReportTemplatePageList } from "@/api/inspectionReport/index.js";
  224. export default {
  225. components: {
  226. addSample,
  227. },
  228. mixins: [dictMixns],
  229. props: {
  230. pageName: {
  231. default: "",
  232. },
  233. way: {
  234. default: "route",
  235. },
  236. produceFilter: {
  237. type: Object,
  238. default: () => ({}),
  239. },
  240. },
  241. data() {
  242. return {
  243. statusList: [
  244. {
  245. value: 0,
  246. label: "未报工",
  247. },
  248. {
  249. value: 1,
  250. label: "已报工",
  251. },
  252. {
  253. value: 2,
  254. label: "已关闭",
  255. },
  256. {
  257. value: 3,
  258. label: "待请样",
  259. },
  260. ],
  261. statusList1: [
  262. {
  263. value: 1,
  264. label: "未报工",
  265. },
  266. {
  267. value: 2,
  268. label: "已报工",
  269. },
  270. ],
  271. tableList: [],
  272. page: 1,
  273. size: 10,
  274. isEnd: false,
  275. keyWord: "",
  276. userInfo: {},
  277. reportTemplateList: [],
  278. };
  279. },
  280. computed: {
  281. templateOptions() {
  282. return (this.reportTemplateList || []).map((t) => ({
  283. text:
  284. (t.name || "") +
  285. "(" +
  286. (t.versionSymbol ?? "") +
  287. (t.bigVersion ?? "") +
  288. (t.versionMark ?? "") +
  289. (t.smallVersion ?? "") +
  290. ")",
  291. value: t.code,
  292. }));
  293. },
  294. },
  295. created() {
  296. this.requestDict("质检计划类型");
  297. this.getReportTemplateList();
  298. },
  299. onLoad() {},
  300. methods: {
  301. buildQueryData(baseData = {}) {
  302. const data = {
  303. ...baseData,
  304. };
  305. if (this.produceFilter && this.produceFilter.produceSourceTaskId) {
  306. data.produceSourceTaskId = this.produceFilter.produceSourceTaskId;
  307. }
  308. if (this.produceFilter && this.produceFilter.workOrderCode) {
  309. data.workOrderCodeList = [this.produceFilter.workOrderCode];
  310. }
  311. return data;
  312. },
  313. async listSubmit(item) {
  314. try {
  315. //后台不提供接口
  316. let list = await processInstancePage({
  317. pageNo: 1,
  318. pageSize: 1,
  319. reset: true,
  320. key: "qms_report_approval",
  321. });
  322. let params = {
  323. businessId: item.id,
  324. businessKey: "qms_report_approval",
  325. formCreateUserId: item.createUserId,
  326. processDefinitionId: list?.list[0]?.processDefinition.id,
  327. variables: {
  328. businessCode: item.code,
  329. businessName: item.name,
  330. businessType: "检测报告单",
  331. },
  332. };
  333. await processInstanceCreateAPI(params);
  334. uni.showModal({
  335. title: `提交成功`,
  336. content: "",
  337. confirmText: "确认",
  338. showCancel: false, // 是否显示取消按钮,默认为 true
  339. success: () => {
  340. this.successInit();
  341. },
  342. });
  343. } catch {}
  344. },
  345. successInit() {
  346. uni.showLoading({
  347. title: "加载中",
  348. });
  349. let data = this.buildQueryData({
  350. pageNum: 1,
  351. size: this.tableList.length,
  352. keyWord: this.keyWord,
  353. // recordingMethod: 1,
  354. });
  355. if (this.pageName) {
  356. data.currentLoginUserId = this.userInfo.userId;
  357. }
  358. if (this.pageName == "myInspectionProjectEntrusted") {
  359. data.approvalStatus = 2;
  360. }
  361. if (this.way == "todo") {
  362. data.status = 0;
  363. }
  364. if (this.way == "done") {
  365. data.status = 1;
  366. }
  367. let api =
  368. this.pageName == "myInspectionProjectTask"
  369. ? getTaskmonadList
  370. : this.pageName == "myInspectionProjectEntrusted"
  371. ? getRequestentrustList
  372. : getList;
  373. api(data)
  374. .then((res) => {
  375. this.tableList = res.list;
  376. })
  377. .then(() => {
  378. uni.hideLoading();
  379. });
  380. },
  381. doSearch() {
  382. this.isEnd = false;
  383. this.page = 1;
  384. this.getList();
  385. },
  386. getReportTemplateList() {
  387. getQmsReportTemplatePageList({
  388. pageNum: 1,
  389. pageSize: 999,
  390. isEnabled: 1,
  391. type: 0,
  392. })
  393. .then((res) => {
  394. this.reportTemplateList = res.list || [];
  395. })
  396. .catch(() => {});
  397. },
  398. isReportReady(item) {
  399. if (
  400. this.pageName == "myInspectionProjectTask" ||
  401. this.pageName == "myInspectionProjectEntrusted"
  402. ) {
  403. return item.status == 2;
  404. }
  405. return item.status == 1;
  406. },
  407. hasReport(item) {
  408. return !!(
  409. item.reportApprovalStatus ||
  410. (item.reportTemplateJson && Object.keys(item.reportTemplateJson).length)
  411. );
  412. },
  413. onTemplateChange(e, item) {
  414. const arr = (e && e.detail && e.detail.value) || [];
  415. const node = arr[arr.length - 1];
  416. if (!node || !node.value) {
  417. return;
  418. }
  419. const tpl = this.reportTemplateList.find(
  420. (t) => String(t.code) == String(node.value),
  421. );
  422. if (tpl && item && item.id) {
  423. this.selectReportTemplate(item, tpl);
  424. }
  425. },
  426. selectReportTemplate(item, template) {
  427. if (!item || !item.id) {
  428. return;
  429. }
  430. const row = {
  431. ...item,
  432. workOrderId: item.id,
  433. type: item.type || 0,
  434. reportTemplateJson: item.reportTemplateJson || {},
  435. reportApprovalTaskVos: item.reportApprovalTaskVos || [],
  436. };
  437. uni.setStorageSync("inspectionReportRow", row);
  438. uni.navigateTo({
  439. url:
  440. "/pages/qms/inspectionReport/detail?id=" +
  441. item.id +
  442. "&edit=1&templateCode=" +
  443. encodeURIComponent(template.code || ""),
  444. });
  445. },
  446. viewReport(item) {
  447. const row = {
  448. ...item,
  449. workOrderId: item.id,
  450. type: item.type || 0,
  451. reportTemplateJson: item.reportTemplateJson || {},
  452. reportApprovalTaskVos: item.reportApprovalTaskVos || [],
  453. };
  454. uni.setStorageSync("inspectionReportRow", row);
  455. uni.navigateTo({
  456. url:
  457. "/pages/qms/inspectionReport/detail?id=" +
  458. item.id +
  459. "&templateCode=" +
  460. encodeURIComponent(item.reportTemplateCode || ""),
  461. });
  462. },
  463. //获取列表信息
  464. getList() {
  465. this.userInfo = uni.getStorageSync("userInfo");
  466. if (this.isEnd || !this.userInfo.userId) {
  467. return;
  468. }
  469. uni.showLoading({
  470. title: "加载中",
  471. });
  472. let data = this.buildQueryData({
  473. pageNum: this.page,
  474. size: this.size,
  475. keyWord: this.keyWord,
  476. // recordingMethod: 1,
  477. });
  478. if (this.pageName) {
  479. data.currentLoginUserId = this.userInfo.userId;
  480. }
  481. if (this.pageName == "myInspectionProjectEntrusted") {
  482. data.approvalStatus = 2;
  483. }
  484. if (this.way == "todo") {
  485. data.status = 0;
  486. }
  487. if (this.way == "done") {
  488. data.status = 1;
  489. }
  490. let api =
  491. this.pageName == "myInspectionProjectTask"
  492. ? getTaskmonadList
  493. : this.pageName == "myInspectionProjectEntrusted"
  494. ? getRequestentrustList
  495. : getList;
  496. api(data)
  497. .then((res) => {
  498. if (this.page === 1) {
  499. this.tableList = res.list;
  500. } else {
  501. this.tableList.push(...res.list);
  502. }
  503. this.page += 1;
  504. this.isEnd = this.tableList.length >= res.count;
  505. })
  506. .then(() => {
  507. uni.hideLoading();
  508. });
  509. },
  510. async sampleCollection(row) {
  511. if (!this.pageName) {
  512. const code = await verificationQualityInspector(row.id);
  513. if (code == "-1") {
  514. return;
  515. }
  516. }
  517. sampleCollection({
  518. id: row.id,
  519. }).then((res) => {
  520. this.$refs.uToast.show({
  521. type: "success",
  522. icon: false,
  523. message: "收样成功",
  524. });
  525. this.doSearch();
  526. });
  527. },
  528. goTo(workId, projectId, sampleMeasureUnit, item, row) {
  529. if (this.pageName == "myList" || !this.pageName) {
  530. if (item.isPendingSample == 1 && row.status != 1) {
  531. this.$refs.uToast.show({
  532. type: "error",
  533. icon: false,
  534. message: "请先完成收样!",
  535. });
  536. return;
  537. }
  538. if (item.status == 3) {
  539. this.$refs.uToast.show({
  540. type: "error",
  541. icon: false,
  542. message: "请先完成请样!",
  543. });
  544. return;
  545. }
  546. }
  547. if (item.recordingMethod == 1) {
  548. uni.navigateTo({
  549. url:
  550. "/pages/qms/inspectionWork/inspectionProjectReport?workId=" +
  551. workId +
  552. "&projectId=" +
  553. projectId +
  554. "&pageName=" +
  555. this.pageName +
  556. "&sampleMeasureUnit=" +
  557. sampleMeasureUnit,
  558. });
  559. } else {
  560. uni.navigateTo({
  561. url:
  562. "/pages/qms/inspectionWork/sampleList?workId=" +
  563. workId +
  564. "&projectId=" +
  565. projectId +
  566. "&pageName=" +
  567. this.pageName,
  568. });
  569. }
  570. },
  571. async addSampleOpen(row) {
  572. const code = await verificationQualityInspector(row.id);
  573. if (code == "-1") {
  574. return;
  575. }
  576. const is = await checkByQualityWorkOrderId(row.id);
  577. if (is) {
  578. this.$refs.uToast.show({
  579. type: "error",
  580. icon: false,
  581. message: "此工单存在未处理完的请样记录,请检查!",
  582. });
  583. return;
  584. }
  585. this.$refs.addSampleRef.open("add", row);
  586. },
  587. scrolltolower() {
  588. if (this.isEnd) {
  589. return;
  590. }
  591. this.getList();
  592. },
  593. },
  594. };
  595. </script>
  596. <style lang="scss" scoped>
  597. .mainBox {
  598. background-color: #f3f8fb;
  599. }
  600. // .wrapper{
  601. // }
  602. .top-wrapper {
  603. background-color: #fff;
  604. display: flex;
  605. width: 750rpx;
  606. height: 88rpx;
  607. padding: 16rpx 32rpx;
  608. align-items: center;
  609. // gap: 16rpx;
  610. position: absolute;
  611. z-index: 999;
  612. // top: 44px;
  613. // // #ifdef APP-PLUS
  614. // top: 140rpx;
  615. // // #endif
  616. /deep/.uni-section {
  617. margin-top: 0px;
  618. }
  619. /deep/.uni-section-header {
  620. padding: 0px;
  621. }
  622. .search_btn {
  623. width: 120rpx;
  624. height: 70rpx;
  625. line-height: 70rpx;
  626. padding: 0 24rpx;
  627. background: $theme-color;
  628. font-size: 32rpx;
  629. color: #fff;
  630. margin: 0;
  631. margin-left: 26rpx;
  632. }
  633. .menu_icon {
  634. width: 44rpx;
  635. height: 44rpx;
  636. margin-left: 14rpx;
  637. }
  638. }
  639. .item {
  640. width: 720rpx;
  641. // height:400rpx;
  642. margin: 20rpx auto 0;
  643. padding: 26rpx;
  644. border-radius: 30rpx;
  645. .text {
  646. margin-top: 20rpx;
  647. }
  648. background: #fff;
  649. }
  650. .item_value {
  651. width: 100%;
  652. display: flex;
  653. flex-wrap: wrap;
  654. margin-left: -10rpx;
  655. > view {
  656. font-size: 24rpx;
  657. color: #fff;
  658. padding: 12rpx;
  659. border-radius: 10rpx;
  660. background: #979797;
  661. margin-left: 10rpx;
  662. margin-top: 20rpx;
  663. }
  664. }
  665. .herder_item {
  666. display: flex;
  667. // align-items: center;
  668. font-size: 28rpx;
  669. font-weight: bold;
  670. .herder_view {
  671. width: calc(100% - 20rpx);
  672. word-break: break-all;
  673. }
  674. .herder_text {
  675. min-width: 10rpx;
  676. height: 32rpx;
  677. border-radius: 10rpx;
  678. background: #00c0a1;
  679. margin-right: 12rpx;
  680. margin-top: 5rpx;
  681. }
  682. }
  683. .btnlist {
  684. display: flex;
  685. align-items: center;
  686. }
  687. /deep/.u-button {
  688. height: 60rpx;
  689. width: auto;
  690. }
  691. </style>