设备管理

This commit is contained in:
2023-03-16 09:50:39 +08:00
parent 8b6fb450a6
commit be87c64a8d
9 changed files with 293 additions and 407 deletions

View File

@@ -2,12 +2,11 @@
package org.nl.wms.pdm.rest;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.nl.common.anno.Log;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.anno.Log;
import org.nl.wms.pdm.service.DeviceService;
import org.nl.wms.pdm.service.dto.DeviceDto;
import org.springframework.data.domain.Pageable;
@@ -19,9 +18,9 @@ import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* @author geng by
* @date 2022-05-25
**/
* @author lyd
* @date 2023-03-15
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "生产设备管理")
@@ -61,7 +60,7 @@ public class DeviceController {
@ApiOperation("删除生产设备")
//@PreAuthorize("@el.check('device:del')")
@DeleteMapping
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
public ResponseEntity<Object> delete(@RequestBody String[] ids) {
deviceService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
@@ -74,46 +73,4 @@ public class DeviceController {
return new ResponseEntity<>(deviceService.getWorkprocedure(),HttpStatus.OK);
}
@PostMapping("/getItemByDevice")
@Log("获取设备下的项点")
@ApiOperation("获取设备下的项点")
//@PreAuthorize("@el.check('device:list')")
public ResponseEntity<Object> getItemByDevice(@RequestBody JSONObject param){
return new ResponseEntity<>(deviceService.getItemByDevice(param),HttpStatus.OK);
}
@PostMapping("/savaDeviceItem")
@Log("保存设备项点")
@ApiOperation("保存设备项点")
//@PreAuthorize("@el.check('device:list')")
public ResponseEntity<Object> savaDeviceItem(@RequestBody JSONObject param){
deviceService.savaDeviceItem(param);
return new ResponseEntity<>(HttpStatus.OK);
}
@PostMapping("/getItemByDeviceId")
@Log("动态获取表格列")
@ApiOperation("动态获取表格列")
//@PreAuthorize("@el.check('dcBaseDevice:list')")
public ResponseEntity<Object> getItemByDeviceId(@RequestBody JSONObject param){
return new ResponseEntity<>(deviceService.getItemByDeviceId(param),HttpStatus.OK);
}
@PostMapping("/copyAdd")
@Log("复制新增")
@ApiOperation("复制新增")
//@PreAuthorize("@el.check('dcBaseDevice:list')")
public ResponseEntity<Object> copyAdd(@RequestBody JSONObject param){
deviceService.copyAdd(param);
return new ResponseEntity<>(HttpStatus.OK);
}
@GetMapping("/queryById/{device_id}")
@Log("查询生产设备")
@ApiOperation("查询生产设备")
//@PreAuthorize("@el.check('device:list')")
public ResponseEntity<Object> queryById(@PathVariable("device_id") String device_id){
return new ResponseEntity<>(deviceService.queryById(device_id),HttpStatus.OK);
}
}

View File

@@ -2,82 +2,71 @@
package org.nl.wms.pdm.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.wms.pdm.service.dto.DeviceDto;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @description 服务接口
* @author geng by
* @date 2022-05-25
**/
* @description 服务接口
* @author lyd
* @date 2023-03-15
**/
public interface DeviceService {
/**
* 查询数据分页
* @param whereJson 条件
* @param page 分页参数
* @return Map<String,Object>
*/
* 查询数据分页
* @param whereJson 条件
* @param page 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(Map whereJson, Pageable page);
/**
* 查询所有数据不分页
* @param whereJson 条件参数
* @return List<DeviceDto>
*/
* 查询所有数据不分页
* @param whereJson 条件参数
* @return List<DeviceDto>
*/
List<DeviceDto> queryAll(Map whereJson);
/**
* 根据ID查询
* @param device_id ID
* @param device_code ID
* @return Device
*/
DeviceDto findById(Long device_id);
DeviceDto findById(String device_code);
/**
* 根据编码查询
* @param code code
* @return Device
*/
* 根据编码查询
* @param code code
* @return Device
*/
DeviceDto findByCode(String code);
/**
* 创建
* @param dto /
*/
* 创建
* @param dto /
*/
void create(DeviceDto dto);
/**
* 编辑
* @param dto /
*/
* 编辑
* @param dto /
*/
void update(DeviceDto dto);
/**
* 多选删除
* @param ids /
*/
void deleteAll(Long[] ids);
JSONArray getWorkprocedure();
JSONArray getItemByDevice(JSONObject param);
void savaDeviceItem(JSONObject param);
* 多选删除
* @param ids /
*/
void deleteAll(String[] ids);
/**
* 查询设备类型
* @param param
* 获取工序的下拉框
* @return
*/
Map<String,Object> getItemByDeviceId(JSONObject param);
void copyAdd(JSONObject param);
DeviceDto queryById(String device_id);
JSONArray getWorkprocedure();
}

View File

@@ -1,73 +1,87 @@
package org.nl.wms.pdm.service.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import java.util.Date;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @description /
* @author geng by
* @date 2022-05-25
**/
* @description /
* @author lyd
* @date 2023-03-15
**/
@Data
public class DeviceDto implements Serializable {
/** 设备标识 */
/** 防止精度丢失 */
@JsonSerialize(using= ToStringSerializer.class)
private Long device_id;
/** 设备编码 */
private String device_code;
/** 设备编码 */
private String device_code;
/** 设备名称 */
private String device_name;
/** 设备名称 */
private String device_name;
/** 生产区域 */
private String product_area;
/** 设备型号 */
private String device_model;
/** 工序标识 */
private Long workprocedure_id;
/** 外部编码 */
private String extend_code;
/** 设备档案标识 */
private Long devicebill_id;
/** 备注 */
private String remark;
/** 是否启用 */
private String is_active;
/** 创建人 */
private String create_id;
/** 创建人姓名 */
private String create_name;
/** 创建时间 */
private String create_time;
/** 是否删除 */
private String is_delete;
/** 工序标识 */
private Long workprocedure_id;
/** 外部编码 */
private String ext_code;
/** 物料标识 */
private Long material_id;
/** 生产班次工单标识 */
private Long produceorder_id;
/** 工单编号 */
private String workorder_code;
/** 生产班次工单编号 */
private String produceorder_code;
/** 设备编码2 */
private String device_code2;
/** 设备产能 */
private BigDecimal productivity;
/** 设备来料仓上限数 */
private BigDecimal inupperlimit_qty;
/** 设备来料仓下限数 */
private BigDecimal inlowerlimit_qty;
/** 设备产品仓上限数 */
private BigDecimal outupperlimit_qty;
/** 设备产品仓下限数 */
private BigDecimal outlowerlimit_qty;
/** 设备初始来料仓数 */
private BigDecimal deviceinitinstor_qty;
/** 设备实时来料仓数 */
private BigDecimal deviceinstor_qty;
/** 设备实时产品仓数 */
private BigDecimal deviceoutstor_qty;
/** 是否人工 */
private String is_artificial;
/** 备注 */
private String remark;
/** 创建人 */
private String create_id;
/** 创建人 */
private String create_name;
/** 创建时间 */
private String create_time;
/** 修改人 */
private String update_id;
/** 修改人 */
private String update_name;
/** 修改时间 */
private String update_time;
/** 是否删除 */
private String is_delete;
}

View File

@@ -3,36 +3,32 @@ package org.nl.wms.pdm.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 org.nl.common.anno.Log;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.utils.SecurityUtils;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.common.utils.SecurityUtils;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.ResultBean;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.WqlUtil;
import org.nl.wms.pdm.service.DeviceService;
import org.nl.wms.pdm.service.dto.DeviceDto;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author geng by
* @description 服务实现
* @date 2022-05-25
* @author lyd
* @date 2023-03-15
**/
@Service
@RequiredArgsConstructor
@@ -40,60 +36,17 @@ import java.util.Map;
public class DeviceServiceImpl implements DeviceService {
@Override
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
String workprocedure_id = MapUtil.getStr(whereJson, "workprocedure_id");
String search = MapUtil.getStr(whereJson, "search");
JSONObject map2 = new JSONObject();
map2.put("flag", "3");
map2.put("workprocedure_id", workprocedure_id);
if (!StrUtil.isEmpty(search)) {
map2.put("search", "%" + search + "%");
}
//根据工序获取设备信息
JSONObject json = WQL.getWO("PDM_BI_DEVICE01").addParamMap(map2).pageQuery(WqlUtil.getHttpContext(page), "device.create_time desc");
JSONArray jsonArray = json.getJSONArray("content");
JSONArray newContent = new JSONArray();
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
JSONObject map = new JSONObject();
String device_id = jsonObject.getString("device_id");
map.put("flag", "4");
map.put("device_id", device_id);
//获取设备所拥有的项点信息
JSONArray itemArray = WQL.getWO("PDM_BI_DEVICE01").addParamMap(map).process().getResultJSONArray(0);
JSONObject newMap = new JSONObject();
newMap.put("device_id", jsonObject.getString("device_id"));
newMap.put("device_code", jsonObject.getString("device_code"));
newMap.put("device_name", jsonObject.getString("device_name"));
newMap.put("device_model", jsonObject.getString("device_model"));
newMap.put("productivity", jsonObject.getString("productivity"));
newMap.put("workprocedure_id", jsonObject.getString("workprocedure_id"));
newMap.put("extend_code", jsonObject.getString("extend_code"));
newMap.put("devicebill_id", jsonObject.getString("devicebill_id"));
newMap.put("remark", jsonObject.getString("remark"));
newMap.put("is_active", jsonObject.getString("is_active"));
newMap.put("is_delete", jsonObject.getString("is_delete"));
//循环每个设备的项点信息将项点所对应的键设为项点编码对应动态表格的prop
for (int j = 0; j < itemArray.size(); j++) {
JSONObject itemObject = itemArray.getJSONObject(j);
if (itemObject.getString("data_type").equals("01")){
if (itemObject.getString("item_value").equals("0")){
newMap.put(itemObject.getString("item_code"), "");
}else {
newMap.put(itemObject.getString("item_code"), "");
}
}else {
newMap.put(itemObject.getString("item_code"), itemObject.getString("item_value"));
}
}
newContent.add(newMap);
}
json.put("content", newContent);
return json;
public Map<String,Object> queryAll(Map whereJson, Pageable page){
Map param = new HashMap();
param.put("flag", "1");
param.put("search", whereJson.get("search"));
param.put("workprocedure_id", whereJson.get("workprocedure_id"));
JSONObject jsonObject = WQL.getWO("QUERY_DEVICE").addParamMap(param).pageQuery(WqlUtil.getHttpContext(page), "device_code asc");
return jsonObject;
}
@Override
public List<DeviceDto> queryAll(Map whereJson) {
public List<DeviceDto> queryAll(Map whereJson){
WQLObject wo = WQLObject.getWQLObject("pdm_bi_device");
JSONArray arr = wo.query().getResultJSONArray(0);
if (ObjectUtil.isNotEmpty(arr)) return arr.toJavaList(DeviceDto.class);
@@ -101,21 +54,21 @@ public class DeviceServiceImpl implements DeviceService {
}
@Override
public DeviceDto findById(Long device_id) {
public DeviceDto findById(String device_code) {
WQLObject wo = WQLObject.getWQLObject("pdm_bi_device");
JSONObject json = wo.query("device_id = '" + device_id + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(json)) {
return json.toJavaObject(DeviceDto.class);
JSONObject json = wo.query("device_code = '" + device_code + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(json)){
return json.toJavaObject( DeviceDto.class);
}
return null;
}
@Override
public DeviceDto findByCode(String code) {
public DeviceDto findByCode(String code) {
WQLObject wo = WQLObject.getWQLObject("pdm_bi_device");
JSONObject json = wo.query("device_code ='" + code + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(json)) {
return json.toJavaObject(DeviceDto.class);
JSONObject json = wo.query("code ='" + code + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(json)){
return json.toJavaObject( DeviceDto.class);
}
return null;
}
@@ -126,13 +79,11 @@ public class DeviceServiceImpl implements DeviceService {
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
//编码唯一性校验
String device_code = dto.getDevice_code();
DeviceDto byCode = this.findByCode(device_code);
if (ObjectUtil.isNotEmpty(byCode)) throw new BadRequestException("编码已存在!");
dto.setDevice_id(IdUtil.getSnowflake(1, 1).nextId());
dto.setCreate_id(currentUserId);
dto.setCreate_name(nickName);
dto.setUpdate_id(currentUserId);
dto.setUpdate_name(nickName);
dto.setUpdate_time(DateUtil.now());
dto.setCreate_time(DateUtil.now());
WQLObject wo = WQLObject.getWQLObject("pdm_bi_device");
@@ -143,12 +94,19 @@ public class DeviceServiceImpl implements DeviceService {
@Override
@Transactional(rollbackFor = Exception.class)
public void update(DeviceDto dto) {
DeviceDto entity = this.findById(dto.getDevice_id());
DeviceDto entity = this.findById(dto.getDevice_code());
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
//编码唯一性校验
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
dto.setUpdate_time(DateUtil.now());
dto.setUpdate_id(currentUserId);
dto.setUpdate_name(nickName);
WQLObject wo = WQLObject.getWQLObject("pdm_bi_device");
String where = "is_delete = '0' and device_code = '" + dto.getDevice_code() + "' and device_id != '" + dto.getDevice_id() + "'";
String where = "is_delete = '0' and device_code = '" + dto.getDevice_code() + "'";
JSONObject jsonObject = wo.query(where).uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonObject)) {
@@ -162,16 +120,23 @@ public class DeviceServiceImpl implements DeviceService {
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteAll(Long[] ids) {
public void deleteAll(String[] ids) {
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
WQLObject wo = WQLObject.getWQLObject("pdm_bi_device");
WQLObject wo_value = WQLObject.getWQLObject("PDM_BI_DeviceItemValue");
for (Long device_id : ids) {
wo.delete("device_id = '" + device_id + "'");
wo_value.delete("device_id = '" + device_id + "'");
for (String device_code: ids) {
JSONObject param = new JSONObject();
param.put("device_code", String.valueOf(device_code));
param.put("is_delete", "1");
param.put("update_optid", currentUserId);
param.put("update_optname", nickName);
param.put("update_time", DateUtil.now());
wo.update(param);
}
}
@Override
public JSONArray getWorkprocedure() {
WQLObject wo = WQLObject.getWQLObject("pdm_bi_workprocedure");
@@ -179,107 +144,4 @@ public class DeviceServiceImpl implements DeviceService {
return resultJSONArray;
}
@Override
public JSONArray getItemByDevice(JSONObject param) {
JSONObject map = new JSONObject();
map.put("flag", "1");
map.put("device_id", param.getString("device_id"));
final JSONArray resultJSONArray = WQL.getWO("PDM_BI_DEVICE01").addParamMap(map).addParamMap(map).process().getResultJSONArray(0);
return resultJSONArray;
}
@Transactional(rollbackFor = Exception.class)
@Override
public void savaDeviceItem(JSONObject param) {
WQLObject wo = WQLObject.getWQLObject("PDM_BI_DeviceItemValue");
final JSONObject row = param.getJSONObject("row");
final JSONArray rows = param.getJSONArray("rows");
final String device_id = row.getString("device_id");
wo.delete("device_id = '" + device_id + "'");
for (int i = 0; i < rows.size(); i++) {
final JSONObject jsonObject = rows.getJSONObject(i);
final String item_id = jsonObject.getString("item_id");
JSONObject map = new JSONObject();
map.put("deviceitem_id", IdUtil.getSnowflake(1, 1).nextId());
map.put("device_id", device_id);
map.put("item_id", item_id);
map.put("item_value", jsonObject.getString("item_value"));
map.put("order_seq", i + 1);
wo.insert(map);
}
}
@Override
public Map<String, Object> getItemByDeviceId(JSONObject param) {
//动态获取设备类型下对应的项点信息
String workprocedure_id = param.getString("workprocedure_id");
String search = param.getString("search");
JSONObject map = new JSONObject();
map.put("flag", "2");
map.put("workprocedure_id", workprocedure_id);
if (StrUtil.isNotEmpty(search)) {
map.put("search", "%" + search + "%");
}
final JSONArray jsonArray = WQL.getWO("PDM_BI_DEVICE01").addParamMap(map).process().getResultJSONArray(0);
JSONArray newArray = new JSONArray();
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
String item_name = jsonObject.getString("item_name");
JSONObject json = new JSONObject();
json.put("label", item_name);
//将表格prop设置为项点编码
json.put("prop", jsonObject.getString("item_code"));
json.put("show", true);
if (item_name.length() >= 6) {
json.put("width", "150");
}
newArray.add(json);
}
JSONObject resultMap = new JSONObject();
resultMap.put("newArray", newArray);
return resultMap;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void copyAdd(JSONObject param) {
WQLObject wo = WQLObject.getWQLObject("PDM_BI_Device");
WQLObject wo_value = WQLObject.getWQLObject("PDM_BI_DeviceItemValue");
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
String device_id = IdUtil.getSnowflake(1, 1).nextId() + "";
JSONObject row = param.getJSONObject("row");
//编码唯一性校验
String device_code = row.getString("device_code");
DeviceDto byCode = this.findByCode(device_code);
if (ObjectUtil.isNotEmpty(byCode)) throw new BadRequestException("编码已存在!");
row.put("device_id", device_id);
row.put("create_id", currentUserId);
row.put("create_name", nickName);
row.put("create_time", DateUtil.now());
wo.insert(row);
JSONArray rows = param.getJSONArray("rows");
if (rows.size() > 0) {
for (int i = 0; i < rows.size(); i++) {
JSONObject jsonObject = rows.getJSONObject(i);
JSONObject map = new JSONObject();
map.put("deviceitem_id", IdUtil.getSnowflake(1, 1).nextId());
map.put("device_id", device_id);
map.put("item_id", jsonObject.getString("item_id"));
map.put("item_value", jsonObject.getString("default_value"));
map.put("order_seq", i + 1);
wo_value.insert(map);
}
}
}
@Override
public DeviceDto queryById(String device_id) {
DeviceDto deviceDto = this.findById(Long.parseLong(device_id));
return deviceDto;
}
}

View File

@@ -0,0 +1,60 @@
[交易说明]
交易名: 设备查询
所属模块:
功能简述:
版权所有:
表引用:
版本经历:
[数据库]
--指定数据库为空采用默认值默认为db.properties中列出的第一个库
[IO定义]
#################################################
## 表字段对应输入参数
#################################################
输入.flag TYPEAS s_string
输入.search TYPEAS s_string
输入.workprocedure_id TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
[临时变量]
--所有中间过程变量均可在此处定义
[业务过程]
##########################################
# 1、输入输出检查 #
##########################################
##########################################
# 2、主过程前处理 #
##########################################
##########################################
# 3、业务主过程 #
##########################################
IF 输入.flag = "1"
PAGEQUERY
SELECT
*
FROM
PDM_BI_Device device
WHERE
1 = 1
OPTION 输入.search <> ""
(device.device_code like "%" 输入.search "%" or
device.device_name like "%" 输入.search "%")
ENDOPTION
OPTION 输入.workprocedure_id <> ""
(device.workprocedure_id = 输入.workprocedure_id)
ENDOPTION
ENDSELECT
ENDPAGEQUERY
ENDIF

View File

@@ -47,14 +47,6 @@ export function savaDeviceItem(data) {
})
}
export function getItemByDeviceId(data) {
return request({
url: 'api/device/getItemByDeviceId',
method: 'post',
data
})
}
export function copyAdd(data) {
return request({
url: 'api/device/copyAdd',
@@ -70,4 +62,4 @@ export function queryById(device_id) {
})
}
export default { add, edit, del, getWorkprocedure, getItemByDevice, savaDeviceItem, getItemByDeviceId, copyAdd, queryById }
export default { add, edit, del, getWorkprocedure, getItemByDevice, savaDeviceItem, copyAdd, queryById }

View File

@@ -26,17 +26,6 @@
</div>
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<crudOperation :permission="permission">
<el-button
slot="right"
class="filter-item"
type="success"
icon="el-icon-position"
size="mini"
:disabled="crud.selections.length !== 1"
@click="addItem(crud.selections[0])"
>
设备扩展项
</el-button>
<el-button
slot="right"
class="filter-item"
@@ -69,30 +58,38 @@
<el-form-item label="设备名称" prop="device_name">
<el-input v-model="form.device_name" style="width: 370px;" />
</el-form-item>
<el-form-item label="设备型号">
<el-input v-model="form.device_model" style="width: 370px;" />
<el-form-item label="生产区域" prop="product_area">
<el-input v-model="form.product_area" style="width: 370px;" />
</el-form-item>
<el-form-item label="设备产能">
<el-input v-model="form.productivity" type="number" oninput="value = value.replace(/[^\d]/g, '')" style="width: 370px;" />
<el-form-item label="设备编码2">
<el-input v-model="form.device_code2" style="width: 370px;" />
</el-form-item>
<el-form-item label="所属工序">
<el-select v-model="form.workprocedure_id" filterable clearable class="filter-item" style="width: 370px">
<el-option
v-for="item in workList"
:key="item.workprocedure_id"
:label="item.workprocedure_name"
:value="item.workprocedure_id"
/>
</el-select>
<el-form-item label="设备来料仓上限数" prop="inupperlimit_qty">
<el-input v-model="form.inupperlimit_qty" style="width: 370px;" />
</el-form-item>
<el-form-item label="外部编码">
<el-input v-model="form.extend_code" style="width: 370px;" />
<el-form-item label="设备来料仓下限数" prop="inlowerlimit_qty">
<el-input v-model="form.inlowerlimit_qty" style="width: 370px;" />
</el-form-item>
<el-form-item label="设备产品仓上限数" prop="outupperlimit_qty">
<el-input v-model="form.outupperlimit_qty" style="width: 370px;" />
</el-form-item>
<el-form-item label="设备产品仓下限数" prop="outlowerlimit_qty">
<el-input v-model="form.outlowerlimit_qty" style="width: 370px;" />
</el-form-item>
<el-form-item label="设备初始来料仓数" prop="deviceinitinstor_qty">
<el-input v-model="form.deviceinitinstor_qty" style="width: 370px;" />
</el-form-item>
<el-form-item label="设备实时来料仓数" prop="deviceinstor_qty">
<el-input v-model="form.deviceinstor_qty" style="width: 370px;" />
</el-form-item>
<el-form-item label="设备实时产品仓数" prop="deviceoutstor_qty">
<el-input v-model="form.deviceoutstor_qty" style="width: 370px;" />
</el-form-item>
<el-form-item label="是否人工" prop="is_artificial">
<el-input v-model="form.is_artificial" style="width: 370px;" />
</el-form-item>
<!-- <el-form-item label="设备档案标识">
未设置字典,请手动设置 Select
</el-form-item>-->
<el-form-item label="备注">
<el-input v-model="form.remark" :rows="3" type="textarea" style="width: 370px;" />
<el-input v-model="form.remark" style="width: 370px;" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
@@ -103,32 +100,27 @@
<!--表格渲染-->
<el-table ref="table" 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="device_code" label="设备编码" />
<el-table-column prop="device_name" label="设备名称" min-width="200" show-overflow-tooltip />
<el-table-column prop="productivity" label="设备产能" />
<el-table-column prop="produceorder_code" label="工单编号" />
<template v-for="(item, index) in tableLabel">
<el-table-column
v-if="item.show"
:key="index"
:show-overflow-tooltip="true"
:prop="item.prop"
:label="item.label"
:min-width="item.width"
/>
</template>
<el-table-column label="是否启用" align="center" prop="is_active">
<el-table-column prop="device_code" label="设备编码" width="100px" show-overflow-tooltip/>
<el-table-column prop="device_name" label="设备名称" />
<el-table-column prop="product_area" label="生产区域" />
<el-table-column prop="device_code2" label="设备编码2" />
<el-table-column prop="inupperlimit_qty" label="设备来料仓上限数" width="120px"/>
<el-table-column prop="inlowerlimit_qty" label="设备来料仓下限数" width="120px"/>
<el-table-column prop="outupperlimit_qty" label="设备产品仓上限数" width="120px"/>
<el-table-column prop="outlowerlimit_qty" label="设备产品仓下限数" width="120px"/>
<el-table-column prop="deviceinitinstor_qty" label="设备初始来料仓数" width="120px"/>
<el-table-column prop="deviceinstor_qty" label="设备实时来料仓数" width="120px"/>
<el-table-column prop="deviceoutstor_qty" label="设备实时产品仓数" width="120px"/>
<el-table-column prop="is_artificial" label="是否人工" >
<template slot-scope="scope">
<el-switch
v-model="scope.row.is_active"
active-color="#409EFF"
inactive-color="#F56C6C"
active-value="1"
inactive-value="0"
@change="changeEnabled(scope.row, scope.row.is_active)"
/>
{{scope.row.is_artificial=='1'?'是':'否'}}
</template>
</el-table-column>
<el-table-column prop="remark" label="备注" width="120px" show-overflow-tooltip/>
<el-table-column prop="create_name" label="创建人" />
<el-table-column prop="create_time" label="创建时间" width="120px" show-overflow-tooltip/>
<el-table-column prop="update_name" label="修改人" />
<el-table-column prop="update_time" label="修改时间" width="120px" show-overflow-tooltip/>
<el-table-column v-permission="[]" label="操作" width="120px" align="center" fixed="right">
<template slot-scope="scope">
<udOperation
@@ -157,16 +149,19 @@ import pagination from '@crud/Pagination'
import DeviceItemDialog from '@/views/wms/pdm/device/DeviceItemDialog'
import DeviceInfoDialog from '@/views/wms/pdm/device/DeviceInfoDialog'
import CopyDialog from '@/views/wms/pdm/device/CopyDialog'
import crudSectattr from '@/api/wms/basedata/st/sectattr'
const defaultForm = { device_id: null, device_code: null, device_name: null, device_model: null, workprocedure_id: null, extend_code: null, devicebill_id: null, remark: null, is_active: null, create_id: null, create_name: null, create_time: null, is_delete: null, productivity: null }
const defaultForm = {device_code: null, device_name: null, product_area: null, workprocedure_id: null, ext_code: null,
material_id: null, workorder_code: null, device_code2: null, inupperlimit_qty: null, inlowerlimit_qty: null,
outupperlimit_qty: null, outlowerlimit_qty: null, deviceinitinstor_qty: null, deviceinstor_qty: null,
deviceoutstor_qty: null, is_artificial: null, remark: null, create_id: null, create_name: null, create_time: null,
update_id: null, update_name: null, update_time: null, is_delete: null }
export default {
name: 'Device',
components: { pagination, crudOperation, rrOperation, udOperation, DeviceItemDialog, CopyDialog, DeviceInfoDialog },
mixins: [presenter(), header(), form(defaultForm), crud()],
dicts: ['is_used'],
cruds() {
return CRUD({ title: '生产设备', url: 'api/device', idField: 'device_id', sort: 'device_id,desc',
return CRUD({ title: '生产设备', url: 'api/device', idField: 'device_code', sort: 'device_code,desc',
optShow: {
add: true,
edit: false,
@@ -188,6 +183,33 @@ export default {
],
device_name: [
{ required: true, message: '设备名称不能为空', trigger: 'blur' }
],
product_area: [
{ required: true, message: '生产区域不能为空', trigger: 'blur' }
],
inupperlimit_qty: [
{ required: true, message: '设备来料仓上限数不能为空', trigger: 'blur' }
],
inlowerlimit_qty: [
{ required: true, message: '设备来料仓下限数不能为空', trigger: 'blur' }
],
outupperlimit_qty: [
{ required: true, message: '设备产品仓上限数不能为空', trigger: 'blur' }
],
outlowerlimit_qty: [
{ required: true, message: '设备产品仓下限数不能为空', trigger: 'blur' }
],
deviceinitinstor_qty: [
{ required: true, message: '设备初始来料仓数不能为空', trigger: 'blur' }
],
deviceinstor_qty: [
{ required: true, message: '设备实时来料仓数不能为空', trigger: 'blur' }
],
deviceoutstor_qty: [
{ required: true, message: '设备实时产品仓数不能为空', trigger: 'blur' }
],
is_artificial: [
{ required: true, message: '是否人工不能为空', trigger: 'blur' }
]
}
}
@@ -197,12 +219,10 @@ export default {
},
methods: {
changeHeader(search, workprocedure_id) {
this.getHeader(search, workprocedure_id)
this.crud.toQuery()
},
// 钩子在获取表格数据之前执行false 则代表不获取数据
[CRUD.HOOK.beforeRefresh]() {
this.getHeader(this.query.search, this.query.workprocedure_id)
return true
},
// 改变状态
@@ -237,14 +257,11 @@ export default {
}
})
},
getWorkprocedure() {
getWorkprocedure() { // 获取工序下拉框
crudDevice.getWorkprocedure().then(res => {
this.workList = res
})
},
addItem(data) {
this.$refs.child.setForm(data)
},
deviceInfo(data) {
this.$refs.child1.setForm(data)
},
@@ -254,11 +271,6 @@ export default {
},
querytable() {
this.crud.toQuery()
},
getHeader(search, workprocedure_id) {
crudDevice.getItemByDeviceId({ search: search, workprocedure_id: workprocedure_id }).then(res => {
this.tableLabel = res.newArray
})
}
}
}