list.vue 19 KB

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