累计跟新
parent
e1da5981ce
commit
d2c41810c4
@ -0,0 +1,201 @@
|
||||
package com.ruoyi.web.controller.ehs;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.ruoyi.materialClass.domain.MaterialClass;
|
||||
import com.ruoyi.materialClass.domain.MaterialClassSub;
|
||||
import com.ruoyi.materialClass.service.IMaterialClassSubService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.materialClass.domain.MaterialClassMaster;
|
||||
import com.ruoyi.materialClass.service.IMaterialClassMasterService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 物资分类一级分类Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-01-05
|
||||
*/
|
||||
@Api(tags="物资分类一级分类管理")
|
||||
@RestController
|
||||
@RequestMapping("/materialClass/materialClassMaster")
|
||||
public class MaterialClassMasterController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IMaterialClassMasterService materialClassMastService;
|
||||
@Autowired
|
||||
private IMaterialClassSubService materialClassSubService;
|
||||
/**
|
||||
* 查询物资分类一级分类列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('materialClass:materialClassMaster:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(MaterialClassMaster materialClassMast)
|
||||
{
|
||||
startPage();
|
||||
List<MaterialClassMaster> list = materialClassMastService.selectMaterialClassMastList(materialClassMast);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出物资分类一级分类列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('materialClass:materialClassMaster:export')")
|
||||
@Log(title = "物资分类一级分类", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, MaterialClassMaster materialClassMast)
|
||||
{
|
||||
List<MaterialClassMaster> list = materialClassMastService.selectMaterialClassMastList(materialClassMast);
|
||||
ExcelUtil<MaterialClassMaster> util = new ExcelUtil<MaterialClassMaster>(MaterialClassMaster.class);
|
||||
util.exportExcel(response, list, "物资分类一级分类数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取物资分类一级分类详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('materialClass:materialClassMaster:query')")
|
||||
@GetMapping(value = "/{classMastId}")
|
||||
public AjaxResult getInfo(@PathVariable("classMastId") String classMastId)
|
||||
{
|
||||
return success(materialClassMastService.selectMaterialClassMastByClassMastId(classMastId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增物资分类一级分类
|
||||
*/
|
||||
@ApiOperation("新增物资分类一级分类")
|
||||
@PreAuthorize("@ss.hasPermi('materialClass:materialClassMaster:add')")
|
||||
@Log(title = "物资分类一级分类", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody MaterialClassMaster materialClassMast)
|
||||
{
|
||||
return toAjax(materialClassMastService.insertMaterialClassMast(materialClassMast));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改物资分类一级分类
|
||||
*/
|
||||
@ApiOperation("修改物资分类一级分类")
|
||||
@PreAuthorize("@ss.hasPermi('materialClass:materialClassMaster:edit')")
|
||||
@Log(title = "物资分类一级分类", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody MaterialClassMaster materialClassMast)
|
||||
{
|
||||
return toAjax(materialClassMastService.updateMaterialClassMast(materialClassMast));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除物资分类一级分类
|
||||
*/
|
||||
@ApiOperation("删除物资分类一级分类")
|
||||
@PreAuthorize("@ss.hasPermi('materialClass:materialClassMaster:remove')")
|
||||
@Log(title = "物资分类一级分类", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable String[] ids)
|
||||
{
|
||||
return toAjax(materialClassMastService.deleteMaterialClassMastByClassMastIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除物资分类一级分类
|
||||
*/
|
||||
@ApiOperation("获取分类的json字符串")
|
||||
@GetMapping(value = "/getMaterialClassJson/{id}")
|
||||
public String getMaterialClassJson(@PathVariable String id) throws JsonProcessingException {
|
||||
MaterialClassMaster msm = new MaterialClassMaster();
|
||||
msm.setClassMastType(id);
|
||||
List<MaterialClassMaster> list = materialClassMastService.selectMaterialClassMastList(msm);
|
||||
List<MaterialClass> mcList = new ArrayList<>();
|
||||
for(MaterialClassMaster mcm :list){
|
||||
MaterialClass mc = new MaterialClass();
|
||||
mc.setLabel(mcm.getClassNameMast());
|
||||
mc.setValue(mcm.getClassMastId());
|
||||
MaterialClassSub mcs = new MaterialClassSub();
|
||||
mcs.setMastId(mcm.getId());
|
||||
List<MaterialClassSub> sublist = materialClassSubService.selectMaterialClassSubList(mcs);
|
||||
List<MaterialClass> mcSubList = new ArrayList<>();
|
||||
for(MaterialClassSub mcss:sublist){
|
||||
MaterialClass mcsub = new MaterialClass();
|
||||
mcsub.setLabel(mcss.getClassNameSub());
|
||||
mcsub.setValue(mcss.getClassSubId());
|
||||
mcSubList.add(mcsub);
|
||||
}
|
||||
mc.setChildren(mcSubList);
|
||||
mcList.add(mc);
|
||||
}
|
||||
//String jsion = JSONUtil.toJsonStr(list);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jsonStr = objectMapper.writeValueAsString(mcList);
|
||||
System.out.println(jsonStr);
|
||||
return jsonStr;
|
||||
}
|
||||
@ApiOperation("获取分类的json字符串")
|
||||
@PostMapping(value = "/setMaterialClassJson")
|
||||
public String setMaterialClassJson(MaterialClassMaster materialClassMaster) throws IOException {
|
||||
String jsonStr = materialClassMaster.getClassNameMast();
|
||||
/*for(MaterialClass mc :mcList){
|
||||
MaterialClassMaster mcm = new MaterialClassMaster();
|
||||
mcm.setClassMastType(id);
|
||||
mcm.setClassMastId(mc.getValue());
|
||||
mcm.setClassNameMast(mc.getLabel());
|
||||
}*/
|
||||
for(int m=2;m<=8;m++) {
|
||||
InputStreamReader isr = new InputStreamReader(new FileInputStream("C:\\materialClass"+m+".json"), "utf8");
|
||||
BufferedReader br = new BufferedReader(isr);
|
||||
StringBuffer resposeBuffer = new StringBuffer("");
|
||||
String lineTxt = null;
|
||||
String s = "";
|
||||
//将文件内容全部拼接到 字符串s
|
||||
while ((lineTxt = br.readLine()) != null) {
|
||||
s += lineTxt;
|
||||
}
|
||||
JSONArray array = (JSONArray) JSONUtil.parseArray(s); // 将JSON字符串转换为JSONArray对象
|
||||
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
cn.hutool.json.JSONObject obj = array.getJSONObject(i);
|
||||
MaterialClassMaster mcm = new MaterialClassMaster();
|
||||
mcm.setClassMastType(String.valueOf(m));
|
||||
mcm.setClassMastId(obj.getStr("value"));
|
||||
mcm.setClassNameMast(obj.getStr("label"));
|
||||
materialClassMastService.insertMaterialClassMast(mcm);
|
||||
JSONArray subArray = obj.getJSONArray("children");
|
||||
for (int j = 0; j < subArray.size(); j++) {
|
||||
cn.hutool.json.JSONObject subObj = subArray.getJSONObject(j);
|
||||
MaterialClassSub sub = new MaterialClassSub();
|
||||
sub.setClassMastId(obj.getStr("value"));
|
||||
sub.setClassSubId(subObj.getStr("value"));
|
||||
sub.setClassNameSub(subObj.getStr("label"));
|
||||
sub.setClassMastType(mcm.getClassMastType());
|
||||
sub.setMastId(mcm.getId());
|
||||
materialClassSubService.save(sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
return "ok";
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,13 @@
|
||||
package com.ruoyi.materialClass.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class MaterialClass {
|
||||
private String value;
|
||||
private String label;
|
||||
List<MaterialClass> children;
|
||||
}
|
||||
|
@ -0,0 +1,49 @@
|
||||
package com.ruoyi.materialClass.domain;
|
||||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 物资分类一级分类对象 material_class_master
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-01-05
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@TableName("material_class_master")
|
||||
public class MaterialClassMaster extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 分类编号 */
|
||||
@Excel(name = "分类编号")
|
||||
private String classMastId;
|
||||
|
||||
/** 主键 */
|
||||
@TableId(type= IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 分类的大类 */
|
||||
@Excel(name = "分类的大类")
|
||||
private String classMastType;
|
||||
|
||||
/** 分类名称 */
|
||||
@Excel(name = "分类名称")
|
||||
private String classNameMast;
|
||||
|
||||
/** 物资分类-二级分类信息 */
|
||||
@TableField(exist = false)
|
||||
private List<MaterialClassSub> materialClassSubList;
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.ruoyi.materialClass.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 物资分类-二级分类对象 material_class_sub
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-01-05
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@TableName("material_class_sub")
|
||||
//@ApiModel(value = "MaterialClassSub", description = "物资分类-二级分类实体")
|
||||
public class MaterialClassSub extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 二级分类主键 */
|
||||
@Excel(name = "二级分类主键")
|
||||
// @ApiModelProperty("二级分类主键")
|
||||
private String classSubId;
|
||||
/** 分类的大类 */
|
||||
@Excel(name = "分类的大类")
|
||||
private String classMastType;
|
||||
/** 上级分类主键 */
|
||||
@Excel(name = "上级分类主键")
|
||||
// @ApiModelProperty("上级分类主键")
|
||||
private String classMastId;
|
||||
// @ApiModelProperty("上级分类主键")
|
||||
private Long mastId;
|
||||
/** 二级分类名称 */
|
||||
@Excel(name = "二级分类名称")
|
||||
// @ApiModelProperty("二级分类名称")
|
||||
private String classNameSub;
|
||||
|
||||
/** 主键 */
|
||||
@TableId(type= IdType.AUTO)
|
||||
// @ApiModelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.ruoyi.materialClass.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.materialClass.domain.MaterialClassMaster;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 物资分类一级分类Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-01-05
|
||||
*/
|
||||
public interface MaterialClassMasterMapper extends BaseMapper<MaterialClassMaster> {
|
||||
/**
|
||||
* 查询物资分类一级分类
|
||||
*
|
||||
* @param classMastId 物资分类一级分类主键
|
||||
* @return 物资分类一级分类
|
||||
*/
|
||||
public MaterialClassMaster selectMaterialClassMastByClassMastId(String classMastId);
|
||||
|
||||
/**
|
||||
* 查询物资分类一级分类列表
|
||||
*
|
||||
* @param materialClassMast 物资分类一级分类
|
||||
* @return 物资分类一级分类集合
|
||||
*/
|
||||
public List<MaterialClassMaster> selectMaterialClassMastList(MaterialClassMaster materialClassMast);
|
||||
|
||||
/**
|
||||
* 删除物资分类一级分类信息
|
||||
*
|
||||
* @param classMastId 物资分类一级分类主键
|
||||
* @return 结果
|
||||
*//*
|
||||
int deleteMaterialClassSubByClassMastId(@Param("classMastId")String classMastId);
|
||||
|
||||
*//**
|
||||
* 批量新增物资分类-二级分类
|
||||
*
|
||||
* @param materialClassSubList 物资分类-二级分类列表
|
||||
* @return 结果
|
||||
*//*
|
||||
int batchInsertMaterialClassSub(List<MaterialClassSub> materialClassSubList);*/
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.ruoyi.materialClass.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.materialClass.domain.MaterialClassSub;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 物资分类-二级分类Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-01-04
|
||||
*/
|
||||
public interface MaterialClassSubMapper extends BaseMapper<MaterialClassSub> {
|
||||
/**
|
||||
* 查询物资分类-二级分类
|
||||
*
|
||||
* @param classSubId 物资分类-二级分类主键
|
||||
* @return 物资分类-二级分类
|
||||
*/
|
||||
public MaterialClassSub selectMaterialClassSubByClassSubId(String classSubId);
|
||||
|
||||
/**
|
||||
* 查询物资分类-二级分类列表
|
||||
*
|
||||
* @param materialClassSub 物资分类-二级分类
|
||||
* @return 物资分类-二级分类集合
|
||||
*/
|
||||
public List<MaterialClassSub> selectMaterialClassSubList(MaterialClassSub materialClassSub);
|
||||
|
||||
public int deleteMaterialClassSubByClassMastId(String classMastId);
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.ruoyi.materialClass.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.materialClass.domain.MaterialClassMaster;
|
||||
|
||||
/**
|
||||
* 物资分类一级分类Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-01-05
|
||||
*/
|
||||
public interface IMaterialClassMasterService extends IService<MaterialClassMaster> {
|
||||
|
||||
/**
|
||||
* 查询物资分类一级分类
|
||||
*
|
||||
* @param classMastId 物资分类一级分类主键
|
||||
* @return 物资分类一级分类
|
||||
*/
|
||||
public MaterialClassMaster selectMaterialClassMastByClassMastId(String classMastId);
|
||||
|
||||
/**
|
||||
* 查询物资分类一级分类列表
|
||||
*
|
||||
* @param materialClassMast 物资分类一级分类
|
||||
* @return 物资分类一级分类集合
|
||||
*/
|
||||
public List<MaterialClassMaster> selectMaterialClassMastList(MaterialClassMaster materialClassMast);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 新增物资分类一级分类
|
||||
*
|
||||
* @param materialClassMast 物资分类一级分类
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertMaterialClassMast(MaterialClassMaster materialClassMast);
|
||||
|
||||
/**
|
||||
* 修改物资分类一级分类
|
||||
*
|
||||
* @param materialClassMast 物资分类一级分类
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateMaterialClassMast(MaterialClassMaster materialClassMast);
|
||||
|
||||
/**
|
||||
* 批量删除物资分类一级分类
|
||||
*
|
||||
* @param classMastIds 需要删除的物资分类一级分类主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMaterialClassMastByClassMastIds(String[] classMastIds);
|
||||
|
||||
/**
|
||||
* 删除物资分类一级分类信息
|
||||
*
|
||||
* @param classMastId 物资分类一级分类主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMaterialClassMastByClassMastId(String classMastId);
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.ruoyi.materialClass.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.materialClass.domain.MaterialClassSub;
|
||||
|
||||
/**
|
||||
* 物资分类-二级分类Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-01-04
|
||||
*/
|
||||
public interface IMaterialClassSubService extends IService<MaterialClassSub> {
|
||||
|
||||
/**
|
||||
* 查询物资分类-二级分类
|
||||
*
|
||||
* @param classSubId 物资分类-二级分类主键
|
||||
* @return 物资分类-二级分类
|
||||
*/
|
||||
public MaterialClassSub selectMaterialClassSubByClassSubId(String classSubId);
|
||||
|
||||
/**
|
||||
* 查询物资分类-二级分类列表
|
||||
*
|
||||
* @param materialClassSub 物资分类-二级分类
|
||||
* @return 物资分类-二级分类集合
|
||||
*/
|
||||
public List<MaterialClassSub> selectMaterialClassSubList(MaterialClassSub materialClassSub);
|
||||
|
||||
}
|
@ -0,0 +1,157 @@
|
||||
package com.ruoyi.materialClass.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.materialClass.mapper.MaterialClassSubMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Arrays;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.ruoyi.materialClass.domain.MaterialClassSub;
|
||||
import com.ruoyi.materialClass.mapper.MaterialClassMasterMapper;
|
||||
import com.ruoyi.materialClass.domain.MaterialClassMaster;
|
||||
import com.ruoyi.materialClass.service.IMaterialClassMasterService;
|
||||
|
||||
/**
|
||||
* 物资分类一级分类Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-01-05
|
||||
*/
|
||||
@Service
|
||||
public class MaterialClassMasterServiceImpl extends ServiceImpl<MaterialClassMasterMapper, MaterialClassMaster> implements IMaterialClassMasterService {
|
||||
|
||||
@Autowired
|
||||
private MaterialClassMasterMapper materialClassMastMapper;
|
||||
@Autowired
|
||||
private MaterialClassSubMapper materialClassSubMapper;
|
||||
/**
|
||||
* 查询物资分类一级分类
|
||||
*
|
||||
* @param classMastId 物资分类一级分类主键
|
||||
* @return 物资分类一级分类
|
||||
*/
|
||||
@Override
|
||||
public MaterialClassMaster selectMaterialClassMastByClassMastId(String classMastId)
|
||||
{
|
||||
MaterialClassMaster materialClassMaster = materialClassMastMapper.selectMaterialClassMastByClassMastId(classMastId);
|
||||
/*MaterialClassSub sub = new MaterialClassSub();
|
||||
sub.setClassMastId(materialClassMaster.getClassMastId());
|
||||
List<MaterialClassSub> subs = materialClassSubMapper.selectMaterialClassSubList(sub);
|
||||
materialClassMaster.setMaterialClassSubList(subs);*/
|
||||
return materialClassMaster;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询物资分类一级分类列表
|
||||
*
|
||||
* @param materialClassMast 物资分类一级分类
|
||||
* @return 物资分类一级分类
|
||||
*/
|
||||
@Override
|
||||
public List<MaterialClassMaster> selectMaterialClassMastList(MaterialClassMaster materialClassMast)
|
||||
{
|
||||
return materialClassMastMapper.selectMaterialClassMastList(materialClassMast);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增物资分类一级分类
|
||||
*
|
||||
* @param materialClassMast 物资分类一级分类
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public int insertMaterialClassMast(MaterialClassMaster materialClassMast)
|
||||
{
|
||||
int rows = materialClassMastMapper.insert(materialClassMast);
|
||||
insertMaterialClassSub(materialClassMast);
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改物资分类一级分类
|
||||
*
|
||||
* @param materialClassMast 物资分类一级分类
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public int updateMaterialClassMast(MaterialClassMaster materialClassMast)
|
||||
{
|
||||
materialClassSubMapper.deleteMaterialClassSubByClassMastId( materialClassMast.getId().toString());
|
||||
insertMaterialClassSub(materialClassMast);
|
||||
return materialClassMastMapper.updateById(materialClassMast);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除物资分类一级分类
|
||||
*
|
||||
* @param classMastIds 需要删除的物资分类一级分类主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public int deleteMaterialClassMastByClassMastIds(String[] classMastIds)
|
||||
{
|
||||
List<String> classMastIdList = Arrays.asList(classMastIds);
|
||||
for (String classMastId : classMastIdList) {
|
||||
materialClassSubMapper.deleteMaterialClassSubByClassMastId(classMastId);
|
||||
}
|
||||
return materialClassMastMapper.deleteBatchIds(classMastIdList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除物资分类一级分类信息
|
||||
*
|
||||
* @param classMastId 物资分类一级分类主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public int deleteMaterialClassMastByClassMastId(String classMastId)
|
||||
{
|
||||
materialClassSubMapper.deleteMaterialClassSubByClassMastId(classMastId);
|
||||
return materialClassMastMapper.deleteById(classMastId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增物资分类-二级分类信息
|
||||
*
|
||||
* @param materialClassMast 物资分类一级分类对象
|
||||
*/
|
||||
private void insertMaterialClassSub(MaterialClassMaster materialClassMast)
|
||||
{
|
||||
List<MaterialClassSub> materialClassSubList = materialClassMast.getMaterialClassSubList();
|
||||
String classMastId = materialClassMast.getClassMastId();
|
||||
Long mastId = materialClassMast.getId();
|
||||
String classMastType = materialClassMast.getClassMastType();
|
||||
if (StringUtils.isNotNull(materialClassSubList)) {
|
||||
for (MaterialClassSub materialClassSub : materialClassSubList) {
|
||||
materialClassSub.setClassMastId(classMastId);
|
||||
materialClassSub.setMastId(mastId);
|
||||
materialClassSub.setClassMastType(classMastType);
|
||||
materialClassSubMapper.insert(materialClassSub);
|
||||
}
|
||||
//materialClassMastMapper.batchInsertMaterialClassSub(materialClassSubList);
|
||||
}
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<MaterialClassMaster> buildQueryWrapper(MaterialClassMaster query) {
|
||||
Map<String, Object> params = query.getParams();
|
||||
LambdaQueryWrapper<MaterialClassMaster> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(StringUtils.isNotBlank(query.getClassMastId()), MaterialClassMaster::getClassMastId, query.getClassMastId());
|
||||
lqw.eq(StringUtils.isNotBlank(query.getClassMastType()), MaterialClassMaster::getClassMastType, query.getClassMastType());
|
||||
lqw.eq(StringUtils.isNotBlank(query.getClassNameMast()), MaterialClassMaster::getClassNameMast, query.getClassNameMast());
|
||||
lqw.orderByDesc(MaterialClassMaster::getCreateTime);
|
||||
lqw.eq(query.getDeptId() != null, MaterialClassMaster::getDeptId, query.getDeptId());
|
||||
lqw.eq(query.getCreateUserId() != null, MaterialClassMaster::getCreateUserId, query.getCreateUserId());
|
||||
lqw.eq(query.getUpdateUserId() != null, MaterialClassMaster::getUpdateUserId, query.getUpdateUserId());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package com.ruoyi.materialClass.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.ruoyi.materialClass.mapper.MaterialClassSubMapper;
|
||||
import com.ruoyi.materialClass.domain.MaterialClassSub;
|
||||
import com.ruoyi.materialClass.service.IMaterialClassSubService;
|
||||
|
||||
/**
|
||||
* 物资分类-二级分类Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-01-04
|
||||
*/
|
||||
@Service
|
||||
public class MaterialClassSubServiceImpl extends ServiceImpl<MaterialClassSubMapper, MaterialClassSub> implements IMaterialClassSubService {
|
||||
|
||||
@Autowired
|
||||
private MaterialClassSubMapper materialClassSubMapper;
|
||||
|
||||
/**
|
||||
* 查询物资分类-二级分类
|
||||
*
|
||||
* @param classSubId 物资分类-二级分类主键
|
||||
* @return 物资分类-二级分类
|
||||
*/
|
||||
@Override
|
||||
public MaterialClassSub selectMaterialClassSubByClassSubId(String classSubId)
|
||||
{
|
||||
return materialClassSubMapper.selectMaterialClassSubByClassSubId(classSubId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询物资分类-二级分类列表
|
||||
*
|
||||
* @param materialClassSub 物资分类-二级分类
|
||||
* @return 物资分类-二级分类
|
||||
*/
|
||||
@Override
|
||||
public List<MaterialClassSub> selectMaterialClassSubList(MaterialClassSub materialClassSub)
|
||||
{
|
||||
return materialClassSubMapper.selectMaterialClassSubList(materialClassSub);
|
||||
}
|
||||
|
||||
|
||||
private LambdaQueryWrapper<MaterialClassSub> buildQueryWrapper(MaterialClassSub query) {
|
||||
Map<String, Object> params = query.getParams();
|
||||
LambdaQueryWrapper<MaterialClassSub> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(StringUtils.isNotBlank(query.getClassMastId()), MaterialClassSub::getClassMastId, query.getClassMastId());
|
||||
lqw.like(StringUtils.isNotBlank(query.getClassNameSub()), MaterialClassSub::getClassNameSub, query.getClassNameSub());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.materialClass.mapper.MaterialClassMasterMapper">
|
||||
|
||||
<resultMap type="MaterialClassMaster" id="MaterialClassMastResult">
|
||||
<result property="classMastId" column="class_mast_id" />
|
||||
<result property="id" column="id" />
|
||||
<result property="classMastType" column="class_mast_type" />
|
||||
<result property="classNameMast" column="class_name_mast" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
<result property="createUserId" column="create_user_id" />
|
||||
<result property="updateUserId" column="update_user_id" />
|
||||
<result property="classCount" column="class_count" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="MaterialClassMastMaterialClassSubResult" type="MaterialClassMaster" extends="MaterialClassMastResult">
|
||||
<collection property="materialClassSubList" notNullColumn="sub_class_sub_id" javaType="java.util.List" resultMap="MaterialClassSubResult" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="MaterialClassSub" id="MaterialClassSubResult">
|
||||
<result property="classSubId" column="sub_class_sub_id" />
|
||||
<result property="classMastId" column="sub_class_mast_id" />
|
||||
<result property="classMastType" column="class_mast_type" />
|
||||
<result property="classNameSub" column="sub_class_name_sub" />
|
||||
<result property="createBy" column="sub_create_by" />
|
||||
<result property="createTime" column="sub_create_time" />
|
||||
<result property="updateBy" column="sub_update_by" />
|
||||
<result property="updateTime" column="sub_update_time" />
|
||||
<result property="remark" column="sub_remark" />
|
||||
<result property="deptId" column="sub_dept_id" />
|
||||
<result property="createUserId" column="sub_create_user_id" />
|
||||
<result property="updateUserId" column="sub_update_user_id" />
|
||||
<result property="id" column="sub_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectMaterialClassMastVo">
|
||||
select class_mast_id, id, class_mast_type, class_name_mast, create_by, create_time, update_by, update_time,
|
||||
remark, dept_id, create_user_id, update_user_id,(select count(1) from material_class_sub b where a.id=b.mast_id ) class_count from material_class_master a
|
||||
</sql>
|
||||
|
||||
<select id="selectMaterialClassMastList" parameterType="MaterialClassMaster" resultMap="MaterialClassMastResult">
|
||||
<include refid="selectMaterialClassMastVo"/>
|
||||
<where>
|
||||
<if test="classMastId != null and classMastId != ''"> and class_mast_id = #{classMastId}</if>
|
||||
<if test="classMastType != null and classMastType != ''"> and class_mast_type = #{classMastType}</if>
|
||||
<if test="classNameMast != null and classNameMast != ''"> and class_name_mast = #{classNameMast}</if>
|
||||
<if test="deptId != null "> and dept_id = #{deptId}</if>
|
||||
<if test="createUserId != null "> and create_user_id = #{createUserId}</if>
|
||||
<if test="updateUserId != null "> and update_user_id = #{updateUserId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectMaterialClassMastByClassMastId" parameterType="String" resultMap="MaterialClassMastMaterialClassSubResult">
|
||||
select a.class_mast_id, a.id, a.class_mast_type, a.class_name_mast, a.create_by, a.create_time, a.update_by, a.update_time, a.remark, a.dept_id, a.create_user_id, a.update_user_id,
|
||||
b.class_sub_id as sub_class_sub_id, b.class_mast_id as sub_class_mast_id, b.class_name_sub as sub_class_name_sub, b.create_by as sub_create_by, b.create_time as sub_create_time, b.update_by as sub_update_by, b.update_time as sub_update_time, b.remark as sub_remark, b.dept_id as sub_dept_id, b.create_user_id as sub_create_user_id, b.update_user_id as sub_update_user_id, b.id as sub_id
|
||||
from material_class_master a
|
||||
left join material_class_sub b on b.mast_id = a.id
|
||||
where a.id = #{classMastId}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.materialClass.mapper.MaterialClassSubMapper">
|
||||
|
||||
<resultMap type="MaterialClassSub" id="MaterialClassSubResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="mastId" column="mast_id" />
|
||||
<result property="classMastType" column="class_mast_type" />
|
||||
<result property="classMastId" column="class_mast_id" />
|
||||
<result property="classSubId" column="class_sub_id" />
|
||||
<result property="classNameSub" column="class_name_sub" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
<result property="createUserId" column="create_user_id" />
|
||||
<result property="updateUserId" column="update_user_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectMaterialClassSubVo">
|
||||
select class_sub_id, class_mast_id, class_name_sub from material_class_sub
|
||||
</sql>
|
||||
|
||||
<select id="selectMaterialClassSubList" parameterType="MaterialClassSub" resultMap="MaterialClassSubResult">
|
||||
<include refid="selectMaterialClassSubVo"/>
|
||||
<where>
|
||||
<if test="mastId != null "> and mast_id = #{mastId}</if>
|
||||
<if test="classMastType != null and classMastType != ''"> and class_mast_type = #{classMastType}</if>
|
||||
<if test="classMastId != null and classMastId != ''"> and class_mast_id = #{classMastId}</if>
|
||||
<if test="classSubId != null and classSubId != ''"> and class_sub_id = #{classSubId}</if>
|
||||
<if test="classNameSub != null and classNameSub != ''"> and class_name_sub like concat('%', #{classNameSub}, '%')</if>
|
||||
<if test="deptId != null "> and dept_id = #{deptId}</if>
|
||||
<if test="createUserId != null "> and create_user_id = #{createUserId}</if>
|
||||
<if test="updateUserId != null "> and update_user_id = #{updateUserId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectMaterialClassSubByClassSubId" parameterType="String" resultMap="MaterialClassSubResult">
|
||||
<include refid="selectMaterialClassSubVo"/>
|
||||
where class_sub_id = #{classSubId}
|
||||
</select>
|
||||
|
||||
<delete id="deleteMaterialClassSubByClassMastId" parameterType="String">
|
||||
delete
|
||||
from material_class_sub
|
||||
where mast_id = #{classMastId}
|
||||
</delete>
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,62 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询物资分类一级分类列表
|
||||
export function listMaterialClass(query) {
|
||||
return request({
|
||||
url: '/materialClass/materialClassMaster/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询物资分类一级分类详细
|
||||
export function getMaterialClass(classMastId) {
|
||||
return request({
|
||||
url: '/materialClass/materialClassMaster/' + classMastId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增物资分类一级分类
|
||||
export function addMaterialClass(data) {
|
||||
return request({
|
||||
url: '/materialClass/materialClassMaster',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改物资分类一级分类
|
||||
export function updateMaterialClass(data) {
|
||||
return request({
|
||||
url: '/materialClass/materialClassMaster',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除物资分类一级分类
|
||||
export function delMaterialClass(classMastId) {
|
||||
return request({
|
||||
url: '/materialClass/materialClassMaster/' + classMastId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 按大类获取json
|
||||
export function getMaterialClassJson(typeId) {
|
||||
return request({
|
||||
url: '/materialClass/materialClassMaster/getMaterialClassJson/' + typeId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 根据json保存
|
||||
export function setMaterialClassJson(data) {
|
||||
return request({
|
||||
url: '/materialClass/materialClassMaster/setMaterialClassJson' ,
|
||||
method: 'post',
|
||||
params: data
|
||||
})
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询物资分类-二级分类列表
|
||||
export function listMaterialClass(query) {
|
||||
return request({
|
||||
url: '/materialClass/materialClassSub/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询物资分类-二级分类详细
|
||||
export function getMaterialClass(classSubId) {
|
||||
return request({
|
||||
url: '/materialClass/materialClassSub/' + classSubId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增物资分类-二级分类
|
||||
export function addMaterialClass(data) {
|
||||
return request({
|
||||
url: '/materialClass/materialClassSub',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改物资分类-二级分类
|
||||
export function updateMaterialClass(data) {
|
||||
return request({
|
||||
url: '/materialClass/materialClassSub',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除物资分类-二级分类
|
||||
export function delMaterialClass(classSubId) {
|
||||
return request({
|
||||
url: '/materialClass/materialClassSub/' + classSubId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
@ -1,216 +0,0 @@
|
||||
<template>
|
||||
<div class="upload-file">
|
||||
<el-upload
|
||||
multiple
|
||||
:action="uploadFileUrl"
|
||||
:before-upload="handleBeforeUpload"
|
||||
:file-list="fileList"
|
||||
:limit="limit"
|
||||
:on-error="handleUploadError"
|
||||
:on-exceed="handleExceed"
|
||||
:on-success="handleUploadSuccess"
|
||||
:show-file-list="false"
|
||||
:headers="headers"
|
||||
class="upload-file-uploader"
|
||||
ref="fileUpload"
|
||||
>
|
||||
<!-- 上传按钮 -->
|
||||
<el-button size="mini" type="primary">选取文件</el-button>
|
||||
<!-- 上传提示 -->
|
||||
<div class="el-upload__tip" slot="tip" v-if="showTip">
|
||||
请上传
|
||||
<template v-if="fileSize"> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>
|
||||
<template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>
|
||||
的文件
|
||||
</div>
|
||||
</el-upload>
|
||||
|
||||
<!-- 文件列表 -->
|
||||
<transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
|
||||
<li :key="file.url" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList">
|
||||
<el-link :href="`${baseUrl}${file.url}`" :underline="false" target="_blank">
|
||||
<span class="el-icon-document"> {{ getFileName(file.name) }} </span>
|
||||
</el-link>
|
||||
<div class="ele-upload-list__item-content-action">
|
||||
<el-link :underline="false" @click="handleDelete(index)" type="danger">删除</el-link>
|
||||
</div>
|
||||
</li>
|
||||
</transition-group>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getToken } from "@/utils/auth";
|
||||
|
||||
export default {
|
||||
name: "FileUpload",
|
||||
props: {
|
||||
// 值
|
||||
value: [String, Object, Array],
|
||||
// 数量限制
|
||||
limit: {
|
||||
type: Number,
|
||||
default: 5,
|
||||
},
|
||||
// 大小限制(MB)
|
||||
fileSize: {
|
||||
type: Number,
|
||||
default: 5,
|
||||
},
|
||||
// 文件类型, 例如['png', 'jpg', 'jpeg']
|
||||
fileType: {
|
||||
type: Array,
|
||||
default: () => ["doc", "xls", "ppt", "txt", "pdf"],
|
||||
},
|
||||
// 是否显示提示
|
||||
isShowTip: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
number: 0,
|
||||
uploadList: [],
|
||||
baseUrl: process.env.VUE_APP_BASE_API,
|
||||
uploadFileUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传文件服务器地址
|
||||
headers: {
|
||||
Authorization: "Bearer " + getToken(),
|
||||
},
|
||||
fileList: [],
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
value: {
|
||||
handler(val) {
|
||||
if (val) {
|
||||
let temp = 1;
|
||||
// 首先将值转为数组
|
||||
const list = Array.isArray(val) ? val : this.value.split(',');
|
||||
// 然后将数组转为对象数组
|
||||
this.fileList = list.map(item => {
|
||||
if (typeof item === "string") {
|
||||
item = { name: item, url: item };
|
||||
}
|
||||
item.uid = item.uid || new Date().getTime() + temp++;
|
||||
return item;
|
||||
});
|
||||
} else {
|
||||
this.fileList = [];
|
||||
return [];
|
||||
}
|
||||
},
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// 是否显示提示
|
||||
showTip() {
|
||||
return this.isShowTip && (this.fileType || this.fileSize);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
// 上传前校检格式和大小
|
||||
handleBeforeUpload(file) {
|
||||
// 校检文件类型
|
||||
if (this.fileType) {
|
||||
const fileName = file.name.split('.');
|
||||
const fileExt = fileName[fileName.length - 1];
|
||||
const isTypeOk = this.fileType.indexOf(fileExt) >= 0;
|
||||
if (!isTypeOk) {
|
||||
this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// 校检文件大小
|
||||
if (this.fileSize) {
|
||||
const isLt = file.size / 1024 / 1024 < this.fileSize;
|
||||
if (!isLt) {
|
||||
this.$modal.msgError(`上传文件大小不能超过 ${this.fileSize} MB!`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
this.$modal.loading("正在上传文件,请稍候...");
|
||||
this.number++;
|
||||
return true;
|
||||
},
|
||||
// 文件个数超出
|
||||
handleExceed() {
|
||||
this.$modal.msgError(`上传文件数量不能超过 ${this.limit} 个!`);
|
||||
},
|
||||
// 上传失败
|
||||
handleUploadError(err) {
|
||||
this.$modal.msgError("上传文件失败,请重试");
|
||||
this.$modal.closeLoading();
|
||||
},
|
||||
// 上传成功回调
|
||||
handleUploadSuccess(res, file) {
|
||||
if (res.code === 200) {
|
||||
this.uploadList.push({ name: res.fileName, url: res.fileName });
|
||||
this.uploadedSuccessfully();
|
||||
} else {
|
||||
this.number--;
|
||||
this.$modal.closeLoading();
|
||||
this.$modal.msgError(res.msg);
|
||||
this.$refs.fileUpload.handleRemove(file);
|
||||
this.uploadedSuccessfully();
|
||||
}
|
||||
},
|
||||
// 删除文件
|
||||
handleDelete(index) {
|
||||
this.fileList.splice(index, 1);
|
||||
this.$emit("input", this.listToString(this.fileList));
|
||||
},
|
||||
// 上传结束处理
|
||||
uploadedSuccessfully() {
|
||||
if (this.number > 0 && this.uploadList.length === this.number) {
|
||||
this.fileList = this.fileList.concat(this.uploadList);
|
||||
this.uploadList = [];
|
||||
this.number = 0;
|
||||
this.$emit("input", this.listToString(this.fileList));
|
||||
this.$modal.closeLoading();
|
||||
}
|
||||
},
|
||||
// 获取文件名称
|
||||
getFileName(name) {
|
||||
// 如果是url那么取最后的名字 如果不是直接返回
|
||||
if (name.lastIndexOf("/") > -1) {
|
||||
return name.slice(name.lastIndexOf("/") + 1);
|
||||
} else {
|
||||
return name;
|
||||
}
|
||||
},
|
||||
// 对象转成指定字符串分隔
|
||||
listToString(list, separator) {
|
||||
let strs = "";
|
||||
separator = separator || ",";
|
||||
for (let i in list) {
|
||||
strs += list[i].url + separator;
|
||||
}
|
||||
return strs != '' ? strs.substr(0, strs.length - 1) : '';
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.upload-file-uploader {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.upload-file-list .el-upload-list__item {
|
||||
border: 1px solid #e4e7ed;
|
||||
line-height: 2;
|
||||
margin-bottom: 10px;
|
||||
position: relative;
|
||||
}
|
||||
.upload-file-list .ele-upload-list__item-content {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
color: inherit;
|
||||
}
|
||||
.ele-upload-list__item-content-action .el-link {
|
||||
margin-right: 10px;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,398 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<!--<el-form-item label="分类编号" prop="classMastId">
|
||||
<el-input
|
||||
v-model="queryParams.classMastId"
|
||||
placeholder="请输入分类编号"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>-->
|
||||
<el-form-item label="基本分类" prop="classMastType">
|
||||
<el-select v-model="queryParams.classMastType" placeholder="请选择基本分类" clearable>
|
||||
<el-option
|
||||
v-for="dict in dict.type.material_class_fast"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!--<el-form-item label="分类名称" prop="classNameMast">
|
||||
<el-input
|
||||
v-model="queryParams.classNameMast"
|
||||
placeholder="请输入分类名称"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建者部门" prop="deptId">
|
||||
<el-input
|
||||
v-model="queryParams.deptId"
|
||||
placeholder="请输入创建者部门"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建者id" prop="createUserId">
|
||||
<el-input
|
||||
v-model="queryParams.createUserId"
|
||||
placeholder="请输入创建者id"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="修改着id" prop="updateUserId">
|
||||
<el-input
|
||||
v-model="queryParams.updateUserId"
|
||||
placeholder="请输入修改着id"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>-->
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['materialClass:materialClassMaster:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['materialClass:materialClassMaster:edit']"
|
||||
>修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['materialClass:materialClassMaster:remove']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['materialClass:materialClassMaster:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="materialClassList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="基本分类" align="center" prop="classMastType">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.material_class_fast" :value="scope.row.classMastType"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="分类编号" align="center" prop="classMastId" />
|
||||
<!--<el-table-column label="主键" align="center" prop="id" />-->
|
||||
|
||||
<el-table-column label="分类名称" align="center" prop="classNameMast" />
|
||||
<el-table-column label="子分类数量" align="center" prop="classCount" />
|
||||
<!--<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="创建者部门" align="center" prop="deptId" />-->
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['materialClass:materialClassMaster:edit']"
|
||||
>修改</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['materialClass:materialClassMaster:remove']"
|
||||
>删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改物资分类一级分类对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="基本大类" prop="classMastType" >
|
||||
<el-select v-model="form.classMastType" placeholder="请选择基本大类" :disabled="true">
|
||||
<el-option
|
||||
v-for="dict in dict.type.material_class_fast"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="分类编号" prop="classMastId">
|
||||
<el-input v-model="form.classMastId" placeholder="请输入分类编号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="分类名称" prop="classNameMast">
|
||||
<el-input v-model="form.classNameMast" placeholder="请输入分类名称" />
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>-->
|
||||
<el-divider content-position="center">二级分类信息</el-divider>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddMaterialClassSub">添加</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteMaterialClassSub">删除</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-table :data="materialClassSubList" :row-class-name="rowMaterialClassSubIndex" @selection-change="handleMaterialClassSubSelectionChange" ref="materialClassSub">
|
||||
<el-table-column type="selection" width="50" align="center" />
|
||||
<el-table-column label="序号" align="center" prop="index" width="50"/>
|
||||
<el-table-column label="分类编号" prop="classNameSub" width="180">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.classSubId" placeholder="请输入二级分类编号" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="分类名称" prop="classNameSub" width="220">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.classNameSub" placeholder="请输入二级分类名称" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
</el-table>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listMaterialClass, getMaterialClass, delMaterialClass, addMaterialClass, updateMaterialClass } from "@/api/ehs/materialClassMaster";
|
||||
|
||||
export default {
|
||||
name: "MaterialClass",
|
||||
dicts: ['material_class_fast'],
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 子表选中数据
|
||||
checkedMaterialClassSub: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 物资分类一级分类表格数据
|
||||
materialClassList: [],
|
||||
// 物资分类-二级分类表格数据
|
||||
materialClassSubList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
classMastId: null,
|
||||
classMastType: null,
|
||||
classNameMast: null,
|
||||
deptId: null,
|
||||
createUserId: null,
|
||||
updateUserId: null
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
classMastId: [
|
||||
{ required: true, message: "分类编号不能为空", trigger: "blur" }
|
||||
],
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询物资分类一级分类列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listMaterialClass(this.queryParams).then(response => {
|
||||
this.materialClassList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
classMastId: null,
|
||||
id: null,
|
||||
classMastType: null,
|
||||
classNameMast: null,
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
updateBy: null,
|
||||
updateTime: null,
|
||||
remark: null,
|
||||
deptId: null,
|
||||
createUserId: null,
|
||||
updateUserId: null
|
||||
};
|
||||
this.materialClassSubList = [];
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.id)
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加物资分类一级分类";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const classMastId = row.id || this.ids
|
||||
getMaterialClass(classMastId).then(response => {
|
||||
this.form = response.data;
|
||||
this.materialClassSubList = response.data.materialClassSubList;
|
||||
this.open = true;
|
||||
this.title = "修改物资分类一级分类";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
this.form.materialClassSubList = this.materialClassSubList;
|
||||
if (this.form.id != null) {
|
||||
updateMaterialClass(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addMaterialClass(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const classMastIds = row.id || this.ids;
|
||||
this.$modal.confirm('是否确认删除物资分类一级分类编号为"' + classMastIds + '"的数据项?').then(function() {
|
||||
return delMaterialClass(classMastIds);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
},
|
||||
/** 物资分类-二级分类序号 */
|
||||
rowMaterialClassSubIndex({ row, rowIndex }) {
|
||||
row.index = rowIndex + 1;
|
||||
},
|
||||
/** 物资分类-二级分类添加按钮操作 */
|
||||
handleAddMaterialClassSub() {
|
||||
let obj = {};
|
||||
obj.classMastId = "";
|
||||
obj.classNameSub = "";
|
||||
obj.remark = "";
|
||||
obj.deptId = "";
|
||||
this.materialClassSubList.push(obj);
|
||||
},
|
||||
/** 物资分类-二级分类删除按钮操作 */
|
||||
handleDeleteMaterialClassSub() {
|
||||
if (this.checkedMaterialClassSub.length == 0) {
|
||||
this.$modal.msgError("请先选择要删除的物资分类-二级分类数据");
|
||||
} else {
|
||||
const materialClassSubList = this.materialClassSubList;
|
||||
const checkedMaterialClassSub = this.checkedMaterialClassSub;
|
||||
this.materialClassSubList = materialClassSubList.filter(function(item) {
|
||||
return checkedMaterialClassSub.indexOf(item.index) == -1
|
||||
});
|
||||
}
|
||||
},
|
||||
/** 复选框选中数据 */
|
||||
handleMaterialClassSubSelectionChange(selection) {
|
||||
this.checkedMaterialClassSub = selection.map(item => item.index)
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('materialClass/materialClass/export', {
|
||||
...this.queryParams
|
||||
}, `materialClass_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,259 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="上级分类主键" prop="classMastId">
|
||||
<el-input
|
||||
v-model="queryParams.classMastId"
|
||||
placeholder="请输入上级分类主键"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="二级分类名称" prop="classNameSub">
|
||||
<el-input
|
||||
v-model="queryParams.classNameSub"
|
||||
placeholder="请输入二级分类名称"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['materialClass:materialClass:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['materialClass:materialClass:edit']"
|
||||
>修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['materialClass:materialClass:remove']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['materialClass:materialClass:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="materialClassList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="二级分类主键" align="center" prop="classSubId" />
|
||||
<el-table-column label="上级分类主键" align="center" prop="classMastId" />
|
||||
<el-table-column label="二级分类名称" align="center" prop="classNameSub" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['materialClass:materialClass:edit']"
|
||||
>修改</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['materialClass:materialClass:remove']"
|
||||
>删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改物资分类-二级分类对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="上级分类主键" prop="classMastId">
|
||||
<el-input v-model="form.classMastId" placeholder="请输入上级分类主键" />
|
||||
</el-form-item>
|
||||
<el-form-item label="二级分类名称" prop="classNameSub">
|
||||
<el-input v-model="form.classNameSub" placeholder="请输入二级分类名称" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listMaterialClass, getMaterialClass, delMaterialClass, addMaterialClass, updateMaterialClass } from "@/api/ehs/materialClassSub";
|
||||
|
||||
export default {
|
||||
name: "MaterialClass",
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 物资分类-二级分类表格数据
|
||||
materialClassList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
classMastId: null,
|
||||
classNameSub: null
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询物资分类-二级分类列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listMaterialClass(this.queryParams).then(response => {
|
||||
this.materialClassList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
classSubId: null,
|
||||
classMastId: null,
|
||||
classNameSub: null
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.classSubId)
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加物资分类-二级分类";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const classSubId = row.classSubId || this.ids
|
||||
getMaterialClass(classSubId).then(response => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改物资分类-二级分类";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.classSubId != null) {
|
||||
updateMaterialClass(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addMaterialClass(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const classSubIds = row.classSubId || this.ids;
|
||||
this.$modal.confirm('是否确认删除物资分类-二级分类编号为"' + classSubIds + '"的数据项?').then(function() {
|
||||
return delMaterialClass(classSubIds);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('materialClass/materialClass/export', {
|
||||
...this.queryParams
|
||||
}, `materialClass_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Reference in New Issue