sampleListDialog.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. <!-- 用户编辑弹窗 -->
  2. <template>
  3. <ele-modal
  4. :title="title"
  5. :visible.sync="visible"
  6. :before-close="handleClose"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. width="80%"
  11. :maxable="true"
  12. >
  13. <el-table :data="tableData" :default-expand-all="true">
  14. <el-table-column type="expand">
  15. <template slot-scope="props">
  16. <div style="padding: 10px">
  17. <el-table :data="props.row.qualitySampleTemplateList" border>
  18. <el-table-column
  19. label="质检方案编码"
  20. prop="qualitySchemeTemplateCode"
  21. align="center"
  22. >
  23. <template slot-scope="scope">
  24. <span :class="scope.row.qualityResults === 2 ? 'warn' : ''">
  25. {{ scope.row.qualitySchemeTemplateCode }}
  26. </span>
  27. </template>
  28. </el-table-column>
  29. <el-table-column
  30. label="质检方案名称"
  31. prop="qualitySchemeTemplateName"
  32. align="center"
  33. >
  34. <template slot-scope="scope">
  35. <span :class="scope.row.qualityResults === 2 ? 'warn' : ''">
  36. {{ scope.row.qualitySchemeTemplateName }}
  37. </span>
  38. </template>
  39. </el-table-column>
  40. <el-table-column
  41. label="质检类型"
  42. prop="categoryLevelClassName"
  43. align="center"
  44. >
  45. <template slot-scope="scope">
  46. <span :class="scope.row.qualityResults === 2 ? 'warn' : ''">
  47. {{ scope.row.categoryLevelClassName }}
  48. </span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column
  52. label="质检项编码"
  53. prop="inspectionCode"
  54. align="center"
  55. >
  56. <template slot-scope="scope">
  57. <span :class="scope.row.qualityResults === 2 ? 'warn' : ''">
  58. {{ scope.row.inspectionCode }}
  59. </span>
  60. </template>
  61. </el-table-column>
  62. <el-table-column
  63. label="质检项名称"
  64. prop="inspectionName"
  65. align="center"
  66. >
  67. <template slot-scope="scope">
  68. <span :class="scope.row.qualityResults === 2 ? 'warn' : ''">
  69. {{ scope.row.inspectionName }}
  70. </span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column
  74. label="工艺参数"
  75. prop="defaultValue"
  76. align="center"
  77. show-overflow-tooltip
  78. >
  79. <template slot-scope="scope">
  80. <!-- <span :class="scope.row.qualityResults === 2 ? 'warn' : ''">
  81. {{ scope.row.defaultValue }}
  82. </span> -->
  83. <div
  84. style="display: flex; justify-content: center"
  85. :class="scope.row.qualityResults === 2 ? 'warn' : ''"
  86. >
  87. <span>{{ scope.row.symbol }}</span>
  88. <span v-if="scope.row.textType == 3">
  89. {{ scope.row.minValue }}-{{ scope.row.maxValue }}
  90. </span>
  91. <span v-else>
  92. <span>{{ scope.row.defaultValue }}</span>
  93. </span>
  94. {{ scope.row.unitName }}
  95. </div>
  96. </template>
  97. </el-table-column>
  98. <el-table-column label="质检工具" prop="" align="center">
  99. <template slot-scope="scope">
  100. <toolButtom
  101. v-model="scope.row.useTools"
  102. :type="type"
  103. :sList="scope.row.toolList"
  104. />
  105. </template>
  106. </el-table-column>
  107. <el-table-column
  108. label="质检内容"
  109. prop="qualityResultContent"
  110. align="center"
  111. fixed="right"
  112. width="360"
  113. >
  114. <template slot-scope="scope">
  115. <el-input
  116. :class="scope.row.qualityResults === 2 ? 'warn' : ''"
  117. @blur="(e) => inputResultContent(e, scope.row)"
  118. v-model="scope.row.qualityResultContent"
  119. placeholder="请输入内容"
  120. :disabled="type == 'detail'"
  121. ></el-input>
  122. </template>
  123. </el-table-column>
  124. <el-table-column
  125. label="质检结果"
  126. prop="qualityResults"
  127. align="center"
  128. fixed="right"
  129. >
  130. <template slot-scope="scope">
  131. <el-select
  132. v-model="scope.row.qualityResults"
  133. placeholder="请选择"
  134. style="width: 100%"
  135. @change="qualityResultsListChange"
  136. :disabled="type == 'detail'"
  137. >
  138. <el-option
  139. v-for="item in qualityResultsList"
  140. :key="item.value"
  141. :label="item.label"
  142. :value="item.value"
  143. >
  144. </el-option>
  145. </el-select>
  146. </template>
  147. </el-table-column>
  148. </el-table>
  149. </div>
  150. </template>
  151. </el-table-column>
  152. <template v-for="column in tableColumns">
  153. <el-table-column
  154. :label="column.label"
  155. :prop="column.prop"
  156. :fixed="column.fixed"
  157. :show-overflow-tooltip="true"
  158. :width="column.width"
  159. :align="column.align"
  160. :formatter="column.formatter"
  161. >
  162. <!-- <template slot-scope="scope" v-if="column.slot=='qualityResults'">
  163. <el-select
  164. v-model="scope.row.qualityResults"
  165. placeholder="请选择"
  166. style="width: 100%"
  167. :disabled="type == 'detail'"
  168. >
  169. <el-option
  170. v-for="item in qualityResultsList"
  171. :key="item.value"
  172. :label="item.label"
  173. :value="item.value"
  174. >
  175. </el-option>
  176. </el-select>
  177. </template> -->
  178. </el-table-column>
  179. </template>
  180. <!-- <el-table-column label="操作" align="center" width="80">
  181. <template slot-scope="scope">
  182. <el-link
  183. :underline="false"
  184. type="primary"
  185. @click="handleDispose(scope.$index, scope.row, 'dispose')"
  186. >
  187. 处置
  188. </el-link>
  189. </template>
  190. </el-table-column> -->
  191. </el-table>
  192. <template v-slot:footer v-if="type == 'report'">
  193. <el-button @click="handleClose">取消</el-button>
  194. <el-button type="primary" @click="handleConfirm"> 确认 </el-button>
  195. </template>
  196. </ele-modal>
  197. </template>
  198. <script>
  199. import index from 'ele-admin/lib/ele-avatar-list';
  200. import toolButtom from './toolButtom.vue';
  201. export default {
  202. components: {
  203. toolButtom
  204. },
  205. data() {
  206. return {
  207. title: '',
  208. visible: false,
  209. rowIndex: 0,
  210. type: '',
  211. tableData: [],
  212. tableColumns: [
  213. {
  214. label: '编码',
  215. prop: 'categoryCode',
  216. width: '150',
  217. align: 'center'
  218. },
  219. {
  220. label: '名称',
  221. prop: 'categoryName',
  222. width: '150',
  223. align: 'center',
  224. showOverflowTooltip: true
  225. },
  226. { label: '批次号', prop: 'batchNo', align: 'center' },
  227. // { label: '发货条码', prop: 'barcodes', align: 'center' },
  228. { label: '包装编码', prop: 'packageNo', align: 'center' },
  229. { label: '包装数量', prop: 'packingQuantity', align: 'center' },
  230. // { label: '包装单位', prop: 'packingUnit', align: 'center' },
  231. { label: '计量数量', prop: 'measureQuantity', align: 'center' },
  232. // { label: '计量单位', prop: 'measureUnit', align: 'center' },
  233. { label: '物料代号', prop: 'materielDesignation', align: 'center' },
  234. { label: '客户代号', prop: 'clientCode', align: 'center' },
  235. { label: '刻码', prop: 'engrave', align: 'center' },
  236. { label: '重量', prop: 'weight', align: 'center' },
  237. { label: '重量单位', prop: 'weightUnit', align: 'center' },
  238. { label: '仓库', prop: 'warehouseName', align: 'center' },
  239. {
  240. label: '质检结果',
  241. prop: 'qualityResults',
  242. align: 'center',
  243. slot: 'qualityResults',
  244. formatter: (row, column) => {
  245. if (row.qualityResults) {
  246. return row.qualityResults == 1
  247. ? '合格'
  248. : row.qualityResults == 2
  249. ? '不合格'
  250. : row.qualityResults == 3
  251. ? '让步接收'
  252. : '';
  253. }
  254. }
  255. }
  256. // { label: '货区', prop: 'areaName', align: 'center', },
  257. // { label: '货架', prop: 'goodsShelfName', align: 'center', },
  258. // { label: '货位', prop: 'goodsAllocationName', align: 'center', },
  259. // { label: '生产日期', prop: 'productionDate', align: 'center', },
  260. // { label: '采购日期', prop: 'purchaseDate', align: 'center', }
  261. ],
  262. qualityResultsList: [
  263. {
  264. value: 1,
  265. label: '合格'
  266. },
  267. {
  268. value: 2,
  269. label: '不合格'
  270. },
  271. {
  272. value: 3,
  273. label: '让步接收'
  274. }
  275. ],
  276. sList: [] //质检工具筛选
  277. };
  278. },
  279. computed: {},
  280. created() {},
  281. methods: {
  282. async openDia(index, row, type, list, isStatus, sList) {
  283. this.tableData = [];
  284. this.rowIndex = index;
  285. this.type = type;
  286. // console.log(list, 'lklllllllllllllllllkkkkkkkkkkkkkkkkkkkkk', list[0].qualityResults);
  287. //如果质检项qualitySampleTemplateList只有一条数据且质检结果是让步接收
  288. if (list[0].qualitySampleTemplateList.length == 1) {
  289. for (let i = 0; i < list[0].qualitySampleTemplateList.length; i++) {
  290. list[0].qualitySampleTemplateList[i].qualityResults = list[0]
  291. .qualityResults
  292. ? list[0].qualityResults
  293. : 1;
  294. }
  295. }
  296. // 默认合格
  297. list.map((item) => {
  298. item.qualitySampleTemplateList &&
  299. item.qualitySampleTemplateList.map((el) => {
  300. el.qualityResults = el.qualityResults ? el.qualityResults : 1;
  301. });
  302. });
  303. this.tableData = JSON.parse(JSON.stringify(list));
  304. console.log(this.tableData, '33333333333333333');
  305. this.visible = true;
  306. },
  307. qualityResultsListChange() {
  308. this.tableData.forEach((item, index) => {
  309. this.$set(
  310. this.tableData[index],
  311. 'qualityResults',
  312. this.getQuality(item.qualitySampleTemplateList)
  313. );
  314. });
  315. },
  316. getQuality(arr) {
  317. let getQualityValue = 1;
  318. arr.forEach((item) => {
  319. if (item.qualityResults == 2) {
  320. getQualityValue = 2;
  321. }
  322. });
  323. return getQualityValue;
  324. },
  325. inputResultContent(e, row) {
  326. console.log(row, 'row row row');
  327. if (row.textType == '1') {
  328. if (!row.symbol) {
  329. if (row.qualityResultContent != row.defaultValue) {
  330. this.$set(row, 'qualityResults', 2);
  331. } else {
  332. this.$set(row, 'qualityResults', 1);
  333. }
  334. return;
  335. }
  336. let key = this.mathematicalJudgment(row);
  337. this.$set(row, 'qualityResults', key);
  338. return;
  339. }
  340. if (row.textType == '3') {
  341. let num = Number(row.qualityResultContent);
  342. if (num == NaN) {
  343. this.$set(row, 'qualityResults', 2);
  344. return;
  345. }
  346. console.log(num, 'num');
  347. if (num >= Number(row.minValue) && num <= Number(row.maxValue)) {
  348. this.$set(row, 'qualityResults', 1);
  349. } else {
  350. this.$set(row, 'qualityResults', 2);
  351. }
  352. }
  353. },
  354. // 数学判断
  355. mathematicalJudgment(row) {
  356. console.log('进来没有',row);
  357. let symbol = row.symbol?.trim(); // 符号
  358. let Ivalue = Number(row.qualityResultContent); // 输入的值
  359. let Dvalue = Number(row.defaultValue); // 判断的值
  360. if (Ivalue == NaN || Dvalue == NaN) {
  361. return 2;
  362. }
  363. if (symbol == '±') {
  364. if (Math.abs(Ivalue) != Math.abs(Dvalue)) {
  365. return 1;
  366. } else {
  367. return 2;
  368. }
  369. }
  370. if (symbol == '≤' || symbol == '≦') {
  371. if (Ivalue <= Dvalue) {
  372. return 1;
  373. } else {
  374. return 2;
  375. }
  376. }
  377. if (symbol == '≥' || symbol == '≧') {
  378. if (Ivalue >= Dvalue) {
  379. return 1;
  380. } else {
  381. return 2;
  382. }
  383. }
  384. if (symbol == '≈' || symbol == '=') {
  385. console.log('进来等于号')
  386. if (Ivalue == Dvalue) {
  387. return 1;
  388. } else {
  389. return 2;
  390. }
  391. }
  392. if (symbol == '≠') {
  393. if (Ivalue != Dvalue) {
  394. return 1;
  395. } else {
  396. return 2;
  397. }
  398. }
  399. if (symbol == '>') {
  400. if (Ivalue > Dvalue) {
  401. return 1;
  402. } else {
  403. return 2;
  404. }
  405. }
  406. if (symbol == '<') {
  407. if (Ivalue > Dvalue) {
  408. return 1;
  409. } else {
  410. return 2;
  411. }
  412. }
  413. return 2;
  414. },
  415. handleClose() {
  416. this.visible = false;
  417. },
  418. handleConfirm() {
  419. this.visible = false;
  420. this.$emit('handleConfirm', this.tableData, this.rowIndex);
  421. },
  422. handleDispose(index, row, type) {
  423. this.$emit('handleDispose', index, row, type);
  424. },
  425. //选择质检工具
  426. openToolList(index, row) {
  427. this.$emit('openToolList', index, row);
  428. }
  429. }
  430. };
  431. </script>
  432. <style scoped lang="scss">
  433. ::v-deep .warn {
  434. color: red;
  435. .el-input__inner {
  436. color: red;
  437. }
  438. }
  439. </style>