备件安全库存查询
This commit is contained in:
@@ -0,0 +1,77 @@
|
|||||||
|
|
||||||
|
package org.nl.wms.sb.stat.rest;
|
||||||
|
|
||||||
|
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.nl.annotation.Log;
|
||||||
|
import org.nl.wms.sb.stat.service.DevicesafetyqtyqueryService;
|
||||||
|
import org.nl.wms.sb.stat.service.DevicesparepartivtService;
|
||||||
|
import org.nl.wms.sb.stat.service.dto.DevicesparepartivtDto;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Liuxy
|
||||||
|
* @date 2022-06-28
|
||||||
|
**/
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Api(tags = "备件安全库存查询")
|
||||||
|
@RequestMapping("/api/devicesafetyqtyquery")
|
||||||
|
@Slf4j
|
||||||
|
public class DevicesafetyqtyqueryController {
|
||||||
|
|
||||||
|
private final DevicesafetyqtyqueryService devicesafetyqtyqueryService;
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
@Log("备件安全库存查询")
|
||||||
|
@ApiOperation("备件安全库存查询")
|
||||||
|
//@PreAuthorize("@el.check('devicesparepartivt:list')")
|
||||||
|
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
|
||||||
|
return new ResponseEntity<>(devicesafetyqtyqueryService.queryAll(whereJson, page), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
@Log("新增备件安全库存查询")
|
||||||
|
@ApiOperation("新增备件安全库存查询")
|
||||||
|
//@PreAuthorize("@el.check('devicesparepartivt:add')")
|
||||||
|
public ResponseEntity<Object> create(@Validated @RequestBody DevicesparepartivtDto dto) {
|
||||||
|
devicesafetyqtyqueryService.create(dto);
|
||||||
|
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping
|
||||||
|
@Log("修改备件安全库存查询")
|
||||||
|
@ApiOperation("修改备件安全库存查询")
|
||||||
|
//@PreAuthorize("@el.check('devicesparepartivt:edit')")
|
||||||
|
public ResponseEntity<Object> update(@Validated @RequestBody DevicesparepartivtDto dto) {
|
||||||
|
devicesafetyqtyqueryService.update(dto);
|
||||||
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log("删除备件安全库存查询")
|
||||||
|
@ApiOperation("删除备件安全库存查询")
|
||||||
|
//@PreAuthorize("@el.check('devicesparepartivt:del')")
|
||||||
|
@DeleteMapping
|
||||||
|
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
|
||||||
|
devicesafetyqtyqueryService.deleteAll(ids);
|
||||||
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("导出数据")
|
||||||
|
@GetMapping(value = "/download")
|
||||||
|
public void download(HttpServletResponse response, @RequestParam Map whereJson) throws IOException {
|
||||||
|
devicesafetyqtyqueryService.download(whereJson, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
|
||||||
|
package org.nl.wms.sb.stat.service;
|
||||||
|
|
||||||
|
import org.nl.wms.sb.stat.service.dto.DevicesparepartivtDto;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Liuxy
|
||||||
|
* @description 服务接口
|
||||||
|
* @date 2022-06-28
|
||||||
|
**/
|
||||||
|
public interface DevicesafetyqtyqueryService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询数据分页
|
||||||
|
*
|
||||||
|
* @param whereJson 条件
|
||||||
|
* @param page 分页参数
|
||||||
|
* @return Map<String, Object>
|
||||||
|
*/
|
||||||
|
Map<String, Object> queryAll(Map whereJson, Pageable page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有数据不分页
|
||||||
|
*
|
||||||
|
* @param whereJson 条件参数
|
||||||
|
* @return List<DevicesparepartivtDto>
|
||||||
|
*/
|
||||||
|
List<DevicesparepartivtDto> queryAll(Map whereJson);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID查询
|
||||||
|
*
|
||||||
|
* @param stockrecord_id ID
|
||||||
|
* @return Devicesparepartivt
|
||||||
|
*/
|
||||||
|
DevicesparepartivtDto findById(Long stockrecord_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据编码查询
|
||||||
|
*
|
||||||
|
* @param code code
|
||||||
|
* @return Devicesparepartivt
|
||||||
|
*/
|
||||||
|
DevicesparepartivtDto findByCode(String code);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建
|
||||||
|
*
|
||||||
|
* @param dto /
|
||||||
|
*/
|
||||||
|
void create(DevicesparepartivtDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
*
|
||||||
|
* @param dto /
|
||||||
|
*/
|
||||||
|
void update(DevicesparepartivtDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多选删除
|
||||||
|
*
|
||||||
|
* @param ids /
|
||||||
|
*/
|
||||||
|
void deleteAll(Long[] ids);
|
||||||
|
|
||||||
|
void download(Map whereJson, HttpServletResponse response) throws IOException;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,197 @@
|
|||||||
|
|
||||||
|
package org.nl.wms.sb.stat.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.nl.exception.BadRequestException;
|
||||||
|
import org.nl.utils.FileUtil;
|
||||||
|
import org.nl.utils.SecurityUtils;
|
||||||
|
import org.nl.wms.basedata.master.service.ClassstandardService;
|
||||||
|
import org.nl.wms.sb.stat.service.DevicesafetyqtyqueryService;
|
||||||
|
import org.nl.wms.sb.stat.service.DevicesparepartivtService;
|
||||||
|
import org.nl.wms.sb.stat.service.dto.DevicesparepartivtDto;
|
||||||
|
import org.nl.wql.WQL;
|
||||||
|
import org.nl.wql.core.bean.WQLObject;
|
||||||
|
import org.nl.wql.util.WqlUtil;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Liuxy
|
||||||
|
* @description 服务实现
|
||||||
|
* @date 2022-06-28
|
||||||
|
**/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class DevicesafetyqtyqueryServiceImpl implements DevicesafetyqtyqueryService {
|
||||||
|
private final ClassstandardService classstandardService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||||
|
String material_type_id = MapUtil.getStr(whereJson, "material_type_id");
|
||||||
|
String class_idStr = (String) whereJson.get("class_idStr");
|
||||||
|
String material_code = MapUtil.getStr(whereJson, "material_code");
|
||||||
|
String type = MapUtil.getStr(whereJson, "type");
|
||||||
|
|
||||||
|
HashMap<String, String> map = new HashMap<>();
|
||||||
|
map.put("flag", "1");
|
||||||
|
map.put("type",type);
|
||||||
|
if (ObjectUtil.isNotEmpty(material_code)) map.put("material_code", "%"+material_code+"%");
|
||||||
|
//处理物料当前节点的所有子节点
|
||||||
|
if (!StrUtil.isEmpty(material_type_id)) {
|
||||||
|
map.put("material_type_id", material_type_id);
|
||||||
|
String classIds = classstandardService.getChildIdStr(material_type_id);
|
||||||
|
map.put("classIds", classIds);
|
||||||
|
} else if (ObjectUtil.isNotEmpty(class_idStr)) {
|
||||||
|
String classIds = classstandardService.getAllChildIdStr(class_idStr);
|
||||||
|
map.put("classIds", classIds);
|
||||||
|
}
|
||||||
|
JSONObject json = WQL.getWO("EM_DEVICESAFETQTYQUERY001").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "ivt.material_id DESC");
|
||||||
|
|
||||||
|
JSONArray content = json.getJSONArray("content");
|
||||||
|
for (int i = 0; i < content.size(); i++) {
|
||||||
|
JSONObject jsonObject = content.getJSONObject(i);
|
||||||
|
if (ObjectUtil.isEmpty(jsonObject.getString("safe_ivt_up"))) jsonObject.put("safe_ivt_up","99999999");
|
||||||
|
if (ObjectUtil.isEmpty(jsonObject.getString("safe_ivt_down"))) jsonObject.put("safe_ivt_down","0");
|
||||||
|
}
|
||||||
|
json.put("content",content);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DevicesparepartivtDto> queryAll(Map whereJson) {
|
||||||
|
WQLObject wo = WQLObject.getWQLObject("em_bi_devicesparepartivt");
|
||||||
|
JSONArray arr = wo.query().getResultJSONArray(0);
|
||||||
|
if (ObjectUtil.isNotEmpty(arr)) return arr.toJavaList(DevicesparepartivtDto.class);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DevicesparepartivtDto findById(Long stockrecord_id) {
|
||||||
|
WQLObject wo = WQLObject.getWQLObject("em_bi_devicesparepartivt");
|
||||||
|
JSONObject json = wo.query("stockrecord_id = '" + stockrecord_id + "'").uniqueResult(0);
|
||||||
|
if (ObjectUtil.isNotEmpty(json)) {
|
||||||
|
return json.toJavaObject(DevicesparepartivtDto.class);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DevicesparepartivtDto findByCode(String code) {
|
||||||
|
WQLObject wo = WQLObject.getWQLObject("em_bi_devicesparepartivt");
|
||||||
|
JSONObject json = wo.query("code ='" + code + "'").uniqueResult(0);
|
||||||
|
if (ObjectUtil.isNotEmpty(json)) {
|
||||||
|
return json.toJavaObject(DevicesparepartivtDto.class);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void create(DevicesparepartivtDto dto) {
|
||||||
|
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||||
|
String nickName = SecurityUtils.getNickName();
|
||||||
|
String now = DateUtil.now();
|
||||||
|
|
||||||
|
dto.setStockrecord_id(IdUtil.getSnowflake(1, 1).nextId());
|
||||||
|
|
||||||
|
WQLObject wo = WQLObject.getWQLObject("em_bi_devicesparepartivt");
|
||||||
|
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||||
|
wo.insert(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void update(DevicesparepartivtDto dto) {
|
||||||
|
DevicesparepartivtDto entity = this.findById(dto.getStockrecord_id());
|
||||||
|
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||||
|
|
||||||
|
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||||
|
String nickName = SecurityUtils.getNickName();
|
||||||
|
|
||||||
|
String now = DateUtil.now();
|
||||||
|
|
||||||
|
WQLObject wo = WQLObject.getWQLObject("em_bi_devicesparepartivt");
|
||||||
|
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||||
|
wo.update(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void deleteAll(Long[] ids) {
|
||||||
|
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||||
|
String nickName = SecurityUtils.getNickName();
|
||||||
|
String now = DateUtil.now();
|
||||||
|
|
||||||
|
WQLObject wo = WQLObject.getWQLObject("em_bi_devicesparepartivt");
|
||||||
|
for (Long stockrecord_id : ids) {
|
||||||
|
JSONObject param = new JSONObject();
|
||||||
|
param.put("stockrecord_id", String.valueOf(stockrecord_id));
|
||||||
|
param.put("is_delete", "1");
|
||||||
|
param.put("update_optid", currentUserId);
|
||||||
|
param.put("update_optname", nickName);
|
||||||
|
param.put("update_time", now);
|
||||||
|
wo.update(param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void download(Map whereJson, HttpServletResponse response) throws IOException {
|
||||||
|
String material_type_id = MapUtil.getStr(whereJson, "material_type_id");
|
||||||
|
String class_idStr = (String) whereJson.get("class_idStr");
|
||||||
|
String material_code = MapUtil.getStr(whereJson, "material_code");
|
||||||
|
String type = MapUtil.getStr(whereJson, "type");
|
||||||
|
|
||||||
|
HashMap<String, String> map = new HashMap<>();
|
||||||
|
map.put("flag", "1");
|
||||||
|
map.put("type",type);
|
||||||
|
if (ObjectUtil.isNotEmpty(material_code)) map.put("material_code", "%"+material_code+"%");
|
||||||
|
//处理物料当前节点的所有子节点
|
||||||
|
if (!StrUtil.isEmpty(material_type_id)) {
|
||||||
|
map.put("material_type_id", material_type_id);
|
||||||
|
String classIds = classstandardService.getChildIdStr(material_type_id);
|
||||||
|
map.put("classIds", classIds);
|
||||||
|
} else if (ObjectUtil.isNotEmpty(class_idStr)) {
|
||||||
|
String classIds = classstandardService.getAllChildIdStr(class_idStr);
|
||||||
|
map.put("classIds", classIds);
|
||||||
|
}
|
||||||
|
JSONArray rows = WQL.getWO("EM_DEVICESAFETQTYQUERY001").addParamMap(map).process().getResultJSONArray(0);
|
||||||
|
|
||||||
|
for (int i = 0; i < rows.size(); i++) {
|
||||||
|
JSONObject jsonObject = rows.getJSONObject(i);
|
||||||
|
if (ObjectUtil.isEmpty(jsonObject.getString("safe_ivt_up"))) jsonObject.put("safe_ivt_up","99999999");
|
||||||
|
if (ObjectUtil.isEmpty(jsonObject.getString("safe_ivt_down"))) jsonObject.put("safe_ivt_down","0");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
|
for (int i = 0; i < rows.size(); i++) {
|
||||||
|
JSONObject jo = rows.getJSONObject(i);
|
||||||
|
Map<String, Object> dtl_map = new LinkedHashMap<>();
|
||||||
|
dtl_map.put("物料编码", jo.getString("material_code"));
|
||||||
|
dtl_map.put("物料名称", jo.getString("material_name"));
|
||||||
|
dtl_map.put("物料分类", jo.getString("class_name"));
|
||||||
|
dtl_map.put("安全库存上限", jo.getString("safe_ivt_up"));
|
||||||
|
dtl_map.put("安全库存下限", jo.getString("safe_ivt_down"));
|
||||||
|
dtl_map.put("库存", jo.getString("ivt_qty"));
|
||||||
|
dtl_map.put("单位", jo.getString("qty_unit_name"));
|
||||||
|
list.add(dtl_map);
|
||||||
|
}
|
||||||
|
FileUtil.downloadExcel(list, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
[交易说明]
|
||||||
|
交易名: 安全库存查询分页查询
|
||||||
|
所属模块:
|
||||||
|
功能简述:
|
||||||
|
版权所有:
|
||||||
|
表引用:
|
||||||
|
版本经历:
|
||||||
|
|
||||||
|
[数据库]
|
||||||
|
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库
|
||||||
|
|
||||||
|
[IO定义]
|
||||||
|
#################################################
|
||||||
|
## 表字段对应输入参数
|
||||||
|
#################################################
|
||||||
|
输入.flag TYPEAS s_string
|
||||||
|
输入.classIds TYPEAS f_string
|
||||||
|
输入.material_code TYPEAS s_string
|
||||||
|
输入.type TYPEAS s_string
|
||||||
|
|
||||||
|
|
||||||
|
[临时表]
|
||||||
|
--这边列出来的临时表就会在运行期动态创建
|
||||||
|
|
||||||
|
[临时变量]
|
||||||
|
--所有中间过程变量均可在此处定义
|
||||||
|
|
||||||
|
[业务过程]
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 1、输入输出检查 #
|
||||||
|
##########################################
|
||||||
|
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 2、主过程前处理 #
|
||||||
|
##########################################
|
||||||
|
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# 3、业务主过程 #
|
||||||
|
##########################################
|
||||||
|
|
||||||
|
IF 输入.flag = "1"
|
||||||
|
PAGEQUERY
|
||||||
|
SELECT
|
||||||
|
mater.material_code,
|
||||||
|
mater.material_name,
|
||||||
|
MAX( class.class_name ) AS class_name,
|
||||||
|
MAX( saivt.safe_ivt_up ) AS safe_ivt_up,
|
||||||
|
MAX( saivt.safe_ivt_down ) AS safe_ivt_down,
|
||||||
|
sum(ivt.ivt_qty) AS ivt_qty,
|
||||||
|
MAX(ivt.qty_unit_name) AS qty_unit_name
|
||||||
|
FROM
|
||||||
|
EM_BI_DeviceSparePartIvt ivt
|
||||||
|
LEFT JOIN ST_IVT_MaterialSafeIvt saivt ON saivt.material_id = ivt.material_id
|
||||||
|
LEFT JOIN md_me_materialbase mater ON mater.material_id = ivt.material_id
|
||||||
|
LEFT JOIN md_pb_classstandard class ON mater.material_type_id = class.class_id
|
||||||
|
WHERE
|
||||||
|
1=1
|
||||||
|
OPTION 输入.classIds <> ""
|
||||||
|
class.class_id in 输入.classIds
|
||||||
|
ENDOPTION
|
||||||
|
|
||||||
|
OPTION 输入.material_code <> ""
|
||||||
|
(mater.material_code like 输入.material_code or
|
||||||
|
mater.material_name like 输入.material_code)
|
||||||
|
ENDOPTION
|
||||||
|
|
||||||
|
OPTION 输入.type = "01"
|
||||||
|
ivt.ivt_qty > saivt.safe_ivt_up
|
||||||
|
ENDOPTION
|
||||||
|
|
||||||
|
OPTION 输入.type = "02"
|
||||||
|
ivt.ivt_qty < saivt.safe_ivt_down
|
||||||
|
ENDOPTION
|
||||||
|
|
||||||
|
OPTION 输入.type = "03"
|
||||||
|
saivt.safe_ivt_up <= ivt.ivt_qty <= saivt.safe_ivt_up
|
||||||
|
ENDOPTION
|
||||||
|
|
||||||
|
group by ivt.material_id
|
||||||
|
|
||||||
|
ENDSELECT
|
||||||
|
ENDPAGEQUERY
|
||||||
|
ENDIF
|
||||||
27
mes/qd/src/api/wms/sb/devicesafetyqtyquery.js
Normal file
27
mes/qd/src/api/wms/sb/devicesafetyqtyquery.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function add(data) {
|
||||||
|
return request({
|
||||||
|
url: 'api/devicesafetyqtyquery',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function del(ids) {
|
||||||
|
return request({
|
||||||
|
url: 'api/devicesafetyqtyquery/',
|
||||||
|
method: 'delete',
|
||||||
|
data: ids
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function edit(data) {
|
||||||
|
return request({
|
||||||
|
url: 'api/devicesafetyqtyquery',
|
||||||
|
method: 'put',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default { add, edit, del }
|
||||||
222
mes/qd/src/views/wms/sb/stat/devicesafetyqtyquery/index.vue
Normal file
222
mes/qd/src/views/wms/sb/stat/devicesafetyqtyquery/index.vue
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<!--工具栏-->
|
||||||
|
<div class="head-container">
|
||||||
|
<div v-if="crud.props.searchToggle">
|
||||||
|
<el-form
|
||||||
|
size="mini"
|
||||||
|
:inline="true"
|
||||||
|
class="demo-form-inline"
|
||||||
|
label-position="right"
|
||||||
|
label-width="80px"
|
||||||
|
label-suffix=":"
|
||||||
|
>
|
||||||
|
<el-form-item label="设备类别">
|
||||||
|
<treeselect
|
||||||
|
v-model="query.material_type_id"
|
||||||
|
:load-options="loadClass"
|
||||||
|
:options="classes"
|
||||||
|
style="width: 200px;"
|
||||||
|
placeholder="请选择"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="备件物料">
|
||||||
|
<el-input
|
||||||
|
v-model="query.material_code"
|
||||||
|
clearable
|
||||||
|
placeholder="编码、名称"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<!-- <el-form-item label="库存类型">
|
||||||
|
<el-select
|
||||||
|
v-model="query.type"
|
||||||
|
clearable
|
||||||
|
size="mini"
|
||||||
|
placeholder="请选择"
|
||||||
|
class="filter-item"
|
||||||
|
@change="hand"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in deviceTypeList"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>-->
|
||||||
|
<rrOperation />
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||||
|
<crudOperation :permission="permission">
|
||||||
|
<el-button
|
||||||
|
slot="right"
|
||||||
|
class="filter-item"
|
||||||
|
type="success"
|
||||||
|
icon="el-icon-check"
|
||||||
|
size="mini"
|
||||||
|
@click="downdtl"
|
||||||
|
>
|
||||||
|
导出Excel
|
||||||
|
</el-button>
|
||||||
|
</crudOperation>
|
||||||
|
<!--表格渲染-->
|
||||||
|
<el-table ref="table" border :cell-style="cellStyle" v-loading="crud.loading" :data="crud.data" size="mini" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
|
||||||
|
<el-table-column type="selection" width="55" />
|
||||||
|
<el-table-column prop="material_code" label="物料编码" />
|
||||||
|
<el-table-column prop="material_name" label="物料名称" />
|
||||||
|
<el-table-column prop="class_name" label="物料分类" />
|
||||||
|
<el-table-column prop="safe_ivt_up" label="安全库存上限" />
|
||||||
|
<el-table-column prop="safe_ivt_down" label="安全库存下限" />
|
||||||
|
<el-table-column prop="ivt_qty" label="库存" />
|
||||||
|
<el-table-column prop="qty_unit_name" label="单位" />
|
||||||
|
</el-table>
|
||||||
|
<!--分页组件-->
|
||||||
|
<pagination />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import crudDevicesafetyqtyquery from '@/api/wms/sb/devicesafetyqtyquery'
|
||||||
|
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
||||||
|
import rrOperation from '@crud/RR.operation'
|
||||||
|
import crudOperation from '@crud/CRUD.operation'
|
||||||
|
import udOperation from '@crud/UD.operation'
|
||||||
|
import pagination from '@crud/Pagination'
|
||||||
|
import { download } from '@/api/data'
|
||||||
|
import { downloadFile } from '@/utils'
|
||||||
|
import crudClassstandard from '@/api/wms/basedata/master/classstandard'
|
||||||
|
import Treeselect, { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
|
||||||
|
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||||
|
import crudMaterialbase from '@/api/wms/basedata/master/materialbase'
|
||||||
|
|
||||||
|
const defaultForm = { }
|
||||||
|
export default {
|
||||||
|
name: 'Devicesafetyqtyquery',
|
||||||
|
components: { pagination, crudOperation, rrOperation, udOperation, Treeselect },
|
||||||
|
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||||
|
cruds() {
|
||||||
|
return CRUD({
|
||||||
|
title: '备件安全库存量查询',
|
||||||
|
url: 'api/devicesafetyqtyquery',
|
||||||
|
idField: 'stockrecord_id',
|
||||||
|
sort: 'stockrecord_id,desc',
|
||||||
|
crudMethod: { ...crudDevicesafetyqtyquery },
|
||||||
|
optShow: {
|
||||||
|
add: false,
|
||||||
|
edit: false,
|
||||||
|
del: false,
|
||||||
|
download: false,
|
||||||
|
reset: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
classes: [],
|
||||||
|
class_idStr: null,
|
||||||
|
materOpt_code: '23',
|
||||||
|
deviceTypeList: [
|
||||||
|
{ 'label': '超上限', 'value': '01' },
|
||||||
|
{ 'label': '超下限', 'value': '02' },
|
||||||
|
{ 'label': '正常', 'value': '03' }
|
||||||
|
],
|
||||||
|
permission: {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
const param = {
|
||||||
|
'materOpt_code': this.materOpt_code
|
||||||
|
}
|
||||||
|
crudMaterialbase.getMaterOptType(param).then(res => {
|
||||||
|
this.class_idStr = res.class_idStr
|
||||||
|
this.crud.query.class_idStr = this.class_idStr
|
||||||
|
this.crud.toQuery()
|
||||||
|
this.queryClassId()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
|
||||||
|
[CRUD.HOOK.beforeRefresh]() {
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
hand(value) {
|
||||||
|
this.crud.toQuery()
|
||||||
|
},
|
||||||
|
loadClass({ action, parentNode, callback }) {
|
||||||
|
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||||
|
crudClassstandard.getClass({ pid: parentNode.id }).then(res => {
|
||||||
|
parentNode.children = res.content.map(function(obj) {
|
||||||
|
if (obj.hasChildren) {
|
||||||
|
obj.children = null
|
||||||
|
}
|
||||||
|
return obj
|
||||||
|
})
|
||||||
|
setTimeout(() => {
|
||||||
|
callback()
|
||||||
|
}, 100)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
queryClassId() {
|
||||||
|
const param = {
|
||||||
|
'class_idStr': this.class_idStr
|
||||||
|
}
|
||||||
|
crudClassstandard.queryClassById(param).then(res => {
|
||||||
|
this.classes = res.content.map(obj => {
|
||||||
|
if (obj.hasChildren) {
|
||||||
|
obj.children = null
|
||||||
|
}
|
||||||
|
return obj
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
downdtl() {
|
||||||
|
if (this.currentRow !== null) {
|
||||||
|
crud.downloadLoading = true
|
||||||
|
download('/api/devicesafetyqtyquery/download', this.crud.query).then(result => {
|
||||||
|
downloadFile(result, '备件安全库存量', 'xlsx')
|
||||||
|
crud.downloadLoading = false
|
||||||
|
}).catch(() => {
|
||||||
|
crud.downloadLoading = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
formatUp(row, cloum) {
|
||||||
|
if (row.safe_ivt_up === '') {
|
||||||
|
return '999999'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
formatDown(row, cloum) {
|
||||||
|
if (row.safe_ivt_down === '') {
|
||||||
|
return '0'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
cellStyle({ row, column, rowIndex, columnIndex }) {
|
||||||
|
const safe_ivt_down = parseInt(row.safe_ivt_down)
|
||||||
|
const safe_ivt_up = parseInt(row.safe_ivt_up)
|
||||||
|
const ivt_qty = parseInt(row.ivt_qty)
|
||||||
|
|
||||||
|
if (column.property === 'ivt_qty') {
|
||||||
|
if (ivt_qty > safe_ivt_up) {
|
||||||
|
return 'background: red'
|
||||||
|
}
|
||||||
|
if (ivt_qty < safe_ivt_down) {
|
||||||
|
return 'background: red'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (safe_ivt_down <= ivt_qty <= safe_ivt_up) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user