| | |
| | | import {ElDatePicker, ElMessage} from "element-plus" |
| | | import {nextTick, onMounted, onUnmounted, reactive, ref, watch} from "vue" |
| | | import {Search} from "@element-plus/icons-vue" |
| | | import {useRouter} from 'vue-router' |
| | | import {useRoute, useRouter} from 'vue-router' |
| | | import {changeFilterEvent, filterChanged} from "@/hook" |
| | | |
| | | import { useI18n } from 'vue-i18n' |
| | |
| | | //语言获取 |
| | | const { t } = useI18n() |
| | | let router=useRouter() |
| | | const route = useRoute() |
| | | |
| | | let props = defineProps({ |
| | | orderId:null |
| | | }) |
| | | onMounted(()=>{ |
| | | if(props.orderId===null || props.orderId===undefined || props.orderId===''){ |
| | | return |
| | | |
| | | }else{ |
| | | form.orderId = props.orderId |
| | | getWorkOrder() |
| | | } |
| | | form.orderId = props.orderId |
| | | getWorkOrder() |
| | | if(route.query.orderId===null || route.query.orderId===undefined || route.query.orderId===''){ |
| | | |
| | | }else { |
| | | form.orderId = route.query.orderId |
| | | getWorkOrder() |
| | | } |
| | | |
| | | }) |
| | | |
| | | |
| | |
| | | } |
| | | }) |
| | | |
| | | |
| | | //需要合并的列 |
| | | let column = [1,3,8] |
| | | //点击查询 |
| | | const getWorkOrder = () => { |
| | | request.post(`/report/processCardProgress/${form.orderId}`,column).then((res) => { |
| | | gridOptions.columns = gridOptions.columns.slice(0, 11); //清除动态生成的列重新查询 |
| | | request.post(`/report/processCardProgress/${form.orderId}`, column).then((res) => { |
| | | if (res.code == 200) { |
| | | if(res.data.data.length===0){ |
| | | if (res.data.data.length === 0) { |
| | | ElMessage.warning(t('report.noDataFoundForThisOrder')) |
| | | return |
| | | } |
| | | //gridOptions.columns = JSON.parse(JSON.stringify(columns)) |
| | | res.data.title.forEach(item =>{ |
| | | let column = {slots: { default: 'quantitySum' }, width: 90,title: item.process} |
| | | |
| | | // 动态添加列 |
| | | res.data.title.forEach((item, index) => { |
| | | let column = { |
| | | slots: { default: 'quantitySum' }, |
| | | width: 150, |
| | | title: item.process, |
| | | field: `dynamicColumn${index}` // 为动态列添加唯一的 field |
| | | } |
| | | gridOptions.columns.push(column) |
| | | }) |
| | | res.data.data.forEach(item => { |
| | | item.reportWorkQuantity=JSON.parse(item.reportWorkQuantity) |
| | | item.reportWorkQuantityCount=JSON.parse(item.reportWorkQuantityCount) |
| | | item.reportWorkQuantity = JSON.parse(item.reportWorkQuantity) |
| | | item.reportWorkQuantityCount = JSON.parse(item.reportWorkQuantityCount) |
| | | //item.reportWorkTime = JSON.parse(item.reportWorkTime) |
| | | }) |
| | | mergeCells.value = res.data.mergeCell |
| | | xGrid.value.loadData(res.data.data) |
| | |
| | | } |
| | | }) |
| | | } |
| | | |
| | | const footSumDynamic = (data, columnTitle) => { |
| | | let sum = 0; |
| | | data.forEach(item => { |
| | | const value = Number(item.reportWorkQuantity[columnTitle]) || 0; // 从 reportWorkQuantity 中提取值并转换为数字 |
| | | sum += value; |
| | | }); |
| | | return sum.toFixed(2); |
| | | } |
| | | |
| | | const quantitySum = ( row,column )=>{ |
| | | const reportWorkQuantity = row.reportWorkQuantity[column.title] || 0 |
| | | const reportWorkQuantityCount = row.reportWorkQuantityCount[column.title] || 0 |
| | | if(reportWorkQuantity===reportWorkQuantityCount){ |
| | | return reportWorkQuantity |
| | | const reportWorkTime = row.reportWorkTime[column.title] || 0 |
| | | if (reportWorkTime===0){ |
| | | if(reportWorkQuantity===reportWorkQuantityCount){ |
| | | return reportWorkQuantity |
| | | } |
| | | |
| | | return (reportWorkQuantity |
| | | +'(' |
| | | +reportWorkQuantityCount |
| | | +')' ) |
| | | } |
| | | else { |
| | | if(reportWorkQuantity===reportWorkQuantityCount){ |
| | | return (reportWorkQuantity+'[' |
| | | +reportWorkTime |
| | | +']') |
| | | } |
| | | |
| | | return (reportWorkQuantity |
| | | +'(' |
| | | +reportWorkQuantityCount |
| | | +')' |
| | | +'[' |
| | | +reportWorkTime |
| | | +']' |
| | | ) |
| | | } |
| | | |
| | | return (reportWorkQuantity |
| | | +'(' |
| | | +reportWorkQuantityCount |
| | | +')' ) |
| | | //return |
| | | } |
| | | |
| | |
| | | slots: {filter: 'num1_filter'}, |
| | | filterMethod: filterChanged}, |
| | | {field: 'quantity', width: 90,title: t('order.quantity')}, |
| | | {field: 'gross_area', width: 90,title: t('order.area')}, |
| | | {field: 'broken_num',width: 90, title: t('reportingWorks.quantityBroken')}, |
| | | // {field: 'shippedQuantity',width: 120, title: t('report.shippedQuantity')}, |
| | | {field: 'inventory',width: 120, title: t('report.inventoryNum')}, |
| | |
| | | data: [ |
| | | ],//table body实际数据 |
| | | //脚部求和 |
| | | footerMethod ({ columns, data }) {//页脚函数 |
| | | |
| | | return[ |
| | | footerMethod ({ columns, data }) { |
| | | return [ |
| | | columns.map((column, columnIndex) => { |
| | | if (columnIndex === 0) { |
| | | return t('basicData.total') |
| | | } |
| | | const List = ["quantity","broken_num","inventory",] |
| | | const List = ["quantity", "broken_num", "inventory", "inventoryArea","gross_area"]; // 静态列的求和 |
| | | if (List.includes(column.field)) { |
| | | console.log(data) |
| | | console.log(column.field) |
| | | return footSum(data, column.field) |
| | | } |
| | | // 动态列的求和 |
| | | if (column.field && column.field.startsWith('dynamicColumn')) { |
| | | return footSumDynamic(data, column.title) |
| | | } |
| | | return '' |
| | | }) |
| | | ] |
| | | }, |
| | | |
| | | } |
| | | }) |
| | | |
| | | |