<template>
|
<div class="app-container">
|
<div class="search_form">
|
<div>
|
<span class="search_title ml10">物料编码:</span>
|
<el-input v-model="searchForm.materialCode"
|
style="width: 200px"
|
placeholder="请输入物料编码"
|
clearable />
|
<span class="search_title ml10">产品名称:</span>
|
<el-input v-model="searchForm.productName"
|
style="width: 200px"
|
placeholder="请输入产品名称"
|
clearable />
|
<el-button type="primary"
|
@click="handleQuery"
|
style="margin-left: 10px">搜索</el-button>
|
<el-button @click="handleReset">重置</el-button>
|
</div>
|
</div>
|
<div class="table_list">
|
<PIMTable rowKey="materialCode"
|
:column="tableColumn"
|
:tableData="tableData"
|
:page="page"
|
height="calc(100vh - 280px)"
|
:tableLoading="tableLoading"
|
:isSelection="false"
|
:isShowSummary="true"
|
:summaryMethod="summaryMethod"
|
@pagination="pagination">
|
</PIMTable>
|
</div>
|
</div>
|
</template>
|
|
<script setup>
|
import { onMounted, ref, reactive } from "vue";
|
import { summaryByProductType } from "@/api/productionPlan/productionPlan.js";
|
import PIMTable from "../productionPlan/components/PIMTable.vue";
|
|
const tableColumn = ref([
|
{
|
label: "物料编码",
|
prop: "materialCode",
|
},
|
{
|
label: "产品名称",
|
prop: "productName",
|
dataType: "tag",
|
formatType: params => {
|
return "primary";
|
},
|
},
|
{
|
label: "产品规格",
|
prop: "productSpec",
|
className: "spec-cell",
|
},
|
{
|
label: "长",
|
prop: "length",
|
formatData: cell => (cell ? `${cell}mm` : ""),
|
},
|
{
|
label: "宽",
|
prop: "width",
|
formatData: cell => (cell ? `${cell}mm` : ""),
|
},
|
{
|
label: "高",
|
prop: "height",
|
formatData: cell => (cell ? `${cell}mm` : ""),
|
},
|
{
|
label: "块数",
|
prop: "quantity",
|
formatData: cell => (cell ? `${cell}块` : ""),
|
},
|
{
|
label: "方数",
|
prop: "volume",
|
className: "volume-cell",
|
formatData: cell => (cell ? `${cell}方` : ""),
|
},
|
]);
|
const tableData = ref([]);
|
const tableLoading = ref(false);
|
const page = reactive({
|
current: 1,
|
size: 100,
|
total: 0,
|
});
|
|
// 搜索表单
|
const searchForm = reactive({
|
materialCode: "",
|
productName: "",
|
});
|
|
// 查询列表
|
/** 搜索按钮操作 */
|
const handleQuery = () => {
|
page.current = 1;
|
getList();
|
};
|
|
/** 重置按钮操作 */
|
const handleReset = () => {
|
searchForm.materialCode = "";
|
searchForm.productName = "";
|
page.current = 1;
|
getList();
|
};
|
const pagination = obj => {
|
page.current = obj.page;
|
page.size = obj.limit;
|
getList();
|
};
|
|
const getList = () => {
|
tableLoading.value = true;
|
// 构造一个新的对象,不包含entryDate字段
|
const params = { ...searchForm, ...page };
|
params.entryDate = undefined;
|
summaryByProductType(params)
|
.then(res => {
|
tableLoading.value = false;
|
|
tableData.value = res.data;
|
page.total = res.total;
|
})
|
.catch(() => {
|
tableLoading.value = false;
|
});
|
};
|
|
// 汇总方法
|
const summaryMethod = ({ columns, data }) => {
|
const sums = [];
|
columns.forEach((column, index) => {
|
if (index === 0) {
|
sums[index] = "总计";
|
return;
|
}
|
if (column.property === "quantity") {
|
const total = data.reduce((acc, item) => {
|
return acc + (Number(item.quantity) || 0);
|
}, 0);
|
sums[index] = `${total}块`;
|
} else if (column.property === "volume") {
|
const total = data.reduce((acc, item) => {
|
return acc + (Number(item.volume) || 0);
|
}, 0);
|
sums[index] = `${total.toFixed(4)}方`;
|
} else {
|
sums[index] = "";
|
}
|
});
|
return sums;
|
};
|
|
onMounted(() => {
|
getList();
|
});
|
</script>
|
|
<style scoped lang="scss">
|
.app-container {
|
padding: 24px;
|
background-color: #f0f2f5;
|
min-height: calc(100vh - 48px);
|
}
|
|
.search_form {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
margin-bottom: 24px;
|
padding: 20px;
|
background-color: #ffffff;
|
border-radius: 6px;
|
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
|
transition: all 0.3s ease;
|
|
&:hover {
|
box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.08);
|
}
|
|
.search_title {
|
color: #606266;
|
font-size: 14px;
|
font-weight: 500;
|
}
|
|
.ml10 {
|
margin-left: 10px;
|
}
|
}
|
|
.table_list {
|
background-color: #ffffff;
|
border-radius: 6px;
|
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
|
overflow: hidden;
|
height: calc(100vh - 230px);
|
}
|
|
:deep(.el-table) {
|
border: none;
|
border-radius: 6px;
|
overflow: hidden;
|
box-shadow: 0 4px 16px rgba(102, 126, 234, 0.1);
|
|
.el-table__header-wrapper {
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
th {
|
background: transparent;
|
font-weight: 600;
|
color: #ffffff;
|
border-bottom: none;
|
padding: 16px 0;
|
letter-spacing: 0.5px;
|
}
|
}
|
|
.el-table__body-wrapper {
|
tr {
|
transition: all 0.3s ease;
|
|
&:hover {
|
background: linear-gradient(
|
90deg,
|
rgba(102, 126, 234, 0.05) 0%,
|
rgba(118, 75, 162, 0.05) 100%
|
);
|
transform: scale(1.002);
|
box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
|
}
|
|
td {
|
border-bottom: 1px solid #f0f0f0;
|
padding: 14px 0;
|
color: #303133;
|
}
|
}
|
|
tr.current-row {
|
background: linear-gradient(
|
90deg,
|
rgba(102, 126, 234, 0.08) 0%,
|
rgba(118, 75, 162, 0.08) 100%
|
);
|
}
|
|
// 数值字段样式
|
.quantity-cell,
|
.volume-cell,
|
.dimension-cell {
|
font-weight: 600;
|
color: #409eff;
|
font-family: "Courier New", monospace;
|
text-shadow: 0 1px 2px rgba(64, 158, 255, 0.2);
|
}
|
|
// 规格字段样式
|
.spec-cell {
|
color: #67c23a;
|
font-weight: 500;
|
padding: 4px 8px;
|
border-radius: 4px;
|
}
|
|
// 编码字段样式
|
.code-cell {
|
color: #e6a23c;
|
font-family: "Courier New", monospace;
|
font-weight: 500;
|
padding: 4px 8px;
|
border-radius: 4px;
|
}
|
|
// 日期字段样式
|
.date-cell {
|
color: #909399;
|
font-style: italic;
|
}
|
}
|
|
.el-table__empty-block {
|
padding: 60px 0;
|
background-color: #fafafa;
|
}
|
}
|
|
.pagination-container {
|
display: flex;
|
justify-content: flex-end;
|
padding: 16px 20px;
|
background-color: #ffffff;
|
border-top: 1px solid #ebeef5;
|
border-radius: 0 0 12px 12px;
|
}
|
|
:deep(.el-button) {
|
transition: all 0.3s ease;
|
|
&:hover {
|
transform: translateY(-1px);
|
}
|
}
|
|
@media (max-width: 768px) {
|
.app-container {
|
padding: 16px;
|
}
|
|
.search_form {
|
flex-direction: column;
|
align-items: flex-start;
|
gap: 12px;
|
|
.el-form {
|
width: 100%;
|
|
.el-form-item {
|
width: 100%;
|
}
|
}
|
|
.el-button {
|
margin-right: 12px;
|
}
|
}
|
|
:deep(.el-table) {
|
th,
|
td {
|
padding: 10px 0;
|
font-size: 12px;
|
}
|
}
|
}
|
</style>
|