newQualityContentTabs.vue 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860
  1. <!-- 质检内容 -->
  2. <template>
  3. <el-row>
  4. <!-- 选择质检方案 -->
  5. <inspectionTemplateDialog
  6. ref="inspectionTemplateRef"
  7. @choose="inspectionTemplateSuccess"
  8. ></inspectionTemplateDialog>
  9. <header-title title="检测内容">
  10. <el-button
  11. type="primary"
  12. :loading="loading"
  13. v-if="type != 'detail'"
  14. @click="$emit('batch-quality')"
  15. >批量检测</el-button
  16. >
  17. <!-- <el-button
  18. type="primary"
  19. :loading="loading"
  20. v-if="type != 'detail'"
  21. @click="$emit('batch-dispose')"
  22. >批量处置</el-button
  23. > -->
  24. </header-title>
  25. <el-tabs v-model="activeNameKK" @tab-click="handleClick">
  26. <!-- -->
  27. <el-tab-pane label="来源清单" name="1">
  28. <ele-pro-table
  29. ref="sourceTable"
  30. :columns="tableColumns1"
  31. :datasource="datasource"
  32. @selection-change="handleSelectionChange"
  33. :initLoad="false"
  34. :needPage="false"
  35. height="500px"
  36. >
  37. <!-- :pagination="true" -->
  38. <!-- <template
  39. v-slot:toolbar
  40. v-if="form.qualityMode == 2 && type != 'detail'"
  41. >
  42. <el-dropdown trigger="click" @command="handleSampleNumber">
  43. <el-link type="primary" icon="el-icon-plus">取样</el-link>
  44. <el-dropdown-menu slot="dropdown">
  45. <el-dropdown-item command="1">取整样</el-dropdown-item>
  46. <el-dropdown-item command="2">取小样</el-dropdown-item>
  47. </el-dropdown-menu>
  48. </el-dropdown>
  49. </template> -->
  50. <template v-slot:toolkit v-if="form.qualityMode == 2">
  51. <el-row>
  52. <el-form
  53. ref="ruleForm"
  54. :model="formData"
  55. label-width="60px"
  56. size="mini"
  57. :rules="rules"
  58. class="flex"
  59. :show-message="false"
  60. >
  61. <el-col :span="6" v-if="conditionType == 2">
  62. <el-form-item
  63. prop="number"
  64. label-width="0"
  65. style="margin-bottom: 0"
  66. >
  67. <el-input
  68. v-model="formData.number"
  69. placeholder="请输入"
  70. size="mini"
  71. ></el-input>
  72. </el-form-item>
  73. </el-col>
  74. <el-col :span="6" v-if="conditionType == 2">
  75. <el-form-item
  76. prop="sampleUnit"
  77. label-width="0"
  78. style="margin: 0"
  79. >
  80. <DictSelection
  81. dictName="计量单位"
  82. clearable
  83. v-model="formData.sampleUnit"
  84. size="mini"
  85. filter-placeholder="请输入计量单位搜索"
  86. @change="changeSamUnit"
  87. ></DictSelection>
  88. </el-form-item>
  89. </el-col>
  90. <el-col :span="8" v-if="conditionType == 2">
  91. <el-form-item prop="portion" label="数量" style="margin: 0">
  92. <el-input
  93. v-model="formData.portion"
  94. placeholder="请输入"
  95. size="mini"
  96. ></el-input>
  97. </el-form-item>
  98. </el-col>
  99. <el-col :span="10" v-if="conditionType == 1">
  100. <el-form-item prop="portion" label="数量" style="margin: 0">
  101. <el-input
  102. v-model="formData.portion"
  103. placeholder="请输入"
  104. size="mini"
  105. ></el-input>
  106. </el-form-item>
  107. </el-col>
  108. <el-col :span="10" v-if="conditionType == 1">
  109. <el-form-item
  110. prop="packingUnit"
  111. label="单位"
  112. style="margin: 0"
  113. >
  114. <el-select
  115. v-model="formData.packingUnit"
  116. placeholder="请选择"
  117. >
  118. <el-option
  119. v-for="item in packingSpecificationOption"
  120. :key="item.id"
  121. :label="item.conversionUnit"
  122. :value="item.id"
  123. >
  124. </el-option>
  125. </el-select>
  126. </el-form-item>
  127. </el-col>
  128. <el-col
  129. :span="4"
  130. style="text-align: right"
  131. v-if="conditionType == 2"
  132. >
  133. <el-button
  134. type="primary"
  135. size="mini"
  136. @click="handleSampleSubmit"
  137. style="margin-right: 12px"
  138. >确认</el-button
  139. >
  140. </el-col>
  141. <el-col
  142. :span="4"
  143. style="text-align: right"
  144. v-if="conditionType == 1"
  145. >
  146. <el-button
  147. type="primary"
  148. size="mini"
  149. @click="handleSampleSubmit"
  150. style="margin-right: 12px"
  151. >确认</el-button
  152. >
  153. </el-col>
  154. </el-form>
  155. </el-row>
  156. </template>
  157. <template v-slot:materielDesignation="{ row }">
  158. <el-input
  159. v-model="row.materielDesignation"
  160. placeholder="请输入"
  161. ></el-input>
  162. </template>
  163. <template v-slot:clientCode="{ row }">
  164. <el-input v-model="row.clientCode" placeholder="请输入"></el-input>
  165. </template>
  166. <template v-slot:engrave="{ row }">
  167. <el-input v-model="row.engrave" placeholder="请输入"></el-input>
  168. </template>
  169. <template v-slot:weight="{ row }">
  170. <el-input v-model="row.weight" placeholder="请输入"></el-input>
  171. </template>
  172. </ele-pro-table>
  173. </el-tab-pane>
  174. <!-- -->
  175. <el-tab-pane label="样品清单" name="2">
  176. <el-table
  177. v-if="sampleList.length > 0"
  178. ref="showSampleListTable"
  179. :data="paginatedSampleList"
  180. tooltip-effect="dark"
  181. height="500"
  182. border
  183. row-key="id"
  184. >
  185. <el-table-column
  186. label="序号"
  187. type="index"
  188. width="50"
  189. align="center"
  190. fixed="left"
  191. ></el-table-column>
  192. <template v-for="(column, index) in tableColumns">
  193. <el-table-column
  194. :key="index"
  195. :label="column.label"
  196. :prop="column.prop"
  197. :fixed="column.fixed"
  198. :show-overflow-tooltip="true"
  199. :width="column.width"
  200. :align="column.align"
  201. >
  202. <template slot-scope="scope">
  203. <template v-if="column.prop === 'categoryCode'">
  204. <el-link
  205. type="primary"
  206. :underline="false"
  207. @click="handleDetail(scope.$index, scope.row, 'detail')"
  208. >
  209. {{ scope.row.categoryCode }}
  210. </el-link>
  211. </template>
  212. <template v-else-if="column.prop === 'materielDesignation'">
  213. <el-input
  214. :disabled="status"
  215. v-model="scope.row.materielDesignation"
  216. size="mini"
  217. v-direction="{ x: 0, y: scope.$index }"
  218. ></el-input>
  219. </template>
  220. <template v-else-if="column.prop === 'clientCode'">
  221. <el-input
  222. :disabled="status"
  223. v-model="scope.row.clientCode"
  224. size="mini"
  225. v-direction="{ x: 1, y: scope.$index }"
  226. ></el-input>
  227. </template>
  228. <template v-else-if="column.prop === 'engrave'">
  229. <el-input
  230. :disabled="status"
  231. v-model="scope.row.engrave"
  232. size="mini"
  233. v-direction="{ x: 2, y: scope.$index }"
  234. ></el-input>
  235. </template>
  236. <template v-else-if="column.prop === 'weight'">
  237. <el-input
  238. v-model="scope.row.weight"
  239. :disabled="status"
  240. oninput="value = value.replace(/[^\d.]/g, '')"
  241. :min="0"
  242. @input="inputWeight(scope.row, scope.$index)"
  243. size="mini"
  244. v-direction="{ x: 3, y: scope.$index }"
  245. ></el-input>
  246. </template>
  247. <template v-else>
  248. {{ scope.row[column.prop] }}
  249. </template>
  250. </template>
  251. </el-table-column>
  252. </template>
  253. <!-- *** fixed="right" -->
  254. <el-table-column
  255. label="处置状态"
  256. prop="disposeType"
  257. align="center"
  258. :show-overflow-tooltip="true"
  259. >
  260. <template slot-scope="scope">
  261. <span>{{ disposeTypeList[scope.row.disposeType] }}</span>
  262. </template>
  263. </el-table-column>
  264. <!-- *** fixed="right" -->
  265. <el-table-column
  266. label="处置时间"
  267. prop="disposeTime"
  268. align="center"
  269. :show-overflow-tooltip="true"
  270. >
  271. </el-table-column>
  272. <!-- *** fixed="right" -->
  273. <el-table-column
  274. label="状态"
  275. prop="status"
  276. align="center"
  277. fixed="right"
  278. :show-overflow-tooltip="true"
  279. v-if="form.recordingMethod != 1"
  280. >
  281. <template slot-scope="scope">
  282. {{
  283. inspectionProjectStatus.find(
  284. (item) => item.value == scope.row.status
  285. )?.label
  286. }}
  287. </template>
  288. </el-table-column>
  289. <!-- <el-table-column
  290. label="质检状态"
  291. prop="qualityStatus"
  292. align="center"
  293. fixed="right"
  294. :show-overflow-tooltip="true"
  295. v-if="form.recordingMethod != 1"
  296. >
  297. <template slot-scope="scope">
  298. <span v-if="scope.row.qualityStatus == 0">未检</span>
  299. <span v-if="scope.row.qualityStatus == 1">已检</span>
  300. <span v-if="scope.row.qualityStatus == 2">待检</span>
  301. </template>
  302. </el-table-column> -->
  303. <el-table-column
  304. label="检测结果"
  305. prop="qualityResults"
  306. align="center"
  307. width="180"
  308. fixed="right"
  309. :show-overflow-tooltip="true"
  310. v-if="form.recordingMethod != 1"
  311. >
  312. <template slot-scope="scope">
  313. <el-select
  314. @change="selectQualityResultsChange"
  315. v-model="scope.row.qualityResults"
  316. placeholder="请选择"
  317. style="width: 100%"
  318. :disabled="type == 'detail' || scope.row.correlationId"
  319. size="mini"
  320. >
  321. <el-option
  322. v-for="item in qualityResultsList"
  323. :key="item.value"
  324. :label="item.label"
  325. :value="item.value"
  326. >
  327. </el-option>
  328. </el-select>
  329. </template>
  330. </el-table-column>
  331. <el-table-column
  332. label="不良类型"
  333. align="center"
  334. v-if="form.recordingMethod != 1"
  335. prop="badTypeId"
  336. width="180"
  337. >
  338. <template v-slot="{ row, $index }">
  339. <el-select
  340. v-model="row.badTypeId"
  341. placeholder="请选择不良类型"
  342. size="small"
  343. style="width: 100%"
  344. remote
  345. filterable
  346. clearable
  347. @change="badTypeChange(row)"
  348. :disabled="type == 'detail' || row.correlationId"
  349. >
  350. <el-option
  351. v-for="item in badTypeList"
  352. :key="item.id"
  353. :label="item.name"
  354. :value="item.id"
  355. >
  356. </el-option>
  357. </el-select>
  358. </template>
  359. </el-table-column>
  360. <el-table-column
  361. label="不良名称"
  362. align="center"
  363. prop="badNameId"
  364. width="180"
  365. v-if="form.recordingMethod != 1"
  366. >
  367. <template v-slot="{ row, $index }">
  368. <el-select
  369. v-model="row.badNameId"
  370. placeholder="请选择不良名称"
  371. size="small"
  372. style="width: 100%"
  373. remote
  374. filterable
  375. clearable
  376. @change="badNameChange(row)"
  377. :disabled="type == 'detail' || row.correlationId"
  378. >
  379. <el-option
  380. v-for="item in badNameList"
  381. :key="item.id"
  382. :label="item.name"
  383. :value="item.id"
  384. >
  385. </el-option>
  386. </el-select>
  387. </template>
  388. </el-table-column>
  389. <el-table-column
  390. label="操作"
  391. align="center"
  392. width="120"
  393. fixed="right"
  394. v-if="type != 'detail' && form.recordingMethod != 1"
  395. >
  396. <template slot-scope="scope">
  397. <el-link
  398. :type="scope.row.isValid ? 'primary' : 'danger'"
  399. :underline="false"
  400. v-if="!scope.row.correlationId"
  401. @click="handleDetail(scope.$index, scope.row, 'report')"
  402. >
  403. 检测
  404. </el-link>
  405. <!-- <el-link
  406. type="primary"
  407. :underline="false"
  408. @click="handleDispose(scope.$index, scope.row, 'dispose')"
  409. >处置
  410. </el-link> -->
  411. </template>
  412. </el-table-column>
  413. </el-table>
  414. <!-- <el-pagination
  415. @size-change="handleSampleSizeChange"
  416. @current-change="handleSampleCurrentChange"
  417. :current-page="samplePagination.currentPage"
  418. :page-sizes="[10, 20, 50, 100]"
  419. :page-size="samplePagination.pageSize"
  420. layout="total, sizes, prev, pager, next, jumper"
  421. :total="sampleList.length"
  422. /> -->
  423. </el-tab-pane>
  424. <!-- -->
  425. <el-tab-pane label="检测方案" name="3">
  426. <el-button
  427. v-if="type !== 'detail'"
  428. @click="addInspectionTemplate"
  429. type="primary"
  430. style="margin-top: 5px"
  431. >选择检测方案</el-button
  432. >
  433. <el-button
  434. v-if="type !== 'detail'"
  435. @click="delAll"
  436. type="danger"
  437. style="margin-top: 5px"
  438. >批量删除</el-button
  439. >
  440. <el-table
  441. :data="paginatedSchemeList"
  442. tooltip-effect="dark"
  443. height="500"
  444. border
  445. row-key="id"
  446. @selection-change="handleSelectionChange1"
  447. >
  448. <el-table-column
  449. type="selection"
  450. width="55"
  451. align="center"
  452. :selectable="
  453. (row) => {
  454. return type == 'detail' || ![1, 2, 3, 4].includes(row.status);
  455. }
  456. "
  457. >
  458. </el-table-column>
  459. <el-table-column
  460. label="序号"
  461. type="index"
  462. width="50"
  463. align="center"
  464. ></el-table-column>
  465. <el-table-column
  466. label="检测方案编码"
  467. prop="qualitySchemeTemplateCode"
  468. align="center"
  469. >
  470. </el-table-column>
  471. <el-table-column
  472. label="检测方案名称"
  473. prop="qualitySchemeTemplateName"
  474. align="center"
  475. ></el-table-column>
  476. <el-table-column
  477. label="检测类型"
  478. prop="categoryLevelClassName"
  479. align="center"
  480. ></el-table-column>
  481. <el-table-column
  482. label="检测项编码"
  483. prop="inspectionCode"
  484. align="center"
  485. ></el-table-column>
  486. <el-table-column
  487. label="检测项名称"
  488. prop="inspectionName"
  489. align="center"
  490. ></el-table-column>
  491. <el-table-column label="附件" prop="imgUrl" align="center">
  492. <template slot-scope="scope">
  493. <fileMain v-model="scope.row.imgUrl" type="view"></fileMain>
  494. </template>
  495. </el-table-column>
  496. <el-table-column
  497. label="工艺参数"
  498. show-overflow-tooltip
  499. prop="defaultValue"
  500. align="center"
  501. >
  502. <template slot-scope="scope">
  503. <div style="display: flex; justify-content: center">
  504. <span>{{ scope.row.symbol }}</span>
  505. <span v-if="scope.row.textType == 3">
  506. {{ scope.row.minValue }}-{{ scope.row.maxValue }}
  507. </span>
  508. <span v-else>
  509. <span>{{ scope.row.defaultValue }}</span>
  510. </span>
  511. {{ scope.row.unitName }}
  512. </div>
  513. </template>
  514. </el-table-column>
  515. <el-table-column
  516. label="执行方法"
  517. prop="executionMethod"
  518. align="center"
  519. :show-overflow-tooltip="true"
  520. v-if="form.recordingMethod == 1"
  521. >
  522. <template slot-scope="scope">
  523. {{ scope.row.executionMethod == 1 ? '常规' : '实验' }}
  524. </template></el-table-column
  525. >
  526. <el-table-column
  527. label="检测状态"
  528. prop="status"
  529. align="center"
  530. :show-overflow-tooltip="true"
  531. v-if="form.recordingMethod == 1"
  532. >
  533. <template slot-scope="scope">
  534. {{
  535. inspectionProjectStatus.find(
  536. (item) => item.value == scope.row.status
  537. )?.label
  538. }}
  539. </template>
  540. </el-table-column>
  541. <el-table-column
  542. label="检测结果"
  543. prop="qualityResults"
  544. align="center"
  545. width="180"
  546. :show-overflow-tooltip="true"
  547. v-if="form.recordingMethod == 1"
  548. >
  549. <template slot-scope="scope">
  550. <el-select
  551. @change="selectQualityResultsChange"
  552. v-model="scope.row.qualityResults"
  553. placeholder="请选择"
  554. style="width: 100%"
  555. :disabled="
  556. type == 'detail' || [2, 3, 4].includes(scope.row.status)
  557. "
  558. size="mini"
  559. >
  560. <el-option
  561. v-for="item in qualityResultsList"
  562. :key="item.value"
  563. :label="item.label"
  564. :value="item.value"
  565. >
  566. </el-option>
  567. </el-select>
  568. </template>
  569. </el-table-column>
  570. <el-table-column label="操作" width="150" v-if="type !== 'detail'">
  571. <template slot-scope="scope">
  572. <!-- <el-link
  573. v-if="form.recordingMethod == 1"
  574. :type="scope.row.isValid ? 'primary' : 'danger'"
  575. :underline="false"
  576. @click="inspectionProjectReport(scope.$index, scope.row)"
  577. >
  578. 质检
  579. </el-link> -->
  580. <el-popconfirm
  581. class="ele-action"
  582. title="确定要删除当前方案吗?"
  583. @confirm="handDel(scope.$index)"
  584. v-if="![1, 2, 3, 4].includes(scope.row.status)"
  585. >
  586. <template v-slot:reference>
  587. <el-link
  588. type="danger"
  589. :underline="false"
  590. icon="el-icon-delete"
  591. >
  592. 删除
  593. </el-link>
  594. </template>
  595. </el-popconfirm>
  596. </template>
  597. </el-table-column>
  598. </el-table>
  599. <!-- <el-pagination
  600. @size-change="handleSchemeSizeChange"
  601. @current-change="handleSchemeCurrentChange"
  602. :current-page="schemePagination.currentPage"
  603. :page-sizes="[10, 20, 50, 100]"
  604. :page-size="schemePagination.pageSize"
  605. layout="total, sizes, prev, pager, next, jumper"
  606. :total="schemeList.length"
  607. /> -->
  608. </el-tab-pane>
  609. <el-tab-pane label="检测任务单" name="4">
  610. <ele-pro-table
  611. ref="table"
  612. :columns="taskColumns"
  613. :datasource="form.taskMonadList"
  614. :needPage="false"
  615. >
  616. </ele-pro-table>
  617. </el-tab-pane>
  618. <el-tab-pane label="检测请托单" name="5">
  619. <ele-pro-table
  620. ref="table"
  621. :columns="entrustColumns"
  622. :datasource="form.requestEntrustList"
  623. :needPage="false"
  624. >
  625. </ele-pro-table>
  626. </el-tab-pane>
  627. <el-tab-pane label="工艺文件" name="6">
  628. <wokePopupList ref="wokePopupListRef"></wokePopupList>
  629. </el-tab-pane>
  630. </el-tabs>
  631. </el-row>
  632. </template>
  633. <script>
  634. import inspectionTemplateDialog from '@/views/inspectionTemplate/components/inspectionTemplateDialog.vue';
  635. import wokePopupList from '@/components/workList/wokePopupList.vue';
  636. import { parameterGetByCode } from '@/api/main/index';
  637. import {
  638. getDetails,
  639. getCategoryPackageDisposition
  640. } from '@/api/classifyManage/itemInformation';
  641. import {
  642. save,
  643. update,
  644. getById,
  645. exeReportWork,
  646. queryQualitySamplContent,
  647. queryQualityTempleContent,
  648. queryQualityInventory,
  649. newFilePageAPI
  650. } from '@/api/inspectionWork';
  651. import { getQualityTemplateByIds } from '@/api/inspectionTemplate';
  652. import { getCodeList } from '@/api/login';
  653. import { inspectionProjectStatus } from '@/enum/dict.js';
  654. import dictMixins from '@/mixins/dictMixins';
  655. import { getList as getBadNameList } from '@/api/unacceptedProduct/unqualifiedName';
  656. import { getList as getBadTypeList } from '@/api/unacceptedProduct/unqualifiedType';
  657. export default {
  658. mixins: [dictMixins],
  659. components: {
  660. inspectionTemplateDialog,
  661. wokePopupList
  662. },
  663. watch: {
  664. schemeList: {
  665. handler(newVal, oldVal) {
  666. this.templateList = newVal;
  667. // console.log(newVal, 'schemeList');
  668. },
  669. deep: true,
  670. immediate: true
  671. },
  672. activeName: {
  673. handler(newVal) {
  674. this.activeNameKK = newVal;
  675. // console.log(newVal);
  676. }
  677. }
  678. },
  679. props: {
  680. type: String,
  681. packingList: Array,
  682. sampleList: Array,
  683. schemeList: Array,
  684. fileParam: Array,
  685. loading: Boolean,
  686. form: Object,
  687. ids: String,
  688. activeName: String,
  689. status: Boolean,
  690. productId: {
  691. type: String,
  692. default: ''
  693. }
  694. },
  695. data() {
  696. return {
  697. // 不良品类型列表
  698. fileTableList: [],
  699. selection1: [],
  700. badTypeList: [],
  701. // 不良名称列表
  702. badNameList: [],
  703. inspectionProjectStatus,
  704. disposeTypeList: {
  705. 1: '返工',
  706. 2: '返修',
  707. 3: '报废',
  708. 4: '降级使用',
  709. 5: '让步接收',
  710. 6: '留样',
  711. 7: '消耗',
  712. 8: '回用/归批',
  713. 9: '转试销',
  714. 10: '退货'
  715. },
  716. templateList: [],
  717. planTemplateList: [],
  718. activeNameKK: '',
  719. samplePagination: { currentPage: 1, pageSize: 10 },
  720. schemePagination: { currentPage: 1, pageSize: 10 },
  721. qualityResultsList: [
  722. {
  723. value: 1,
  724. label: '合格'
  725. },
  726. {
  727. value: 2,
  728. label: '不合格'
  729. },
  730. {
  731. value: 3,
  732. label: '让步接收'
  733. }
  734. ],
  735. tableColumns: [
  736. {
  737. label: '样品编码',
  738. prop: 'sampleCode',
  739. width: '200',
  740. align: 'center',
  741. fixed: 'left'
  742. },
  743. {
  744. label: '编码',
  745. prop: 'categoryCode',
  746. align: 'center',
  747. fixed: 'left'
  748. },
  749. {
  750. label: '名称',
  751. prop: 'categoryName',
  752. align: 'center'
  753. },
  754. { label: '批次号', prop: 'batchNo', align: 'center' },
  755. { label: '发货条码', prop: 'barcodes', align: 'center' },
  756. { label: '包装编码', prop: 'packageNo', align: 'center' },
  757. { label: '包装数量', prop: 'packingQuantity', align: 'center' },
  758. { label: '包装单位', prop: 'packingUnit', align: 'center' },
  759. { label: '计量数量', prop: 'measureQuantity', align: 'center' },
  760. { label: '计量单位', prop: 'measureUnit', align: 'center' },
  761. {
  762. label: '供应商名称',
  763. prop: 'supplierName',
  764. align: 'center',
  765. width: '120'
  766. },
  767. {
  768. label: '供应商代号',
  769. prop: 'supplierCode',
  770. align: 'center',
  771. width: '120'
  772. },
  773. {
  774. label: '物料代号',
  775. prop: 'materielDesignation',
  776. align: 'center',
  777. slot: 'materielDesignation',
  778. width: '120'
  779. },
  780. {
  781. label: '客户代号',
  782. prop: 'clientCode',
  783. align: 'center',
  784. slot: 'clientCode',
  785. width: '120'
  786. },
  787. {
  788. label: '刻码',
  789. prop: 'engrave',
  790. align: 'center',
  791. slot: 'engrave',
  792. width: '120'
  793. },
  794. {
  795. label: '机型',
  796. prop: 'modelKey',
  797. align: 'center',
  798. showOverflowTooltip: true
  799. },
  800. {
  801. label: '颜色',
  802. prop: 'colorKey',
  803. align: 'center',
  804. showOverflowTooltip: true
  805. },
  806. {
  807. label: '型号',
  808. prop: 'modelType',
  809. align: 'center',
  810. showOverflowTooltip: true
  811. },
  812. {
  813. label: '规格',
  814. prop: 'specification',
  815. align: 'center',
  816. showOverflowTooltip: true
  817. },
  818. {
  819. label: '电压等级',
  820. prop: 'voltage',
  821. align: 'center',
  822. showOverflowTooltip: true
  823. },
  824. {
  825. label: '重量',
  826. prop: 'weight',
  827. align: 'center',
  828. slot: 'weight',
  829. width: '120'
  830. },
  831. {
  832. label: '重量单位',
  833. prop: 'weightUnit',
  834. align: 'center',
  835. width: 100
  836. },
  837. { label: '仓库', prop: 'warehouseName', align: 'center', width: 100 },
  838. { label: '货区', prop: 'areaName', align: 'center' },
  839. { label: '货架', prop: 'goodsShelfName', align: 'center' },
  840. { label: '货位', prop: 'goodsAllocationName', align: 'center' },
  841. { label: '生产日期', prop: 'productionDate', align: 'center' },
  842. { label: '采购日期', prop: 'purchaseDate', align: 'center' }
  843. ],
  844. entrustColumns: [
  845. {
  846. columnKey: 'index',
  847. label: '序号',
  848. type: 'index',
  849. width: 55,
  850. align: 'center',
  851. showOverflowTooltip: true,
  852. fixed: 'left'
  853. },
  854. {
  855. prop: 'code',
  856. label: '请托单号',
  857. showOverflowTooltip: true,
  858. align: 'center',
  859. minWidth: 130
  860. },
  861. {
  862. prop: 'name',
  863. label: '任务名称',
  864. showOverflowTooltip: true,
  865. align: 'center',
  866. minWidth: 110
  867. },
  868. {
  869. prop: 'sampleQuantity',
  870. label: '样品数',
  871. showOverflowTooltip: true,
  872. align: 'center',
  873. formatter: (row) => {
  874. if (row.sampleQuantity) {
  875. return (
  876. row.sampleQuantity + this.sampleList[0]?.measureUnit || ''
  877. );
  878. }
  879. },
  880. minWidth: 110
  881. },
  882. {
  883. prop: 'sampleQualifiedNumber',
  884. label: '样品合格数',
  885. showOverflowTooltip: true,
  886. align: 'center',
  887. formatter: (row) => {
  888. if (row.sampleQualifiedNumber) {
  889. return (
  890. row.sampleQualifiedNumber + this.sampleList[0]?.measureUnit ||
  891. ''
  892. );
  893. }
  894. },
  895. minWidth: 110
  896. },
  897. {
  898. prop: 'sampleNoQualifiedNumber',
  899. label: '样品不合格数',
  900. showOverflowTooltip: true,
  901. align: 'center',
  902. formatter: (row) => {
  903. if (row.sampleNoQualifiedNumber) {
  904. return (
  905. row.sampleNoQualifiedNumber +
  906. this.sampleList[0]?.measureUnit || ''
  907. );
  908. }
  909. },
  910. minWidth: 110
  911. },
  912. {
  913. prop: 'lossNumber',
  914. label: '损耗数(合格品)',
  915. showOverflowTooltip: true,
  916. align: 'center',
  917. formatter: (row) => {
  918. if (row.lossNumber) {
  919. return row.lossNumber + this.sampleList[0]?.measureUnit || '';
  920. }
  921. },
  922. minWidth: 110
  923. },
  924. {
  925. prop: 'lossNumberUnqualified',
  926. label: '损耗数(不合格品)',
  927. showOverflowTooltip: true,
  928. align: 'center',
  929. formatter: (row) => {
  930. if (row.lossNumberUnqualified) {
  931. return (
  932. row.lossNumberUnqualified + this.sampleList[0]?.measureUnit ||
  933. ''
  934. );
  935. }
  936. },
  937. minWidth: 110
  938. },
  939. {
  940. prop: 'retainedSampleQuantity',
  941. label: '留样数(合格品)',
  942. showOverflowTooltip: true,
  943. align: 'center',
  944. formatter: (row) => {
  945. if (row.retainedSampleQuantity) {
  946. return (
  947. row.retainedSampleQuantity +
  948. this.sampleList[0]?.measureUnit || ''
  949. );
  950. }
  951. },
  952. minWidth: 110
  953. },
  954. {
  955. prop: 'retainedSampleUnqualified',
  956. label: '留样数(不合格品)',
  957. formatter: (row) => {
  958. if (row.retainedSampleUnqualified) {
  959. return (
  960. row.retainedSampleUnqualified +
  961. this.sampleList[0]?.measureUnit || ''
  962. );
  963. }
  964. },
  965. showOverflowTooltip: true,
  966. align: 'center',
  967. minWidth: 110
  968. },
  969. {
  970. prop: 'status',
  971. minWidth: 110,
  972. label: '状态',
  973. align: 'center',
  974. formatter: (row) => {
  975. return row.status == 0
  976. ? '待收样'
  977. : row.status == 1
  978. ? '未报工'
  979. : '已报工';
  980. },
  981. showOverflowTooltip: true
  982. }
  983. ],
  984. taskColumns: [
  985. {
  986. columnKey: 'index',
  987. label: '序号',
  988. type: 'index',
  989. width: 55,
  990. align: 'center',
  991. showOverflowTooltip: true,
  992. fixed: 'left'
  993. },
  994. {
  995. prop: 'code',
  996. label: '检测任务单号',
  997. showOverflowTooltip: true,
  998. align: 'center',
  999. minWidth: 130
  1000. },
  1001. {
  1002. prop: 'name',
  1003. label: '任务名称',
  1004. showOverflowTooltip: true,
  1005. align: 'center',
  1006. minWidth: 110
  1007. },
  1008. {
  1009. prop: 'sampleQuantity',
  1010. label: '样品数',
  1011. showOverflowTooltip: true,
  1012. align: 'center',
  1013. formatter: (row) => {
  1014. if (row.sampleQuantity) {
  1015. return (
  1016. row.sampleQuantity + this.sampleList[0]?.measureUnit || ''
  1017. );
  1018. }
  1019. },
  1020. minWidth: 110
  1021. },
  1022. {
  1023. prop: 'sampleQualifiedNumber',
  1024. label: '样品合格数',
  1025. showOverflowTooltip: true,
  1026. align: 'center',
  1027. formatter: (row) => {
  1028. if (row.sampleQualifiedNumber) {
  1029. return (
  1030. row.sampleQualifiedNumber + this.sampleList[0]?.measureUnit ||
  1031. ''
  1032. );
  1033. }
  1034. },
  1035. minWidth: 110
  1036. },
  1037. {
  1038. prop: 'sampleNoQualifiedNumber',
  1039. label: '样品不合格数',
  1040. showOverflowTooltip: true,
  1041. align: 'center',
  1042. formatter: (row) => {
  1043. if (row.sampleNoQualifiedNumber) {
  1044. return (
  1045. row.sampleNoQualifiedNumber +
  1046. this.sampleList[0]?.measureUnit || ''
  1047. );
  1048. }
  1049. },
  1050. minWidth: 110
  1051. },
  1052. {
  1053. prop: 'lossNumber',
  1054. label: '损耗数(合格品)',
  1055. showOverflowTooltip: true,
  1056. align: 'center',
  1057. formatter: (row) => {
  1058. if (row.lossNumber) {
  1059. return row.lossNumber + this.sampleList[0]?.measureUnit || '';
  1060. }
  1061. },
  1062. minWidth: 110
  1063. },
  1064. {
  1065. prop: 'lossNumberUnqualified',
  1066. label: '损耗数(不合格品)',
  1067. showOverflowTooltip: true,
  1068. align: 'center',
  1069. formatter: (row) => {
  1070. if (row.lossNumberUnqualified) {
  1071. return (
  1072. row.lossNumberUnqualified + this.sampleList[0]?.measureUnit ||
  1073. ''
  1074. );
  1075. }
  1076. },
  1077. minWidth: 110
  1078. },
  1079. {
  1080. prop: 'retainedSampleQuantity',
  1081. label: '留样数(合格品)',
  1082. showOverflowTooltip: true,
  1083. align: 'center',
  1084. formatter: (row) => {
  1085. if (row.retainedSampleQuantity) {
  1086. return (
  1087. row.retainedSampleQuantity +
  1088. this.sampleList[0]?.measureUnit || ''
  1089. );
  1090. }
  1091. },
  1092. minWidth: 110
  1093. },
  1094. {
  1095. prop: 'retainedSampleUnqualified',
  1096. label: '留样数(不合格品)',
  1097. formatter: (row) => {
  1098. if (row.retainedSampleUnqualified) {
  1099. return (
  1100. row.retainedSampleUnqualified +
  1101. this.sampleList[0]?.measureUnit || ''
  1102. );
  1103. }
  1104. },
  1105. showOverflowTooltip: true,
  1106. align: 'center',
  1107. minWidth: 110
  1108. },
  1109. {
  1110. prop: 'status',
  1111. minWidth: 110,
  1112. label: '状态',
  1113. align: 'center',
  1114. formatter: (row) => {
  1115. return row.status == 0
  1116. ? '待收样'
  1117. : row.status == 1
  1118. ? '未报工'
  1119. : '已报工';
  1120. },
  1121. showOverflowTooltip: true
  1122. }
  1123. ],
  1124. // 表格选中数据
  1125. jobColumns1: [
  1126. {
  1127. label: '编码',
  1128. prop: 'code',
  1129. width: 180,
  1130. align: 'center',
  1131. showOverflowTooltip: true
  1132. },
  1133. {
  1134. prop: 'name',
  1135. label: '文档名称',
  1136. align: 'center',
  1137. slot: 'name',
  1138. showOverflowTooltip: true,
  1139. minWidth: 200
  1140. },
  1141. {
  1142. prop: 'storagePath',
  1143. label: '文件名称',
  1144. align: 'center',
  1145. showOverflowTooltip: true,
  1146. minWidth: 200,
  1147. formatter: (_row, _column, cellValue) => {
  1148. return cellValue[0]?.name;
  1149. }
  1150. },
  1151. {
  1152. prop: 'version',
  1153. label: '版本',
  1154. align: 'center',
  1155. showOverflowTooltip: true,
  1156. minWidth: 100
  1157. },
  1158. {
  1159. prop: 'createTime',
  1160. label: '创建时间',
  1161. showOverflowTooltip: true,
  1162. align: 'center',
  1163. minWidth: 110
  1164. },
  1165. {
  1166. columnKey: 'action',
  1167. label: '操作',
  1168. width: 100,
  1169. align: 'center',
  1170. resizable: false,
  1171. slot: 'action',
  1172. showOverflowTooltip: true
  1173. }
  1174. ],
  1175. conditionType: null,
  1176. formData: {
  1177. number: 1,
  1178. sampleUnit: '',
  1179. portion: null,
  1180. packingUnit: ''
  1181. },
  1182. rules: {
  1183. number: [
  1184. {
  1185. required: true,
  1186. message: '请输入',
  1187. trigger: 'blur'
  1188. }
  1189. ],
  1190. sampleUnit: [
  1191. {
  1192. required: true,
  1193. message: '请选择样品单位',
  1194. trigger: 'change'
  1195. }
  1196. ],
  1197. portion: [
  1198. {
  1199. required: true,
  1200. message: '请输入',
  1201. trigger: 'blur'
  1202. }
  1203. ],
  1204. packingUnit: [
  1205. {
  1206. required: true,
  1207. message: '请选择',
  1208. trigger: 'change'
  1209. }
  1210. ]
  1211. },
  1212. packingSpecificationOption: [] // 包装规格下拉
  1213. };
  1214. },
  1215. computed: {
  1216. showBtn() {
  1217. return this.$route.query.qualityType == 2;
  1218. },
  1219. tableColumns1() {
  1220. let arr = [
  1221. // (this.btnType !== 'issued' || this.baseForm.qualityMode === 2)
  1222. // ? {
  1223. // columnKey: 'selection',
  1224. // type: 'selection',
  1225. // width: 45,
  1226. // align: 'center'
  1227. // }
  1228. // : null,
  1229. {
  1230. columnKey: 'selection',
  1231. type: 'selection',
  1232. width: 45,
  1233. align: 'center'
  1234. },
  1235. {
  1236. columnKey: 'index',
  1237. label: '序号',
  1238. type: 'index',
  1239. width: 55,
  1240. align: 'center',
  1241. fixed: 'left'
  1242. },
  1243. {
  1244. label: '编码',
  1245. prop: 'categoryCode',
  1246. width: 150,
  1247. align: 'center',
  1248. showOverflowTooltip: true
  1249. },
  1250. {
  1251. label: '名称',
  1252. prop: 'categoryName',
  1253. width: '150',
  1254. align: 'center',
  1255. width: 120,
  1256. showOverflowTooltip: true
  1257. },
  1258. {
  1259. label: '批次号',
  1260. prop: 'batchNo',
  1261. align: 'center',
  1262. width: 120,
  1263. showOverflowTooltip: true
  1264. },
  1265. {
  1266. label: '发货条码',
  1267. prop: 'barcodes',
  1268. align: 'center',
  1269. showOverflowTooltip: true
  1270. },
  1271. {
  1272. label: '包装编码',
  1273. prop: 'packageNo',
  1274. align: 'center',
  1275. width: 120,
  1276. showOverflowTooltip: true
  1277. },
  1278. { label: '包装数量', prop: 'packingQuantity', align: 'center' },
  1279. { label: '包装单位', prop: 'packingUnit', align: 'center' },
  1280. // {
  1281. // label: '包装规格',
  1282. // prop: 'packingSpecification',
  1283. // align: 'center',
  1284. // width: 180
  1285. // },
  1286. { label: '计量数量', prop: 'measureQuantity', align: 'center' },
  1287. { label: '计量单位', prop: 'measureUnit', align: 'center' },
  1288. { label: '物料代号', prop: 'materielDesignation', align: 'center' },
  1289. { label: '客户代号', prop: 'clientCode', align: 'center' },
  1290. {
  1291. label: '供应商名称',
  1292. prop: 'supplierName',
  1293. align: 'center',
  1294. width: 120,
  1295. showOverflowTooltip: true
  1296. },
  1297. {
  1298. label: '供应商代号',
  1299. prop: 'supplierCode',
  1300. align: 'center',
  1301. width: '120',
  1302. showOverflowTooltip: true
  1303. },
  1304. { label: '刻码', prop: 'engrave', align: 'center' },
  1305. {
  1306. label: '机型',
  1307. prop: 'modelKey',
  1308. align: 'center',
  1309. showOverflowTooltip: true
  1310. },
  1311. {
  1312. label: '颜色',
  1313. prop: 'colorKey',
  1314. align: 'center',
  1315. showOverflowTooltip: true
  1316. },
  1317. {
  1318. label: '型号',
  1319. prop: 'modelType',
  1320. align: 'center',
  1321. showOverflowTooltip: true
  1322. },
  1323. {
  1324. label: '规格',
  1325. prop: 'specification',
  1326. align: 'center',
  1327. showOverflowTooltip: true
  1328. },
  1329. {
  1330. label: '电压等级',
  1331. prop: 'voltage',
  1332. align: 'center',
  1333. showOverflowTooltip: true
  1334. },
  1335. { label: '重量', prop: 'weight', align: 'center' },
  1336. { label: '重量单位', prop: 'weightUnit', align: 'center' },
  1337. {
  1338. label: '仓库',
  1339. prop: 'warehouseName',
  1340. align: 'center',
  1341. width: 120,
  1342. showOverflowTooltip: true
  1343. },
  1344. { label: '货区', prop: 'areaName', align: 'center' },
  1345. { label: '货架', prop: 'goodsShelfName', align: 'center' },
  1346. { label: '货位', prop: 'goodsAllocationName', align: 'center' },
  1347. {
  1348. label: '生产日期',
  1349. prop: 'productionDate',
  1350. align: 'center',
  1351. width: 120,
  1352. showOverflowTooltip: true
  1353. },
  1354. {
  1355. label: '采购日期',
  1356. prop: 'purchaseDate',
  1357. align: 'center',
  1358. width: 120,
  1359. showOverflowTooltip: true
  1360. }
  1361. ];
  1362. return arr;
  1363. },
  1364. // 分页后的样品列表
  1365. paginatedSampleList() {
  1366. // const { currentPage, pageSize } = this.samplePagination;
  1367. // const start = (currentPage - 1) * pageSize;
  1368. // const end = start + pageSize;
  1369. // return this.sampleList?.slice(start, end);
  1370. return this.sampleList;
  1371. },
  1372. // 分页后的质检方案列表
  1373. paginatedSchemeList() {
  1374. // const { currentPage, pageSize } = this.schemePagination;
  1375. // const start = (currentPage - 1) * pageSize;
  1376. // const end = start + pageSize;
  1377. // console.log(this.templateList,'全部数据')
  1378. // return this.templateList?.slice(start, end);
  1379. return this.templateList;
  1380. }
  1381. },
  1382. created() {
  1383. this.activeNameKK = this.activeName;
  1384. this.reload({ qualityWorkerId: this.ids });
  1385. let direction = this.$getDirection();
  1386. this.getBadTypeList();
  1387. this.getBadNameList();
  1388. direction.on('keyup', function (e, val) {
  1389. if (e.keyCode == 39) {
  1390. direction.next();
  1391. }
  1392. if (e.keyCode == 37) {
  1393. direction.previous();
  1394. }
  1395. if (e.keyCode == 38) {
  1396. direction.previousLine();
  1397. }
  1398. if (e.keyCode == 40) {
  1399. direction.nextLine();
  1400. }
  1401. });
  1402. },
  1403. mounted() {
  1404. this.getFileParam();
  1405. },
  1406. methods: {
  1407. async getFileParam() {
  1408. const res = await parameterGetByCode({
  1409. code: 'mes_craft_file_by_category_code'
  1410. });
  1411. const byCategory = res?.value === '1';
  1412. if (byCategory) {
  1413. this.$refs.wokePopupListRef.openTwo(this.form);
  1414. } else {
  1415. this.$refs.wokePopupListRef.open(
  1416. this.fileParam.map((item) => item.id)
  1417. );
  1418. }
  1419. },
  1420. // 不良类型改变
  1421. badTypeChange(row) {
  1422. row.badTypeName = null;
  1423. // 赋值badTypeName
  1424. const badType = this.badTypeList.find(
  1425. (item) => item.id === row.badTypeId
  1426. );
  1427. if (badType) {
  1428. row.badTypeName = badType.name;
  1429. }
  1430. this.getBadNameList(row.badTypeId);
  1431. },
  1432. // 不良名称改变
  1433. badNameChange(row) {
  1434. // 赋值badNameName
  1435. const badItem = this.badNameList.find(
  1436. (item) => item.id === row.badNameId
  1437. );
  1438. if (badItem) {
  1439. row.badNameName = badItem.name;
  1440. }
  1441. },
  1442. // 查询不良类型
  1443. async getBadTypeList() {
  1444. const res = await getBadTypeList({
  1445. pageNum: 1,
  1446. size: 999
  1447. });
  1448. this.badTypeList = res.list;
  1449. },
  1450. // 查询不良名称
  1451. async getBadNameList() {
  1452. const res = await getBadNameList({
  1453. pageNum: 1,
  1454. size: 999
  1455. });
  1456. this.badNameList = res.list;
  1457. },
  1458. //合格数量变化设置样品清单 全减并且不拆包才执行
  1459. async setSampleList(val, total) {
  1460. this.$set(this.sampleList[0], 'measureQuantity', val);
  1461. let weight = this.form.totalWeight / total;
  1462. let arr = [];
  1463. for (let i = 0; i < total - val; i++) {
  1464. let data = JSON.parse(JSON.stringify(this.sampleList[0]));
  1465. data['measureQuantity'] = 1;
  1466. data['qualityResults'] = 2;
  1467. data['qualityStatus'] = 1;
  1468. data['qualitySampleTemplateList'] = [];
  1469. data['id'] = '';
  1470. data['weight'] = parseFloat(weight).toFixed(2);
  1471. let code = await getCodeList('sample_code', { count: 1 });
  1472. data['sampleCode'] = code[0];
  1473. arr.push(data);
  1474. }
  1475. this.$set(
  1476. this.sampleList[0],
  1477. 'weight',
  1478. parseFloat(val * weight).toFixed(2)
  1479. );
  1480. this.sampleList = [this.sampleList[0], ...arr];
  1481. this.$emit('sampleListChange', this.sampleList);
  1482. },
  1483. async datasource({ page, limit, where }) {
  1484. console.log('执行33');
  1485. const res = await queryQualityInventory({
  1486. ...where,
  1487. pageNum: page,
  1488. // size: limit
  1489. size: -1
  1490. });
  1491. if (res.list.length == 0) {
  1492. return res;
  1493. }
  1494. // 包装数量的字段
  1495. // if (!this.productId) {
  1496. // return res;
  1497. // }
  1498. // const result = await getCategoryPackageDisposition({
  1499. // categoryIds: [this.productId]
  1500. // });
  1501. // let str = '';
  1502. // if (result.length) {
  1503. let o = res.list[0];
  1504. let listArr = [];
  1505. if (o.measureUnit) {
  1506. listArr.push({
  1507. packageCellTotal: 1,
  1508. conversionUnit: o.measureUnit,
  1509. id: '111'
  1510. });
  1511. }
  1512. if (o.packingUnit) {
  1513. listArr.push({
  1514. packageCellTotal: o.measureQuantity - 0,
  1515. conversionUnit: o.packingUnit,
  1516. id: '222'
  1517. });
  1518. }
  1519. // result.map((el, index) => {
  1520. // // let Unit = el.conversionUnit.trim();
  1521. // // if (Unit == o.packingUnit.trim() || Unit == o.measureUnit.trim()) {
  1522. // // listArr.push(el);
  1523. // // }
  1524. // if (index == 0) {
  1525. // // el.packageCellTotal = el.packageCell - 0;
  1526. // return;
  1527. // }
  1528. // if (index === result.length - 1) {
  1529. // str = `${str}${el.packageCell}${el.packageUnit}/${el.conversionUnit}`;
  1530. // } else {
  1531. // str = `${str}${el.packageCell}${el.packageUnit}/${el.conversionUnit},`;
  1532. // }
  1533. // // if (index == 1) {
  1534. // // el.packageCellTotal = el.packageCell - 0;
  1535. // // return;
  1536. // // }
  1537. // // 计算乘法的规则
  1538. // // el.packageCellTotal =
  1539. // // el.packageCell * result[index - 1].packageCellTotal;
  1540. // });
  1541. res.list.map((el) => {
  1542. el.weightProportion = el.weight
  1543. ? (el.weight / el.measureQuantity).toFixed(4)
  1544. : 0;
  1545. el.weightProportion = el.weightProportion - 0;
  1546. });
  1547. this.packingSpecificationOption = listArr;
  1548. return res;
  1549. },
  1550. reload(where) {
  1551. this.$nextTick(() => {
  1552. if (this.$refs.sourceTable && this.$refs.sourceTable.reload)
  1553. this.$refs.sourceTable.reload({ page: 1, where: where });
  1554. });
  1555. },
  1556. tableSelClear() {
  1557. this.$refs.sourceTable.clearSelection();
  1558. },
  1559. handleSelectionChange(selection) {
  1560. if (this.form.conditionType == 2) {
  1561. if (this.form.isUnpack == 2) {
  1562. this.$set(this.form, 'sampleNumber', this.formData.portion);
  1563. } else {
  1564. this.formData.portion = selection.length;
  1565. this.$set(this.form, 'sampleNumber', selection.length);
  1566. }
  1567. this.formData.sampleUnit = selection[0]?.measureUnit;
  1568. this.$set(this.form, 'sampleMeasureUnit', selection[0]?.measureUnit);
  1569. } else if (this.form.conditionType == 1) {
  1570. this.$set(this.form, 'sampleNumber', this.formData.portion);
  1571. }
  1572. // this.formData.portion = selection.length;
  1573. // this.formData.sampleUnit = selection[0]?.measureUnit;
  1574. //
  1575. // this.$set(this.form, 'sampleNumber', selection.length);
  1576. // this.$set(this.form, 'sampleMeasureUnit', selection[0]?.measureUnit);
  1577. this.$emit('handleSelectionChange', selection);
  1578. },
  1579. handleSelectionChange1(selection) {
  1580. this.selection1 = selection;
  1581. },
  1582. delAll() {
  1583. if (!this.selection1.length) {
  1584. this.$message.error('请至少选择一条数据!');
  1585. return;
  1586. }
  1587. this.selection1.forEach((item) => {
  1588. this.handDel(
  1589. this.templateList.findIndex((temp) => temp.id == item.id)
  1590. );
  1591. });
  1592. console.log(this.selection1, 'this.selection1');
  1593. },
  1594. handleSampleNumber(val) {
  1595. this.conditionType = val;
  1596. this.form.sampleUnit = '';
  1597. this.$emit('getConditionType', val);
  1598. //取整样
  1599. // let data = this.$refs.sourceTable.getData()
  1600. // this.$emit('getSelectedList')
  1601. // if (this.selectedList.length == 0) {
  1602. // this.$message.warning('请先选择样品!');
  1603. // }
  1604. // if (val == 1) {
  1605. // // this.activeName = '2'
  1606. // this.$emit('handleSample1', val, data)
  1607. // } else if (val == 2) {
  1608. // this.tableSelClear();
  1609. // this.$emit('handleSample1', val, data)
  1610. // }
  1611. },
  1612. handleInputNumber(val) {
  1613. let packingList = this.$refs.sourceTable.getData();
  1614. const maxValue =
  1615. packingList.length > 1
  1616. ? packingList.length
  1617. : packingList[0].measureQuantity;
  1618. if (val > maxValue) {
  1619. this.$message.warning('数量不能大于计量数量!');
  1620. this.formData.number = maxValue;
  1621. return;
  1622. }
  1623. },
  1624. handleInput(val) {
  1625. if (val == 0 || val == '' || val == null) {
  1626. this.$refs.sourceTable.clearSelection();
  1627. return;
  1628. }
  1629. let packingList = this.$refs.sourceTable.getData();
  1630. if (!packingList || packingList.length === 0) {
  1631. return;
  1632. }
  1633. // 计算 packingList 中 measureQuantity 字段的总和
  1634. const measureQuantitySum = packingList.reduce((sum, item) => {
  1635. const quantity = Number(item.measureQuantity) || 0;
  1636. return sum + quantity;
  1637. }, 0);
  1638. const portion = Number(this.formData.portion);
  1639. // 清空当前选中
  1640. this.$refs.sourceTable.clearSelection();
  1641. if (this.form.conditionType == 2) {
  1642. // 确保 portion 不超过数据列表长度
  1643. const safePortion = Math.min(portion, packingList.length);
  1644. if (this.form.isUnpack == 2) {
  1645. const maxQuantity = Number(packingList[0].measureQuantity);
  1646. if (portion > maxQuantity) {
  1647. this.$message.warning('取样数量不能大于计量数量!');
  1648. this.formData.portion = maxQuantity;
  1649. }
  1650. } else if (this.form.isUnpack == 1) {
  1651. if (portion > packingList.length) {
  1652. this.$message.warning('取样数量不能大于来源清单数量!');
  1653. this.formData.portion = packingList.length;
  1654. }
  1655. }
  1656. packingList.slice(0, safePortion).forEach((row) => {
  1657. this.$refs.sourceTable.toggleRowSelection(row);
  1658. });
  1659. } else if (this.form.conditionType == 1) {
  1660. // 确保 portion 不超过数据列表长度
  1661. const safePortion = Math.min(portion, measureQuantitySum);
  1662. if (portion > measureQuantitySum) {
  1663. this.$message.warning('取样数量不能大于计量数量!');
  1664. this.formData.portion = measureQuantitySum;
  1665. }
  1666. // 选中前 safePortion 行
  1667. packingList.slice(0, safePortion).forEach((row) => {
  1668. this.$refs.sourceTable.toggleRowSelection(row, true);
  1669. });
  1670. }
  1671. // if (packingList.length > 1) {
  1672. // if (portion > packingList.length) {
  1673. // this.$message.warning('取样数量不能大于来源清单数量!');
  1674. // this.formData.portion = packingList.length;
  1675. // return;
  1676. // }
  1677. // packingList.slice(0, this.formData.portion).forEach(row => {
  1678. // this.$refs.table12.toggleRowSelection(row);
  1679. // });
  1680. // } else {
  1681. // const maxQuantity = Number(packingList[0].measureQuantity);
  1682. // if (portion > maxQuantity) {
  1683. // this.$message.warning('取样数量不能大于计量数量!');
  1684. // this.formData.portion = maxQuantity;
  1685. // return;
  1686. // }
  1687. // }
  1688. },
  1689. changeSamUnit(val) {
  1690. this.$emit('changeSamUnit', val);
  1691. },
  1692. handleSampleSubmit() {
  1693. this.$refs.ruleForm.validate((valid) => {
  1694. if (valid) {
  1695. //取小样 赋值右上角单位
  1696. this.changeSamUnit(this.formData.sampleUnit);
  1697. let params = {
  1698. conditionType: this.conditionType,
  1699. measureQ: this.formData.number,
  1700. sampleUnit: this.formData.sampleUnit,
  1701. portion: this.formData.portion
  1702. };
  1703. let specifications = this.packingSpecificationOption.find(
  1704. (el) => el.id == this.formData.packingUnit
  1705. );
  1706. console.log('执行这里没', params, '---');
  1707. this.$emit('handleSampleSubmit', params, specifications);
  1708. }
  1709. });
  1710. },
  1711. handleClick(tab) {
  1712. this.activeNameKK = tab.name;
  1713. },
  1714. tabsChange(val) {
  1715. this.activeNameKK = val;
  1716. },
  1717. tabsConditionType(val) {
  1718. this.conditionType = val;
  1719. },
  1720. checkSelectable(row, index) {
  1721. // 只有当质检方式为抽检(qualityMode=2)时 类型不是生产检验 才可选
  1722. return this.form.qualityType != 2 && this.form.qualityMode === 2;
  1723. },
  1724. handleDetail(index, row, type) {
  1725. this.$emit('handleDetail', index, row, type);
  1726. },
  1727. inputWeight(row, index) {
  1728. this.$emit('inputWeight', row, index);
  1729. },
  1730. handleDispose(index, row, type) {
  1731. this.$emit('handleDispose', { row, index });
  1732. },
  1733. handleSampleSizeChange(val) {
  1734. this.samplePagination.pageSize = val;
  1735. this.samplePagination.currentPage = 1;
  1736. },
  1737. handleSampleCurrentChange(val) {
  1738. this.samplePagination.currentPage = val;
  1739. },
  1740. handleSchemeSizeChange(val) {
  1741. this.schemePagination.pageSize = val;
  1742. this.schemePagination.currentPage = 1;
  1743. },
  1744. handleSchemeCurrentChange(val) {
  1745. this.schemePagination.currentPage = val;
  1746. },
  1747. //质检项报工
  1748. inspectionProjectReport(index, row) {
  1749. this.$emit('inspectionProjectReport', { index, list: [row] });
  1750. },
  1751. selectQualityResultsChange() {
  1752. this.$emit('countQualityResults');
  1753. },
  1754. addInspectionTemplate() {
  1755. let type = this.form.qualityType || 1;
  1756. this.$refs.inspectionTemplateRef.open(type);
  1757. },
  1758. async inspectionTemplateSuccess(select) {
  1759. let data = await getQualityTemplateByIds({
  1760. templateIds: select.map((item) => item.id)
  1761. });
  1762. data.forEach((item) => {
  1763. item.id = null;
  1764. });
  1765. // 这里是选择方案后,数据新加,要改为覆盖
  1766. // this.templateList.push(...data);
  1767. // const strings = this.templateList.map((item) => JSON.stringify(item));
  1768. // const removeDupList = [...new Set(strings)];
  1769. // const result = removeDupList.map((item) => JSON.parse(item));
  1770. if (this.form.recordingMethod != 1) {
  1771. this.templateList = [];
  1772. } else {
  1773. this.templateList = this.templateList.filter((item) => item.status);
  1774. }
  1775. data.forEach((item) => {
  1776. item['qualityResults'] = 1;
  1777. item['status'] = 0;
  1778. });
  1779. this.templateList.push(...data);
  1780. // this.templateList = result.map((item) => {
  1781. // item['qualityResults'] = 1;
  1782. // return item;
  1783. // });
  1784. this.sampleList.forEach((item, index) => {
  1785. this.$set(
  1786. this.sampleList[index],
  1787. 'qualitySampleTemplateList',
  1788. this.templateList
  1789. );
  1790. });
  1791. this.$set(this.form, 'templateList', this.templateList);
  1792. this.$emit('setSchemeList', this.templateList);
  1793. // this.schemeList = this.templateList;
  1794. this.schemePagination.total = this.templateList.length;
  1795. if (this.form.recordingMethod == 1) {
  1796. this.$emit('setSchemeListChange');
  1797. }
  1798. },
  1799. handDel(index) {
  1800. this.templateList.splice(index, 1);
  1801. this.sampleList.forEach((item, index) => {
  1802. this.$set(
  1803. this.sampleList[index],
  1804. 'qualitySampleTemplateList',
  1805. this.templateList.map((item) => {
  1806. item['qualityResults'] = 1;
  1807. return item;
  1808. })
  1809. );
  1810. });
  1811. }
  1812. }
  1813. };
  1814. </script>