Compare commits
4 Commits
6aa1d581e7
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e7a50bf64 | ||
|
|
3ae6403bd3 | ||
|
|
855dbbe099 | ||
| f41a17c885 |
@@ -70,7 +70,7 @@ spring:
|
|||||||
# 国际化资源文件路径
|
# 国际化资源文件路径
|
||||||
basename: i18n/messages
|
basename: i18n/messages
|
||||||
profiles:
|
profiles:
|
||||||
active: prod
|
active: @profiles.active@
|
||||||
# 文件上传
|
# 文件上传
|
||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ public class MatMaterial extends BaseEntity {
|
|||||||
* 配料名称
|
* 配料名称
|
||||||
*/
|
*/
|
||||||
private String materialName;
|
private String materialName;
|
||||||
|
/**
|
||||||
|
* 物料类型:1=辅料,2=原料
|
||||||
|
*/
|
||||||
|
private Integer materialType;
|
||||||
/**
|
/**
|
||||||
* 配料规格
|
* 配料规格
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -54,4 +54,9 @@ public class MatProduct extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品图片,多个图片以逗号分隔
|
||||||
|
*/
|
||||||
|
private String productImages;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,11 @@ public class MatMaterialBo extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String materialName;
|
private String materialName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料类型:1=辅料,2=原料
|
||||||
|
*/
|
||||||
|
private Integer materialType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 配料规格
|
* 配料规格
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -52,5 +52,10 @@ public class MatProductBo extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品图片,多个图片以逗号分隔
|
||||||
|
*/
|
||||||
|
private String productImages;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,12 @@ public class MatMaterialVo {
|
|||||||
@ExcelProperty(value = "配料名称")
|
@ExcelProperty(value = "配料名称")
|
||||||
private String materialName;
|
private String materialName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料类型:1=辅料,2=原料
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "物料类型")
|
||||||
|
private Integer materialType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 配料规格
|
* 配料规格
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -58,5 +58,11 @@ public class MatProductVo {
|
|||||||
@ExcelProperty(value = "备注")
|
@ExcelProperty(value = "备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品图片,多个图片以逗号分隔
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "产品图片")
|
||||||
|
private String productImages;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,12 @@ public class MatProductWithMaterialsVo {
|
|||||||
@ExcelProperty(value = "备注")
|
@ExcelProperty(value = "备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品图片,多个图片以逗号分隔
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "产品图片")
|
||||||
|
private String productImages;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关联的配料信息列表
|
* 关联的配料信息列表
|
||||||
*/
|
*/
|
||||||
@@ -81,4 +87,4 @@ public class MatProductWithMaterialsVo {
|
|||||||
private BigDecimal planNum; // 计划采购总数量
|
private BigDecimal planNum; // 计划采购总数量
|
||||||
private BigDecimal receivedNum; // 已入库数量
|
private BigDecimal receivedNum; // 已入库数量
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ public class MatMaterialServiceImpl implements IMatMaterialService {
|
|||||||
Map<String, Object> params = bo.getParams();
|
Map<String, Object> params = bo.getParams();
|
||||||
LambdaQueryWrapper<MatMaterial> lqw = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<MatMaterial> lqw = Wrappers.lambdaQuery();
|
||||||
lqw.like(StringUtils.isNotBlank(bo.getMaterialName()), MatMaterial::getMaterialName, bo.getMaterialName());
|
lqw.like(StringUtils.isNotBlank(bo.getMaterialName()), MatMaterial::getMaterialName, bo.getMaterialName());
|
||||||
|
lqw.eq(bo.getMaterialType() != null, MatMaterial::getMaterialType, bo.getMaterialType());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getSpec()), MatMaterial::getSpec, bo.getSpec());
|
lqw.eq(StringUtils.isNotBlank(bo.getSpec()), MatMaterial::getSpec, bo.getSpec());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getModel()), MatMaterial::getModel, bo.getModel());
|
lqw.eq(StringUtils.isNotBlank(bo.getModel()), MatMaterial::getModel, bo.getModel());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getFactory()), MatMaterial::getFactory, bo.getFactory());
|
lqw.eq(StringUtils.isNotBlank(bo.getFactory()), MatMaterial::getFactory, bo.getFactory());
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<resultMap type="com.gear.mat.domain.MatMaterial" id="MatMaterialResult">
|
<resultMap type="com.gear.mat.domain.MatMaterial" id="MatMaterialResult">
|
||||||
<result property="materialId" column="material_id"/>
|
<result property="materialId" column="material_id"/>
|
||||||
<result property="materialName" column="material_name"/>
|
<result property="materialName" column="material_name"/>
|
||||||
|
<result property="materialType" column="material_type"/>
|
||||||
<result property="spec" column="spec"/>
|
<result property="spec" column="spec"/>
|
||||||
<result property="model" column="model"/>
|
<result property="model" column="model"/>
|
||||||
<result property="factory" column="factory"/>
|
<result property="factory" column="factory"/>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import javax.validation.constraints.NotBlank;
|
|||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工资录入明细业务对象 gear_wage_entry_detail
|
* 工资录入明细业务对象 gear_wage_entry_detail
|
||||||
@@ -71,4 +72,6 @@ public class GearWageEntryDetailBo extends BaseEntity {
|
|||||||
private String makeupReason;
|
private String makeupReason;
|
||||||
|
|
||||||
private String remark;
|
private String remark;
|
||||||
|
// 新增累计金额
|
||||||
|
private Map<String, BigDecimal> cumulativeAmounts;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,4 +77,6 @@ public class GearWageEntryDetailVo {
|
|||||||
|
|
||||||
@ExcelProperty(value = "备注")
|
@ExcelProperty(value = "备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
@ExcelProperty(value = "累计金额")
|
||||||
|
private BigDecimal cumulativeAmount;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,11 +49,24 @@ public class GearWageEntryDetailServiceImpl implements IGearWageEntryDetailServi
|
|||||||
return TableDataInfo.build(result);
|
return TableDataInfo.build(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public List<GearWageEntryDetailVo> queryList(GearWageEntryDetailBo bo) {
|
// public List<GearWageEntryDetailVo> queryList(GearWageEntryDetailBo bo) {
|
||||||
LambdaQueryWrapper<GearWageEntryDetail> lqw = buildQueryWrapper(bo);
|
// LambdaQueryWrapper<GearWageEntryDetail> lqw = buildQueryWrapper(bo);
|
||||||
return baseMapper.selectVoList(lqw);
|
// 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) {
|
private LambdaQueryWrapper<GearWageEntryDetail> buildQueryWrapper(GearWageEntryDetailBo bo) {
|
||||||
LambdaQueryWrapper<GearWageEntryDetail> lqw = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<GearWageEntryDetail> lqw = Wrappers.lambdaQuery();
|
||||||
|
|||||||
@@ -40,7 +40,8 @@
|
|||||||
"vue-cropper": "1.1.1",
|
"vue-cropper": "1.1.1",
|
||||||
"vue-router": "4.5.1",
|
"vue-router": "4.5.1",
|
||||||
"vue3-treeselect": "^0.1.10",
|
"vue3-treeselect": "^0.1.10",
|
||||||
"vuedraggable": "4.1.0"
|
"vuedraggable": "4.1.0",
|
||||||
|
"xlsx": "^0.18.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "5.2.4",
|
"@vitejs/plugin-vue": "5.2.4",
|
||||||
|
|||||||
@@ -11,10 +11,32 @@
|
|||||||
</div>
|
</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
|
<el-table :data="list" style="width: 100%" border stripe @row-click="handleRowSelect" highlight-current-row
|
||||||
row-key="materialId" :current-row-key="materialId">
|
row-key="materialId" :current-row-key="materialId">
|
||||||
<el-table-column prop="materialName" label="配料名称" min-width="120" align="center" />
|
<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="spec" label="配料规格" min-width="100" align="center" />
|
||||||
<el-table-column prop="model" 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" />
|
<el-table-column prop="factory" label="生产厂家" min-width="120" align="center" />
|
||||||
@@ -64,6 +86,12 @@ const emit = defineEmits(['change']);
|
|||||||
const list = ref([]); // 物料列表
|
const list = ref([]); // 物料列表
|
||||||
const open = ref(false); // 弹窗显隐
|
const open = ref(false); // 弹窗显隐
|
||||||
|
|
||||||
|
// 搜索表单数据
|
||||||
|
const searchForm = ref({
|
||||||
|
materialName: '',
|
||||||
|
materialType: ''
|
||||||
|
});
|
||||||
|
|
||||||
// 分页响应式数据(核心新增)
|
// 分页响应式数据(核心新增)
|
||||||
const pageNum = ref(1); // 当前页码
|
const pageNum = ref(1); // 当前页码
|
||||||
const pageSize = ref(10); // 每页条数
|
const pageSize = ref(10); // 每页条数
|
||||||
@@ -77,7 +105,15 @@ onMounted(async () => {
|
|||||||
// 加载物料列表(适配分页参数)
|
// 加载物料列表(适配分页参数)
|
||||||
async function fetchMaterialList() {
|
async function fetchMaterialList() {
|
||||||
try {
|
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;
|
list.value = res.rows;
|
||||||
total.value = res.total; // 赋值总条数供分页使用
|
total.value = res.total; // 赋值总条数供分页使用
|
||||||
@@ -95,6 +131,16 @@ async function fetchMaterialList() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 重置搜索
|
||||||
|
function resetSearch() {
|
||||||
|
searchForm.value = {
|
||||||
|
materialName: '',
|
||||||
|
materialType: ''
|
||||||
|
};
|
||||||
|
pageNum.value = 1;
|
||||||
|
fetchMaterialList();
|
||||||
|
}
|
||||||
|
|
||||||
// 表格行选择物料
|
// 表格行选择物料
|
||||||
function handleRowSelect(row) {
|
function handleRowSelect(row) {
|
||||||
if (row.materialId === materialId.value) return;
|
if (row.materialId === materialId.value) return;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const service = axios.create({
|
|||||||
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
||||||
baseURL: import.meta.env.VITE_APP_BASE_API,
|
baseURL: import.meta.env.VITE_APP_BASE_API,
|
||||||
// 超时
|
// 超时
|
||||||
timeout: 10000
|
timeout: 30000
|
||||||
})
|
})
|
||||||
|
|
||||||
// request拦截器
|
// request拦截器
|
||||||
|
|||||||
@@ -25,6 +25,11 @@
|
|||||||
<raw :data="scope.row" :materialId="scope.row.materialId" />
|
<raw :data="scope.row" :materialId="scope.row.materialId" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</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">
|
<el-table-column label="所需数量" align="center" prop="materialNum">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
{{ formatDecimal(scope.row.materialNum) }}
|
{{ formatDecimal(scope.row.materialNum) }}
|
||||||
@@ -75,6 +80,7 @@
|
|||||||
|
|
||||||
<script setup name="ProductMaterialRelation">
|
<script setup name="ProductMaterialRelation">
|
||||||
import { listProductMaterialRelation, getProductMaterialRelation, delProductMaterialRelation, addProductMaterialRelation, updateProductMaterialRelation } from "@/api/mat/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 RawSelector from '@/components/RawSelector/index.vue'
|
||||||
import Raw from '@/components/Renderer/Raw.vue'
|
import Raw from '@/components/Renderer/Raw.vue'
|
||||||
import { formatDecimal } from '@/utils/gear'
|
import { formatDecimal } from '@/utils/gear'
|
||||||
@@ -128,8 +134,21 @@ watch(() => props.productId, (newVal, oldVal) => {
|
|||||||
function getList() {
|
function getList() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
listProductMaterialRelation(queryParams.value).then(response => {
|
listProductMaterialRelation(queryParams.value).then(response => {
|
||||||
productMaterialRelationList.value = response.rows;
|
const relations = response.rows;
|
||||||
total.value = response.total;
|
// 为每个配方项获取物料详细信息,包括物料类型
|
||||||
|
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;
|
loading.value = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,9 +45,24 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="备注" align="center" prop="remark" />
|
<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">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button link type="primary" icon="Plus" @click="handleBom(scope.row)">配方</el-button>
|
<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="Edit" @click="handleUpdate(scope.row)">修改</el-button>
|
||||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
|
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
@@ -75,6 +90,26 @@
|
|||||||
<el-form-item label="备注" prop="remark">
|
<el-form-item label="备注" prop="remark">
|
||||||
<el-input v-model="form.remark" placeholder="请输入备注" />
|
<el-input v-model="form.remark" placeholder="请输入备注" />
|
||||||
</el-form-item>
|
</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>
|
</el-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<div class="dialog-footer">
|
<div class="dialog-footer">
|
||||||
@@ -110,16 +145,191 @@
|
|||||||
<el-empty v-else description="选择产品查看配料信息" />
|
<el-empty v-else description="选择产品查看配料信息" />
|
||||||
|
|
||||||
<!-- </StickyDragContainer> -->
|
<!-- </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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="Product">
|
<script setup name="Product">
|
||||||
|
import { ref, computed } from 'vue';
|
||||||
import { listProduct, getProduct, delProduct, addProduct, updateProduct } from "@/api/mat/product";
|
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 bom from "@/views/mat/components/bom.vue";
|
||||||
import StickyDragContainer from "@/components/StickyDragContainer/index.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 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();
|
const { proxy } = getCurrentInstance();
|
||||||
|
|
||||||
@@ -136,6 +346,9 @@ const title = ref("");
|
|||||||
const currentProductId = ref(null);
|
const currentProductId = ref(null);
|
||||||
const currentProduct = ref({});
|
const currentProduct = ref({});
|
||||||
const appContainer = ref(null);
|
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) => {
|
const formatterTime = (time) => {
|
||||||
return proxy.parseTime(time, '{y}-{m}-{d}')
|
return proxy.parseTime(time, '{y}-{m}-{d}')
|
||||||
@@ -185,8 +398,10 @@ function reset() {
|
|||||||
createBy: null,
|
createBy: null,
|
||||||
updateTime: null,
|
updateTime: null,
|
||||||
updateBy: null,
|
updateBy: null,
|
||||||
remark: null
|
remark: null,
|
||||||
|
productImages: null
|
||||||
};
|
};
|
||||||
|
imageFileList.value = [];
|
||||||
proxy.resetForm("productRef");
|
proxy.resetForm("productRef");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,11 +439,60 @@ function handleUpdate(row) {
|
|||||||
getProduct(_productId).then(response => {
|
getProduct(_productId).then(response => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
form.value = response.data;
|
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;
|
open.value = true;
|
||||||
title.value = "修改产品基础信息";
|
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() {
|
function submitForm() {
|
||||||
proxy.$refs["productRef"].validate(valid => {
|
proxy.$refs["productRef"].validate(valid => {
|
||||||
@@ -287,5 +551,153 @@ function handleRowClick(row) {
|
|||||||
currentProduct.value = 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();
|
getList();
|
||||||
</script>
|
</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>
|
||||||
|
|||||||
@@ -13,6 +13,11 @@
|
|||||||
<el-form-item label="厂家" prop="factory">
|
<el-form-item label="厂家" prop="factory">
|
||||||
<el-input v-model="queryParams.factory" placeholder="请输入厂家" clearable @keyup.enter="handleQuery" />
|
<el-input v-model="queryParams.factory" placeholder="请输入厂家" clearable @keyup.enter="handleQuery" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<!-- <el-form-item label="物料类型" prop="materialType">
|
||||||
|
<el-select v-model="queryParams.materialType" placeholder="请选择物料类型" @change="handleQuery" disabled>
|
||||||
|
<el-option label="原料" value="2" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item> -->
|
||||||
<!-- <el-form-item label="计量单位 个/公斤/米等" prop="unit">
|
<!-- <el-form-item label="计量单位 个/公斤/米等" prop="unit">
|
||||||
<el-input v-model="queryParams.unit" placeholder="请输入计量单位 个/公斤/米等" clearable @keyup.enter="handleQuery" />
|
<el-input v-model="queryParams.unit" placeholder="请输入计量单位 个/公斤/米等" clearable @keyup.enter="handleQuery" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -45,6 +50,11 @@
|
|||||||
<el-table-column type="selection" width="55" align="center" />
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
<!-- <el-table-column label="配料ID 主键" align="center" prop="materialId" v-if="true" /> -->
|
<!-- <el-table-column label="配料ID 主键" align="center" prop="materialId" v-if="true" /> -->
|
||||||
<el-table-column label="配料名称" align="center" prop="materialName" />
|
<el-table-column label="配料名称" align="center" prop="materialName" />
|
||||||
|
<el-table-column label="物料类型" align="center" prop="materialType">
|
||||||
|
<template #default="scope">
|
||||||
|
{{ scope.row.materialType === 1 ? '辅料' : '主材' }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="配料规格" align="center" prop="spec" />
|
<el-table-column label="配料规格" align="center" prop="spec" />
|
||||||
<el-table-column label="配料型号" align="center" prop="model" />
|
<el-table-column label="配料型号" align="center" prop="model" />
|
||||||
<el-table-column label="厂家" align="center" prop="factory" />
|
<el-table-column label="厂家" align="center" prop="factory" />
|
||||||
@@ -79,6 +89,11 @@
|
|||||||
<el-form-item label="配料名称" prop="materialName">
|
<el-form-item label="配料名称" prop="materialName">
|
||||||
<el-input v-model="form.materialName" placeholder="请输入配料名称" />
|
<el-input v-model="form.materialName" placeholder="请输入配料名称" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="物料类型" prop="materialType">
|
||||||
|
<el-select v-model="form.materialType" placeholder="请选择物料类型" disabled>
|
||||||
|
<el-option label="主材" value="2" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="配料规格" prop="spec">
|
<el-form-item label="配料规格" prop="spec">
|
||||||
<el-input v-model="form.spec" placeholder="请输入配料规格" />
|
<el-input v-model="form.spec" placeholder="请输入配料规格" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -171,7 +186,7 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
|
||||||
<Price :materialId="currentMaterialId" ref="priceRef" />
|
<Price :materialId="currentMaterialId" ref="priceRef" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -232,6 +247,7 @@ const data = reactive({
|
|||||||
factory: undefined,
|
factory: undefined,
|
||||||
unit: undefined,
|
unit: undefined,
|
||||||
currentStock: undefined,
|
currentStock: undefined,
|
||||||
|
materialType: 2, // 固定为原料
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
}
|
}
|
||||||
@@ -260,6 +276,7 @@ function reset() {
|
|||||||
form.value = {
|
form.value = {
|
||||||
materialId: null,
|
materialId: null,
|
||||||
materialName: null,
|
materialName: null,
|
||||||
|
materialType: 2, // 固定为原料
|
||||||
spec: null,
|
spec: null,
|
||||||
model: null,
|
model: null,
|
||||||
factory: null,
|
factory: null,
|
||||||
@@ -284,6 +301,7 @@ function handleQuery() {
|
|||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
function resetQuery() {
|
function resetQuery() {
|
||||||
proxy.resetForm("queryRef");
|
proxy.resetForm("queryRef");
|
||||||
|
queryParams.value.materialType = 2; // 重置后仍为原料
|
||||||
handleQuery();
|
handleQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,9 @@
|
|||||||
<el-col :span="2.5">
|
<el-col :span="2.5">
|
||||||
<el-button size="small" type="info" plain icon="RefreshRight" @click="handleInitDaily(true)">重置当日名单</el-button>
|
<el-button size="small" type="info" plain icon="RefreshRight" @click="handleInitDaily(true)">重置当日名单</el-button>
|
||||||
</el-col>
|
</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-col :span="1.8">
|
||||||
<el-button size="small" type="primary" plain icon="Check" @click="saveAllRows">全部保存</el-button>
|
<el-button size="small" type="primary" plain icon="Check" @click="saveAllRows">全部保存</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -72,6 +75,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column label="总金额" align="center" prop="totalAmount" width="110" />
|
<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">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="170">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button link type="primary" icon="Check" @click="saveRow(scope.row)">保存</el-button>
|
<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 showSearch = ref(true)
|
||||||
const total = ref(0)
|
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({
|
const data = reactive({
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
@@ -149,18 +174,43 @@ function recalcRowAmount(row) {
|
|||||||
const baseAmount = round2(workload * unitPrice)
|
const baseAmount = round2(workload * unitPrice)
|
||||||
row.baseAmount = baseAmount
|
row.baseAmount = baseAmount
|
||||||
row.totalAmount = round2(baseAmount + extraAmount)
|
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() {
|
function getList() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
// 加载存储的累计金额数据
|
||||||
|
loadCumulativeAmounts()
|
||||||
|
|
||||||
listWageEntryDetail(queryParams.value).then(response => {
|
listWageEntryDetail(queryParams.value).then(response => {
|
||||||
const rows = response.rows || []
|
const rows = response.rows || []
|
||||||
|
|
||||||
wageEntryDetailList.value = rows.map(row => {
|
wageEntryDetailList.value = rows.map(row => {
|
||||||
const r = {
|
const r = {
|
||||||
...row,
|
...row,
|
||||||
workload: normalizeEditableValue(row.workload),
|
workload: normalizeEditableValue(row.workload),
|
||||||
unitPrice: normalizeEditableValue(row.unitPrice),
|
unitPrice: normalizeEditableValue(row.unitPrice),
|
||||||
extraAmount: normalizeEditableValue(row.extraAmount)
|
extraAmount: normalizeEditableValue(row.extraAmount),
|
||||||
|
cumulativeAmount: cumulativeAmounts.value[row.empName] || 0
|
||||||
}
|
}
|
||||||
recalcRowAmount(r)
|
recalcRowAmount(r)
|
||||||
return r
|
return r
|
||||||
@@ -202,6 +252,13 @@ function buildRowPayload(row) {
|
|||||||
function saveRow(row) {
|
function saveRow(row) {
|
||||||
const payload = buildRowPayload(row)
|
const payload = buildRowPayload(row)
|
||||||
updateWageEntryDetail(payload).then(() => {
|
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('保存成功')
|
proxy.$modal.msgSuccess('保存成功')
|
||||||
getList()
|
getList()
|
||||||
})
|
})
|
||||||
@@ -219,11 +276,19 @@ async function saveAllRows() {
|
|||||||
const payload = buildRowPayload(row)
|
const payload = buildRowPayload(row)
|
||||||
try {
|
try {
|
||||||
await updateWageEntryDetail(payload)
|
await updateWageEntryDetail(payload)
|
||||||
|
// 更新累计金额
|
||||||
|
if (!cumulativeAmounts.value[row.empName]) {
|
||||||
|
cumulativeAmounts.value[row.empName] = 0
|
||||||
|
}
|
||||||
|
cumulativeAmounts.value[row.empName] += parseFloat(payload.totalAmount) || 0
|
||||||
successCount++
|
successCount++
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
failCount++
|
failCount++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 保存累计金额数据
|
||||||
|
saveCumulativeAmounts()
|
||||||
|
|
||||||
loading.value = false
|
loading.value = false
|
||||||
if (failCount === 0) {
|
if (failCount === 0) {
|
||||||
proxy.$modal.msgSuccess(`全部保存完成,共 ${successCount} 条`)
|
proxy.$modal.msgSuccess(`全部保存完成,共 ${successCount} 条`)
|
||||||
@@ -244,10 +309,20 @@ function handleDelete(row) {
|
|||||||
|
|
||||||
function handleExport() {
|
function handleExport() {
|
||||||
proxy.download('oa/wageEntryDetail/export', {
|
proxy.download('oa/wageEntryDetail/export', {
|
||||||
...queryParams.value
|
...queryParams.value,
|
||||||
|
cumulativeAmounts: cumulativeAmounts.value
|
||||||
}, `wage_entry_detail_${new Date().getTime()}.xlsx`)
|
}, `wage_entry_detail_${new Date().getTime()}.xlsx`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetCumulativeAmounts() {
|
||||||
|
proxy.$modal.confirm('是否确认重置所有员工的累计金额?此操作不可恢复。').then(() => {
|
||||||
|
cumulativeAmounts.value = {}
|
||||||
|
saveCumulativeAmounts()
|
||||||
|
proxy.$modal.msgSuccess('累计金额已重置')
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function handleInitDaily(forceReset = false) {
|
function handleInitDaily(forceReset = false) {
|
||||||
const entryDate = queryParams.value.entryDate || proxy.parseTime(new Date(), '{y}-{m}-{d}')
|
const entryDate = queryParams.value.entryDate || proxy.parseTime(new Date(), '{y}-{m}-{d}')
|
||||||
const text = forceReset ? `确认重置 ${entryDate} 的当日名单吗?将先删除后重建。` : `确认初始化 ${entryDate} 的工人名单吗?`
|
const text = forceReset ? `确认重置 ${entryDate} 的当日名单吗?将先删除后重建。` : `确认初始化 ${entryDate} 的工人名单吗?`
|
||||||
@@ -260,15 +335,25 @@ function handleInitDaily(forceReset = false) {
|
|||||||
proxy.$modal.msgSuccess(`操作成功,共写入 ${res.data || 0} 人`)
|
proxy.$modal.msgSuccess(`操作成功,共写入 ${res.data || 0} 人`)
|
||||||
}
|
}
|
||||||
getList()
|
getList()
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('重置当日名单失败:', err)
|
||||||
|
proxy.$modal.msgError('操作失败,请稍后重试')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function autoInitFirstEnter() {
|
async function autoInitFirstEnter() {
|
||||||
const entryDate = queryParams.value.entryDate || proxy.parseTime(new Date(), '{y}-{m}-{d}')
|
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 () => {
|
onMounted(async () => {
|
||||||
|
// 加载存储的累计金额数据
|
||||||
|
loadCumulativeAmounts()
|
||||||
await autoInitFirstEnter()
|
await autoInitFirstEnter()
|
||||||
getList()
|
getList()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -91,6 +91,7 @@
|
|||||||
<script setup name="WageMakeup">
|
<script setup name="WageMakeup">
|
||||||
import { listWageEntryDetail, updateWageEntryDetail, delWageEntryDetail } from '@/api/oa/wageEntryDetail'
|
import { listWageEntryDetail, updateWageEntryDetail, delWageEntryDetail } from '@/api/oa/wageEntryDetail'
|
||||||
import useUserStore from '@/store/modules/user'
|
import useUserStore from '@/store/modules/user'
|
||||||
|
import { onMounted } from 'vue'
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance()
|
const { proxy } = getCurrentInstance()
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
@@ -102,6 +103,27 @@ const open = ref(false)
|
|||||||
const title = ref('')
|
const title = ref('')
|
||||||
const buttonLoading = ref(false)
|
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({
|
const data = reactive({
|
||||||
form: {},
|
form: {},
|
||||||
queryParams: {
|
queryParams: {
|
||||||
@@ -197,6 +219,18 @@ function submitForm() {
|
|||||||
}
|
}
|
||||||
// 本页面补录语义:更新当前记录并标记为已补录
|
// 本页面补录语义:更新当前记录并标记为已补录
|
||||||
updateWageEntryDetail(payload).then(() => {
|
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('补录成功')
|
proxy.$modal.msgSuccess('补录成功')
|
||||||
open.value = false
|
open.value = false
|
||||||
getList()
|
getList()
|
||||||
@@ -229,5 +263,8 @@ function handleExport() {
|
|||||||
proxy.download('oa/wageEntryDetail/export', { ...buildQuery() }, `wage_makeup_${new Date().getTime()}.xlsx`)
|
proxy.download('oa/wageEntryDetail/export', { ...buildQuery() }, `wage_makeup_${new Date().getTime()}.xlsx`)
|
||||||
}
|
}
|
||||||
|
|
||||||
getList()
|
onMounted(() => {
|
||||||
|
loadCumulativeAmounts()
|
||||||
|
getList()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user