diff --git a/src/components/a-detail-panel/ADetailPanel.tsx b/src/components/a-detail-panel/ADetailPanel.tsx index f9bafdf..957baca 100644 --- a/src/components/a-detail-panel/ADetailPanel.tsx +++ b/src/components/a-detail-panel/ADetailPanel.tsx @@ -19,7 +19,7 @@ interface ADetailPanelType { } const component = defineComponent( - (props: ADetailPanelType, {slots, expose}: SetupContext) => { + (props: ADetailPanelType, {slots, expose}: SetupContext) => { const showDialog = ref(false) const loading = ref(false) @@ -28,10 +28,10 @@ const component = defineComponent( const dialogCloseHandler = () => { detailData.$reset() } - const open = (data: T) => { + const open = (id: string) => { showDialog.value = true loading.value = true - props.detailsLoader(data.id!) + props.detailsLoader(id) .then(res => { detailData.$reset((res?.data ?? {}) as any) }) @@ -70,8 +70,8 @@ const component = defineComponent( }, ) -export interface ADetailPanelInstance extends InstanceType { - open: (data: T) => void +export interface ADetailPanelInstance extends InstanceType { + open: (id: string) => void } diff --git a/src/components/a-page/a-table-page/ATablePage.tsx b/src/components/a-page/a-table-page/ATablePage.tsx index 15c36dc..6dfbf9c 100644 --- a/src/components/a-page/a-table-page/ATablePage.tsx +++ b/src/components/a-page/a-table-page/ATablePage.tsx @@ -623,6 +623,8 @@ const component = defineComponent( class="data-table" span-method={props.table.spanMethod} onSort-change={sortChangeHandler} + summary-method={props.table.summaryMethod} + show-summary={props.table.summaryMethod != null} > { slots.columns?.() diff --git a/src/components/a-page/a-table-page/build-summary-method.ts b/src/components/a-page/a-table-page/build-summary-method.ts new file mode 100644 index 0000000..7ae6b93 --- /dev/null +++ b/src/components/a-page/a-table-page/build-summary-method.ts @@ -0,0 +1,24 @@ +import type { TableColumnCtx } from 'element-plus' +import type { DefaultRow } from 'element-plus/es/components/table/src/table/defaults' + +export interface SummaryMethodProps { + columns: TableColumnCtx[] + data: T[] +} + +export type SummariesType = { + [key in keyof T]?: (data: T[]) => string +} & { + [key: string]: (data: T[]) => string +} + +export default function buildSummaryMethod(summaries: SummariesType) { + return ({columns, data}: SummaryMethodProps) => { + const summary: string[] = [ '合计' ] + for (let i = 1; i < columns.length; i++) { + const column = columns[i] + summary[i] = summaries[column.property]?.(data) ?? '' + } + return summary + } +} diff --git a/src/pages/order/book/Book.vue b/src/pages/order/book/Book.vue index 0a99ad1..931b6e2 100644 --- a/src/pages/order/book/Book.vue +++ b/src/pages/order/book/Book.vue @@ -44,7 +44,7 @@ - + @@ -100,9 +117,10 @@ import BookDetail from '@/pages/order/book/BookDetail.vue' import type { R } from '@/common/utils/http-util.ts' import DispatchForm from '@/pages/order/book/DispatchForm.vue' import OrderApi from '@/pages/order/order-api.ts' +import Strings from '@/common/utils/strings.ts' const props = defineProps<{ - defaultOrderCategory: 'XiaoShou' | 'HuiShou' | 'DuanBo' + bizType: 'XiaoShou' | 'HuiShou' | 'DuanBo' }>() const tablePageIns = useTemplateRef('tablePage') @@ -122,7 +140,8 @@ const tablePageProps = buildTablePageProps +(it1.settleMoney ?? 0)).reduce((a: number, b: number) => a + b, 0) ?? 0 dataList.push({ ...record, ...it, + settleMoney, + orderId: record.id, rowCount: i === 0 ? transRecodes.length : 0, } as OrderTypes.TableData) } @@ -185,7 +207,6 @@ const tablePageProps = buildTablePageProps - - - + + + + + + + + + @@ -79,14 +91,17 @@ import ADetailPanel, { } from '@/components/a-detail-panel/ADetailPanel.tsx' import TransRecode, { buildTransRecodeProps } from '@/pages/order/trans-recode/TransRecode.tsx' import DispatchForm from '@/pages/order/book/DispatchForm.vue' -import { transStatusColor } from '@/pages/order/constants.ts' +import { + transStatus, + transStatusColor, +} from '@/pages/order/constants.ts' import { elIcons } from '@/common/element/element.ts' import Strings from '@/common/utils/strings.ts' import OrderApi from '@/pages/order/order-api.ts' -const detailPanelIns = useTemplateRef>('detailPanel') +const detailPanelIns = useTemplateRef('detailPanel') const dispatchFormIns = useTemplateRef>('dispatchForm') - +let orderId = '' const transRecodeProps = buildTransRecodeProps({ moduleValue: [], selectable: true, @@ -97,7 +112,7 @@ const transRecodeProps = buildTransRecodeProps({ function dispatch(data: OrderTypes.SearchOrderResult, transId?: string, trainNum?: number) { dispatchFormIns.value?.open({ - orderId: data.id, + // orderId: data.id, sn: data.sn, transIds: transId == null ? transRecodeProps.moduleValue : [ transId ], transOrgId: data.transOrgId, @@ -105,14 +120,21 @@ function dispatch(data: OrderTypes.SearchOrderResult, transId?: string, trainNum }) } +function succ() { + detailPanelIns.value?.open(orderId) +} + const detailPanelProps = buildDetailPanelProps({ title: '订单详情', width: '80vw', - detailsLoader: OrderApi.detail, + detailsLoader(id) { + return OrderApi.detail(id, 'YuYue') + }, }) defineExpose({ open(data: OrderTypes.TableData) { - detailPanelIns.value?.open(data) + orderId = data.orderId! + detailPanelIns.value?.open(data.orderId!) }, }) diff --git a/src/pages/order/book/DispatchForm.vue b/src/pages/order/book/DispatchForm.vue index 8002307..712ef55 100644 --- a/src/pages/order/book/DispatchForm.vue +++ b/src/pages/order/book/DispatchForm.vue @@ -14,6 +14,7 @@ let transOrgId = ref(undefined) let sn = ref(undefined) let trainNum = ref(undefined) +const emits = defineEmits([ 'succ' ]) const formPanelProps = buildFormPanelProps({ title: '派单', labelWidth: '0', @@ -21,12 +22,14 @@ const formPanelProps = buildFormPanelProps({ return Promise.resolve({}) }, doSubmit(data) { - return OrderApi.dispatch({ - orderId: orderId!, - transIds: transIds!, + return OrderApi.assignmentDriver({ + orderId: orderId, + orderTransId: transIds, driverId: data.driverId, }) - .then(() => true) + .then(() => { + emits('succ') + }) }, rules: () => { return { diff --git a/src/pages/order/book/product/ProductBook.vue b/src/pages/order/book/product/ProductBook.vue index 4bbd7df..1bcd5f0 100644 --- a/src/pages/order/book/product/ProductBook.vue +++ b/src/pages/order/book/product/ProductBook.vue @@ -3,7 +3,7 @@ import Book from '@/pages/order/book/Book.vue' diff --git a/src/pages/order/realtime/InOutPanel.vue b/src/pages/order/realtime/InOutPanel.vue index 1f86698..7c32192 100644 --- a/src/pages/order/realtime/InOutPanel.vue +++ b/src/pages/order/realtime/InOutPanel.vue @@ -7,6 +7,7 @@ import { ElMessage, type FormInstance, } from 'element-plus' +import OrderApi from '@/pages/order/order-api.ts' const orderData = Utils.resetAble(reactive<{ id: string @@ -21,6 +22,8 @@ const title = computed(() => { return `${orderData.licensePlate} ${orderData.state}` }) +const emits = defineEmits([ 'succ' ]) + const formIns = useTemplateRef('formRef') const inOutData = Utils.resetAble(reactive({ @@ -37,12 +40,25 @@ function dialogCloseHandler() { function submitHandler() { submiting.value = true - FormUtil.submit(formIns, () => Promise.resolve()) + const data = { + orderTransId: orderData.id, + weight: (inOutData.weight ?? 0) * 1000, + frontPhoto: inOutData.headerPhoto, + bodyPhoto: inOutData.bodyPhoto, + } + FormUtil.submit(formIns, () => { + if (orderData.state === '进场') { + return OrderApi.truckComing(data).then(() => true) + } else { + return OrderApi.truckLeaving(data).then(() => true) + } + }) .then(res => { ElMessage.success(`${title.value}成功`) if ((res ?? true)) { showDialog.value = false } + emits('succ') }) .finally(() => { submiting.value = false diff --git a/src/pages/order/realtime/Realtime.vue b/src/pages/order/realtime/Realtime.vue index bc429ce..f0e992a 100644 --- a/src/pages/order/realtime/Realtime.vue +++ b/src/pages/order/realtime/Realtime.vue @@ -36,11 +36,11 @@ - + + @@ -108,21 +132,24 @@ import { checkStatus, checkStatusColor, paymentStatusColor, + summaryMethod, transStatus, transStatusColor, } from '@/pages/order/constants.ts' import InOutPanel from '@/pages/order/realtime/InOutPanel.vue' -import { ElMessage } from 'element-plus' import { useTemplateRef } from 'vue' import type { R } from '@/common/utils/http-util.ts' import RealtimeDetail from '@/pages/order/realtime/RealtimeDetail.vue' +import CheckPanel from '@/pages/order/realtime/CheckPanel.vue' +import OrderApi from '@/pages/order/order-api.ts' const props = defineProps<{ - defaultOrderCategory: 'XiaoShou' | 'HuiShou' | 'DuanBo' + bizType: 'XiaoShou' | 'HuiShou' | 'DuanBo' }>() const tablePageIns = useTemplateRef('tablePage') const realtimeDetailIns = useTemplateRef>('realtimeDetail') const inOutPanelIns = useTemplateRef>('inOutPanel') +const checkPanelIns = useTemplateRef>('checkPanel') function research() { tablePageIns.value?.doSearch() @@ -137,112 +164,35 @@ const tablePageProps = buildTablePageProps { - const records = res.data.records - const dataList: OrderTypes.TableData[] = [] - res.data.records = dataList - for (const record of records) { - const transRecodes = record.transRecodes ?? [] - record.transRecodes = undefined - for (let i = 0; i < transRecodes.length; i++) { - const it = transRecodes[i] - dataList.push({ - ...record, - ...it, - rowCount: i === 0 ? transRecodes.length : 0, - } as OrderTypes.TableData) - } - } - return res as R> - }) - }, */ paging(param: OrderTypes.SearchOrderParam) { - return Promise.resolve({ - code: 200, - data: { - current: param.current, - size: param.size, - total: 100, - records: [ - { - rowCount: 3, - id: '123', - sn: '202308240001', - orderTime: '2023-08-24 10:00:00', - contacts: '张三', - phone: '13800000000', - projectName: '项目A', - stationName: '站点B', - goodsName: '商品X', - unit: '吨', - customerMemo: '客户备注', - estimatedQuantity: 100, - estimatedTrainNum: 2, - transDistance: 500, - orderCategoryTxt: '订单类型A', - transStatusTxt: '已进场', - transStatus: 'YiJinChang', - checkStatus: 'YiKanLiao', - checkStatusTxt: '未勘料', - paymentStatusTxt: '未支付', - truckLicensePlate: '苏A9B905', - }, - { - rowCount: 0, - id: '123', - sn: '202308240001', - orderTime: '2023-08-24 10:00:00', - contacts: '张三', - phone: '13800000000', - projectName: '项目A', - stationName: '站点B', - goodsName: '商品X', - unit: '吨', - customerMemo: '客户备注', - estimatedQuantity: 100, - estimatedTrainNum: 2, - transDistance: 500, - orderCategoryTxt: '订单类型A', - transStatusTxt: '运输中', - transStatus: 'YunShuZhong', - checkStatus: 'WeiKanLiao', - checkStatusTxt: '未勘料', - paymentStatusTxt: '未支付', - truckLicensePlate: '苏A9B905', - }, - { - rowCount: 0, - id: '123', - sn: '202308240001', - orderTime: '2023-08-24 10:00:00', - contacts: '张三', - phone: '13800000000', - projectName: '项目A', - stationName: '站点B', - goodsName: '商品X', - unit: '吨', - customerMemo: '客户备注', - estimatedQuantity: 100, - estimatedTrainNum: 2, - transDistance: 500, - orderCategoryTxt: '订单类型A', - transStatusTxt: '已进场', - transStatus: 'YiJinChang', - checkStatus: 'WeiKanLiao', - checkStatusTxt: '未勘料', - paymentStatusTxt: '未支付', - truckLicensePlate: '苏A9B905', - }, - ] as OrderTypes.TableData[], - }, - } as R>) + return OrderApi.paging(param) + .then(res => { + const records = res.data.records + const dataList: OrderTypes.TableData[] = [] + res.data.records = dataList + for (const record of records) { + const transRecodes = (record.transRecodes ?? []) as TransRecode[] + record.transRecodes = undefined + for (let i = 0; i < transRecodes.length; i++) { + const it = transRecodes[i] as TransRecode + const settleMoney = it.paymentRecords?.map(it1 => +(it1.settleMoney ?? 0)).reduce((a: number, b: number) => a + b, 0) ?? 0 + dataList.push({ + ...record, + ...it, + settleMoney, + orderId: record.id, + rowCount: i === 0 ? transRecodes.length : 0, + } as OrderTypes.TableData) + } + } + return res as R> + }) }, }, table: { @@ -258,8 +208,9 @@ const tablePageProps = buildTablePageProps - - - + + + + + + + + + - + @@ -132,14 +144,19 @@ import Strings from '@/common/utils/strings.ts' import AIcon from '@/components/a-icon/AIcon.vue' import OrderApi from '@/pages/order/order-api.ts' -const detailPanelIns = useTemplateRef>('detailPanel') +const detailPanelIns = useTemplateRef('detailPanel') -const transRecodeProps = buildTransRecodeProps({}) +const transRecodeProps = buildTransRecodeProps({ + enableSummary: true, +}) const detailPanelProps = buildDetailPanelProps({ title: '订单详情', width: '80vw', - detailsLoader: OrderApi.detail, + detailsLoader(id) { + return OrderApi.detail(id, 'ShiShi') + }, + }) @@ -158,7 +175,7 @@ function kanliao(data: OrderTypes.TransRecode) { defineExpose({ open(data: OrderTypes.TableData) { - detailPanelIns.value?.open(data) + detailPanelIns.value?.open(data.orderId!) }, }) diff --git a/src/pages/order/realtime/product/ProductRealtime.vue b/src/pages/order/realtime/product/ProductRealtime.vue index 524981e..d5f9f9a 100644 --- a/src/pages/order/realtime/product/ProductRealtime.vue +++ b/src/pages/order/realtime/product/ProductRealtime.vue @@ -3,7 +3,7 @@ import Realtime from '@/pages/order/realtime/Realtime.vue'