car.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. <template>
  2. <a-spin :spinning="isSpinning" wrapperClassName="car-info-spin">
  3. <a-tabs v-model:activeKey="activeKey" type="card">
  4. <a-tab-pane :key="item" :tab="'车位' + item" v-for="item in carPosition[ccmNo]">
  5. <div class="car-info-wrapper">
  6. <div class="licensePlate"
  7. >装运车辆:{{ vehicleInfo['info' + item] && vehicleInfo['info' + item].licensePlate ? vehicleInfo['info' + item].licensePlate : '' }}</div
  8. >
  9. <print-car-info
  10. :ref="printCarInfoRefs[`infoRef${item}`]"
  11. :carPositon="item"
  12. :ccm-no="ccmNo"
  13. :info="vehicleInfo['info' + item]"
  14. @change="handleChange"
  15. @refresh="refreshCarList"
  16. />
  17. <div class="print">
  18. <a-button
  19. type="primary"
  20. v-if="vehicleInfo['info' + item] && vehicleInfo['info' + item].id"
  21. @click="
  22. () =>
  23. openPrintModal(true, {
  24. record: vehicleInfo['info' + item],
  25. typeConfigId: !vehicleInfo['info' + item].typeConfigId ? '1024' : vehicleInfo['info' + item].typeConfigId,
  26. })
  27. "
  28. >打印</a-button
  29. >
  30. </div>
  31. <div class="change-type flex items-center" v-if="vehicleInfo['info' + item] && Object.keys(vehicleInfo['info' + item]).includes('btype')">
  32. <span>{{ vehicleInfo['info' + item].ccmNo_dictText }}</span>
  33. <span>/</span>
  34. <a-switch
  35. v-model:checked="vehicleInfo['info' + item].btype"
  36. checked-value="0"
  37. @change="(checked) => handleBtypeChange(checked, vehicleInfo['info' + item])"
  38. checked-children="热坯"
  39. un-checked-value="1"
  40. un-checked-children="冷坯"
  41. />
  42. </div>
  43. </div>
  44. </a-tab-pane>
  45. <!-- <a-tab-pane key="2" tab="车位2" force-render>Content of Tab Pane 2</a-tab-pane> -->
  46. </a-tabs>
  47. <div class="flex justify-between refresh-wrapper" :style="{ left: carPosition[ccmNo].length * 70 + 20 + 'px' }">
  48. <a-button size="large" type="primary" style="font-size: 18px" @click="refresh(1)"> 刷新 </a-button>
  49. <RouterLink :to="'/shippingBill/' + ccmNo" target="_blank">
  50. <a-button size="large" type="primary" style="font-size: 18px"> 装运列表 </a-button>
  51. </RouterLink>
  52. </div>
  53. <div class="stack-divider flex justify-between items-center">
  54. <div class="flex items-center">
  55. {{ stackInfo.typeName || '' }}
  56. <div style="margin-left: 20px">
  57. <a-button size="large" type="primary" style="font-size: 18px" @click="refresh(2)"> 刷新 </a-button>
  58. </div>
  59. </div>
  60. <div>
  61. <a-button
  62. type="primary"
  63. v-if="vehicleInfo['info' + activeKey] && vehicleInfo['info' + activeKey].id && !vehicleInfo['info' + activeKey].outTime"
  64. danger
  65. @click="stackToCar"
  66. >
  67. 堆垛装车
  68. </a-button>
  69. <a-button style="background-color: #f5f5f5; color: #838383" v-else disabled>堆垛装车</a-button>
  70. </div>
  71. </div>
  72. <div class="stacking-wrapper selected-divider" id="operatorCC-stacking-wrapper">
  73. <div class="selected-divider-row flex" :id="`stackLayer${pitem.value}`" v-for="pitem in stackingList" :key="pitem.value">
  74. <!-- <a-divider orientation="left" class="stacking-list-divider">{{ pitem.label }}</a-divider> -->
  75. <div class="p-layer">{{ pitem.value }}</div>
  76. <div
  77. v-for="item in stackingObj[pitem.value]"
  78. class="p-stack-col stacking-list-row flex-1"
  79. @click="handleStackClick(item)"
  80. :class="{ 'selected-row': selectedAddressId.includes(item.id) }"
  81. >
  82. <a-dropdown :trigger="['contextmenu']">
  83. <div class="stack-col" :class="{ 'hemp-texture': !!item.steelBillet.length }">{{ item.heatNo }}</div>
  84. <template #overlay v-if="item.billetNos">
  85. <a-menu @click="menuClick($event, item)" style="min-width: 100px">
  86. <a-menu-item key="1" style="background-color: #b7eb8f; color: #000; text-align: center">更换位置</a-menu-item>
  87. </a-menu>
  88. </template>
  89. </a-dropdown>
  90. </div>
  91. </div>
  92. </div>
  93. </a-spin>
  94. <!-- 打印 -->
  95. <printModal @register="registerPrintModal" />
  96. </template>
  97. <script setup lang="ts">
  98. import { ref, onMounted, onUnmounted, h } from 'vue';
  99. import printCarInfo from './printCarInfo.vue';
  100. import { useTimeoutFn } from '/@/hooks/core/useTimeout';
  101. import { list, edit } from '../../shippingBill/shippingBill.api';
  102. import { getStackInfo, stackLoadSave, stackLocationChange } from '../../hotDelivery/hotDelivery.api';
  103. import { getMachineConfig, MachineConfigType, destinationOptions } from '../../hotDelivery/common.data';
  104. import { useMessage } from '/@/hooks/web/useMessage';
  105. import printModal from '../../shippingBill/components/printModal.vue';
  106. import { useModal } from '/@/components/Modal';
  107. import { render } from '/@/utils/common/renderUtils';
  108. // 注册打印modal
  109. const [registerPrintModal, { openModal: openPrintModal }] = useModal();
  110. const { createConfirm, createMessage } = useMessage();
  111. const props = defineProps({
  112. ccmNo: {
  113. type: [String, Number],
  114. default: '5',
  115. },
  116. });
  117. const isSpinning = ref(false);
  118. const activeKey = ref(1);
  119. const carPosition = {
  120. '5': [1, 2],
  121. '6': [2, 3, 4],
  122. };
  123. // 车辆信息
  124. const infoRef1 = ref();
  125. const infoRef2 = ref();
  126. const infoRef3 = ref();
  127. const infoRef4 = ref();
  128. const printCarInfoRefs = { infoRef1, infoRef2, infoRef3, infoRef4 };
  129. // 5号机堆垛
  130. const stackingList = ref<any[]>([]);
  131. const stackingObj = ref<any>({});
  132. const stackInfo = ref<any>({});
  133. // 车位1车辆信息
  134. // id: '',
  135. // licensePlate: '',
  136. // destination: '',
  137. // typeConfigId: undefined,
  138. // ccmNo: '',
  139. // ccmNo_dictText: '',
  140. // amountTotal: 0,
  141. // steel: '',
  142. // size: '',
  143. // positionNum: '',
  144. const vehicleInfo = ref<any>({
  145. info1: {},
  146. info2: {},
  147. info3: {},
  148. info4: {},
  149. });
  150. const getInfo = async (type?: number | undefined) => {
  151. // 获取车位1车辆信息
  152. try {
  153. isSpinning.value = true;
  154. if (type === 1 || type === undefined) {
  155. const fetchArr: any = [];
  156. carPosition[props.ccmNo].forEach((item) => {
  157. fetchArr.push(
  158. list({
  159. column: 'createTime',
  160. order: 'desc',
  161. pageNo: 1,
  162. pageSize: 1,
  163. positionNum: item,
  164. ccmNo: props.ccmNo,
  165. })
  166. );
  167. });
  168. await Promise.all(fetchArr).then((res) => {
  169. if (Array.isArray(res)) {
  170. res.forEach((item, index) => {
  171. if (item.records[0]) {
  172. vehicleInfo.value[`info${index + 1}`] = {
  173. ...item.records[0],
  174. oldLicensePlate: item.records[0].licensePlate,
  175. oldTypeConfigId: item.records[0].typeConfigId === '1024' ? undefined : item.records[0].typeConfigId,
  176. typeConfigId: item.records[0].typeConfigId === '1024' ? undefined : item.records[0].typeConfigId,
  177. oldBrandNum: item.records[0].brandNum,
  178. oldSize: item.records[0].size,
  179. };
  180. setTimeout(
  181. () => {
  182. printCarInfoRefs[`infoRef${index + 1}`] &&
  183. printCarInfoRefs[`infoRef${index + 1}`].value &&
  184. printCarInfoRefs[`infoRef${index + 1}`].value[0].getTableList();
  185. },
  186. 50 * (index + 1)
  187. );
  188. }
  189. });
  190. }
  191. });
  192. }
  193. const machineConfig = await getMachineConfig(props.ccmNo)[MachineConfigType.STACKING];
  194. stackInfo.value = machineConfig[0];
  195. if (type === 2 || type === undefined) {
  196. await getStackInfoList(machineConfig[0].id);
  197. }
  198. } catch (error) {
  199. console.log(error);
  200. } finally {
  201. isSpinning.value = false;
  202. start();
  203. }
  204. };
  205. const { start, stop } = useTimeoutFn(getInfo, 10000);
  206. // 获取堆垛机堆垛信息
  207. // 获取当前堆垛信息
  208. const getStackInfoList = async (typeConfigId) => {
  209. const stackingInfo = await getStackInfo({ typeConfigId });
  210. let layerObj = {};
  211. if (stackingInfo.length) {
  212. stackingInfo.forEach((item) => {
  213. if (!layerObj[item.layer]) layerObj[item.layer] = [];
  214. layerObj[item.layer].push({ ...item, steelBillet: item.billetNos ? item.billetNos.split(',') : [] });
  215. });
  216. }
  217. stackingObj.value = layerObj;
  218. stackingList.value = Object.keys(layerObj)
  219. .sort((a, b) => Number(b) - Number(a))
  220. .map((item) => ({ label: `第${item}层`, value: item }));
  221. // nextTick(() => {
  222. // const element = document.getElementById(`operatorCC-stacking-wrapper`);
  223. // if (element) {
  224. // element.scrollIntoView({
  225. // behavior: 'smooth',
  226. // block: 'center',
  227. // inline: 'center',
  228. // });
  229. // }
  230. // });
  231. };
  232. // 修改类型
  233. function handleBtypeChange(v, record) {
  234. stop();
  235. createConfirm({
  236. iconType: 'warning',
  237. title: '确认修改',
  238. width: '460px',
  239. content: () => {
  240. return h('div', { style: { fontSize: '16px' } }, [
  241. h('span', null, `是否将车牌为`),
  242. h('span', { style: { fontSize: '18px', color: '#d48806' } }, `${record.licensePlate}`),
  243. h('span', null, `的`),
  244. h('span', { style: { fontSize: '18px', color: v === '1' ? '#cd201f' : '#3b5999' } }, `${v === '1' ? ' 热坯 ' : ' 冷坯 '}`),
  245. h('span', null, `改为`),
  246. h('span', { style: { fontSize: '18px', color: v === '1' ? '#3b5999' : '#cd201f' } }, `${v === '1' ? ' 冷坯 ' : ' 热坯 '}`),
  247. h('span', null, `?`),
  248. ]);
  249. },
  250. okText: '确认',
  251. cancelText: '取消',
  252. onOk: () => {
  253. return edit({ id: record.id, btype: v }).then(() => {
  254. getInfo();
  255. });
  256. },
  257. onCancel: () => {
  258. start();
  259. record.btype = v === '1' ? '0' : '1';
  260. },
  261. });
  262. }
  263. // 修改牌号,车号,目的地
  264. const handleChange = (options) => {
  265. const { type, value, carPositon } = options;
  266. console.log(options, value, value === undefined);
  267. if (value === undefined) return;
  268. stop();
  269. createConfirm({
  270. iconType: 'warning',
  271. title: '确认修改',
  272. width: '460px',
  273. content: () => {
  274. let title = '',
  275. content: any = '';
  276. if (type === 'licensePlate') {
  277. title = '是否修改车牌号为:';
  278. content = value;
  279. } else if (type === 'destination') {
  280. title = '是否修改目的地为:';
  281. const curDestination = destinationOptions[props.ccmNo].find((item) => item.value === value);
  282. content = curDestination ? curDestination.label : '';
  283. } else if (type === 'brandNum') {
  284. title = '是否修改牌号为:';
  285. content = render.renderDict(value, 'billet_spec');
  286. } else if (type === 'size') {
  287. title = '是否修改定尺为:';
  288. content = value;
  289. }
  290. return h('div', { style: { fontSize: '16px' } }, [
  291. h('span', null, title),
  292. h('span', { style: { fontSize: '18px', color: '#d48806' } }, content),
  293. ]);
  294. },
  295. onOk: () => {
  296. let params = { ...vehicleInfo.value[`info${carPositon}`] };
  297. if (type === 'destination') {
  298. const curDestination = destinationOptions[props.ccmNo].find((item) => item.value === value);
  299. params.destination = curDestination.label;
  300. }
  301. return edit(params).then(() => {
  302. getInfo();
  303. });
  304. },
  305. onCancel: () => {
  306. start();
  307. if (type === 'licensePlate') {
  308. vehicleInfo.value[`info${carPositon}`].licensePlate = vehicleInfo.value[`info${carPositon}`].oldLicensePlate;
  309. } else if (type === 'destination') {
  310. vehicleInfo.value[`info${carPositon}`].typeConfigId = vehicleInfo.value[`info${carPositon}`].oldTypeConfigId;
  311. } else if (type === 'brandNum') {
  312. vehicleInfo.value[`info${carPositon}`].brandNum = vehicleInfo.value[`info${carPositon}`].oldBrandNum;
  313. } else if (type === 'size') {
  314. vehicleInfo.value[`info${carPositon}`].size = vehicleInfo.value[`info${carPositon}`].oldSize;
  315. }
  316. },
  317. });
  318. };
  319. // 选择堆垛位置装车
  320. const selectedAddressId = ref<any[]>([]);
  321. const selectedAddress = ref<any[]>([]);
  322. const getSelectedStack = () => {
  323. return selectedAddress.value || [];
  324. };
  325. // 右键换位置
  326. const menuClick = (e, info) => {
  327. if (e.key === '1') {
  328. const selectedStackList = selectedAddress.value.filter((item) => !item.billetNos);
  329. if (!selectedStackList.length) {
  330. createMessage.error('请选择要移动的位置,且位置上没有钢坯!');
  331. return;
  332. }
  333. if (selectedStackList.length > 1) {
  334. createMessage.error('钢坯移动的空位置只能选择一个!');
  335. return;
  336. }
  337. createConfirm({
  338. iconType: 'warning',
  339. title: '确认更换位置',
  340. width: '460px',
  341. content: () => {
  342. return h('div', { style: { fontSize: '16px' } }, [
  343. h('span', null, `是否将`),
  344. h('span', { style: { fontSize: '18px', color: '#d48806' } }, `${info.layer}层${info.address}`),
  345. h('span', null, `更换到`),
  346. h('span', { style: { fontSize: '18px', color: '#cd201f' } }, `${selectedStackList[0].layer}层${selectedStackList[0].address}`),
  347. h('span', null, `?`),
  348. ]);
  349. },
  350. okText: '更换',
  351. cancelText: '取消',
  352. onOk: () => {
  353. const params = {
  354. stackId: info.id,
  355. locationChangeId: selectedStackList[0].id,
  356. };
  357. return stackLocationChange(params).then(() => {
  358. selectedAddressId.value = [];
  359. selectedAddress.value = [];
  360. refresh(2);
  361. });
  362. },
  363. });
  364. }
  365. };
  366. const handleStackClick = (v) => {
  367. const index = selectedAddressId.value.indexOf(v.id);
  368. if (index > -1) {
  369. selectedAddressId.value.splice(index, 1);
  370. selectedAddress.value.splice(index, 1);
  371. } else {
  372. selectedAddressId.value.push(v.id);
  373. selectedAddress.value.push(v);
  374. }
  375. };
  376. const stackToCar = async () => {
  377. try {
  378. const valiDesRes = validateCarDestination();
  379. if (!valiDesRes) {
  380. return;
  381. }
  382. const selectedStackList = selectedAddress.value.filter((item) => item.billetNos);
  383. if (!selectedStackList.length) {
  384. createMessage.error('请选择有钢坯的堆垛位置装车!');
  385. return;
  386. }
  387. const curDestination =
  388. destinationOptions[props.ccmNo].find((item) => item.value === vehicleInfo.value[`info${activeKey.value}`].typeConfigId) || {};
  389. const params = {
  390. storageBill: vehicleInfo.value[`info${activeKey.value}`] || {},
  391. belongTable: stackInfo.value?.belongTable,
  392. billetHotsendTypeConfigId: stackInfo.value.id,
  393. stackingAndLoadingVehiclesList: selectedStackList,
  394. destination: vehicleInfo.value[`info${activeKey.value}`].destination,
  395. destinationId: vehicleInfo.value[`info${activeKey.value}`].typeConfigId,
  396. destinationTable: curDestination.belongTable,
  397. billetHotsend: {
  398. ccmNo: props.ccmNo,
  399. isUpd: false,
  400. },
  401. };
  402. stop();
  403. isSpinning.value = true;
  404. await stackLoadSave(params);
  405. getInfo();
  406. } catch (error) {
  407. isSpinning.value = false;
  408. } finally {
  409. selectedAddressId.value = [];
  410. selectedAddress.value = [];
  411. }
  412. };
  413. // 验证是否有目的地
  414. const validateCarDestination = () => {
  415. const curVehicleInfo = vehicleInfo.value[`info${activeKey.value}`];
  416. if (!curVehicleInfo.typeConfigId || !curVehicleInfo.destination || curVehicleInfo.typeConfigId == 1024) {
  417. createMessage.error('请先选择装运单库名!');
  418. printCarInfoRefs[`infoRef${activeKey.value}`].value && printCarInfoRefs[`infoRef${activeKey.value}`].value[0].focusDestination();
  419. return false;
  420. }
  421. return true;
  422. };
  423. // 刷新
  424. const refresh = (type) => {
  425. stop();
  426. getInfo(type);
  427. };
  428. onMounted(() => {
  429. getInfo();
  430. });
  431. onUnmounted(() => {
  432. stop();
  433. });
  434. const refreshCarList = () => {
  435. stop();
  436. getInfo();
  437. };
  438. defineExpose({
  439. getSelectedStack,
  440. getStackInfo: () => stackInfo.value,
  441. getCurrentCar: () => vehicleInfo.value[`info${activeKey.value}`],
  442. refreshCarList: refreshCarList,
  443. valirDest: validateCarDestination,
  444. });
  445. </script>
  446. <style lang="less" scoped>
  447. @import '../../hotDelivery/components/metal.less';
  448. .car-info-spin {
  449. position: relative;
  450. height: 100%;
  451. :deep(.ant-spin-container) {
  452. display: flex;
  453. flex-direction: column;
  454. height: 100%;
  455. overflow: hidden;
  456. }
  457. .refresh-wrapper {
  458. position: absolute;
  459. left: 100px;
  460. right: 170px;
  461. }
  462. .ant-tabs {
  463. color: #dadada;
  464. :deep(.ant-tabs-tab) {
  465. font-size: 16px;
  466. background: #01396c;
  467. &.ant-tabs-tab-active {
  468. background: #0085ff;
  469. .ant-tabs-tab-btn {
  470. color: #fff;
  471. }
  472. }
  473. }
  474. }
  475. }
  476. .car-info-wrapper {
  477. position: relative;
  478. padding: 30px 10px 10px;
  479. border: 1px solid var(--op-border-color);
  480. border-radius: 6px;
  481. .licensePlate {
  482. width: 190px;
  483. background-color: #010c3a;
  484. position: absolute;
  485. top: -15px;
  486. left: 30px;
  487. font-size: 16px;
  488. color: var(--op-text-color-fff);
  489. text-align: center;
  490. }
  491. .print {
  492. position: absolute;
  493. right: 22px;
  494. top: 40px;
  495. }
  496. .change-type {
  497. position: absolute;
  498. right: 22px;
  499. top: -50px;
  500. gap: 10px;
  501. color: var(--op-text-color-fff);
  502. font-size: 20px;
  503. .ant-switch {
  504. background-color: #3b5999;
  505. :deep(.ant-switch-inner) {
  506. .ant-switch-inner-checked,
  507. .ant-switch-inner-unchecked {
  508. font-size: 17px;
  509. }
  510. }
  511. }
  512. .ant-switch.ant-switch-checked {
  513. background-color: #cd201f;
  514. }
  515. }
  516. }
  517. .stack-divider {
  518. font-size: 16px;
  519. margin-top: 10px;
  520. color: var(--op-text-color-fff);
  521. }
  522. .stacking-wrapper {
  523. flex: 1;
  524. overflow: auto;
  525. padding: 0;
  526. margin-top: 6px;
  527. padding-bottom: 20px;
  528. .selected-divider-row {
  529. margin-top: 5px;
  530. gap: 3px;
  531. }
  532. &.selected-divider .selected-divider-row .stacking-list-row {
  533. cursor: pointer;
  534. height: 24px;
  535. line-height: 20px;
  536. border: 1px solid var(--op-border-color);
  537. border-radius: 4px;
  538. font-size: 20px;
  539. }
  540. .stacking-list-divider {
  541. margin: 0;
  542. color: var(--vxe-danger-color, #f56c6c);
  543. }
  544. .stack-col {
  545. overflow: hidden;
  546. }
  547. .p-stack-col {
  548. padding-right: 0 !important;
  549. max-width: 11%;
  550. }
  551. .p-layer {
  552. width: 20px;
  553. margin-right: 10px;
  554. font-size: 20px;
  555. color: #f50;
  556. font-family: 'Kingsoft_Cloud_Font';
  557. line-height: 24px;
  558. text-align: center;
  559. }
  560. }
  561. </style>