123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733 |
- <template>
- <a-spin :spinning="isSpinning" wrapperClassName="car-info-spin">
- <div type="card">
- <div :key="item" style="margin-bottom: 20px" v-for="item in carPosition[ccmNo]">
- <div class="car-wei" :class="`car-wei-${item}`">
- <span class="num">{{ '车位' + item }}</span>
- <a-button size="large" type="primary" style="font-size: 18px; margin-left: 6px" @click="createChargeBill(item)">创建装运单</a-button>
- </div>
- <div class="car-info-wrapper">
- <div class="licensePlate"
- >装运车辆:{{ vehicleInfo['info' + item] && vehicleInfo['info' + item].licensePlate ? vehicleInfo['info' + item].licensePlate : '' }}</div
- >
- <print-car-info
- :ref="printCarInfoRefs[`infoRef${item}`]"
- :carPositon="item"
- :ccm-no="ccmNo"
- :info="vehicleInfo['info' + item]"
- @change="handleChange"
- @refresh="refreshCarList"
- />
- <div class="print">
- <a-button
- type="primary"
- v-if="vehicleInfo['info' + item] && vehicleInfo['info' + item].id"
- @click="
- () =>
- openPrintModal(true, {
- record: vehicleInfo['info' + item],
- typeConfigId: !vehicleInfo['info' + item].typeConfigId ? '1024' : vehicleInfo['info' + item].typeConfigId,
- type: 'offline',
- })
- "
- >打印</a-button
- >
- </div>
- <div class="change-type flex items-center" v-if="vehicleInfo['info' + item] && Object.keys(vehicleInfo['info' + item]).includes('btype')">
- <span>{{ vehicleInfo['info' + item].ccmNo_dictText }}</span>
- <span>/</span>
- <a-switch
- v-model:checked="vehicleInfo['info' + item].btype"
- checked-value="0"
- @change="(checked) => handleBtypeChange(checked, vehicleInfo['info' + item])"
- checked-children="热坯"
- un-checked-value="1"
- un-checked-children="冷坯"
- />
- </div>
- </div>
- </div>
- <!-- <a-tab-pane key="2" tab="车位2" force-render>Content of Tab Pane 2</a-tab-pane> -->
- </div>
- <div class="flex justify-between refresh-wrapper" :style="{ left: carPosition[ccmNo].length * 70 + 70 + 'px' }">
- <a-button size="large" type="primary" style="font-size: 18px" @click="refresh(1)"> 刷新 </a-button>
- <RouterLink :to="'/shippingBill/' + ccmNo" target="_blank">
- <a-button size="large" type="primary" style="font-size: 18px"> 装运列表 </a-button>
- </RouterLink>
- </div>
- <a-tabs
- v-model:activeKey="stackActiveKey"
- @change="
- (v) => {
- const index = stackList.findIndex((item) => item.id == v);
- stackInfo = stackList[index];
- getStackInfoList(v);
- }
- "
- >
- <a-tab-pane :key="item.id" :tab="item.typeName" v-for="item in stackList">
- <div
- v-if="stackingObj[stackActiveKey] && stackingObj[stackActiveKey].length"
- class="stacking-wrapper selected-divider flex flex-wrap"
- id="operatorCC-stacking-wrapper"
- >
- <div
- class="selected-divider-row flex flex-col"
- :id="`stackLayer${pitem.heatNo}`"
- v-for="pitem in stackingObj[stackActiveKey]"
- :key="pitem.heatNo"
- >
- <div class="p-layer flex justify-between">
- <span class="lu">炉号</span><span class="hao">{{ pitem.heatNo }}</span>
- </div>
- <div class="dtl-list">
- <div class="dtl-item flex justify-between" v-for="m in pitem.details">
- <span class="size">{{ m.stackingLength }}</span>
- <span>
- <span class="zhi">{{ m.stackingCount }}</span> 支</span
- >
- </div>
- </div>
- </div>
- </div>
- <a-empty v-else />
- </a-tab-pane>
- <template #rightExtra>
- <!-- <div>
- <a-button
- type="primary"
- v-if="vehicleInfo['info' + activeKey] && vehicleInfo['info' + activeKey].id && !vehicleInfo['info' + activeKey].outTime"
- danger
- @click="stackToCar"
- >
- 堆垛装车
- </a-button>
- <a-button style="background-color: #f5f5f5; color: #838383" v-else disabled>堆垛装车</a-button>
- </div> -->
- <a-button size="large" type="primary" style="font-size: 18px" @click="refresh(2)"> 刷新 </a-button>
- </template>
- </a-tabs>
- </a-spin>
- <!-- 打印 -->
- <printModal @register="registerPrintModal" />
- <!-- 快速创建装运单 -->
- <a-modal
- v-model:open="openCreateChargeBill"
- title="创建装运单"
- centered
- width="400px"
- ok-text="确认"
- :okButtonProps="{ loading: okLoading }"
- cancel-text="取消"
- @ok="confirmCreateChargeBill"
- @cancel="
- () => {
- openCreateChargeBill = false;
- }
- "
- >
- <div class="flex justify-center items-center" v-if="createChargeBillPositionNum == 2" style="margin: 20px 0">
- <div>选择铸机:</div>
- <JSearchSelect type="list" style="width: 277px" v-model:value="createChargeBillCcmNo" dict="lg_zj" placeholder="请选择" allowClear />
- </div>
- <div class="flex justify-center items-center" style="margin: 20px 0">
- <div>选择车辆:</div>
- <JSearchSelect type="list" style="width: 277px" v-model:value="createChargeBillCar" dict="lg_car" placeholder="请选择" allowClear />
- </div>
- </a-modal>
- </template>
- <script setup lang="ts">
- import { ref, onMounted, onUnmounted, h } from 'vue';
- import printCarInfo from './printCarInfo.vue';
- import { useTimeoutFn } from '/@/hooks/core/useTimeout';
- import { list, edit } from '../../shippingBill/shippingBill.api';
- import { stackLoadSave, stackLocationChange } from '../../hotDelivery/hotDelivery.api';
- import { getMachineConfig, MachineConfigType, destinationOptions } from '../../hotDelivery/common.data';
- import { useMessage } from '/@/hooks/web/useMessage';
- import printModal from '../../shippingBill/components/printModal.vue';
- import { useModal } from '/@/components/Modal';
- import { render } from '/@/utils/common/renderUtils';
- import { getStackInfoByCcmNo, quickCreateStorageBill } from '../operator.api';
- import JSearchSelect from '/@/components/Form/src/jeecg/components/JSearchSelect.vue';
- // 注册打印modal
- const [registerPrintModal, { openModal: openPrintModal }] = useModal();
- const { createConfirm, createMessage } = useMessage();
- const props = defineProps({
- ccmNo: {
- type: [String, Number],
- default: '5',
- },
- });
- const isSpinning = ref(false);
- const activeKey = ref(1);
- const carPosition = {
- '5': [1, 2],
- '6': [2, 3, 4],
- };
- // 车辆信息
- const infoRef1 = ref();
- const infoRef2 = ref();
- const infoRef3 = ref();
- const infoRef4 = ref();
- const printCarInfoRefs = { infoRef1, infoRef2, infoRef3, infoRef4 };
- // 5号机堆垛
- const stackingObj = ref<any>({});
- const stackInfo = ref<any>({});
- const stackActiveKey = ref('10');
- const stackList = ref<any[]>([]);
- // 车位1车辆信息
- // id: '',
- // licensePlate: '',
- // destination: '',
- // typeConfigId: undefined,
- // ccmNo: '',
- // ccmNo_dictText: '',
- // amountTotal: 0,
- // steel: '',
- // size: '',
- // positionNum: '',
- const vehicleInfo = ref<any>({
- info1: {},
- info2: {},
- info3: {},
- info4: {},
- });
- // 获取堆垛信息
- const getStackInfo = async () => {
- const machineConfig = await getMachineConfig(props.ccmNo)[MachineConfigType.STACKING];
- stackInfo.value = machineConfig[0];
- stackActiveKey.value = machineConfig[0].id;
- stackList.value = machineConfig;
- };
- const getInfo = async (type?: number | undefined) => {
- // 获取车位1车辆信息
- try {
- isSpinning.value = true;
- if (type === 1 || type === undefined) {
- const fetchArr: any = [];
- carPosition[props.ccmNo].forEach((item) => {
- fetchArr.push(
- list({
- column: 'createTime',
- order: 'desc',
- pageNo: 1,
- pageSize: 1,
- positionNum: item,
- ...(item == 2 ? {} : { ccmNo: props.ccmNo }),
- })
- );
- });
- await Promise.all(fetchArr).then((res) => {
- if (Array.isArray(res)) {
- res.forEach((item) => {
- if (item.records[0]) {
- vehicleInfo.value[`info${item.records[0].positionNum}`] = {
- ...item.records[0],
- oldLicensePlate: item.records[0].licensePlate,
- oldTypeConfigId: item.records[0].typeConfigId === '1024' ? undefined : item.records[0].typeConfigId,
- typeConfigId: item.records[0].typeConfigId === '1024' ? undefined : item.records[0].typeConfigId,
- oldBrandNum: item.records[0].brandNum,
- oldSize: item.records[0].size,
- };
- }
- });
- // setTimeout(() => {
- // printCarInfoRefs[`infoRef${activeKey.value}`] &&
- // printCarInfoRefs[`infoRef${activeKey.value}`].value &&
- // printCarInfoRefs[`infoRef${activeKey.value}`].value[0].getTableList();
- // }, 50);
- }
- });
- }
- if (type === 2 || type === undefined) {
- await getStackInfoList(stackActiveKey.value);
- }
- } catch (error) {
- console.log(error);
- } finally {
- isSpinning.value = false;
- start();
- }
- };
- const { start, stop } = useTimeoutFn(getInfo, 10000);
- // 获取堆垛机堆垛信息
- // 获取当前堆垛信息
- const getStackInfoList = async (typeConfigId) => {
- const stackingInfo = await getStackInfoByCcmNo({ ccmNo: props.ccmNo, typeConfigId });
- // stackingList.value = stackingInfo || [];
- stackingObj.value[typeConfigId] = stackingInfo || [];
- };
- // 修改类型
- function handleBtypeChange(v, record) {
- stop();
- createConfirm({
- iconType: 'warning',
- title: '确认修改',
- width: '460px',
- content: () => {
- return h('div', { style: { fontSize: '16px' } }, [
- h('span', null, `是否将车牌为`),
- h('span', { style: { fontSize: '18px', color: '#d48806' } }, `${record.licensePlate}`),
- h('span', null, `的`),
- h('span', { style: { fontSize: '18px', color: v === '1' ? '#cd201f' : '#3b5999' } }, `${v === '1' ? ' 热坯 ' : ' 冷坯 '}`),
- h('span', null, `改为`),
- h('span', { style: { fontSize: '18px', color: v === '1' ? '#3b5999' : '#cd201f' } }, `${v === '1' ? ' 冷坯 ' : ' 热坯 '}`),
- h('span', null, `?`),
- ]);
- },
- okText: '确认',
- cancelText: '取消',
- onOk: () => {
- return edit({ id: record.id, btype: v }).then(() => {
- getInfo();
- });
- },
- onCancel: () => {
- start();
- record.btype = v === '1' ? '0' : '1';
- },
- });
- }
- // 修改牌号,车号,目的地
- const handleChange = (options) => {
- const { type, value, carPositon } = options;
- console.log(options, value, value === undefined);
- if (value === undefined) return;
- stop();
- createConfirm({
- iconType: 'warning',
- title: '确认修改',
- width: '460px',
- content: () => {
- let title = '',
- content: any = '';
- if (type === 'licensePlate') {
- title = '是否修改车牌号为:';
- content = value;
- } else if (type === 'destination') {
- title = '是否修改目的地为:';
- const curDestination = destinationOptions[props.ccmNo].find((item) => item.value === value);
- content = curDestination ? curDestination.label : '';
- } else if (type === 'brandNum') {
- title = '是否修改牌号为:';
- content = render.renderDict(value, 'billet_spec');
- } else if (type === 'size') {
- title = '是否修改定尺为:';
- content = value;
- }
- return h('div', { style: { fontSize: '16px' } }, [
- h('span', null, title),
- h('span', { style: { fontSize: '18px', color: '#d48806' } }, content),
- ]);
- },
- onOk: () => {
- let params = { ...vehicleInfo.value[`info${carPositon}`] };
- if (type === 'destination') {
- const curDestination = destinationOptions[props.ccmNo].find((item) => item.value === value);
- params.destination = curDestination.label;
- }
- return edit(params).then(() => {
- getInfo();
- });
- },
- onCancel: () => {
- start();
- if (type === 'licensePlate') {
- vehicleInfo.value[`info${carPositon}`].licensePlate = vehicleInfo.value[`info${carPositon}`].oldLicensePlate;
- } else if (type === 'destination') {
- vehicleInfo.value[`info${carPositon}`].typeConfigId = vehicleInfo.value[`info${carPositon}`].oldTypeConfigId;
- } else if (type === 'brandNum') {
- vehicleInfo.value[`info${carPositon}`].brandNum = vehicleInfo.value[`info${carPositon}`].oldBrandNum;
- } else if (type === 'size') {
- vehicleInfo.value[`info${carPositon}`].size = vehicleInfo.value[`info${carPositon}`].oldSize;
- }
- },
- });
- };
- // 选择堆垛位置装车
- const selectedAddressId = ref<any[]>([]);
- const selectedAddress = ref<any[]>([]);
- const getSelectedStack = () => {
- return selectedAddress.value || [];
- };
- // 右键换位置
- const menuClick = (e, info) => {
- if (e.key === '1') {
- const selectedStackList = selectedAddress.value.filter((item) => !item.billetNos);
- if (!selectedStackList.length) {
- createMessage.error('请选择要移动的位置,且位置上没有钢坯!');
- return;
- }
- if (selectedStackList.length > 1) {
- createMessage.error('钢坯移动的空位置只能选择一个!');
- return;
- }
- createConfirm({
- iconType: 'warning',
- title: '确认更换位置',
- width: '460px',
- content: () => {
- return h('div', { style: { fontSize: '16px' } }, [
- h('span', null, `是否将`),
- h('span', { style: { fontSize: '18px', color: '#d48806' } }, `${info.layer}层${info.address}`),
- h('span', null, `更换到`),
- h('span', { style: { fontSize: '18px', color: '#cd201f' } }, `${selectedStackList[0].layer}层${selectedStackList[0].address}`),
- h('span', null, `?`),
- ]);
- },
- okText: '更换',
- cancelText: '取消',
- onOk: () => {
- const params = {
- stackId: info.id,
- locationChangeId: selectedStackList[0].id,
- };
- return stackLocationChange(params).then(() => {
- selectedAddressId.value = [];
- selectedAddress.value = [];
- refresh(2);
- });
- },
- });
- }
- };
- const tabChange = (key) => {
- printCarInfoRefs[`infoRef${key}`] && printCarInfoRefs[`infoRef${key}`].value && printCarInfoRefs[`infoRef${key}`].value[0].getTableList();
- };
- const handleStackClick = (v) => {
- const index = selectedAddressId.value.indexOf(v.id);
- if (index > -1) {
- selectedAddressId.value.splice(index, 1);
- selectedAddress.value.splice(index, 1);
- } else {
- selectedAddressId.value.push(v.id);
- selectedAddress.value.push(v);
- }
- };
- const stackToCar = async () => {
- try {
- const valiDesRes = validateCarDestination();
- if (!valiDesRes) {
- return;
- }
- const selectedStackList = selectedAddress.value.filter((item) => item.billetNos);
- if (!selectedStackList.length) {
- createMessage.error('请选择有钢坯的堆垛位置装车!');
- return;
- }
- const curDestination =
- destinationOptions[props.ccmNo].find((item) => item.value === vehicleInfo.value[`info${activeKey.value}`].typeConfigId) || {};
- const params = {
- storageBill: vehicleInfo.value[`info${activeKey.value}`] || {},
- belongTable: stackInfo.value?.belongTable,
- billetHotsendTypeConfigId: stackInfo.value.id,
- stackingAndLoadingVehiclesList: selectedStackList,
- destination: vehicleInfo.value[`info${activeKey.value}`].destination,
- destinationId: vehicleInfo.value[`info${activeKey.value}`].typeConfigId,
- destinationTable: curDestination.belongTable,
- billetHotsend: {
- ccmNo: props.ccmNo,
- isUpd: false,
- },
- };
- stop();
- isSpinning.value = true;
- await stackLoadSave(params);
- getInfo();
- } catch (error) {
- isSpinning.value = false;
- } finally {
- selectedAddressId.value = [];
- selectedAddress.value = [];
- }
- };
- // 验证是否有目的地
- const validateCarDestination = () => {
- const curVehicleInfo = vehicleInfo.value[`info${activeKey.value}`];
- if (!curVehicleInfo.typeConfigId || !curVehicleInfo.destination || curVehicleInfo.typeConfigId == 1024) {
- createMessage.error('请先选择装运单库名!');
- printCarInfoRefs[`infoRef${activeKey.value}`].value && printCarInfoRefs[`infoRef${activeKey.value}`].value[0].focusDestination();
- return false;
- }
- return true;
- };
- // 创建装车单
- const openCreateChargeBill = ref(false);
- const createChargeBillCcmNo = ref(props.ccmNo);
- const createChargeBillPositionNum = ref(1);
- const createChargeBillCar = ref(undefined);
- const okLoading = ref(false);
- const createChargeBill = async (pn) => {
- openCreateChargeBill.value = true;
- createChargeBillPositionNum.value = pn;
- createChargeBillCcmNo.value = props.ccmNo;
- createChargeBillCar.value = undefined;
- };
- const confirmCreateChargeBill = async () => {
- try {
- if (createChargeBillPositionNum.value == 2 && !createChargeBillCcmNo.value) {
- createMessage.error('请选择铸机号!');
- return;
- }
- if (!createChargeBillCar.value) {
- createMessage.error('请选择车辆!');
- return;
- }
- okLoading.value = true;
- await quickCreateStorageBill({
- ccmNo: createChargeBillCcmNo.value,
- licensePlate: createChargeBillCar.value,
- positionNum: createChargeBillPositionNum.value,
- });
- refresh(1);
- openCreateChargeBill.value = false;
- okLoading.value = false;
- } catch (error) {
- okLoading.value = false;
- }
- };
- // 刷新
- const refresh = (type?: number) => {
- stop();
- getInfo(type);
- };
- onMounted(() => {
- getStackInfo();
- getInfo();
- });
- onUnmounted(() => {
- stop();
- });
- const refreshCarList = () => {
- selectedAddressId.value = [];
- selectedAddress.value = [];
- stop();
- getInfo();
- };
- defineExpose({
- getSelectedStack,
- getStackInfo: () => stackInfo.value,
- getCurrentCar: () => vehicleInfo.value[`info${activeKey.value}`],
- refreshCarList: refreshCarList,
- valirDest: validateCarDestination,
- });
- </script>
- <style lang="less" scoped>
- @import '../../hotDelivery/components/metal.less';
- .car-info-spin {
- position: relative;
- height: 100%;
- overflow: auto;
- :deep(.ant-spin-container) {
- display: flex;
- flex-direction: column;
- height: 100%;
- overflow: auto;
- }
- .refresh-wrapper {
- position: absolute;
- left: 100px;
- right: 170px;
- }
- .ant-tabs {
- color: #dadada;
- :deep(.ant-tabs-tab) {
- font-size: 16px;
- background: #01396c;
- margin-left: 6px;
- padding: 8px 12px;
- border-radius: 6px 6px 0 0;
- &.ant-tabs-tab-active {
- background: #0085ff;
- .ant-tabs-tab-btn {
- color: #fff;
- }
- }
- }
- }
- .car-wei {
- height: 58px;
- font-size: 20px;
- color: #fff;
- .num {
- display: inline-block;
- background: #01396c;
- border-radius: 4px 4px 0 0;
- padding: 6px 10px;
- }
- }
- .car-wei-1 {
- margin-top: 0;
- }
- }
- .car-info-wrapper {
- position: relative;
- padding: 30px 10px 10px;
- border: 1px solid var(--op-border-color);
- border-radius: 6px;
- .licensePlate {
- width: 190px;
- background-color: #010c3a;
- position: absolute;
- top: -15px;
- left: 30px;
- font-size: 16px;
- color: var(--op-text-color-fff);
- text-align: center;
- }
- .print {
- position: absolute;
- right: 22px;
- top: 40px;
- }
- .change-type {
- position: absolute;
- right: 22px;
- top: -50px;
- gap: 10px;
- color: var(--op-text-color-fff);
- font-size: 20px;
- .ant-switch {
- background-color: #3b5999;
- :deep(.ant-switch-inner) {
- .ant-switch-inner-checked,
- .ant-switch-inner-unchecked {
- font-size: 17px;
- }
- }
- }
- .ant-switch.ant-switch-checked {
- background-color: #cd201f;
- }
- }
- }
- .stack-divider {
- font-size: 16px;
- margin-top: 10px;
- color: var(--op-text-color-fff);
- }
- .stacking-wrapper {
- flex: unset;
- overflow: unset;
- padding: 0;
- margin-top: 6px;
- padding-bottom: 20px;
- gap: 10px 12px;
- .selected-divider-row {
- width: 158px;
- min-height: 120px;
- background: #08184d;
- border-radius: 2px;
- border: 1px solid #001966;
- padding: 6px;
- margin-top: 0;
- margin-bottom: 10px;
- }
- &.selected-divider .selected-divider-row .stacking-list-row {
- cursor: pointer;
- height: 24px;
- line-height: 20px;
- border: 1px solid var(--op-border-color);
- border-radius: 4px;
- font-size: 20px;
- }
- .stacking-list-divider {
- margin: 0;
- color: var(--vxe-danger-color, #f56c6c);
- }
- .stack-col {
- overflow: hidden;
- }
- .p-stack-col {
- padding-right: 0 !important;
- max-width: 11%;
- }
- .p-layer {
- font-family: 'Kingsoft_Cloud_Font';
- line-height: 32px;
- font-weight: 500;
- font-size: 20px;
- color: #cccccc;
- border-bottom: 1px solid #0b2066;
- .hao {
- color: #99b1ff;
- }
- }
- .dtl-item {
- font-weight: 400;
- font-size: 18px;
- color: #808080;
- margin-top: 6px;
- .zhi {
- color: #fff;
- }
- }
- }
- </style>
|