Commit 0f0f04bd authored by 张兴海's avatar 张兴海

模板管理添加修改导入规则,优化状态代码

parent cc15ce74
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.ruoyi</groupId> <groupId>com.ruoyi</groupId>
<artifactId>ruoyi</artifactId> <artifactId>ruoyi</artifactId>
<version>3.4.0</version> <version>3.4.0</version>
...@@ -121,6 +122,14 @@ ...@@ -121,6 +122,14 @@
<version>${swagger.version}</version> <version>${swagger.version}</version>
</dependency> </dependency>
<!-- lombok的依赖项-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
<scope>provided</scope>
</dependency>
<!--io常用工具类 --> <!--io常用工具类 -->
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
......
...@@ -10,6 +10,7 @@ import com.ruoyi.common.utils.SecurityUtils; ...@@ -10,6 +10,7 @@ import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.ActSupplies; import com.ruoyi.system.domain.ActSupplies;
import com.ruoyi.system.service.IActSuppliesService; import com.ruoyi.system.service.IActSuppliesService;
import com.ruoyi.system.web.ServiceCode;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -164,20 +165,24 @@ public class ActSuppliesController extends BaseController ...@@ -164,20 +165,24 @@ public class ActSuppliesController extends BaseController
* 启用物料总分类管理 * 启用物料总分类管理
*/ */
@PreAuthorize("@ss.hasPermi('Actsupplies:Actsupplies:enable')") @PreAuthorize("@ss.hasPermi('Actsupplies:Actsupplies:enable')")
@GetMapping("/enable/{id}") @PutMapping("/{id}/enable")
public AjaxResult setEnable(@PathVariable("id") Long id) public AjaxResult setEnable(@PathVariable("id") Long id, @RequestParam("status") Integer status)
{ {
actSuppliesService.setEnable(id); actSuppliesService.setEnable(id,status);
return AjaxResult.success(); if (status < 0){
return AjaxResult.error(ServiceCode.ERR_CODE+"","启用失败");
}else {
return AjaxResult.success(ServiceCode.OK+"","启用成功");
}
} }
/** /**
* 禁用物料总分类管理 * 禁用物料总分类管理
*/ */
@PreAuthorize("@ss.hasPermi('Actsupplies:Actsupplies:Disable')") @PreAuthorize("@ss.hasPermi('Actsupplies:Actsupplies:Disable')")
@GetMapping("/disable/{id}") @PutMapping("/{id}/disable")
public AjaxResult setDisable(@PathVariable("id") Long id) public AjaxResult setDisable(@PathVariable("id") Long id, @RequestParam("status") Integer status)
{ {
if (actSuppliesService.find(id).size()>0 || actSuppliesService.findId(id).size()>0){ if (actSuppliesService.find(id).size()>0 || actSuppliesService.findId(id).size()>0){
...@@ -186,9 +191,13 @@ public class ActSuppliesController extends BaseController ...@@ -186,9 +191,13 @@ public class ActSuppliesController extends BaseController
} }
actSuppliesService.setDisable(id);
return AjaxResult.success("200","修改成功"); actSuppliesService.setDisable(id,status);
if(status > 1){
return AjaxResult.error(ServiceCode.ERR_CODE+"","禁用失败");
}
return AjaxResult.success("200","禁用成功");
} }
......
...@@ -114,9 +114,6 @@ public class ActSuppliesConvertController extends BaseController{ ...@@ -114,9 +114,6 @@ public class ActSuppliesConvertController extends BaseController{
} }
/**
*
* */
} }
...@@ -12,6 +12,7 @@ import com.ruoyi.common.utils.poi.ExcelUtil; ...@@ -12,6 +12,7 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.ActSupplies; import com.ruoyi.system.domain.ActSupplies;
import com.ruoyi.system.domain.ActSuppliesDetails; import com.ruoyi.system.domain.ActSuppliesDetails;
import com.ruoyi.system.service.IActSuppliesDetailsService; import com.ruoyi.system.service.IActSuppliesDetailsService;
import com.ruoyi.system.web.ServiceCode;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -133,24 +134,34 @@ public class ActSuppliesDetailsController extends BaseController ...@@ -133,24 +134,34 @@ public class ActSuppliesDetailsController extends BaseController
* 启用物料细分类管理 * 启用物料细分类管理
*/ */
@PreAuthorize("@ss.hasPermi('ActSuppliesDetails:ActSuppliesDetails:enable')") @PreAuthorize("@ss.hasPermi('ActSuppliesDetails:ActSuppliesDetails:enable')")
@GetMapping("/enable/{id}") @GetMapping("/{id}/enable")
public AjaxResult setEnable(@PathVariable("id") Long id) public AjaxResult setEnable(@PathVariable("id") Long id, @RequestParam("status") Integer status)
{ {
actSuppliesDetailsService.setEnable(id); actSuppliesDetailsService.setEnable(id,status);
return AjaxResult.success(); if (status < 0){
return AjaxResult.error(ServiceCode.ERR_CODE+"","启用失败");
}else {
return AjaxResult.success(ServiceCode.OK+"","启用成功");
}
} }
/** /**
* 禁用物料细分类管理 * 禁用物料细分类管理
*/ */
@PreAuthorize("@ss.hasPermi('ActSuppliesDetails:ActSuppliesDetails:Disable')") @PreAuthorize("@ss.hasPermi('ActSuppliesDetails:ActSuppliesDetails:Disable')")
@GetMapping("/disable/{id}") @GetMapping("/{id}/disable")
public AjaxResult setDisable(@PathVariable("id") Long id) public AjaxResult setDisable(@PathVariable("id") Long id, @RequestParam("status") Integer status)
{ {
actSuppliesDetailsService.setDisable(id); actSuppliesDetailsService.setDisable(id,status);
return AjaxResult.success();
if(status > 1){
return AjaxResult.error(ServiceCode.ERR_CODE+"","禁用失败");
}
return AjaxResult.success(ServiceCode.OK+"","启动成功");
} }
} }
...@@ -10,6 +10,7 @@ import com.ruoyi.common.core.domain.entity.SysUser; ...@@ -10,6 +10,7 @@ import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.ActSuppliesRoleDetail; import com.ruoyi.system.domain.ActSuppliesRoleDetail;
import com.ruoyi.system.domain.ActSuppliesTemplate; import com.ruoyi.system.domain.ActSuppliesTemplate;
import com.ruoyi.system.web.ServiceCode;
import org.springframework.beans.propertyeditors.CustomDateEditor; import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
...@@ -65,12 +66,6 @@ public class ActSuppliesRoleController extends BaseController ...@@ -65,12 +66,6 @@ public class ActSuppliesRoleController extends BaseController
return getDataTable(list); return getDataTable(list);
} }
@InitBinder
public void initBinder(WebDataBinder binder, WebRequest request) {
//转换日期 注意这里的转化要和传进来的字符串的格式一直 如2015-9-9 就应该为yyyy-MM-dd
DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));// CustomDateEditor为自定义日期编辑器
}
/** /**
* 查询规则详情列表 * 查询规则详情列表
*/ */
...@@ -172,33 +167,41 @@ public class ActSuppliesRoleController extends BaseController ...@@ -172,33 +167,41 @@ public class ActSuppliesRoleController extends BaseController
return toAjax(actSuppliesRoleService.deleteActSuppliesRoleByIds(ids)); return toAjax(actSuppliesRoleService.deleteActSuppliesRoleByIds(ids));
} }
/** /**
* 启用物料总分类管理 * 启用物料总分类管理
*/ */
@PreAuthorize("@ss.hasPermi('system:suppliesrole:enable')") @PreAuthorize("@ss.hasPermi('system:suppliesrole:enable')")
@GetMapping("/enable/{id}") @PutMapping("/{id}/enable")
public AjaxResult setEnable(@PathVariable("id") Long id) public AjaxResult setEnable(@PathVariable("id") Long id, @RequestParam("status") Integer status)
{ {
actSuppliesRoleService.setEnable(id); actSuppliesRoleService.setEnable(id,status);
return AjaxResult.success(); if (status < 0){
return AjaxResult.error(ServiceCode.ERR_CODE+"","启用失败");
}else {
return AjaxResult.success(ServiceCode.OK+"","启用成功");
}
} }
/** /**
* 禁用物料总分类管理 * 禁用物料总分类管理
*/ */
@PreAuthorize("@ss.hasPermi('system:suppliesrole:Disable')") @PreAuthorize("@ss.hasPermi('system:suppliesrole:Disable')")
@GetMapping("/disable/{id}") @PutMapping("/{id}/disable")
public AjaxResult setDisable(@PathVariable("id") Long id) public AjaxResult setDisable(@PathVariable("id") Long id, @RequestParam("status") Integer status)
{ {
if (actSuppliesRoleService.find(Math.toIntExact(id)).size()>0){ if (actSuppliesRoleService.find(Math.toIntExact(id)).size()>0){
return AjaxResult.success("该规则下存在关联规则,请先删除关联规则!!!","操作失败"); return AjaxResult.error("该规则下存在关联规则,请先删除关联规则!!!","操作失败");
} }
actSuppliesRoleService.setDisable(id); actSuppliesRoleService.setDisable(id,status);
return AjaxResult.success("200","修改成功");
if(status > 1){
return AjaxResult.error(ServiceCode.ERR_CODE+"","禁用失败");
}
return AjaxResult.success(ServiceCode.OK+"","禁用成功");
} }
......
...@@ -3,9 +3,12 @@ package com.ruoyi.system.controller; ...@@ -3,9 +3,12 @@ package com.ruoyi.system.controller;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.ActSuppliesRole;
import com.ruoyi.system.domain.ActSuppliesTemplate; import com.ruoyi.system.domain.ActSuppliesTemplate;
import com.ruoyi.system.service.ActSuppliesTemplateService; import com.ruoyi.system.service.ActSuppliesTemplateService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -41,6 +44,31 @@ public class ActSuppliesTemplateController extends BaseController { ...@@ -41,6 +44,31 @@ public class ActSuppliesTemplateController extends BaseController {
} }
/**
* 查询导入规则列表
*/
@PreAuthorize("@ss.hasPermi('SuppliesTemplate:SuppliesTemplate:lists')")
@GetMapping("/lists/{id}")
public TableDataInfo lists(@PathVariable("id") Integer id)
{
startPage();
List<ActSuppliesRole> list = actSuppliesTemplateService.selectActSuppliesRoleList(id);
return getDataTable(list);
}
/**
* 修改导入规则
*/
@PreAuthorize("@ss.hasPermi('SuppliesTemplate:SuppliesTemplate:edit')")
@Log(title = "导入规则", businessType = BusinessType.UPDATE)
@PutMapping("/edit/{id}")
public AjaxResult edit(@RequestBody ActSuppliesRole actSuppliesRole)
{
SysUser user = SecurityUtils.getLoginUser().getUser();
actSuppliesRole.setUpdateBy(user.getUserName());
return toAjax(actSuppliesTemplateService.updateActSuppliesRole(actSuppliesRole));
}
/** /**
* 导出Excel模板列表 * 导出Excel模板列表
*/ */
...@@ -169,7 +197,7 @@ public class ActSuppliesTemplateController extends BaseController { ...@@ -169,7 +197,7 @@ public class ActSuppliesTemplateController extends BaseController {
@GetMapping("/enable/{id}") @GetMapping("/enable/{id}")
public AjaxResult setEnable(@PathVariable("id") Long id) public AjaxResult setEnable(@PathVariable("id") Long id)
{ {
System.out.println("开始处理【启用物料总分类管理】的请求,参数:{}"+ id);
actSuppliesTemplateService.setEnable(id); actSuppliesTemplateService.setEnable(id);
return AjaxResult.success(); return AjaxResult.success();
} }
...@@ -184,7 +212,7 @@ public class ActSuppliesTemplateController extends BaseController { ...@@ -184,7 +212,7 @@ public class ActSuppliesTemplateController extends BaseController {
// if(actSuppliesTemplateService.find(id).size()>0){ // if(actSuppliesTemplateService.find(id).size()>0){
// return AjaxResult.success("该物料下存在关联物料,请先删除关联物料!!!","操作失败"); // return AjaxResult.success("该物料下存在关联物料,请先删除关联物料!!!","操作失败");
// } // }
System.out.println("开始处理【禁用物料总分类管理】的请求,参数:{}"+ id);
actSuppliesTemplateService.setDisable(id); actSuppliesTemplateService.setDisable(id);
return AjaxResult.success(); return AjaxResult.success();
......
...@@ -5,6 +5,7 @@ import com.ruoyi.system.domain.ActSuppliesDetails; ...@@ -5,6 +5,7 @@ import com.ruoyi.system.domain.ActSuppliesDetails;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 物料细分类管理Mapper接口 * 物料细分类管理Mapper接口
...@@ -70,5 +71,9 @@ public interface ActSuppliesDetailsMapper ...@@ -70,5 +71,9 @@ public interface ActSuppliesDetailsMapper
*/ */
public int countByDetailsName(String detailsName); public int countByDetailsName(String detailsName);
int updateActSuppliesDetails(Map<String, Object> paramMap);
int setEnable(Map<String, Object> paramMap);
int setDisable(Map<String, Object> paramMap);
List<ActSupplies> saveSid(); List<ActSupplies> saveSid();
} }
...@@ -2,9 +2,11 @@ package com.ruoyi.system.mapper; ...@@ -2,9 +2,11 @@ package com.ruoyi.system.mapper;
import com.ruoyi.system.domain.ActSupplies; import com.ruoyi.system.domain.ActSupplies;
import com.ruoyi.system.domain.ActSuppliesRole; import com.ruoyi.system.domain.ActSuppliesRole;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 物料总分类管理Mapper接口 * 物料总分类管理Mapper接口
...@@ -83,7 +85,9 @@ public interface ActSuppliesMapper ...@@ -83,7 +85,9 @@ public interface ActSuppliesMapper
*/ */
public int countBySuppliesName(String suppliesName); public int countBySuppliesName(String suppliesName);
int updateActSupplies(Map<String, Object> paramMap);
int setEnable(Map<String, Object> paramMap);
int setDisable(Map<String, Object> paramMap);
List<ActSupplies> selectActSuppliesListOne(ActSupplies actSupplies); List<ActSupplies> selectActSuppliesListOne(ActSupplies actSupplies);
} }
package com.ruoyi.system.mapper; package com.ruoyi.system.mapper;
import java.util.List; import java.util.List;
import java.util.Map;
import com.ruoyi.system.domain.ActSuppliesRole; import com.ruoyi.system.domain.ActSuppliesRole;
import com.ruoyi.system.domain.ActSuppliesRoleDetail; import com.ruoyi.system.domain.ActSuppliesRoleDetail;
import com.ruoyi.system.domain.ActSuppliesTemplate; import com.ruoyi.system.domain.ActSuppliesTemplate;
...@@ -85,9 +87,12 @@ public interface ActSuppliesRoleMapper ...@@ -85,9 +87,12 @@ public interface ActSuppliesRoleMapper
List<ActSuppliesTemplate> saveSid(); List<ActSuppliesTemplate> saveSid();
int updateActSuppliesRole(Map<String, Object> paramMap);
int setEnable(Map<String, Object> paramMap);
int setDisable(Map<String, Object> paramMap);
List<Integer> findall(Integer[] ids); List<Integer> findall(Integer[] ids);
List<Integer> find(Integer id); List<Integer> find(Integer id);
public int countByRoleName(ActSuppliesRole actSuppliesRole); public int countByRoleName(ActSuppliesRole actSuppliesRole);
......
package com.ruoyi.system.mapper; package com.ruoyi.system.mapper;
import com.ruoyi.system.domain.ActSuppliesRole;
import com.ruoyi.system.domain.ActSuppliesTemplate; import com.ruoyi.system.domain.ActSuppliesTemplate;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -43,7 +44,13 @@ public interface ActSuppliesTemplateMapper ...@@ -43,7 +44,13 @@ public interface ActSuppliesTemplateMapper
List<ActSuppliesTemplate> saveTemplateStatus(Long[] ids); List<ActSuppliesTemplate> saveTemplateStatus(Long[] ids);
int selectHistory(Long id);
void updateRelease(ActSuppliesTemplate actSuppliesTemplate); void updateRelease(ActSuppliesTemplate actSuppliesTemplate);
}
ActSuppliesRole selectActSuppliesRoleById(Integer id);
List<ActSuppliesRole> selectActSuppliesRoleList(Integer id);
int updateActSuppliesRole(ActSuppliesRole actSuppliesRole);
int selectHistory(Long id);
}
\ No newline at end of file
package com.ruoyi.system.service; package com.ruoyi.system.service;
import com.ruoyi.system.domain.ActSuppliesRole;
import com.ruoyi.system.domain.ActSuppliesTemplate; import com.ruoyi.system.domain.ActSuppliesTemplate;
import java.util.List; import java.util.List;
...@@ -50,4 +51,27 @@ public interface ActSuppliesTemplateService ...@@ -50,4 +51,27 @@ public interface ActSuppliesTemplateService
int offShelfStatus(Long[] ids); int offShelfStatus(Long[] ids);
String copyTemplate(Long id); String copyTemplate(Long id);
/**
* 查询导入规则
*
* @param id 导入规则ID
* @return 导入规则
*/
public ActSuppliesRole selectActSuppliesRoleById(Integer id);
/**
* 查询导入规则列表
*
* @param id 导入规则
* @return 导入规则集合
*/
public List<ActSuppliesRole> selectActSuppliesRoleList(Integer id);
/**
* 修改导入规则
*
* @param actSuppliesRole 导入规则
* @return 结果
*/
public int updateActSuppliesRole(ActSuppliesRole actSuppliesRole);
} }
...@@ -3,6 +3,7 @@ package com.ruoyi.system.service; ...@@ -3,6 +3,7 @@ package com.ruoyi.system.service;
import com.ruoyi.system.domain.ActSupplies; import com.ruoyi.system.domain.ActSupplies;
import com.ruoyi.system.domain.ActSuppliesDetails; import com.ruoyi.system.domain.ActSuppliesDetails;
import io.lettuce.core.dynamic.annotation.Param;
import java.util.List; import java.util.List;
...@@ -65,18 +66,19 @@ public interface IActSuppliesDetailsService ...@@ -65,18 +66,19 @@ public interface IActSuppliesDetailsService
List<ActSupplies> saveSid(); List<ActSupplies> saveSid();
/** /**
* 启用物料分类管理 * 启用物料分类管理
* *
* @param id 尝试启用物料分类管理的id * @param id 尝试启用物料分类管理的id
* @return * @return
*/ */
void setEnable(Long id); int setEnable(@Param("id") Long id, @Param("status") Integer status);
/** /**
* 禁用 * 禁用
* *
* @param id 尝试禁用物料分类管理的id * @param id 尝试禁用物料分类管理的id
*/ */
void setDisable(Long id); int setDisable(@Param("id") Long id, @Param("status") Integer status);
} }
...@@ -4,7 +4,7 @@ import java.util.List; ...@@ -4,7 +4,7 @@ import java.util.List;
import com.ruoyi.system.domain.ActSuppliesRole; import com.ruoyi.system.domain.ActSuppliesRole;
import com.ruoyi.system.domain.ActSuppliesRoleDetail; import com.ruoyi.system.domain.ActSuppliesRoleDetail;
import com.ruoyi.system.domain.ActSuppliesTemplate; import com.ruoyi.system.domain.ActSuppliesTemplate;
import org.springframework.stereotype.Repository; import io.lettuce.core.dynamic.annotation.Param;
/** /**
* 导入规则Service接口 * 导入规则Service接口
...@@ -88,14 +88,15 @@ public interface IActSuppliesRoleService ...@@ -88,14 +88,15 @@ public interface IActSuppliesRoleService
* @param id 尝试启用物料细分类管理的id * @param id 尝试启用物料细分类管理的id
* @return * @return
*/ */
void setEnable(Long id); int setEnable(@Param("id") Long id, @Param("status") Integer status);
/** /**
* 禁用 * 禁用
* *
* @param id 尝试禁用物料细分类管理的id * @param id 尝试禁用物料细分类管理的id
*/ */
void setDisable(Long id); int setDisable(@Param("id") Long id, @Param("status") Integer status);
List<Integer> findall(Integer[] ids); List<Integer> findall(Integer[] ids);
List<Integer> find(Integer id); List<Integer> find(Integer id);
......
package com.ruoyi.system.service; package com.ruoyi.system.service;
import com.ruoyi.system.domain.ActSupplies; import com.ruoyi.system.domain.ActSupplies;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
...@@ -64,21 +65,21 @@ public interface IActSuppliesService ...@@ -64,21 +65,21 @@ public interface IActSuppliesService
List<ActSupplies> options(); List<ActSupplies> options();
/** /**
* 启用物料细分类管理 * 启用物料细分类管理
* *
* @param id 尝试启用物料细分类管理的id * @param id 尝试启用物料细分类管理的id
* @return * @return
*/ */
void setEnable(Long id); int setEnable(@Param("id") Long id, @Param("status") Integer status);
/** /**
* 禁用 * 禁用
* *
* @param id 尝试禁用物料细分类管理的id * @param id 尝试禁用物料细分类管理的id
*/ */
void setDisable(Long id); int setDisable(@Param("id") Long id, @Param("status") Integer status);
List<Integer> findall(Long[] ids); List<Integer> findall(Long[] ids);
......
...@@ -10,7 +10,9 @@ import org.springframework.beans.BeanUtils; ...@@ -10,7 +10,9 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 物料细分类管理Service业务层处理 * 物料细分类管理Service业务层处理
...@@ -122,44 +124,32 @@ public class ActSuppliesDetailsServiceImpl implements IActSuppliesDetailsService ...@@ -122,44 +124,32 @@ public class ActSuppliesDetailsServiceImpl implements IActSuppliesDetailsService
return actSuppliesDetailsMapper.saveSid(); return actSuppliesDetailsMapper.saveSid();
} }
@Override @Override
public void setEnable(Long id) { public int setEnable(Long id, Integer status) {
updateStatusById(id,0); updateStatusById(id, status);
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("id", id);
paramMap.put("status", status);
return actSuppliesDetailsMapper.setEnable(paramMap);
} }
@Override @Override
public void setDisable(Long id) { public int setDisable(Long id, Integer status) {
updateStatusById(id,1); updateStatusById(id, status);
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("id", id);
paramMap.put("status", status);
return actSuppliesDetailsMapper.setDisable(paramMap);
} }
private void updateStatusById(Long id, Integer status){ private int updateStatusById(Long id, Integer status){
String[] statusText={"禁用","启用"};
//判断查询结果是否为空 Map<String, Object> paramMap = new HashMap<>();
ActSuppliesDetails queryResult = actSuppliesDetailsMapper.selectActSuppliesDetailsById(id); paramMap.put("id", id);
paramMap.put("status", status);
if(queryResult ==null) { return actSuppliesDetailsMapper.updateActSuppliesDetails(paramMap);
String message =statusText[status] + "物料细分类管理失败,尝试访问的数据不存在";
System.out.println(message);
throw new RuntimeException(message);
}
//判断以上查询结果中的status是否与参数status相同
if(queryResult.getStatus().equals(status)){
String message = statusText[status] + "物料细分类管理失败,当前物料细分类管理已经处理" +statusText[status] + "状态!";
System.out.println(message);
throw new RuntimeException(message);
}
ActSuppliesDetails actSuppliesDetails=new ActSuppliesDetails();
actSuppliesDetails.setId(id);
actSuppliesDetails.setStatus(status);
int rows = actSuppliesDetailsMapper.updateActSuppliesDetails(actSuppliesDetails);
if (rows != 1) {
String message = statusText[status] + "物料细分类管理失败,服务器忙请再次重试";
System.out.println(message);
throw new RuntimeException(message);
}
} }
} }
package com.ruoyi.system.service.impl; package com.ruoyi.system.service.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
...@@ -219,13 +221,21 @@ public class ActSuppliesRoleServiceImpl implements IActSuppliesRoleService ...@@ -219,13 +221,21 @@ public class ActSuppliesRoleServiceImpl implements IActSuppliesRoleService
} }
@Override @Override
public void setEnable(Long id) { public int setEnable(Long id, Integer status) {
updateStatusById(id,0); updateStatusById(id, status);
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("id", id);
paramMap.put("status", status);
return actSuppliesRoleMapper.setEnable(paramMap);
} }
@Override @Override
public void setDisable(Long id) { public int setDisable(Long id, Integer status) {
updateStatusById(id,1); updateStatusById(id, status);
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("id", id);
paramMap.put("status", status);
return actSuppliesRoleMapper.setDisable(paramMap);
} }
@Override @Override
......
...@@ -11,7 +11,9 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -11,7 +11,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.sql.rowset.serial.SerialException; import javax.sql.rowset.serial.SerialException;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import static jdk.nashorn.internal.runtime.regexp.joni.Config.log; import static jdk.nashorn.internal.runtime.regexp.joni.Config.log;
...@@ -126,19 +128,29 @@ public class ActSuppliesServiceImpl implements IActSuppliesService ...@@ -126,19 +128,29 @@ public class ActSuppliesServiceImpl implements IActSuppliesService
return actSuppliesMapper.options(); return actSuppliesMapper.options();
} }
@Override @Override
public List<Integer> findall(Long[] ids) { public int setEnable(Long id, Integer status) {
return actSuppliesMapper.findall(ids); updateStatusById(id, status);
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("id", id);
paramMap.put("status", status);
return actSuppliesMapper.setEnable(paramMap);
} }
@Override @Override
public void setEnable(Long id) { public int setDisable(Long id, Integer status) {
updateStatusById(id,0); updateStatusById(id, status);
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("id", id);
paramMap.put("status", status);
return actSuppliesMapper.setDisable(paramMap);
} }
@Override @Override
public void setDisable(Long id) { public List<Integer> findall(Long[] ids) {
updateStatusById(id,1); return actSuppliesMapper.findall(ids);
} }
@Override @Override
...@@ -162,35 +174,13 @@ public class ActSuppliesServiceImpl implements IActSuppliesService ...@@ -162,35 +174,13 @@ public class ActSuppliesServiceImpl implements IActSuppliesService
return actSuppliesMapper.selectActSuppliesListOne(actSupplies); return actSuppliesMapper.selectActSuppliesListOne(actSupplies);
} }
private void updateStatusById(Long id, Integer status){ private int updateStatusById(Long id, Integer status){
String[] statusText={"禁用","启用"};
//判断查询结果是否为空 Map<String, Object> paramMap = new HashMap<>();
ActSupplies queryResult = actSuppliesMapper.selectActSuppliesById(id); paramMap.put("id", id);
if(queryResult ==null) { paramMap.put("status", status);
String message =statusText[status] + "物料总分类管理失败,尝试访问的数据不存在";
System.out.println(message);
throw new RuntimeException(message);
}
//判断以上查询结果中的status是否与参数status相同
if(queryResult.getStatus().equals(status)){
String message = statusText[status] + "物料总分类管理失败,当前物料总分类管理已经处理" +statusText[status] + "状态!";
System.out.println(message);
throw new RuntimeException(message);
}
return actSuppliesMapper.updateActSupplies(paramMap);
ActSupplies actSupplies = new ActSupplies();
actSupplies.setId(id);
actSupplies.setStatus(status);
int rows = actSuppliesMapper.updateActSupplies(actSupplies);
if (rows != 1) {
String message = statusText[status] + "物料总分类管理失败,服务器忙请再次重试";
System.out.println(message);
throw new RuntimeException(message);
}
} }
} }
......
...@@ -4,7 +4,9 @@ import com.ruoyi.common.core.domain.AjaxResult; ...@@ -4,7 +4,9 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.ActSuppliesRole;
import com.ruoyi.system.domain.ActSuppliesTemplate; import com.ruoyi.system.domain.ActSuppliesTemplate;
import com.ruoyi.system.mapper.ActSuppliesRoleMapper;
import com.ruoyi.system.mapper.ActSuppliesTemplateMapper; import com.ruoyi.system.mapper.ActSuppliesTemplateMapper;
import com.ruoyi.system.service.ActSuppliesTemplateService; import com.ruoyi.system.service.ActSuppliesTemplateService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -26,6 +28,9 @@ public class ActSuppliesTemplateServiceImpl implements ActSuppliesTemplateServic ...@@ -26,6 +28,9 @@ public class ActSuppliesTemplateServiceImpl implements ActSuppliesTemplateServic
@Autowired @Autowired
private ActSuppliesTemplateMapper actSuppliesTemplateMapper; private ActSuppliesTemplateMapper actSuppliesTemplateMapper;
@Autowired
private ActSuppliesRoleMapper actSuppliesRoleMapper;
@Override @Override
public List<ActSuppliesTemplate> selectSuppliesTemplateList(ActSuppliesTemplate sysSupplies) { public List<ActSuppliesTemplate> selectSuppliesTemplateList(ActSuppliesTemplate sysSupplies) {
...@@ -57,6 +62,28 @@ public class ActSuppliesTemplateServiceImpl implements ActSuppliesTemplateServic ...@@ -57,6 +62,28 @@ public class ActSuppliesTemplateServiceImpl implements ActSuppliesTemplateServic
sysSupplies.setUpdateTime(DateUtils.getNowDate()); sysSupplies.setUpdateTime(DateUtils.getNowDate());
return actSuppliesTemplateMapper.updateSuppliesTemplate(sysSupplies); return actSuppliesTemplateMapper.updateSuppliesTemplate(sysSupplies);
} }
/**
* 查询导入规则
*
* @param id 导入规则
* @return 导入规则
*/
@Override
public ActSuppliesRole selectActSuppliesRoleById(Integer id) {
return actSuppliesTemplateMapper.selectActSuppliesRoleById(id);
}
@Override
public List<ActSuppliesRole> selectActSuppliesRoleList(Integer id) {
return actSuppliesTemplateMapper.selectActSuppliesRoleList(id);
}
@Override
public int updateActSuppliesRole(ActSuppliesRole actSuppliesRole) {
actSuppliesRole.setUpdateTime(DateUtils.getNowDate());
return actSuppliesTemplateMapper.updateActSuppliesRole(actSuppliesRole);
}
@Override @Override
public List<String> deleteSuppliesTemplateByIds(Long[] ids) { public List<String> deleteSuppliesTemplateByIds(Long[] ids) {
...@@ -192,6 +219,8 @@ public class ActSuppliesTemplateServiceImpl implements ActSuppliesTemplateServic ...@@ -192,6 +219,8 @@ public class ActSuppliesTemplateServiceImpl implements ActSuppliesTemplateServic
} }
private void updateStatusById(Long id, Integer status){ private void updateStatusById(Long id, Integer status){
String[] statusText={"禁用","启用"}; String[] statusText={"禁用","启用"};
......
...@@ -55,6 +55,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -55,6 +55,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select a.id,a.pid,b.supplies_name fname,a.supplies_name,a.status from act_supplies a LEFT JOIN act_supplies b on a.pid =b.id where a.status = 0 select a.id,a.pid,b.supplies_name fname,a.supplies_name,a.status from act_supplies a LEFT JOIN act_supplies b on a.pid =b.id where a.status = 0
</select> </select>
<update id="setEnable" parameterType="java.util.Map">
UPDATE act_supplies_details
SET status = 0
WHERE id = #{id}
</update>
<update id="setDisable" parameterType="java.util.Map">
UPDATE act_supplies_details
SET status = 1
WHERE id = #{id}
</update>
<select id="selectActSuppliesDetailsList" parameterType="ActSuppliesDetails" resultMap="OneActSuppliesDetailsResult"> <select id="selectActSuppliesDetailsList" parameterType="ActSuppliesDetails" resultMap="OneActSuppliesDetailsResult">
select a.id, a.sid,b.supplies_name,a.details_name,a.sysclassify,a.status from act_supplies_details a left join act_supplies b on a.sid = b.id select a.id, a.sid,b.supplies_name,a.details_name,a.sysclassify,a.status from act_supplies_details a left join act_supplies b on a.sid = b.id
<where> <where>
......
...@@ -25,6 +25,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -25,6 +25,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="countBySuppliesName" resultType="int"> <select id="countBySuppliesName" resultType="int">
select count(*) from act_supplies where supplies_name=#{suppliesName} select count(*) from act_supplies where supplies_name=#{suppliesName}
</select> </select>
<select id="selectActSuppliesList" parameterType="ActSupplies" resultMap="ActSuppliesResult"> <select id="selectActSuppliesList" parameterType="ActSupplies" resultMap="ActSuppliesResult">
select a.id,a.pid,b.supplies_name fname,a.supplies_name,a.status from act_supplies a , act_supplies b select a.id,a.pid,b.supplies_name fname,a.supplies_name,a.status from act_supplies a , act_supplies b
<where> <where>
...@@ -96,6 +98,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -96,6 +98,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id} where id = #{id}
</update> </update>
<update id="setEnable" parameterType="java.util.Map">
UPDATE act_supplies
SET status = 0
WHERE id = #{id}
</update>
<update id="setDisable" parameterType="java.util.Map">
UPDATE act_supplies
SET status = 1
WHERE id = #{id}
</update>
<select id="findall" parameterType="String" resultType="Integer"> <select id="findall" parameterType="String" resultType="Integer">
...@@ -127,6 +140,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -127,6 +140,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- <delete id="deleteActSuppliesById" parameterType="Long">--> <!-- <delete id="deleteActSuppliesById" parameterType="Long">-->
<!-- delete from act_supplies where id = #{id}--> <!-- delete from act_supplies where id = #{id}-->
<!-- </delete>--> <!-- </delete>-->
......
...@@ -74,6 +74,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -74,6 +74,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select id, temp_id, role_name, status, create_by, create_time, update_by, update_time from act_supplies_role select id, temp_id, role_name, status, create_by, create_time, update_by, update_time from act_supplies_role
</sql> </sql>
<update id="setEnable" parameterType="java.util.Map">
UPDATE act_supplies_role
SET status = 0
WHERE id = #{id}
</update>
<update id="setDisable" parameterType="java.util.Map">
UPDATE act_supplies_role
SET status = 1
WHERE id = #{id}
</update>
<sql id="selectActSuppliesRoleDetailVo"> <sql id="selectActSuppliesRoleDetailVo">
select id, role_id, detail_name, detail_m_h, detail_m_l, detail_y_h, detail_y_l,detail_y_s, detail_content,convert_status, status, create_by, create_time, update_by, update_time from act_supplies_role_detail select id, role_id, detail_name, detail_m_h, detail_m_l, detail_y_h, detail_y_l,detail_y_s, detail_content,convert_status, status, create_by, create_time, update_by, update_time from act_supplies_role_detail
</sql> </sql>
......
...@@ -17,6 +17,19 @@ ...@@ -17,6 +17,19 @@
</resultMap> </resultMap>
<resultMap type="ActSuppliesRole" id="ActSuppliesRoleResult">
<result property="id" column="id" />
<result property="tempId" column="temp_id" />
<result property="roleName" column="role_name" />
<result property="status" column="status" />
<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="templateName" column="template_name"/>
</resultMap>
<sql id="selectSuppliesTemplateVo"> <sql id="selectSuppliesTemplateVo">
select id, det_id, template_name, template_content, status, create_by, create_time, update_by, update_time from act_supplies_template select id, det_id, template_name, template_content, status, create_by, create_time, update_by, update_time from act_supplies_template
</sql> </sql>
...@@ -34,6 +47,32 @@ ...@@ -34,6 +47,32 @@
select template_name from act_supplies_template select template_name from act_supplies_template
</select> </select>
<sql id="selectActSuppliesRoleVo">
select id, temp_id, role_name, status, create_by, create_time, update_by, update_time from act_supplies_role
</sql>
<select id="selectActSuppliesRoleList" parameterType="Integer" resultMap="ActSuppliesRoleResult">
select id , role_name from act_supplies_role where temp_id = #{id}
</select>
<select id="selectActSuppliesRoleById" parameterType="Integer" resultMap="ActSuppliesRoleResult">
<include refid="selectActSuppliesRoleVo"/>
where temp_id = #{id}
</select>
<update id="updateActSuppliesRole" parameterType="ActSuppliesRole">
update act_supplies_role
<trim prefix="SET" suffixOverrides=",">
<if test="tempId != null">temp_id = #{tempId},</if>
<if test="roleName != null">role_name = #{roleName},</if>
<if test="status != null">status = #{status},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<select id="selectSuppliesTemplateList" parameterType="ActSuppliesTemplate" resultMap="SuppliesTemplateResult"> <select id="selectSuppliesTemplateList" parameterType="ActSuppliesTemplate" resultMap="SuppliesTemplateResult">
select id, det_id, template_name, status from act_supplies_template select id, det_id, template_name, status from act_supplies_template
<where> <where>
......
...@@ -61,16 +61,15 @@ export function exportActSuppliesDetails(query) { ...@@ -61,16 +61,15 @@ export function exportActSuppliesDetails(query) {
} }
//启用 //启用
export function toggleEnable(id) { export function toggleEnable(id) {
return request({ return request({
url: '/ActSuppliesDetails/ActSuppliesDetails/enable/' +id, url: `/Actsupplies/Actsupplies/${id}/enable?status=0`,
method: 'get', method: 'put',
})
})
} }
//禁用 //禁用
export function toggleDisable(id) { export function toggleDisable(id) {
return request({ return request({
url: '/ActSuppliesDetails/ActSuppliesDetails/disable/' + id, url: `/Actsupplies/Actsupplies/${id}/disable?status=1`,
method: 'get', method: 'put',
}) })
} }
...@@ -59,22 +59,35 @@ export function delSupplies(id) { ...@@ -59,22 +59,35 @@ export function delSupplies(id) {
method: 'delete' method: 'delete'
}) })
} }
//启用 export function toggleEnable(id) {
return request({
url: `/Actsupplies/Actsupplies/${id}/enable?status=0`,
method: 'put',
})
}
/*//启用
export function toggleEnable(id) { export function toggleEnable(id) {
return request({ return request({
url: '/Actsupplies/Actsupplies/enable/' +id, url: '/Actsupplies/Actsupplies/enable/' +id,
method: 'get', method: 'get',
}) })
} }*/
//禁用
export function toggleDisable(id) {
return request({
url: `/Actsupplies/Actsupplies/${id}/disable?status=1`,
method: 'put',
})
}
/*//禁用
export function toggleDisable(id) { export function toggleDisable(id) {
return request({ return request({
url: '/Actsupplies/Actsupplies/disable/' +id, url: '/Actsupplies/Actsupplies/disable/' +id,
method: 'get', method: 'get',
}) })
} }*/
......
...@@ -19,6 +19,22 @@ export function listSuppliesTemplate(query) { ...@@ -19,6 +19,22 @@ export function listSuppliesTemplate(query) {
}) })
} }
// 查询导入规则列表
export function listSuppliesrole(id) {
return request({
url: '/SuppliesTemplate/SuppliesTemplate/lists/' +id,
method: 'get',
})
}
// 查询导入规则详细
export function getSuppliesrole(id) {
return request({
url: '/system/suppliesrole/' + id,
method: 'get'
})
}
//展示excel模板 //展示excel模板
export function listSuppliesTemplateId(id) { export function listSuppliesTemplateId(id) {
return request({ return request({
...@@ -35,6 +51,15 @@ export function getSuppliesTemplate(id) { ...@@ -35,6 +51,15 @@ export function getSuppliesTemplate(id) {
}) })
} }
// 修改导入规则
export function updateSuppliesrole(id) {
return request({
url: '/system/suppliesrole/edit' +id,
method: 'put',
})
}
// 新增Excel模板 // 新增Excel模板
export function addSuppliesTemplate(data) { export function addSuppliesTemplate(data) {
return request({ return request({
......
...@@ -86,19 +86,18 @@ export function exportSuppliesrole(query) { ...@@ -86,19 +86,18 @@ export function exportSuppliesrole(query) {
//启用 //启用
export function toggleEnable(id) { export function toggleEnable(id) {
return request({ return request({
url: '/system/suppliesrole/enable/' +id, url: `/system/suppliesrole/${id}/enable?status=0`,
method: 'get', method: 'put',
})
})
} }
//禁用 //禁用
export function toggleDisable(id) { export function toggleDisable(id) {
return request({ return request({
url: '/system/suppliesrole/disable/' +id, url: `/system/suppliesrole/${id}/disable?status=1`,
method: 'get', method: 'put',
})
})
} }
//发布 //发布
......
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="上级分类" prop="sid"> <el-form-item label="上级分类" prop="sid">
<el-select v-model="queryParams.sid" filterable clearable placeholder="请选择上级分类" > <el-select v-model="queryParams.sid" filterable clearable placeholder="请选择上级分类" >
<el-option <el-option
v-for="option in options2" v-for="option in options2"
:key="option.suppliesName" :key="option.suppliesName"
:label="option.fname==null ? option.id+'-'+option.suppliesName : option.fname+'-'+option.suppliesName" :label="option.fname==null ? option.id+'-'+option.suppliesName : option.fname+'-'+option.suppliesName"
:value="option.id" :value="option.id"
></el-option> ></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="物料名称" prop="detailsName"> <el-form-item label="物料名称" prop="detailsName">
<el-input <el-input
v-model="queryParams.detailsName" v-model="queryParams.detailsName"
placeholder="请输入物料名称" placeholder="请输入物料名称"
clearable clearable
size="small" size="small"
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
maxlength="36" maxlength="36"
/> />
</el-form-item> </el-form-item>
<el-form-item label="所属系统" prop="sysclassify"> <el-form-item label="所属系统" prop="sysclassify">
<el-input <el-input
v-model="queryParams.sysclassify" v-model="queryParams.sysclassify"
placeholder="请输入所属系统" placeholder="请输入所属系统"
clearable clearable
size="small" size="small"
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
maxlength="15" maxlength="15"
/> />
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable @keyup.enter.native="handleQuery"> <el-select v-model="queryParams.status" placeholder="请选择状态" clearable @keyup.enter.native="handleQuery">
<el-option label="启用" :value="0"></el-option> <el-option label="启用" :value="0"></el-option>
<el-option label="禁用" :value="1"></el-option> <el-option label="禁用" :value="1"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <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-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="primary" type="primary"
plain plain
icon="el-icon-plus" icon="el-icon-plus"
size="mini" size="mini"
@click="handleAdd" @click="handleAdd"
v-hasPermi="['ActSuppliesDetails:ActSuppliesDetails:add']" v-hasPermi="['ActSuppliesDetails:ActSuppliesDetails:add']"
>新增</el-button> >新增</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="success" type="success"
plain plain
icon="el-icon-edit" icon="el-icon-edit"
size="mini" size="mini"
:disabled="single" :disabled="single"
@click="handleUpdate" @click="handleUpdate"
v-hasPermi="['ActSuppliesDetails:ActSuppliesDetails:edit']" v-hasPermi="['ActSuppliesDetails:ActSuppliesDetails:edit']"
>修改</el-button> >修改</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="danger" type="danger"
plain plain
icon="el-icon-delete" icon="el-icon-delete"
size="mini" size="mini"
:disabled="multiple" :disabled="multiple"
@click="handleDelete" @click="handleDelete"
v-hasPermi="['ActSuppliesDetails:ActSuppliesDetails:remove']" v-hasPermi="['ActSuppliesDetails:ActSuppliesDetails:remove']"
>删除</el-button> >删除</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="warning" type="warning"
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
@click="handleExport" @click="handleExport"
v-hasPermi="['ActSuppliesDetails:ActSuppliesDetails:export']" v-hasPermi="['ActSuppliesDetails:ActSuppliesDetails:export']"
>导出</el-button> >导出</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="ActSuppliesDetailsList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="ActSuppliesDetailsList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column type="index" width="80" align="center" label="序号" :index="indexMethod" /> <el-table-column type="index" width="80" align="center" label="序号" :index="indexMethod" />
<el-table-column label="上级分类" align="center"> <el-table-column label="上级分类" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<div> <div>
<template> <template>
{{ scope.row.fname }} {{ scope.row.fname }}
</template> </template>
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="物料名称" align="center" prop="detailsName" /> <el-table-column label="物料名称" align="center" prop="detailsName" />
<el-table-column label="所属系统" align="center" prop="sysclassify" /> <el-table-column label="所属系统" align="center" prop="sysclassify" />
<el-table-column label="状态" align="center"> <el-table-column label="状态" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<div> <div>
<el-switch <el-switch
@change="toggleEnable(scope.row)" @change="toggleEnable(scope.row)"
v-model="scope.row.status" v-model="scope.row.status"
:active-value="0" :active-value="0"
:inactive-value="1" :inactive-value="1"
active-color="#13ce66" active-color="#13ce66"
inactive-color="#cccccc"> inactive-color="#cccccc">
</el-switch> </el-switch>
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-edit" icon="el-icon-edit"
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
v-hasPermi="['ActSuppliesDetails:ActSuppliesDetails:edit']" v-hasPermi="['ActSuppliesDetails:ActSuppliesDetails:edit']"
>修改</el-button> >修改</el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-delete" icon="el-icon-delete"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['ActSuppliesDetails:ActSuppliesDetails:remove']" v-hasPermi="['ActSuppliesDetails:ActSuppliesDetails:remove']"
>删除</el-button> >删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination <pagination
v-show="total>0" v-show="total>0"
:total="total" :total="total"
:page.sync="queryParams.pageNum" :page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize" :limit.sync="queryParams.pageSize"
@pagination="getList" @pagination="getList"
/> />
<!-- 添加或修改物料细分类管理对话框 --> <!-- 添加或修改物料细分类管理对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <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 ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="上级分类" prop="sid"> <el-form-item label="上级分类" prop="sid">
<el-select v-model="form.sid" filterable placeholder="请选择所属分类" style="width:380px" > <el-select v-model="form.sid" filterable placeholder="请选择所属分类" style="width:380px" >
<el-option <el-option
v-for="option in options2" v-for="option in options2"
:key="option.suppliesName" :key="option.suppliesName"
:label="option.fname==null ? option.id+'-'+option.suppliesName : option.fname+'-'+option.suppliesName" :label="option.fname==null ? option.id+'-'+option.suppliesName : option.fname+'-'+option.suppliesName"
:value="option.id" :value="option.id"
></el-option> ></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="物料名称" prop="detailsName"> <el-form-item label="物料名称" prop="detailsName">
<el-input v-model="form.detailsName" placeholder="请输入物料名称" maxlength="36"/> <el-input v-model="form.detailsName" placeholder="请输入物料名称" maxlength="36"/>
</el-form-item> </el-form-item>
<el-form-item label="所属系统" prop="sysclassify"> <el-form-item label="所属系统" prop="sysclassify">
<el-input v-model="form.sysclassify" placeholder="请输入所属系统" maxlength="36"/> <el-input v-model="form.sysclassify" placeholder="请输入所属系统" maxlength="36"/>
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="status" > <el-form-item label="状态" prop="status" >
<el-select v-model="form.status" placeholder="请选择状态" style="width:380px"> <el-select v-model="form.status" placeholder="请选择状态" style="width:380px">
<el-option label="启用" :value="0"></el-option> <el-option label="启用" :value="0"></el-option>
<el-option label="禁用" :value="1"></el-option> <el-option label="禁用" :value="1"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleExport123">确 定</el-button> <el-button type="primary" @click="handleExport123">确 定</el-button>
<el-button @click="cancel">取 消</el-button> <el-button @click="cancel">取 消</el-button>
</div> </div>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { listActSuppliesDetails, toggleEnable,toggleDisable,getActSuppliesDetails, delActSuppliesDetails, addActSuppliesDetails, updateActSuppliesDetails, exportActSuppliesDetails,saveSid } from "@/api/ActSuppliesDetails/ActSuppliesDetails"; import { listActSuppliesDetails, toggleEnable,toggleDisable,getActSuppliesDetails, delActSuppliesDetails, addActSuppliesDetails, updateActSuppliesDetails, exportActSuppliesDetails,saveSid } from "@/api/ActSuppliesDetails/ActSuppliesDetails";
export default { export default {
name: "ActSuppliesDetails", name: "ActSuppliesDetails",
components: { components: {
}, },
data() { data() {
return { return {
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 选中数组 // 选中数组
ids: [], ids: [],
name:[], name:[],
// 非单个禁用 // 非单个禁用
single: true, single: true,
// 非多个禁用 // 非多个禁用
multiple: true, multiple: true,
// 显示搜索条件 // 显示搜索条件
showSearch: true, showSearch: true,
// 总条数 // 总条数
total: 0, total: 0,
// 物料细分类管理表格数据 // 物料细分类管理表格数据
ActSuppliesDetailsList: [], ActSuppliesDetailsList: [],
options2:[],//初始化空数组
// 弹出层标题 options2:[],//初始化空数组
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
sid: null,
fname:null,
detailsName: null,
sysclassify: null,
status: 0,
},
// 表单参数
form: {
status:'0'
},
// 表单校验
rules: {
sid: [
{ required: true, message: "关联中类不能为空", trigger: "change" }
],
detailsName: [
{ required: true, message: "物料名称不能为空", trigger: "blur" }
],
sysclassify: [
{ required: true, message: "所属系统不能为空", trigger: "blur" }
]
},
idRules:[
{ pattern: /^\d+$/, message: 'ID只能输入数字', trigger: 'blur' }
]
};
},
created() {
this.getList();
},
mounted() {
this.fetchOptions();
},
methods: {
/**显示序号*/ // 弹出层标题
indexMethod(index){ title: "",
// const pageSize = this.queryParams.pageSize; // 是否显示弹出层
// const pageNumber = this.queryParams.pageNum || 1; open: false,
return index + 1; // 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
sid: null,
fname:null,
detailsName: null,
sysclassify: null,
status: 0,
},
// 表单参数
form: {
status:'0'
},
// 表单校验
rules: {
sid: [
{ required: true, message: "关联中类不能为空", trigger: "change" }
],
detailsName: [
{ required: true, message: "物料名称不能为空", trigger: "blur" }
],
sysclassify: [
{ required: true, message: "所属系统不能为空", trigger: "blur" }
]
},
idRules:[
{ pattern: /^\d+$/, message: 'ID只能输入数字', trigger: 'blur' }
]
};
},
created() {
this.getList();
}, },
mounted() {
this.fetchOptions();
},
methods: {
/**启用 */ /**显示序号*/
toggleEnable(actSuppliesDetails){ indexMethod(index){
console.log('你点击了【' + actSuppliesDetails.detailsName+'】的开关控件,当前开关值:' + actSuppliesDetails.status); // const pageSize = this.queryParams.pageSize;
let enableText=['启用','禁用']; // const pageNumber = this.queryParams.pageNum || 1;
if(actSuppliesDetails.status === 0) { return index + 1;
toggleEnable(actSuppliesDetails.id).then((response) =>{ },
if(response.code === 200){ /**启用 */
toggleEnable(actSuppliesDetails){
console.log('你点击了【' + actSuppliesDetails.detailsName+'】的开关控件,当前开关值:' + actSuppliesDetails.status);
let enableText=['启用','禁用'];
if(actSuppliesDetails.status === 0) {
toggleEnable(actSuppliesDetails.id).then((response) =>{
let message = '操作成功,已经将【' + actSuppliesDetails.detailsName +'】的状态改为【'+ enableText[actSuppliesDetails.status] +'】 !'; if(response.code === 200){
this.$message({
message: message,
type:'success'
});
}else {
this.$message.error(response.message);
}
});
}else {
toggleDisable(actSuppliesDetails.id).then((response) =>{
if(response.code === 200){
let message = '操作成功,已经将【' + actSuppliesDetails.detailsName +'】的状态改为【'+ enableText[actSuppliesDetails.status] +'】 !';
this.$message({
message: message,
type:'error'
});
}else {
this.$message.error(response.message);
}
});
}
},
/** 获取上级分类*/ let message = '操作成功,已经将【' + actSuppliesDetails.detailsName +'】的状态改为【'+ enableText[actSuppliesDetails.status] +'】 !';
fetchOptions() { this.$message({
saveSid().then(response => { message: message,
console.log(response.rows) type:'success'
this.options2 = response.rows; });
}); }else {
}, this.$message.error(response.message);
}
});
}else {
toggleDisable(actSuppliesDetails.id).then((response) =>{
if(response.code === 200){
let message = '操作成功,已经将【' + actSuppliesDetails.detailsName +'】的状态改为【'+ enableText[actSuppliesDetails.status] +'】 !';
this.$message({
message: message,
type:'error'
});
}else {
this.$message.error(response.message);
}
});
}
},
/** 查询物料细分类管理列表 */ /** 获取上级分类*/
getList() { fetchOptions() {
this.indexMethod(0); saveSid().then(response => {
this.loading = true; console.log(response.rows)
listActSuppliesDetails(this.queryParams).then(response => { this.options2 = response.rows;
this.ActSuppliesDetailsList = response.rows; });
this.total = response.total; },
this.loading = false;
}); /** 查询物料细分类管理列表 */
}, getList() {
// 取消按钮 this.indexMethod(0);
cancel() { this.loading = true;
this.open = false; listActSuppliesDetails(this.queryParams).then(response => {
this.reset(); this.ActSuppliesDetailsList = response.rows;
}, this.total = response.total;
// 表单重置 this.loading = false;
reset() {
this.form = {
id: null,
sid: null,
detailsName: null,
sysclassify: null,
status: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: 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.id)
this.name = selection.map(item => item.detailsName)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.fetchOptions();
this.reset();
this.open = true;
this.title = "新增物料";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getActSuppliesDetails(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改物料";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateActSuppliesDetails(this.form).then(response => {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
}); });
} else { },
addActSuppliesDetails(this.form).then(response => { // 取消按钮
this.msgSuccess("新增成功"); cancel() {
this.open = false; this.open = false;
this.getList(); this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
sid: null,
detailsName: null,
sysclassify: null,
status: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: 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.id)
this.name = selection.map(item => item.detailsName)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.fetchOptions();
this.reset();
this.open = true;
this.title = "新增物料";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getActSuppliesDetails(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改物料";
}); });
} },
} /** 提交按钮 */
}); submitForm() {
}, this.$refs["form"].validate(valid => {
/** 删除按钮操作 */ if (valid) {
handleDelete(row) { if (this.form.id != null) {
const ids = row.id || this.ids; updateActSuppliesDetails(this.form).then(response => {
const name = row.detailsName|| this.name ; this.msgSuccess("修改成功");
this.$confirm('是否确认删除物料名称为"' + name + '"的数据项?', "警告", { this.open = false;
confirmButtonText: "确定", this.getList();
cancelButtonText: "取消", });
type: "warning" } else {
}).then(function() { addActSuppliesDetails(this.form).then(response => {
return delActSuppliesDetails(ids); this.msgSuccess("新增成功");
}).then((result) => { this.open = false;
if (result.data==="操作失败"){ this.getList();
this.getList(); });
this.msgError("删除失败,存在关联关系"); }
}else { }
this.getList(); });
this.msgSuccess("删除成功"); },
} /** 删除按钮操作 */
}).catch(()=>{ handleDelete(row) {
}) const ids = row.id || this.ids;
}, const name = row.detailsName|| this.name ;
/** 导出按钮操作 */ this.$confirm('是否确认删除物料名称为"' + name + '"的数据项?', "警告", {
handleExport() { confirmButtonText: "确定",
const queryParams = this.queryParams; cancelButtonText: "取消",
this.$confirm('是否确认导出所有六矿物料数据项?', "警告", { type: "warning"
confirmButtonText: "确定", }).then(function() {
cancelButtonText: "取消", return delActSuppliesDetails(ids);
type: "warning" }).then((result) => {
}).then(function() { if (result.data==="操作失败"){
return exportActSuppliesDetails(queryParams); this.getList();
}).then(response => { this.msgError("删除失败,存在关联关系");
this.download(response.msg); }else {
}) this.getList();
}, this.msgSuccess("删除成功");
}
}).catch(()=>{
})
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有六矿物料数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return exportActSuppliesDetails(queryParams);
}).then(response => {
this.download(response.msg);
})
},
/** 导出设置 */ /** 导出设置 */
handleExport123: debounce(function() { handleExport123: debounce(function() {
// 处理点击事件 // 处理点击事件
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
if (this.form.id != null) { if (this.form.id != null) {
updateActSuppliesDetails(this.form).then(response => { updateActSuppliesDetails(this.form).then(response => {
this.msgSuccess("修改成功"); this.msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
} else { } else {
addActSuppliesDetails(this.form).then(response => { addActSuppliesDetails(this.form).then(response => {
this.msgSuccess("新增成功"); this.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
});
}
}
}); });
} }, 1000),
} }
});
}, 1000),
}
}; };
function debounce(func, delay) { function debounce(func, delay) {
let timer; let timer;
return function () { return function () {
const context = this; const context = this;
const args = arguments; const args = arguments;
clearTimeout(timer); clearTimeout(timer);
timer = setTimeout(function () { timer = setTimeout(function () {
func.apply(context, args); func.apply(context, args);
}, delay); }, delay);
}; };
} }
</script> </script>
...@@ -223,7 +223,7 @@ export default { ...@@ -223,7 +223,7 @@ export default {
{ required: true, message: "关联id不能为空", trigger: "change" }, { required: true, message: "关联id不能为空", trigger: "change" },
], ],
suppliesName:[ suppliesName:[
{ required: true, message: "物料名称不能为空", trigger: "blur" } { required: true, message: "二级分类名称不能为空", trigger: "blur" }
], ],
}, },
idRules:[ idRules:[
...@@ -351,7 +351,7 @@ export default { ...@@ -351,7 +351,7 @@ export default {
getSupplies(id).then(response => { getSupplies(id).then(response => {
this.form = response.data; this.form = response.data;
this.open = true; this.open = true;
this.title = "修改物料总分类管理"; this.title = "修改二级分类";
}); });
}, },
/** 提交按钮 */ /** 提交按钮 */
...@@ -380,7 +380,7 @@ export default { ...@@ -380,7 +380,7 @@ export default {
handleDelete(row) { handleDelete(row) {
const ids = row.id || this.ids; const ids = row.id || this.ids;
const name = row.suppliesName|| this.name; const name = row.suppliesName|| this.name;
this.$confirm('是否确认删除物料总分类管理编号为"' + name + '"的数据项?', "警告", { this.$confirm('是否确认删除二级分类编号为"' + name + '"的数据项?', "警告", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
......
...@@ -215,7 +215,7 @@ export default { ...@@ -215,7 +215,7 @@ export default {
{ required: true, message: "关联id不能为空", trigger: "change" }, { required: true, message: "关联id不能为空", trigger: "change" },
], ],
suppliesName:[ suppliesName:[
{ required: true, message: "物料名称不能为空", trigger: "blur" } { required: true, message: "一级分类名称不能为空", trigger: "blur" }
], ],
}, },
idRules:[ idRules:[
...@@ -339,7 +339,7 @@ export default { ...@@ -339,7 +339,7 @@ export default {
this.reset(); this.reset();
this.form.pid = 0; this.form.pid = 0;
this.open = true; this.open = true;
this.title = "新增级分类"; this.title = "新增级分类";
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
...@@ -348,7 +348,7 @@ export default { ...@@ -348,7 +348,7 @@ export default {
getSupplies(id).then(response => { getSupplies(id).then(response => {
this.form = response.data; this.form = response.data;
this.open = true; this.open = true;
this.title = "修改物料总分类管理"; this.title = "修改一级分类";
}); });
}, },
/** 提交按钮 */ /** 提交按钮 */
...@@ -377,7 +377,7 @@ export default { ...@@ -377,7 +377,7 @@ export default {
handleDelete(row) { handleDelete(row) {
const ids = row.id || this.ids; const ids = row.id || this.ids;
const name = row.suppliesName || this.name; const name = row.suppliesName || this.name;
this.$confirm('是否确认删除物料总分类管理编号为"' + name + '"的数据项?', "警告", { this.$confirm('是否确认删除一级分类编号为"' + name + '"的数据项?', "警告", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
......
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form ref="queryForm" size="small" :inline="true" label-width="68px"> <el-form ref="queryForm" size="small" :inline="true" label-width="68px">
<el-form-item label="模板" prop="name" > <el-form-item label="模板" prop="name" >
<el-select v-model="selectedOption" ref="mySelect" size="mini" @change="handleOptionChange" filterable placeholder="请选择您要查看的模板"> <el-select v-model="selectedOption" ref="mySelect" size="mini" @change="handleOptionChange" filterable placeholder="请选择您要查看的模板">
<!-- <el-option label="自设的模板名" value="使用空白模板"></el-option>--> <!-- <el-option label="自设的模板名" value="使用空白模板"></el-option>-->
<el-option <el-option
v-for="item in depss" :key="item.id" :label="item.templateName" :value="item.id"> v-for="item in depss" :key="item.id" :label="item.templateName" :value="item.id">
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="规则" prop="rule"> <el-form-item label="规则" prop="rule">
<el-select v-model="selectedRule" ref="mySelect" size="mini" @change="handleRuleChange" filterable placeholder="请选择您要查看的规则" > <el-select v-model="selectedRule" ref="mySelect" size="mini" @change="handleRuleChange" filterable placeholder="请选择您要查看的规则" >
<el-option <el-option
v-for="iem in luckyrule" :key="iem.id" :label="iem.roleName" :value="iem.id"> v-for="iem in luckyrule" :key="iem.id" :label="iem.roleName" :value="iem.id">
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="warning" type="warning"
plain plain
icon="el-icon-upload2" icon="el-icon-upload2"
size="mini" size="mini"
@click="handleExport" @click="handleExport"
>导出</el-button> v-hasPermi="['ruoyi-myexcel:myexcel:export']"
</el-col> >导出</el-button>
<el-col :span="1.5"> </el-col>
<el-upload <el-col :span="1.5">
type="file" <el-upload
name="file" type="file"
ref="upload" name="file"
:before-upload="handleFileChange" ref="upload"
action='' :before-upload="handleFileChange"
:limit="1" action=''
:file-list="fileList" :limit="1"
:disabled="disableNextButton" :file-list="fileList"
> :disabled="disableNextButton"
<el-button plain size="mini" icon="el-icon-download" type="primary" :disabled="disableNextButton" >导入</el-button>
</el-upload>
</el-col>
</el-row>
<!-- luckysheet容器 -->
<div
id="luckysheet"
style="margin: 0px; padding: 0px; position: absolute; width: 100%;left: 0px; top: 110px; height: 1000px; z-index: 0"
> >
</div> <el-button plain size="mini" icon="el-icon-download" type="primary" :disabled="disableNextButton" >导入</el-button>
</el-upload>
</el-col>
</el-row>
<!-- luckysheet容器 -->
<div
id="luckysheet"
style="margin: 0px; padding: 0px; position: absolute; width: 100%;left: 0px; top: 110px; height: 1000px; z-index: 0"
>
</div> </div>
</div>
</template> </template>
...@@ -71,910 +72,434 @@ var fileName="新建XLSX工作表"; //定义表名 ...@@ -71,910 +72,434 @@ var fileName="新建XLSX工作表"; //定义表名
var rule=[]; var rule=[];
var tempId; var tempId;
export default { export default {
name: "Mymodule", name: "Mymodule",
data() { data() {
return { return {
//弹出页面的表名 //弹出页面的表名
from_name : "", from_name : "",
// 是否显示弹出层 // 是否显示弹出层
dialogVisible : false, dialogVisible : false,
selectedOption:'', selectedOption:'',
selectedRule:'', selectedRule:'',
luckysheetData: '', luckysheetData: '',
fileList:[], fileList:[],
disableNextButton: true, disableNextButton: true,
luckyrule:[], luckyrule:[],
depss:[], depss:[],
// 表单参数 // 表单参数
form: {}, form: {},
// 查询参数 // 查询参数
queryParams: { queryParams: {
status:0 status:0
}, },
}; };
}, },
created() { created() {
//刷新页面时进行的操作 //刷新页面时进行的操作
this.getList(); this.getList();
},
mounted() {
this.init();
fileName="新建XLSX工作表";
},
methods:{
/** 页面刷新时展示的数据*/
getList() {
listSuppliesTemplate(this.queryParams).then(response => {
this.depss = response.rows;
});
},
/** 下拉选和页面luckysheet绑定 */
handleOptionChange() {
this.selectedRule='';
this.disableNextButton = this.selectedRule === '';
//根据选中的下拉选项值获取相应的信息
getSuppliesTemplate(this.selectedOption).then(response => {
tempId= this.selectedOption;
const sysSupplies = response.rows;
this.luckysheetData = sysSupplies[0].templateContent;
//将接收到的json存到json_data中
//const json_data = response.data;
var json_data = JSON.parse(sysSupplies[0].templateContent);
roleList(this.selectedOption).then(response => {
this.luckyrule = response.rows;
});
let suffixArr = sysSupplies[0].templateName.split('.');
fileName = suffixArr[0];
//luckysheet.destroy()
luckysheet.create({
container: "luckysheet", // Luckysheet 的容器元素 ID
title: fileName, // Excel 文件名
data: json_data, // Excel 数据
showinfobar: false, //是否显示顶部名称栏
lang:'zh',
});
}).catch(() => {
// 处理错误逻辑,这里是一个空的错误处理函数
this.$message.error('查询失败,发生未知错误!');
});
}, },
mounted() { /** 规则下拉选 调佣后端的方法*/
handleRuleChange(){
if (this.selectedOption==='') {
this.selectedRule='';
this.$message.warning("选择规则前请先选择模板!");
return ; // 如果按钮被禁用,提前返回,避免执行下一步操作
}
this.disableNextButton = this.selectedRule === '';
roleListid(this.selectedRule).then(response => {
rule=response.rows;
});
this.init(); },
/** 回车事件和保存提交绑定 */
handleEnter(event) {
if (event.keyCode === 13) {
event.preventDefault(); // 阻止默认的回车事件
// 触发确定操作
this.submit_from();
}
},
/** 重置按钮操作 */
resetQuery() {
//刷新下拉选框内容
fileName="新建XLSX工作表"; fileName="新建XLSX工作表";
this.selectedOption='';
this.disableNextButton='';
this.selectedRule='';
this.luckyrule=[];
//刷新luckysheet表格
this.init();
}, },
methods:{ /** Luckyexcel文档 */
/** 页面刷新时展示的数据*/ init() {
getList() { let options = {
listSuppliesTemplate(this.queryParams).then(response => { container: 'luckysheet', //luckysheet为容器id
this.depss = response.rows; title:'',
}); lang:'zh',
showinfobar:false,
}, data:[
/** 下拉选和页面luckysheet绑定 */ {
handleOptionChange() { "name": "sheet1", //工作表名称
this.selectedRule=''; "color": "", //工作表颜色
this.disableNextButton = this.selectedRule === ''; "index": 0, //工作表索引
//根据选中的下拉选项值获取相应的信息 "status": 1, //激活状态
getSuppliesTemplate(this.selectedOption).then(response => { "order": 0, //工作表的下标
tempId= this.selectedOption; "hide": 0,//是否隐藏
const sysSupplies = response.rows; "row": 8, //行数
this.luckysheetData = sysSupplies[0].templateContent; "column": 10, //列数
//将接收到的json存到json_data中 "defaultRowHeight": 19, //自定义行高
//const json_data = response.data; "defaultColWidth": 73, //自定义列宽
var json_data = JSON.parse(sysSupplies[0].templateContent); "celldata": [
roleList(this.selectedOption).then(response => {
this.luckyrule = response.rows;
}); ], //初始化使用的单元格数据
let suffixArr = sysSupplies[0].templateName.split('.'); "config": {
fileName = suffixArr[0]; "merge": {
//luckysheet.destroy() }, //合并单元格
luckysheet.create({ "rowlen":{}, //表格行高
container: "luckysheet", // Luckysheet 的容器元素 ID "columnlen":{}, //表格列宽
title: fileName, // Excel 文件名 "rowhidden":{}, //隐藏行
data: json_data, // Excel 数据 "colhidden":{}, //隐藏列
showinfobar: false, //是否显示顶部名称栏 "borderInfo":{
lang:'zh',
}); }, //边框
}).catch(() => { "authority":{}, //工作表保护
// 处理错误逻辑,这里是一个空的错误处理函数 },
this.$message.error('查询失败,发生未知错误!'); },
}); /*{
}, "name": "Sheet2",
/** 规则下拉选 调佣后端的方法*/ "color": "",
handleRuleChange(){ "index": 1,
if (this.selectedOption==='') { "status": 0,
this.selectedRule=''; "order": 1,
this.$message.warning("选择规则前请先选择模板!"); "celldata": [],
return ; // 如果按钮被禁用,提前返回,避免执行下一步操作 "config": {}
} },
this.disableNextButton = this.selectedRule === ''; {
roleListid(this.selectedRule).then(response => { "name": "Sheet3",
rule=response.rows; "color": "",
}); "index": 2,
"status": 0,
}, "order": 2,
/** 回车事件和保存提交绑定 */ "celldata": [],
handleEnter(event) { "config": {},
if (event.keyCode === 13) { }*/
event.preventDefault(); // 阻止默认的回车事件 ]
// 触发确定操作
this.submit_from(); }
} luckysheet.create(options);
},
/** 重置按钮操作 */ },
resetQuery() {
//刷新下拉选框内容 /** 导入事件*/
fileName="新建XLSX工作表"; handleFileChange(evt) {
this.selectedOption=''; if (this.disableNextButton) {
this.disableNextButton=''; this.$message.warning("请先选择模板再进行导入!");
this.selectedRule=''; return false; // 如果按钮被禁用,提前返回,避免执行下一步操作
this.luckyrule=[]; }
//刷新luckysheet表格 let name = evt.name
this.init(); let suffixArr = name.split('.'),
}, suffix = suffixArr[suffixArr.length - 1]
/** Luckyexcel文档 */ if (suffix !== 'xlsx') {
init() { this.$message({
let options = { message: "上传格式不正确,请上传xlsx格式文件",
container: 'luckysheet', //luckysheet为容器id type: "warning"});
title:'', return
lang:'zh', }
showinfobar:false, LuckyExcel.transformExcelToLucky(
data:[ evt,
{ function(exportJson) {
"name": "sheet1", //工作表名称 if (exportJson.sheets === null || exportJson.sheets.length === 0) {
"color": "", //工作表颜色 this.$message({
"index": 0, //工作表索引 message: "导入失败,请检查上传的文件是否正确",
"status": 1, //激活状态 type: "warning"
"order": 0, //工作表的下标 });
"hide": 0,//是否隐藏 return
"row": 8, //行数
"column": 10, //列数
"defaultRowHeight": 19, //自定义行高
"defaultColWidth": 73, //自定义列宽
"celldata": [
], //初始化使用的单元格数据
"config": {
"merge": {
}, //合并单元格
"rowlen":{}, //表格行高
"columnlen":{}, //表格列宽
"rowhidden":{}, //隐藏行
"colhidden":{}, //隐藏列
"borderInfo":{
}, //边框
"authority":{}, //工作表保护
},
},
/*{
"name": "Sheet2",
"color": "",
"index": 1,
"status": 0,
"order": 1,
"celldata": [],
"config": {}
},
{
"name": "Sheet3",
"color": "",
"index": 2,
"status": 0,
"order": 2,
"celldata": [],
"config": {},
}*/
]
}
luckysheet.create(options);
},
/** 导入事件*/
async handleFileChange(evt) {
let exx;
const cons = new Promise((resolve, reject) => {
LuckyExcel.transformExcelToLucky(evt, exportJson => {
exx = exportJson;
resolve(exx);
});
});
try {
const exportJson = await cons;
await this.summary(exportJson);
console.log('summary 执行完毕');
this.submit(exportJson);
} catch (Error) {
this.$message({
message: Error.message,
type: "error"});
console.log(Error.message);
console.log("这里是最外面的地方");
}
},
/** 物料转换汇总到页面*/
summary(exportJson){
let sysRulez;
let sysRules;
let sysConver;
let value=[];
let data;
//获取规则 sysRulez是物料转换 sysRules是数据汇总规则 13
for(let i=0;i<rule.length;i++){
if (rule[i].convertStatus==1){
sysRulez = JSON.parse(rule[i].detailContent);
} }
if(rule[i].convertStatus==2){ let sysRulez;
if (parseInt(rule[i].detailYS)===1){ let sysRules;
sysConver = JSON.parse(rule[i].detailContent) let value=[];
}else { let map=new Map();
//获取物料转换的规则
//
for(let i=0;i<rule.length;i++){
if (rule[i].convertStatus===1){
sysRulez = JSON.parse(rule[i].detailContent);
}
if(rule[i].convertStatus===2){
sysRules = JSON.parse(rule[i].detailContent); sysRules = JSON.parse(rule[i].detailContent);
} }
} }
}
try {
//获取物料转换的sheet表 //获取物料转换的sheet表
data=window.luckysheet.transToData(exportJson.sheets[sysRulez[0].se].celldata); let data=window.luckysheet.transToData(exportJson.sheets[sysRulez[0].se].celldata);
} window.luckysheet.set
catch (err){ let key_i=sysRulez[0].ce;
throw new Error("导入失败,所选文件或规则有误"); //获取物料转换的数据
} for (let i=0;i<sysRules.length;i++){
//获取物料转换中导入表的列,用来获取物料名 //value.push(data[sysRules[i].re][sysRules[i].ce].m);
let key_i=parseInt(sysRulez[0].ce);
//获取物料转换的数据 value.push(sysRules[i].ce);
for (let i=0;i<sysRules.length;i++){ }
//value.push(data[sysRules[i].re][sysRules[i].ce].m);
value.push(sysRules[i].ce);
}
//console.log("value的值为:"+value);
return new Promise((resolve, reject) => {
const asyncTasks = [];
switch (tempId) {
case 2:
{
let departmentMap = new Map();
let departments = [];
departmentMap.set('原煤', ['综一队', '综二队', '综三队', '开一区', '开二区', '准备一区', '准备二区', '掘进一区', '掘进二区', '掘进三区', '开拓项目部', '巷修区', '井运区', '通风区', '机电运转中心', '皮带运输中心']);
departmentMap.set('风选煤', '洗煤厂');
departmentMap.set('制造费用', ['机电检修中心', '地测科', '设备管理科', '旧品利用中心', '机修加工中心', '网络安全与信息通讯中心', '保卫科', '煤质管理科', '迁建科', '综合服务中心']);
departmentMap.set('管理费用', ['财务部', '综合办公室', '纪委监察科', '工会', '团委', '安全管理部', '经营管理部', '党委组织部(人力资源部)', '党委宣传部', '生产技术部', '机电运输部', '科协', '节能环保法律办公室', '党委组织部', '人力资源部']);
for (let i = parseFloat(sysRulez[0].re) + 1; i < data.length; i++) {
let n = parseInt(sysRules[0].ce) + 2;
if (data[i][key_i] != null && data[i][n] != null) {
let num = data[i][n].m;
//根据得到的num,找到对应的key
let keyy = getKeyByValue(departmentMap, num);
departments.push(keyy);
} else {
departments.push(null);
}
}
for (let key of departmentMap.keys()) {
let map = new Map();
let smallMat = [];
//console.log(departments);
for (let i = parseFloat(sysRulez[0].re) + 1; i < data.length; i++) {
if (data[i][key_i] != null && departments[i - 1] === key) {
let num = data[i][key_i].m;
smallMat.push(num);
} else {
smallMat.push(null);
}
}
//console.log(smallMat);
asyncTasks.push(
new Promise((innerResolve, innerReject) => {
const allNull = smallMat.every(item =>item===null);
if (allNull ) {
throw new Error("导入失败,导入文件错误,所选文件与模板规则不匹");
}
materialConvert(smallMat)
.then(response => {
let array = response.rows;
//console.log(array);
//luckysheet.setCellValue(12, 1, {bg:"#FF0000"})
for (let i = parseFloat(sysRulez[0].re) + 1; i < data.length; i++) {
let values = [];
if (data[i][13] != null && departments[i - 1] === key && data[i][key_i] != null) {
for (let j = 0; j < value.length; j++) {
let a = parseFloat(data[i][value[j]].v);
values.push(a);
}
//插入多个value的值
let index = smallMat.indexOf(data[i][key_i].m);
let key = array[index];
if (map.has(key)) {
let oldValues = map.get(key);
for (let i = 0; i < values.length; i++) {
values[i] = parseFloat(parseFloat(values[i] + oldValues[i]).toFixed(2));
}
map.set(key, values);
} else {
map.set(key, values);
}
}
}
//循环得到汇总结果
//console.log(map);
let cells;
let rowss = luckysheet.find(key);
if (rowss.length != 0) {
for (let i = 0; i < sysRules.length; i++) {
map.forEach((value, key) => {
let searchResult = luckysheet.find(key);
if (searchResult.length != 0 && key != null) {
cells = searchResult[0].column;
luckysheet.setCellValue(rowss[0].row, cells, value[i]);
luckysheet.setCellValue(rowss[0].row, cells, {
"ct": {
"fa": "General",
"t": "n"
}
});
}
});
}
}
}).catch(Error => { let smallMat=[];
console.log("这里是单个异步请求出错处"); for(let i=parseInt(sysRulez[0].re)+1;i<data.length;i++){
//必须加,不能删除 if(data[i][key_i]!=null){
innerReject(Error); // 异步请求出错 let num=data[i][key_i].m;
}); smallMat.push(num);
})); }else{
} smallMat.push(null);
} }
break; }
case 6: {
let deps = [];
let exps = [];
let map = new Map();
let smallMat = [];
for (let i = parseFloat(sysRulez[0].re) + 1; i < data.length; i++) {
if (data[i][key_i] != null) {
let num = data[i][key_i].m;
let dep = data[i][1].m;
let exp = data[i][14].m;
smallMat.push(num);
deps.push(dep);
exps.push(exp);
} else {
smallMat.push(null);
deps.push(null);
exps.push(null);
}
}
//console.log(smallMat);
asyncTasks.push(
new Promise((innerResolve, innerReject) => {
const allNull = smallMat.every(item =>item===null);
const allNull1 = deps.every(item =>item===null);
const allNull2 = exps.every(item =>item===null);
if (allNull || allNull1 ||allNull2) {
throw new Error("导入失败,导入文件错误,所选文件与模板规则不匹");
}
materialConvert(smallMat)
.then(response => {
let array = response.rows;
//console.log(array);
//luckysheet.setCellValue(12, 1, {bg:"#FF0000"})
for (let i = parseFloat(sysRulez[0].re) + 1, k = 0; i < data.length; i++, k++) {
let values = [];
if (data[i][key_i] != null) {
for (let j = 0; j < value.length; j++) {
try{
let a = parseFloat(data[i][value[j]].v);
values.push(a);
}catch(err){
throw new Error("导入失败,导入文件不匹");
}
}
//插入多个value的值
let key = exps[k] + '/' + deps[k] + '/' + array[k];
if (map.has(key)) {
let oldValues = map.get(key);
for (let i = 0; i < values.length; i++) {
values[i] = parseFloat(parseFloat(values[i] + oldValues[i]).toFixed(2));
}
map.set(key, values);
} else {
map.set(key, values);
}
}
} materialConvert(smallMat).then(response => {
//循环得到汇总结果 debugger
console.log(map); let array = response.rows;
if (map.size === 0) { //luckysheet.setCellValue(12, 1, {bg:"#FF0000"})
throw new Error("导入失败,导入文件错误"); for (let i =parseInt(sysRulez[0].re)+1; i < data.length; i++) {
let values = [];
if(data[i][key_i]!=null){
for(let j=0;j<value.length;j++) {
let a = parseFloat(data[i][value[j]].v);
if (isNaN(a)){
a=0;
} }
//循环得到汇总结果 values.push(a);
let cells;
let rowws;
let con=0;
let warn;
for (let i = 0; i < sysRules.length; i++) {
map.forEach((value, key) => {
const suffixArr = key.split('/'), mat = suffixArr[2], depp = suffixArr[1],
expp = suffixArr[0];
//console.log(expp);console.log(depp);console.log(mat);
let searchResult = luckysheet.find(expp);
if (searchResult.length === 0 && expp == null) {
warn++;
return
}
rowws = searchResult[0].row;
for (let i = 1; i < 10000000000000000000000000; i++) {
let n = rowws + i;
let gg = luckysheet.getCellValue(n, 0);
if (gg!==null) {
con = rowws + i;
break;
}
}
searchResult= luckysheet.find(depp);
let k=0;
let r;
for(let i=0;i<searchResult.length;i++){
r = searchResult[i].row;
if(r<con&&r>=rowws){
k=1;
break;
}
}
if(k===1){
let matResult = luckysheet.find(mat);
if (matResult.length !== 0 && mat != null) {
cells = matResult[0].column;
luckysheet.setCellValue(r, cells, value[i]);
luckysheet.setCellValue(r, cells, {
"ct": {
"fa": "General",
"t": "n"
}
});
}
}
});
}
}).catch(Error => {
console.log("这里是单个异步请求出错处");
//必须加,不能删除
innerReject(Error); // 异步请求出错
});
}));
}
break;
case 1: {
let map = new Map();
let smallMat = [];
for (let i = parseInt(sysRulez[0].re) + 1; i < data.length; i++) {
if (data[i][key_i] != null) {
let num = data[i][key_i].m;
smallMat.push(num);
} else {
smallMat.push(null);
} }
}else{
break;
} }
for (let j = 0; j < value.length; j++) { //插入多个value的值
if (data[sysRulez[0].re][value[j]] != null) { let index = smallMat.indexOf(data[i][key_i].m);
let num = data[sysRulez[0].re][value[j]].m; let key = array[index];
smallMat.push(num); key = key+"-"+data[i][sysRulez[1].ce].m
} else { if (map.has(key)) {
smallMat.push(null); let oldValues = map.get(key);
for (let i=0;i<values.length;i++){
values[i] = parseFloat(parseFloat(parseFloat(values[i]) + parseFloat(oldValues[i])).toFixed(2));
} }
map.set(key, values);
} else {
map.set(key, values);
} }
//console.log(smallMat); }
asyncTasks.push( //循环得到汇总结果
new Promise((innerResolve, innerReject) => { let row;
const allNull = smallMat.every(item =>item===null); map.forEach((value, key) => {
if (allNull ) { let splitElement = key.split("-");
throw new Error("导入失败,导入文件错误,所选文件与模板规则不匹"); row = luckysheet.find(splitElement[0])[0].row
} if (splitElement[1] !== 'undefined') {
materialConvert(smallMat)
.then(response => { let find = luckysheet.find(splitElement[1])[0];
let array = response.rows; if (find != null && luckysheet.getCellValue(find.row, 0) === 0) {
//console.log(array); // for (let i =0;i<value.length;i++) {
//luckysheet.setCellValue(12, 1, {bg:"#FF0000"}) // luckysheet.setCellValue(sysConver[i].rt, sysConver[i].ct, value[i]);
for (let i = parseInt(sysRulez[0].re) + 1; i < data.length; i++) { // luckysheet.setCellValue(sysConver[i].rt, sysConver[i].ct, {
let values = []; // "ct": {
if (data[i][key_i] != null) { // "fa": "General",
for (let j = 0; j < value.length; j++) { // "t": "n"
try{ // }
let a = parseFloat(data[i][value[j]].v); // });
if (isNaN(a)) { // }
a = 0;
}
values.push(a);
}catch (err){
throw new Error("导入失败,导入文件不匹");
}
}
} else {
break;
}
//插入多个value的值
let index = smallMat.indexOf(data[i][key_i].m);
let key = array[index];
if (map.has(key)) {
let oldValues = map.get(key);
for (let i = 0; i < values.length; i++) {
values[i] = parseFloat(parseFloat(parseFloat(values[i]) + parseFloat(oldValues[i])).toFixed(2));
}
map.set(key, values);
} else { } else {
map.set(key, values);
} let rowindex;
} let colindex;
if (map.size === 0) { let config;
throw new Error("导入失败,导入文件错误");
} // let bord={
//循环得到汇总结果 // "rangeType": "cell",
let row; // "value": {
let con; // "row_index": 0,
let warn=0; // "col_index": 0,
console.log(map); // "l": {
for (let i = 0; i < sysRules.length; i++) { // "style": 1,
// "color": "#000000"
map.forEach((value, key) => { // },
let matchingCells = []; // "r": {
let name = data[sysRules[i].re][sysRules[i].ce].m // "style": 1,
if (name.includes("洗煤")) { // "color": "#000000"
row = sysRules[i].rt; // },
con = parseInt(sysRules[i].rt) + 10; // "t": {
} else { // "style": 1,
row = sysRules[i].rt; // "color": "#000000"
con = 54; // },
// "b": {
// "style": 1,
// "color": "#000000"
// }
// }
// };
let bord = {
"rangeType": "range",
"borderType": "border-all",
"style": "1",
"color": "#000000",
"range": [{
"row": [0, 0],
"column": [0, 0]
}]
} }
for (; row <= con; row++) {
let cellValue = luckysheet.getCellValue(row, parseInt(sysRulez[0].ct));
if (cellValue === null) { let cellValue = luckysheet.getcellvalue(row);
warn++ luckysheet.insertRow(row + 1)
} else { luckysheet.setCellValue(row + 1, sysRulez[0].ct, splitElement[0]);
if (cellValue.includes(key)) { luckysheet.setCellValue(row + 1, sysRulez[0].ct, cellValue[0]);
luckysheet.setCellValue(row, sysRules[i].ct, value[i]);
luckysheet.setCellValue(row, sysRules[i].ct, { // config = luckysheet.getConfig(0);
"ct": { // bord.value.row_index = row+1;
"fa": "General", // bord.value.col_index = parseInt(sysRulez[0].ct);
"t": "n" // config.borderInfo.push(bord);
} // luckysheet.setConfig(config);
}); //
break; // config = luckysheet.getConfig(0);
}else{ // bord.value.row_index = row+1;
} // bord.value.col_index = parseInt(sysRulez[0].ct)+1;
} // config.borderInfo.push(bord);
// luckysheet.setConfig(config);
luckysheet.setCellValue(row + 1, sysRulez[1].ct, splitElement[1]);
luckysheet.setCellValue(row + 1, sysRulez[1].ct, cellValue[2]);
// config = luckysheet.getConfig(0);
// bord.value.row_index = row+1;
// bord.value.col_index = parseInt(sysRulez[1].ct);
// config.borderInfo.push(bord);
// luckysheet.setConfig(config);
if (value[0]===0){
luckysheet.setCellValue(row + 1, parseInt(sysRules[0].ct) + 1, 0);
luckysheet.setCellValue(row + 1, parseInt(sysRules[0].ct) + 1, cellValue[4]);
}else {
luckysheet.setCellValue(row + 1, parseInt(sysRules[0].ct) + 1, value[1] / value[0]);
luckysheet.setCellValue(row + 1, parseInt(sysRules[0].ct) + 1, cellValue[4]);
} }
}); // config = luckysheet.getConfig(0);
} // bord.value.row_index = row+1;
let value2 = []; // bord.value.col_index = parseInt(sysRules[0].ct)+1;
let map2 = new Map; // config.borderInfo.push(bord);
for (let i = 0; i < sysConver.length; i++) { // luckysheet.setConfig(config);
//value.push(data[sysRules[i].re][sysRules[i].ce].m);
value2.push(sysConver[i].ce); for (let i = 0; i < value.length; i++) {
} luckysheet.setCellValue(row + 1, sysRules[i].ct, value[i]);
for (let i = parseInt(sysRulez[0].re) + 1; i < data.length; i++) { luckysheet.setCellValue(row + 1, sysRules[i].ct, {
let values2 = []; "ct": {
if (data[i][key_i] != null) { "fa": "General",
for (let j = 0; j < value2.length; j++) { "t": "n"
try{
let a = parseFloat(data[i][value2[j]].v);
if (isNaN(a)) {
a = 0;
} }
values2.push(a); });
}catch (err){ luckysheet.setCellValue(row + 1, sysRules[i].ct, cellValue[3]);
throw new Error("导入失败,导入文件不匹"); // config = luckysheet.getConfig(0);
} // bord.value.row_index = row+1;
// bord.value.col_index = parseInt(sysRules[i].ct);
// config.borderInfo.push(bord);
// luckysheet.setConfig(config);
} }
} else {
break; config = luckysheet.getConfig(0);
} bord.range[0].row = [row + 1, row + 1];
//插入多个value的值 bord.range[0].column = [sysRulez[0].ct, sysRules[sysRules.length - 1].ct];
let key = data[sysConver[0].re][sysConver[0].ce].v; config.borderInfo.push(bord);
if (map2.has(key)) { luckysheet.setConfig(config);
let oldValues = map2.get(key);
for (let i = 0; i < values2.length; i++) {
values2[i] = parseFloat(parseFloat(parseFloat(values2[i]) + parseFloat(oldValues[i])).toFixed(2));
}
map2.set(key, values2);
} else {
map2.set(key, values2);
} }
} }else {
if (map2.size === 0) { luckysheet.setCellValue(row, parseInt(sysRulez[1].ct), "");
throw new Error("导入失败,导入文件错误"); if (value[0]===0){
luckysheet.setCellValue(row, parseInt(sysRules[0].ct) + 1, 0);
}else {
luckysheet.setCellValue(row, parseInt(sysRules[0].ct) + 1, value[1] / value[0]);
} }
map2.forEach((value, key) => {
for (let i = 0; i < value.length; i++) { for (let i = 0; i < value.length; i++) {
luckysheet.setCellValue(sysConver[i].rt, sysConver[i].ct, value[i]); luckysheet.setCellValue(row, sysRules[i].ct, value[i]);
luckysheet.setCellValue(sysConver[i].rt, sysConver[i].ct, { // config = luckysheet.getConfig(0);
"ct": { // bord.value.row_index = row+1;
"fa": "General", // bord.value.col_index = parseInt(sysRules[i].ct);
"t": "n" // config.borderInfo.push(bord);
} // luckysheet.setConfig(config);
});
}
})
}).catch(Error => {
console.log("这里是单个异步请求出错处");
//必须加,不能删除
innerReject(Error); // 异步请求出错
});
}));
}
break;
case 7: {
let map = new Map();
let smallMat = [];
let deps = [];
for (let i = parseFloat(sysRulez[0].re) + 1; i < data.length; i++) {
if (data[i][sysRulez[1].ce]!= null && data[i][key_i]!= null ) {
let num = data[i][key_i].m;
let dep = data[i][sysRulez[1].ce].m;
if(dep){
smallMat.push(null);
deps.push(null);
}else{
smallMat.push(num);
deps.push(dep);
}
} else {
smallMat.push(null);
deps.push(null);
}
}
debugger
console.log(deps);
asyncTasks.push(
new Promise((innerResolve, innerReject) => {
const allNull = smallMat.every(item =>item===null);
if (allNull ) {
throw new Error("导入失败,导入文件错误,所选文件与模板规则不匹");
}
materialConvert(smallMat)
.then(response => {
let array = response.rows;
for (let i = parseFloat(sysRulez[0].re) + 1, k = 0; i < data.length; i++, k++) {
let values = [];
if (data[i][key_i] != null) {
for (let j = 0; j < value.length; j++) {
try{
let a = parseFloat(data[i][value[j]].v);
values.push(a);
}catch (err){
this.$message({
message: "导入失败,导入文件不匹",
type: "error"
});
innerReject(error); // 异步请求出错
}
}
//插入多个value的值
//此方法只适用于一对一唯一值
/*let index = smallMat.indexOf(data[i][key_i].m);
let key = array[index];*/
let key = array[k] + '/' + deps[k];
if (map.has(key)) {
let oldValues = map.get(key);
for (let i = 0; i < values.length; i++) {
values[i] = parseFloat(parseFloat(values[i] + oldValues[i]).toFixed(2));
}
map.set(key, values);
} else {
map.set(key, values);
}
} }
} }
//循环得到汇总结果
console.log(map);
if (map.size === 0) {
this.$message({
message: "导入失败,导入文件错误",
type: "error"
});
innerReject(error); // 异步请求出错
}
//返回单元格第二行的数据
//let celn=luckysheet.getcellvalue(1);
//返回当前工作表第1列数据
//let cown=luckysheet.getcellvalue(null,0);
let rowws;
let config;
let bord = {
"rangeType": "range",
"borderType": "border-all",
"style": "1",
"color": "#000000",
"range": [{
"row": [0, 0],
"column": [0, 0]
}]
}
let warn=0;
map.forEach((value, key) => {
const suffixArr = key.split('/'), mat = suffixArr[0], depp = suffixArr[1];
//console.log(mat);console.log(depp);
let searchResult = luckysheet.find(mat);
rowws = searchResult[0].row;
if (searchResult.length != 0 && key != null) {
luckysheet.insertRow(rowws + 1);
//输出部门数量金额
luckysheet.setCellValue(rowws + 1, sysRulez[1].ct, depp);
for (let i = 0; i < sysRules.length; i++) {
luckysheet.setCellValue(rowws + 1, sysRules[i].ct, value[i]);
//修改单元格样式
/*luckysheet.setCellValue(rowws+g, sysRules[i].ct, {
"ct": {
"fa": "General",
"t": "n"
}
});*/
}
//输出单价
luckysheet.setCellValue(rowws + 1, parseInt(sysRules[0].ct) + 1, value[1] / value[0]);
//修改单价样式
/*luckysheet.setCellValue(rowws+g,parseInt(sysRules[0].ct)+1,{
"ct": {
"fa": "0.0000",
"t": "n"
}
});*/
} else{
warn++;
}
config = luckysheet.getConfig(0);
bord.range[0].row = [rowws + 1, rowws + 1];
bord.range[0].column = [0, sysRules[sysRules.length - 1].ct];
config.borderInfo.push(bord);
luckysheet.setConfig(config);
});
console.log(warn);
/*let find1 = luckysheet.find("合计");
let number = parseInt(find1[0].row)-1;
luckysheet.setCellValue(find1[0].row, sysRules[sysRules.length-1].ct, "=SUM(F2:F"+number+")")*/
}).catch(Error => {
console.log("这里是单个异步请求出错处");
//必须加,不能删除
innerReject(Error); // 异步请求出错
}); });
})); let find1 = luckysheet.find("合计");
let number = parseInt(find1[0].row)-1;
luckysheet.setCellValue(find1[0].row, sysRules[sysRules.length-1].ct, "=SUM(F2:F"+number+")");
} }).catch(() => {
break; // 处理错误逻辑,这里是一个空的错误处理函数
default : console.log("走到这了,物料转换后续处理出问题了!!");
{
let map = new Map();
let smallMat = [];
for (let i = parseFloat(sysRulez[0].re) + 1; i < data.length; i++) {
if (data[i][key_i] != null) {
let num = data[i][key_i].m;
smallMat.push(num);
} else {
smallMat.push(null);
}
}
asyncTasks.push(
new Promise((innerResolve, innerReject) => {
const allNull = smallMat.every(item =>item===null);
if (allNull ) {
throw new Error("导入失败,导入文件错误,所选文件与模板规则不匹");
}
materialConvert(smallMat)
.then(response => {
let array = response.rows;
for (let i = parseFloat(sysRulez[0].re) + 1; i < data.length; i++) {
let values = [];
let index;
if (data[i][key_i] != null) {
for (let j = 0; j < value.length; j++) {
try{
let a = parseFloat(data[i][value[j]].v);
values.push(a);
}catch (err){
throw new Error("导入失败,导入文件不匹");
}
}
//插入多个value的值
index = smallMat.indexOf(data[i][key_i].m);
let key = array[index];
if (map.has(key)) {
let oldValues = map.get(key);
for (let i = 0; i < values.length; i++) {
values[i] = parseFloat(parseFloat(values[i] + oldValues[i]).toFixed(2));
}
map.set(key, values);
} else {
map.set(key, values);
}
}
} });
//循环得到汇总结果
console.log(map);
if (map.size === 0) {
throw new Error("导入失败,导入文件错误");
}
let rowws;
let warn = 0;
for (let i = 0; i < sysRules.length; i++) {
map.forEach((value, key) => {
let searchResult;
searchResult= luckysheet.find(key);
if (searchResult && searchResult.length !== 0 && key != null) {
rowws = searchResult[0].row;
luckysheet.setCellValue(rowws, sysRules[i].ct, value[i]);
luckysheet.setCellValue(rowws, sysRules[i].ct, {
"ct": {
"fa": "General",
"t": "n"
}
});
} else {
warn++;
}
});
}
if (warn / sysRules.length === map.size) {
throw new Error("导入文件与所选模板规则不匹配");
} else if (warn > 0) {
this.$message({
message: "还有"+warn/sysRules.length+"条大类未能匹配到",
type: "warning"});
}
resolve(response.rows);
innerResolve(); // 标记当前异步任务完成
}).catch(Error => {
console.log("这里是单个异步请求出错处");
//必须加,不能删除
innerReject(Error); // 异步请求出错
});
}));
}
break;
}
//切换到想要的sheet //切换到想要的sheet
luckysheet.setSheetActive(0); luckysheet.setSheetActive(0);
Promise.all(asyncTasks) })
.then(() => {
resolve(); // 所有异步请求执行完成 },
})
.catch(Error => { /** 导出设置 */
console.log("这里是所有的异步请求出错处"); handleExport: debounce(function() {
reject(Error); // 异步请求出错 // 处理点击事件
}); exportExcel(luckysheet.getAllSheets(),fileName)
}); }, 500), // 设置延迟时间,单位为毫秒
}, }
/** 保存导入文件和生成文件 */
submit(contents){
debugger
console.log("还是执行了保存方法");
const name = contents.info.name;
let objsheet = luckysheet.getAllSheets() // 得到表的数据
//LuckyExcel = objsheet // 将表的数据保存本地
let strsheet = JSON.stringify(objsheet)// 对象转化为字符串
const data={name :name,jsons:strsheet};
/*addMyluckyexcel(data).then(response => {
if(response.code==200){
this.$message({
message: '保存成功', type: 'success'
});
this.dialogVisible=false;
//this.$router.replace({ path: '/' }); //刷新整个页面会出错
//window.location.reload();//也是全局刷新,不合适
this.$router.go(-1);
}else{
this.$message.error('保存失败');
}
});*/
},
/** 导出设置 */
handleExport: debounce(function() {
// 处理点击事件
exportExcel(luckysheet.getAllSheets(),fileName)
}, 500), // 设置延迟时间,单位为毫秒
}
// 配置项111 // 配置项111
}; };
// debounce函数定义 // debounce函数定义
function debounce(func, delay) { function debounce(func, delay) {
let timer; let timer;
return function () { return function () {
const context = this; const context = this;
const args = arguments; const args = arguments;
clearTimeout(timer); clearTimeout(timer);
timer = setTimeout(function () { timer = setTimeout(function () {
func.apply(context, args); func.apply(context, args);
}, delay); }, delay);
}; };
}
function getKeyByValue(map, value) {
for (let [key, val] of map) {
if (val === value) {
return key;
}
if (Array.isArray(val) && val.includes(value)) {
return key;
}
}
} }
</script> </script>
...@@ -35,18 +35,18 @@ ...@@ -35,18 +35,18 @@
>新增 >新增
</el-button> </el-button>
</el-col> </el-col>
<!-- <el-col :span="1.5">--> <!-- <el-col :span="1.5">
<!-- <el-button--> <el-button
<!-- type="success"--> type="success"
<!-- plain--> plain
<!-- icon="el-icon-edit"--> icon="el-icon-edit"
<!-- size="mini"--> size="mini"
<!-- :disabled="single"--> :disabled="single"
<!-- @click="handleUpdate"--> @click="handleUpdate"
<!-- v-hasPermi="['SuppliesTemplate:SuppliesTemplate:edit']"--> v-hasPermi="['SuppliesTemplate:SuppliesTemplate:edit']"
<!-- >修改--> >修改
<!-- </el-button>--> </el-button>
<!-- </el-col>--> </el-col>-->
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="danger" type="danger"
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
>发布 >发布
</el-button> </el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
...@@ -78,24 +79,22 @@ ...@@ -78,24 +79,22 @@
<el-table-column type="selection" width="55" align="center"/> <el-table-column type="selection" width="55" align="center"/>
<el-table-column type="index" width="80" align="center" label="序号" :index="indexMethod"/> <el-table-column type="index" width="80" align="center" label="序号" :index="indexMethod"/>
<el-table-column label="模板名称" align="center" prop="templateName"/> <el-table-column label="模板名称" align="center" prop="templateName"/>
<!-- <el-table-column label="状态" align="center" prop="status">--> <!-- <el-table-column label="状态" align="center" prop="status">
<!-- <template slot-scope="scope">--> <template slot-scope="scope">
<!-- <div>--> <div>
<!-- <el-switch--> <el-switch
<!-- @change="toggleEnable(scope.row)"--> @change="toggleEnable(scope.row)"
<!-- v-model="scope.row.status"--> v-model="scope.row.status"
<!-- :active-value="0"--> :active-value="0"
<!-- :inactive-value="1"--> :inactive-value="1"
<!-- active-color="#13ce66"--> active-color="#13ce66"
<!-- inactive-color="#cccccc"--> inactive-color="#cccccc"
<!-- active-text="已发布"--> active-text="已发布"
<!-- inactive-text="未发布"--> inactive-text="未发布">
<!-- disabled = "true">--> </el-switch>
<!-- </el-switch>--> </div>
<!-- </div>--> </template>
<!-- </template>--> </el-table-column>-->
<!-- </el-table-column>-->
<el-table-column label="状态" align="center"> <el-table-column label="状态" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<div> <div>
...@@ -112,7 +111,7 @@ ...@@ -112,7 +111,7 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width" >
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
size="mini" size="mini"
...@@ -169,6 +168,14 @@ ...@@ -169,6 +168,14 @@
v-hasPermi="['SuppliesTemplate:SuppliesTemplate:remove']" v-hasPermi="['SuppliesTemplate:SuppliesTemplate:remove']"
>删除 >删除
</el-button> </el-button>
<el-button
size="mini"
type="text"
icon="el-icon-detailUpdate"
@click="detailUpdate(scope.row)"
v-hasPermi="['SuppliesTemplate:SuppliesTemplate:detailUpdate']"
>修改购入规则
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -215,6 +222,29 @@ ...@@ -215,6 +222,29 @@
</div> </div>
</el-dialog> </el-dialog>
<!-- 添加或修改导入规则对话框 -->
<el-dialog :title="title" :visible.sync="optionRole" width="500px" append-to-body>
<el-form ref="forms" :model="forms" :rules="rules" label-width="80px">
<el-form-item label="所属模板" prop="tempId">
<el-select v-model="selectedOption" filterable placeholder="请选择关联项" style="width:380px" @change="handleOptionChange(selectedOption)" >
<el-option
v-for="option in options1"
:key="option.roleName"
:label="option.roleName"
:value="option.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="规则名称" prop="roleName">
<el-input v-model="forms.roleName" placeholder="请输入规则名称" maxlength="36"/>
</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 id="luckysheet" :style="{ position: positionValue, top: '0', left: '0', right: '0', bottom: '0' }"></div> <div id="luckysheet" :style="{ position: positionValue, top: '0', left: '0', right: '0', bottom: '0' }"></div>
<!-- 遮罩层组件 --> <!-- 遮罩层组件 -->
...@@ -277,6 +307,9 @@ ...@@ -277,6 +307,9 @@
<script> <script>
import { import {
listSuppliesTemplate, listSuppliesTemplate,
listSuppliesrole,
getSuppliesrole,
updateSuppliesrole,
getSuppliesTemplate, getSuppliesTemplate,
delSuppliesTemplate, delSuppliesTemplate,
addSuppliesTemplate, addSuppliesTemplate,
...@@ -293,6 +326,7 @@ export default { ...@@ -293,6 +326,7 @@ export default {
name: "SuppliesTemplate", name: "SuppliesTemplate",
data() { data() {
return { return {
selectedOption:'',
positionValue: 'static', positionValue: 'static',
fileList: [{ fileList: [{
name: 'food.jpeg', name: 'food.jpeg',
...@@ -329,6 +363,10 @@ export default { ...@@ -329,6 +363,10 @@ export default {
open1: false, open1: false,
showProgress: false, showProgress: false,
uploadProgress: 0, uploadProgress: 0,
optionRole:false,
options1:[],
// 查询参数 // 查询参数
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
...@@ -339,6 +377,7 @@ export default { ...@@ -339,6 +377,7 @@ export default {
status: null, status: null,
}, },
form: {}, form: {},
forms: {},
rules: {}, rules: {},
} }
}, },
...@@ -355,7 +394,6 @@ export default { ...@@ -355,7 +394,6 @@ export default {
}, },
methods: { methods: {
/**启用 */ /**启用 */
toggleEnable(SuppliesTemplate) { toggleEnable(SuppliesTemplate) {
console.log('你点击了【' + SuppliesTemplate.s + '】的开关控件,当前开关值:' + SuppliesTemplate.status); console.log('你点击了【' + SuppliesTemplate.s + '】的开关控件,当前开关值:' + SuppliesTemplate.status);
...@@ -427,7 +465,6 @@ export default { ...@@ -427,7 +465,6 @@ export default {
}); });
this.uploading = false; this.uploading = false;
return isJpgOrPng; return isJpgOrPng;
}, },
// handleFileChange(event){ // handleFileChange(event){
...@@ -453,6 +490,7 @@ export default { ...@@ -453,6 +490,7 @@ export default {
// 取消按钮 // 取消按钮
cancel() { cancel() {
this.open = false; this.open = false;
this.optionRole = false;
this.reset(); this.reset();
}, },
// 表单重置 // 表单重置
...@@ -510,6 +548,27 @@ export default { ...@@ -510,6 +548,27 @@ export default {
this.msgError("文件文件已发布无法修改!!!") this.msgError("文件文件已发布无法修改!!!")
} }
}, },
detailUpdate(row) {
this.title="修改导入规则";
this.selectedOption='';
this.forms='';
this.instea='';
const id = row.id || this.ids
listSuppliesrole(id).then(response =>{
this.options1 = response.rows;
});
this.optionRole = true;
},
handleOptionChange(selectedOption) {
getSuppliesrole(selectedOption).then(response => {
this.forms = response.data;
this.optionRole = true;
});
},
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
if (!this.form.templateName) { if (!this.form.templateName) {
......
...@@ -20,13 +20,13 @@ ...@@ -20,13 +20,13 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="规则名称" prop="roleName"> <el-form-item label="规则名称" prop="roleName">
<!-- <el-select v-model="queryParams.roleName" filterable clearable placeholder="请选择规则" > <!-- <el-select v-model="queryParams.roleName" filterable clearable placeholder="请选择规则" >
<el-option <el-option
v-for="option in options1" v-for="option in options1"
:key="option.roleName" :key="option.roleName"
:label="option.roleName" :label="option.roleName"
:value="option.id" :value="option.id"
></el-option>--> ></el-option>-->
<el-input <el-input
v-model="queryParams.roleName" v-model="queryParams.roleName"
placeholder="请输入规则名称" placeholder="请输入规则名称"
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
size="small" size="small"
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
<!-- </el-select>--> <!-- </el-select>-->
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择状态"> <el-select v-model="queryParams.status" placeholder="请选择状态">
...@@ -59,17 +59,17 @@ ...@@ -59,17 +59,17 @@
v-hasPermi="['system:suppliesrole:add']" v-hasPermi="['system:suppliesrole:add']"
>新增</el-button> >新增</el-button>
</el-col> </el-col>
<!-- <el-col :span="1.5">--> <!-- <el-col :span="1.5">-->
<!-- <el-button--> <!-- <el-button-->
<!-- type="success"--> <!-- type="success"-->
<!-- plain--> <!-- plain-->
<!-- icon="el-icon-edit"--> <!-- icon="el-icon-edit"-->
<!-- size="mini"--> <!-- size="mini"-->
<!-- :disabled="single"--> <!-- :disabled="single"-->
<!-- @click="handleUpdate"--> <!-- @click="handleUpdate"-->
<!-- v-hasPermi="['system:suppliesrole:edit']"--> <!-- v-hasPermi="['system:suppliesrole:edit']"-->
<!-- >修改</el-button>--> <!-- >修改</el-button>-->
<!-- </el-col>--> <!-- </el-col>-->
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="danger" type="danger"
...@@ -109,23 +109,23 @@ ...@@ -109,23 +109,23 @@
<el-table-column type="index" width="80" align="center" label="序号" :index="indexMethod" /> <el-table-column type="index" width="80" align="center" label="序号" :index="indexMethod" />
<el-table-column label="所属模板" align="center" prop="templateName" /> <el-table-column label="所属模板" align="center" prop="templateName" />
<el-table-column label="规则名称" align="center" prop="roleName" /> <el-table-column label="规则名称" align="center" prop="roleName" />
<!-- <el-table-column label="状态" align="center">--> <!-- <el-table-column label="状态" align="center">-->
<!-- <template slot-scope="scope">--> <!-- <template slot-scope="scope">-->
<!-- <div>--> <!-- <div>-->
<!-- <el-switch--> <!-- <el-switch-->
<!-- @change="toggleEnable(scope.row)"--> <!-- @change="toggleEnable(scope.row)"-->
<!-- v-model="scope.row.status"--> <!-- v-model="scope.row.status"-->
<!-- :active-value="0"--> <!-- :active-value="0"-->
<!-- :inactive-value="1"--> <!-- :inactive-value="1"-->
<!-- active-color="#13ce66"--> <!-- active-color="#13ce66"-->
<!-- inactive-color="#cccccc"--> <!-- inactive-color="#cccccc"-->
<!-- active-text="已发布"--> <!-- active-text="已发布"-->
<!-- inactive-text="未发布"--> <!-- inactive-text="未发布"-->
<!-- disabled = "true">--> <!-- disabled = "true">-->
<!-- </el-switch>--> <!-- </el-switch>-->
<!-- </div>--> <!-- </div>-->
<!-- </template>--> <!-- </template>-->
<!-- </el-table-column>--> <!-- </el-table-column>-->
<el-table-column label="状态" align="center"> <el-table-column label="状态" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<div> <div>
...@@ -215,21 +215,21 @@ ...@@ -215,21 +215,21 @@
</el-form-item> </el-form-item>
<el-form-item label="规则名称" prop="roleName"> <el-form-item label="规则名称" prop="roleName">
<el-input v-model="form.roleName" placeholder="请输入规则名称" maxlength="15"/> <el-input v-model="form.roleName" placeholder="请输入规则名称" maxlength="15"/>
<!-- <el-select v-model="queryParams.roleName" filterable clearable placeholder="请选择规则" > <!-- <el-select v-model="queryParams.roleName" filterable clearable placeholder="请选择规则" >
<el-option <el-option
v-for="option in options1" v-for="option in options1"
:key="option.roleName" :key="option.roleName"
:label="option.roleName" :label="option.roleName"
:value="option.id" :value="option.id"
></el-option> ></el-option>
</el-select>--> </el-select>-->
</el-form-item> </el-form-item>
<!-- <el-form-item label="状态">--> <!-- <el-form-item label="状态">-->
<!-- <el-select v-model="form.status" style="width:380px">--> <!-- <el-select v-model="form.status" style="width:380px">-->
<!-- <el-option label="启用" :value="0"></el-option>--> <!-- <el-option label="启用" :value="0"></el-option>-->
<!-- <el-option label="禁用" :value="1"></el-option>--> <!-- <el-option label="禁用" :value="1"></el-option>-->
<!-- </el-select>--> <!-- </el-select>-->
<!-- </el-form-item>--> <!-- </el-form-item>-->
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button> <el-button type="primary" @click="submitForm">确 定</el-button>
...@@ -241,7 +241,7 @@ ...@@ -241,7 +241,7 @@
<el-dialog :title="title" :visible.sync="optionDetail" width="1300px" append-to-body> <el-dialog :title="title" :visible.sync="optionDetail" width="1300px" append-to-body>
<el-form ref="forms" :model="forms" :rules="rules" label-width="80px"> <el-form ref="forms" :model="forms" :rules="rules" label-width="80px">
<el-form-item label="规则详情" prop="roleId"> <el-form-item label="规则详情" prop="roleId">
<el-select v-model="forms.roleId" filterable placeholder="请选择关联项" @change="handleOptionChange(forms.roleId)" > <el-select v-model="selectedOption" filterable placeholder="请选择关联项" @change="handleOptionChange(selectedOption)" >
<el-option <el-option
v-for="option in options1" v-for="option in options1"
:key="option.detailName" :key="option.detailName"
...@@ -333,7 +333,7 @@ ...@@ -333,7 +333,7 @@
</style> </style>
<script> <script>
import { listSuppliesrole,detailUpdate,updateSuppliesroledetail,listSuppliesroledetail,toggleEnable,toggleDisable, getSuppliesrole,getSuppliesroledetail,delSuppliesrole, addSuppliesrole, updateSuppliesrole, exportSuppliesrole,saveSid, releaseRoleStatus, offShelfRoleStatus} from "@/api/system/suppliesrole"; import { listSuppliesrole,updateSuppliesroledetail,listSuppliesroledetail,toggleEnable,toggleDisable, getSuppliesrole,getSuppliesroledetail,delSuppliesrole, addSuppliesrole, updateSuppliesrole, exportSuppliesrole,saveSid, releaseRoleStatus, offShelfRoleStatus} from "@/api/system/suppliesrole";
import {delActSuppliesDetails} from "@/api/ActSuppliesDetails/ActSuppliesDetails"; import {delActSuppliesDetails} from "@/api/ActSuppliesDetails/ActSuppliesDetails";
/*import {listSuppliesroledetail, updateSuppliesroledetail} from "../../../api/system/suppliesrole";*/ /*import {listSuppliesroledetail, updateSuppliesroledetail} from "../../../api/system/suppliesrole";*/
...@@ -343,6 +343,7 @@ export default { ...@@ -343,6 +343,7 @@ export default {
}, },
data() { data() {
return { return {
selectedOption:'',
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 选中数组 // 选中数组
...@@ -542,20 +543,22 @@ export default { ...@@ -542,20 +543,22 @@ export default {
} }
}, },
/** 修改规则详情按钮操作*/
detailUpdate(row) { detailUpdate(row) {
this.reset(); this.title = "修改规则详情";
this.selectedOption='';
this.forms='';
this.instea='';
const id = row.id || this.ids const id = row.id || this.ids
listSuppliesroledetail(row.id).then(response =>{ listSuppliesroledetail(id).then(response =>{
this.options1 = response.rows;
this.options1 = response.rows;
}); });
this.optionDetail = true; this.optionDetail = true;
}, },
/** 修改规则下的规则 */
handleOptionChange(id){ handleOptionChange(selectedOption){
getSuppliesroledetail(selectedOption).then(response => {
getSuppliesroledetail(id).then(response => {
this.forms = response.data; this.forms = response.data;
const detailContent = response.data.detailContent; const detailContent = response.data.detailContent;
const parse = JSON.parse(detailContent); const parse = JSON.parse(detailContent);
...@@ -567,9 +570,10 @@ export default { ...@@ -567,9 +570,10 @@ export default {
this.instea = this.detailMH.length; this.instea = this.detailMH.length;
this.optionDetail = true; this.optionDetail = true;
this.title = "修改规则详情";
}); });
}, },
/** 提交按钮 */ /** 提交按钮 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment