From 7022ca19f7544a2a3e71b710f6adafc94d3442ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=BF=9D=E6=A1=A6?= <1103851924@qq.com> Date: Wed, 23 Mar 2022 19:21:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=83=A8=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=EF=BC=8C=E6=B7=BB=E5=8A=A0=E8=AE=BE=E5=A4=87=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/sys/EquipmentController.java | 54 ++++++++ .../toesbieya/jxc/model/vo/EquipmentVo.java | 20 +++ .../jxc/model/vo/search/EquipmentSearch.java | 22 ++++ .../jxc/service/sys/SysEquipmentService.java | 121 ++++++++++++++++++ .../jxc/service/sys/SysSupplierService.java | 10 +- vue/full/src/config/index.js | 2 +- .../src/layout/component/Footer/index.vue | 2 +- .../src/router/module/admin/child/system.js | 53 ++++++-- vue/full/src/router/module/dev/index.js | 8 -- vue/full/src/router/module/doc/index.js | 4 - vue/full/src/util/index.js | 6 +- .../view/admin/system/supplier/EditDialog.vue | 1 + .../view/admin/system/supplier/indexPage.vue | 4 +- .../userInfo}/component/EditDialog.vue | 0 14 files changed, 270 insertions(+), 37 deletions(-) create mode 100644 java/local/src/main/java/cn/toesbieya/jxc/controller/sys/EquipmentController.java create mode 100644 java/local/src/main/java/cn/toesbieya/jxc/model/vo/EquipmentVo.java create mode 100644 java/local/src/main/java/cn/toesbieya/jxc/model/vo/search/EquipmentSearch.java create mode 100644 java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysEquipmentService.java delete mode 100644 vue/full/src/router/module/dev/index.js delete mode 100644 vue/full/src/router/module/doc/index.js rename vue/full/src/view/admin/{system/user => user/userInfo}/component/EditDialog.vue (100%) diff --git a/java/local/src/main/java/cn/toesbieya/jxc/controller/sys/EquipmentController.java b/java/local/src/main/java/cn/toesbieya/jxc/controller/sys/EquipmentController.java new file mode 100644 index 0000000..96eec85 --- /dev/null +++ b/java/local/src/main/java/cn/toesbieya/jxc/controller/sys/EquipmentController.java @@ -0,0 +1,54 @@ +package cn.toesbieya.jxc.controller.sys; + +import cn.toesbieya.jxc.model.entity.SysEquipment; +import cn.toesbieya.jxc.model.vo.search.EquipmentSearch; +import cn.toesbieya.jxc.service.sys.SysEquipmentService; +import cn.toesbieya.jxc.model.vo.R; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +@RestController +@RequestMapping("system/equipment") +public class EquipmentController { + @Resource + private SysEquipmentService service; + + @PostMapping("search") + public R search(@RequestBody EquipmentSearch vo) { + return R.success(service.search(vo)); + } + + @PostMapping("add") + public R add(@RequestBody SysEquipment equipment) { + String errMsg = validateCreateParam(equipment); + if (errMsg != null) return R.fail("添加失败," + errMsg); + equipment.setId(null); + equipment.setCreateTime(System.currentTimeMillis()); + return service.add(equipment); + } + + @PostMapping("update") + public R update(@RequestBody SysEquipment equipment) { + String errMsg = validateUpdateParam(equipment); + return errMsg == null ? service.update(equipment) : R.fail("修改失败," + errMsg); + } + + @PostMapping("del") + public R del(@RequestBody SysEquipment equipment) { + if (equipment.getId() == null) return R.fail("删除失败,参数错误"); + return service.del(equipment); + } + + private String validateCreateParam(SysEquipment equipment) { + if (StringUtils.isEmpty(equipment.getName())) return "设备名称不能为空"; + return null; + } + + private String validateUpdateParam(SysEquipment equipment) { + if (equipment.getId() == null) return "参数错误"; + return validateCreateParam(equipment); + } +} + diff --git a/java/local/src/main/java/cn/toesbieya/jxc/model/vo/EquipmentVo.java b/java/local/src/main/java/cn/toesbieya/jxc/model/vo/EquipmentVo.java new file mode 100644 index 0000000..80987d8 --- /dev/null +++ b/java/local/src/main/java/cn/toesbieya/jxc/model/vo/EquipmentVo.java @@ -0,0 +1,20 @@ +package cn.toesbieya.jxc.model.vo; + +import cn.toesbieya.jxc.model.entity.SysEquipment; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.ToString; +import org.springframework.beans.BeanUtils; + +@Data +@NoArgsConstructor +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class EquipmentVo extends SysEquipment { + private String regionName; + + public EquipmentVo(SysEquipment parent) { + BeanUtils.copyProperties(parent, this); + } +} diff --git a/java/local/src/main/java/cn/toesbieya/jxc/model/vo/search/EquipmentSearch.java b/java/local/src/main/java/cn/toesbieya/jxc/model/vo/search/EquipmentSearch.java new file mode 100644 index 0000000..8ec9521 --- /dev/null +++ b/java/local/src/main/java/cn/toesbieya/jxc/model/vo/search/EquipmentSearch.java @@ -0,0 +1,22 @@ +package cn.toesbieya.jxc.model.vo.search; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class EquipmentSearch extends BaseSearch { + private Integer id; + private String name; + private String spec; + private String introduction; + private String supplier; + private String manuDate; + private String buyDate; + private String location; + private Boolean enable; + private Long startTime; + private Long endTime; +} diff --git a/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysEquipmentService.java b/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysEquipmentService.java new file mode 100644 index 0000000..acb2153 --- /dev/null +++ b/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysEquipmentService.java @@ -0,0 +1,121 @@ +package cn.toesbieya.jxc.service.sys; + +import cn.toesbieya.jxc.annoation.UserAction; +import cn.toesbieya.jxc.mapper.SysEquipmentMapper; +import cn.toesbieya.jxc.model.entity.SysEquipment; +import cn.toesbieya.jxc.model.vo.EquipmentVo; +import cn.toesbieya.jxc.model.vo.R; +import cn.toesbieya.jxc.model.vo.result.PageResult; +import cn.toesbieya.jxc.model.vo.search.EquipmentSearch; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.pagehelper.PageHelper; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + +@Service +public class SysEquipmentService { + @Resource + private SysEquipmentMapper equipmentMapper; + + public PageResult search(EquipmentSearch vo){ + Integer id = vo.getId(); + String name = vo.getName(); + String spec = vo.getSpec(); + String introduction = vo.getIntroduction(); + String supplier = vo.getSupplier(); + String location = vo.getLocation(); + Boolean enable = vo.getEnable(); + String manuDate = vo.getManuDate(); + String buyDate = vo.getBuyDate(); + Long startTime = vo.getStartTime(); + Long endTime = vo.getEndTime(); + + Wrapper wrapper = + Wrappers.lambdaQuery(SysEquipment.class) + .eq(id != null,SysEquipment::getId,id) + .like(!StringUtils.isEmpty(name),SysEquipment::getName,name) + .like(!StringUtils.isEmpty(spec),SysEquipment::getSpec,spec) + .like(!StringUtils.isEmpty(introduction),SysEquipment::getIntroduction,introduction) + .like(!StringUtils.isEmpty(supplier),SysEquipment::getSupplier,supplier) + .like(!StringUtils.isEmpty(location),SysEquipment::getLocation,location) + .like(!StringUtils.isEmpty(manuDate),SysEquipment::getManuDate,manuDate) + .like(!StringUtils.isEmpty(buyDate),SysEquipment::getBuyDate,buyDate) + .eq(enable != null,SysEquipment::isEnable,enable) + .ge(startTime != null,SysEquipment::getCreateTime,startTime) + .le(endTime != null,SysEquipment::getCreateTime,endTime) + .orderByDesc(SysEquipment::getCreateTime); + + PageHelper.startPage(vo.getPage(), vo.getPageSize()); + + List equipments = equipmentMapper.selectList(wrapper); + + PageResult pageResult = new PageResult<>(equipments); + + int equipmentNum = equipments.size(); + + List list = new ArrayList<>(equipmentNum); + + equipments.forEach(equipment -> { + list.add(new EquipmentVo(equipment)); + }); + + return new PageResult<>(pageResult.getTotal(),list); + } + + @UserAction("'添加设备:'+ #equipment.name") + public R add(SysEquipment equipment){ + if (isNameExist(equipment.getName(), null)) { + return R.fail(String.format("添加失败,设备【%s】已存在", equipment.getName())); + } + int rows = equipmentMapper.insert(equipment); + return rows > 0 ? R.success("添加成功") : R.fail("添加失败"); + } + + @UserAction("'修改设备' + #equipment.name") + public R update(SysEquipment equipment){ + Integer id = equipment.getId(); + String name = equipment.getName(); + + if(isNameExist(name,id)) { + return R.fail(String.format("修改失败,设备【%s】已存在", name)); + } + equipmentMapper.update( + null, + Wrappers.lambdaUpdate(SysEquipment.class) + .set(SysEquipment::getName, name) + .set(SysEquipment::getSupplier, equipment.getSupplier()) + .set(SysEquipment::getIntroduction, equipment.getIntroduction()) + .set(SysEquipment::getManuDate,equipment.getManuDate()) + .set(SysEquipment::getBuyDate,equipment.getBuyDate()) + .set(SysEquipment::getSpec, equipment.getSpec()) + .set(SysEquipment::getLocation, equipment.getLocation()) + .set(SysEquipment::isEnable, equipment.isEnable()) + .eq(SysEquipment::getId, id) + ); + return R.success("修改成功"); + } + + @UserAction("'删除设备:'+ #equipment.name") + public R del(SysEquipment equipment) { + int rows = equipmentMapper.delete( + Wrappers.lambdaQuery(SysEquipment.class) + .eq(SysEquipment::getId, equipment.getId()) + .eq(SysEquipment::isEnable, false) + ); + return rows > 0 ? R.success("删除成功") : R.fail("删除失败,请刷新重试"); + } + + private boolean isNameExist(String name, Integer id) { + Integer num = equipmentMapper.selectCount( + Wrappers.lambdaQuery(SysEquipment.class) + .eq(SysEquipment::getName, name) + .ne(id != null, SysEquipment::getId, id) + ); + + return num != null && num > 0; + } +} diff --git a/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysSupplierService.java b/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysSupplierService.java index 0b80078..9bf3bd5 100644 --- a/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysSupplierService.java +++ b/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysSupplierService.java @@ -84,22 +84,22 @@ public class SysSupplierService { return new PageResult<>(pageResult.getTotal(), list); } - @UserAction("'添加供应商:'+ #supplier.name") + @UserAction("'添加试剂厂商:'+ #supplier.name") public R add(SysSupplier supplier) { if (isNameExist(supplier.getName(), null)) { - return R.fail(String.format("添加失败,供应商【%s】已存在", supplier.getName())); + return R.fail(String.format("添加失败,试剂厂商【%s】已存在", supplier.getName())); } int rows = supplierMapper.insert(supplier); return rows > 0 ? R.success("添加成功") : R.fail("添加失败"); } - @UserAction("'修改供应商:'+ #supplier.name") + @UserAction("'修改试剂厂商:'+ #supplier.name") public R update(SysSupplier supplier) { Integer id = supplier.getId(); String name = supplier.getName(); if (isNameExist(name, id)) { - return R.fail(String.format("修改失败,供应商【%s】已存在", name)); + return R.fail(String.format("修改失败,试剂厂商【%s】已存在", name)); } supplierMapper.update( @@ -117,7 +117,7 @@ public class SysSupplierService { return R.success("修改成功"); } - @UserAction("'删除供应商:'+ #supplier.name") + @UserAction("'删除试剂厂商:'+ #supplier.name") public R del(SysSupplier supplier) { int rows = supplierMapper.delete( Wrappers.lambdaQuery(SysSupplier.class) diff --git a/vue/full/src/config/index.js b/vue/full/src/config/index.js index f831ec5..c0de2f5 100644 --- a/vue/full/src/config/index.js +++ b/vue/full/src/config/index.js @@ -5,7 +5,7 @@ module.exports = { contextPath, //页面标题、登录注册页的标题 - title: 'BiuBiuBiu~', + title: '试剂管理系统', //logo地址 logo: `${contextPath}static/img/logo.svg`, diff --git a/vue/full/src/layout/component/Footer/index.vue b/vue/full/src/layout/component/Footer/index.vue index 74a2ab5..5be1939 100644 --- a/vue/full/src/layout/component/Footer/index.vue +++ b/vue/full/src/layout/component/Footer/index.vue @@ -1,6 +1,6 @@ diff --git a/vue/full/src/router/module/admin/child/system.js b/vue/full/src/router/module/admin/child/system.js index 5f8da94..924a6bb 100644 --- a/vue/full/src/router/module/admin/child/system.js +++ b/vue/full/src/router/module/admin/child/system.js @@ -16,18 +16,6 @@ const router = { component: 'admin/system/menu/', meta: {title: '菜单管理', noCache: true} }, - { - path: 'role', - name: 'roleManagement', - component: 'admin/system/role/', - meta: {title: '角色管理'} - }, - { - path: 'user', - name: 'userManagement', - component: 'admin/system/user/', - meta: {title: '用户管理'} - }, { path: 'category', name: 'categorySetting', @@ -44,8 +32,45 @@ const router = { path: 'supplier', name: 'supplierManagement', component: 'admin/system/supplier/', - meta: {title: '供应商管理'} - } + meta: {title: '试剂厂商管理'} + }, + { + path:'equipment', + name: 'equipmentManagement', + component: 'admin/system/equipment/', + meta: {title: '设备管理'} + }, + { + path:'position', + name: 'positionManagement', + component: 'admin/system/position/', + meta: {title: '仓位管理'} + }, + { + path:'reagent', + name: 'reagentManagement', + component: 'admin/system/reagent/', + meta: {title: '试剂管理'} + }, + { + path:'storehouse', + name: 'storehouseManagement', + component: 'admin/system/storehouse/', + meta: {title: '仓库管理'} + }, + { + path:'cargoSpace', + name: 'cargoSpaceManagement', + component: 'admin/system/cargoSpace/', + meta: {title: '货位管理'} + }, + { + path:'dictionary ', + name: 'dictionary Management', + component: 'admin/system/dictionary /', + meta: {title: '字典管理'} + }, + ] } diff --git a/vue/full/src/router/module/dev/index.js b/vue/full/src/router/module/dev/index.js deleted file mode 100644 index eeeaec2..0000000 --- a/vue/full/src/router/module/dev/index.js +++ /dev/null @@ -1,8 +0,0 @@ -/*顶级菜单:开发用的页面*/ -import component from "@/view/dev" - -export default { - path: '/dev', - component, - meta: {title: '开发专用页面', icon: 'svg-develop', noAuth: true, noCache: true} -} diff --git a/vue/full/src/router/module/doc/index.js b/vue/full/src/router/module/doc/index.js deleted file mode 100644 index c7f28d6..0000000 --- a/vue/full/src/router/module/doc/index.js +++ /dev/null @@ -1,4 +0,0 @@ -export default { - path: 'https://doc.toesbieya.cn/jxc-admin', - meta: {title: '文档', icon: 'svg-documentation', noAuth: true} -} diff --git a/vue/full/src/util/index.js b/vue/full/src/util/index.js index 102948a..f5d6038 100644 --- a/vue/full/src/util/index.js +++ b/vue/full/src/util/index.js @@ -175,14 +175,14 @@ export function mergeObj(target, source) { } /** - * 日期格式化 + * 日期格式化到毫秒 * * @param fmt {*|string} 格式,y(+..y)-年、M(+M)-月、d(+d)-天、H(+H)-时、m(+m)-分、s(+s)-秒、S-毫秒 * @param date {Date} 可选,被格式化的日期 * @return {string} 格式化后的日期字符串 */ export function timeFormat(fmt, date = new Date()) { - if (isEmpty(fmt)) fmt = 'yyyy-MM-dd HH:mm:ss' + if (isEmpty(fmt)) fmt = 'yyyy-MM-dd' const o = { "M+": date.getMonth() + 1, //月份 @@ -209,6 +209,8 @@ export function timeFormat(fmt, date = new Date()) { return fmt } + + export function throttle(func, delay = 100) { let timeoutID let lastExec = 0 diff --git a/vue/full/src/view/admin/system/supplier/EditDialog.vue b/vue/full/src/view/admin/system/supplier/EditDialog.vue index b2a0d77..d1fe13a 100644 --- a/vue/full/src/view/admin/system/supplier/EditDialog.vue +++ b/vue/full/src/view/admin/system/supplier/EditDialog.vue @@ -140,6 +140,7 @@ export default { }, clearForm() { + resetObj(this.form) this.$nextTick(() => this.$refs.form.clearValidate()) }, diff --git a/vue/full/src/view/admin/system/supplier/indexPage.vue b/vue/full/src/view/admin/system/supplier/indexPage.vue index 256968f..ce9f954 100644 --- a/vue/full/src/view/admin/system/supplier/indexPage.vue +++ b/vue/full/src/view/admin/system/supplier/indexPage.vue @@ -1,7 +1,7 @@