From 52d32487878ec0009335fbe25819ec589ef043a7 Mon Sep 17 00:00:00 2001 From: hayu <1604366271@qq.com> Date: Mon, 22 Jul 2024 21:21:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B6=E6=A0=B7=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SamplesManageController.java | 116 ++++++++ .../controller/ToolsManageController.java | 6 +- .../aqgqj/basis/dao/SamplesManageDao.java | 57 ++++ .../bonus/aqgqj/basis/dao/ToolsManageDao.java | 3 + .../basis/entity/dto/SamplesManageDto.java | 125 ++++++++ .../basis/entity/dto/ToolsManageDto.java | 14 +- .../basis/service/SamplesManageService.java | 45 +++ .../impl/SamplesManageServiceImpl.java | 101 +++++++ .../mappers/basis/SamplesManageMapper.xml | 123 ++++++++ .../static/js/samples/child/samplesAdd.js | 245 ++++++++++++++++ .../static/js/samples/child/samplesForm.js | 272 ++++++++++++++++++ .../resources/static/js/samples/samplesMge.js | 247 ++++++++++++++++ .../static/js/tools/child/certificateView.js | 17 +- .../resources/static/js/tools/toolsMge.js | 4 +- .../pages/samples/child/samplesAdd.html | 137 +++++++++ .../pages/samples/child/samplesForm.html | 52 ++++ .../static/pages/samples/samplesMge.html | 74 +++++ 17 files changed, 1622 insertions(+), 16 deletions(-) create mode 100644 src/main/java/com/bonus/aqgqj/basis/controller/SamplesManageController.java create mode 100644 src/main/java/com/bonus/aqgqj/basis/dao/SamplesManageDao.java create mode 100644 src/main/java/com/bonus/aqgqj/basis/entity/dto/SamplesManageDto.java create mode 100644 src/main/java/com/bonus/aqgqj/basis/service/SamplesManageService.java create mode 100644 src/main/java/com/bonus/aqgqj/basis/service/impl/SamplesManageServiceImpl.java create mode 100644 src/main/resources/mappers/basis/SamplesManageMapper.xml create mode 100644 src/main/resources/static/js/samples/child/samplesAdd.js create mode 100644 src/main/resources/static/js/samples/child/samplesForm.js create mode 100644 src/main/resources/static/js/samples/samplesMge.js create mode 100644 src/main/resources/static/pages/samples/child/samplesAdd.html create mode 100644 src/main/resources/static/pages/samples/child/samplesForm.html create mode 100644 src/main/resources/static/pages/samples/samplesMge.html diff --git a/src/main/java/com/bonus/aqgqj/basis/controller/SamplesManageController.java b/src/main/java/com/bonus/aqgqj/basis/controller/SamplesManageController.java new file mode 100644 index 0000000..9416552 --- /dev/null +++ b/src/main/java/com/bonus/aqgqj/basis/controller/SamplesManageController.java @@ -0,0 +1,116 @@ +package com.bonus.aqgqj.basis.controller; + +import com.bonus.aqgqj.annotation.DecryptAndVerify; +import com.bonus.aqgqj.annotation.LogAnnotation; +import com.bonus.aqgqj.basis.entity.dto.SamplesManageDto; +import com.bonus.aqgqj.basis.entity.dto.SamplesManageDto; +import com.bonus.aqgqj.basis.service.SamplesManageService; +import com.bonus.aqgqj.basis.service.ToolsManageService; +import com.bonus.aqgqj.system.vo.EncryptedReq; +import com.bonus.aqgqj.system.vo.SysOrgVo; +import com.bonus.aqgqj.utils.ServerResponse; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import io.swagger.annotations.Api; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + + +/** + * 收样管理 + * @author hay + */ +@Api(tags = "收样管理") +@RestController +@RequestMapping("/samples/") +public class SamplesManageController { + + private static final Logger log = LoggerFactory.getLogger("adminLogger"); + + @Autowired + private SamplesManageService samplesManageService; + + @PostMapping(value = "getList") + @DecryptAndVerify(decryptedClass = SamplesManageDto.class) + @LogAnnotation(operModul = "收样管理-收样管理", operation = "查询用列表", operDesc = "业务级事件",operType="查询") + @PreAuthorize("@pms.hasPermission('sys:samples:query')" ) + public ServerResponse listUsers(EncryptedReq data) { + PageHelper.startPage(data.getData().getPage(), data.getData().getLimit()); + try { + List list = samplesManageService.list(data.getData()); + PageInfo pageInfo = new PageInfo<>(list); + return ServerResponse.createSuccessPage(pageInfo,data.getData().getPage(),data.getData().getLimit()); + } catch (Exception e) { + log.error(e.toString(),e); + } + return ServerResponse.createErrorPage(data.getData().getPage(),data.getData().getLimit()); + } + + @PostMapping(value = "getDetailsList") + @DecryptAndVerify(decryptedClass = SamplesManageDto.class) + @LogAnnotation(operModul = "收样管理-收样管理详情", operation = "查询用列表", operDesc = "业务级事件",operType="查询") + @PreAuthorize("@pms.hasPermission('sys:samples:query')" ) + public ServerResponse getDetailsList(EncryptedReq data) { + PageHelper.startPage(data.getData().getPage(), data.getData().getLimit()); + try { + List list = samplesManageService.getDetailsList(data.getData()); + PageInfo pageInfo = new PageInfo<>(list); + return ServerResponse.createSuccessPage(pageInfo,data.getData().getPage(),data.getData().getLimit()); + } catch (Exception e) { + log.error(e.toString(),e); + } + return ServerResponse.createErrorPage(data.getData().getPage(),data.getData().getLimit()); + } + + + @PostMapping(value = "all") + @LogAnnotation(operModul = "收样管理", operation = "查询所有工器具", operDesc = "业务级事件",operType="查询") + @PreAuthorize("@pms.hasPermission('sys:samples:query')" ) + public ServerResponse getAll() { + try { + List list = samplesManageService.listTools(); + return ServerResponse.createSuccess(list); + }catch (Exception e){ + log.error(e.toString(),e); + } + return ServerResponse.createErroe("操作失败"); + } + + @PostMapping(value = "allCustomName") + @LogAnnotation(operModul = "收样管理", operation = "查询所有单位", operDesc = "业务级事件",operType="查询") + @PreAuthorize("@pms.hasPermission('sys:samples:query')" ) + public ServerResponse getAllCustomName() { + try { + List list = samplesManageService.getAllCustomName(); + return ServerResponse.createSuccess(list); + }catch (Exception e){ + log.error(e.toString(),e); + } + return ServerResponse.createErroe("操作失败"); + } + + /** + * @description 新增收样数据 + */ + @PostMapping("addSamples") + @DecryptAndVerify(decryptedClass = SamplesManageDto.class)//加解密统一管理 + @LogAnnotation(operModul = "收样管理", operation = "新增收样数据", operDesc = "业务级事件", operType = "新增") + @PreAuthorize("@pms.hasPermission('sys:samples:add')") + public ServerResponse addSamples(EncryptedReq vo) { + try { + return samplesManageService.addSamples(vo.getData()); + }catch (Exception e){ + log.error(e.toString(),e); + } + return ServerResponse.createErroe("操作失败"); + } + + +} diff --git a/src/main/java/com/bonus/aqgqj/basis/controller/ToolsManageController.java b/src/main/java/com/bonus/aqgqj/basis/controller/ToolsManageController.java index 5f4915a..5c1383e 100644 --- a/src/main/java/com/bonus/aqgqj/basis/controller/ToolsManageController.java +++ b/src/main/java/com/bonus/aqgqj/basis/controller/ToolsManageController.java @@ -49,7 +49,7 @@ public class ToolsManageController { @PostMapping(value = "getList") @DecryptAndVerify(decryptedClass = ToolsManageDto.class) - @LogAnnotation(operModul = "工器具管理-工器具个体管理", operation = "查询用列表", operDesc = "系统级事件",operType="查询") + @LogAnnotation(operModul = "工器具管理-工器具个体管理", operation = "查询用列表", operDesc = "业务级事件",operType="查询") @PreAuthorize("@pms.hasPermission('sys:tools:query')" ) public ServerResponse listUsers(EncryptedReq data) { PageHelper.startPage(data.getData().getPage(), data.getData().getLimit()); @@ -65,7 +65,7 @@ public class ToolsManageController { @PostMapping(value = "getDetailsList") @DecryptAndVerify(decryptedClass = ToolsManageDto.class) - @LogAnnotation(operModul = "工器具管理-工器具个体管理详情", operation = "查询用列表", operDesc = "系统级事件",operType="查询") + @LogAnnotation(operModul = "工器具管理-工器具个体管理详情", operation = "查询用列表", operDesc = "业务级事件",operType="查询") @PreAuthorize("@pms.hasPermission('sys:tools:query')" ) public ServerResponse getDetailsList(EncryptedReq data) { PageHelper.startPage(data.getData().getPage(), data.getData().getLimit()); @@ -81,7 +81,7 @@ public class ToolsManageController { @PostMapping(value = "all") - @LogAnnotation(operModul = "工器具管理", operation = "查询所有工器具", operDesc = "系统级事件",operType="查询") + @LogAnnotation(operModul = "工器具管理", operation = "查询所有工器具", operDesc = "业务级事件",operType="查询") @PreAuthorize("@pms.hasPermission('sys:tools:query')" ) public ServerResponse getAll() { try { diff --git a/src/main/java/com/bonus/aqgqj/basis/dao/SamplesManageDao.java b/src/main/java/com/bonus/aqgqj/basis/dao/SamplesManageDao.java new file mode 100644 index 0000000..51cd52d --- /dev/null +++ b/src/main/java/com/bonus/aqgqj/basis/dao/SamplesManageDao.java @@ -0,0 +1,57 @@ +package com.bonus.aqgqj.basis.dao; + +import com.bonus.aqgqj.basis.entity.dto.SamplesManageDto; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface SamplesManageDao { + + /** + * 查询列表 + * @param bean + * @return + */ + List list(SamplesManageDto bean); + + /** + * 获取工器具 + * @param id + * @return + */ + String getSampleTools(Integer id); + + /** + * 获取详情列表 + * @param data + * @return + */ + List getDetailsList(SamplesManageDto data); + + /** + * 获取工器具 + * @return + */ + List listTools(); + + /** + * 获取所有单位名称 + * @return + */ + List getAllCustomName(); + + /** + * 新增收样数据 tb_samples + * @param samplesManageDto + * @return + */ + int addSamples(SamplesManageDto samplesManageDto); + + /** + * 新增设备数据 tb_samples_device + * @param dto + * @return + */ + int addSamplesDevice(SamplesManageDto dto); +} diff --git a/src/main/java/com/bonus/aqgqj/basis/dao/ToolsManageDao.java b/src/main/java/com/bonus/aqgqj/basis/dao/ToolsManageDao.java index db2081a..696eb2e 100644 --- a/src/main/java/com/bonus/aqgqj/basis/dao/ToolsManageDao.java +++ b/src/main/java/com/bonus/aqgqj/basis/dao/ToolsManageDao.java @@ -15,6 +15,9 @@ import org.apache.ibatis.annotations.Update; import java.util.List; import java.util.Map; +/** + * @author hay + */ @Mapper public interface ToolsManageDao { diff --git a/src/main/java/com/bonus/aqgqj/basis/entity/dto/SamplesManageDto.java b/src/main/java/com/bonus/aqgqj/basis/entity/dto/SamplesManageDto.java new file mode 100644 index 0000000..eef624b --- /dev/null +++ b/src/main/java/com/bonus/aqgqj/basis/entity/dto/SamplesManageDto.java @@ -0,0 +1,125 @@ +package com.bonus.aqgqj.basis.entity.dto; + +import com.bonus.aqgqj.base.entity.PageEntity; +import lombok.Data; + +/** + * 工器具个体管理 + * @author hay + */ +@Data +public class SamplesManageDto extends PageEntity { + + private static final long serialVersionUID = -6525908145032868837L; + + private Integer id; + + /** + * 名称 + */ + private String name; + + /** + * 送样单位id + */ + private Integer customId; + + /** + * 送样单位 + */ + private String customName; + + /** + * 送样部门 + */ + private String sampleDepartment; + + /** + * 送样人 + */ + private String sampleUser; + + /** + * 送样时间 + */ + private String sampleTime; + + /** + * 送样设备 + */ + private String sampleTools; + + /** + * 收样人 + */ + private String collectSamplesUser; + + /** + * 收样时间 + */ + private String collectSamplesTime; + + /** + * 班组 + */ + private String teamName; + + /** + * 设备编号 + */ + private String devCode; + + /** + * 客户自编号 + */ + private String devTypeCode; + + /** + * 生产厂家 + */ + private String factoryName; + + /** + * 生产日期 + */ + private String manufactureDate; + + /** + * 设备规格 + */ + private String devModule; + + /** + * 试验日期 + */ + private String experTime; + + /** + * 下次试验日期 + */ + private String nextExperTime; + + /** + * 试验人员 + */ + private String experUser; + + /** + * 试验结论 + */ + private String experConclu; + + /** + * 关键字 + */ + private String keyWord; + + private String paramsList; + + /** + * 创建人 + */ + private Integer createBy; + + +} diff --git a/src/main/java/com/bonus/aqgqj/basis/entity/dto/ToolsManageDto.java b/src/main/java/com/bonus/aqgqj/basis/entity/dto/ToolsManageDto.java index a02af06..6303ec6 100644 --- a/src/main/java/com/bonus/aqgqj/basis/entity/dto/ToolsManageDto.java +++ b/src/main/java/com/bonus/aqgqj/basis/entity/dto/ToolsManageDto.java @@ -60,12 +60,12 @@ public class ToolsManageDto extends PageEntity { private String teamName; /** - * 设备编号 + * 客户自编号 */ private String devCode; /** - * 客户自编号 + * 设备编号 */ private String devTypeCode; @@ -104,6 +104,16 @@ public class ToolsManageDto extends PageEntity { */ private String experConclu; + /** + * 试验周期 + */ + private String experCycle; + + /** + * 试验单价(元) + */ + private String experPrice; + /** * 关键字 */ diff --git a/src/main/java/com/bonus/aqgqj/basis/service/SamplesManageService.java b/src/main/java/com/bonus/aqgqj/basis/service/SamplesManageService.java new file mode 100644 index 0000000..cc248d9 --- /dev/null +++ b/src/main/java/com/bonus/aqgqj/basis/service/SamplesManageService.java @@ -0,0 +1,45 @@ +package com.bonus.aqgqj.basis.service; + +import com.bonus.aqgqj.basis.entity.dto.SamplesManageDto; +import com.bonus.aqgqj.utils.ServerResponse; + +import java.util.List; + +/** + * 工器具个体管理 + * @author hay + */ +public interface SamplesManageService { + /** + * 查询列表 + * @param bean + * @return + */ + List list(SamplesManageDto bean); + + /** + * 详情列表 + * @param data + * @return + */ + List getDetailsList(SamplesManageDto data); + + /** + * 工器具列表 + * @return + */ + List listTools(); + + /** + * 单位列表 + * @return + */ + List getAllCustomName(); + + /** + * 新增 + * @param data + * @return + */ + ServerResponse addSamples(SamplesManageDto data); +} diff --git a/src/main/java/com/bonus/aqgqj/basis/service/impl/SamplesManageServiceImpl.java b/src/main/java/com/bonus/aqgqj/basis/service/impl/SamplesManageServiceImpl.java new file mode 100644 index 0000000..fc11771 --- /dev/null +++ b/src/main/java/com/bonus/aqgqj/basis/service/impl/SamplesManageServiceImpl.java @@ -0,0 +1,101 @@ +package com.bonus.aqgqj.basis.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.bonus.aqgqj.basis.dao.SamplesManageDao; +import com.bonus.aqgqj.basis.dao.ToolsManageDao; +import com.bonus.aqgqj.basis.entity.dto.SamplesManageDto; +import com.bonus.aqgqj.basis.service.SamplesManageService; +import com.bonus.aqgqj.basis.service.ToolsManageService; +import com.bonus.aqgqj.utils.ServerResponse; +import com.bonus.aqgqj.utils.UserUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +/** +* @description 工器具个体管理 +* @author hay +* @date 2024/7/20 16:10 +*/ +@Slf4j +@Service +public class SamplesManageServiceImpl implements SamplesManageService { + + + @Resource + private SamplesManageDao samplesManageDao; + + /** + * 查询列表 + * @param bean + * @return + */ + @Override + public List list(SamplesManageDto bean) { + List list = samplesManageDao.list(bean); + for (SamplesManageDto dto : list){ + String sampleTools = samplesManageDao.getSampleTools(dto.getId()); + dto.setSampleTools(sampleTools); + } + return list; + } + + /** + * 查询详情列表 + * @param data + * @return + */ + @Override + public List getDetailsList(SamplesManageDto data) { + return samplesManageDao.getDetailsList(data); + } + + @Override + public List listTools() { + List list = samplesManageDao.listTools(); + return list; + } + + /** + * 查询所有单位列表 + * @return + */ + @Override + public List getAllCustomName() { + return samplesManageDao.getAllCustomName(); + } + + @Override + public ServerResponse addSamples(SamplesManageDto data) { + JSONArray jsonArray = JSONObject.parseArray(data.getParamsList()); + List samplesManageDtos = jsonArray.toJavaList(SamplesManageDto.class); + if (samplesManageDtos.size() > 0){ + //先增加基础数据表,并返回Id + Integer userId = Integer.parseInt(UserUtil.getLoginUser().getId().toString()); + samplesManageDtos.get(0).setCreateBy(userId); + int re= samplesManageDao.addSamples(samplesManageDtos.get(0)); + if (re>0){ + //添加详情数据 + for (SamplesManageDto dto : samplesManageDtos){ + dto.setId(samplesManageDtos.get(0).getId()); + dto.setCreateBy(userId); + int res= samplesManageDao.addSamplesDevice(dto); + if (res<=0){ + return ServerResponse.createByErrorMsg(500,"新增失败"); + } + } + }else { + return ServerResponse.createByErrorMsg(500,"新增失败"); + } + }else { + return ServerResponse.createByErrorMsg(500,"新增失败"); + } + return ServerResponse.createBySuccessMsg("上传成功"); + } + + +} diff --git a/src/main/resources/mappers/basis/SamplesManageMapper.xml b/src/main/resources/mappers/basis/SamplesManageMapper.xml new file mode 100644 index 0000000..27b6c7b --- /dev/null +++ b/src/main/resources/mappers/basis/SamplesManageMapper.xml @@ -0,0 +1,123 @@ + + + + INSERT INTO tb_sample(custom_id, + custom_name, + department, + sample_user, + sample_time, + create_time, + create_user, + sample_date) + VALUES (#{customId}, + #{customName}, + #{sampleDepartment}, + #{sampleUser}, + #{sampleTime}, + NOW(), + #{createBy}, + #{sampleTime}) + + + INSERT INTO tb_sample_device(sample_id, + dev_type_name, + dev_type_code, + dev_module, + sample_time, + create_time, + create_user) + VALUES (#{id}, + #{sampleTools}, + #{devTypeCode}, + #{devModule}, + #{sampleTime}, + NOW(), + #{createBy}) + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/static/js/samples/child/samplesAdd.js b/src/main/resources/static/js/samples/child/samplesAdd.js new file mode 100644 index 0000000..54916a2 --- /dev/null +++ b/src/main/resources/static/js/samples/child/samplesAdd.js @@ -0,0 +1,245 @@ +let form, layer,laydate, table, tableIns; +let pageNum = 1, limitSize = 10; // 默认第一页,分页数量为10 +let orgData,selectOrgId; +let idParam; +let listData=[]; + +function setParams(params) { + idParam = JSON.parse(params).id; + layui.use(['form', 'layer', 'table', 'laydate'], function () { + form = layui.form; + layer = layui.layer; + laydate = layui.laydate; + table = layui.table; + layui.form.render(); + getCustomNameSelected(); + getToolsSelected(); + initTable(listData) + laydate.render({ + elem: '#sampleTime', + type: 'datetime', + fullPanel: true + }); + + form.on('submit(formData)', function (data) { + console.log("data123456:",data) + console.log($('#sampleTime').val()) + pages(data.field) + $('#devTypeCode').val('') + }); + }) +} + +/** + * 数据处理 + * @param data + */ +function pages(data) { + var customNameValue =$('#customName').val() + // 2. 查找对应的选项文本 + var selectedText = $('#customName option[value="' + customNameValue + '"]').text(); + + var sampleToolsValue =$('#sampleTools').val() + // 2. 查找对应的选项文本 + var sampleToolsText = $('#sampleTools option[value="' + sampleToolsValue + '"]').text(); + + // 向数组中添加数据 + listData.push({ + customId: data.customName, + customName: selectedText, + sampleDepartment: data.sampleDepartment, + sampleUser: data.sampleUser, + sampleTime: $('#sampleTime').val(), + sampleToolsId: data.sampleTools, + sampleTools: sampleToolsText, + devModule: data.devModule, + devTypeCode: data.devTypeCode + }); + console.log("listData:",listData) + //启用/禁用控件 + enableDisableControl(); + + initTable(listData) +} + +/** + * 启用/禁用控件 + * 判断列表是否为空,不为空的话,将控件设置为不可点击 + */ +function enableDisableControl() { + if (listData.length > 0) { + $('#customName').prop('disabled', true); + $('#sampleTools').prop('disabled', true); + form.render(); + $('#sampleDepartment').prop('disabled', true); + $('#sampleUser').prop('disabled', true); + $('#sampleTime').prop('disabled', true); + $('#devModule').prop('disabled', true); + } else { + $('#customName').prop('disabled', false); + $('#sampleTools').prop('disabled', false); + form.render(); + $('#sampleDepartment').prop('disabled', false); + $('#sampleUser').prop('disabled', false); + $('#sampleTime').prop('disabled', false); + $('#devModule').prop('disabled', false); + } +} + +/** + * 获取单位数据 + */ +function getCustomNameSelected() { + let url = dataUrl + '/samples/allCustomName'; + ajaxRequest(url, "POST", null, true, function () { + }, function (result) { + if (result.code === 200) { + setSelectValue(result.data, 'customName'); + // return result.data + } else { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); +} + +/** + * 获取设备类型数据 + */ +function getToolsSelected() { + let url = dataUrl + '/tools/all'; + ajaxRequest(url, "POST", null, true, function () { + }, function (result) { + if (result.code === 200) { + setSelectValue(result.data, 'sampleTools'); + // return result.data + } else { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); +} + +/*初始化表格*/ +function initTable(dataList) { + tableIns = table.render({ + elem: "#table_data", + height: "full-130", + data: dataList, + cols: [ + [ + //表头 + {type: 'numbers', title: '序号', width: '10%', align: 'center'}, + {field: "sampleTools",width: '25%', title: "设备类型", unresize: true, align: "center"}, + {field: "devTypeCode", width: '25%', title: "设备编号", unresize: true, align: "center"}, + {field: "sampleTime", width: '30%', title: "收样时间", unresize: true, align: "center"}, + { + field: "view1",width: '10%', title: "操作", unresize: true, align: "center", + templet: function (d) { + return '删除'; + } + }, + ], + ] + }); +} + +function handleClick1(index) { + console.log(index) + // 根据行索引删除 listData 中对应的数据 + listData.splice(index, 1); + + // 更新表格 + initTable(listData); + + //启用/禁用控件 + enableDisableControl(); +} + +// 获取参数 +function getReqParams(page, limit, type) { + var selectedValue =$('#sampleTools').val() + // 2. 查找对应的选项文本 + var selectedText = $('#sampleTools option[value="' + selectedValue + '"]').text(); + if (selectedText=='请选择'){ + selectedText='' + } + let obj = {}; + if (!type) { + obj = { + page: page + "", + limit: limit + "", + id: idParam, + sampleTools: selectedText, + keyWord:$('#keyWord').val() + }; + } else { + obj = { + page: '1', + limit: '10', + id: idParam, + sampleTools: selectedText, + keyWord: '' + }; + } + console.log(obj) + obj={ + encryptedData:encryptCBC(JSON.stringify(obj)) + } + return obj; +} + +/** + * 上传数据 + */ +function uploadData() { + if (listData.length == 0) { + return layer.msg('请先添加数据', { + icon: 2, + time: 2000 //2秒关闭(如果不配置,默认是3秒) + }); + } + let loadingMsg = layer.msg('数据上传中,请稍候...', {icon: 16, scrollbar: false, time: 0}); + let url = dataUrl + '/samples/addSamples'; + let params = { + "paramsList": listData + } + params={ + encryptedData:encryptCBC(JSON.stringify(params)) + } + ajaxRequest(url, "POST", params, true, function () { + }, function (result) { + layer.close(loadingMsg); // 关闭提示层 + if (result.code === 200) { + closePage(1); + parent.layer.msg("收样信息添加成功", {icon: 1}); + }else { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + layer.close(loadingMsg); // 关闭提示层 + error(xhr) + }); +} + + +/*下拉选表单赋值*/ +function setSelectValue(list, selectName) { + console.log("list",list) + let html = ''; + $.each(list, function (index, item) { + html += ''; + }) + $('#' + selectName).empty().append(html); + layui.form.render(); +} + +function closePage(type) { + let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引 + parent.layer.close(index); //再执行关闭 + if (type === 1) { + parent.reloadData() + } +} diff --git a/src/main/resources/static/js/samples/child/samplesForm.js b/src/main/resources/static/js/samples/child/samplesForm.js new file mode 100644 index 0000000..c67faff --- /dev/null +++ b/src/main/resources/static/js/samples/child/samplesForm.js @@ -0,0 +1,272 @@ +let form, layer, table, tableIns; +let pageNum = 1, limitSize = 10; // 默认第一页,分页数量为10 +let orgData,selectOrgId; +let idParam; + +function setParams(params){ + idParam = JSON.parse(params).id; + layui.use(['form', 'layer', 'table', 'laydate'], function () { + form = layui.form; + layer = layui.layer; + table = layui.table; + layui.form.render(); + pages(1, 10, 1); + getToolsSelected(); + }) +} + +function pages(pageNum, pageSize, typeNum) { + let params = getReqParams(pageNum, pageSize, typeNum); + let url = dataUrl + "/samples/getDetailsList" + ajaxRequest(url, "POST", params, true, function () { + }, function (result) { + console.log(result); + if (result.code === 200) { + if (result.data) { + initTable(result.data, result.limit, result.curr) + laypages(result.count, result.curr, result.limit) + } + } else if (result.code === 500) { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); + +} + +function getToolsSelected() { + let url = dataUrl + '/samples/all'; + ajaxRequest(url, "POST", null, true, function () { + }, function (result) { + if (result.code === 200) { + setSelectValue(result.data, 'sampleTools'); + // return result.data + } else { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); +} + +function laypages(total, page, limit) { + layui.use(['laypage'], function () { + let laypage = layui.laypage; + laypage.render({ + elem: 'voi-page', + count: total, + curr: page, + limit: limit, + limits: [10, 20, 50, 100, 200, 500], + layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'], + groups: 5, + jump: function (obj, first) { + if (!first) { + pageNum = obj.curr, limitSize = obj.limit; + pages(obj.curr, obj.limit, null); + } + } + }); + }) +} + +/*初始化表格*/ +function initTable(dataList, limit, page) { + let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,}); + tableIns = table.render({ + elem: "#table_data", + height: "full-130", + data: dataList, + limit: limit, + cols: [ + [ + //表头 + {title: "序号", width: 80, unresize: true, align: "center", + templet: function (d) { + return (page - 1) * limit + d.LAY_INDEX; + } + }, + {field: "sampleTools", title: "设备类型", unresize: true, align: "center"}, + {field: "devTypeCode", title: "设备编号", unresize: true, align: "center"}, + {field: "devCode", title: "客户自编号", unresize: true, align: "center"}, + {field: "devModule", title: "规格型号", unresize: true, align: "center"}, + {field: "customName", title: "送检部门", unresize: true, align: "center"}, + {field: "experCycle", title: "试验周期", unresize: true, align: "center"}, + {field: "experPrice", title: "试验单价(元)", unresize: true, align: "center"}, + { + field: "view1", title: "收样标签", unresize: true, align: "center", + templet: function (d) { + return '打印'; + } + }, + ], + ], + done: function (res, curr, count) { + layer.close(loadingMsg); + table.resize("table_data"); + count || this.elem.next(".layui-table-view").find(".layui-table-header").css("display", "inline-block"); + count || this.elem.next(".layui-table-view").find(".layui-table-box").css("overflow", "auto"); + }, + }); +} + +function handleClick1(view1) { + alert('Clicked on: ' + view1); +} + +function handleClick2(view1) { + alert('Clicked on: ' + view1); +} + +function handleClick3(view1) { + alert('Clicked on: ' + view1); +} + +// 获取参数 +function getReqParams(page, limit, type) { + var selectedValue =$('#sampleTools').val() + // 2. 查找对应的选项文本 + var selectedText = $('#sampleTools option[value="' + selectedValue + '"]').text(); + if (selectedText=='请选择设备类型'){ + selectedText='' + } + let obj = {}; + if (!type) { + obj = { + page: page + "", + limit: limit + "", + id: idParam, + sampleTools: selectedText, + keyWord:$('#keyWord').val() + }; + } else { + obj = { + page: '1', + limit: '10', + id: idParam, + sampleTools: selectedText, + keyWord: '' + }; + } + console.log(obj) + obj={ + encryptedData:encryptCBC(JSON.stringify(obj)) + } + return obj; +} + +// 查询/重置 +function query() { + let pattern = new RegExp("[%_<>]"); + if (pattern.test($("#loginName").val())) { + $("#loginName").val(''); + return layer.msg('用户名查询包含特殊字符,请重新输入', { + icon: 2, + time: 2000 //2秒关闭(如果不配置,默认是3秒) + }); + } + if (pattern.test($("#phone").val())) { + $("#phone").val(''); + return layer.msg('手机号查询包含特殊字符,请重新输入', { + icon: 2, + time: 2000 //2秒关闭(如果不配置,默认是3秒) + }); + } + pageNum = 1; + pages(1, limitSize); +} + + +//重置 +function reset() { + pages(1, limitSize, 1) +} + + +function reloadData() { + pages(pageNum, limitSize); +} + +// 新增/修改平台用户 +function addData(id) { + if (id) { + title = '详情'; + } + let param = { + 'id': id + } + openIframe2("addOrEditUser", title, "child/toolsFrom.html", '100%', '100%', param); +} + +/*删除用户*/ +function delData(id) { + layer.confirm("确定删除吗?", { + move: false + }, function () { + let loadingMsg = layer.msg('数据删除中,请稍候...', {icon: 16, scrollbar: false, time: 0}); + let url = dataUrl + "/users/delById"; + let params = { + 'id': id + } + params={ + encryptedData:encryptCBC(JSON.stringify(params)) + } + ajaxRequest(url, "POST", params, true, function () { + }, function (result) { + layer.close(loadingMsg); // 关闭提示层 + if (result.code === 200) { + parent.layer.msg(result.msg, {icon: 1}) + query() + } else if (result.code === 500) { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + layer.close(loadingMsg); // 关闭提示层 + error(xhr) + }); + }) +} + +// 启用/停用/解除锁定 +function editUserAccountStatus(id, status, type) { + let url = dataUrl + "/sys/user/editUserAccountStatus?token=" + token; + let params = { + 'id': id, + 'accountStatus': status, + 'type': type + } + ajaxRequest(url, "POST", params, true, function () { + }, function (result) { + if (result.code === 200) { + if(type){ + reloadData(); + } + parent.layer.msg(result.msg, {icon: 1}) + } else if (result.code === 500) { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); +} + +// 管理员修改密码 +function resetPwd(id) { + let param = { + 'id': id, + 'type': '1' + } + openIframe2("addOrEditUnifyUser", '修改密码', "password.html", '770px', '400px', param); +} + +/*下拉选表单赋值*/ +function setSelectValue(list, selectName) { + console.log("list",list) + let html = ''; + $.each(list, function (index, item) { + html += ''; + }) + $('#' + selectName).empty().append(html); + layui.form.render(); +} diff --git a/src/main/resources/static/js/samples/samplesMge.js b/src/main/resources/static/js/samples/samplesMge.js new file mode 100644 index 0000000..5310ca0 --- /dev/null +++ b/src/main/resources/static/js/samples/samplesMge.js @@ -0,0 +1,247 @@ +let form, layer, table, tableIns; +let pageNum = 1, limitSize = 10; // 默认第一页,分页数量为10 +let orgData,selectOrgId; + +layui.use(['form', 'layer', 'table', 'laydate'], function () { + form = layui.form; + layer = layui.layer; + table = layui.table; + layui.form.render(); + pages(1, 10, 1); + getToolsSelected(); +}) + + +function getToolsSelected() { + let url = dataUrl + '/tools/all'; + ajaxRequest(url, "POST", null, true, function () { + }, function (result) { + if (result.code === 200) { + setSelectValue(result.data, 'sampleTools'); + // return result.data + } else { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); +} + + +function pages(pageNum, pageSize, typeNum) { + let params = getReqParams(pageNum, pageSize, typeNum); + let url = dataUrl + "/samples/getList" + ajaxRequest(url, "POST", params, true, function () { + }, function (result) { + console.log("result.data:",result.data); + if (result.code === 200) { + if (result.data) { + initTable(result.data, result.limit, result.curr) + laypages(result.count, result.curr, result.limit) + } + } else if (result.code === 500) { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); + +} + +function laypages(total, page, limit) { + layui.use(['laypage'], function () { + let laypage = layui.laypage; + laypage.render({ + elem: 'voi-page', + count: total, + curr: page, + limit: limit, + limits: [10, 20, 50, 100, 200, 500], + layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'], + groups: 5, + jump: function (obj, first) { + if (!first) { + pageNum = obj.curr, limitSize = obj.limit; + pages(obj.curr, obj.limit, null); + } + } + }); + }) +} + +/*初始化表格*/ +function initTable(dataList, limit, page) { + let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,}); + tableIns = table.render({ + elem: "#table_data", + height: "full-130", + data: dataList, + limit: limit, + cols: [ + [ + //表头 + {title: "序号", width: 80, unresize: true, align: "center", + templet: function (d) { + return (page - 1) * limit + d.LAY_INDEX; + } + }, + {field: "customName", title: "送样单位", unresize: true, align: "center"}, + {field: "sampleUser", title: "送样人", unresize: true, align: "center"}, + {field: "sampleTime", title: "送样时间", unresize: true, align: "center"}, + {field: "sampleTools", title: "送样设备", unresize: true, align: "center"}, + {field: "collectSamplesUser", title: "收样人", unresize: true, align: "center"}, + {field: "collectSamplesTime", title: "收样时间", unresize: true, align: "center"}, + { + field: "teamName", title: "试验班组", unresize: true, align: "center", templet: function (d) { + let html = ''; + let view =''; + if (d.teamName == null) { + view="未派工"; + } else { + view="" + d.teamName + ""; + } + html=view; + return html; + } + }, + {title: "操作", unresize: true, width: 85, align: "center", + templet: function (d) { + + let html = ''; + let view="详情"; + html=view; + if(d.delFlag==1){ + return ''; + } + return html; + } + }, + ], + ], + done: function (res, curr, count) { + layer.close(loadingMsg); + table.resize("table_data"); + count || this.elem.next(".layui-table-view").find(".layui-table-header").css("display", "inline-block"); + count || this.elem.next(".layui-table-view").find(".layui-table-box").css("overflow", "auto"); + }, + }); +} + +function handleClick1(sampleTools,devModule,devCode,experTime,nextExperTime,experUser,experConclu,customName) { + title = '合格证'; + let param = { + 'sampleTools' : sampleTools, + 'devModule' : devModule, + 'devCode' : devCode, + 'experTime' : experTime, + 'nextExperTime' : nextExperTime, + 'experUser': experUser, + 'experConclu': experConclu, + 'customName': customName + } + openIframe2("addOrEditUser", title, "child/certificateView.html", '30%', '70%', param); +} + +function handleClick2(view1) { + alert('Clicked on: ' + view1); +} + + +// 获取参数 +function getReqParams(page, limit, type) { + var selectedValue =$('#sampleTools').val() + // 2. 查找对应的选项文本 + var selectedText = $('#sampleTools option[value="' + selectedValue + '"]').text(); + if (selectedText=='请选择设备类型'){ + selectedText='' + } + let obj = {}; + if (!type) { + obj = { + page: page + "", + limit: limit + "", + sampleTools: selectedText, + collectSamplesUser:$('#collectSamplesUser').val(), + keyWord:$('#keyWord').val() + }; + } else { + obj = { + page: '1', + limit: '10', + sampleTools: '', + collectSamplesUser: '', + keyWord: '' + }; + } + console.log(obj) + obj={ + encryptedData:encryptCBC(JSON.stringify(obj)) + } + return obj; +} + +// 查询/重置 +function query() { + let pattern = new RegExp("[%_<>]"); + if (pattern.test($("#loginName").val())) { + $("#loginName").val(''); + return layer.msg('用户名查询包含特殊字符,请重新输入', { + icon: 2, + time: 2000 //2秒关闭(如果不配置,默认是3秒) + }); + } + if (pattern.test($("#phone").val())) { + $("#phone").val(''); + return layer.msg('手机号查询包含特殊字符,请重新输入', { + icon: 2, + time: 2000 //2秒关闭(如果不配置,默认是3秒) + }); + } + pageNum = 1; + pages(1, limitSize); +} + + +//重置 +function reset() { + pages(1, limitSize, 1) +} + + +function reloadData() { + pages(pageNum, limitSize); +} + +// 新增/修改平台用户 +function addData(id) { + if (id) { + title = '收样管理/详情'; + } + let param = { + 'id': id + } + openIframe2("addOrEditUser", title, "child/samplesForm.html", '100%', '100%', param); +} + +/** + * 收样 + */ +function collectSamples(id) { + title = '收样'; + let param = { + 'id': id + } + openIframe2("addOrEditUser", title, "child/samplesAdd.html", '70%', '90%', param); +} + + +/*下拉选表单赋值*/ +function setSelectValue(list, selectName) { + console.log("list",list) + let html = ''; + $.each(list, function (index, item) { + html += ''; + }) + $('#' + selectName).empty().append(html); + layui.form.render(); +} diff --git a/src/main/resources/static/js/tools/child/certificateView.js b/src/main/resources/static/js/tools/child/certificateView.js index ac5c84c..404008c 100644 --- a/src/main/resources/static/js/tools/child/certificateView.js +++ b/src/main/resources/static/js/tools/child/certificateView.js @@ -1,16 +1,15 @@ function setParams(params){ var data=JSON.parse(params); - console.log("data",data); //给控件赋值 - document.getElementById('sampleTools').textContent = data.sampleTools; - document.getElementById('devModule').textContent = data.devModule; - document.getElementById('devCode').textContent = data.devCode; - document.getElementById('experTime').textContent = data.experTime; - document.getElementById('nextExperTime').textContent = data.nextExperTime; - document.getElementById('experUser').textContent = data.experUser; - document.getElementById('experConclu').textContent = data.experConclu; - document.getElementById('customName').textContent = data.customName; + document.getElementById('sampleTools').textContent = data.sampleTools === "null" || data.sampleTools === undefined ? '' : data.sampleTools; + document.getElementById('devModule').textContent = data.devModule === "null" || data.devModule === undefined ? '' : data.devModule; + document.getElementById('devCode').textContent = data.devCode === "null" || data.devCode === undefined ? '' : data.devCode; + document.getElementById('experTime').textContent = data.experTime === "null" || data.experTime === undefined ? '' : data.experTime; + document.getElementById('nextExperTime').textContent = data.nextExperTime === "null" || data.nextExperTime === undefined ? '' : data.nextExperTime; + document.getElementById('experUser').textContent = data.experUser === "null" || data.experUser === undefined ? '' : data.experUser; + document.getElementById('experConclu').textContent = data.experConclu === "null" || data.experConclu === undefined ? '' : data.experConclu; + document.getElementById('customName').textContent = data.customName === "null" || data.customName === undefined ? '' : data.customName; } diff --git a/src/main/resources/static/js/tools/toolsMge.js b/src/main/resources/static/js/tools/toolsMge.js index 7385620..dd1e432 100644 --- a/src/main/resources/static/js/tools/toolsMge.js +++ b/src/main/resources/static/js/tools/toolsMge.js @@ -86,8 +86,8 @@ function initTable(dataList, limit, page) { } }, {field: "sampleTools", title: "设备类型", unresize: true, align: "center"}, - {field: "devCode", title: "设备编号", unresize: true, align: "center"}, - {field: "devTypeCode", title: "客户自编号", unresize: true, align: "center"}, + {field: "devTypeCode", title: "设备编号", unresize: true, align: "center"}, + {field: "devCode", title: "客户自编号", unresize: true, align: "center"}, {field: "devModule", title: "设备规格", unresize: true, align: "center"}, {field: "customName", title: "送样单位", unresize: true, align: "center"}, {field: "sampleDepartment", title: "送样部门", unresize: true, align: "center"}, diff --git a/src/main/resources/static/pages/samples/child/samplesAdd.html b/src/main/resources/static/pages/samples/child/samplesAdd.html new file mode 100644 index 0000000..0acca31 --- /dev/null +++ b/src/main/resources/static/pages/samples/child/samplesAdd.html @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + 详情 + + + +
+ +
+
+
+ + + +
+
+ + + \ No newline at end of file diff --git a/src/main/resources/static/pages/samples/child/samplesForm.html b/src/main/resources/static/pages/samples/child/samplesForm.html new file mode 100644 index 0000000..555c72b --- /dev/null +++ b/src/main/resources/static/pages/samples/child/samplesForm.html @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + 详情 + + +
+ +
+
+
+
+
+ + + \ No newline at end of file diff --git a/src/main/resources/static/pages/samples/samplesMge.html b/src/main/resources/static/pages/samples/samplesMge.html new file mode 100644 index 0000000..8550ccd --- /dev/null +++ b/src/main/resources/static/pages/samples/samplesMge.html @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + 收样管理 + + +
+ +
+
+
+
+
+ + + + + \ No newline at end of file