Compare commits
6 Commits
897c690996
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e7a50bf64 | ||
|
|
3ae6403bd3 | ||
|
|
855dbbe099 | ||
| f41a17c885 | |||
|
|
6aa1d581e7 | ||
|
|
595b9fbd68 |
@@ -32,6 +32,10 @@ public class MatMaterial extends BaseEntity {
|
||||
* 配料名称
|
||||
*/
|
||||
private String materialName;
|
||||
/**
|
||||
* 物料类型:1=辅料,2=原料
|
||||
*/
|
||||
private Integer materialType;
|
||||
/**
|
||||
* 配料规格
|
||||
*/
|
||||
|
||||
@@ -54,4 +54,9 @@ public class MatProduct extends BaseEntity {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 产品图片,多个图片以逗号分隔
|
||||
*/
|
||||
private String productImages;
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,11 @@ public class MatMaterialBo extends BaseEntity {
|
||||
*/
|
||||
private String materialName;
|
||||
|
||||
/**
|
||||
* 物料类型:1=辅料,2=原料
|
||||
*/
|
||||
private Integer materialType;
|
||||
|
||||
/**
|
||||
* 配料规格
|
||||
*/
|
||||
|
||||
@@ -52,5 +52,10 @@ public class MatProductBo extends BaseEntity {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 产品图片,多个图片以逗号分隔
|
||||
*/
|
||||
private String productImages;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -34,6 +34,12 @@ public class MatMaterialVo {
|
||||
@ExcelProperty(value = "配料名称")
|
||||
private String materialName;
|
||||
|
||||
/**
|
||||
* 物料类型:1=辅料,2=原料
|
||||
*/
|
||||
@ExcelProperty(value = "物料类型")
|
||||
private Integer materialType;
|
||||
|
||||
/**
|
||||
* 配料规格
|
||||
*/
|
||||
|
||||
@@ -58,5 +58,11 @@ public class MatProductVo {
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 产品图片,多个图片以逗号分隔
|
||||
*/
|
||||
@ExcelProperty(value = "产品图片")
|
||||
private String productImages;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -57,6 +57,12 @@ public class MatProductWithMaterialsVo {
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 产品图片,多个图片以逗号分隔
|
||||
*/
|
||||
@ExcelProperty(value = "产品图片")
|
||||
private String productImages;
|
||||
|
||||
/**
|
||||
* 关联的配料信息列表
|
||||
*/
|
||||
@@ -81,4 +87,4 @@ public class MatProductWithMaterialsVo {
|
||||
private BigDecimal planNum; // 计划采购总数量
|
||||
private BigDecimal receivedNum; // 已入库数量
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ public class MatMaterialServiceImpl implements IMatMaterialService {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<MatMaterial> lqw = Wrappers.lambdaQuery();
|
||||
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.getModel()), MatMaterial::getModel, bo.getModel());
|
||||
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">
|
||||
<result property="materialId" column="material_id"/>
|
||||
<result property="materialName" column="material_name"/>
|
||||
<result property="materialType" column="material_type"/>
|
||||
<result property="spec" column="spec"/>
|
||||
<result property="model" column="model"/>
|
||||
<result property="factory" column="factory"/>
|
||||
|
||||
@@ -93,4 +93,6 @@ public class GearWorkerController extends BaseController {
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] workerIds) {
|
||||
return toAjax(iGearWorkerService.deleteWithValidByIds(Arrays.asList(workerIds), true));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,9 +7,6 @@ import com.gear.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 工人主数据对象 gear_worker
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("gear_worker")
|
||||
@@ -26,19 +23,16 @@ public class GearWorker extends BaseEntity {
|
||||
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 默认计费类型(1小时工 2计件工 3天工)
|
||||
*/
|
||||
private String defaultBillingType;
|
||||
|
||||
private String defaultWorkTypeName;
|
||||
|
||||
/**
|
||||
* 状态(0在职 1离职)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
@TableLogic
|
||||
/**
|
||||
* 逻辑删除标记:0-未删除,2-已删除
|
||||
*/
|
||||
@TableLogic(value = "0", delval = "2")
|
||||
private String delFlag;
|
||||
|
||||
private String remark;
|
||||
|
||||
@@ -12,6 +12,7 @@ import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 工资录入明细业务对象 gear_wage_entry_detail
|
||||
@@ -71,4 +72,6 @@ public class GearWageEntryDetailBo extends BaseEntity {
|
||||
private String makeupReason;
|
||||
|
||||
private String remark;
|
||||
// 新增累计金额
|
||||
private Map<String, BigDecimal> cumulativeAmounts;
|
||||
}
|
||||
|
||||
@@ -77,4 +77,6 @@ public class GearWageEntryDetailVo {
|
||||
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
@ExcelProperty(value = "累计金额")
|
||||
private BigDecimal cumulativeAmount;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,40 @@ package com.gear.oa.mapper;
|
||||
import com.gear.common.core.mapper.BaseMapperPlus;
|
||||
import com.gear.oa.domain.GearWorker;
|
||||
import com.gear.oa.domain.vo.GearWorkerVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
* 工人主数据Mapper接口
|
||||
*/
|
||||
public interface GearWorkerMapper extends BaseMapperPlus<GearWorkerMapper, GearWorker, GearWorkerVo> {
|
||||
/**
|
||||
* 根据工号查询所有记录(包括逻辑删除的),绕过 MyBatis-Plus 自动过滤
|
||||
*
|
||||
* @param workerNo 工号
|
||||
* @return 工人记录(可能为 null)
|
||||
*/
|
||||
@Select("SELECT * FROM gear_worker WHERE worker_no = #{workerNo}")
|
||||
GearWorker selectByWorkerNoIncludeDeleted(@Param("workerNo") String workerNo);
|
||||
|
||||
/**
|
||||
* 强制恢复并更新已删除的工人记录
|
||||
* 直接将 del_flag 更新为 0,并更新其他字段
|
||||
*
|
||||
* @param worker 包含新数据的工人对象(必须包含 workerNo 和需要更新的字段)
|
||||
* @return 影响行数
|
||||
*/
|
||||
@Update("UPDATE gear_worker SET " +
|
||||
"worker_name = #{workerName}, " +
|
||||
"phone = #{phone}, " +
|
||||
"default_billing_type = #{defaultBillingType}, " +
|
||||
"default_work_type_name = #{defaultWorkTypeName}, " +
|
||||
"status = #{status}, " +
|
||||
"del_flag = '0', " +
|
||||
"remark = #{remark}, " +
|
||||
"update_by = #{updateBy}, " +
|
||||
"update_time = NOW() " +
|
||||
"WHERE worker_no = #{workerNo}")
|
||||
int recoverByWorkerNo(GearWorker worker);
|
||||
}
|
||||
|
||||
@@ -49,11 +49,24 @@ public class GearWageEntryDetailServiceImpl implements IGearWageEntryDetailServi
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GearWageEntryDetailVo> queryList(GearWageEntryDetailBo bo) {
|
||||
LambdaQueryWrapper<GearWageEntryDetail> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
// @Override
|
||||
// public List<GearWageEntryDetailVo> queryList(GearWageEntryDetailBo bo) {
|
||||
// LambdaQueryWrapper<GearWageEntryDetail> lqw = buildQueryWrapper(bo);
|
||||
// return baseMapper.selectVoList(lqw);
|
||||
//
|
||||
// }
|
||||
@Override
|
||||
public List<GearWageEntryDetailVo> queryList(GearWageEntryDetailBo bo) {
|
||||
// 将 selectList 改为 selectVoList
|
||||
List<GearWageEntryDetailVo> list = baseMapper.selectVoList(buildQueryWrapper(bo));
|
||||
// 处理累计金额
|
||||
if (bo.getCumulativeAmounts() != null) {
|
||||
for (GearWageEntryDetailVo vo : list) {
|
||||
vo.setCumulativeAmount(bo.getCumulativeAmounts().get(vo.getEmpName()));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<GearWageEntryDetail> buildQueryWrapper(GearWageEntryDetailBo bo) {
|
||||
LambdaQueryWrapper<GearWageEntryDetail> lqw = Wrappers.lambdaQuery();
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gear.common.core.domain.PageQuery;
|
||||
import com.gear.common.core.page.TableDataInfo;
|
||||
import com.gear.common.exception.ServiceException;
|
||||
import com.gear.common.utils.StringUtils;
|
||||
import com.gear.oa.domain.GearWorker;
|
||||
import com.gear.oa.domain.bo.GearWorkerBo;
|
||||
@@ -14,14 +15,13 @@ import com.gear.oa.domain.vo.GearWorkerVo;
|
||||
import com.gear.oa.mapper.GearWorkerMapper;
|
||||
import com.gear.oa.service.IGearWorkerService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 工人主数据Service业务层处理
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class GearWorkerServiceImpl implements IGearWorkerService {
|
||||
@@ -48,6 +48,8 @@ public class GearWorkerServiceImpl implements IGearWorkerService {
|
||||
|
||||
private LambdaQueryWrapper<GearWorker> buildQueryWrapper(GearWorkerBo bo) {
|
||||
LambdaQueryWrapper<GearWorker> lqw = Wrappers.lambdaQuery();
|
||||
// 只查询未删除的数据(del_flag = '0')
|
||||
lqw.eq(GearWorker::getDelFlag, "0");
|
||||
lqw.eq(bo.getWorkerId() != null, GearWorker::getWorkerId, bo.getWorkerId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getWorkerNo()), GearWorker::getWorkerNo, bo.getWorkerNo());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getWorkerName()), GearWorker::getWorkerName, bo.getWorkerName());
|
||||
@@ -59,17 +61,48 @@ public class GearWorkerServiceImpl implements IGearWorkerService {
|
||||
|
||||
@Override
|
||||
public Boolean insertByBo(GearWorkerBo bo) {
|
||||
// 使用自定义方法查询所有记录(包括逻辑删除的)
|
||||
GearWorker existing = baseMapper.selectByWorkerNoIncludeDeleted(bo.getWorkerNo());
|
||||
|
||||
if (existing != null) {
|
||||
// 记录存在
|
||||
if ("0".equals(existing.getDelFlag())) {
|
||||
throw new ServiceException("工号 " + bo.getWorkerNo() + " 已存在且未删除,不能重复添加");
|
||||
} else {
|
||||
// 已删除,执行强制恢复更新
|
||||
GearWorker update = BeanUtil.toBean(bo, GearWorker.class);
|
||||
// 必须设置工号,用于 WHERE 条件
|
||||
update.setWorkerNo(bo.getWorkerNo());
|
||||
// 调用自定义恢复方法,直接更新数据库
|
||||
int rows = baseMapper.recoverByWorkerNo(update);
|
||||
if (rows > 0) {
|
||||
bo.setWorkerId(existing.getWorkerId());
|
||||
log.info("恢复并更新已删除工人成功,workerNo={}", bo.getWorkerNo());
|
||||
return true;
|
||||
} else {
|
||||
throw new ServiceException("恢复工人数据失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 完全新增
|
||||
log.info("新增工人,workerNo={}", bo.getWorkerNo());
|
||||
GearWorker add = BeanUtil.toBean(bo, GearWorker.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setWorkerId(add.getWorkerId());
|
||||
}
|
||||
return flag;
|
||||
baseMapper.insert(add);
|
||||
bo.setWorkerId(add.getWorkerId());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateByBo(GearWorkerBo bo) {
|
||||
GearWorker existing = baseMapper.selectById(bo.getWorkerId());
|
||||
if (existing == null) {
|
||||
throw new ServiceException("记录不存在");
|
||||
}
|
||||
if (!"0".equals(existing.getDelFlag())) {
|
||||
throw new ServiceException("该记录已被删除,无法更新");
|
||||
}
|
||||
GearWorker update = BeanUtil.toBean(bo, GearWorker.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
@@ -82,10 +115,14 @@ public class GearWorkerServiceImpl implements IGearWorkerService {
|
||||
if (StringUtils.isBlank(entity.getDefaultBillingType())) {
|
||||
entity.setDefaultBillingType("1");
|
||||
}
|
||||
if (StringUtils.isBlank(entity.getDelFlag())) {
|
||||
entity.setDelFlag("0");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
// 由于 @TableLogic(value="0", delval="2") 配置,此处会执行 UPDATE gear_worker SET del_flag='2'
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
@@ -103,24 +140,43 @@ public class GearWorkerServiceImpl implements IGearWorkerService {
|
||||
msg.append("[工号/姓名为空]");
|
||||
continue;
|
||||
}
|
||||
GearWorker exist = baseMapper.selectOne(Wrappers.<GearWorker>lambdaQuery()
|
||||
.eq(GearWorker::getWorkerNo, item.getWorkerNo()));
|
||||
|
||||
if (exist == null) {
|
||||
GearWorker add = BeanUtil.toBean(item, GearWorker.class);
|
||||
validEntityBeforeSave(add);
|
||||
baseMapper.insert(add);
|
||||
success++;
|
||||
} else if (Boolean.TRUE.equals(updateSupport)) {
|
||||
GearWorker update = BeanUtil.toBean(item, GearWorker.class);
|
||||
update.setWorkerId(exist.getWorkerId());
|
||||
validEntityBeforeSave(update);
|
||||
baseMapper.updateById(update);
|
||||
success++;
|
||||
} else {
|
||||
fail++;
|
||||
msg.append("[工号重复:").append(item.getWorkerNo()).append("]");
|
||||
// 使用自定义方法查询所有记录(包括逻辑删除的)
|
||||
GearWorker existing = baseMapper.selectByWorkerNoIncludeDeleted(item.getWorkerNo());
|
||||
|
||||
if (existing != null) {
|
||||
if ("0".equals(existing.getDelFlag())) {
|
||||
// 未删除,根据 updateSupport 决定
|
||||
if (Boolean.TRUE.equals(updateSupport)) {
|
||||
GearWorker update = BeanUtil.toBean(item, GearWorker.class);
|
||||
update.setWorkerId(existing.getWorkerId());
|
||||
validEntityBeforeSave(update);
|
||||
baseMapper.updateById(update);
|
||||
success++;
|
||||
} else {
|
||||
fail++;
|
||||
msg.append("[工号重复:").append(item.getWorkerNo()).append("]");
|
||||
}
|
||||
} else {
|
||||
// 已删除,强制恢复
|
||||
GearWorker recover = BeanUtil.toBean(item, GearWorker.class);
|
||||
recover.setWorkerNo(item.getWorkerNo());
|
||||
int rows = baseMapper.recoverByWorkerNo(recover);
|
||||
if (rows > 0) {
|
||||
success++;
|
||||
} else {
|
||||
fail++;
|
||||
msg.append("[恢复失败:").append(item.getWorkerNo()).append("]");
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// 完全新增
|
||||
GearWorker add = BeanUtil.toBean(item, GearWorker.class);
|
||||
validEntityBeforeSave(add);
|
||||
baseMapper.insert(add);
|
||||
success++;
|
||||
}
|
||||
return "导入完成,成功" + success + "条,失败" + fail + "条" + (msg.length() > 0 ? "," + msg : "");
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"element-plus": "2.9.9",
|
||||
"file-saver": "2.0.5",
|
||||
"fuse.js": "6.6.2",
|
||||
"i": "^0.3.7",
|
||||
"js-beautify": "1.14.11",
|
||||
"js-cookie": "3.0.5",
|
||||
"jsencrypt": "3.3.2",
|
||||
@@ -39,7 +40,8 @@
|
||||
"vue-cropper": "1.1.1",
|
||||
"vue-router": "4.5.1",
|
||||
"vue3-treeselect": "^0.1.10",
|
||||
"vuedraggable": "4.1.0"
|
||||
"vuedraggable": "4.1.0",
|
||||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "5.2.4",
|
||||
|
||||
@@ -35,10 +35,26 @@ export function updateWorker(data) {
|
||||
})
|
||||
}
|
||||
|
||||
// 删除工人
|
||||
export function delWorker(workerId) {
|
||||
// // 删除工人
|
||||
// export function delWorker(workerIds) {
|
||||
// return request({
|
||||
// url: '/oa/worker/' + workerId,
|
||||
// // url: '/oa/worker/' + workerIds.join(','),
|
||||
// method: 'delete'
|
||||
// })
|
||||
// }
|
||||
// 删除工人(修复后,支持单个+批量删除)
|
||||
export function delWorker(workerIds) {
|
||||
let url = ''
|
||||
if (Array.isArray(workerIds)) {
|
||||
// 数组 → 拼接成 1,2,3
|
||||
url = '/oa/worker/' + workerIds.join(',')
|
||||
} else {
|
||||
// 单个ID
|
||||
url = '/oa/worker/' + workerIds
|
||||
}
|
||||
return request({
|
||||
url: '/oa/worker/' + workerId,
|
||||
url: url,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
@use './mixin.scss';
|
||||
@use './transition.scss';
|
||||
@use './element-ui.scss';
|
||||
@@ -176,4 +177,5 @@ aside {
|
||||
vertical-align: middle;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,10 +11,32 @@
|
||||
</div>
|
||||
|
||||
<!-- 选择弹窗:表格+分页+底部按钮 -->
|
||||
<el-dialog title="选择配料" v-model="open" width="800px" destroy-on-close>
|
||||
<el-dialog title="选择配料" v-model="open" width="900px" destroy-on-close>
|
||||
<!-- 检索功能 -->
|
||||
<el-form :model="searchForm" :inline="true" class="mb-4">
|
||||
<el-form-item label="配料名称">
|
||||
<el-input v-model="searchForm.materialName" placeholder="请输入配料名称" clearable @keyup.enter="fetchMaterialList" />
|
||||
</el-form-item>
|
||||
<el-form-item label="物料类型">
|
||||
<el-select v-model="searchForm.materialType" placeholder="请选择物料类型" clearable @change="fetchMaterialList">
|
||||
<el-option label="主材" value="2" />
|
||||
<el-option label="辅料" value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="fetchMaterialList">搜索</el-button>
|
||||
<el-button @click="resetSearch">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table :data="list" style="width: 100%" border stripe @row-click="handleRowSelect" highlight-current-row
|
||||
row-key="materialId" :current-row-key="materialId">
|
||||
<el-table-column prop="materialName" label="配料名称" min-width="120" align="center" />
|
||||
<el-table-column label="物料类型" width="100" align="center">
|
||||
<template #default="scope">
|
||||
{{ scope.row.materialType === 1 ? '辅料' : scope.row.materialType === 2 ? '主材' : '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="spec" label="配料规格" min-width="100" align="center" />
|
||||
<el-table-column prop="model" label="配料型号" min-width="100" align="center" />
|
||||
<el-table-column prop="factory" label="生产厂家" min-width="120" align="center" />
|
||||
@@ -64,6 +86,12 @@ const emit = defineEmits(['change']);
|
||||
const list = ref([]); // 物料列表
|
||||
const open = ref(false); // 弹窗显隐
|
||||
|
||||
// 搜索表单数据
|
||||
const searchForm = ref({
|
||||
materialName: '',
|
||||
materialType: ''
|
||||
});
|
||||
|
||||
// 分页响应式数据(核心新增)
|
||||
const pageNum = ref(1); // 当前页码
|
||||
const pageSize = ref(10); // 每页条数
|
||||
@@ -77,7 +105,15 @@ onMounted(async () => {
|
||||
// 加载物料列表(适配分页参数)
|
||||
async function fetchMaterialList() {
|
||||
try {
|
||||
const res = await listMaterial({ pageNum: pageNum.value, pageSize: pageSize.value });
|
||||
// 构建查询参数,包含分页和搜索条件
|
||||
const params = {
|
||||
pageNum: pageNum.value,
|
||||
pageSize: pageSize.value,
|
||||
materialName: searchForm.value.materialName,
|
||||
materialType: searchForm.value.materialType
|
||||
};
|
||||
|
||||
const res = await listMaterial(params);
|
||||
|
||||
list.value = res.rows;
|
||||
total.value = res.total; // 赋值总条数供分页使用
|
||||
@@ -95,6 +131,16 @@ async function fetchMaterialList() {
|
||||
}
|
||||
}
|
||||
|
||||
// 重置搜索
|
||||
function resetSearch() {
|
||||
searchForm.value = {
|
||||
materialName: '',
|
||||
materialType: ''
|
||||
};
|
||||
pageNum.value = 1;
|
||||
fetchMaterialList();
|
||||
}
|
||||
|
||||
// 表格行选择物料
|
||||
function handleRowSelect(row) {
|
||||
if (row.materialId === materialId.value) return;
|
||||
|
||||
@@ -170,8 +170,8 @@ onMounted(() => {
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.topmenu-container.el-menu--horizontal > .el-menu-item {
|
||||
<style lang="scss" scoped>
|
||||
:deep(.el-menu > .el-menu-item) {
|
||||
float: left;
|
||||
height: 50px !important;
|
||||
line-height: 50px !important;
|
||||
@@ -180,13 +180,14 @@ onMounted(() => {
|
||||
margin: 0 10px !important;
|
||||
}
|
||||
|
||||
.topmenu-container.el-menu--horizontal > .el-menu-item.is-active, .el-menu--horizontal > .el-sub-menu.is-active .el-submenu__title {
|
||||
:deep(.el-menu > .el-menu-item.is-active), :deep(.el-menu > .el-sub-menu.is-active .el-submenu__title) {
|
||||
border-bottom: 2px solid #{'var(--theme)'} !important;
|
||||
color: #303133;
|
||||
background-color: #f5f7fa !important;
|
||||
}
|
||||
|
||||
/* sub-menu item */
|
||||
.topmenu-container.el-menu--horizontal > .el-sub-menu .el-sub-menu__title {
|
||||
:deep(.el-menu > .el-sub-menu .el-sub-menu__title) {
|
||||
float: left;
|
||||
height: 50px !important;
|
||||
line-height: 50px !important;
|
||||
@@ -196,17 +197,17 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
/* 背景色隐藏 */
|
||||
.topmenu-container.el-menu--horizontal>.el-menu-item:not(.is-disabled):focus, .topmenu-container.el-menu--horizontal>.el-menu-item:not(.is-disabled):hover, .topmenu-container.el-menu--horizontal>.el-submenu .el-submenu__title:hover {
|
||||
:deep(.el-menu>.el-menu-item:not(.is-disabled):focus), :deep(.el-menu>.el-menu-item:not(.is-disabled):hover), :deep(.el-menu>.el-sub-menu .el-sub-menu__title:hover) {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
/* 图标右间距 */
|
||||
.topmenu-container .svg-icon {
|
||||
:deep(.svg-icon) {
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
/* topmenu more arrow */
|
||||
.topmenu-container .el-sub-menu .el-sub-menu__icon-arrow {
|
||||
:deep(.el-sub-menu .el-sub-menu__icon-arrow) {
|
||||
position: static;
|
||||
vertical-align: middle;
|
||||
margin-left: 8px;
|
||||
|
||||
@@ -90,8 +90,9 @@ function isActive(r) {
|
||||
function activeStyle(tag) {
|
||||
if (!isActive(tag)) return {}
|
||||
return {
|
||||
"background-color": theme.value,
|
||||
"border-color": theme.value
|
||||
"background-color": "#f5f7fa",
|
||||
"border-color": "#f5f7fa",
|
||||
"color": "#303133"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,13 +292,13 @@ function handleScroll() {
|
||||
}
|
||||
|
||||
&.active {
|
||||
background-color: #42b983;
|
||||
color: #fff;
|
||||
border-color: #42b983;
|
||||
background-color: #f5f7fa;
|
||||
color: #303133;
|
||||
border-color: #f5f7fa;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
background: #fff;
|
||||
background: #42b983;
|
||||
display: inline-block;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
|
||||
@@ -17,7 +17,7 @@ const service = axios.create({
|
||||
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
||||
baseURL: import.meta.env.VITE_APP_BASE_API,
|
||||
// 超时
|
||||
timeout: 10000
|
||||
timeout: 30000
|
||||
})
|
||||
|
||||
// request拦截器
|
||||
|
||||
@@ -247,23 +247,23 @@ export default {
|
||||
}
|
||||
|
||||
/* 对话框样式 */
|
||||
::v-deep .el-dialog__header {
|
||||
:deep(.el-dialog__header) {
|
||||
padding: 10px 15px;
|
||||
}
|
||||
|
||||
::v-deep .el-dialog__body {
|
||||
:deep(.el-dialog__body) {
|
||||
padding: 10px 15px;
|
||||
}
|
||||
|
||||
::v-deep .el-dialog__footer {
|
||||
:deep(.el-dialog__footer) {
|
||||
padding: 8px 15px;
|
||||
}
|
||||
|
||||
::v-deep .el-form-item {
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
::v-deep .el-input__inner {
|
||||
:deep(.el-input__inner) {
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
font-size: 13px;
|
||||
|
||||
@@ -25,6 +25,11 @@
|
||||
<raw :data="scope.row" :materialId="scope.row.materialId" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="物料类型" width="100" align="center">
|
||||
<template #default="scope">
|
||||
{{ scope.row.material?.materialType === 1 ? '辅料' : scope.row.material?.materialType === 2 ? '主材' : '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="所需数量" align="center" prop="materialNum">
|
||||
<template #default="scope">
|
||||
{{ formatDecimal(scope.row.materialNum) }}
|
||||
@@ -75,6 +80,7 @@
|
||||
|
||||
<script setup name="ProductMaterialRelation">
|
||||
import { listProductMaterialRelation, getProductMaterialRelation, delProductMaterialRelation, addProductMaterialRelation, updateProductMaterialRelation } from "@/api/mat/productMaterialRelation";
|
||||
import { getMaterial } from "@/api/mat/material";
|
||||
import RawSelector from '@/components/RawSelector/index.vue'
|
||||
import Raw from '@/components/Renderer/Raw.vue'
|
||||
import { formatDecimal } from '@/utils/gear'
|
||||
@@ -128,8 +134,21 @@ watch(() => props.productId, (newVal, oldVal) => {
|
||||
function getList() {
|
||||
loading.value = true;
|
||||
listProductMaterialRelation(queryParams.value).then(response => {
|
||||
productMaterialRelationList.value = response.rows;
|
||||
total.value = response.total;
|
||||
const relations = response.rows;
|
||||
// 为每个配方项获取物料详细信息,包括物料类型
|
||||
const promises = relations.map(item => {
|
||||
return getMaterial(item.materialId).then(materialResponse => {
|
||||
item.material = materialResponse.data;
|
||||
return item;
|
||||
});
|
||||
});
|
||||
return Promise.all(promises);
|
||||
}).then(relationsWithMaterial => {
|
||||
productMaterialRelationList.value = relationsWithMaterial;
|
||||
total.value = relationsWithMaterial.length;
|
||||
loading.value = false;
|
||||
}).catch(error => {
|
||||
console.error('获取数据失败:', error);
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -45,9 +45,24 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="产品图片" align="center" prop="productImages">
|
||||
<template #default="scope">
|
||||
<div v-if="scope.row.productImages" class="image-preview">
|
||||
<el-image
|
||||
v-for="(image, index) in scope.row.productImages.split(',')"
|
||||
:key="index"
|
||||
:src="image"
|
||||
:preview-src-list="scope.row.productImages.split(',')"
|
||||
style="width: 40px; height: 40px; margin-right: 8px;"
|
||||
/>
|
||||
</div>
|
||||
<span v-else>无</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" icon="Plus" @click="handleBom(scope.row)">配方</el-button>
|
||||
<el-button link type="primary" icon="View" @click="handleDetail(scope.row)">详情</el-button>
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)">修改</el-button>
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
|
||||
</template>
|
||||
@@ -75,6 +90,26 @@
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
<el-form-item label="产品图片" prop="productImages">
|
||||
<el-upload
|
||||
v-model:file-list="imageFileList"
|
||||
:action="uploadUrl"
|
||||
:headers="headers"
|
||||
:on-success="handleImageUploadSuccess"
|
||||
:on-remove="handleImageRemove"
|
||||
multiple
|
||||
list-type="picture"
|
||||
:limit="5"
|
||||
:before-upload="beforeUpload"
|
||||
>
|
||||
<el-button type="primary" icon="Upload">上传图片</el-button>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip">
|
||||
最多上传5张图片,支持 JPG、PNG 格式
|
||||
</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
@@ -110,16 +145,191 @@
|
||||
<el-empty v-else description="选择产品查看配料信息" />
|
||||
|
||||
<!-- </StickyDragContainer> -->
|
||||
|
||||
<!-- 产品详情弹窗 -->
|
||||
<el-dialog :title="currentProductDetail.productName + ' - 产品详情'" v-model="detailOpen" width="900px" append-to-body>
|
||||
<!-- 产品信息和图片容器 -->
|
||||
<div class="product-header">
|
||||
<!-- 产品基本信息 -->
|
||||
<div class="product-info">
|
||||
<h3 class="section-title">产品信息</h3>
|
||||
<div class="info-content">
|
||||
<div class="info-row">
|
||||
<span class="label">品名:</span>
|
||||
<span class="value">{{ currentProductDetail.productName }}</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="label">产品规格:</span>
|
||||
<span class="value">{{ currentProductDetail.spec }}</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="label">产品型号:</span>
|
||||
<span class="value">{{ currentProductDetail.model }}</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="label">产品单价:</span>
|
||||
<span class="value">{{ formatDecimal(currentProductDetail.unitPrice) }} 元</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="label">备注:</span>
|
||||
<span class="value">{{ currentProductDetail.remark || '无' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 产品图片 -->
|
||||
<div class="product-images" v-if="currentProductDetail.productImages">
|
||||
<h3 class="section-title">产品图片</h3>
|
||||
<div class="image-list">
|
||||
<el-image
|
||||
v-for="(image, index) in currentProductDetail.productImages.split(',')"
|
||||
:key="index"
|
||||
:src="image"
|
||||
:preview-src-list="currentProductDetail.productImages.split(',')"
|
||||
style="width: 150px; height: 150px; margin-right: 15px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 材料明细 -->
|
||||
<div class="material-detail">
|
||||
<h3 class="section-title">材料明细</h3>
|
||||
|
||||
<!-- 主材部分 -->
|
||||
<div class="material-category" v-if="rawMaterials.length > 0">
|
||||
<h4 class="category-title">主材</h4>
|
||||
<el-table v-loading="materialLoading" :data="rawMaterials" style="width: 100%" border>
|
||||
<el-table-column label="材料名称" width="150">
|
||||
<template #default="scope">
|
||||
<Raw :data="scope.row" :materialId="scope.row.materialId" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="材料规格" width="200">
|
||||
<template #default="scope">
|
||||
{{ scope.row.material?.spec || '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数量" width="100" align="center">
|
||||
<template #default="scope">
|
||||
{{ formatDecimal(scope.row.materialNum) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="价格" width="100" align="center">
|
||||
<template #default="scope">
|
||||
{{ formatDecimal(scope.row.material?.unitPrice || 0) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" />
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<!-- 辅材部分 -->
|
||||
<div class="material-category" v-if="auxiliaryMaterials.length > 0">
|
||||
<h4 class="category-title">辅材</h4>
|
||||
<el-table v-loading="materialLoading" :data="auxiliaryMaterials" style="width: 100%" border>
|
||||
<el-table-column label="材料名称" width="150">
|
||||
<template #default="scope">
|
||||
<Raw :data="scope.row" :materialId="scope.row.materialId" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="材料规格" width="200">
|
||||
<template #default="scope">
|
||||
{{ scope.row.material?.spec || '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数量" width="100" align="center">
|
||||
<template #default="scope">
|
||||
{{ formatDecimal(scope.row.materialNum) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="价格" width="100" align="center">
|
||||
<template #default="scope">
|
||||
{{ formatDecimal(scope.row.material?.unitPrice || 0) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" />
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<!-- 无数据提示 -->
|
||||
<div v-if="productMaterialRelationList.length === 0">
|
||||
<el-empty description="暂无配方数据" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 总计部分 -->
|
||||
<div class="total-section">
|
||||
<div class="total-item">
|
||||
<span class="total-label">产品总价:</span>
|
||||
<span class="total-value">{{ formatDecimal(currentProductDetail.unitPrice || 0) }} 元</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="Product">
|
||||
import { ref, computed } from 'vue';
|
||||
import { listProduct, getProduct, delProduct, addProduct, updateProduct } from "@/api/mat/product";
|
||||
import { listProductMaterialRelation } from "@/api/mat/productMaterialRelation";
|
||||
import { getMaterial } from "@/api/mat/material";
|
||||
import bom from "@/views/mat/components/bom.vue";
|
||||
import StickyDragContainer from "@/components/StickyDragContainer/index.vue";
|
||||
import { formatDecimal } from '@/utils/gear'
|
||||
import Raw from '@/components/Renderer/Raw.vue';
|
||||
import { formatDecimal } from '@/utils/gear';
|
||||
import { getToken } from '@/utils/auth';
|
||||
|
||||
const bomOpen = ref(false);
|
||||
const detailOpen = ref(false);
|
||||
const currentProductDetail = ref({});
|
||||
|
||||
// 配方数据
|
||||
const productMaterialRelationList = ref([]);
|
||||
const materialLoading = ref(false);
|
||||
|
||||
// 计算总金额
|
||||
const totalAmount = computed(() => {
|
||||
return productMaterialRelationList.value.reduce((sum, item) => {
|
||||
// 假设每个物料都有价格,实际项目中需要从物料数据中获取
|
||||
const price = item.material?.unitPrice || 0;
|
||||
const quantity = item.materialNum || 0;
|
||||
return sum + (price * quantity);
|
||||
}, 0);
|
||||
});
|
||||
|
||||
// 分离原料和辅料
|
||||
const rawMaterials = computed(() => {
|
||||
// 原料(主材):materialType === 2
|
||||
return productMaterialRelationList.value.filter(item => {
|
||||
return item && item.material && item.material.materialType === 2;
|
||||
});
|
||||
});
|
||||
|
||||
const auxiliaryMaterials = computed(() => {
|
||||
// 辅料:materialType === 1
|
||||
return productMaterialRelationList.value.filter(item => {
|
||||
return item && item.material && item.material.materialType === 1;
|
||||
});
|
||||
});
|
||||
|
||||
// 计算原料总金额
|
||||
const rawMaterialsTotal = computed(() => {
|
||||
return rawMaterials.value.reduce((sum, item) => {
|
||||
const price = item.material?.unitPrice || 0;
|
||||
const quantity = item.materialNum || 0;
|
||||
return sum + (price * quantity);
|
||||
}, 0);
|
||||
});
|
||||
|
||||
// 计算辅料总金额
|
||||
const auxiliaryMaterialsTotal = computed(() => {
|
||||
return auxiliaryMaterials.value.reduce((sum, item) => {
|
||||
const price = item.material?.unitPrice || 0;
|
||||
const quantity = item.materialNum || 0;
|
||||
return sum + (price * quantity);
|
||||
}, 0);
|
||||
});
|
||||
|
||||
const { proxy } = getCurrentInstance();
|
||||
|
||||
@@ -136,6 +346,9 @@ const title = ref("");
|
||||
const currentProductId = ref(null);
|
||||
const currentProduct = ref({});
|
||||
const appContainer = ref(null);
|
||||
const imageFileList = ref([]);
|
||||
const uploadUrl = ref(import.meta.env.VITE_APP_BASE_API + '/system/oss/upload');
|
||||
const headers = ref({ Authorization: "Bearer " + getToken() });
|
||||
|
||||
const formatterTime = (time) => {
|
||||
return proxy.parseTime(time, '{y}-{m}-{d}')
|
||||
@@ -185,8 +398,10 @@ function reset() {
|
||||
createBy: null,
|
||||
updateTime: null,
|
||||
updateBy: null,
|
||||
remark: null
|
||||
remark: null,
|
||||
productImages: null
|
||||
};
|
||||
imageFileList.value = [];
|
||||
proxy.resetForm("productRef");
|
||||
}
|
||||
|
||||
@@ -224,11 +439,60 @@ function handleUpdate(row) {
|
||||
getProduct(_productId).then(response => {
|
||||
loading.value = false;
|
||||
form.value = response.data;
|
||||
// 处理图片文件列表
|
||||
if (form.value.productImages) {
|
||||
imageFileList.value = form.value.productImages.split(',').map(url => ({
|
||||
name: url.substring(url.lastIndexOf('/') + 1),
|
||||
url: url
|
||||
}));
|
||||
}
|
||||
open.value = true;
|
||||
title.value = "修改产品基础信息";
|
||||
});
|
||||
}
|
||||
|
||||
/** 图片上传成功处理 */
|
||||
function handleImageUploadSuccess(response, uploadFile) {
|
||||
if (response.code === 200) {
|
||||
const imageUrl = response.data.url;
|
||||
if (form.value.productImages) {
|
||||
form.value.productImages += ',' + imageUrl;
|
||||
} else {
|
||||
form.value.productImages = imageUrl;
|
||||
}
|
||||
} else {
|
||||
proxy.$modal.msgError('上传失败:' + response.msg);
|
||||
}
|
||||
}
|
||||
|
||||
/** 图片移除处理 */
|
||||
function handleImageRemove(uploadFile, uploadFiles) {
|
||||
const imageUrl = uploadFile.url;
|
||||
if (form.value.productImages) {
|
||||
const images = form.value.productImages.split(',');
|
||||
const index = images.indexOf(imageUrl);
|
||||
if (index > -1) {
|
||||
images.splice(index, 1);
|
||||
form.value.productImages = images.join(',');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 图片上传前校验 */
|
||||
function beforeUpload(file) {
|
||||
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
|
||||
const isLt2M = file.size / 1024 / 1024 < 2;
|
||||
if (!isJpgOrPng) {
|
||||
proxy.$modal.msgError('只能上传 JPG/PNG 格式的图片');
|
||||
return false;
|
||||
}
|
||||
if (!isLt2M) {
|
||||
proxy.$modal.msgError('图片大小不能超过 2MB');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["productRef"].validate(valid => {
|
||||
@@ -287,5 +551,153 @@ function handleRowClick(row) {
|
||||
currentProduct.value = row;
|
||||
}
|
||||
|
||||
function handleDetail(row) {
|
||||
loading.value = true;
|
||||
materialLoading.value = true;
|
||||
// 获取产品详情
|
||||
getProduct(row.productId).then(response => {
|
||||
currentProductDetail.value = response.data;
|
||||
// 获取配方数据
|
||||
return listProductMaterialRelation({ productId: row.productId });
|
||||
}).then(response => {
|
||||
const relations = response.rows;
|
||||
// 为每个配方项获取物料详细信息,包括物料类型
|
||||
const promises = relations.map(item => {
|
||||
return getMaterial(item.materialId).then(materialResponse => {
|
||||
item.material = materialResponse.data;
|
||||
return item;
|
||||
});
|
||||
});
|
||||
return Promise.all(promises);
|
||||
}).then(relationsWithMaterial => {
|
||||
productMaterialRelationList.value = relationsWithMaterial;
|
||||
detailOpen.value = true;
|
||||
}).catch(error => {
|
||||
console.error('获取数据失败:', error);
|
||||
}).finally(() => {
|
||||
loading.value = false;
|
||||
materialLoading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
getList();
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 产品信息和图片容器 */
|
||||
.product-header {
|
||||
display: flex;
|
||||
margin: 20px 0;
|
||||
gap: 30px;
|
||||
}
|
||||
|
||||
/* 产品图片部分 */
|
||||
.product-images {
|
||||
flex-shrink: 0;
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.image-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 15px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* 产品信息部分 */
|
||||
.product-info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 15px;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 2px solid #409eff;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.info-content {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.info-row {
|
||||
margin-bottom: 10px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-weight: bold;
|
||||
margin-right: 15px;
|
||||
width: 100px;
|
||||
display: inline-block;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.value {
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
/* 材料明细部分 */
|
||||
.material-detail {
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.material-category {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.category-title {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10px;
|
||||
padding: 8px 15px;
|
||||
background-color: #ecf5ff;
|
||||
color: #409eff;
|
||||
border-left: 4px solid #409eff;
|
||||
}
|
||||
|
||||
/* 总计部分 */
|
||||
.total-section {
|
||||
margin-top: 30px;
|
||||
padding: 20px;
|
||||
background-color: #f0f9eb;
|
||||
border: 1px solid #b7eb8f;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.total-item {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.total-label {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.total-value {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
/* 表格样式 */
|
||||
:deep(.el-table th) {
|
||||
background-color: #f5f7fa;
|
||||
font-weight: bold;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
:deep(.el-table tr:hover) {
|
||||
background-color: #ecf5ff;
|
||||
}
|
||||
|
||||
:deep(.el-table td) {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
<el-form-item label="厂家" prop="factory">
|
||||
<el-input v-model="queryParams.factory" placeholder="请输入厂家" clearable @keyup.enter="handleQuery" />
|
||||
</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-input v-model="queryParams.unit" placeholder="请输入计量单位 个/公斤/米等" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
@@ -45,6 +50,11 @@
|
||||
<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="配料名称" 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="model" />
|
||||
<el-table-column label="厂家" align="center" prop="factory" />
|
||||
@@ -79,6 +89,11 @@
|
||||
<el-form-item label="配料名称" prop="materialName">
|
||||
<el-input v-model="form.materialName" placeholder="请输入配料名称" />
|
||||
</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-input v-model="form.spec" placeholder="请输入配料规格" />
|
||||
</el-form-item>
|
||||
@@ -171,7 +186,7 @@
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
|
||||
|
||||
<Price :materialId="currentMaterialId" ref="priceRef" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -232,6 +247,7 @@ const data = reactive({
|
||||
factory: undefined,
|
||||
unit: undefined,
|
||||
currentStock: undefined,
|
||||
materialType: 2, // 固定为原料
|
||||
},
|
||||
rules: {
|
||||
}
|
||||
@@ -260,6 +276,7 @@ function reset() {
|
||||
form.value = {
|
||||
materialId: null,
|
||||
materialName: null,
|
||||
materialType: 2, // 固定为原料
|
||||
spec: null,
|
||||
model: null,
|
||||
factory: null,
|
||||
@@ -284,6 +301,7 @@ function handleQuery() {
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
proxy.resetForm("queryRef");
|
||||
queryParams.value.materialType = 2; // 重置后仍为原料
|
||||
handleQuery();
|
||||
}
|
||||
|
||||
|
||||
@@ -539,8 +539,8 @@ export default {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
::v-deep .el-input-group__append,
|
||||
::v-deep .el-input-group__prepend {
|
||||
:deep(.el-input-group__append),
|
||||
:deep(.el-input-group__prepend) {
|
||||
width: 20px !important;
|
||||
box-sizing: border-box !important;
|
||||
padding: 0 10px !important;
|
||||
|
||||
@@ -98,8 +98,8 @@
|
||||
<el-date-picker
|
||||
clearable
|
||||
v-model="form.uploadTime"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
placeholder="请选择上传时间"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
<el-col :span="2.5">
|
||||
<el-button size="small" type="info" plain icon="RefreshRight" @click="handleInitDaily(true)">重置当日名单</el-button>
|
||||
</el-col>
|
||||
<el-col :span="2.5">
|
||||
<el-button size="small" type="danger" plain icon="Refresh" @click="resetCumulativeAmounts">重置累计金额</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.8">
|
||||
<el-button size="small" type="primary" plain icon="Check" @click="saveAllRows">全部保存</el-button>
|
||||
</el-col>
|
||||
@@ -72,6 +75,7 @@
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="总金额" align="center" prop="totalAmount" width="110" />
|
||||
<el-table-column label="累计金额" align="center" prop="cumulativeAmount" width="110" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="170">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" icon="Check" @click="saveRow(scope.row)">保存</el-button>
|
||||
@@ -95,6 +99,27 @@ const loading = ref(true)
|
||||
const showSearch = ref(true)
|
||||
const total = ref(0)
|
||||
|
||||
// 存储累计金额数据
|
||||
const cumulativeAmounts = ref({})
|
||||
|
||||
// 从localStorage加载累计金额数据
|
||||
function loadCumulativeAmounts() {
|
||||
const stored = localStorage.getItem('wageCumulativeAmounts')
|
||||
if (stored) {
|
||||
try {
|
||||
cumulativeAmounts.value = JSON.parse(stored)
|
||||
} catch (e) {
|
||||
console.error('Failed to parse cumulative amounts:', e)
|
||||
cumulativeAmounts.value = {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 保存累计金额数据到localStorage
|
||||
function saveCumulativeAmounts() {
|
||||
localStorage.setItem('wageCumulativeAmounts', JSON.stringify(cumulativeAmounts.value))
|
||||
}
|
||||
|
||||
const data = reactive({
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
@@ -149,18 +174,43 @@ function recalcRowAmount(row) {
|
||||
const baseAmount = round2(workload * unitPrice)
|
||||
row.baseAmount = baseAmount
|
||||
row.totalAmount = round2(baseAmount + extraAmount)
|
||||
|
||||
// 重新计算累计金额
|
||||
updateCumulativeAmounts()
|
||||
}
|
||||
|
||||
function updateCumulativeAmounts() {
|
||||
// 计算当前页面的总金额
|
||||
const currentEmpAmounts = {}
|
||||
wageEntryDetailList.value.forEach(row => {
|
||||
const empName = row.empName
|
||||
if (!currentEmpAmounts[empName]) {
|
||||
currentEmpAmounts[empName] = 0
|
||||
}
|
||||
currentEmpAmounts[empName] += parseFloat(row.totalAmount) || 0
|
||||
})
|
||||
|
||||
// 更新每个员工的累计金额(基于存储的数据)
|
||||
wageEntryDetailList.value.forEach(row => {
|
||||
row.cumulativeAmount = cumulativeAmounts.value[row.empName] || 0
|
||||
})
|
||||
}
|
||||
|
||||
function getList() {
|
||||
loading.value = true
|
||||
// 加载存储的累计金额数据
|
||||
loadCumulativeAmounts()
|
||||
|
||||
listWageEntryDetail(queryParams.value).then(response => {
|
||||
const rows = response.rows || []
|
||||
|
||||
wageEntryDetailList.value = rows.map(row => {
|
||||
const r = {
|
||||
...row,
|
||||
workload: normalizeEditableValue(row.workload),
|
||||
unitPrice: normalizeEditableValue(row.unitPrice),
|
||||
extraAmount: normalizeEditableValue(row.extraAmount)
|
||||
extraAmount: normalizeEditableValue(row.extraAmount),
|
||||
cumulativeAmount: cumulativeAmounts.value[row.empName] || 0
|
||||
}
|
||||
recalcRowAmount(r)
|
||||
return r
|
||||
@@ -202,6 +252,13 @@ function buildRowPayload(row) {
|
||||
function saveRow(row) {
|
||||
const payload = buildRowPayload(row)
|
||||
updateWageEntryDetail(payload).then(() => {
|
||||
// 更新累计金额
|
||||
if (!cumulativeAmounts.value[row.empName]) {
|
||||
cumulativeAmounts.value[row.empName] = 0
|
||||
}
|
||||
cumulativeAmounts.value[row.empName] += parseFloat(payload.totalAmount) || 0
|
||||
saveCumulativeAmounts()
|
||||
|
||||
proxy.$modal.msgSuccess('保存成功')
|
||||
getList()
|
||||
})
|
||||
@@ -219,11 +276,19 @@ async function saveAllRows() {
|
||||
const payload = buildRowPayload(row)
|
||||
try {
|
||||
await updateWageEntryDetail(payload)
|
||||
// 更新累计金额
|
||||
if (!cumulativeAmounts.value[row.empName]) {
|
||||
cumulativeAmounts.value[row.empName] = 0
|
||||
}
|
||||
cumulativeAmounts.value[row.empName] += parseFloat(payload.totalAmount) || 0
|
||||
successCount++
|
||||
} catch (e) {
|
||||
failCount++
|
||||
}
|
||||
}
|
||||
// 保存累计金额数据
|
||||
saveCumulativeAmounts()
|
||||
|
||||
loading.value = false
|
||||
if (failCount === 0) {
|
||||
proxy.$modal.msgSuccess(`全部保存完成,共 ${successCount} 条`)
|
||||
@@ -244,10 +309,20 @@ function handleDelete(row) {
|
||||
|
||||
function handleExport() {
|
||||
proxy.download('oa/wageEntryDetail/export', {
|
||||
...queryParams.value
|
||||
...queryParams.value,
|
||||
cumulativeAmounts: cumulativeAmounts.value
|
||||
}, `wage_entry_detail_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
|
||||
function resetCumulativeAmounts() {
|
||||
proxy.$modal.confirm('是否确认重置所有员工的累计金额?此操作不可恢复。').then(() => {
|
||||
cumulativeAmounts.value = {}
|
||||
saveCumulativeAmounts()
|
||||
proxy.$modal.msgSuccess('累计金额已重置')
|
||||
getList()
|
||||
})
|
||||
}
|
||||
|
||||
function handleInitDaily(forceReset = false) {
|
||||
const entryDate = queryParams.value.entryDate || proxy.parseTime(new Date(), '{y}-{m}-{d}')
|
||||
const text = forceReset ? `确认重置 ${entryDate} 的当日名单吗?将先删除后重建。` : `确认初始化 ${entryDate} 的工人名单吗?`
|
||||
@@ -260,15 +335,25 @@ function handleInitDaily(forceReset = false) {
|
||||
proxy.$modal.msgSuccess(`操作成功,共写入 ${res.data || 0} 人`)
|
||||
}
|
||||
getList()
|
||||
}).catch(err => {
|
||||
console.error('重置当日名单失败:', err)
|
||||
proxy.$modal.msgError('操作失败,请稍后重试')
|
||||
})
|
||||
}
|
||||
|
||||
async function autoInitFirstEnter() {
|
||||
const entryDate = queryParams.value.entryDate || proxy.parseTime(new Date(), '{y}-{m}-{d}')
|
||||
await initDailyWorkers({ entryDate, forceReset: false })
|
||||
try {
|
||||
await initDailyWorkers({ entryDate, forceReset: false })
|
||||
} catch (err) {
|
||||
console.error('自动初始化当日名单失败:', err)
|
||||
// 静默失败,不影响页面加载
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
// 加载存储的累计金额数据
|
||||
loadCumulativeAmounts()
|
||||
await autoInitFirstEnter()
|
||||
getList()
|
||||
})
|
||||
|
||||
@@ -91,6 +91,7 @@
|
||||
<script setup name="WageMakeup">
|
||||
import { listWageEntryDetail, updateWageEntryDetail, delWageEntryDetail } from '@/api/oa/wageEntryDetail'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import { onMounted } from 'vue'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const userStore = useUserStore()
|
||||
@@ -102,6 +103,27 @@ const open = ref(false)
|
||||
const title = ref('')
|
||||
const buttonLoading = ref(false)
|
||||
|
||||
// 存储累计金额数据
|
||||
const cumulativeAmounts = ref({})
|
||||
|
||||
// 从localStorage加载累计金额数据
|
||||
function loadCumulativeAmounts() {
|
||||
const stored = localStorage.getItem('wageCumulativeAmounts')
|
||||
if (stored) {
|
||||
try {
|
||||
cumulativeAmounts.value = JSON.parse(stored)
|
||||
} catch (e) {
|
||||
console.error('Failed to parse cumulative amounts:', e)
|
||||
cumulativeAmounts.value = {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 保存累计金额数据到localStorage
|
||||
function saveCumulativeAmounts() {
|
||||
localStorage.setItem('wageCumulativeAmounts', JSON.stringify(cumulativeAmounts.value))
|
||||
}
|
||||
|
||||
const data = reactive({
|
||||
form: {},
|
||||
queryParams: {
|
||||
@@ -197,6 +219,18 @@ function submitForm() {
|
||||
}
|
||||
// 本页面补录语义:更新当前记录并标记为已补录
|
||||
updateWageEntryDetail(payload).then(() => {
|
||||
// 更新累计金额
|
||||
const workload = parseFloat(payload.workload) || 0
|
||||
const unitPrice = parseFloat(payload.unitPrice) || 0
|
||||
const extraAmount = parseFloat(payload.extraAmount) || 0
|
||||
const totalAmount = workload * unitPrice + extraAmount
|
||||
|
||||
if (!cumulativeAmounts.value[payload.empName]) {
|
||||
cumulativeAmounts.value[payload.empName] = 0
|
||||
}
|
||||
cumulativeAmounts.value[payload.empName] += totalAmount
|
||||
saveCumulativeAmounts()
|
||||
|
||||
proxy.$modal.msgSuccess('补录成功')
|
||||
open.value = false
|
||||
getList()
|
||||
@@ -229,5 +263,8 @@ function handleExport() {
|
||||
proxy.download('oa/wageEntryDetail/export', { ...buildQuery() }, `wage_makeup_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
|
||||
getList()
|
||||
onMounted(() => {
|
||||
loadCumulativeAmounts()
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
<el-col :span="1.5"><el-button size="small" type="warning" plain icon="Download" @click="handleExport">导出</el-button></el-col>
|
||||
<el-col :span="1.5"><el-button size="small" type="info" plain icon="Upload" @click="openImport">导入</el-button></el-col>
|
||||
<el-col :span="1.8"><el-button size="small" plain icon="Download" @click="downloadTemplate">下载模板</el-button></el-col>
|
||||
<el-col :span="2.2"><el-button size="small" type="primary" plain icon="User" @click="openUserSelectDialog">选择用户导入</el-button></el-col>
|
||||
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" />
|
||||
</el-row>
|
||||
|
||||
@@ -122,6 +124,21 @@
|
||||
<el-button @click="importOpen = false">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<!-- 选择系统用户导入弹窗 -->
|
||||
<el-dialog title="选择需要导入的用户" v-model="userSelectOpen" width="700px" append-to-body>
|
||||
<el-input v-model="userSearchKey" placeholder="搜索账号/昵称/手机号" clearable style="width: 300px; margin-bottom: 10px"/>
|
||||
<el-table ref="userSelectTableRef" v-model:selection="selectedUserIds" :data="filterUserList" border height="350" @selection-change="handleUserSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="账号" prop="userName" align="center" />
|
||||
<el-table-column label="昵称" prop="nickName" align="center" />
|
||||
<el-table-column label="手机号" prop="phonenumber" align="center" />
|
||||
</el-table>
|
||||
<template #footer>
|
||||
<el-button @click="userSelectOpen = false">取消</el-button>
|
||||
<el-button type="primary" @click="confirmImportSelectedUser">确认导入</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -129,6 +146,7 @@
|
||||
<script setup name="Worker">
|
||||
import { listWorker, getWorker, addWorker, updateWorker, delWorker, importWorkerData } from '@/api/oa/worker'
|
||||
import { listWageRateConfig } from '@/api/oa/wageRateConfig'
|
||||
import { listUser } from '@/api/system/user'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
@@ -148,8 +166,37 @@ const importLoading = ref(false)
|
||||
const updateSupport = ref(false)
|
||||
const importFile = ref(null)
|
||||
|
||||
// 选择用户导入相关
|
||||
const userSelectOpen = ref(false)
|
||||
const allUserList = ref([])
|
||||
const selectedUserIds = ref([])
|
||||
// 已存在工号缓存
|
||||
const existWorkerNos = ref([])
|
||||
// 用户检索关键词
|
||||
const userSearchKey = ref('')
|
||||
|
||||
// 过滤后的用户列表(账号/昵称/手机号模糊检索)
|
||||
const filterUserList = computed(() => {
|
||||
const key = userSearchKey.value.trim()
|
||||
if (!key) return allUserList.value
|
||||
return allUserList.value.filter(item =>
|
||||
item.userName?.includes(key) ||
|
||||
item.nickName?.includes(key) ||
|
||||
item.phonenumber?.includes(key)
|
||||
)
|
||||
})
|
||||
// 表格ref
|
||||
const userSelectTableRef = ref(null)
|
||||
|
||||
// 同步选中的用户ID
|
||||
function handleUserSelectionChange(selection) {
|
||||
selectedUserIds.value = selection.map(item => item.userId)
|
||||
}
|
||||
|
||||
|
||||
const rateOptions = ref([])
|
||||
|
||||
|
||||
const data = reactive({
|
||||
form: {},
|
||||
queryParams: {
|
||||
@@ -358,5 +405,86 @@ function submitImport() {
|
||||
})
|
||||
}
|
||||
|
||||
// 打开用户选择弹窗【修复空值初始化】
|
||||
async function openUserSelectDialog() {
|
||||
// 每次打开都严格初始化所有变量,避免 undefined
|
||||
allUserList.value = []
|
||||
selectedUserIds.value = []
|
||||
userSearchKey.value = ''
|
||||
|
||||
try {
|
||||
loading.value = true
|
||||
// 加载系统用户列表
|
||||
const userRes = await listUser({ pageNum: 1, pageSize: 9999, status: '0' })
|
||||
// 确保赋值为数组,避免 undefined
|
||||
allUserList.value = userRes?.rows || []
|
||||
} catch (err) {
|
||||
console.error("加载用户失败", err)
|
||||
proxy.$modal.msgError('加载用户列表失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
userSelectOpen.value = true
|
||||
}
|
||||
}
|
||||
// 确认导入选中用户【前端终极兜底 · 零报错】
|
||||
async function confirmImportSelectedUser() {
|
||||
if (!selectedUserIds.value?.length) {
|
||||
proxy.$modal.msgWarning('请至少选择一条用户')
|
||||
return
|
||||
}
|
||||
if (!filterUserList.value?.length) {
|
||||
proxy.$modal.msgWarning('用户列表为空,无法导入')
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
let success = 0, update = 0
|
||||
|
||||
try {
|
||||
// 1. 一次性查询所有已存在工号,构建Map
|
||||
const { rows: existWorkers } = await listWorker({ pageNum: 1, pageSize: 9999 })
|
||||
const existMap = new Map(existWorkers.map(w => [w.workerNo, w]))
|
||||
|
||||
// 2. 过滤有效用户
|
||||
const users = filterUserList.value.filter(u =>
|
||||
u?.userId && selectedUserIds.value.includes(u.userId)
|
||||
)
|
||||
|
||||
// 3. 分批次处理,避免并发冲突
|
||||
for (const user of users) {
|
||||
const workerNo = user.userName
|
||||
const data = {
|
||||
workerNo,
|
||||
workerName: user.nickName || user.userName,
|
||||
phone: user.phonenumber,
|
||||
status: '0',
|
||||
defaultBillingType: '1',
|
||||
defaultWorkTypeName: '普通工人',
|
||||
remark: '从系统用户导入'
|
||||
}
|
||||
|
||||
// 4. 严格判断:Map中存在 → 更新,不存在 → 新增
|
||||
if (existMap.has(workerNo)) {
|
||||
data.workerId = existMap.get(workerNo).workerId
|
||||
await updateWorker(data)
|
||||
update++
|
||||
} else {
|
||||
await addWorker(data)
|
||||
success++
|
||||
// 同步更新Map,避免后续重复判断
|
||||
existMap.set(workerNo, { workerNo })
|
||||
}
|
||||
}
|
||||
|
||||
proxy.$modal.msgSuccess(`导入完成:新增 ${success} 条,更新 ${update} 条`)
|
||||
userSelectOpen.value = false
|
||||
getList()
|
||||
} catch (err) {
|
||||
console.error('导入失败:', err)
|
||||
proxy.$modal.msgError('导入失败,请查看控制台日志')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
getList()
|
||||
</script>
|
||||
|
||||
@@ -501,6 +501,14 @@ function handleAdd() {
|
||||
function handleUpdate(row) {
|
||||
reset()
|
||||
const userId = row.userId || ids.value
|
||||
// let userId
|
||||
// if (row && row.userId) {
|
||||
// userId = row.userId
|
||||
// } else if (ids.value && ids.value.length > 0) {
|
||||
// userId = ids.value[0]
|
||||
// } else {
|
||||
// return
|
||||
// }
|
||||
getUser(userId).then(response => {
|
||||
form.value = response.data
|
||||
postOptions.value = response.data.posts
|
||||
@@ -509,7 +517,7 @@ function handleUpdate(row) {
|
||||
form.value.roleIds = response.data.roleIds
|
||||
open.value = true
|
||||
title.value = "修改用户"
|
||||
form.password = ""
|
||||
form.value.password = ""
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user