inspectionProjectReport.vue 29 KB

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