newQualityContentTabs.vue 53 KB

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