| | |
| | | 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' |
| | | import footSum from "@/hook/footSum"; |
| | | //语言获取 |
| | | 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 }) {//页脚函数 |
| | | // let footList=['7','8','9','10'] |
| | | // return[ |
| | | // columns.map((column, columnIndex) => { |
| | | // if (columnIndex === 0) { |
| | | // return '合计:' |
| | | // } |
| | | // if (footList.includes(column.field)) { |
| | | // return sumNum(data, column.field) |
| | | // } |
| | | // return '' |
| | | // }) |
| | | // ] |
| | | // } |
| | | |
| | | footerMethod ({ columns, data }) { |
| | | return [ |
| | | columns.map((column, columnIndex) => { |
| | | if (columnIndex === 0) { |
| | | return t('basicData.total') |
| | | } |
| | | const List = ["quantity", "broken_num", "inventory", "inventoryArea","gross_area"]; // 静态列的求和 |
| | | if (List.includes(column.field)) { |
| | | return footSum(data, column.field) |
| | | } |
| | | // 动态列的求和 |
| | | if (column.field && column.field.startsWith('dynamicColumn')) { |
| | | return footSumDynamic(data, column.title) |
| | | } |
| | | return '' |
| | | }) |
| | | ] |
| | | } |
| | | }) |
| | | |
| | | |
| | |
| | | </script> |
| | | |
| | | <template> |
| | | <div class="main-div-customer" > |
| | | <div id="selectForm"> |
| | | <el-row :gutter="0"> |
| | | <div style="width: 100%;height: 100%"> |
| | | <div class="head"> |
| | | <el-input |
| | | v-model="form.orderId" |
| | | clearable |
| | |
| | | type="primary" :icon="Search">{{$t('basicData.search')}} |
| | | |
| | | </el-button> |
| | | </el-row> |
| | | |
| | | </div> |
| | | <vxe-grid |
| | | height="100%" |
| | | class="mytable-scrollbar" |
| | | ref="xGrid" |
| | | v-bind="gridOptions" |
| | | :merge-cells="mergeCells" |
| | | <div class="main-table"> |
| | | <vxe-grid |
| | | height="100%" |
| | | class="mytable-scrollbar" |
| | | ref="xGrid" |
| | | v-bind="gridOptions" |
| | | :merge-cells="mergeCells" |
| | | |
| | | > |
| | | <!-- @toolbar-button-click="toolbarButtonClickEvent"--> |
| | | <!-- 下拉显示所有信息插槽--> |
| | | <template #content="{ row }"> |
| | | <ul class="expand-wrapper"> |
| | | <li v-for="(item,index) in gridOptions.columns" v-show="item.field!=undefined "> |
| | | <span style="font-weight: bold">{{item.title+': '}}</span> |
| | | <span>{{ row[item.field] }}</span> |
| | | </li> |
| | | </ul> |
| | | </template> |
| | | > |
| | | <!-- @toolbar-button-click="toolbarButtonClickEvent"--> |
| | | <!-- 下拉显示所有信息插槽--> |
| | | <template #content="{ row }"> |
| | | <ul class="expand-wrapper"> |
| | | <li v-for="(item,index) in gridOptions.columns" v-show="item.field!=undefined "> |
| | | <span style="font-weight: bold">{{item.title+': '}}</span> |
| | | <span>{{ row[item.field] }}</span> |
| | | </li> |
| | | </ul> |
| | | </template> |
| | | |
| | | |
| | | |
| | | <template #num1_filter="{ column, $panel }"> |
| | | <div> |
| | | <div v-for="(option, index) in column.filters" :key="index"> |
| | | <input v-model="option.data" |
| | | type="text" |
| | | @input="changeFilterEvent($event, option, $panel)"/> |
| | | <template #num1_filter="{ column, $panel }"> |
| | | <div> |
| | | <div v-for="(option, index) in column.filters" :key="index"> |
| | | <input v-model="option.data" |
| | | type="text" |
| | | @keyup.enter.native="$panel.confirmFilter()" |
| | | @input="changeFilterEvent($event, option, $panel)"/> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | </template> |
| | | |
| | | <template #quantitySum="{ row,column }"> |
| | | <span>{{ quantitySum(row,column) }} </span> |
| | | </template> |
| | | <template #quantitySum="{ row,column }"> |
| | | <span>{{ quantitySum(row,column) }} </span> |
| | | </template> |
| | | |
| | | |
| | | </vxe-grid> |
| | | </vxe-grid> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <style scoped> |
| | | .main-div-customer{ |
| | | width: 99%; |
| | | height: 90%; |
| | | .head{ |
| | | width: 100%; |
| | | height: 35px; |
| | | } |
| | | #selectForm { |
| | | width: 60%; |
| | | text-align: center; |
| | | |
| | | .main-table{ |
| | | width: 100%; |
| | | height: calc(100% - 35px); |
| | | } |
| | | </style> |