car-copy.vue 19 KB

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