完成物料添加修改功能
parent
bc7f3078bc
commit
c267b1e645
|
@ -6,24 +6,20 @@ import com.wangziyang.mes.basedata.entity.SpMaterile;
|
||||||
import com.wangziyang.mes.basedata.entity.SpTableManager;
|
import com.wangziyang.mes.basedata.entity.SpTableManager;
|
||||||
import com.wangziyang.mes.basedata.request.SpFlowReq;
|
import com.wangziyang.mes.basedata.request.SpFlowReq;
|
||||||
import com.wangziyang.mes.basedata.service.ISpMaterileService;
|
import com.wangziyang.mes.basedata.service.ISpMaterileService;
|
||||||
|
import com.wangziyang.mes.common.BaseController;
|
||||||
import com.wangziyang.mes.common.Result;
|
import com.wangziyang.mes.common.Result;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import com.wangziyang.mes.common.BaseController;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 物料控制器
|
* 物料控制器
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author WangZiYang
|
* @author WangZiYang
|
||||||
|
@ -38,6 +34,7 @@ public class SpMaterileController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISpMaterileService iSpMaterileService;
|
private ISpMaterileService iSpMaterileService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物料管理界面
|
* 物料管理界面
|
||||||
*
|
*
|
||||||
|
@ -84,4 +81,34 @@ public class SpMaterileController extends BaseController {
|
||||||
IPage result = iSpMaterileService.page(req);
|
IPage result = iSpMaterileService.page(req);
|
||||||
return Result.success(result);
|
return Result.success(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料管理修改、新增
|
||||||
|
*
|
||||||
|
* @param record 物料实体类
|
||||||
|
* @return 执行结果
|
||||||
|
*/
|
||||||
|
@ApiOperation("物料管理修改、新增")
|
||||||
|
@PostMapping("/add-or-update")
|
||||||
|
@ResponseBody
|
||||||
|
public Result addOrUpdate( SpMaterile record) {
|
||||||
|
iSpMaterileService.saveOrUpdate(record);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除物料信息
|
||||||
|
*
|
||||||
|
* @param req 请求参数
|
||||||
|
* @return Result 执行结果
|
||||||
|
*/
|
||||||
|
@ApiOperation("删除物料信息")
|
||||||
|
@ApiImplicitParams({@ApiImplicitParam(name = "req", value = "物料实体", defaultValue = "物料实体")})
|
||||||
|
@PostMapping("/delete")
|
||||||
|
@ResponseBody
|
||||||
|
public Result deleteByTableNameId(SpMaterile req) throws Exception {
|
||||||
|
iSpMaterileService.removeById(req.getId());
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,15 +73,14 @@
|
||||||
class="layui-input" value="${result.size}">
|
class="layui-input" value="${result.size}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item"style="width: 1000px;" >
|
<div class="layui-form-item" style="width: 1000px;">
|
||||||
<label for="js-flowId" class="layui-form-label sp-required">工艺流程
|
<label for="js-flowId" class="layui-form-label sp-required">工艺流程
|
||||||
</label>
|
</label>
|
||||||
<div class="layui-input-inline">
|
<div class="layui-input-inline">
|
||||||
<select id="js-flowId" name="flowId" lay-filter="flow-filter" lay-verify="required"
|
<select id="js-flowId" name="flowId" lay-filter="flow-filter" lay-verify="required">
|
||||||
value="${result.flowDesc}">
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<p id="js-flowProcess" style="font-size:23px">测试->dd->dd</p>
|
<p id="js-flowProcess" style="font-size:23px"></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label for="js-is-deleted" class="layui-form-label sp-required">状态
|
<label for="js-is-deleted" class="layui-form-label sp-required">状态
|
||||||
|
@ -104,26 +103,17 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
layui.use(['form', 'util'], function () {
|
layui.use(['form', 'util'], function () {
|
||||||
var form = layui.form,
|
var form = layui.form,
|
||||||
util = layui.util;
|
util = layui.util;
|
||||||
var flowRows = [];
|
var flowRows = [];
|
||||||
|
//流程添加下拉框
|
||||||
getFlowData();
|
getFlowData();
|
||||||
$.each(flowRows, function (index, item) {
|
|
||||||
$('#js-flowId').append(new Option(item.flowDesc, item.id));
|
|
||||||
});
|
|
||||||
//给表单赋值
|
|
||||||
form.val("formTest", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
|
|
||||||
"size": "100*100*100",// "name": "value"
|
|
||||||
"flowId": 3
|
|
||||||
});
|
|
||||||
//获取表单区域所有值
|
|
||||||
var data1 = form.val("formTest");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化流程数据
|
* 初始化流程数据
|
||||||
|
@ -143,20 +133,42 @@
|
||||||
flowRows = data.data;
|
flowRows = data.data;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$.each(flowRows, function (index, item) {
|
||||||
|
$('#js-flowId').append(new Option(item.flowDesc, item.id));
|
||||||
|
});
|
||||||
|
//编辑时候根据回显的ID 绘制流程
|
||||||
|
flowProssbyId("${result.flowId}")
|
||||||
}
|
}
|
||||||
|
//初始化 物料类型
|
||||||
|
|
||||||
//下拉框选择 绘制流程时序图
|
//下拉框选择 绘制流程时序图
|
||||||
form.on('select(flow-filter)', function (data) {
|
form.on('select(flow-filter)', function (data) {
|
||||||
var newArr = flowRows.filter(function (obj) {
|
flowProssbyId(data.value)
|
||||||
return obj.id == data.value;
|
|
||||||
});
|
|
||||||
var lb_p = document.getElementById("js-flowProcess");
|
|
||||||
lb_p.innerHTML = newArr[0].process;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//通过ID 获取流程时序 绘制
|
||||||
|
function flowProssbyId(flowId) {
|
||||||
|
var newArr = flowRows.filter(function (obj) {
|
||||||
|
return obj.id == flowId;
|
||||||
|
});
|
||||||
|
if (newArr.length > 0) {
|
||||||
|
var lb_p = document.getElementById("js-flowProcess");
|
||||||
|
lb_p.innerHTML = newArr[0].process;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//给表单赋值
|
||||||
|
form.val("formTest", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
|
||||||
|
"flowId": "${result.flowId}"
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
//监听提交
|
//监听提交
|
||||||
form.on('submit(js-submit-filter)', function (data) {
|
form.on('submit(js-submit-filter)', function (data) {
|
||||||
spUtil.submitForm({
|
spUtil.submitForm({
|
||||||
url: "${request.contextPath}/admin/sys/role/add-or-update",
|
url: "${request.contextPath}/basedata/materile/add-or-update",
|
||||||
data: data.field
|
data: data.field
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,7 @@
|
||||||
if (obj.event === 'edit') {
|
if (obj.event === 'edit') {
|
||||||
spLayer.open({
|
spLayer.open({
|
||||||
title: '编辑',
|
title: '编辑',
|
||||||
area: ['800px', '400px'],
|
area: ['90%', '90%'],
|
||||||
// 请求url参数
|
// 请求url参数
|
||||||
spWhere: {id: data.id},
|
spWhere: {id: data.id},
|
||||||
content: '${request.contextPath}/basedata/materile/add-or-update-ui'
|
content: '${request.contextPath}/basedata/materile/add-or-update-ui'
|
||||||
|
@ -172,8 +172,25 @@
|
||||||
// 删除
|
// 删除
|
||||||
if (obj.event === 'delete') {
|
if (obj.event === 'delete') {
|
||||||
layer.confirm('确认要删除吗?', function (index) {
|
layer.confirm('确认要删除吗?', function (index) {
|
||||||
obj.del();
|
spUtil.ajax({
|
||||||
layer.close(index);
|
url: '${request.contextPath}/basedata/materile/delete',
|
||||||
|
async: false,
|
||||||
|
type: 'POST',
|
||||||
|
// 是否显示 loading
|
||||||
|
showLoading: true,
|
||||||
|
// 是否序列化参数
|
||||||
|
serializable: false,
|
||||||
|
// 参数
|
||||||
|
data: {
|
||||||
|
id: data.id
|
||||||
|
},
|
||||||
|
success: function (data) {
|
||||||
|
tableIns.reload();
|
||||||
|
layer.close(index);
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue