inspectionProjectReport.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975
  1. <!-- 用户编辑弹窗 -->
  2. <template>
  3. <ele-modal
  4. :title="title + (type == 'detail' ? '详情' : '报工')"
  5. :visible.sync="visible"
  6. :before-close="handleClose"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. width="80%"
  11. resizable
  12. :maxable="true"
  13. >
  14. <ele-pro-table
  15. :needPage="false"
  16. :columns="workColumns"
  17. :datasource="[form]"
  18. >
  19. <template v-slot:toolbar>
  20. 样品总数:{{ form.workSampleCount }}{{ form.measureUnit }}
  21. </template>
  22. <template v-slot:craftFiles="{ row }">
  23. <el-link type="primary" :underline="false" @click="craftFiles(row)"
  24. >工艺文件</el-link
  25. >
  26. </template>
  27. <template v-slot:isRequired="{ column }">
  28. <span class="is-required">{{ column.label }}</span>
  29. </template>
  30. <template v-slot:qualityType="{ row }">
  31. {{ getDictValue('质检计划类型', row.qualityType) }}
  32. </template>
  33. <template v-slot:qualityMode="{ row }">
  34. {{ getDictValue('取样类型', row.qualityMode) }}
  35. </template>
  36. <template v-slot:hours="{ row }">
  37. <el-input
  38. v-model="row.hours"
  39. placeholder="请输入"
  40. type="number"
  41. :disabled="type == 'detail'"
  42. >
  43. </el-input>
  44. </template>
  45. <template v-slot:accessory="{ row }">
  46. <fileMain v-model="row.accessory" type="view"></fileMain>
  47. </template>
  48. <template v-slot:sampleQuantity="{ row }">
  49. <el-input
  50. v-model="row.sampleQuantity"
  51. placeholder="请输入"
  52. type="number"
  53. @input="formSampleQuantityChange"
  54. :disabled="type == 'detail'"
  55. >
  56. <template slot="append">{{ form.measureUnit }}</template>
  57. </el-input>
  58. </template>
  59. <template v-slot:sampleNoQualifiedNumber="{ row }">
  60. <el-input
  61. v-model="row.sampleNoQualifiedNumber"
  62. @input="formSampleNoQualifiedNumberChange"
  63. placeholder="请输入"
  64. type="number"
  65. :disabled="type == 'detail'"
  66. >
  67. <template slot="append">{{ form.measureUnit }}</template>
  68. </el-input>
  69. </template>
  70. </ele-pro-table>
  71. <ele-pro-table
  72. :needPage="false"
  73. :columns="tableColumns"
  74. :datasource="tableData"
  75. >
  76. <template v-slot:toolbar>
  77. <div
  78. style="
  79. display: flex;
  80. justify-content: space-between;
  81. align-items: center;
  82. "
  83. >
  84. <span>
  85. 当前检测剩余样品数:{{ form.sampleQuantity
  86. }}{{ form.measureUnit }}</span
  87. >
  88. <el-button
  89. type="primary"
  90. v-if="type != 'detail'"
  91. @click="handleOneKeyQualified"
  92. style="margin-right: 10px"
  93. >
  94. 一键合格
  95. </el-button>
  96. </div>
  97. </template>
  98. <template v-slot:qualityStandardType="{ row }">
  99. {{ getDictValue('质检标准类型', row.qualityStandardType) }}
  100. </template>
  101. <template v-slot:executionMethod="{ row }">
  102. <el-select
  103. v-model="row.executionMethod"
  104. style="width: 100%"
  105. :disabled="type == 'detail' || !!row.experimentCode"
  106. >
  107. <el-option :value="1" label="常规检验"></el-option>
  108. <el-option :value="2" label="实验"></el-option>
  109. </el-select>
  110. </template>
  111. <template v-slot:useTools="{ row }">
  112. <toolButtom v-model="row.useTools" :type="type" :sList="row.toolList" />
  113. </template>
  114. <template v-slot:qualityResultContent="{ row }">
  115. <el-input
  116. v-model="row.qualityResultContent"
  117. placeholder="请输入内容"
  118. :disabled="type == 'detail'"
  119. @input="handleInput(row, row.qualityResultContent)"
  120. >
  121. <template slot="append" v-if="row.unitName">
  122. {{ row.unitName }}
  123. </template>
  124. </el-input>
  125. </template>
  126. <template v-slot:sampleQuantity="{ row, $index }">
  127. <el-input
  128. v-model="row.sampleQuantity"
  129. placeholder="请输入"
  130. :disabled="type == 'detail'"
  131. type="number"
  132. @input="inputValue('sampleQuantity', row, $index)"
  133. >
  134. <template slot="append">{{ form.measureUnit }}</template>
  135. </el-input>
  136. </template>
  137. <template v-slot:qualifiedQuantity="{ row, $index }">
  138. <el-input
  139. v-model="row.qualifiedQuantity"
  140. placeholder="请输入"
  141. :disabled="type == 'detail'"
  142. type="number"
  143. @input="inputValue('qualifiedQuantity', row, $index)"
  144. >
  145. <template slot="append">{{ form.measureUnit }}</template>
  146. </el-input>
  147. </template>
  148. <template v-slot:noQualifiedQuantity="{ row, $index }">
  149. <el-input
  150. v-model="row.noQualifiedQuantity"
  151. placeholder="请输入"
  152. :disabled="type == 'detail'"
  153. type="number"
  154. @input="inputValue('noQualifiedQuantity', row, $index)"
  155. >
  156. <template slot="append">{{ form.measureUnit }}</template>
  157. </el-input>
  158. </template>
  159. <template v-slot:lossNumber="{ row, $index }">
  160. <el-input
  161. v-model="row.lossNumber"
  162. placeholder="请输入"
  163. :disabled="type == 'detail'"
  164. type="number"
  165. @input="inputValue('lossNumber', row, $index)"
  166. @click.native="curretNum = row.lossNumber"
  167. >
  168. <template slot="append">{{ form.measureUnit }}</template>
  169. </el-input>
  170. </template>
  171. <template v-slot:lossNumberUnqualified="{ row, $index }">
  172. <el-input
  173. v-model="row.lossNumberUnqualified"
  174. placeholder="请输入"
  175. :disabled="type == 'detail'"
  176. type="number"
  177. @input="inputValue('lossNumberUnqualified', row, $index)"
  178. @click.native="curretNum = row.lossNumberUnqualified"
  179. >
  180. <template slot="append">{{ form.measureUnit }}</template>
  181. </el-input>
  182. </template>
  183. <template v-slot:retainedSampleQuantity="{ row, $index }">
  184. <el-input
  185. v-model="row.retainedSampleQuantity"
  186. placeholder="请输入"
  187. :disabled="type == 'detail'"
  188. type="number"
  189. @input="inputValue('retainedSampleQuantity', row, $index)"
  190. @click.native="curretNum = row.retainedSampleQuantity"
  191. >
  192. <template slot="append">{{ form.measureUnit }}</template>
  193. </el-input>
  194. </template>
  195. <template v-slot:retainedSampleUnqualified="{ row, $index }">
  196. <el-input
  197. v-model="row.retainedSampleUnqualified"
  198. placeholder="请输入"
  199. :disabled="type == 'detail'"
  200. type="number"
  201. @input="inputValue('retainedSampleUnqualified', row, $index)"
  202. @click.native="curretNum = row.retainedSampleUnqualified"
  203. >
  204. <template slot="append">{{ form.measureUnit }}</template>
  205. </el-input>
  206. </template>
  207. <template v-slot:qualityResults="{ row, $index }">
  208. <el-select
  209. v-model="row.qualityResults"
  210. placeholder="请选择"
  211. style="width: 100%"
  212. :disabled="type == 'detail'"
  213. >
  214. <el-option
  215. v-for="item in qualityResultsList"
  216. :key="item.value"
  217. :label="item.label"
  218. :value="item.value"
  219. >
  220. </el-option>
  221. </el-select>
  222. </template>
  223. <template v-slot:inspectImage="{ row, $index }">
  224. <fileMain
  225. v-model="row.inspectImage"
  226. :type="type == 'detail' ? 'view' : 'add'"
  227. ></fileMain>
  228. </template>
  229. <template v-slot:imgUrl="{ row, $index }">
  230. <fileMain v-model="row.imgUrl" type="view"></fileMain>
  231. </template>
  232. <template v-slot:defaultValue="{ row }">
  233. <div style="display: flex; justify-content: center">
  234. <span>{{ row.symbol }}</span>
  235. <span v-if="row.textType == 3">
  236. {{ row.minValue }}-{{ row.maxValue }}
  237. </span>
  238. <span v-else>
  239. <span>{{ row.defaultValue }}</span>
  240. </span>
  241. {{ row.unitName }}
  242. </div>
  243. </template>
  244. <template v-slot:isRequired="{ column }">
  245. <span class="is-required">{{ column.label }}</span>
  246. </template>
  247. <template v-slot:action="{ row }">
  248. <el-link
  249. type="primary"
  250. :underline="false"
  251. @click="experimentReport(row, 'report')"
  252. v-if="row.executionMethod == 2"
  253. >
  254. 实验
  255. </el-link>
  256. </template>
  257. </ele-pro-table>
  258. <template v-slot:footer>
  259. <el-button @click="handleClose">取消</el-button>
  260. <el-button type="primary" @click="handleConfirm" v-if="type != 'detail'">
  261. 确认
  262. </el-button>
  263. </template>
  264. <experimentReport
  265. ref="experimentReport"
  266. @done="experimentReportDone"
  267. :pageName="pageName"
  268. ></experimentReport>
  269. <wokePopup ref="wokePopupRef"></wokePopup>
  270. </ele-modal>
  271. </template>
  272. <script>
  273. import dictMixins from '@/mixins/dictMixins';
  274. import detailMixins from '../mixins/detailMixins';
  275. import toolButtom from './toolButtom.vue';
  276. import experimentReport from './experimentReport.vue';
  277. import { handleInput } from './unit.js';
  278. import {
  279. exeTaskReportWork,
  280. exeEntrustReportWork
  281. } from '@/api/inspectionProjectTask';
  282. import wokePopup from '@/components/workList/wokePopup.vue';
  283. import { parameterGetByCode } from '@/api/main/index';
  284. import { craftFiles } from '@/api/inspectionWork';
  285. export default {
  286. mixins: [dictMixins, detailMixins],
  287. components: { toolButtom, experimentReport, wokePopup },
  288. data() {
  289. return {
  290. handleInput,
  291. type: 'report',
  292. title: '检测项工单',
  293. visible: false,
  294. form: {},
  295. tableData: [],
  296. rowIndex: [],
  297. curretNum: 0,
  298. qms_qualityResultContent: 1,
  299. workColumns: [
  300. {
  301. minWidth: 150,
  302. prop: 'code',
  303. align: 'center',
  304. label: '检测项工单号',
  305. showOverflowTooltip: true
  306. },
  307. {
  308. minWidth: 150,
  309. prop: 'qualityWorkOrderCode',
  310. align: 'center',
  311. label: '检测工单编码',
  312. showOverflowTooltip: true
  313. },
  314. {
  315. minWidth: 150,
  316. prop: 'qualityWorkOrderName',
  317. align: 'center',
  318. label: '检测工单名称',
  319. showOverflowTooltip: true
  320. },
  321. {
  322. minWidth: 150,
  323. prop: 'qualityWorkOrderCode',
  324. align: 'center',
  325. label: '来源单号',
  326. showOverflowTooltip: true
  327. },
  328. {
  329. minWidth: 100,
  330. prop: 'qualityType',
  331. slot: 'qualityType',
  332. align: 'center',
  333. label: '类型',
  334. showOverflowTooltip: true
  335. },
  336. {
  337. minWidth: 100,
  338. slot: 'qualityMode',
  339. prop: 'qualityMode',
  340. align: 'center',
  341. label: '检测方式',
  342. showOverflowTooltip: true
  343. },
  344. {
  345. minWidth: 120,
  346. prop: 'productCode',
  347. align: 'center',
  348. label: '编码',
  349. showOverflowTooltip: true
  350. },
  351. {
  352. minWidth: 120,
  353. prop: 'productName',
  354. align: 'center',
  355. label: '名称',
  356. showOverflowTooltip: true
  357. },
  358. {
  359. minWidth: 100,
  360. prop: 'batchNo',
  361. align: 'center',
  362. label: '批次号',
  363. showOverflowTooltip: true
  364. },
  365. {
  366. minWidth: 120,
  367. prop: 'specification',
  368. align: 'center',
  369. label: '规格',
  370. showOverflowTooltip: true
  371. },
  372. {
  373. minWidth: 100,
  374. prop: 'brandNo',
  375. align: 'center',
  376. label: '牌号',
  377. showOverflowTooltip: true
  378. },
  379. {
  380. minWidth: 120,
  381. prop: 'produceTaskName',
  382. align: 'center',
  383. label: '工序名称',
  384. showOverflowTooltip: true
  385. },
  386. {
  387. minWidth: 120,
  388. prop: 'total',
  389. align: 'center',
  390. label: '总数量',
  391. formatter: (row) => {
  392. if (row.total) {
  393. return row.total + this.form.measureUnit || '';
  394. }
  395. },
  396. showOverflowTooltip: true
  397. },
  398. {
  399. minWidth: 180,
  400. prop: 'sampleQuantity',
  401. headerSlot: 'isRequired',
  402. slot: 'sampleQuantity',
  403. align: 'center',
  404. label: '样品数',
  405. showOverflowTooltip: true
  406. },
  407. {
  408. minWidth: 180,
  409. prop: 'sampleNoQualifiedNumber',
  410. slot: 'sampleNoQualifiedNumber',
  411. align: 'center',
  412. label: '样品不合格数',
  413. showOverflowTooltip: true
  414. },
  415. {
  416. minWidth: 140,
  417. prop: 'sampleQualifiedNumber',
  418. headerSlot: 'isRequired',
  419. slot: 'sampleQualifiedNumber',
  420. align: 'center',
  421. formatter: (row) => {
  422. if (row.sampleQualifiedNumber) {
  423. return (
  424. row.sampleQualifiedNumber + (this.form.measureUnit || '')
  425. );
  426. }
  427. },
  428. label: '样品合格数',
  429. showOverflowTooltip: true
  430. },
  431. {
  432. minWidth: 140,
  433. prop: 'lossNumber',
  434. slot: 'lossNumber',
  435. align: 'center',
  436. formatter: (row) => {
  437. if (row.lossNumber) {
  438. return row.lossNumber + (this.form.measureUnit || '');
  439. }
  440. },
  441. label: '损耗数(合格品)',
  442. showOverflowTooltip: true
  443. },
  444. {
  445. minWidth: 140,
  446. prop: 'lossNumberUnqualified',
  447. slot: 'lossNumberUnqualified',
  448. align: 'center',
  449. formatter: (row) => {
  450. if (row.lossNumberUnqualified) {
  451. return (
  452. row.lossNumberUnqualified + (this.form.measureUnit || '')
  453. );
  454. }
  455. },
  456. label: '损耗数(不合格品)',
  457. showOverflowTooltip: true
  458. },
  459. {
  460. minWidth: 140,
  461. prop: 'retainedSampleQuantity',
  462. slot: 'retainedSampleQuantity',
  463. align: 'center',
  464. formatter: (row) => {
  465. if (row.retainedSampleQuantity) {
  466. return (
  467. row.retainedSampleQuantity + (this.form.measureUnit || '')
  468. );
  469. }
  470. },
  471. label: '留样数(合格品)',
  472. showOverflowTooltip: true
  473. },
  474. {
  475. minWidth: 140,
  476. prop: 'retainedSampleUnqualified',
  477. slot: 'retainedSampleUnqualified',
  478. align: 'center',
  479. formatter: (row) => {
  480. if (row.retainedSampleUnqualified) {
  481. return (
  482. row.retainedSampleUnqualified + (this.form.measureUnit || '')
  483. );
  484. }
  485. },
  486. label: '留样数(不合格品)',
  487. showOverflowTooltip: true
  488. },
  489. {
  490. minWidth: 120,
  491. prop: 'hours',
  492. slot: 'hours',
  493. align: 'center',
  494. label: '工时',
  495. showOverflowTooltip: true
  496. },
  497. {
  498. minWidth: 120,
  499. prop: 'accessory',
  500. slot: 'accessory',
  501. align: 'center',
  502. label: '附件',
  503. showOverflowTooltip: true
  504. },
  505. {
  506. minWidth: 120,
  507. prop: 'qualityNames',
  508. slot: 'qualityNames',
  509. align: 'center',
  510. label: '检测人',
  511. showOverflowTooltip: true
  512. },
  513. {
  514. minWidth: 120,
  515. prop: 'qualityTimeEnd',
  516. slot: 'qualityTimeEnd',
  517. align: 'center',
  518. label: '检测时间',
  519. showOverflowTooltip: true
  520. },
  521. {
  522. minWidth: 120,
  523. prop: 'craftFiles',
  524. slot: 'craftFiles',
  525. align: 'center',
  526. label: '工艺文件',
  527. fixed: 'right',
  528. showOverflowTooltip: true
  529. }
  530. ],
  531. qualityResultsList: [
  532. {
  533. value: 1,
  534. label: '合格'
  535. },
  536. {
  537. value: 2,
  538. label: '不合格'
  539. },
  540. {
  541. value: 3,
  542. label: '让步接收'
  543. }
  544. ],
  545. sList: [], //质检工具筛选
  546. pageName: ''
  547. };
  548. },
  549. computed: {
  550. tableColumns() {
  551. return [
  552. {
  553. width: 45,
  554. type: 'index',
  555. columnKey: 'index',
  556. align: 'center',
  557. fixed: 'left'
  558. },
  559. {
  560. minWidth: 150,
  561. prop: 'qualitySchemeTemplateCode',
  562. align: 'center',
  563. label: '检测方案编码',
  564. showOverflowTooltip: true
  565. },
  566. {
  567. minWidth: 120,
  568. prop: 'qualitySchemeTemplateName',
  569. align: 'center',
  570. label: '检测方案名称',
  571. showOverflowTooltip: true
  572. },
  573. {
  574. minWidth: 100,
  575. prop: 'categoryLevelClassName',
  576. align: 'center',
  577. label: '检测类型',
  578. showOverflowTooltip: true
  579. },
  580. {
  581. minWidth: 130,
  582. prop: 'inspectionCode',
  583. align: 'center',
  584. label: '检测项编码',
  585. showOverflowTooltip: true
  586. },
  587. {
  588. minWidth: 120,
  589. prop: 'inspectionName',
  590. align: 'center',
  591. label: '检测项名称',
  592. showOverflowTooltip: true
  593. },
  594. {
  595. minWidth: 100,
  596. prop: 'qualityStandardType',
  597. slot: 'qualityStandardType',
  598. align: 'center',
  599. label: '执行标准',
  600. showOverflowTooltip: true
  601. },
  602. {
  603. minWidth: 150,
  604. slot: 'defaultValue',
  605. prop: 'defaultValue',
  606. align: 'center',
  607. label: '工艺参数',
  608. showOverflowTooltip: true
  609. },
  610. {
  611. minWidth: 130,
  612. prop: 'executionMethod',
  613. slot: 'executionMethod',
  614. align: 'center',
  615. label: '执行方法',
  616. showOverflowTooltip: true
  617. },
  618. {
  619. minWidth: 100,
  620. prop: 'useTools',
  621. slot: 'useTools',
  622. align: 'center',
  623. label: '检测工具',
  624. showOverflowTooltip: true
  625. },
  626. {
  627. minWidth: 200,
  628. prop: 'qualityResultContent',
  629. align: 'center',
  630. slot: 'qualityResultContent',
  631. headerSlot: this.qms_qualityResultContent == 1 ? 'isRequired' : '',
  632. label: '检测内容',
  633. showOverflowTooltip: true
  634. },
  635. {
  636. minWidth: 180,
  637. prop: 'sampleQuantity',
  638. slot: 'sampleQuantity',
  639. headerSlot: 'isRequired',
  640. align: 'center',
  641. label: '样品数',
  642. showOverflowTooltip: true
  643. },
  644. {
  645. minWidth: 180,
  646. prop: 'qualifiedQuantity',
  647. align: 'center',
  648. slot: 'qualifiedQuantity',
  649. label: '合格数',
  650. showOverflowTooltip: true
  651. },
  652. {
  653. minWidth: 180,
  654. prop: 'noQualifiedQuantity',
  655. slot: 'noQualifiedQuantity',
  656. align: 'center',
  657. label: '不合格数',
  658. showOverflowTooltip: true
  659. },
  660. {
  661. minWidth: 180,
  662. prop: 'lossNumber',
  663. slot: 'lossNumber',
  664. align: 'center',
  665. label: '损耗数(合格品)',
  666. showOverflowTooltip: true
  667. },
  668. {
  669. minWidth: 180,
  670. prop: 'lossNumberUnqualified',
  671. slot: 'lossNumberUnqualified',
  672. align: 'center',
  673. label: '损耗数(不合格品)',
  674. showOverflowTooltip: true
  675. },
  676. {
  677. minWidth: 180,
  678. prop: 'retainedSampleQuantity',
  679. slot: 'retainedSampleQuantity',
  680. align: 'center',
  681. label: '留样数(合格品)',
  682. showOverflowTooltip: true
  683. },
  684. {
  685. minWidth: 180,
  686. prop: 'retainedSampleUnqualified',
  687. slot: 'retainedSampleUnqualified',
  688. align: 'center',
  689. label: '留样数(不合格品)',
  690. showOverflowTooltip: true
  691. },
  692. {
  693. minWidth: 130,
  694. prop: 'qualityResults',
  695. slot: 'qualityResults',
  696. align: 'center',
  697. label: '检测结果',
  698. showOverflowTooltip: true,
  699. fixed: 'right'
  700. },
  701. {
  702. minWidth: 150,
  703. prop: 'experimentCode',
  704. align: 'center',
  705. label: '实验编号',
  706. showOverflowTooltip: true
  707. },
  708. {
  709. minWidth: 120,
  710. prop: 'inspectImage',
  711. slot: 'inspectImage',
  712. align: 'center',
  713. label: '检验图片',
  714. showOverflowTooltip: true
  715. },
  716. {
  717. minWidth: 100,
  718. prop: 'imgUrl',
  719. slot: 'imgUrl',
  720. align: 'center',
  721. label: '附件',
  722. showOverflowTooltip: true
  723. },
  724. {
  725. columnKey: 'action',
  726. label: '操作',
  727. width: 120,
  728. align: 'center',
  729. resizable: false,
  730. slot: 'action',
  731. showOverflowTooltip: true,
  732. fixed: 'right'
  733. }
  734. ];
  735. },
  736. getSampleQuantityCount() {
  737. return this.form.sampleQuantity;
  738. }
  739. },
  740. created() {
  741. this.requestDict('质检计划类型');
  742. this.requestDict('取样类型');
  743. this.requestDict('质检标准类型');
  744. parameterGetByCode({
  745. code: 'qms_qualityResultContent'
  746. }).then((res) => {
  747. this.qms_qualityResultContent = res?.value;
  748. });
  749. },
  750. methods: {
  751. async craftFiles(row) {
  752. const res = await parameterGetByCode({
  753. code: 'mes_craft_file_by_category_code'
  754. });
  755. const byCategory = res?.value === '1';
  756. if (byCategory) {
  757. this.$refs.wokePopupRef.openTwo(row);
  758. } else {
  759. const data = row.qualityWorkOrderId
  760. ? await craftFiles(row.qualityWorkOrderId)
  761. : [];
  762. this.$refs.wokePopupRef.open(data.map((item) => item.id));
  763. }
  764. },
  765. experimentReport(row, type) {
  766. console.log(this.getSampleQuantityCount, 'this.form');
  767. this.$refs.experimentReport.open(
  768. {
  769. ...row,
  770. batchNo: this.form.batchNo,
  771. qualityWorkOrderId: this.form.qualityWorkOrderId,
  772. getSampleQuantityCount: this.form.sampleQuantity
  773. },
  774. type
  775. );
  776. },
  777. experimentReportDone(data) {
  778. console.log(data);
  779. let index = this.tableData.findIndex((item) => item.id == data.id);
  780. this.$set(this.tableData, index, data);
  781. console.log(this.tableData);
  782. // this.initData();
  783. },
  784. async open({ workData, row, list }, type, pageName) {
  785. this.tableData = [];
  786. this.pageName = pageName;
  787. this.type = type;
  788. if (pageName == 'inspectionProjectTask') {
  789. this.title = '检测项任务单';
  790. }
  791. if (pageName == 'inspectionProjectRequest') {
  792. this.title = '检测项受托单';
  793. }
  794. if (type == 'report') {
  795. let data = { ...row, ...workData };
  796. console.log(data, workData);
  797. data.sampleQuantity = row.sampleQuantity || data.workSampleCount;
  798. data.sampleNoQualifiedNumber = row.sampleNoQualifiedNumber || 0;
  799. data.sampleQualifiedNumber =
  800. row.sampleQualifiedNumber ||
  801. data.sampleQuantity - data.sampleNoQualifiedNumber ||
  802. 0;
  803. this.$set(this, 'form', JSON.parse(JSON.stringify(data)));
  804. console.log(this.form, 'this.form');
  805. this.tableData = JSON.parse(JSON.stringify(list));
  806. this.tableData.forEach((item, index) => {
  807. if (item.experimentCode) {
  808. this.$set(this.tableData[index], 'executionMethod', 2);
  809. }
  810. this.$set(
  811. this.tableData[index],
  812. 'executionMethod',
  813. item.executionMethod || 1
  814. );
  815. });
  816. // if (row.sampleQuantity) {
  817. // this.form.remainingSampleCount =
  818. // Number(row.sampleQuantity) +
  819. // Number(this.form.remainingSampleCount);
  820. // }
  821. } else {
  822. this.$set(this, 'form', JSON.parse(JSON.stringify(workData)));
  823. this.$set(
  824. this.form,
  825. 'sampleNoQualifiedNumber',
  826. this.form.sampleNoQualifiedNumber || 0
  827. );
  828. this.$set(
  829. this.form,
  830. 'sampleQualifiedNumber',
  831. this.form.sampleQualifiedNumber ||
  832. this.form.sampleQuantity - this.form.sampleNoQualifiedNumber ||
  833. 0
  834. );
  835. this.tableData = JSON.parse(JSON.stringify(list));
  836. // if (this.form.qualityWorkOrderId) {
  837. // this.form.remainingSampleCount =
  838. // this.form.sampleQuantity + this.form.remainingSampleCount;
  839. // }
  840. }
  841. this.visible = true;
  842. },
  843. handleOneKeyQualified() {
  844. this.tableData.forEach((item, index) => {
  845. this.$set(this.tableData[index], 'qualityResults', 1);
  846. });
  847. },
  848. formSampleQuantityChange() {
  849. if (this.form.sampleQuantity < 0) {
  850. this.form.sampleQuantity = 0;
  851. }
  852. if (this.form.sampleQuantity > this.form.workSampleCount) {
  853. this.form.sampleQuantity = this.form.workSampleCount;
  854. }
  855. if (
  856. this.form.sampleQuantity <
  857. Math.max(...this.tableData.map((item) => item.sampleQuantity))
  858. ) {
  859. this.tableData.forEach((item, index) => {
  860. this.resetData(item, index, [
  861. 'qualifiedQuantity',
  862. 'noQualifiedQuantity',
  863. 'sampleQuantity'
  864. ]);
  865. });
  866. }
  867. this.form.sampleQualifiedNumber = this.form.sampleQuantity;
  868. this.form.sampleNoQualifiedNumber = 0;
  869. },
  870. formSampleNoQualifiedNumberChange() {
  871. if (+this.form.sampleNoQualifiedNumber < 0) {
  872. this.form.sampleNoQualifiedNumber = 0;
  873. }
  874. if (+this.form.sampleNoQualifiedNumber > this.form.sampleQuantity) {
  875. this.form.sampleNoQualifiedNumber = this.form.sampleQuantity;
  876. }
  877. this.form.sampleQualifiedNumber =
  878. this.form.sampleQuantity - this.form.sampleNoQualifiedNumber;
  879. },
  880. handleClose() {
  881. this.visible = false;
  882. if (this.$refs.wokePopupRef) {
  883. this.$refs.wokePopupRef.visible = false;
  884. }
  885. },
  886. handleConfirm() {
  887. let isHandleConfirm = false;
  888. if (!this.form.sampleQuantity) {
  889. return this.$message.error('样品数不能为空!');
  890. }
  891. this.tableData.forEach((item, index) => {
  892. item.status = 1;
  893. if (!item.qualityResultContent) {
  894. isHandleConfirm = true;
  895. }
  896. });
  897. if (!this.pageName) {
  898. this.$emit('success', { data: this.form, tableData: this.tableData });
  899. this.visible = false;
  900. } else {
  901. if (isHandleConfirm && this.qms_qualityResultContent == 1) {
  902. return this.$message.error('检测内容不能为空!');
  903. }
  904. let api =
  905. this.pageName == 'inspectionProjectTask'
  906. ? exeTaskReportWork
  907. : exeEntrustReportWork;
  908. api({
  909. ...this.form,
  910. templateList: this.tableData
  911. }).then((res) => {
  912. this.$message.success('操作成功');
  913. this.$emit('reload');
  914. this.visible = false;
  915. });
  916. }
  917. },
  918. inputValue(type, item, index) {
  919. if (item[type] < 0) {
  920. item[type] = 0;
  921. }
  922. //样品数
  923. if (type == 'sampleQuantity') {
  924. this.isSampleQuantity(item, index);
  925. }
  926. //样品合格数、不合格数
  927. if (type == 'qualifiedQuantity' || type == 'noQualifiedQuantity') {
  928. this.isQualifiedQuantity(item, index, type);
  929. }
  930. //损耗数
  931. if (type == 'lossNumber' || type == 'lossNumberUnqualified') {
  932. this.setNumber(item, index, type, '损耗', 'lossNumber');
  933. }
  934. //留样数
  935. if (
  936. type == 'retainedSampleQuantity' ||
  937. type == 'retainedSampleUnqualified'
  938. ) {
  939. this.setNumber(item, index, type, '留样', 'retainedSampleQuantity');
  940. }
  941. }
  942. }
  943. };
  944. </script>
  945. <style scoped lang="scss">
  946. ::v-deep .warn {
  947. color: red;
  948. .el-input__inner {
  949. color: red;
  950. }
  951. }
  952. </style>