car.vue 19 KB

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