inspectionProjectReport.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083
  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' || qms_defaultDisposalType"
  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' || qms_defaultDisposalType"
  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. @change="(val) => handleQualityResultsChange(val, row, $index)"
  214. >
  215. <el-option
  216. v-for="item in qualityResultsList"
  217. :key="item.value"
  218. :label="item.label"
  219. :value="item.value"
  220. >
  221. </el-option>
  222. </el-select>
  223. </template>
  224. <template v-slot:inspectImage="{ row, $index }">
  225. <fileMain
  226. v-model="row.inspectImage"
  227. :type="type == 'detail' ? 'view' : 'add'"
  228. ></fileMain>
  229. </template>
  230. <template v-slot:imgUrl="{ row, $index }">
  231. <fileMain v-model="row.imgUrl" type="view"></fileMain>
  232. </template>
  233. <template v-slot:defaultValue="{ row }">
  234. <div style="display: flex; justify-content: center; color: #409eff">
  235. <span v-if="row.textType != 8">{{ row.symbol }}</span>
  236. <span v-if="row.textType == 3">
  237. {{ row.minValue }}-{{ row.maxValue }}
  238. </span>
  239. <span v-else-if="row.textType == 8">
  240. 标准值:{{ row.defaultValue }}{{ row.unitName || '' }} 下限:{{
  241. row.minValue || 0
  242. }}{{ row.unitName || '' }} 上限:{{ row.maxValue || 0
  243. }}{{ row.unitName || '' }}
  244. </span>
  245. <span v-else>
  246. <span>{{ row.defaultValue }}</span>
  247. </span>
  248. <span v-if="row.textType != 8">
  249. {{ row.unitName }}
  250. </span>
  251. </div>
  252. </template>
  253. <template v-slot:inspectionName="{ row }">
  254. <span style="color: #409eff">{{ row.inspectionName }}</span>
  255. </template>
  256. <template v-slot:isRequired="{ column }">
  257. <span class="is-required">{{ column.label }}</span>
  258. </template>
  259. <template v-slot:action="{ row }">
  260. <el-link
  261. type="primary"
  262. :underline="false"
  263. @click="experimentReport(row, 'report')"
  264. v-if="row.executionMethod == 2"
  265. >
  266. 实验
  267. </el-link>
  268. </template>
  269. </ele-pro-table>
  270. <template v-slot:footer>
  271. <el-button @click="handleClose">取消</el-button>
  272. <el-button type="primary" @click="handleConfirm" v-if="type != 'detail'">
  273. 确认
  274. </el-button>
  275. </template>
  276. <experimentReport
  277. ref="experimentReport"
  278. @done="experimentReportDone"
  279. :pageName="pageName"
  280. ></experimentReport>
  281. <wokePopup ref="wokePopupRef"></wokePopup>
  282. </ele-modal>
  283. </template>
  284. <script>
  285. import dictMixins from '@/mixins/dictMixins';
  286. import detailMixins from '../mixins/detailMixins';
  287. import toolButtom from './toolButtom.vue';
  288. import experimentReport from './experimentReport.vue';
  289. import { handleInput } from './unit.js';
  290. import {
  291. exeTaskReportWork,
  292. exeEntrustReportWork
  293. } from '@/api/inspectionProjectTask';
  294. import wokePopup from '@/components/workList/wokePopup.vue';
  295. import { parameterGetByCode } from '@/api/main/index';
  296. import { craftFiles, mesCraftFiles } from '@/api/inspectionWork';
  297. export default {
  298. mixins: [dictMixins, detailMixins],
  299. components: { toolButtom, experimentReport, wokePopup },
  300. data() {
  301. return {
  302. handleInput,
  303. type: 'report',
  304. title: '检测项工单',
  305. visible: false,
  306. form: {},
  307. tableData: [],
  308. rowIndex: [],
  309. curretNum: 0,
  310. qms_qualityResultContent: 1,
  311. qms_defaultDisposalType: false,
  312. workColumns: [
  313. {
  314. minWidth: 150,
  315. prop: 'code',
  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: 150,
  329. prop: 'qualityWorkOrderName',
  330. align: 'center',
  331. label: '检测工单名称',
  332. showOverflowTooltip: true
  333. },
  334. // {
  335. // minWidth: 150,
  336. // prop: 'qualityWorkOrderCode',
  337. // align: 'center',
  338. // label: '来源单号',
  339. // showOverflowTooltip: true
  340. // },
  341. {
  342. minWidth: 100,
  343. prop: 'qualityType',
  344. slot: 'qualityType',
  345. align: 'center',
  346. label: '类型',
  347. showOverflowTooltip: true
  348. },
  349. {
  350. minWidth: 100,
  351. slot: 'qualityMode',
  352. prop: 'qualityMode',
  353. align: 'center',
  354. label: '检测方式',
  355. showOverflowTooltip: true
  356. },
  357. {
  358. minWidth: 120,
  359. prop: 'productCode',
  360. align: 'center',
  361. label: '编码',
  362. showOverflowTooltip: true
  363. },
  364. {
  365. minWidth: 120,
  366. prop: 'productName',
  367. align: 'center',
  368. label: '名称',
  369. showOverflowTooltip: true
  370. },
  371. {
  372. minWidth: 100,
  373. prop: 'batchNo',
  374. align: 'center',
  375. label: '批次号',
  376. showOverflowTooltip: true
  377. },
  378. {
  379. minWidth: 120,
  380. prop: 'specification',
  381. align: 'center',
  382. label: '规格',
  383. showOverflowTooltip: true
  384. },
  385. {
  386. minWidth: 100,
  387. prop: 'brandNo',
  388. align: 'center',
  389. label: '牌号',
  390. showOverflowTooltip: true
  391. },
  392. {
  393. minWidth: 120,
  394. prop: 'produceTaskName',
  395. align: 'center',
  396. label: '工序名称',
  397. showOverflowTooltip: true
  398. },
  399. {
  400. minWidth: 120,
  401. prop: 'total',
  402. align: 'center',
  403. label: '总数量',
  404. formatter: (row) => {
  405. if (row.total) {
  406. return row.total + this.form.measureUnit || '';
  407. }
  408. },
  409. showOverflowTooltip: true
  410. },
  411. {
  412. minWidth: 180,
  413. prop: 'sampleQuantity',
  414. headerSlot: 'isRequired',
  415. slot: 'sampleQuantity',
  416. align: 'center',
  417. label: '样品数',
  418. showOverflowTooltip: true
  419. },
  420. {
  421. minWidth: 180,
  422. prop: 'sampleNoQualifiedNumber',
  423. slot: 'sampleNoQualifiedNumber',
  424. align: 'center',
  425. label: '样品不合格数',
  426. formatter: (row) => {
  427. if (row.sampleNoQualifiedNumber) {
  428. return (
  429. row.sampleNoQualifiedNumber + (this.form.measureUnit || '')
  430. );
  431. }
  432. },
  433. showOverflowTooltip: true
  434. },
  435. {
  436. minWidth: 140,
  437. prop: 'sampleQualifiedNumber',
  438. headerSlot: 'isRequired',
  439. slot: 'sampleQualifiedNumber',
  440. align: 'center',
  441. formatter: (row) => {
  442. if (row.sampleQualifiedNumber) {
  443. return (
  444. row.sampleQualifiedNumber + (this.form.measureUnit || '')
  445. );
  446. }
  447. },
  448. label: '样品合格数',
  449. showOverflowTooltip: true
  450. },
  451. {
  452. minWidth: 140,
  453. prop: 'lossNumber',
  454. slot: 'lossNumber',
  455. align: 'center',
  456. formatter: (row) => {
  457. if (row.lossNumber) {
  458. return row.lossNumber + (this.form.measureUnit || '');
  459. }
  460. },
  461. label: '损耗数(合格品)',
  462. showOverflowTooltip: true
  463. },
  464. {
  465. minWidth: 140,
  466. prop: 'lossNumberUnqualified',
  467. slot: 'lossNumberUnqualified',
  468. align: 'center',
  469. formatter: (row) => {
  470. if (row.lossNumberUnqualified) {
  471. return (
  472. row.lossNumberUnqualified + (this.form.measureUnit || '')
  473. );
  474. }
  475. },
  476. label: '损耗数(不合格品)',
  477. showOverflowTooltip: true
  478. },
  479. {
  480. minWidth: 140,
  481. prop: 'retainedSampleQuantity',
  482. slot: 'retainedSampleQuantity',
  483. align: 'center',
  484. formatter: (row) => {
  485. if (row.retainedSampleQuantity) {
  486. return (
  487. row.retainedSampleQuantity + (this.form.measureUnit || '')
  488. );
  489. }
  490. },
  491. label: '留样数(合格品)',
  492. showOverflowTooltip: true
  493. },
  494. {
  495. minWidth: 140,
  496. prop: 'retainedSampleUnqualified',
  497. slot: 'retainedSampleUnqualified',
  498. align: 'center',
  499. formatter: (row) => {
  500. if (row.retainedSampleUnqualified) {
  501. return (
  502. row.retainedSampleUnqualified + (this.form.measureUnit || '')
  503. );
  504. }
  505. },
  506. label: '留样数(不合格品)',
  507. showOverflowTooltip: true
  508. },
  509. {
  510. minWidth: 120,
  511. prop: 'hours',
  512. slot: 'hours',
  513. align: 'center',
  514. label: '工时',
  515. showOverflowTooltip: true
  516. },
  517. {
  518. minWidth: 120,
  519. prop: 'accessory',
  520. slot: 'accessory',
  521. align: 'center',
  522. label: '附件',
  523. showOverflowTooltip: true
  524. },
  525. {
  526. minWidth: 120,
  527. prop: 'qualityNames',
  528. slot: 'qualityNames',
  529. align: 'center',
  530. label: '检测人',
  531. showOverflowTooltip: true
  532. },
  533. {
  534. minWidth: 120,
  535. prop: 'qualityTimeEnd',
  536. slot: 'qualityTimeEnd',
  537. align: 'center',
  538. label: '检测时间',
  539. showOverflowTooltip: true
  540. },
  541. {
  542. minWidth: 120,
  543. prop: 'craftFiles',
  544. slot: 'craftFiles',
  545. align: 'center',
  546. label: '工艺文件',
  547. fixed: 'right',
  548. showOverflowTooltip: true
  549. }
  550. ],
  551. qualityResultsList: [
  552. {
  553. value: 1,
  554. label: '合格'
  555. },
  556. {
  557. value: 2,
  558. label: '不合格'
  559. },
  560. {
  561. value: 3,
  562. label: '让步接收'
  563. }
  564. ],
  565. sList: [], //质检工具筛选
  566. pageName: ''
  567. };
  568. },
  569. computed: {
  570. tableColumns() {
  571. return [
  572. {
  573. width: 45,
  574. type: 'index',
  575. columnKey: 'index',
  576. align: 'center',
  577. fixed: 'left'
  578. },
  579. {
  580. minWidth: 150,
  581. prop: 'qualitySchemeTemplateCode',
  582. align: 'center',
  583. label: '检测方案编码',
  584. showOverflowTooltip: true
  585. },
  586. {
  587. minWidth: 120,
  588. prop: 'qualitySchemeTemplateName',
  589. align: 'center',
  590. label: '检测方案名称',
  591. showOverflowTooltip: true
  592. },
  593. {
  594. minWidth: 100,
  595. prop: 'categoryLevelClassName',
  596. align: 'center',
  597. label: '检测类型',
  598. showOverflowTooltip: true
  599. },
  600. {
  601. minWidth: 130,
  602. prop: 'inspectionCode',
  603. align: 'center',
  604. label: '检测项编码',
  605. showOverflowTooltip: true
  606. },
  607. {
  608. minWidth: 120,
  609. prop: 'inspectionName',
  610. slot: 'inspectionName',
  611. align: 'center',
  612. label: '检测项名称',
  613. showOverflowTooltip: true
  614. },
  615. {
  616. minWidth: 100,
  617. prop: 'qualityStandardType',
  618. slot: 'qualityStandardType',
  619. align: 'center',
  620. label: '执行标准',
  621. showOverflowTooltip: true
  622. },
  623. {
  624. minWidth: 320,
  625. slot: 'defaultValue',
  626. prop: 'defaultValue',
  627. align: 'center',
  628. label: '工艺参数',
  629. showOverflowTooltip: true
  630. },
  631. {
  632. minWidth: 130,
  633. prop: 'executionMethod',
  634. slot: 'executionMethod',
  635. align: 'center',
  636. label: '执行方法',
  637. showOverflowTooltip: true
  638. },
  639. {
  640. minWidth: 100,
  641. prop: 'useTools',
  642. slot: 'useTools',
  643. align: 'center',
  644. label: '检测工具',
  645. showOverflowTooltip: true
  646. },
  647. {
  648. minWidth: 200,
  649. prop: 'qualityResultContent',
  650. align: 'center',
  651. slot: 'qualityResultContent',
  652. headerSlot: this.qms_qualityResultContent == 1 ? 'isRequired' : '',
  653. label: '检测内容',
  654. showOverflowTooltip: true
  655. },
  656. {
  657. minWidth: 180,
  658. prop: 'sampleQuantity',
  659. slot: 'sampleQuantity',
  660. headerSlot: 'isRequired',
  661. align: 'center',
  662. label: '样品数',
  663. showOverflowTooltip: true
  664. },
  665. {
  666. minWidth: 180,
  667. prop: 'qualifiedQuantity',
  668. align: 'center',
  669. slot: 'qualifiedQuantity',
  670. label: '合格数',
  671. showOverflowTooltip: true
  672. },
  673. {
  674. minWidth: 180,
  675. prop: 'noQualifiedQuantity',
  676. slot: 'noQualifiedQuantity',
  677. align: 'center',
  678. label: '不合格数',
  679. showOverflowTooltip: true
  680. },
  681. {
  682. minWidth: 180,
  683. prop: 'lossNumber',
  684. slot: 'lossNumber',
  685. align: 'center',
  686. label: '损耗数(合格品)',
  687. showOverflowTooltip: true
  688. },
  689. {
  690. minWidth: 180,
  691. prop: 'lossNumberUnqualified',
  692. slot: 'lossNumberUnqualified',
  693. align: 'center',
  694. label: '损耗数(不合格品)',
  695. showOverflowTooltip: true
  696. },
  697. {
  698. minWidth: 180,
  699. prop: 'retainedSampleQuantity',
  700. slot: 'retainedSampleQuantity',
  701. align: 'center',
  702. label: '留样数(合格品)',
  703. showOverflowTooltip: true
  704. },
  705. {
  706. minWidth: 180,
  707. prop: 'retainedSampleUnqualified',
  708. slot: 'retainedSampleUnqualified',
  709. align: 'center',
  710. label: '留样数(不合格品)',
  711. showOverflowTooltip: true
  712. },
  713. {
  714. minWidth: 130,
  715. prop: 'qualityResults',
  716. slot: 'qualityResults',
  717. align: 'center',
  718. label: '检测结果',
  719. showOverflowTooltip: true,
  720. fixed: 'right'
  721. },
  722. {
  723. minWidth: 150,
  724. prop: 'experimentCode',
  725. align: 'center',
  726. label: '实验编号',
  727. showOverflowTooltip: true
  728. },
  729. {
  730. minWidth: 120,
  731. prop: 'inspectImage',
  732. slot: 'inspectImage',
  733. align: 'center',
  734. label: '检验图片',
  735. showOverflowTooltip: true
  736. },
  737. {
  738. minWidth: 100,
  739. prop: 'imgUrl',
  740. slot: 'imgUrl',
  741. align: 'center',
  742. label: '附件',
  743. showOverflowTooltip: true
  744. },
  745. {
  746. columnKey: 'action',
  747. label: '操作',
  748. width: 120,
  749. align: 'center',
  750. resizable: false,
  751. slot: 'action',
  752. showOverflowTooltip: true,
  753. fixed: 'right'
  754. }
  755. ];
  756. },
  757. getSampleQuantityCount() {
  758. return this.form.sampleQuantity;
  759. }
  760. },
  761. created() {
  762. parameterGetByCode({
  763. code: 'default_disposal_type'
  764. }).then((res) => {
  765. this.qms_defaultDisposalType = res?.value == 1 ? true : false;
  766. });
  767. this.requestDict('质检计划类型');
  768. this.requestDict('取样类型');
  769. this.requestDict('质检标准类型');
  770. parameterGetByCode({
  771. code: 'qms_qualityResultContent'
  772. }).then((res) => {
  773. this.qms_qualityResultContent = res?.value;
  774. });
  775. },
  776. methods: {
  777. async craftFiles(row) {
  778. const res = await parameterGetByCode({
  779. code: 'mes_craft_file_by_category_code'
  780. });
  781. const byCategory = res?.value === '1';
  782. if (byCategory) {
  783. this.$refs.wokePopupRef.openTwo(row);
  784. } else {
  785. const data = row.qualityWorkOrderId
  786. ? await craftFiles(row.qualityWorkOrderId)
  787. : await mesCraftFiles({
  788. taskId: row.produceTaskId,
  789. workOrderId: row.mesWorkOrderId,
  790. productCode: row.productCode
  791. });
  792. this.$refs.wokePopupRef.open(data.map((item) => item.id));
  793. }
  794. },
  795. experimentReport(row, type) {
  796. console.log(this.getSampleQuantityCount, 'this.form');
  797. this.$refs.experimentReport.open(
  798. {
  799. ...row,
  800. batchNo: this.form.batchNo,
  801. qualityWorkOrderId: this.form.qualityWorkOrderId,
  802. getSampleQuantityCount: this.form.sampleQuantity
  803. },
  804. type
  805. );
  806. },
  807. experimentReportDone(data) {
  808. console.log(data);
  809. let index = this.tableData.findIndex((item) => item.id == data.id);
  810. this.$set(this.tableData, index, data);
  811. console.log(this.tableData);
  812. // this.initData();
  813. },
  814. //当 qms_defaultDisposalType 为 true 时,损耗数自动同步合格/不合格数
  815. syncLossNumber(row, index) {
  816. if (!this.qms_defaultDisposalType) return;
  817. this.$set(
  818. this.tableData[index],
  819. 'lossNumber',
  820. Number(row.qualifiedQuantity) || 0
  821. );
  822. this.$set(
  823. this.tableData[index],
  824. 'lossNumberUnqualified',
  825. Number(row.noQualifiedQuantity) || 0
  826. );
  827. this.initData();
  828. },
  829. async open({ workData, row, list }, type, pageName) {
  830. this.tableData = [];
  831. this.pageName = pageName;
  832. this.type = type;
  833. if (pageName == 'inspectionProjectTask') {
  834. this.title = '检测项任务单';
  835. }
  836. if (pageName == 'inspectionProjectRequest') {
  837. this.title = '检测项受托单';
  838. }
  839. if (type == 'report') {
  840. let data = { ...row, ...workData };
  841. console.log(data, workData);
  842. data.sampleQuantity = row.sampleQuantity || data.workSampleCount;
  843. data.sampleNoQualifiedNumber = row.sampleNoQualifiedNumber || 0;
  844. data.sampleQualifiedNumber =
  845. row.sampleQualifiedNumber ||
  846. data.sampleQuantity - data.sampleNoQualifiedNumber ||
  847. 0;
  848. this.$set(this, 'form', JSON.parse(JSON.stringify(data)));
  849. console.log(this.form, 'this.form');
  850. this.tableData = JSON.parse(JSON.stringify(list));
  851. this.tableData.forEach((item, index) => {
  852. if (item.experimentCode) {
  853. this.$set(this.tableData[index], 'executionMethod', 2);
  854. }
  855. this.$set(
  856. this.tableData[index],
  857. 'executionMethod',
  858. item.executionMethod || 1
  859. );
  860. });
  861. // if (row.sampleQuantity) {
  862. // this.form.remainingSampleCount =
  863. // Number(row.sampleQuantity) +
  864. // Number(this.form.remainingSampleCount);
  865. // }
  866. } else {
  867. this.$set(this, 'form', JSON.parse(JSON.stringify(workData)));
  868. this.$set(
  869. this.form,
  870. 'sampleNoQualifiedNumber',
  871. this.form.sampleNoQualifiedNumber || 0
  872. );
  873. this.$set(
  874. this.form,
  875. 'sampleQualifiedNumber',
  876. this.form.sampleQualifiedNumber ||
  877. this.form.sampleQuantity - this.form.sampleNoQualifiedNumber ||
  878. 0
  879. );
  880. this.tableData = JSON.parse(JSON.stringify(list));
  881. // if (this.form.qualityWorkOrderId) {
  882. // this.form.remainingSampleCount =
  883. // this.form.sampleQuantity + this.form.remainingSampleCount;
  884. // }
  885. }
  886. //当 qms_defaultDisposalType 为 true 时,初始化时同步损耗数
  887. if (this.qms_defaultDisposalType) {
  888. this.tableData.forEach((item, index) => {
  889. this.syncLossNumber(item, index);
  890. });
  891. }
  892. this.visible = true;
  893. },
  894. handleOneKeyQualified() {
  895. this.tableData.forEach((item, index) => {
  896. this.$set(this.tableData[index], 'qualityResults', 1);
  897. });
  898. },
  899. formSampleQuantityChange() {
  900. if (this.form.sampleQuantity < 0) {
  901. this.form.sampleQuantity = 0;
  902. }
  903. if (this.form.sampleQuantity > this.form.workSampleCount) {
  904. this.form.sampleQuantity = this.form.workSampleCount;
  905. }
  906. if (
  907. this.form.sampleQuantity <
  908. Math.max(...this.tableData.map((item) => item.sampleQuantity))
  909. ) {
  910. this.tableData.forEach((item, index) => {
  911. this.resetData(item, index, [
  912. 'qualifiedQuantity',
  913. 'noQualifiedQuantity',
  914. 'sampleQuantity'
  915. ]);
  916. });
  917. }
  918. this.form.sampleQualifiedNumber = this.form.sampleQuantity;
  919. this.form.sampleNoQualifiedNumber = 0;
  920. },
  921. formSampleNoQualifiedNumberChange() {
  922. if (+this.form.sampleNoQualifiedNumber < 0) {
  923. this.form.sampleNoQualifiedNumber = 0;
  924. }
  925. if (+this.form.sampleNoQualifiedNumber > this.form.sampleQuantity) {
  926. this.form.sampleNoQualifiedNumber = this.form.sampleQuantity;
  927. }
  928. this.form.sampleQualifiedNumber =
  929. this.form.sampleQuantity - this.form.sampleNoQualifiedNumber;
  930. },
  931. handleClose() {
  932. this.visible = false;
  933. if (this.$refs.wokePopupRef) {
  934. this.$refs.wokePopupRef.visible = false;
  935. }
  936. },
  937. handleConfirm() {
  938. let isHandleConfirm = false;
  939. if (!this.form.sampleQuantity) {
  940. return this.$message.error('样品数不能为空!');
  941. }
  942. this.tableData.forEach((item, index) => {
  943. item.status = 1;
  944. if (!item.qualityResultContent) {
  945. isHandleConfirm = true;
  946. }
  947. });
  948. if (!this.pageName) {
  949. this.$emit('success', { data: this.form, tableData: this.tableData });
  950. this.visible = false;
  951. } else {
  952. if (isHandleConfirm && this.qms_qualityResultContent == 1) {
  953. return this.$message.error('检测内容不能为空!');
  954. }
  955. let api =
  956. this.pageName == 'inspectionProjectTask'
  957. ? exeTaskReportWork
  958. : exeEntrustReportWork;
  959. api({
  960. ...this.form,
  961. templateList: this.tableData
  962. }).then((res) => {
  963. this.$message.success('操作成功');
  964. this.$emit('reload');
  965. this.visible = false;
  966. });
  967. }
  968. },
  969. inputValue(type, item, index) {
  970. if (item[type] < 0) {
  971. item[type] = 0;
  972. }
  973. //样品数
  974. if (type == 'sampleQuantity') {
  975. this.isSampleQuantity(item, index);
  976. }
  977. //样品合格数、不合格数
  978. if (type == 'qualifiedQuantity' || type == 'noQualifiedQuantity') {
  979. this.isQualifiedQuantity(item, index, type);
  980. if (type == 'noQualifiedQuantity' && item[type] > 0) {
  981. this.$set(this.tableData[index], 'qualityResults', 2);
  982. }
  983. //当 qms_defaultDisposalType 为 true 时,损耗数自动同步合格/不合格数
  984. this.syncLossNumber(item, index);
  985. }
  986. //损耗数
  987. if (type == 'lossNumber' || type == 'lossNumberUnqualified') {
  988. this.setNumber(item, index, type, '损耗', 'lossNumber');
  989. }
  990. //留样数
  991. if (
  992. type == 'retainedSampleQuantity' ||
  993. type == 'retainedSampleUnqualified'
  994. ) {
  995. this.setNumber(item, index, type, '留样', 'retainedSampleQuantity');
  996. }
  997. },
  998. handleQualityResultsChange(val, row, index) {
  999. //切换到合格:把不合格数移到合格数
  1000. if (val == 1) {
  1001. if (
  1002. row.qualifiedQuantity == 0 &&
  1003. row.noQualifiedQuantity &&
  1004. row.noQualifiedQuantity != 0
  1005. ) {
  1006. this.$set(row, 'qualifiedQuantity', row.noQualifiedQuantity);
  1007. this.$set(row, 'noQualifiedQuantity', 0);
  1008. this.isQualifiedQuantity(row, index, 'qualifiedQuantity');
  1009. }
  1010. }
  1011. //切换到不合格:把合格数移到不合格数
  1012. if (val == 2) {
  1013. if (
  1014. row.noQualifiedQuantity == 0 &&
  1015. row.qualifiedQuantity &&
  1016. row.qualifiedQuantity != 0
  1017. ) {
  1018. this.$set(row, 'noQualifiedQuantity', row.qualifiedQuantity);
  1019. this.$set(row, 'qualifiedQuantity', 0);
  1020. this.isQualifiedQuantity(row, index, 'noQualifiedQuantity');
  1021. }
  1022. }
  1023. //当 qms_defaultDisposalType 为 true 时,损耗数自动同步合格/不合格数
  1024. this.syncLossNumber(row, index);
  1025. }
  1026. },
  1027. watch: {
  1028. tableData: {
  1029. deep: true,
  1030. handler(newVal) {
  1031. if (!newVal || !newVal.length) {
  1032. this.form.sampleNoQualifiedNumber = 0;
  1033. this.form.sampleQualifiedNumber = this.form.sampleQuantity || 0;
  1034. return;
  1035. }
  1036. const maxNoQualified = newVal.reduce((max, item) => {
  1037. const val = Number(item.noQualifiedQuantity) || 0;
  1038. return val > max ? val : max;
  1039. }, 0);
  1040. this.$set(this.form, 'sampleNoQualifiedNumber', maxNoQualified);
  1041. const qualifiedNumber =
  1042. (Number(this.form.sampleQuantity) || 0) - maxNoQualified;
  1043. if (qualifiedNumber < 0) {
  1044. this.$message.warning('样品合格数不能小于0');
  1045. this.$set(this.form, 'sampleQualifiedNumber', 0);
  1046. } else {
  1047. this.$set(this.form, 'sampleQualifiedNumber', qualifiedNumber);
  1048. }
  1049. }
  1050. }
  1051. }
  1052. };
  1053. </script>
  1054. <style scoped lang="scss">
  1055. ::v-deep .warn {
  1056. color: red;
  1057. .el-input__inner {
  1058. color: red;
  1059. }
  1060. }
  1061. </style>