| | |
| | | return count.toFixed(2) |
| | | } |
| | | |
| | | //合并显示其他列 |
| | | const handleDynamicColumns = (data,title) => { |
| | | // 1. 收集所有行的otherColumns字段(去重) |
| | | const allOtherFields = new Set(); |
| | | data.forEach(row => { |
| | | if (!row || !row.otherColumns) return; |
| | | |
| | | let parsedOtherColumns; |
| | | try { |
| | | // 核心:将字符串解析为JSON |
| | | parsedOtherColumns = JSON.parse(row.otherColumns); |
| | | } catch (e) { |
| | | console.error('解析otherColumns失败:', e, '原始数据:', row.otherColumns); |
| | | return; |
| | | } |
| | | |
| | | // 2. 从解析后的JSON中收集字段(支持数组或对象格式) |
| | | if (Array.isArray(parsedOtherColumns)) { |
| | | // 数组格式:[{ key: 'field1', label: '字段1', value: '值1' }, ...] |
| | | parsedOtherColumns.forEach(item => { |
| | | if (item.key) allOtherFields.add(item.key); |
| | | }); |
| | | } else if (typeof parsedOtherColumns === 'object' && parsedOtherColumns !== null) { |
| | | // 对象格式:{ field1: { label: '字段1', value: '值1' }, ... } |
| | | Object.keys(parsedOtherColumns).forEach(key => { |
| | | allOtherFields.add(key); |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | // 2. 生成动态子列(作为processList的children) |
| | | const otherColumns = Array.from(allOtherFields).map(field => { |
| | | // 尝试获取字段对应的label(优先取第一个出现的label) |
| | | let label=field; |
| | | title.forEach(item=>{ |
| | | if(field==item.column){ |
| | | label=item.alias |
| | | } |
| | | }) |
| | | return { |
| | | title: label, |
| | | field: `otherColumnsJson.${field}`, |
| | | width: 120, |
| | | align: 'center', |
| | | // 处理字段值显示(兼容数组/对象类型的otherColumns) |
| | | formatter: ({ row }) => { |
| | | return row.otherColumnsJson?.[field] || ''; |
| | | |
| | | } |
| | | }; |
| | | }); |
| | | |
| | | // 3. 定义父级列processList,包含动态子列 |
| | | const processList = { |
| | | title: t('其他列'), |
| | | field: 'process', |
| | | children: otherColumns // 将动态列作为子列 |
| | | }; |
| | | |
| | | // 4. 先移除已存在的process列(避免重复),再添加新列 |
| | | gridOptions.columns = gridOptions.columns.filter(col => col.field !== 'process'); |
| | | gridOptions.columns.push(processList); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | watch(props, (newVal) => { |
| | |
| | | basicProp.value.pageTotal = res.data.total.pageTotal |
| | | basicProp.value.dataTotal = res.data.total.total |
| | | orderInfo.reportFormDate = res.data.selectDate |
| | | |
| | | //订单明细报表 |
| | | if (props.childrenData.url === '/order/getOrderReport') { |
| | | const dataList = res.data.data || []; |
| | | handleDynamicColumns(dataList,res.data.title) |
| | | } |
| | | } |
| | | }) |
| | | return |
| | |
| | | basicProp.value.pageTotal = res.data.total.pageTotal |
| | | basicProp.value.dataTotal = res.data.total.total |
| | | orderInfo.reportFormDate = res.data.selectDate |
| | | |
| | | |
| | | } |
| | | }) |
| | | } |
| | |
| | | import { ref} from "vue" |
| | | import request from "@/utils/request" |
| | | import {useI18n} from "vue-i18n"; |
| | | import {filterChanged} from "@/hook"; |
| | | |
| | | const { t } = useI18n() |
| | | const childrenData = ref({ |
| | |
| | | {field: 'productId',width:120, title: t('order.productId'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: 'productName',width:120, title: t('order.product'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: 'orderNumber',width:120, title: t('order.OrderNum'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | // {field: 'buildingNumber',width:120, title: '楼号',filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: 'buildingNumber',width:120, title: t('order.buildingNumber'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: 'width',width:120, title: t('order.width'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: 'height',width:120, title: t('order.height'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: 'quantity',width:120, title: t('order.quantity'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | |
| | | private String productName; |
| | | @ExcelProperty("订单序号") |
| | | private Integer orderNumber; |
| | | @ExcelProperty("楼层编号") |
| | | private String buildingNumber; |
| | | @ExcelProperty("宽") |
| | | private Double width; |
| | | @ExcelProperty("高") |
| | |
| | | |
| | | import java.time.LocalDate; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Data |
| | | @TableName("sd.`order_detail`") |
| | |
| | | private Integer landingSequence; |
| | | @TableField(exist= false,select = false) |
| | | private Double thickness; |
| | | @TableField(exist= false,select = false) |
| | | private Map<String, Object> otherColumnsJson; |
| | | |
| | | //用于智能分架 |
| | | @TableField(exist= false,select = false) |
| | |
| | | private final WorkOrderMapper workOrderMapper; |
| | | private final FlowCardMapper flowCardMapper; |
| | | |
| | | private final BasicOtherMoneyMapper basicOtherMoneyMapper; |
| | | |
| | | private final OrderProcessDetailMapper orderProcessDetailMapper; |
| | | public OrderService(OrderMapper orderMapper, OrderDetailMapper orderDetailMapper, OrderGlassDetailMapper orderGlassDetailMapper, OrderProcessDetailMapper orderProcessDetailMapper, SysErrorService sysErrorService, OrderOtherMoneyMapper orderOtherMoneyMapper, ProductMapper productMapper, LogService logService, WorkOrderMapper workOrderMapper, FlowCardMapper flowCardMapper) { |
| | | public OrderService(OrderMapper orderMapper, OrderDetailMapper orderDetailMapper, OrderGlassDetailMapper orderGlassDetailMapper, OrderProcessDetailMapper orderProcessDetailMapper, SysErrorService sysErrorService, OrderOtherMoneyMapper orderOtherMoneyMapper, ProductMapper productMapper, LogService logService, WorkOrderMapper workOrderMapper, FlowCardMapper flowCardMapper, BasicOtherMoneyMapper basicOtherMoneyMapper) { |
| | | this.orderMapper = orderMapper; |
| | | this.orderDetailMapper = orderDetailMapper; |
| | | this.orderGlassDetailMapper = orderGlassDetailMapper; |
| | |
| | | this.logService = logService; |
| | | this.workOrderMapper = workOrderMapper; |
| | | this.flowCardMapper = flowCardMapper; |
| | | this.basicOtherMoneyMapper = basicOtherMoneyMapper; |
| | | } |
| | | |
| | | public boolean saveOrder(Map<String,Object> orderMap) throws Exception { |
| | |
| | | endDate = selectDate.get(1); |
| | | } |
| | | } |
| | | List<OrderDetail> orderDetailList = orderDetailMapper.getOrderReport(offset, pageSize, startDate, endDate, orderDetail,model,scope); |
| | | List<BasicOtherMoney> basicOtherMoneyList=basicOtherMoneyMapper.selectList(new QueryWrapper<BasicOtherMoney>()); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | |
| | | for (OrderDetail detail : orderDetailList) { |
| | | String otherColumnsStr = detail.getOtherColumns(); |
| | | if (otherColumnsStr == null || otherColumnsStr.trim().isEmpty()||otherColumnsStr.equals("{}")) { |
| | | continue; // 跳过空值 |
| | | } |
| | | try { |
| | | // 解析为Map(也可解析为自定义实体类,如OtherColumnsDTO) |
| | | Map<String, Object> otherColumnsJson = objectMapper.readValue(otherColumnsStr, Map.class); |
| | | |
| | | detail.setOtherColumnsJson(otherColumnsJson); |
| | | } catch (JsonProcessingException e) { |
| | | System.err.println("解析otherColumns失败,数据:" + otherColumnsStr + ",错误:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("data",orderDetailMapper.getOrderReport(offset, pageSize, startDate, endDate, orderDetail,model,scope)); |
| | | map.put("data",orderDetailList); |
| | | map.put("title",basicOtherMoneyList); |
| | | map.put("total",orderDetailMapper.getOrderReportTotal(offset, pageSize, startDate, endDate, orderDetail,"order")); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | |
| | | and a.order_number like concat('%',#{orderDetail.orderNumber},'%') |
| | | </if> |
| | | |
| | | <if test="orderDetail.buildingNumber != null and orderDetail.buildingNumber != ''"> |
| | | and a.building_number like concat('%',#{orderDetail.buildingNumber},'%') |
| | | </if> |
| | | |
| | | <if test="orderDetail.width != null and orderDetail.width != '' and model==0"> |
| | | and a.width regexp REGEXP_REPLACE(#{orderDetail.width},'\\.0+$','') |
| | | </if> |
| | |
| | | and a.order_number like concat('%',#{orderDetail.orderNumber},'%') |
| | | </if> |
| | | |
| | | <if test="orderDetail.buildingNumber != null and orderDetail.buildingNumber != ''"> |
| | | and a.building_number like concat('%',#{orderDetail.buildingNumber},'%') |
| | | </if> |
| | | |
| | | <if test="orderDetail.width != null and orderDetail.width != ''"> |
| | | and a.width regexp REGEXP_REPLACE(#{orderDetail.width},'\\.0+$','') |
| | | </if> |