月工资计算,产品详情页补充
This commit is contained in:
@@ -54,4 +54,9 @@ public class MatProduct extends BaseEntity {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 产品图片,多个图片以逗号分隔
|
||||
*/
|
||||
private String productImages;
|
||||
|
||||
}
|
||||
|
||||
@@ -52,5 +52,10 @@ public class MatProductBo extends BaseEntity {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 产品图片,多个图片以逗号分隔
|
||||
*/
|
||||
private String productImages;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -58,5 +58,11 @@ public class MatProductVo {
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 产品图片,多个图片以逗号分隔
|
||||
*/
|
||||
@ExcelProperty(value = "产品图片")
|
||||
private String productImages;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -57,6 +57,12 @@ public class MatProductWithMaterialsVo {
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 产品图片,多个图片以逗号分隔
|
||||
*/
|
||||
@ExcelProperty(value = "产品图片")
|
||||
private String productImages;
|
||||
|
||||
/**
|
||||
* 关联的配料信息列表
|
||||
*/
|
||||
@@ -81,4 +87,4 @@ public class MatProductWithMaterialsVo {
|
||||
private BigDecimal planNum; // 计划采购总数量
|
||||
private BigDecimal receivedNum; // 已入库数量
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 工资录入明细业务对象 gear_wage_entry_detail
|
||||
@@ -71,4 +72,6 @@ public class GearWageEntryDetailBo extends BaseEntity {
|
||||
private String makeupReason;
|
||||
|
||||
private String remark;
|
||||
// 新增累计金额
|
||||
private Map<String, BigDecimal> cumulativeAmounts;
|
||||
}
|
||||
|
||||
@@ -77,4 +77,6 @@ public class GearWageEntryDetailVo {
|
||||
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
@ExcelProperty(value = "累计金额")
|
||||
private BigDecimal cumulativeAmount;
|
||||
}
|
||||
|
||||
@@ -49,11 +49,24 @@ public class GearWageEntryDetailServiceImpl implements IGearWageEntryDetailServi
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GearWageEntryDetailVo> queryList(GearWageEntryDetailBo bo) {
|
||||
LambdaQueryWrapper<GearWageEntryDetail> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
// @Override
|
||||
// public List<GearWageEntryDetailVo> queryList(GearWageEntryDetailBo bo) {
|
||||
// LambdaQueryWrapper<GearWageEntryDetail> lqw = buildQueryWrapper(bo);
|
||||
// return baseMapper.selectVoList(lqw);
|
||||
//
|
||||
// }
|
||||
@Override
|
||||
public List<GearWageEntryDetailVo> queryList(GearWageEntryDetailBo bo) {
|
||||
// 将 selectList 改为 selectVoList
|
||||
List<GearWageEntryDetailVo> list = baseMapper.selectVoList(buildQueryWrapper(bo));
|
||||
// 处理累计金额
|
||||
if (bo.getCumulativeAmounts() != null) {
|
||||
for (GearWageEntryDetailVo vo : list) {
|
||||
vo.setCumulativeAmount(bo.getCumulativeAmounts().get(vo.getEmpName()));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<GearWageEntryDetail> buildQueryWrapper(GearWageEntryDetailBo bo) {
|
||||
LambdaQueryWrapper<GearWageEntryDetail> lqw = Wrappers.lambdaQuery();
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
"vue-cropper": "1.1.1",
|
||||
"vue-router": "4.5.1",
|
||||
"vue3-treeselect": "^0.1.10",
|
||||
"vuedraggable": "4.1.0"
|
||||
"vuedraggable": "4.1.0",
|
||||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "5.2.4",
|
||||
|
||||
@@ -11,10 +11,32 @@
|
||||
</div>
|
||||
|
||||
<!-- 选择弹窗:表格+分页+底部按钮 -->
|
||||
<el-dialog title="选择配料" v-model="open" width="800px" destroy-on-close>
|
||||
<el-dialog title="选择配料" v-model="open" width="900px" destroy-on-close>
|
||||
<!-- 检索功能 -->
|
||||
<el-form :model="searchForm" :inline="true" class="mb-4">
|
||||
<el-form-item label="配料名称">
|
||||
<el-input v-model="searchForm.materialName" placeholder="请输入配料名称" clearable @keyup.enter="fetchMaterialList" />
|
||||
</el-form-item>
|
||||
<el-form-item label="物料类型">
|
||||
<el-select v-model="searchForm.materialType" placeholder="请选择物料类型" clearable @change="fetchMaterialList">
|
||||
<el-option label="主材" value="2" />
|
||||
<el-option label="辅料" value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="fetchMaterialList">搜索</el-button>
|
||||
<el-button @click="resetSearch">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table :data="list" style="width: 100%" border stripe @row-click="handleRowSelect" highlight-current-row
|
||||
row-key="materialId" :current-row-key="materialId">
|
||||
<el-table-column prop="materialName" label="配料名称" min-width="120" align="center" />
|
||||
<el-table-column label="物料类型" width="100" align="center">
|
||||
<template #default="scope">
|
||||
{{ scope.row.materialType === 1 ? '辅料' : scope.row.materialType === 2 ? '主材' : '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="spec" label="配料规格" min-width="100" align="center" />
|
||||
<el-table-column prop="model" label="配料型号" min-width="100" align="center" />
|
||||
<el-table-column prop="factory" label="生产厂家" min-width="120" align="center" />
|
||||
@@ -64,6 +86,12 @@ const emit = defineEmits(['change']);
|
||||
const list = ref([]); // 物料列表
|
||||
const open = ref(false); // 弹窗显隐
|
||||
|
||||
// 搜索表单数据
|
||||
const searchForm = ref({
|
||||
materialName: '',
|
||||
materialType: ''
|
||||
});
|
||||
|
||||
// 分页响应式数据(核心新增)
|
||||
const pageNum = ref(1); // 当前页码
|
||||
const pageSize = ref(10); // 每页条数
|
||||
@@ -77,7 +105,15 @@ onMounted(async () => {
|
||||
// 加载物料列表(适配分页参数)
|
||||
async function fetchMaterialList() {
|
||||
try {
|
||||
const res = await listMaterial({ pageNum: pageNum.value, pageSize: pageSize.value });
|
||||
// 构建查询参数,包含分页和搜索条件
|
||||
const params = {
|
||||
pageNum: pageNum.value,
|
||||
pageSize: pageSize.value,
|
||||
materialName: searchForm.value.materialName,
|
||||
materialType: searchForm.value.materialType
|
||||
};
|
||||
|
||||
const res = await listMaterial(params);
|
||||
|
||||
list.value = res.rows;
|
||||
total.value = res.total; // 赋值总条数供分页使用
|
||||
@@ -95,6 +131,16 @@ async function fetchMaterialList() {
|
||||
}
|
||||
}
|
||||
|
||||
// 重置搜索
|
||||
function resetSearch() {
|
||||
searchForm.value = {
|
||||
materialName: '',
|
||||
materialType: ''
|
||||
};
|
||||
pageNum.value = 1;
|
||||
fetchMaterialList();
|
||||
}
|
||||
|
||||
// 表格行选择物料
|
||||
function handleRowSelect(row) {
|
||||
if (row.materialId === materialId.value) return;
|
||||
|
||||
@@ -17,7 +17,7 @@ const service = axios.create({
|
||||
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
||||
baseURL: import.meta.env.VITE_APP_BASE_API,
|
||||
// 超时
|
||||
timeout: 10000
|
||||
timeout: 30000
|
||||
})
|
||||
|
||||
// request拦截器
|
||||
|
||||
@@ -25,6 +25,11 @@
|
||||
<raw :data="scope.row" :materialId="scope.row.materialId" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="物料类型" width="100" align="center">
|
||||
<template #default="scope">
|
||||
{{ scope.row.material?.materialType === 1 ? '辅料' : scope.row.material?.materialType === 2 ? '主材' : '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="所需数量" align="center" prop="materialNum">
|
||||
<template #default="scope">
|
||||
{{ formatDecimal(scope.row.materialNum) }}
|
||||
@@ -75,6 +80,7 @@
|
||||
|
||||
<script setup name="ProductMaterialRelation">
|
||||
import { listProductMaterialRelation, getProductMaterialRelation, delProductMaterialRelation, addProductMaterialRelation, updateProductMaterialRelation } from "@/api/mat/productMaterialRelation";
|
||||
import { getMaterial } from "@/api/mat/material";
|
||||
import RawSelector from '@/components/RawSelector/index.vue'
|
||||
import Raw from '@/components/Renderer/Raw.vue'
|
||||
import { formatDecimal } from '@/utils/gear'
|
||||
@@ -128,8 +134,21 @@ watch(() => props.productId, (newVal, oldVal) => {
|
||||
function getList() {
|
||||
loading.value = true;
|
||||
listProductMaterialRelation(queryParams.value).then(response => {
|
||||
productMaterialRelationList.value = response.rows;
|
||||
total.value = response.total;
|
||||
const relations = response.rows;
|
||||
// 为每个配方项获取物料详细信息,包括物料类型
|
||||
const promises = relations.map(item => {
|
||||
return getMaterial(item.materialId).then(materialResponse => {
|
||||
item.material = materialResponse.data;
|
||||
return item;
|
||||
});
|
||||
});
|
||||
return Promise.all(promises);
|
||||
}).then(relationsWithMaterial => {
|
||||
productMaterialRelationList.value = relationsWithMaterial;
|
||||
total.value = relationsWithMaterial.length;
|
||||
loading.value = false;
|
||||
}).catch(error => {
|
||||
console.error('获取数据失败:', error);
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -45,9 +45,24 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="产品图片" align="center" prop="productImages">
|
||||
<template #default="scope">
|
||||
<div v-if="scope.row.productImages" class="image-preview">
|
||||
<el-image
|
||||
v-for="(image, index) in scope.row.productImages.split(',')"
|
||||
:key="index"
|
||||
:src="image"
|
||||
:preview-src-list="scope.row.productImages.split(',')"
|
||||
style="width: 40px; height: 40px; margin-right: 8px;"
|
||||
/>
|
||||
</div>
|
||||
<span v-else>无</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" icon="Plus" @click="handleBom(scope.row)">配方</el-button>
|
||||
<el-button link type="primary" icon="View" @click="handleDetail(scope.row)">详情</el-button>
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)">修改</el-button>
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
|
||||
</template>
|
||||
@@ -75,6 +90,26 @@
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
<el-form-item label="产品图片" prop="productImages">
|
||||
<el-upload
|
||||
v-model:file-list="imageFileList"
|
||||
:action="uploadUrl"
|
||||
:headers="headers"
|
||||
:on-success="handleImageUploadSuccess"
|
||||
:on-remove="handleImageRemove"
|
||||
multiple
|
||||
list-type="picture"
|
||||
:limit="5"
|
||||
:before-upload="beforeUpload"
|
||||
>
|
||||
<el-button type="primary" icon="Upload">上传图片</el-button>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip">
|
||||
最多上传5张图片,支持 JPG、PNG 格式
|
||||
</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
@@ -110,16 +145,191 @@
|
||||
<el-empty v-else description="选择产品查看配料信息" />
|
||||
|
||||
<!-- </StickyDragContainer> -->
|
||||
|
||||
<!-- 产品详情弹窗 -->
|
||||
<el-dialog :title="currentProductDetail.productName + ' - 产品详情'" v-model="detailOpen" width="900px" append-to-body>
|
||||
<!-- 产品信息和图片容器 -->
|
||||
<div class="product-header">
|
||||
<!-- 产品基本信息 -->
|
||||
<div class="product-info">
|
||||
<h3 class="section-title">产品信息</h3>
|
||||
<div class="info-content">
|
||||
<div class="info-row">
|
||||
<span class="label">品名:</span>
|
||||
<span class="value">{{ currentProductDetail.productName }}</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="label">产品规格:</span>
|
||||
<span class="value">{{ currentProductDetail.spec }}</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="label">产品型号:</span>
|
||||
<span class="value">{{ currentProductDetail.model }}</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="label">产品单价:</span>
|
||||
<span class="value">{{ formatDecimal(currentProductDetail.unitPrice) }} 元</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="label">备注:</span>
|
||||
<span class="value">{{ currentProductDetail.remark || '无' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 产品图片 -->
|
||||
<div class="product-images" v-if="currentProductDetail.productImages">
|
||||
<h3 class="section-title">产品图片</h3>
|
||||
<div class="image-list">
|
||||
<el-image
|
||||
v-for="(image, index) in currentProductDetail.productImages.split(',')"
|
||||
:key="index"
|
||||
:src="image"
|
||||
:preview-src-list="currentProductDetail.productImages.split(',')"
|
||||
style="width: 150px; height: 150px; margin-right: 15px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 材料明细 -->
|
||||
<div class="material-detail">
|
||||
<h3 class="section-title">材料明细</h3>
|
||||
|
||||
<!-- 主材部分 -->
|
||||
<div class="material-category" v-if="rawMaterials.length > 0">
|
||||
<h4 class="category-title">主材</h4>
|
||||
<el-table v-loading="materialLoading" :data="rawMaterials" style="width: 100%" border>
|
||||
<el-table-column label="材料名称" width="150">
|
||||
<template #default="scope">
|
||||
<Raw :data="scope.row" :materialId="scope.row.materialId" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="材料规格" width="200">
|
||||
<template #default="scope">
|
||||
{{ scope.row.material?.spec || '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数量" width="100" align="center">
|
||||
<template #default="scope">
|
||||
{{ formatDecimal(scope.row.materialNum) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="价格" width="100" align="center">
|
||||
<template #default="scope">
|
||||
{{ formatDecimal(scope.row.material?.unitPrice || 0) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" />
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<!-- 辅材部分 -->
|
||||
<div class="material-category" v-if="auxiliaryMaterials.length > 0">
|
||||
<h4 class="category-title">辅材</h4>
|
||||
<el-table v-loading="materialLoading" :data="auxiliaryMaterials" style="width: 100%" border>
|
||||
<el-table-column label="材料名称" width="150">
|
||||
<template #default="scope">
|
||||
<Raw :data="scope.row" :materialId="scope.row.materialId" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="材料规格" width="200">
|
||||
<template #default="scope">
|
||||
{{ scope.row.material?.spec || '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数量" width="100" align="center">
|
||||
<template #default="scope">
|
||||
{{ formatDecimal(scope.row.materialNum) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="价格" width="100" align="center">
|
||||
<template #default="scope">
|
||||
{{ formatDecimal(scope.row.material?.unitPrice || 0) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" />
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<!-- 无数据提示 -->
|
||||
<div v-if="productMaterialRelationList.length === 0">
|
||||
<el-empty description="暂无配方数据" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 总计部分 -->
|
||||
<div class="total-section">
|
||||
<div class="total-item">
|
||||
<span class="total-label">产品总价:</span>
|
||||
<span class="total-value">{{ formatDecimal(currentProductDetail.unitPrice || 0) }} 元</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="Product">
|
||||
import { ref, computed } from 'vue';
|
||||
import { listProduct, getProduct, delProduct, addProduct, updateProduct } from "@/api/mat/product";
|
||||
import { listProductMaterialRelation } from "@/api/mat/productMaterialRelation";
|
||||
import { getMaterial } from "@/api/mat/material";
|
||||
import bom from "@/views/mat/components/bom.vue";
|
||||
import StickyDragContainer from "@/components/StickyDragContainer/index.vue";
|
||||
import { formatDecimal } from '@/utils/gear'
|
||||
import Raw from '@/components/Renderer/Raw.vue';
|
||||
import { formatDecimal } from '@/utils/gear';
|
||||
import { getToken } from '@/utils/auth';
|
||||
|
||||
const bomOpen = ref(false);
|
||||
const detailOpen = ref(false);
|
||||
const currentProductDetail = ref({});
|
||||
|
||||
// 配方数据
|
||||
const productMaterialRelationList = ref([]);
|
||||
const materialLoading = ref(false);
|
||||
|
||||
// 计算总金额
|
||||
const totalAmount = computed(() => {
|
||||
return productMaterialRelationList.value.reduce((sum, item) => {
|
||||
// 假设每个物料都有价格,实际项目中需要从物料数据中获取
|
||||
const price = item.material?.unitPrice || 0;
|
||||
const quantity = item.materialNum || 0;
|
||||
return sum + (price * quantity);
|
||||
}, 0);
|
||||
});
|
||||
|
||||
// 分离原料和辅料
|
||||
const rawMaterials = computed(() => {
|
||||
// 原料(主材):materialType === 2
|
||||
return productMaterialRelationList.value.filter(item => {
|
||||
return item && item.material && item.material.materialType === 2;
|
||||
});
|
||||
});
|
||||
|
||||
const auxiliaryMaterials = computed(() => {
|
||||
// 辅料:materialType === 1
|
||||
return productMaterialRelationList.value.filter(item => {
|
||||
return item && item.material && item.material.materialType === 1;
|
||||
});
|
||||
});
|
||||
|
||||
// 计算原料总金额
|
||||
const rawMaterialsTotal = computed(() => {
|
||||
return rawMaterials.value.reduce((sum, item) => {
|
||||
const price = item.material?.unitPrice || 0;
|
||||
const quantity = item.materialNum || 0;
|
||||
return sum + (price * quantity);
|
||||
}, 0);
|
||||
});
|
||||
|
||||
// 计算辅料总金额
|
||||
const auxiliaryMaterialsTotal = computed(() => {
|
||||
return auxiliaryMaterials.value.reduce((sum, item) => {
|
||||
const price = item.material?.unitPrice || 0;
|
||||
const quantity = item.materialNum || 0;
|
||||
return sum + (price * quantity);
|
||||
}, 0);
|
||||
});
|
||||
|
||||
const { proxy } = getCurrentInstance();
|
||||
|
||||
@@ -136,6 +346,9 @@ const title = ref("");
|
||||
const currentProductId = ref(null);
|
||||
const currentProduct = ref({});
|
||||
const appContainer = ref(null);
|
||||
const imageFileList = ref([]);
|
||||
const uploadUrl = ref(import.meta.env.VITE_APP_BASE_API + '/system/oss/upload');
|
||||
const headers = ref({ Authorization: "Bearer " + getToken() });
|
||||
|
||||
const formatterTime = (time) => {
|
||||
return proxy.parseTime(time, '{y}-{m}-{d}')
|
||||
@@ -185,8 +398,10 @@ function reset() {
|
||||
createBy: null,
|
||||
updateTime: null,
|
||||
updateBy: null,
|
||||
remark: null
|
||||
remark: null,
|
||||
productImages: null
|
||||
};
|
||||
imageFileList.value = [];
|
||||
proxy.resetForm("productRef");
|
||||
}
|
||||
|
||||
@@ -224,11 +439,60 @@ function handleUpdate(row) {
|
||||
getProduct(_productId).then(response => {
|
||||
loading.value = false;
|
||||
form.value = response.data;
|
||||
// 处理图片文件列表
|
||||
if (form.value.productImages) {
|
||||
imageFileList.value = form.value.productImages.split(',').map(url => ({
|
||||
name: url.substring(url.lastIndexOf('/') + 1),
|
||||
url: url
|
||||
}));
|
||||
}
|
||||
open.value = true;
|
||||
title.value = "修改产品基础信息";
|
||||
});
|
||||
}
|
||||
|
||||
/** 图片上传成功处理 */
|
||||
function handleImageUploadSuccess(response, uploadFile) {
|
||||
if (response.code === 200) {
|
||||
const imageUrl = response.data.url;
|
||||
if (form.value.productImages) {
|
||||
form.value.productImages += ',' + imageUrl;
|
||||
} else {
|
||||
form.value.productImages = imageUrl;
|
||||
}
|
||||
} else {
|
||||
proxy.$modal.msgError('上传失败:' + response.msg);
|
||||
}
|
||||
}
|
||||
|
||||
/** 图片移除处理 */
|
||||
function handleImageRemove(uploadFile, uploadFiles) {
|
||||
const imageUrl = uploadFile.url;
|
||||
if (form.value.productImages) {
|
||||
const images = form.value.productImages.split(',');
|
||||
const index = images.indexOf(imageUrl);
|
||||
if (index > -1) {
|
||||
images.splice(index, 1);
|
||||
form.value.productImages = images.join(',');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 图片上传前校验 */
|
||||
function beforeUpload(file) {
|
||||
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
|
||||
const isLt2M = file.size / 1024 / 1024 < 2;
|
||||
if (!isJpgOrPng) {
|
||||
proxy.$modal.msgError('只能上传 JPG/PNG 格式的图片');
|
||||
return false;
|
||||
}
|
||||
if (!isLt2M) {
|
||||
proxy.$modal.msgError('图片大小不能超过 2MB');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["productRef"].validate(valid => {
|
||||
@@ -287,5 +551,153 @@ function handleRowClick(row) {
|
||||
currentProduct.value = row;
|
||||
}
|
||||
|
||||
function handleDetail(row) {
|
||||
loading.value = true;
|
||||
materialLoading.value = true;
|
||||
// 获取产品详情
|
||||
getProduct(row.productId).then(response => {
|
||||
currentProductDetail.value = response.data;
|
||||
// 获取配方数据
|
||||
return listProductMaterialRelation({ productId: row.productId });
|
||||
}).then(response => {
|
||||
const relations = response.rows;
|
||||
// 为每个配方项获取物料详细信息,包括物料类型
|
||||
const promises = relations.map(item => {
|
||||
return getMaterial(item.materialId).then(materialResponse => {
|
||||
item.material = materialResponse.data;
|
||||
return item;
|
||||
});
|
||||
});
|
||||
return Promise.all(promises);
|
||||
}).then(relationsWithMaterial => {
|
||||
productMaterialRelationList.value = relationsWithMaterial;
|
||||
detailOpen.value = true;
|
||||
}).catch(error => {
|
||||
console.error('获取数据失败:', error);
|
||||
}).finally(() => {
|
||||
loading.value = false;
|
||||
materialLoading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
getList();
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 产品信息和图片容器 */
|
||||
.product-header {
|
||||
display: flex;
|
||||
margin: 20px 0;
|
||||
gap: 30px;
|
||||
}
|
||||
|
||||
/* 产品图片部分 */
|
||||
.product-images {
|
||||
flex-shrink: 0;
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.image-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 15px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* 产品信息部分 */
|
||||
.product-info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 15px;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 2px solid #409eff;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.info-content {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.info-row {
|
||||
margin-bottom: 10px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-weight: bold;
|
||||
margin-right: 15px;
|
||||
width: 100px;
|
||||
display: inline-block;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.value {
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
/* 材料明细部分 */
|
||||
.material-detail {
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.material-category {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.category-title {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10px;
|
||||
padding: 8px 15px;
|
||||
background-color: #ecf5ff;
|
||||
color: #409eff;
|
||||
border-left: 4px solid #409eff;
|
||||
}
|
||||
|
||||
/* 总计部分 */
|
||||
.total-section {
|
||||
margin-top: 30px;
|
||||
padding: 20px;
|
||||
background-color: #f0f9eb;
|
||||
border: 1px solid #b7eb8f;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.total-item {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.total-label {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.total-value {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
/* 表格样式 */
|
||||
:deep(.el-table th) {
|
||||
background-color: #f5f7fa;
|
||||
font-weight: bold;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
:deep(.el-table tr:hover) {
|
||||
background-color: #ecf5ff;
|
||||
}
|
||||
|
||||
:deep(.el-table td) {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
<el-table-column label="配料名称" align="center" prop="materialName" />
|
||||
<el-table-column label="物料类型" align="center" prop="materialType">
|
||||
<template #default="scope">
|
||||
{{ scope.row.materialType === 1 ? '辅料' : '原料' }}
|
||||
{{ scope.row.materialType === 1 ? '辅料' : '主材' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="配料规格" align="center" prop="spec" />
|
||||
@@ -91,7 +91,7 @@
|
||||
</el-form-item>
|
||||
<el-form-item label="物料类型" prop="materialType">
|
||||
<el-select v-model="form.materialType" placeholder="请选择物料类型" disabled>
|
||||
<el-option label="原料" value="2" />
|
||||
<el-option label="主材" value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="配料规格" prop="spec">
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
<el-col :span="2.5">
|
||||
<el-button size="small" type="info" plain icon="RefreshRight" @click="handleInitDaily(true)">重置当日名单</el-button>
|
||||
</el-col>
|
||||
<el-col :span="2.5">
|
||||
<el-button size="small" type="danger" plain icon="Refresh" @click="resetCumulativeAmounts">重置累计金额</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.8">
|
||||
<el-button size="small" type="primary" plain icon="Check" @click="saveAllRows">全部保存</el-button>
|
||||
</el-col>
|
||||
@@ -72,6 +75,7 @@
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="总金额" align="center" prop="totalAmount" width="110" />
|
||||
<el-table-column label="累计金额" align="center" prop="cumulativeAmount" width="110" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="170">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" icon="Check" @click="saveRow(scope.row)">保存</el-button>
|
||||
@@ -95,6 +99,27 @@ const loading = ref(true)
|
||||
const showSearch = ref(true)
|
||||
const total = ref(0)
|
||||
|
||||
// 存储累计金额数据
|
||||
const cumulativeAmounts = ref({})
|
||||
|
||||
// 从localStorage加载累计金额数据
|
||||
function loadCumulativeAmounts() {
|
||||
const stored = localStorage.getItem('wageCumulativeAmounts')
|
||||
if (stored) {
|
||||
try {
|
||||
cumulativeAmounts.value = JSON.parse(stored)
|
||||
} catch (e) {
|
||||
console.error('Failed to parse cumulative amounts:', e)
|
||||
cumulativeAmounts.value = {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 保存累计金额数据到localStorage
|
||||
function saveCumulativeAmounts() {
|
||||
localStorage.setItem('wageCumulativeAmounts', JSON.stringify(cumulativeAmounts.value))
|
||||
}
|
||||
|
||||
const data = reactive({
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
@@ -149,18 +174,43 @@ function recalcRowAmount(row) {
|
||||
const baseAmount = round2(workload * unitPrice)
|
||||
row.baseAmount = baseAmount
|
||||
row.totalAmount = round2(baseAmount + extraAmount)
|
||||
|
||||
// 重新计算累计金额
|
||||
updateCumulativeAmounts()
|
||||
}
|
||||
|
||||
function updateCumulativeAmounts() {
|
||||
// 计算当前页面的总金额
|
||||
const currentEmpAmounts = {}
|
||||
wageEntryDetailList.value.forEach(row => {
|
||||
const empName = row.empName
|
||||
if (!currentEmpAmounts[empName]) {
|
||||
currentEmpAmounts[empName] = 0
|
||||
}
|
||||
currentEmpAmounts[empName] += parseFloat(row.totalAmount) || 0
|
||||
})
|
||||
|
||||
// 更新每个员工的累计金额(基于存储的数据)
|
||||
wageEntryDetailList.value.forEach(row => {
|
||||
row.cumulativeAmount = cumulativeAmounts.value[row.empName] || 0
|
||||
})
|
||||
}
|
||||
|
||||
function getList() {
|
||||
loading.value = true
|
||||
// 加载存储的累计金额数据
|
||||
loadCumulativeAmounts()
|
||||
|
||||
listWageEntryDetail(queryParams.value).then(response => {
|
||||
const rows = response.rows || []
|
||||
|
||||
wageEntryDetailList.value = rows.map(row => {
|
||||
const r = {
|
||||
...row,
|
||||
workload: normalizeEditableValue(row.workload),
|
||||
unitPrice: normalizeEditableValue(row.unitPrice),
|
||||
extraAmount: normalizeEditableValue(row.extraAmount)
|
||||
extraAmount: normalizeEditableValue(row.extraAmount),
|
||||
cumulativeAmount: cumulativeAmounts.value[row.empName] || 0
|
||||
}
|
||||
recalcRowAmount(r)
|
||||
return r
|
||||
@@ -202,6 +252,13 @@ function buildRowPayload(row) {
|
||||
function saveRow(row) {
|
||||
const payload = buildRowPayload(row)
|
||||
updateWageEntryDetail(payload).then(() => {
|
||||
// 更新累计金额
|
||||
if (!cumulativeAmounts.value[row.empName]) {
|
||||
cumulativeAmounts.value[row.empName] = 0
|
||||
}
|
||||
cumulativeAmounts.value[row.empName] += parseFloat(payload.totalAmount) || 0
|
||||
saveCumulativeAmounts()
|
||||
|
||||
proxy.$modal.msgSuccess('保存成功')
|
||||
getList()
|
||||
})
|
||||
@@ -219,11 +276,19 @@ async function saveAllRows() {
|
||||
const payload = buildRowPayload(row)
|
||||
try {
|
||||
await updateWageEntryDetail(payload)
|
||||
// 更新累计金额
|
||||
if (!cumulativeAmounts.value[row.empName]) {
|
||||
cumulativeAmounts.value[row.empName] = 0
|
||||
}
|
||||
cumulativeAmounts.value[row.empName] += parseFloat(payload.totalAmount) || 0
|
||||
successCount++
|
||||
} catch (e) {
|
||||
failCount++
|
||||
}
|
||||
}
|
||||
// 保存累计金额数据
|
||||
saveCumulativeAmounts()
|
||||
|
||||
loading.value = false
|
||||
if (failCount === 0) {
|
||||
proxy.$modal.msgSuccess(`全部保存完成,共 ${successCount} 条`)
|
||||
@@ -244,10 +309,20 @@ function handleDelete(row) {
|
||||
|
||||
function handleExport() {
|
||||
proxy.download('oa/wageEntryDetail/export', {
|
||||
...queryParams.value
|
||||
...queryParams.value,
|
||||
cumulativeAmounts: cumulativeAmounts.value
|
||||
}, `wage_entry_detail_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
|
||||
function resetCumulativeAmounts() {
|
||||
proxy.$modal.confirm('是否确认重置所有员工的累计金额?此操作不可恢复。').then(() => {
|
||||
cumulativeAmounts.value = {}
|
||||
saveCumulativeAmounts()
|
||||
proxy.$modal.msgSuccess('累计金额已重置')
|
||||
getList()
|
||||
})
|
||||
}
|
||||
|
||||
function handleInitDaily(forceReset = false) {
|
||||
const entryDate = queryParams.value.entryDate || proxy.parseTime(new Date(), '{y}-{m}-{d}')
|
||||
const text = forceReset ? `确认重置 ${entryDate} 的当日名单吗?将先删除后重建。` : `确认初始化 ${entryDate} 的工人名单吗?`
|
||||
@@ -260,15 +335,25 @@ function handleInitDaily(forceReset = false) {
|
||||
proxy.$modal.msgSuccess(`操作成功,共写入 ${res.data || 0} 人`)
|
||||
}
|
||||
getList()
|
||||
}).catch(err => {
|
||||
console.error('重置当日名单失败:', err)
|
||||
proxy.$modal.msgError('操作失败,请稍后重试')
|
||||
})
|
||||
}
|
||||
|
||||
async function autoInitFirstEnter() {
|
||||
const entryDate = queryParams.value.entryDate || proxy.parseTime(new Date(), '{y}-{m}-{d}')
|
||||
await initDailyWorkers({ entryDate, forceReset: false })
|
||||
try {
|
||||
await initDailyWorkers({ entryDate, forceReset: false })
|
||||
} catch (err) {
|
||||
console.error('自动初始化当日名单失败:', err)
|
||||
// 静默失败,不影响页面加载
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
// 加载存储的累计金额数据
|
||||
loadCumulativeAmounts()
|
||||
await autoInitFirstEnter()
|
||||
getList()
|
||||
})
|
||||
|
||||
@@ -91,6 +91,7 @@
|
||||
<script setup name="WageMakeup">
|
||||
import { listWageEntryDetail, updateWageEntryDetail, delWageEntryDetail } from '@/api/oa/wageEntryDetail'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import { onMounted } from 'vue'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const userStore = useUserStore()
|
||||
@@ -102,6 +103,27 @@ const open = ref(false)
|
||||
const title = ref('')
|
||||
const buttonLoading = ref(false)
|
||||
|
||||
// 存储累计金额数据
|
||||
const cumulativeAmounts = ref({})
|
||||
|
||||
// 从localStorage加载累计金额数据
|
||||
function loadCumulativeAmounts() {
|
||||
const stored = localStorage.getItem('wageCumulativeAmounts')
|
||||
if (stored) {
|
||||
try {
|
||||
cumulativeAmounts.value = JSON.parse(stored)
|
||||
} catch (e) {
|
||||
console.error('Failed to parse cumulative amounts:', e)
|
||||
cumulativeAmounts.value = {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 保存累计金额数据到localStorage
|
||||
function saveCumulativeAmounts() {
|
||||
localStorage.setItem('wageCumulativeAmounts', JSON.stringify(cumulativeAmounts.value))
|
||||
}
|
||||
|
||||
const data = reactive({
|
||||
form: {},
|
||||
queryParams: {
|
||||
@@ -197,6 +219,18 @@ function submitForm() {
|
||||
}
|
||||
// 本页面补录语义:更新当前记录并标记为已补录
|
||||
updateWageEntryDetail(payload).then(() => {
|
||||
// 更新累计金额
|
||||
const workload = parseFloat(payload.workload) || 0
|
||||
const unitPrice = parseFloat(payload.unitPrice) || 0
|
||||
const extraAmount = parseFloat(payload.extraAmount) || 0
|
||||
const totalAmount = workload * unitPrice + extraAmount
|
||||
|
||||
if (!cumulativeAmounts.value[payload.empName]) {
|
||||
cumulativeAmounts.value[payload.empName] = 0
|
||||
}
|
||||
cumulativeAmounts.value[payload.empName] += totalAmount
|
||||
saveCumulativeAmounts()
|
||||
|
||||
proxy.$modal.msgSuccess('补录成功')
|
||||
open.value = false
|
||||
getList()
|
||||
@@ -229,5 +263,8 @@ function handleExport() {
|
||||
proxy.download('oa/wageEntryDetail/export', { ...buildQuery() }, `wage_makeup_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
|
||||
getList()
|
||||
onMounted(() => {
|
||||
loadCumulativeAmounts()
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user