flXiangqingPopUp.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. <template>
  2. <!-- 辅料采集详情界面 -->
  3. <div class="popUp" v-if="modelValue">
  4. <div class="header" style="height: 3vh">
  5. <div class="headerTittle" style="font-weight: border; font-size: 28px">辅料采集详情</div>
  6. </div>
  7. <div class="header" style="display: flex; justify-content: center; margin: 20px">
  8. <div class="box" @click.stop>
  9. <div class="boxItem">
  10. <div class="describeText">需采集物料:{{ showInfo.materialName }}</div>
  11. <div class="describeText">物料编码:{{ showInfo.materialCode }}</div>
  12. <div class="describeText">型号:{{ showInfo.spec }}</div>
  13. </div>
  14. </div>
  15. </div>
  16. <div class="body">
  17. <div class="container1" @click.stop>
  18. <div class="boxTittle">批次号列表(共&nbsp;{{ batchNoTableData.length }}&nbsp;批次)</div>
  19. <el-divider style="margin-top: 20px !important" />
  20. <div style="display: flex; margin-bottom: 20px; align-items: center">
  21. <div class="seqSearchInput">
  22. <!-- <el-input
  23. v-model="searchBatchNo"
  24. placeholder="搜索批次号"
  25. class="searchInput"
  26. clearable
  27. /> -->
  28. </div>
  29. <!-- <el-button style="width: 300px" type="success" @click="autoAll"
  30. >按需全批次自动绑定</el-button
  31. > -->
  32. </div>
  33. <el-table border class="seqTable" :data="showBatchNoTableData" style="flex: 1">
  34. <el-table-column align="center" label="批次号" prop="batchNo" />
  35. <el-table-column align="center" label="绑定管号">
  36. <template #default="scope">
  37. <el-scrollbar max-height="300px">
  38. <el-select
  39. multiple
  40. clearable
  41. filterable
  42. placeholder="管号"
  43. :disabled="!props.isShow"
  44. v-model="batchNoTableData[scope.$index].seqList"
  45. >
  46. <template #header>
  47. <el-checkbox @change="handleCheckAll(scope.$index)"> 全选 </el-checkbox>
  48. </template>
  49. <el-option v-for="item in seqList" :key="item" :label="item" :value="item"> </el-option>
  50. </el-select>
  51. </el-scrollbar>
  52. </template>
  53. </el-table-column>
  54. <!-- <el-table-column align="center" width="160" label="操作">
  55. <template #default="scope">
  56. <el-button style="width: 120px" type="primary"
  57. >按需自动绑定</el-button
  58. >
  59. </template>
  60. </el-table-column> -->
  61. <template #empty>
  62. <div class="empty">
  63. <Empty />
  64. </div>
  65. </template>
  66. </el-table>
  67. <div class="btns">
  68. <el-button type="primary" @click="submit" v-if="props.isShow">绑定确认</el-button>
  69. <el-button @click="handleClose">取消</el-button>
  70. </div>
  71. </div>
  72. <div class="container2" @click.stop>
  73. <div class="boxTittle">管号列表(共 {{ seqList.length }} 个 )</div>
  74. <el-divider />
  75. <div style="display: flex; margin-bottom: 20px; align-items: center">
  76. <div class="seqSearchInput">
  77. <el-input v-model="searchSeqNo" placeholder="搜索管号" class="searchInput" clearable />
  78. </div>
  79. <!-- <el-button @click="seqNoOk = true" :type="seqNoOk ? 'primary' : ''"
  80. >完成绑定</el-button
  81. >
  82. <el-button :type="!seqNoOk ? 'primary' : ''" @click="seqNoOk = false"
  83. >未完成</el-button
  84. > -->
  85. </div>
  86. <el-table border class="seqTable" :data="showSeqData" style="flex: 1">
  87. <el-table-column align="center" label="管号" prop="seqNo" />
  88. <el-table-column align="center" label="批次号绑定情况" prop="bodyatchNoList">
  89. <template #default="scope">
  90. <template v-if="scope.row.batchNoList.length > 0" v-for="item in scope.row.batchNoList">
  91. <div>批次号: {{ item }}</div>
  92. </template>
  93. <span v-else>-</span>
  94. </template>
  95. </el-table-column>
  96. <template #empty>
  97. <div class="empty">
  98. <Empty />
  99. </div>
  100. </template>
  101. </el-table>
  102. </div>
  103. </div>
  104. </div>
  105. </template>
  106. <script setup>
  107. import { useProcessStore } from "@/store";
  108. import { getunProcessedList } from "@/api/prosteps";
  109. import { saveFlBatch } from "@/api/prosteps/wuliaocaiji.ts";
  110. import { useUserStore } from "@/store";
  111. import { includes } from "lodash-es";
  112. const props = defineProps({
  113. modelValue: {
  114. type: Boolean,
  115. default: false,
  116. },
  117. showInfo: {
  118. type: Object,
  119. },
  120. isShow: {
  121. type: Boolean,
  122. default: true,
  123. },
  124. isMixMaterial: {
  125. type: Boolean,
  126. default: false,
  127. },
  128. });
  129. const searchBatchNo = ref("");
  130. const searchSeqNo = ref("");
  131. const handleCheckAll = (index) => {
  132. batchNoTableData.value[index].seqList = seqList.value;
  133. };
  134. const showBatchNoTableData = computed(() => {
  135. let array = JSON.parse(JSON.stringify(batchNoTableData.value));
  136. if (searchBatchNo.value) {
  137. const lowerCaseSearchValue = searchBatchNo.value.toLowerCase();
  138. array = array.filter((item) => item.batchNo && item.batchNo.toLowerCase().includes(lowerCaseSearchValue));
  139. }
  140. return array;
  141. });
  142. const store1 = useUserStore();
  143. const emits = defineEmits(["update:modelValue", "dataList"]);
  144. const store = useProcessStore();
  145. //批次号绑定
  146. const batchNoTableData = ref([]);
  147. const setBatchNo = () => {
  148. const array = [];
  149. if (props.showInfo.batchNoList.length > 0) {
  150. for (let i = 0; i < props.showInfo.batchNoList.length; i++) {
  151. array.push({
  152. batchNo: props.showInfo.batchNoList[i],
  153. seqList: [],
  154. });
  155. }
  156. }
  157. //回显逻辑
  158. if (props.showInfo.collectList.length > 0) {
  159. for (let i = 0; i < array.length; i++) {
  160. for (let j = 0; j < props.showInfo.collectList.length; j++) {
  161. if (props.showInfo.collectList[j].batchNo.includes(array[i].batchNo)) {
  162. array[i].seqList.push(props.showInfo.collectList[j].seqNo);
  163. }
  164. }
  165. }
  166. }
  167. batchNoTableData.value = array;
  168. };
  169. //获取当前物料绑定管号
  170. const seqTableData = ref([]);
  171. const getSeqList = async () => {
  172. const { data } = await getunProcessedList(store.scanInfo.id);
  173. seqList.value = data;
  174. };
  175. const setSeqTableData = () => {
  176. seqTableData.value = [];
  177. for (let i = 0; i < seqList.value.length; i++) {
  178. seqTableData.value.push({
  179. seqNo: seqList.value[i],
  180. batchNoList: [],
  181. });
  182. }
  183. };
  184. const showSeqData = computed(() => {
  185. let array = JSON.parse(JSON.stringify(seqTableData.value));
  186. let obj = {};
  187. for (let j = 0; j < batchNoTableData.value.length; j++) {
  188. obj[batchNoTableData.value[j].batchNo] = batchNoTableData.value[j].seqList;
  189. }
  190. for (let i = 0; i < array.length; i++) {
  191. for (let j = 0; j < batchNoTableData.value.length; j++) {
  192. if (obj[batchNoTableData.value[j].batchNo].includes(array[i].seqNo)) {
  193. array[i].batchNoList.push(batchNoTableData.value[j].batchNo);
  194. }
  195. }
  196. }
  197. if (searchSeqNo.value) {
  198. const lowerCaseSearchValue = searchSeqNo.value.toLowerCase();
  199. array = array.filter((item) => item.seqNo && item.seqNo.toLowerCase().includes(lowerCaseSearchValue));
  200. }
  201. return array;
  202. });
  203. const submit = async () => {
  204. const array = ref([]);
  205. batchNoTableData.value.forEach((item) => {
  206. if (item.seqList.length > 0) {
  207. array.value.push({
  208. itemCode: props.showInfo.materialCode,
  209. itemModel: props.showInfo.spec,
  210. itemName: props.showInfo.materialName,
  211. operationId: store.scanInfo.operationId,
  212. operationName: store.scanInfo.operationName,
  213. processId: store.scanInfo.id,
  214. workOrderCode: store.odersData.workOrderCode,
  215. trackBy: store1.user.username,
  216. seqNoList: item.seqList,
  217. batchNo: item.batchNo,
  218. isMixMaterial: props.isMixMaterial ? 1 : 0,
  219. });
  220. }
  221. });
  222. if (array.value.length < 1) {
  223. ElMessage.error("请先绑定物料!");
  224. return;
  225. }
  226. const { code } = await saveFlBatch(array.value);
  227. if (code == "200") {
  228. ElMessage.success("采集成功!");
  229. handleClose();
  230. dataList();
  231. }
  232. };
  233. //更新外部列表
  234. const dataList = () => {
  235. emits("dataList");
  236. };
  237. const handleClose = () => {
  238. emits("update:modelValue", false);
  239. };
  240. //当前所有管号
  241. const seqList = ref([]);
  242. watch(
  243. () => props.showInfo,
  244. async () => {
  245. if (props.showInfo) {
  246. await getSeqList();
  247. setBatchNo();
  248. setSeqTableData();
  249. }
  250. }
  251. );
  252. </script>
  253. <style>
  254. .el-table .warning-row {
  255. --el-table-tr-bg-color: var(--el-color-warning-light-9);
  256. }
  257. .el-table .success-row {
  258. --el-table-tr-bg-color: var(--el-color-success-light-9);
  259. }
  260. </style>
  261. <style lang="scss" scoped>
  262. .selectInfo {
  263. margin-bottom: 5px;
  264. }
  265. :deep(.el-form-item) {
  266. margin-bottom: 5px !important;
  267. }
  268. .sumFail {
  269. color: black;
  270. }
  271. .sumOk {
  272. color: green;
  273. }
  274. .describeText {
  275. font-size: 20px !important;
  276. font-weight: bolder;
  277. color: black;
  278. }
  279. .searchInput {
  280. height: 40px;
  281. }
  282. :deep(.el-input__wrapper) {
  283. height: 40px !important;
  284. }
  285. :deep(.el-table__cell) {
  286. font-size: 18px !important;
  287. }
  288. .el-divider {
  289. margin-bottom: 10px;
  290. }
  291. .el-button {
  292. width: 180px;
  293. height: 40px;
  294. font-size: 18px;
  295. border-radius: 10px;
  296. }
  297. .describeText {
  298. line-height: 25px !important;
  299. }
  300. .seqTable {
  301. border-radius: 16px;
  302. }
  303. .boxTittle {
  304. font-size: 18px;
  305. font-weight: bolder;
  306. text-align: center;
  307. height: 1vh;
  308. }
  309. .popUp {
  310. position: fixed;
  311. width: 100vw;
  312. height: 100vh;
  313. z-index: 999;
  314. background-color: #00000030;
  315. top: 0;
  316. left: 0;
  317. backdrop-filter: blur(5px);
  318. .header {
  319. margin: 0;
  320. .box {
  321. width: 95vw;
  322. height: 6vh;
  323. background-color: #f1f3f5;
  324. border-radius: 16px;
  325. padding: 10px;
  326. display: flex;
  327. flex-direction: column;
  328. justify-content: space-evenly;
  329. .boxItem {
  330. display: flex;
  331. justify-content: space-between;
  332. padding: 0 5%;
  333. .describeText {
  334. font-size: 18px;
  335. }
  336. }
  337. }
  338. }
  339. .body {
  340. width: 100vw;
  341. height: 85vh;
  342. display: flex;
  343. justify-content: space-evenly;
  344. .container1 {
  345. width: 60vw;
  346. height: 100%;
  347. background-color: #f1f3f5;
  348. border-radius: 16px;
  349. padding: 10px;
  350. display: flex;
  351. flex-direction: column;
  352. .seqSearchInput {
  353. margin-right: 10px;
  354. width: 40%;
  355. max-width: 360px;
  356. }
  357. .btns {
  358. padding-top: 10px;
  359. display: flex;
  360. justify-content: space-evenly;
  361. align-items: center;
  362. }
  363. }
  364. .container2 {
  365. width: 32vw;
  366. height: 100%;
  367. background-color: #f1f3f5;
  368. border-radius: 16px;
  369. padding: 10px;
  370. display: flex;
  371. flex-direction: column;
  372. .seqSearchInput {
  373. margin-right: 10px;
  374. width: 40%;
  375. max-width: 360px;
  376. }
  377. .btns {
  378. height: 8vh;
  379. display: flex;
  380. justify-content: space-evenly;
  381. align-items: center;
  382. }
  383. }
  384. }
  385. }
  386. .headerTittle {
  387. width: 100%;
  388. height: 55px;
  389. text-align: center;
  390. line-height: 55px;
  391. font-size: 38px;
  392. font-weight: 500;
  393. }
  394. </style>