|
@@ -0,0 +1,261 @@
|
|
|
+<template>
|
|
|
+ <BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :footer="null" :title="modalTitle" :height="800" width="80%">
|
|
|
+ <div class="rod-line-details-modal">
|
|
|
+ <BasicTable class="rod-line-details-table" :scroll="{ y: 670 }" :dataSource="tableData" @register="registerTable">
|
|
|
+ <!-- <template v-slot:bodyCell="{ column, record, text }">
|
|
|
+ <div v-if="column.dataIndex === 'billetNo'">
|
|
|
+ <div v-if="record.billetNo">
|
|
|
+ <div v-for="(item, index) in record.billetNos" :key="index">{{ item }}</div>
|
|
|
+ </div>
|
|
|
+ <span v-else>{{ text }}</span>
|
|
|
+ </div>
|
|
|
+ </template> -->
|
|
|
+ <!--操作栏-->
|
|
|
+ <template #action="{ record }">
|
|
|
+ <TableAction :actions="getTableAction(record)" />
|
|
|
+ </template>
|
|
|
+ </BasicTable>
|
|
|
+ </div>
|
|
|
+ </BasicModal>
|
|
|
+</template>
|
|
|
+<script setup lang="ts">
|
|
|
+ import { ref, nextTick } from 'vue';
|
|
|
+ import { BasicModal, useModalInner } from '/@/components/Modal';
|
|
|
+ import { BasicTable, TableAction, BasicColumn } from '/@/components/Table';
|
|
|
+ import { useListPage } from '/@/hooks/system/useListPage';
|
|
|
+ import { listShippingBill, removeBillets } from '../../shippingBill/shippingBill.api';
|
|
|
+ import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
+ import { groupArray } from '/@/views/billet/hotDelivery/common.data';
|
|
|
+
|
|
|
+ const { createConfirm } = useMessage();
|
|
|
+
|
|
|
+ const recordInfo = ref<any>({});
|
|
|
+ // 表格数据
|
|
|
+ const tableData = ref<any[]>([]);
|
|
|
+ const modalTitle = ref('装运明细');
|
|
|
+ const detailColumns: BasicColumn[] = [
|
|
|
+ {
|
|
|
+ title: '炉号',
|
|
|
+ align: 'center',
|
|
|
+ dataIndex: 'heatNo',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '组坯号',
|
|
|
+ align: 'center',
|
|
|
+ width: 280,
|
|
|
+ dataIndex: 'assemblyNumber',
|
|
|
+ ellipsis: false,
|
|
|
+ customRender(opt) {
|
|
|
+ const ph = opt.record.assemblyNumber;
|
|
|
+ if (!ph) return '';
|
|
|
+ const phArr = groupArray(ph.split(','), 2);
|
|
|
+
|
|
|
+ return phArr.join('\n\r').replaceAll(',', '、');
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '坯号',
|
|
|
+ align: 'center',
|
|
|
+ width: 300,
|
|
|
+ dataIndex: 'billetNo',
|
|
|
+ customRender(opt) {
|
|
|
+ const { billetNos, billetNo } = opt.record;
|
|
|
+ if (billetNos) {
|
|
|
+ const phArr = groupArray(billetNos, 2);
|
|
|
+ return phArr.join('\n\r').replaceAll(',', '、');
|
|
|
+ }
|
|
|
+ return billetNo;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '定尺',
|
|
|
+ align: 'center',
|
|
|
+ width: 80,
|
|
|
+ dataIndex: 'size',
|
|
|
+ customRender: ({ record }) => {
|
|
|
+ return record.size || record.length;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '垛位',
|
|
|
+ align: 'center',
|
|
|
+ width: 90,
|
|
|
+ dataIndex: 'stackAddr',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '堆垛层号(1-20)',
|
|
|
+ align: 'center',
|
|
|
+ width: 110,
|
|
|
+ dataIndex: 'stackStorey',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '堆垛编号(1-9)',
|
|
|
+ align: 'center',
|
|
|
+ width: 110,
|
|
|
+ dataIndex: 'stackNum',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: 'createTime',
|
|
|
+ title: '创建日期',
|
|
|
+ },
|
|
|
+ ];
|
|
|
+
|
|
|
+ const props = defineProps({
|
|
|
+ info: {
|
|
|
+ type: Object,
|
|
|
+ default: () => ({}),
|
|
|
+ },
|
|
|
+ api: {
|
|
|
+ type: Function as PropType<(params: any) => Promise<any>>,
|
|
|
+ default: listShippingBill,
|
|
|
+ },
|
|
|
+ showActionColumn: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false,
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ // Emits声明
|
|
|
+ const emit = defineEmits(['register', 'success']);
|
|
|
+
|
|
|
+ const { tableContext } = useListPage({
|
|
|
+ designScope: 'rod-line-details-table',
|
|
|
+ tableProps: {
|
|
|
+ // api: listShippingBill,
|
|
|
+ // beforeFetch: (params) => {
|
|
|
+ // return Object.assign(params, { ...recordInfo.value });
|
|
|
+ // },
|
|
|
+ // afterFetch: async (record) => {
|
|
|
+ // // emit('success');
|
|
|
+ // },
|
|
|
+ immediate: false,
|
|
|
+ columns: detailColumns,
|
|
|
+ size: 'small',
|
|
|
+ useSearchForm: false,
|
|
|
+ showTableSetting: false,
|
|
|
+ striped: true,
|
|
|
+ showActionColumn: props.showActionColumn,
|
|
|
+ pagination: {
|
|
|
+ defaultPageSize: 50,
|
|
|
+ pageSize: 50,
|
|
|
+ },
|
|
|
+ actionColumn: {
|
|
|
+ width: 80,
|
|
|
+ title: '操作',
|
|
|
+ dataIndex: 'action',
|
|
|
+ fixed: 'right',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ // BasicTable绑定注册
|
|
|
+ const [registerTable, { setLoading }, {}] = tableContext;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 操作栏
|
|
|
+ */
|
|
|
+ function getTableAction(record) {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ label: '移除',
|
|
|
+ onClick: () => {
|
|
|
+ createConfirm({
|
|
|
+ iconType: 'warning',
|
|
|
+ title: '确认移除',
|
|
|
+ content: '是否移除选中数据',
|
|
|
+ okText: '确认',
|
|
|
+ cancelText: '取消',
|
|
|
+ onOk: () => {
|
|
|
+ const { storageBillId, ccmNo, heatNo, billetNos, shiftGroup, shift, assemblyNumber, stackStorey, stackNum, stackAddr } = record;
|
|
|
+
|
|
|
+ const params = {
|
|
|
+ id: storageBillId,
|
|
|
+ ccmNo,
|
|
|
+ heatNo,
|
|
|
+ billNos: billetNos.join(','),
|
|
|
+ shiftGroup,
|
|
|
+ shift,
|
|
|
+ assemblyNumber,
|
|
|
+ stackStorey,
|
|
|
+ stackNum,
|
|
|
+ stackAddr,
|
|
|
+ typeConfigId: recordInfo.value.typeConfigId,
|
|
|
+ destination: recordInfo.value.destination,
|
|
|
+ };
|
|
|
+
|
|
|
+ return removeBillets(params).then(() => {
|
|
|
+ getTableList();
|
|
|
+ emit('success');
|
|
|
+ });
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ const getTableList = async () => {
|
|
|
+ try {
|
|
|
+ setLoading(true);
|
|
|
+ const { id, ccmNo, heatNo, typeConfigId } = recordInfo.value;
|
|
|
+ const data = await props.api({
|
|
|
+ id,
|
|
|
+ ccmNo,
|
|
|
+ heatNo,
|
|
|
+ typeConfigId,
|
|
|
+ });
|
|
|
+
|
|
|
+ let newArr: any[] = [];
|
|
|
+ if (Array.isArray(data)) {
|
|
|
+ newArr = data;
|
|
|
+ } else {
|
|
|
+ for (let item in data) {
|
|
|
+ if (data[item] && data[item].length > 0) {
|
|
|
+ newArr = newArr.concat(data[item]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 数据结果按组批号分组
|
|
|
+ newArr = newArr.reduce((acc, cur) => {
|
|
|
+ const index = acc.findIndex((item) => cur.assemblyNumber && item.assemblyNumber === cur.assemblyNumber);
|
|
|
+ if (index === -1) {
|
|
|
+ acc.push({
|
|
|
+ ...cur,
|
|
|
+ billetNos: [cur.billetNo],
|
|
|
+ sizeList: cur.size ? [cur.size] : cur.length ? [cur.length] : [],
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ acc[index].billetNos.push(cur.billetNo);
|
|
|
+ acc[index].sizeList.push(cur.size || cur.length);
|
|
|
+ }
|
|
|
+ return acc;
|
|
|
+ }, []);
|
|
|
+
|
|
|
+ tableData.value = newArr.map((ele) => {
|
|
|
+ return {
|
|
|
+ ...ele,
|
|
|
+ size: ele.sizeList.filter((item, index) => ele.sizeList.indexOf(item) === index).join(',\n\r') + ',',
|
|
|
+ };
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error);
|
|
|
+ } finally {
|
|
|
+ setLoading(false);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ //表单赋值
|
|
|
+ const [registerModal, {}] = useModalInner(async (data) => {
|
|
|
+ try {
|
|
|
+ recordInfo.value = data.record;
|
|
|
+ nextTick(() => {
|
|
|
+ modalTitle.value = data.title || '装运明细-> ' + data.record.licensePlate;
|
|
|
+ getTableList();
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error);
|
|
|
+ }
|
|
|
+ });
|
|
|
+</script>
|
|
|
+<style lang="less" scoped></style>
|