产品最终版,薪资优化
This commit is contained in:
@@ -70,7 +70,8 @@ spring:
|
|||||||
# 国际化资源文件路径
|
# 国际化资源文件路径
|
||||||
basename: i18n/messages
|
basename: i18n/messages
|
||||||
profiles:
|
profiles:
|
||||||
active: @profiles.active@
|
active: prod
|
||||||
|
# @profiles.active@
|
||||||
# 文件上传
|
# 文件上传
|
||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import com.gear.mat.service.IMatProductAdditionService;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,6 +39,11 @@ public class MatProductAdditionController extends BaseController {
|
|||||||
return TableDataInfo.build(list);
|
return TableDataInfo.build(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/listByProductIds")
|
||||||
|
public R<Map<Long, List<MatProductAdditionVo>>> listByProductIds(@RequestBody List<Long> productIds) {
|
||||||
|
return R.ok(productAdditionService.listByProductIds(productIds));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增产品属性附加表
|
* 新增产品属性附加表
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -23,8 +23,13 @@ import com.gear.common.utils.poi.ExcelUtil;
|
|||||||
import com.gear.mat.domain.vo.MatProductVo;
|
import com.gear.mat.domain.vo.MatProductVo;
|
||||||
import com.gear.mat.domain.vo.MatProductWithMaterialsVo;
|
import com.gear.mat.domain.vo.MatProductWithMaterialsVo;
|
||||||
import com.gear.mat.domain.bo.MatProductBo;
|
import com.gear.mat.domain.bo.MatProductBo;
|
||||||
|
import com.gear.mat.domain.bo.MatProductImportBo;
|
||||||
import com.gear.mat.service.IMatProductService;
|
import com.gear.mat.service.IMatProductService;
|
||||||
import com.gear.common.core.page.TableDataInfo;
|
import com.gear.common.core.page.TableDataInfo;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 产品基础信息
|
* 产品基础信息
|
||||||
@@ -48,6 +53,14 @@ public class MatProductController extends BaseController {
|
|||||||
return iMatProductService.queryPageListWithMaterials(bo, pageQuery);
|
return iMatProductService.queryPageListWithMaterials(bo, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询产品基础信息列表(不包含配料信息,用于列表页加速)
|
||||||
|
*/
|
||||||
|
@GetMapping("/listBase")
|
||||||
|
public TableDataInfo<MatProductVo> listBase(MatProductBo bo, PageQuery pageQuery) {
|
||||||
|
return iMatProductService.queryPageList(bo, pageQuery);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出产品基础信息列表
|
* 导出产品基础信息列表
|
||||||
*/
|
*/
|
||||||
@@ -58,6 +71,25 @@ public class MatProductController extends BaseController {
|
|||||||
ExcelUtil.exportExcel(list, "产品基础信息", MatProductVo.class, response);
|
ExcelUtil.exportExcel(list, "产品基础信息", MatProductVo.class, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/importTemplate", method = {RequestMethod.GET, RequestMethod.POST})
|
||||||
|
public void importTemplate(HttpServletResponse response) {
|
||||||
|
ExcelUtil.exportExcel(Collections.singletonList(new MatProductImportBo()), "产品导入模板", MatProductImportBo.class, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log(title = "产品基础信息", businessType = BusinessType.IMPORT)
|
||||||
|
@PostMapping("/importData")
|
||||||
|
public R<String> importData(@RequestPart("file") MultipartFile file,
|
||||||
|
@RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception {
|
||||||
|
if (file == null || file.isEmpty()) {
|
||||||
|
return R.fail("导入文件不能为空");
|
||||||
|
}
|
||||||
|
try (InputStream is = file.getInputStream()) {
|
||||||
|
List<MatProductImportBo> list = ExcelUtil.importExcel(is, MatProductImportBo.class);
|
||||||
|
String msg = iMatProductService.importByExcel(list, updateSupport);
|
||||||
|
return R.ok(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取产品基础信息详细信息
|
* 获取产品基础信息详细信息
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.gear.mat.domain.bo;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品导入模板对象
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class MatProductImportBo {
|
||||||
|
|
||||||
|
@ExcelProperty("产品名称")
|
||||||
|
private String productName;
|
||||||
|
|
||||||
|
@ExcelProperty("产品规格")
|
||||||
|
private String spec;
|
||||||
|
|
||||||
|
@ExcelProperty("产品型号")
|
||||||
|
private String model;
|
||||||
|
|
||||||
|
@ExcelProperty("产品单价")
|
||||||
|
private BigDecimal unitPrice;
|
||||||
|
|
||||||
|
@ExcelProperty("备注")
|
||||||
|
private String remark;
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
import com.gear.mat.domain.MatProductAddition;
|
import com.gear.mat.domain.MatProductAddition;
|
||||||
import com.gear.mat.domain.bo.MatProductAdditionBo;
|
import com.gear.mat.domain.bo.MatProductAdditionBo;
|
||||||
import com.gear.mat.domain.vo.MatProductAdditionVo;
|
import com.gear.mat.domain.vo.MatProductAdditionVo;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,4 +47,6 @@ public interface IMatProductAdditionService extends IService<MatProductAddition>
|
|||||||
boolean delProductAddition(Long addId);
|
boolean delProductAddition(Long addId);
|
||||||
|
|
||||||
boolean batchSaveProductAddition(Long productId, List<MatProductAdditionBo> items);
|
boolean batchSaveProductAddition(Long productId, List<MatProductAdditionBo> items);
|
||||||
|
|
||||||
|
Map<Long, List<MatProductAdditionVo>> listByProductIds(List<Long> productIds);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.gear.mat.service;
|
package com.gear.mat.service;
|
||||||
|
|
||||||
import com.gear.mat.domain.MatProduct;
|
import com.gear.mat.domain.MatProduct;
|
||||||
|
import com.gear.mat.domain.bo.MatProductImportBo;
|
||||||
import com.gear.mat.domain.vo.MatProductVo;
|
import com.gear.mat.domain.vo.MatProductVo;
|
||||||
import com.gear.mat.domain.vo.MatProductWithMaterialsVo;
|
import com.gear.mat.domain.vo.MatProductWithMaterialsVo;
|
||||||
import com.gear.mat.domain.bo.MatProductBo;
|
import com.gear.mat.domain.bo.MatProductBo;
|
||||||
@@ -52,4 +53,9 @@ public interface IMatProductService {
|
|||||||
* 校验并批量删除产品基础信息信息
|
* 校验并批量删除产品基础信息信息
|
||||||
*/
|
*/
|
||||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Excel导入产品基础信息
|
||||||
|
*/
|
||||||
|
String importByExcel(List<MatProductImportBo> list, Boolean updateSupport);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ import com.gear.mat.service.IMatProductAdditionService;
|
|||||||
import com.gear.common.utils.BeanCopyUtils;
|
import com.gear.common.utils.BeanCopyUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -105,4 +108,26 @@ public class MatProductAdditionServiceImpl extends ServiceImpl<MatProductAdditio
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Long, List<MatProductAdditionVo>> listByProductIds(List<Long> productIds) {
|
||||||
|
if (productIds == null || productIds.isEmpty()) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
List<MatProductAddition> list = baseMapper.selectList(new LambdaQueryWrapper<MatProductAddition>()
|
||||||
|
.in(MatProductAddition::getProductId, productIds)
|
||||||
|
.eq(MatProductAddition::getDelFlag, 0)
|
||||||
|
.orderByAsc(MatProductAddition::getProductId)
|
||||||
|
.orderByAsc(MatProductAddition::getAddId));
|
||||||
|
|
||||||
|
Map<Long, List<MatProductAdditionVo>> result = new HashMap<>();
|
||||||
|
for (MatProductAddition item : list) {
|
||||||
|
if (item == null || item.getProductId() == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
MatProductAdditionVo vo = BeanCopyUtils.copy(item, MatProductAdditionVo.class);
|
||||||
|
result.computeIfAbsent(item.getProductId(), k -> new java.util.ArrayList<>()).add(vo);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.gear.common.core.domain.PageQuery;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.gear.mat.domain.bo.MatProductImportBo;
|
||||||
import com.gear.mat.domain.bo.MatProductMaterialRelationBo;
|
import com.gear.mat.domain.bo.MatProductMaterialRelationBo;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -25,6 +26,7 @@ import com.gear.mat.domain.vo.MatProductMaterialRelationVo;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@@ -210,4 +212,46 @@ public class MatProductServiceImpl implements IMatProductService {
|
|||||||
}
|
}
|
||||||
return baseMapper.deleteBatchIds(ids) > 0;
|
return baseMapper.deleteBatchIds(ids) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String importByExcel(List<MatProductImportBo> list, Boolean updateSupport) {
|
||||||
|
if (list == null || list.isEmpty()) {
|
||||||
|
return "导入数据为空";
|
||||||
|
}
|
||||||
|
int success = 0;
|
||||||
|
int skipped = 0;
|
||||||
|
for (MatProductImportBo row : list) {
|
||||||
|
String productName = row == null ? null : StringUtils.trim(row.getProductName());
|
||||||
|
String spec = row == null ? null : StringUtils.trim(row.getSpec());
|
||||||
|
String model = row == null ? null : StringUtils.trim(row.getModel());
|
||||||
|
if (StringUtils.isBlank(productName)) {
|
||||||
|
skipped++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
LambdaQueryWrapper<MatProduct> lqw = Wrappers.lambdaQuery();
|
||||||
|
lqw.eq(MatProduct::getProductName, productName)
|
||||||
|
.eq(MatProduct::getSpec, Objects.toString(spec, ""))
|
||||||
|
.eq(MatProduct::getModel, Objects.toString(model, ""))
|
||||||
|
.last("limit 1");
|
||||||
|
MatProduct exist = baseMapper.selectOne(lqw);
|
||||||
|
if (exist != null && !Boolean.TRUE.equals(updateSupport)) {
|
||||||
|
skipped++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
MatProduct data = exist == null ? new MatProduct() : exist;
|
||||||
|
data.setProductName(productName);
|
||||||
|
data.setSpec(spec);
|
||||||
|
data.setModel(model);
|
||||||
|
data.setUnitPrice(row.getUnitPrice());
|
||||||
|
data.setRemark(row.getRemark());
|
||||||
|
if (exist == null) {
|
||||||
|
baseMapper.insert(data);
|
||||||
|
} else {
|
||||||
|
baseMapper.updateById(data);
|
||||||
|
}
|
||||||
|
success++;
|
||||||
|
}
|
||||||
|
return "导入完成,成功 " + success + " 条,跳过 " + skipped + " 条";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import java.util.Date;
|
|||||||
@ExcelIgnoreUnannotated
|
@ExcelIgnoreUnannotated
|
||||||
public class GearWageEntryDetailVo {
|
public class GearWageEntryDetailVo {
|
||||||
|
|
||||||
@ExcelProperty(value = "明细ID")
|
|
||||||
private Long detailId;
|
private Long detailId;
|
||||||
|
|
||||||
@ExcelProperty(value = "业务日期")
|
@ExcelProperty(value = "业务日期")
|
||||||
@@ -24,63 +23,49 @@ public class GearWageEntryDetailVo {
|
|||||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
private Date entryDate;
|
private Date entryDate;
|
||||||
|
|
||||||
@ExcelProperty(value = "员工ID")
|
|
||||||
private Long empId;
|
private Long empId;
|
||||||
|
|
||||||
@ExcelProperty(value = "员工姓名")
|
@ExcelProperty(value = "员工姓名")
|
||||||
private String empName;
|
private String empName;
|
||||||
|
|
||||||
@ExcelProperty(value = "计费类型")
|
|
||||||
private String billingType;
|
private String billingType;
|
||||||
|
|
||||||
@ExcelProperty(value = "费率配置ID")
|
|
||||||
private Long rateId;
|
private Long rateId;
|
||||||
|
|
||||||
@ExcelProperty(value = "工种")
|
|
||||||
private String workTypeName;
|
private String workTypeName;
|
||||||
|
|
||||||
@ExcelProperty(value = "加工物品")
|
|
||||||
private String itemName;
|
private String itemName;
|
||||||
|
|
||||||
@ExcelProperty(value = "工序")
|
|
||||||
private String processName;
|
private String processName;
|
||||||
|
|
||||||
@ExcelProperty(value = "订单号")
|
|
||||||
private String orderNo;
|
private String orderNo;
|
||||||
|
|
||||||
@ExcelProperty(value = "工作量")
|
|
||||||
private BigDecimal workload;
|
private BigDecimal workload;
|
||||||
|
|
||||||
@ExcelProperty(value = "单价")
|
|
||||||
private BigDecimal unitPrice;
|
private BigDecimal unitPrice;
|
||||||
|
|
||||||
@ExcelProperty(value = "基础金额")
|
|
||||||
private BigDecimal baseAmount;
|
private BigDecimal baseAmount;
|
||||||
|
|
||||||
@ExcelProperty(value = "额外金额")
|
|
||||||
private BigDecimal extraAmount;
|
private BigDecimal extraAmount;
|
||||||
|
|
||||||
@ExcelProperty(value = "额外原因")
|
|
||||||
private String extraReason;
|
private String extraReason;
|
||||||
|
|
||||||
@ExcelProperty(value = "明细计算金额")
|
|
||||||
private BigDecimal calcAmount;
|
private BigDecimal calcAmount;
|
||||||
|
|
||||||
private String calcDetail;
|
private String calcDetail;
|
||||||
|
|
||||||
@ExcelProperty(value = "总金额")
|
@ExcelProperty(value = "每天工资")
|
||||||
|
private BigDecimal dailyWage;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "当天金额")
|
||||||
private BigDecimal totalAmount;
|
private BigDecimal totalAmount;
|
||||||
|
|
||||||
@ExcelProperty(value = "是否补录")
|
|
||||||
private String isMakeup;
|
private String isMakeup;
|
||||||
|
|
||||||
@ExcelProperty(value = "补录责任人")
|
|
||||||
private String makeupResponsible;
|
private String makeupResponsible;
|
||||||
|
|
||||||
@ExcelProperty(value = "补录原因")
|
|
||||||
private String makeupReason;
|
private String makeupReason;
|
||||||
|
|
||||||
@ExcelProperty(value = "备注")
|
|
||||||
private String remark;
|
private String remark;
|
||||||
@ExcelProperty(value = "累计金额")
|
@ExcelProperty(value = "累计金额")
|
||||||
private BigDecimal cumulativeAmount;
|
private BigDecimal cumulativeAmount;
|
||||||
|
|||||||
@@ -51,6 +51,13 @@ public class GearWageEntryDetailServiceImpl implements IGearWageEntryDetailServi
|
|||||||
syncTodayWorkers(bo.getEntryDate());
|
syncTodayWorkers(bo.getEntryDate());
|
||||||
LambdaQueryWrapper<GearWageEntryDetail> lqw = buildQueryWrapper(bo);
|
LambdaQueryWrapper<GearWageEntryDetail> lqw = buildQueryWrapper(bo);
|
||||||
Page<GearWageEntryDetailVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
Page<GearWageEntryDetailVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||||
|
if (result != null && result.getRecords() != null) {
|
||||||
|
for (GearWageEntryDetailVo vo : result.getRecords()) {
|
||||||
|
if (vo != null) {
|
||||||
|
vo.setDailyWage(vo.getTotalAmount());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return TableDataInfo.build(result);
|
return TableDataInfo.build(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +72,13 @@ public class GearWageEntryDetailServiceImpl implements IGearWageEntryDetailServi
|
|||||||
syncTodayWorkers(bo.getEntryDate());
|
syncTodayWorkers(bo.getEntryDate());
|
||||||
// 将 selectList 改为 selectVoList
|
// 将 selectList 改为 selectVoList
|
||||||
List<GearWageEntryDetailVo> list = baseMapper.selectVoList(buildQueryWrapper(bo));
|
List<GearWageEntryDetailVo> list = baseMapper.selectVoList(buildQueryWrapper(bo));
|
||||||
|
if (list != null) {
|
||||||
|
for (GearWageEntryDetailVo vo : list) {
|
||||||
|
if (vo != null) {
|
||||||
|
vo.setDailyWage(vo.getTotalAmount());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// 处理累计金额
|
// 处理累计金额
|
||||||
if (bo.getCumulativeAmounts() != null) {
|
if (bo.getCumulativeAmounts() != null) {
|
||||||
for (GearWageEntryDetailVo vo : list) {
|
for (GearWageEntryDetailVo vo : list) {
|
||||||
|
|||||||
@@ -9,6 +9,15 @@ export function listProduct(query) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询产品基础信息列表(不包含配料信息,用于列表页加速)
|
||||||
|
export function listProductBase(query) {
|
||||||
|
return request({
|
||||||
|
url: '/mat/product/listBase',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 查询产品基础信息详细
|
// 查询产品基础信息详细
|
||||||
export function getProduct(productId) {
|
export function getProduct(productId) {
|
||||||
return request({
|
return request({
|
||||||
@@ -42,3 +51,21 @@ export function delProduct(productId) {
|
|||||||
method: 'delete'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 下载导入模板
|
||||||
|
export function importTemplateProduct() {
|
||||||
|
return request({
|
||||||
|
url: '/mat/product/importTemplate',
|
||||||
|
method: 'post',
|
||||||
|
responseType: 'blob'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导入产品数据
|
||||||
|
export function importProductData(data, updateSupport) {
|
||||||
|
return request({
|
||||||
|
url: '/mat/product/importData?updateSupport=' + (updateSupport ? 1 : 0),
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -42,3 +42,11 @@ export function batchSaveProductAddition(data) {
|
|||||||
data
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function listProductAdditionByProductIds(productIds) {
|
||||||
|
return request({
|
||||||
|
url: '/api/mat/productAddition/listByProductIds',
|
||||||
|
method: 'post',
|
||||||
|
data: productIds
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -47,8 +47,8 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :xs="24" :md="10">
|
<el-col :xs="24" :md="10">
|
||||||
<el-tabs class="media-tabs" type="border-card">
|
<el-tabs v-model="mediaTab" class="media-tabs" type="border-card">
|
||||||
<el-tab-pane label="图片">
|
<el-tab-pane label="图片" name="images">
|
||||||
<el-empty
|
<el-empty
|
||||||
v-if="!(productDetail.productImages && productDetail.productImages.trim())"
|
v-if="!(productDetail.productImages && productDetail.productImages.trim())"
|
||||||
description="暂无图片"
|
description="暂无图片"
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
|
||||||
<el-tab-pane label="说明书">
|
<el-tab-pane label="说明书" name="pdf">
|
||||||
<el-empty v-if="!pdfDisplayList.length" description="暂无说明书" />
|
<el-empty v-if="!pdfDisplayList.length" description="暂无说明书" />
|
||||||
<div v-else class="pdf-list">
|
<div v-else class="pdf-list">
|
||||||
<div v-for="(pdf, index) in pdfDisplayList" :key="index" class="pdf-item">
|
<div v-for="(pdf, index) in pdfDisplayList" :key="index" class="pdf-item">
|
||||||
@@ -100,7 +100,14 @@
|
|||||||
<div class="sub-title">主材 / 辅材 / 工价</div>
|
<div class="sub-title">主材 / 辅材 / 工价</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="total-badge">
|
<div class="total-badge">
|
||||||
合计:{{ formatDecimal(totalAmount) }} 元
|
<div class="total-main">合计:{{ formatDecimal(totalAmount) }} 元</div>
|
||||||
|
<div class="total-breakdown">
|
||||||
|
主材:{{ formatDecimal(mainSubtotal) }} 元
|
||||||
|
<span class="sep">|</span>
|
||||||
|
辅材:{{ formatDecimal(auxiliarySubtotal) }} 元
|
||||||
|
<span class="sep">|</span>
|
||||||
|
工价:{{ formatDecimal(laborSubtotal) }} 元
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -187,6 +194,7 @@ const materialLoading = ref(false);
|
|||||||
const additionLoading = ref(false);
|
const additionLoading = ref(false);
|
||||||
const pdfFiles = ref([]);
|
const pdfFiles = ref([]);
|
||||||
const pdfUrlFiles = ref([]);
|
const pdfUrlFiles = ref([]);
|
||||||
|
const mediaTab = ref('images');
|
||||||
|
|
||||||
// 材料明细数据
|
// 材料明细数据
|
||||||
const productMaterialRelationList = ref([]);
|
const productMaterialRelationList = ref([]);
|
||||||
@@ -222,15 +230,24 @@ const auxiliaryMaterials = computed(() => {
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
// 计算总金额
|
const mainSubtotal = computed(() => {
|
||||||
const totalAmount = computed(() => {
|
return mainMaterials.value.reduce((sum, item) => sum + item.subtotal, 0);
|
||||||
const mainTotal = mainMaterials.value.reduce((sum, item) => sum + item.subtotal, 0);
|
});
|
||||||
const auxiliaryTotal = auxiliaryMaterials.value.reduce((sum, item) => sum + item.subtotal, 0);
|
|
||||||
const manualLaborTotal = productLaborList.value.reduce((sum, item) => {
|
const auxiliarySubtotal = computed(() => {
|
||||||
|
return auxiliaryMaterials.value.reduce((sum, item) => sum + item.subtotal, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
const laborSubtotal = computed(() => {
|
||||||
|
return productLaborList.value.reduce((sum, item) => {
|
||||||
const price = item && item.laborPrice !== undefined && item.laborPrice !== null ? Number(item.laborPrice) : 0;
|
const price = item && item.laborPrice !== undefined && item.laborPrice !== null ? Number(item.laborPrice) : 0;
|
||||||
return sum + (Number.isFinite(price) ? price : 0);
|
return sum + (Number.isFinite(price) ? price : 0);
|
||||||
}, 0);
|
}, 0);
|
||||||
return mainTotal + auxiliaryTotal + manualLaborTotal;
|
});
|
||||||
|
|
||||||
|
// 计算总金额
|
||||||
|
const totalAmount = computed(() => {
|
||||||
|
return mainSubtotal.value + auxiliarySubtotal.value + laborSubtotal.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
const isOssIdList = (val) => {
|
const isOssIdList = (val) => {
|
||||||
@@ -378,6 +395,9 @@ function downloadPdf(pdf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
if (String(route.query?.tab || '') === 'pdf') {
|
||||||
|
mediaTab.value = 'pdf';
|
||||||
|
}
|
||||||
getProductDetail();
|
getProductDetail();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -505,10 +525,29 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.total-badge {
|
.total-badge {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-end;
|
||||||
|
gap: 4px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #f56c6c;
|
color: #f56c6c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.total-main {
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.total-breakdown {
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 18px;
|
||||||
|
color: var(--el-text-color-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sep {
|
||||||
|
margin: 0 6px;
|
||||||
|
}
|
||||||
|
|
||||||
.cost-section {
|
.cost-section {
|
||||||
margin-top: 14px;
|
margin-top: 14px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,10 @@
|
|||||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete">删除</el-button>
|
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete">删除</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="warning" plain icon="Download" @click="handleExport">导出</el-button>
|
<el-button type="info" plain icon="Upload" @click="openImport">导入</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.8">
|
||||||
|
<el-button plain icon="Download" @click="downloadTemplate">导入模板</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
@@ -44,6 +47,30 @@
|
|||||||
{{ formatDecimal(scope.row.unitPrice) }}
|
{{ formatDecimal(scope.row.unitPrice) }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column label="附加属性" align="center" min-width="160">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-tooltip
|
||||||
|
placement="top"
|
||||||
|
:disabled="!hasAdditions(scope.row)"
|
||||||
|
@show="ensureAdditionsLoaded(scope.row)"
|
||||||
|
>
|
||||||
|
<template #content>
|
||||||
|
<div class="addition-tooltip">
|
||||||
|
<div
|
||||||
|
v-for="(it, idx) in getAdditions(scope.row)"
|
||||||
|
:key="it.addId || it.attrName || idx"
|
||||||
|
class="addition-tooltip-item"
|
||||||
|
>
|
||||||
|
{{ it.attrName }}:{{ it.attrValue || '-' }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<span class="addition-first">
|
||||||
|
{{ firstAdditionText(scope.row) }}
|
||||||
|
</span>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
</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">
|
<el-table-column label="产品图片" align="center" prop="productImages">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
@@ -55,7 +82,7 @@
|
|||||||
:preview-src-list="scope.row.productImages.split(',')"
|
:preview-src-list="scope.row.productImages.split(',')"
|
||||||
:z-index="9999"
|
:z-index="9999"
|
||||||
:preview-teleported="true"
|
:preview-teleported="true"
|
||||||
style="width: 40px; height: 40px; margin-right: 8px;"
|
style="width: 32px; height: 32px;"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<span v-else>无</span>
|
<span v-else>无</span>
|
||||||
@@ -64,13 +91,28 @@
|
|||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="320" fixed="right">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="320" fixed="right">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<div class="product-op-actions">
|
<div class="product-op-actions">
|
||||||
|
<div class="op-row">
|
||||||
<el-button link type="primary" icon="View" @click="handleDetail(scope.row)">详情</el-button>
|
<el-button link type="primary" icon="View" @click="handleDetail(scope.row)">详情</el-button>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
icon="Document"
|
||||||
|
:disabled="pdfCount(scope.row) === 0"
|
||||||
|
@click="handleManual(scope.row)"
|
||||||
|
>
|
||||||
|
说明书({{ pdfCount(scope.row) }})
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
<div class="op-row">
|
||||||
|
<el-button link type="primary" icon="Money" @click="handleLabor(scope.row)">工价</el-button>
|
||||||
|
<el-button link type="primary" icon="Setting" @click="handleAddition(scope.row)">附加属性</el-button>
|
||||||
|
</div>
|
||||||
|
<div class="op-row op-row-main">
|
||||||
<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="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="Setting" @click="handleAddition(scope.row)">附加属性</el-button>
|
|
||||||
<el-button link type="primary" icon="Money" @click="handleLabor(scope.row)">工价</el-button>
|
|
||||||
<el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
|
<el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@@ -207,6 +249,64 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
<el-dialog title="产品说明书预览" v-model="manualOpen" width="1200px" append-to-body>
|
||||||
|
<div class="manual-preview-wrap" v-loading="manualLoading">
|
||||||
|
<div class="manual-list">
|
||||||
|
<div class="manual-list-title">说明书列表({{ manualFiles.length }})</div>
|
||||||
|
<el-empty v-if="!manualFiles.length" description="暂无说明书" />
|
||||||
|
<el-scrollbar v-else max-height="420px">
|
||||||
|
<div
|
||||||
|
v-for="(item, index) in manualFiles"
|
||||||
|
:key="item.ossId || item.url || index"
|
||||||
|
class="manual-item"
|
||||||
|
:class="{ active: item.url === currentManualUrl }"
|
||||||
|
@click="selectManual(item)"
|
||||||
|
>
|
||||||
|
{{ item.name }}
|
||||||
|
</div>
|
||||||
|
</el-scrollbar>
|
||||||
|
</div>
|
||||||
|
<div class="manual-viewer">
|
||||||
|
<el-empty v-if="!currentManualUrl" description="请选择说明书" />
|
||||||
|
<iframe v-else :src="currentManualUrl" class="manual-iframe" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<template #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button @click="manualOpen = false">关闭</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
<el-dialog title="导入产品" v-model="importOpen" width="520px" append-to-body>
|
||||||
|
<el-form label-width="140px">
|
||||||
|
<el-form-item label="更新已存在数据">
|
||||||
|
<el-switch v-model="updateSupport" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="选择Excel文件">
|
||||||
|
<el-upload
|
||||||
|
ref="uploadRef"
|
||||||
|
:auto-upload="false"
|
||||||
|
:limit="1"
|
||||||
|
accept=".xlsx,.xls"
|
||||||
|
:on-change="handleImportFileChange"
|
||||||
|
:on-remove="handleImportFileRemove"
|
||||||
|
>
|
||||||
|
<el-button type="primary">选择文件</el-button>
|
||||||
|
<template #tip>
|
||||||
|
<div class="el-upload__tip">仅支持 .xls/.xlsx 文件</div>
|
||||||
|
</template>
|
||||||
|
</el-upload>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button :loading="importLoading" type="primary" @click="submitImport">导 入</el-button>
|
||||||
|
<el-button @click="importOpen = false">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
<!-- 将这个表格改为始终吸底,且外层容器可以拖拽调节高度 -->
|
<!-- 将这个表格改为始终吸底,且外层容器可以拖拽调节高度 -->
|
||||||
<!-- <StickyDragContainer v-if="currentProduct.productId" :parent-ref="appContainer"> -->
|
<!-- <StickyDragContainer v-if="currentProduct.productId" :parent-ref="appContainer"> -->
|
||||||
<div v-if="currentProduct.productId">
|
<div v-if="currentProduct.productId">
|
||||||
@@ -237,10 +337,10 @@
|
|||||||
<script setup name="Product">
|
<script setup name="Product">
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { listProduct, getProduct, delProduct, addProduct, updateProduct } from "@/api/mat/product";
|
import { listProductBase, getProduct, delProduct, addProduct, updateProduct, importProductData } from "@/api/mat/product";
|
||||||
import { listProductMaterialRelation } from "@/api/mat/productMaterialRelation";
|
import { listProductMaterialRelation } from "@/api/mat/productMaterialRelation";
|
||||||
import { getMaterial } from "@/api/mat/material";
|
import { getMaterial } from "@/api/mat/material";
|
||||||
import { listProductAddition, batchSaveProductAddition } from "@/api/mat/productAddition";
|
import { listProductAddition, listProductAdditionByProductIds, batchSaveProductAddition } from "@/api/mat/productAddition";
|
||||||
import { listProductLabor, batchSaveProductLabor } from "@/api/mat/productLabor";
|
import { listProductLabor, batchSaveProductLabor } from "@/api/mat/productLabor";
|
||||||
import { listByIds, listOss } from "@/api/system/oss";
|
import { listByIds, listOss } from "@/api/system/oss";
|
||||||
import bom from "@/views/mat/components/bom.vue";
|
import bom from "@/views/mat/components/bom.vue";
|
||||||
@@ -272,6 +372,16 @@ const appContainer = ref(null);
|
|||||||
const imageFileList = ref([]);
|
const imageFileList = ref([]);
|
||||||
const pdfFileList = ref([]);
|
const pdfFileList = ref([]);
|
||||||
const pdfUseOssId = ref(true);
|
const pdfUseOssId = ref(true);
|
||||||
|
const importOpen = ref(false);
|
||||||
|
const importLoading = ref(false);
|
||||||
|
const updateSupport = ref(false);
|
||||||
|
const importFile = ref(null);
|
||||||
|
const additionPreviewMap = ref({});
|
||||||
|
const additionPreviewLoading = ref({});
|
||||||
|
const manualOpen = ref(false);
|
||||||
|
const manualLoading = ref(false);
|
||||||
|
const manualFiles = ref([]);
|
||||||
|
const currentManualUrl = ref('');
|
||||||
const additionList = ref([]);
|
const additionList = ref([]);
|
||||||
const laborList = ref([]);
|
const laborList = ref([]);
|
||||||
const uploadUrl = ref(import.meta.env.VITE_APP_BASE_API + '/system/oss/upload');
|
const uploadUrl = ref(import.meta.env.VITE_APP_BASE_API + '/system/oss/upload');
|
||||||
@@ -325,9 +435,10 @@ const { queryParams, form, rules } = toRefs(data);
|
|||||||
/** 查询产品基础信息列表 */
|
/** 查询产品基础信息列表 */
|
||||||
function getList() {
|
function getList() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
listProduct(queryParams.value).then(response => {
|
listProductBase(queryParams.value).then(response => {
|
||||||
productList.value = response.rows;
|
productList.value = response.rows;
|
||||||
total.value = response.total;
|
total.value = response.total;
|
||||||
|
prefetchAdditions(productList.value);
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -644,7 +755,31 @@ function handleExport() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleRowClick(row) {
|
function handleRowClick(row) {
|
||||||
currentProduct.value = row;
|
currentProduct.value = { ...row, materials: [] };
|
||||||
|
loadCurrentProductMaterials(row?.productId);
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadCurrentProductMaterials(productId) {
|
||||||
|
if (!productId) return;
|
||||||
|
listProductMaterialRelation({ productId, pageNum: 1, pageSize: 1000 }).then(res => {
|
||||||
|
const relations = res?.rows || [];
|
||||||
|
return Promise.all(relations.map(r =>
|
||||||
|
getMaterial(r.materialId).then(materialRes => ({
|
||||||
|
...(materialRes && materialRes.data ? materialRes.data : {}),
|
||||||
|
...r
|
||||||
|
}))
|
||||||
|
));
|
||||||
|
}).then(items => {
|
||||||
|
currentProduct.value = {
|
||||||
|
...currentProduct.value,
|
||||||
|
materials: items || []
|
||||||
|
};
|
||||||
|
}).catch(() => {
|
||||||
|
currentProduct.value = {
|
||||||
|
...currentProduct.value,
|
||||||
|
materials: []
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDetail(row) {
|
function handleDetail(row) {
|
||||||
@@ -652,6 +787,154 @@ function handleDetail(row) {
|
|||||||
router.push(`/mat/product/detail/${row.productId}`);
|
router.push(`/mat/product/detail/${row.productId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function additionsKey(row) {
|
||||||
|
return row?.productId ? String(row.productId) : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAdditions(row) {
|
||||||
|
const key = additionsKey(row);
|
||||||
|
return (key && additionPreviewMap.value[key]) ? additionPreviewMap.value[key] : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasAdditions(row) {
|
||||||
|
const list = getAdditions(row);
|
||||||
|
return Array.isArray(list) && list.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function firstAdditionText(row) {
|
||||||
|
const list = getAdditions(row);
|
||||||
|
if (!list.length) return '-';
|
||||||
|
const first = list[0];
|
||||||
|
const name = first?.attrName || '-';
|
||||||
|
const value = first?.attrValue || '-';
|
||||||
|
return `${name}:${value}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ensureAdditionsLoaded(row) {
|
||||||
|
const key = additionsKey(row);
|
||||||
|
if (!key) return;
|
||||||
|
if (Object.prototype.hasOwnProperty.call(additionPreviewMap.value, key)) return;
|
||||||
|
if (additionPreviewLoading.value[key]) return;
|
||||||
|
additionPreviewLoading.value = { ...additionPreviewLoading.value, [key]: true };
|
||||||
|
listProductAddition({ productId: row.productId }).then(res => {
|
||||||
|
const rows = res?.rows || [];
|
||||||
|
additionPreviewMap.value = { ...additionPreviewMap.value, [key]: rows };
|
||||||
|
}).catch(() => {
|
||||||
|
additionPreviewMap.value = { ...additionPreviewMap.value, [key]: [] };
|
||||||
|
}).finally(() => {
|
||||||
|
additionPreviewLoading.value = { ...additionPreviewLoading.value, [key]: false };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function prefetchAdditions(list) {
|
||||||
|
const rows = Array.isArray(list) ? list : [];
|
||||||
|
const productIds = rows.map(r => r?.productId).filter(Boolean);
|
||||||
|
if (!productIds.length) return;
|
||||||
|
listProductAdditionByProductIds(productIds).then(res => {
|
||||||
|
const data = res?.data || {};
|
||||||
|
const next = { ...additionPreviewMap.value };
|
||||||
|
for (const id of productIds) {
|
||||||
|
const key = String(id);
|
||||||
|
if (next[key]) continue;
|
||||||
|
next[key] = data[id] || [];
|
||||||
|
}
|
||||||
|
additionPreviewMap.value = next;
|
||||||
|
}).catch(() => {});
|
||||||
|
}
|
||||||
|
|
||||||
|
function pdfCount(row) {
|
||||||
|
const raw = String(row?.productPdfs || '').trim();
|
||||||
|
if (!raw) return 0;
|
||||||
|
return raw.split(',').map(s => String(s).trim()).filter(Boolean).length;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleManual(row) {
|
||||||
|
manualOpen.value = true;
|
||||||
|
manualLoading.value = true;
|
||||||
|
currentManualUrl.value = '';
|
||||||
|
resolveManualFiles(row).then((files) => {
|
||||||
|
manualFiles.value = files;
|
||||||
|
if (files.length > 0) {
|
||||||
|
currentManualUrl.value = files[0].url;
|
||||||
|
}
|
||||||
|
}).finally(() => {
|
||||||
|
manualLoading.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function openImport() {
|
||||||
|
importOpen.value = true;
|
||||||
|
importFile.value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleImportFileChange(file) {
|
||||||
|
importFile.value = file?.raw || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleImportFileRemove() {
|
||||||
|
importFile.value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitImport() {
|
||||||
|
if (!importFile.value) {
|
||||||
|
proxy.$modal.msgError('请先选择导入文件');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
importLoading.value = true;
|
||||||
|
try {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('file', importFile.value);
|
||||||
|
const res = await importProductData(formData, updateSupport.value);
|
||||||
|
if (res.code === 200) {
|
||||||
|
proxy.$modal.msgSuccess(res.msg || res.data || '导入成功');
|
||||||
|
importOpen.value = false;
|
||||||
|
getList();
|
||||||
|
} else {
|
||||||
|
proxy.$modal.msgError(res.msg || '导入失败');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
proxy.$modal.msgError('导入失败');
|
||||||
|
} finally {
|
||||||
|
importLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function downloadTemplate() {
|
||||||
|
proxy.download('mat/product/importTemplate', {}, `product_template_${new Date().getTime()}.xlsx`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectManual(item) {
|
||||||
|
currentManualUrl.value = item?.url || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
async function resolveManualFiles(row) {
|
||||||
|
const raw = String(row?.productPdfs || '').trim();
|
||||||
|
if (!raw) return [];
|
||||||
|
if (isOssIdList(raw)) {
|
||||||
|
const res = await listByIds(raw).catch(() => null);
|
||||||
|
const list = res?.data || [];
|
||||||
|
return list.map((oss) => ({
|
||||||
|
name: oss.originalName || oss.fileName || String(oss.ossId),
|
||||||
|
url: oss.url,
|
||||||
|
ossId: oss.ossId
|
||||||
|
})).filter(item => item.url);
|
||||||
|
}
|
||||||
|
const urls = raw.split(',').map(s => String(s).trim()).filter(Boolean);
|
||||||
|
const rows = await Promise.all(urls.map((url) =>
|
||||||
|
listOss({ url, pageNum: 1, pageSize: 1 })
|
||||||
|
.then(r => (r && r.rows && r.rows[0]) ? r.rows[0] : null)
|
||||||
|
.catch(() => null)
|
||||||
|
));
|
||||||
|
return urls.map((url, index) => {
|
||||||
|
const file = rows[index];
|
||||||
|
return {
|
||||||
|
name: (file && (file.originalName || file.fileName)) || getFileNameFromUrl(url),
|
||||||
|
url: (file && file.url) || url,
|
||||||
|
ossId: file && file.ossId
|
||||||
|
};
|
||||||
|
}).filter(item => item.url);
|
||||||
|
}
|
||||||
|
|
||||||
function handleAddition(row) {
|
function handleAddition(row) {
|
||||||
currentProductId.value = row.productId;
|
currentProductId.value = row.productId;
|
||||||
// 清空附加属性列表
|
// 清空附加属性列表
|
||||||
@@ -761,6 +1044,23 @@ getList();
|
|||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.image-preview {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-table .el-table__cell) {
|
||||||
|
padding-top: 8px;
|
||||||
|
padding-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-table .cell) {
|
||||||
|
padding-left: 8px;
|
||||||
|
padding-right: 8px;
|
||||||
|
line-height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
/* 图片预览层样式 */
|
/* 图片预览层样式 */
|
||||||
:deep(.el-image-viewer__wrapper) {
|
:deep(.el-image-viewer__wrapper) {
|
||||||
z-index: 9999 !important;
|
z-index: 9999 !important;
|
||||||
@@ -768,12 +1068,90 @@ getList();
|
|||||||
|
|
||||||
.product-op-actions {
|
.product-op-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
gap: 4px 10px;
|
gap: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.product-op-actions .el-button + .el-button) {
|
:deep(.product-op-actions .el-button + .el-button) {
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.op-row {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 10px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.op-row-main {
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addition-first {
|
||||||
|
display: inline-block;
|
||||||
|
max-width: 140px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addition-tooltip {
|
||||||
|
max-width: 380px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addition-tooltip-item {
|
||||||
|
line-height: 20px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.manual-preview-wrap {
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
min-height: 620px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.manual-list {
|
||||||
|
width: 260px;
|
||||||
|
border: 1px solid var(--el-border-color-light);
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.manual-list-title {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.manual-item {
|
||||||
|
padding: 8px 10px;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
line-height: 18px;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.manual-item:hover {
|
||||||
|
background-color: var(--el-fill-color-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.manual-item.active {
|
||||||
|
color: var(--el-color-primary);
|
||||||
|
background-color: var(--el-color-primary-light-9);
|
||||||
|
}
|
||||||
|
|
||||||
|
.manual-viewer {
|
||||||
|
flex: 1;
|
||||||
|
border: 1px solid var(--el-border-color-light);
|
||||||
|
border-radius: 6px;
|
||||||
|
overflow: hidden;
|
||||||
|
min-height: 620px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.manual-iframe {
|
||||||
|
width: 100%;
|
||||||
|
height: 620px;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<el-form-item label="员工姓名" prop="empName">
|
<el-form-item label="员工姓名" prop="empName">
|
||||||
<el-input v-model="queryParams.empName" placeholder="请输入员工姓名" clearable @keyup.enter="handleQuery" />
|
<el-input v-model="queryParams.empName" placeholder="请输入员工姓名" clearable @keyup.enter="handleQuery" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="计费类型" prop="billingType">
|
<el-form-item v-if="!simpleMode" label="计费类型" prop="billingType">
|
||||||
<el-select v-model="queryParams.billingType" placeholder="请选择计费类型" clearable style="width: 180px">
|
<el-select v-model="queryParams.billingType" placeholder="请选择计费类型" clearable style="width: 180px">
|
||||||
<el-option label="小时工" value="1" />
|
<el-option label="小时工" value="1" />
|
||||||
<el-option label="计件工" value="2" />
|
<el-option label="计件工" value="2" />
|
||||||
@@ -37,15 +37,15 @@
|
|||||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" />
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" />
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="wageEntryDetailList">
|
<el-table v-loading="loading" :data="wageEntryDetailList" style="width: 100%">
|
||||||
<el-table-column label="业务日期" align="center" prop="entryDate" width="120" />
|
<el-table-column label="业务日期" align="center" prop="entryDate" width="130" />
|
||||||
<el-table-column label="员工姓名" align="center" prop="empName" width="120" />
|
<el-table-column label="员工姓名" align="center" prop="empName" width="140" />
|
||||||
<el-table-column label="计费类型" align="center" prop="billingType" width="100">
|
<el-table-column v-if="!simpleMode" label="计费类型" align="center" prop="billingType" width="100">
|
||||||
<template #default="scope">{{ formatBillingType(scope.row.billingType) }}</template>
|
<template #default="scope">{{ formatBillingType(scope.row.billingType) }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="工种" align="center" prop="workTypeName" min-width="140" />
|
<el-table-column v-if="!simpleMode" label="工种" align="center" prop="workTypeName" min-width="160" />
|
||||||
|
|
||||||
<el-table-column label="工作时间/加工数量" align="center" min-width="170">
|
<el-table-column v-if="!simpleMode" label="工作时间/加工数量" align="center" min-width="170">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="scope.row.workload"
|
v-model="scope.row.workload"
|
||||||
@@ -55,34 +55,49 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column label="单价" align="center" min-width="150">
|
<el-table-column v-if="!simpleMode" label="单价" align="center" min-width="150">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-input v-if="scope.row.billingType === '2'" v-model="scope.row.unitPrice" placeholder="多少钱/件" @input="recalcRowAmount(scope.row)" />
|
<el-input v-if="scope.row.billingType === '2'" v-model="scope.row.unitPrice" placeholder="多少钱/件" @input="recalcRowAmount(scope.row)" />
|
||||||
<span v-else>{{ formatUnitPrice(scope.row) }}</span>
|
<span v-else>{{ formatUnitPrice(scope.row) }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column label="奖惩金额" align="center" min-width="130">
|
<el-table-column v-if="!simpleMode" label="奖惩金额" align="center" min-width="130">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-input v-model="scope.row.extraAmount" placeholder="奖惩金额(负数为惩罚)" @input="recalcRowAmount(scope.row)" />
|
<el-input v-model="scope.row.extraAmount" placeholder="奖惩金额(负数为惩罚)" @input="recalcRowAmount(scope.row)" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column label="奖惩原因" align="center" min-width="180">
|
<el-table-column v-if="!simpleMode" label="奖惩原因" align="center" min-width="180">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-input v-model="scope.row.extraReason" placeholder="奖惩原因" />
|
<el-input v-model="scope.row.extraReason" placeholder="奖惩原因" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column label="明细金额" align="center" prop="calcAmount" width="110">
|
<el-table-column v-if="!simpleMode" label="明细金额" align="center" prop="calcAmount" width="110">
|
||||||
<template #default="scope">{{ round2(toNumber(scope.row.calcAmount)) }}</template>
|
<template #default="scope">{{ round2(toNumber(scope.row.calcAmount)) }}</template>
|
||||||
</el-table-column>
|
</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" min-width="120">
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="220">
|
<template #default="scope">
|
||||||
|
<el-input v-model="scope.row.dailyWage" placeholder="请输入每天工资" @input="applyDailyWage(scope.row)" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column label="当天金额" align="center" min-width="150">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-input :model-value="round2(toNumber(scope.row.totalAmount))" disabled />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column label="累计金额" align="center" min-width="150">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-input :model-value="round2(toNumber(scope.row.cumulativeAmount))" disabled />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" min-width="140">
|
||||||
<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>
|
||||||
<el-button link type="primary" icon="Document" @click="openCalcDialog(scope.row)">明细</el-button>
|
|
||||||
<el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
|
<el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -90,7 +105,7 @@
|
|||||||
|
|
||||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||||
|
|
||||||
<el-dialog v-model="calcOpen" title="明细计算" width="720px" append-to-body>
|
<el-dialog v-if="!simpleMode" v-model="calcOpen" title="明细计算" width="720px" append-to-body>
|
||||||
<div class="calc-toolbar">
|
<div class="calc-toolbar">
|
||||||
<el-button size="small" type="primary" plain icon="Plus" @click="addCalcLine">新增一行</el-button>
|
<el-button size="small" type="primary" plain icon="Plus" @click="addCalcLine">新增一行</el-button>
|
||||||
<div class="calc-sum">合计:{{ calcTotal }} 元</div>
|
<div class="calc-sum">合计:{{ calcTotal }} 元</div>
|
||||||
@@ -135,6 +150,7 @@ const wageEntryDetailList = ref([])
|
|||||||
const loading = ref(true)
|
const loading = ref(true)
|
||||||
const showSearch = ref(true)
|
const showSearch = ref(true)
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
|
const simpleMode = ref(true)
|
||||||
|
|
||||||
// 存储累计金额数据
|
// 存储累计金额数据
|
||||||
const cumulativeAmounts = ref({})
|
const cumulativeAmounts = ref({})
|
||||||
@@ -161,7 +177,7 @@ const data = reactive({
|
|||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 100,
|
pageSize: 100,
|
||||||
entryDate: proxy.parseTime(new Date(), '{y}-{m}-{d}'),
|
entryDate: proxy.parseTime(new Date(Date.now() - 24 * 60 * 60 * 1000), '{y}-{m}-{d}'),
|
||||||
empName: undefined,
|
empName: undefined,
|
||||||
billingType: undefined,
|
billingType: undefined,
|
||||||
isMakeup: '0'
|
isMakeup: '0'
|
||||||
@@ -269,12 +285,26 @@ function saveCalcToRow() {
|
|||||||
row.calcAmount = calcTotal.value
|
row.calcAmount = calcTotal.value
|
||||||
row.calcDetail = JSON.stringify({ v: 1, items: normalizedItems })
|
row.calcDetail = JSON.stringify({ v: 1, items: normalizedItems })
|
||||||
recalcRowAmount(row)
|
recalcRowAmount(row)
|
||||||
|
row.dailyWage = normalizeEditableValue(row.totalAmount)
|
||||||
calcOpen.value = false
|
calcOpen.value = false
|
||||||
proxy.$modal.msgSuccess('明细已保存,请点击该行“保存”提交')
|
proxy.$modal.msgSuccess('明细已保存,请点击该行“保存”提交')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applyDailyWage(row) {
|
||||||
|
const desired = toNumber(row.dailyWage)
|
||||||
|
const rawWorkload = toNumber(row.workload)
|
||||||
|
const workload = (row.billingType === '1' || row.billingType === '3') && rawWorkload <= 0 ? 1 : rawWorkload
|
||||||
|
const unitPrice = toNumber(row.unitPrice)
|
||||||
|
const calcAmount = toNumber(row.calcAmount)
|
||||||
|
const baseAmount = round2(workload * unitPrice)
|
||||||
|
const extraAmount = round2(desired - baseAmount - calcAmount)
|
||||||
|
row.extraAmount = extraAmount
|
||||||
|
recalcRowAmount(row)
|
||||||
|
}
|
||||||
|
|
||||||
function recalcRowAmount(row) {
|
function recalcRowAmount(row) {
|
||||||
const workload = toNumber(row.workload)
|
const rawWorkload = toNumber(row.workload)
|
||||||
|
const workload = (row.billingType === '1' || row.billingType === '3') && rawWorkload <= 0 ? 1 : rawWorkload
|
||||||
const unitPrice = row.billingType === '2' ? toNumber(row.unitPrice) : toNumber(row.unitPrice)
|
const unitPrice = row.billingType === '2' ? toNumber(row.unitPrice) : toNumber(row.unitPrice)
|
||||||
const extraAmount = toNumber(row.extraAmount)
|
const extraAmount = toNumber(row.extraAmount)
|
||||||
const calcAmount = toNumber(row.calcAmount)
|
const calcAmount = toNumber(row.calcAmount)
|
||||||
@@ -319,6 +349,7 @@ function getList() {
|
|||||||
extraAmount: normalizeEditableValue(row.extraAmount),
|
extraAmount: normalizeEditableValue(row.extraAmount),
|
||||||
calcAmount: row.calcAmount ?? 0,
|
calcAmount: row.calcAmount ?? 0,
|
||||||
calcDetail: row.calcDetail,
|
calcDetail: row.calcDetail,
|
||||||
|
dailyWage: normalizeEditableValue(row.totalAmount),
|
||||||
cumulativeAmount: cumulativeAmounts.value[row.empName] || 0
|
cumulativeAmount: cumulativeAmounts.value[row.empName] || 0
|
||||||
}
|
}
|
||||||
recalcRowAmount(r)
|
recalcRowAmount(r)
|
||||||
@@ -337,7 +368,7 @@ function handleQuery() {
|
|||||||
|
|
||||||
function resetQuery() {
|
function resetQuery() {
|
||||||
proxy.resetForm('queryRef')
|
proxy.resetForm('queryRef')
|
||||||
queryParams.value.entryDate = proxy.parseTime(new Date(), '{y}-{m}-{d}')
|
queryParams.value.entryDate = proxy.parseTime(new Date(Date.now() - 24 * 60 * 60 * 1000), '{y}-{m}-{d}')
|
||||||
queryParams.value.isMakeup = '0'
|
queryParams.value.isMakeup = '0'
|
||||||
handleQuery()
|
handleQuery()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,25 +30,30 @@
|
|||||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" />
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" />
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="list">
|
<el-table v-loading="loading" :data="list" style="width: 100%">
|
||||||
<el-table-column label="业务日期" align="center" prop="entryDate" width="120" />
|
<el-table-column label="业务日期" align="center" prop="entryDate" width="130" />
|
||||||
<el-table-column label="员工姓名" align="center" prop="empName" width="120" />
|
<el-table-column label="员工姓名" align="center" prop="empName" width="140" />
|
||||||
<el-table-column label="计费类型" align="center" prop="billingType" width="100">
|
<el-table-column v-if="!simpleMode" label="计费类型" align="center" prop="billingType" width="100">
|
||||||
<template #default="scope">{{ formatBillingType(scope.row.billingType) }}</template>
|
<template #default="scope">{{ formatBillingType(scope.row.billingType) }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="工种" align="center" prop="workTypeName" min-width="140" />
|
<el-table-column v-if="!simpleMode" label="工种" align="center" prop="workTypeName" min-width="140" />
|
||||||
<el-table-column label="工作时间/加工数量" align="center" prop="workload" width="140" />
|
<el-table-column label="每天工资" align="center" min-width="120">
|
||||||
<el-table-column label="单价" align="center" prop="unitPrice" width="110" />
|
<template #default="scope">{{ formatAmount(scope.row.totalAmount) }}</template>
|
||||||
<el-table-column label="奖惩金额" align="center" prop="extraAmount" width="130" />
|
</el-table-column>
|
||||||
<el-table-column label="奖惩原因" align="center" prop="extraReason" min-width="160" :show-overflow-tooltip="true" />
|
<el-table-column label="当天金额" align="center" min-width="150">
|
||||||
|
<template #default="scope">{{ formatAmount(scope.row.totalAmount) }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="累计金额" align="center" min-width="150">
|
||||||
|
<template #default="scope">{{ formatAmount(scope.row.cumulativeAmount) }}</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="补录状态" align="center" prop="isMakeup" width="100">
|
<el-table-column label="补录状态" align="center" prop="isMakeup" width="100">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-tag :type="scope.row.isMakeup === '1' ? 'warning' : 'info'">{{ scope.row.isMakeup === '1' ? '已补录' : '未补录' }}</el-tag>
|
<el-tag :type="scope.row.isMakeup === '1' ? 'warning' : 'info'">{{ scope.row.isMakeup === '1' ? '已补录' : '未补录' }}</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="补录责任人" align="center" prop="makeupResponsible" width="120" />
|
<el-table-column v-if="!simpleMode" label="补录责任人" align="center" prop="makeupResponsible" width="120" />
|
||||||
<el-table-column label="补录原因" align="center" prop="makeupReason" min-width="180" :show-overflow-tooltip="true" />
|
<el-table-column v-if="!simpleMode" label="补录原因" align="center" prop="makeupReason" min-width="180" :show-overflow-tooltip="true" />
|
||||||
<el-table-column label="操作" align="center" width="220">
|
<el-table-column label="操作" align="center" min-width="140">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button link type="primary" icon="Edit" @click="handleMakeup(scope.row)">补录</el-button>
|
<el-button link type="primary" icon="Edit" @click="handleMakeup(scope.row)">补录</el-button>
|
||||||
<el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
|
<el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
|
||||||
@@ -61,21 +66,10 @@
|
|||||||
<el-dialog :title="title" v-model="open" width="640px" append-to-body>
|
<el-dialog :title="title" v-model="open" width="640px" append-to-body>
|
||||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="110px">
|
<el-form ref="formRef" :model="form" :rules="rules" label-width="110px">
|
||||||
<el-form-item label="业务日期" prop="entryDate">
|
<el-form-item label="业务日期" prop="entryDate">
|
||||||
<el-date-picker clearable v-model="form.entryDate" type="date" value-format="YYYY-MM-DD" style="width: 100%" />
|
<el-date-picker clearable v-model="form.entryDate" type="date" value-format="YYYY-MM-DD" style="width: 100%" disabled />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="员工姓名" prop="empName"><el-input v-model="form.empName" /></el-form-item>
|
<el-form-item label="员工姓名" prop="empName"><el-input v-model="form.empName" disabled /></el-form-item>
|
||||||
<el-form-item label="计费类型" prop="billingType">
|
<el-form-item label="每天工资" prop="dailyWage"><el-input v-model="form.dailyWage" placeholder="请输入每天工资" /></el-form-item>
|
||||||
<el-select v-model="form.billingType" style="width: 100%">
|
|
||||||
<el-option label="小时工" value="1" />
|
|
||||||
<el-option label="计件工" value="2" />
|
|
||||||
<el-option label="天工" value="3" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="工种" prop="workTypeName"><el-input v-model="form.workTypeName" /></el-form-item>
|
|
||||||
<el-form-item :label="form.billingType === '2' ? '加工数量' : '工作时间'" prop="workload"><el-input v-model="form.workload" /></el-form-item>
|
|
||||||
<el-form-item label="单价" prop="unitPrice" v-if="form.billingType === '2'"><el-input v-model="form.unitPrice" placeholder="元/件" /></el-form-item>
|
|
||||||
<el-form-item label="奖惩金额" prop="extraAmount"><el-input v-model="form.extraAmount" placeholder="负数为惩罚金额" /></el-form-item>
|
|
||||||
<el-form-item label="奖惩原因" prop="extraReason"><el-input v-model="form.extraReason" placeholder="请输入奖惩原因" /></el-form-item>
|
|
||||||
<el-form-item label="补录原因" prop="makeupReason"><el-input type="textarea" v-model="form.makeupReason" /></el-form-item>
|
<el-form-item label="补录原因" prop="makeupReason"><el-input type="textarea" v-model="form.makeupReason" /></el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
@@ -102,6 +96,7 @@ const showSearch = ref(true)
|
|||||||
const open = ref(false)
|
const open = ref(false)
|
||||||
const title = ref('')
|
const title = ref('')
|
||||||
const buttonLoading = ref(false)
|
const buttonLoading = ref(false)
|
||||||
|
const simpleMode = ref(true)
|
||||||
|
|
||||||
// 存储累计金额数据
|
// 存储累计金额数据
|
||||||
const cumulativeAmounts = ref({})
|
const cumulativeAmounts = ref({})
|
||||||
@@ -129,16 +124,14 @@ const data = reactive({
|
|||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 50,
|
pageSize: 50,
|
||||||
entryDate: undefined,
|
entryDate: proxy.parseTime(new Date(Date.now() - 24 * 60 * 60 * 1000), '{y}-{m}-{d}'),
|
||||||
empName: undefined,
|
empName: undefined,
|
||||||
makeupView: 'all'
|
makeupView: 'all'
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
entryDate: [{ required: true, message: '业务日期不能为空', trigger: 'change' }],
|
entryDate: [{ required: true, message: '业务日期不能为空', trigger: 'change' }],
|
||||||
empId: [{ required: true, message: '员工ID不能为空', trigger: 'blur' }],
|
empId: [{ required: true, message: '员工ID不能为空', trigger: 'blur' }],
|
||||||
billingType: [{ required: true, message: '计费类型不能为空', trigger: 'change' }],
|
dailyWage: [{ required: true, message: '每天工资不能为空', trigger: 'blur' }],
|
||||||
rateId: [{ required: true, message: '费率ID不能为空', trigger: 'blur' }],
|
|
||||||
workload: [{ required: true, message: '工作量不能为空', trigger: 'blur' }],
|
|
||||||
makeupReason: [{ required: true, message: '补录原因不能为空', trigger: 'blur' }]
|
makeupReason: [{ required: true, message: '补录原因不能为空', trigger: 'blur' }]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -152,6 +145,25 @@ function formatBillingType(type) {
|
|||||||
return '-'
|
return '-'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toNumber(v) {
|
||||||
|
const n = Number(v)
|
||||||
|
return Number.isFinite(n) ? n : 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function round2(v) {
|
||||||
|
return Math.round(v * 100) / 100
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeEditableValue(v) {
|
||||||
|
if (v === null || v === undefined) return ''
|
||||||
|
if (String(v) === '0' || String(v) === '0.00') return ''
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatAmount(v) {
|
||||||
|
return round2(toNumber(v))
|
||||||
|
}
|
||||||
|
|
||||||
function buildQuery() {
|
function buildQuery() {
|
||||||
const q = {
|
const q = {
|
||||||
pageNum: queryParams.value.pageNum,
|
pageNum: queryParams.value.pageNum,
|
||||||
@@ -168,7 +180,11 @@ function buildQuery() {
|
|||||||
function getList() {
|
function getList() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
listWageEntryDetail(buildQuery()).then(res => {
|
listWageEntryDetail(buildQuery()).then(res => {
|
||||||
list.value = res.rows || []
|
const rows = res.rows || []
|
||||||
|
list.value = rows.map(r => ({
|
||||||
|
...r,
|
||||||
|
cumulativeAmount: cumulativeAmounts.value[r.empName] || 0
|
||||||
|
}))
|
||||||
total.value = res.total || 0
|
total.value = res.total || 0
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
@@ -203,7 +219,9 @@ function handleMakeup(row) {
|
|||||||
isMakeup: '1',
|
isMakeup: '1',
|
||||||
makeupResponsibleId: userStore.id || row.makeupResponsibleId || null,
|
makeupResponsibleId: userStore.id || row.makeupResponsibleId || null,
|
||||||
makeupResponsible: userStore.nickName || row.makeupResponsible || null,
|
makeupResponsible: userStore.nickName || row.makeupResponsible || null,
|
||||||
makeupReason: row.makeupReason || null
|
makeupReason: row.makeupReason || null,
|
||||||
|
dailyWage: normalizeEditableValue(row.totalAmount),
|
||||||
|
originalTotalAmount: toNumber(row.totalAmount)
|
||||||
}
|
}
|
||||||
title.value = '补录 补录负责人:'+form.value.makeupResponsible
|
title.value = '补录 补录负责人:'+form.value.makeupResponsible
|
||||||
open.value = true
|
open.value = true
|
||||||
@@ -213,22 +231,21 @@ function submitForm() {
|
|||||||
proxy.$refs.formRef.validate(valid => {
|
proxy.$refs.formRef.validate(valid => {
|
||||||
if (!valid) return
|
if (!valid) return
|
||||||
buttonLoading.value = true
|
buttonLoading.value = true
|
||||||
const payload = {
|
const payload = { ...form.value, isMakeup: '1' }
|
||||||
...form.value,
|
const desired = toNumber(payload.dailyWage)
|
||||||
isMakeup: '1'
|
const rawWorkload = toNumber(payload.workload)
|
||||||
}
|
const workload = (payload.billingType === '1' || payload.billingType === '3') && rawWorkload <= 0 ? 1 : rawWorkload
|
||||||
|
const unitPrice = toNumber(payload.unitPrice)
|
||||||
|
const calcAmount = toNumber(payload.calcAmount)
|
||||||
|
const baseAmount = round2(workload * unitPrice)
|
||||||
|
payload.extraAmount = round2(desired - baseAmount - calcAmount)
|
||||||
|
|
||||||
// 本页面补录语义:更新当前记录并标记为已补录
|
// 本页面补录语义:更新当前记录并标记为已补录
|
||||||
updateWageEntryDetail(payload).then(() => {
|
updateWageEntryDetail(payload).then(() => {
|
||||||
// 更新累计金额
|
const oldTotal = toNumber(payload.originalTotalAmount)
|
||||||
const workload = parseFloat(payload.workload) || 0
|
const nextTotal = toNumber(payload.totalAmount || desired)
|
||||||
const unitPrice = parseFloat(payload.unitPrice) || 0
|
const diff = nextTotal - oldTotal
|
||||||
const extraAmount = parseFloat(payload.extraAmount) || 0
|
cumulativeAmounts.value[payload.empName] = toNumber(cumulativeAmounts.value[payload.empName]) + diff
|
||||||
const totalAmount = workload * unitPrice + extraAmount
|
|
||||||
|
|
||||||
if (!cumulativeAmounts.value[payload.empName]) {
|
|
||||||
cumulativeAmounts.value[payload.empName] = 0
|
|
||||||
}
|
|
||||||
cumulativeAmounts.value[payload.empName] += totalAmount
|
|
||||||
saveCumulativeAmounts()
|
saveCumulativeAmounts()
|
||||||
|
|
||||||
proxy.$modal.msgSuccess('补录成功')
|
proxy.$modal.msgSuccess('补录成功')
|
||||||
@@ -254,7 +271,7 @@ function handleQuery() {
|
|||||||
|
|
||||||
function resetQuery() {
|
function resetQuery() {
|
||||||
proxy.resetForm('queryRef')
|
proxy.resetForm('queryRef')
|
||||||
queryParams.value.entryDate = undefined
|
queryParams.value.entryDate = proxy.parseTime(new Date(Date.now() - 24 * 60 * 60 * 1000), '{y}-{m}-{d}')
|
||||||
queryParams.value.makeupView = 'all'
|
queryParams.value.makeupView = 'all'
|
||||||
handleQuery()
|
handleQuery()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,27 +19,24 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
<div class="worker-toolbar mb8">
|
||||||
<el-col :span="1.5"><el-button size="small" type="primary" plain icon="Plus" @click="handleAdd">新增</el-button></el-col>
|
<el-button size="small" type="primary" plain icon="Plus" @click="handleAdd">新增</el-button>
|
||||||
<el-col :span="1.5"><el-button size="small" type="success" plain icon="Edit" :disabled="single" @click="handleUpdate">修改</el-button></el-col>
|
<el-button size="small" type="success" plain icon="Edit" :disabled="single" @click="handleUpdate">修改</el-button>
|
||||||
<el-col :span="1.5"><el-button size="small" type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete">删除</el-button></el-col>
|
<el-button size="small" type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete">删除</el-button>
|
||||||
<el-col :span="1.5"><el-button size="small" type="warning" plain icon="Download" @click="handleExport">导出</el-button></el-col>
|
<el-button size="small" type="warning" plain icon="Download" @click="handleExport">导出</el-button>
|
||||||
<el-col :span="1.5"><el-button size="small" type="info" plain icon="Upload" @click="openImport">导入</el-button></el-col>
|
<el-button size="small" type="info" plain icon="Upload" @click="openImport">导入</el-button>
|
||||||
<el-col :span="1.8"><el-button size="small" plain icon="Download" @click="downloadTemplate">下载模板</el-button></el-col>
|
<el-button size="small" plain icon="Download" @click="downloadTemplate">下载模板</el-button>
|
||||||
<el-col :span="2.2"><el-button size="small" type="primary" plain icon="User" @click="openUserSelectDialog">选择用户导入</el-button></el-col>
|
<el-button size="small" type="primary" plain icon="User" @click="openUserSelectDialog">选择用户导入</el-button>
|
||||||
|
<div class="toolbar-right">
|
||||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" />
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" />
|
||||||
</el-row>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="workerList" @selection-change="handleSelectionChange">
|
<el-table v-loading="loading" :data="workerList" @selection-change="handleSelectionChange">
|
||||||
<el-table-column type="selection" width="55" align="center" />
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
<el-table-column label="工号" align="center" prop="workerNo" width="140" />
|
<el-table-column label="工号" align="center" prop="workerNo" width="140" />
|
||||||
<el-table-column label="姓名" align="center" prop="workerName" width="120" />
|
<el-table-column label="姓名" align="center" prop="workerName" width="120" />
|
||||||
<el-table-column label="手机号" align="center" prop="phone" width="140" />
|
<el-table-column label="手机号" align="center" prop="phone" width="140" />
|
||||||
<el-table-column label="默认计费类型" align="center" prop="defaultBillingType" width="120">
|
|
||||||
<template #default="scope">{{ formatBillingType(scope.row.defaultBillingType) }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="默认工种" align="center" prop="defaultWorkTypeName" min-width="140" />
|
|
||||||
<el-table-column label="状态" align="center" prop="status" width="100">
|
<el-table-column label="状态" align="center" prop="status" width="100">
|
||||||
<template #default="scope"><el-tag :type="scope.row.status === '0' ? 'success' : 'info'">{{ scope.row.status === '0' ? '在职' : '离职' }}</el-tag></template>
|
<template #default="scope"><el-tag :type="scope.row.status === '0' ? 'success' : 'info'">{{ scope.row.status === '0' ? '在职' : '离职' }}</el-tag></template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -62,25 +59,6 @@
|
|||||||
<el-form-item label="姓名" prop="workerName"><el-input v-model="form.workerName" placeholder="请输入姓名" /></el-form-item>
|
<el-form-item label="姓名" prop="workerName"><el-input v-model="form.workerName" placeholder="请输入姓名" /></el-form-item>
|
||||||
<el-form-item label="手机号" prop="phone"><el-input v-model="form.phone" placeholder="请输入手机号" /></el-form-item>
|
<el-form-item label="手机号" prop="phone"><el-input v-model="form.phone" placeholder="请输入手机号" /></el-form-item>
|
||||||
|
|
||||||
<el-form-item label="默认工种" prop="selectedRateId">
|
|
||||||
<el-select v-model="form.selectedRateId" placeholder="请选择默认工种" style="width: 100%" clearable @change="handleRateChange">
|
|
||||||
<el-option
|
|
||||||
v-for="item in rateOptions"
|
|
||||||
:key="item.rateId"
|
|
||||||
:label="rateOptionLabel(item)"
|
|
||||||
:value="item.rateId"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item label="默认计费类型" prop="defaultBillingType">
|
|
||||||
<el-select v-model="form.defaultBillingType" placeholder="请选择" style="width: 100%" disabled>
|
|
||||||
<el-option label="小时工" value="1" />
|
|
||||||
<el-option label="计件工" value="2" />
|
|
||||||
<el-option label="天工" value="3" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-radio-group v-model="form.status">
|
<el-radio-group v-model="form.status">
|
||||||
<el-radio label="0">在职</el-radio>
|
<el-radio label="0">在职</el-radio>
|
||||||
@@ -208,8 +186,7 @@ const data = reactive({
|
|||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
workerNo: [{ required: true, message: '工号不能为空', trigger: 'blur' }],
|
workerNo: [{ required: true, message: '工号不能为空', trigger: 'blur' }],
|
||||||
workerName: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
|
workerName: [{ required: true, message: '姓名不能为空', trigger: 'blur' }]
|
||||||
selectedRateId: [{ required: true, message: '默认工种不能为空', trigger: 'change' }]
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -309,25 +286,19 @@ function handleSelectionChange(selection) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleAdd() {
|
function handleAdd() {
|
||||||
loadRateOptions().then(() => {
|
|
||||||
reset()
|
reset()
|
||||||
open.value = true
|
open.value = true
|
||||||
title.value = '新增工人'
|
title.value = '新增工人'
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleUpdate(row) {
|
function handleUpdate(row) {
|
||||||
const workerId = row?.workerId || ids.value[0]
|
const workerId = row?.workerId || ids.value[0]
|
||||||
if (!workerId) return
|
if (!workerId) return
|
||||||
Promise.all([loadRateOptions(), getWorker(workerId)]).then(([, response]) => {
|
getWorker(workerId).then((response) => {
|
||||||
form.value = {
|
form.value = {
|
||||||
...response.data,
|
...response.data,
|
||||||
selectedRateId: null
|
selectedRateId: null
|
||||||
}
|
}
|
||||||
const matched = rateOptions.value.find(i => i.rateName === form.value.defaultWorkTypeName && i.billingType === form.value.defaultBillingType)
|
|
||||||
if (matched) {
|
|
||||||
form.value.selectedRateId = matched.rateId
|
|
||||||
}
|
|
||||||
open.value = true
|
open.value = true
|
||||||
title.value = '修改工人'
|
title.value = '修改工人'
|
||||||
})
|
})
|
||||||
@@ -488,3 +459,21 @@ async function confirmImportSelectedUser() {
|
|||||||
}
|
}
|
||||||
getList()
|
getList()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.worker-toolbar {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbar-right {
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-table .el-table__cell) {
|
||||||
|
padding-top: 8px;
|
||||||
|
padding-bottom: 8px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user