list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  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: 460rpx"
  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
  148. class="text btnlist"
  149. v-if="
  150. ![2].includes(item.status) && pageName && pageName != 'myList'
  151. "
  152. >
  153. 操作:
  154. <view style="display: flex">
  155. <u-button
  156. style="margin-left: 5px"
  157. v-if="item.recordingMethod != 1"
  158. type="primary"
  159. text="批量质检"
  160. @click="goTo(item.id, '', item.sampleMeasureUnit, item, {})"
  161. >
  162. </u-button>
  163. </view>
  164. </view> -->
  165. </view>
  166. </view>
  167. <view style="width: 100%; height: 40rpx"></view>
  168. <view style="margin-top: 20vh" v-if="tableList.length == 0">
  169. <u-empty iconSize="150" textSize="32" text="暂无数据"> </u-empty>
  170. </view>
  171. </u-list>
  172. </view>
  173. <u-toast ref="uToast"></u-toast>
  174. <addSample ref="addSampleRef" @reload="doSearch"></addSample>
  175. </view>
  176. </template>
  177. <script>
  178. import dictMixns from "@/mixins/dictMixins";
  179. import addSample from "./addSample.vue";
  180. import {
  181. getList,
  182. getRequestentrustList,
  183. sampleCollection,
  184. getTaskmonadList,
  185. verificationQualityInspector,
  186. checkByQualityWorkOrderId,
  187. } from "@/api/inspectionWork/index.js";
  188. export default {
  189. components: {
  190. addSample,
  191. },
  192. mixins: [dictMixns],
  193. props: {
  194. pageName: {
  195. default: "",
  196. },
  197. way: {
  198. default: "route",
  199. },
  200. produceFilter: {
  201. type: Object,
  202. default: () => ({}),
  203. },
  204. },
  205. data() {
  206. return {
  207. statusList: [
  208. {
  209. value: 0,
  210. label: "未报工",
  211. },
  212. {
  213. value: 1,
  214. label: "已报工",
  215. },
  216. {
  217. value: 2,
  218. label: "已关闭",
  219. },
  220. {
  221. value: 3,
  222. label: "待请样",
  223. },
  224. ],
  225. statusList1: [
  226. {
  227. value: 1,
  228. label: "未报工",
  229. },
  230. {
  231. value: 2,
  232. label: "已报工",
  233. },
  234. ],
  235. tableList: [],
  236. page: 1,
  237. size: 10,
  238. isEnd: false,
  239. keyWord: "",
  240. userInfo: {},
  241. };
  242. },
  243. computed: {},
  244. created() {
  245. this.requestDict("质检计划类型");
  246. },
  247. onLoad() {},
  248. methods: {
  249. buildQueryData(baseData = {}) {
  250. const data = {
  251. ...baseData,
  252. };
  253. if (this.produceFilter && this.produceFilter.produceSourceTaskId) {
  254. data.produceSourceTaskId = this.produceFilter.produceSourceTaskId;
  255. }
  256. if (this.produceFilter && this.produceFilter.workOrderCode) {
  257. data.workOrderCodeList = [this.produceFilter.workOrderCode];
  258. }
  259. return data;
  260. },
  261. successInit() {
  262. uni.showLoading({
  263. title: "加载中",
  264. });
  265. let data = this.buildQueryData({
  266. pageNum: 1,
  267. size: this.tableList.length,
  268. keyWord: this.keyWord,
  269. // recordingMethod: 1,
  270. });
  271. if (this.pageName) {
  272. data.currentLoginUserId = this.userInfo.userId;
  273. }
  274. if (this.pageName == "myInspectionProjectEntrusted") {
  275. data.approvalStatus = 2;
  276. }
  277. if (this.way == "todo") {
  278. data.status = 0;
  279. }
  280. if (this.way == "done") {
  281. data.status = 1;
  282. }
  283. let api =
  284. this.pageName == "myInspectionProjectTask"
  285. ? getTaskmonadList
  286. : this.pageName == "myInspectionProjectEntrusted"
  287. ? getRequestentrustList
  288. : getList;
  289. api(data)
  290. .then((res) => {
  291. this.tableList = res.list;
  292. })
  293. .then(() => {
  294. uni.hideLoading();
  295. });
  296. },
  297. doSearch() {
  298. this.isEnd = false;
  299. this.page = 1;
  300. this.getList();
  301. },
  302. //获取列表信息
  303. getList() {
  304. this.userInfo = uni.getStorageSync("userInfo");
  305. if (this.isEnd || !this.userInfo.userId) {
  306. return;
  307. }
  308. uni.showLoading({
  309. title: "加载中",
  310. });
  311. let data = this.buildQueryData({
  312. pageNum: this.page,
  313. size: this.size,
  314. keyWord: this.keyWord,
  315. // recordingMethod: 1,
  316. });
  317. if (this.pageName) {
  318. data.currentLoginUserId = this.userInfo.userId;
  319. }
  320. if (this.pageName == "myInspectionProjectEntrusted") {
  321. data.approvalStatus = 2;
  322. }
  323. if (this.way == "todo") {
  324. data.status = 0;
  325. }
  326. if (this.way == "done") {
  327. data.status = 1;
  328. }
  329. let api =
  330. this.pageName == "myInspectionProjectTask"
  331. ? getTaskmonadList
  332. : this.pageName == "myInspectionProjectEntrusted"
  333. ? getRequestentrustList
  334. : getList;
  335. api(data)
  336. .then((res) => {
  337. if (this.page === 1) {
  338. this.tableList = res.list;
  339. } else {
  340. this.tableList.push(...res.list);
  341. }
  342. this.page += 1;
  343. this.isEnd = this.tableList.length >= res.count;
  344. })
  345. .then(() => {
  346. uni.hideLoading();
  347. });
  348. },
  349. async sampleCollection(row) {
  350. if (!this.pageName) {
  351. const code = await verificationQualityInspector(row.id);
  352. if (code == "-1") {
  353. return;
  354. }
  355. }
  356. sampleCollection({
  357. id: row.id,
  358. }).then((res) => {
  359. this.$refs.uToast.show({
  360. type: "success",
  361. icon: false,
  362. message: "收样成功",
  363. });
  364. this.doSearch();
  365. });
  366. },
  367. goTo(workId, projectId, sampleMeasureUnit, item, row) {
  368. if (this.pageName == "myList" || !this.pageName) {
  369. if (item.isPendingSample == 1 && row.status != 1) {
  370. this.$refs.uToast.show({
  371. type: "error",
  372. icon: false,
  373. message: "请先完成收样!",
  374. });
  375. return;
  376. }
  377. if (item.status == 3) {
  378. this.$refs.uToast.show({
  379. type: "error",
  380. icon: false,
  381. message: "请先完成请样!",
  382. });
  383. return;
  384. }
  385. }
  386. if (item.recordingMethod == 1) {
  387. uni.navigateTo({
  388. url:
  389. "/pages/qms/inspectionWork/inspectionProjectReport?workId=" +
  390. workId +
  391. "&projectId=" +
  392. projectId +
  393. "&pageName=" +
  394. this.pageName +
  395. "&sampleMeasureUnit=" +
  396. sampleMeasureUnit,
  397. });
  398. } else {
  399. uni.navigateTo({
  400. url:
  401. "/pages/qms/inspectionWork/sampleList?workId=" +
  402. workId +
  403. "&projectId=" +
  404. projectId +
  405. "&pageName=" +
  406. this.pageName,
  407. });
  408. }
  409. },
  410. async addSampleOpen(row) {
  411. const code = await verificationQualityInspector(row.id);
  412. if (code == "-1") {
  413. return;
  414. }
  415. const is = await checkByQualityWorkOrderId(row.id);
  416. if (is) {
  417. this.$refs.uToast.show({
  418. type: "error",
  419. icon: false,
  420. message: "此工单存在未处理完的请样记录,请检查!",
  421. });
  422. return;
  423. }
  424. this.$refs.addSampleRef.open("add", row);
  425. },
  426. scrolltolower() {
  427. if (this.isEnd) {
  428. return;
  429. }
  430. this.getList();
  431. },
  432. },
  433. };
  434. </script>
  435. <style lang="scss" scoped>
  436. .mainBox {
  437. background-color: #f3f8fb;
  438. }
  439. // .wrapper{
  440. // }
  441. .top-wrapper {
  442. background-color: #fff;
  443. display: flex;
  444. width: 750rpx;
  445. height: 88rpx;
  446. padding: 16rpx 32rpx;
  447. align-items: center;
  448. // gap: 16rpx;
  449. position: absolute;
  450. z-index: 999;
  451. // top: 44px;
  452. // // #ifdef APP-PLUS
  453. // top: 140rpx;
  454. // // #endif
  455. /deep/.uni-section {
  456. margin-top: 0px;
  457. }
  458. /deep/.uni-section-header {
  459. padding: 0px;
  460. }
  461. .search_btn {
  462. width: 120rpx;
  463. height: 70rpx;
  464. line-height: 70rpx;
  465. padding: 0 24rpx;
  466. background: $theme-color;
  467. font-size: 32rpx;
  468. color: #fff;
  469. margin: 0;
  470. margin-left: 26rpx;
  471. }
  472. .menu_icon {
  473. width: 44rpx;
  474. height: 44rpx;
  475. margin-left: 14rpx;
  476. }
  477. }
  478. .item {
  479. width: 720rpx;
  480. // height:400rpx;
  481. margin: 20rpx auto 0;
  482. padding: 26rpx;
  483. border-radius: 30rpx;
  484. .text {
  485. margin-top: 20rpx;
  486. }
  487. background: #fff;
  488. }
  489. .item_value {
  490. width: 100%;
  491. display: flex;
  492. flex-wrap: wrap;
  493. margin-left: -10rpx;
  494. > view {
  495. font-size: 24rpx;
  496. color: #fff;
  497. padding: 12rpx;
  498. border-radius: 10rpx;
  499. background: #979797;
  500. margin-left: 10rpx;
  501. margin-top: 20rpx;
  502. }
  503. }
  504. .herder_item {
  505. display: flex;
  506. // align-items: center;
  507. font-size: 28rpx;
  508. font-weight: bold;
  509. .herder_view {
  510. width: calc(100% - 20rpx);
  511. word-break: break-all;
  512. }
  513. .herder_text {
  514. min-width: 10rpx;
  515. height: 32rpx;
  516. border-radius: 10rpx;
  517. background: #00c0a1;
  518. margin-right: 12rpx;
  519. margin-top: 5rpx;
  520. }
  521. }
  522. .btnlist {
  523. display: flex;
  524. align-items: center;
  525. }
  526. /deep/.u-button {
  527. height: 60rpx;
  528. width: auto;
  529. }
  530. </style>