完善供货商逻辑创建 钱包
This commit is contained in:
@@ -6,7 +6,11 @@
|
|||||||
"Bash(mvn compile:*)",
|
"Bash(mvn compile:*)",
|
||||||
"Bash(xargs cat:*)",
|
"Bash(xargs cat:*)",
|
||||||
"Bash(cd:*)",
|
"Bash(cd:*)",
|
||||||
"Bash(grep:*)"
|
"Bash(grep:*)",
|
||||||
|
"Bash(copy:*)",
|
||||||
|
"Bash(cmd /c \"copy /Y \"\"D:\\\\git\\\\bomaos-shop\\\\src\\\\main\\\\resources\\\\templates\\\\system\\\\supplier.html\"\" \"\"D:\\\\git\\\\bomaos-shop\\\\target\\\\classes\\\\templates\\\\system\\\\supplier.html\"\"\")",
|
||||||
|
"Bash(cmd /c \"copy /Y \"\"D:\\\\git\\\\bomaos-shop\\\\src\\\\main\\\\resources\\\\templates\\\\system\\\\user.html\"\" \"\"D:\\\\git\\\\bomaos-shop\\\\target\\\\classes\\\\templates\\\\system\\\\user.html\"\"\")",
|
||||||
|
"Bash(javap:*)"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,25 @@
|
|||||||
package com.bomaos.common.system.controller;
|
package com.bomaos.common.system.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.bomaos.common.core.annotation.OperLog;
|
import com.bomaos.common.core.annotation.OperLog;
|
||||||
import com.bomaos.common.core.web.*;
|
import com.bomaos.common.core.web.*;
|
||||||
import com.bomaos.common.system.entity.Supplier;
|
import com.bomaos.common.system.entity.Supplier;
|
||||||
|
import com.bomaos.common.system.entity.User;
|
||||||
import com.bomaos.common.system.service.SupplierService;
|
import com.bomaos.common.system.service.SupplierService;
|
||||||
|
import com.bomaos.common.system.service.UserService;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 供应商管理
|
* 供应商管理
|
||||||
@@ -22,9 +28,15 @@ import java.util.List;
|
|||||||
@RequestMapping("/sys/supplier")
|
@RequestMapping("/sys/supplier")
|
||||||
public class SupplierController extends BaseController {
|
public class SupplierController extends BaseController {
|
||||||
|
|
||||||
|
/** 供应商角色ID */
|
||||||
|
private static final Integer SUPPLIER_ROLE_ID = 4;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SupplierService supplierService;
|
private SupplierService supplierService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
@RequiresPermissions("sys:supplier:view")
|
@RequiresPermissions("sys:supplier:view")
|
||||||
@RequestMapping()
|
@RequestMapping()
|
||||||
public String view() {
|
public String view() {
|
||||||
@@ -69,44 +81,85 @@ public class SupplierController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加供应商
|
* 添加供应商(同时创建登录账号)
|
||||||
*/
|
*/
|
||||||
|
@Transactional
|
||||||
@RequiresPermissions("sys:supplier:save")
|
@RequiresPermissions("sys:supplier:save")
|
||||||
@OperLog(value = "供应商管理", desc = "添加", param = false, result = true)
|
@OperLog(value = "供应商管理", desc = "添加", param = false, result = true)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping("/save")
|
@RequestMapping("/save")
|
||||||
public JsonResult save(Supplier supplier) {
|
public JsonResult save(Supplier supplier) {
|
||||||
|
if (supplier.getUsername() == null || supplier.getUsername().trim().isEmpty()) {
|
||||||
|
return JsonResult.error("登录账号不能为空");
|
||||||
|
}
|
||||||
|
if (supplier.getPassword() == null || supplier.getPassword().trim().isEmpty()) {
|
||||||
|
return JsonResult.error("登录密码不能为空");
|
||||||
|
}
|
||||||
|
// 检查账号是否已存在
|
||||||
|
User existUser = userService.getByUsername(supplier.getUsername().trim());
|
||||||
|
if (existUser != null) {
|
||||||
|
return JsonResult.error("登录账号已存在");
|
||||||
|
}
|
||||||
|
// 创建供应商
|
||||||
supplier.setCreateTime(new Date());
|
supplier.setCreateTime(new Date());
|
||||||
supplier.setUpdateTime(new Date());
|
supplier.setUpdateTime(new Date());
|
||||||
if (supplierService.save(supplier)) {
|
if (!supplierService.save(supplier)) {
|
||||||
return JsonResult.ok("添加成功");
|
|
||||||
}
|
|
||||||
return JsonResult.error("添加失败");
|
return JsonResult.error("添加失败");
|
||||||
}
|
}
|
||||||
|
// 创建关联的登录账号
|
||||||
|
User user = new User();
|
||||||
|
user.setUsername(supplier.getUsername().trim());
|
||||||
|
user.setPassword(userService.encodePsw(supplier.getPassword()));
|
||||||
|
user.setNickName(supplier.getNickName() != null && !supplier.getNickName().trim().isEmpty()
|
||||||
|
? supplier.getNickName().trim() : supplier.getName());
|
||||||
|
user.setSupplierId(supplier.getId());
|
||||||
|
user.setState(0);
|
||||||
|
user.setRoleIds(Collections.singletonList(SUPPLIER_ROLE_ID));
|
||||||
|
if (!userService.saveUser(user)) {
|
||||||
|
return JsonResult.error("创建登录账号失败");
|
||||||
|
}
|
||||||
|
return JsonResult.ok("添加成功");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改供应商
|
* 修改供应商(同步更新关联用户昵称)
|
||||||
*/
|
*/
|
||||||
|
@Transactional
|
||||||
@RequiresPermissions("sys:supplier:update")
|
@RequiresPermissions("sys:supplier:update")
|
||||||
@OperLog(value = "供应商管理", desc = "修改", param = false, result = true)
|
@OperLog(value = "供应商管理", desc = "修改", param = false, result = true)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping("/update")
|
@RequestMapping("/update")
|
||||||
public JsonResult update(Supplier supplier) {
|
public JsonResult update(Supplier supplier) {
|
||||||
supplier.setUpdateTime(new Date());
|
supplier.setUpdateTime(new Date());
|
||||||
if (supplierService.updateById(supplier)) {
|
if (!supplierService.updateById(supplier)) {
|
||||||
return JsonResult.ok("修改成功");
|
|
||||||
}
|
|
||||||
return JsonResult.error("修改失败");
|
return JsonResult.error("修改失败");
|
||||||
}
|
}
|
||||||
|
// 同步更新关联用户的昵称
|
||||||
|
if (supplier.getNickName() != null && !supplier.getNickName().trim().isEmpty()) {
|
||||||
|
User linkedUser = userService.getOne(
|
||||||
|
new QueryWrapper<User>().eq("supplier_id", supplier.getId()));
|
||||||
|
if (linkedUser != null) {
|
||||||
|
User updateUser = new User();
|
||||||
|
updateUser.setUserId(linkedUser.getUserId());
|
||||||
|
updateUser.setNickName(supplier.getNickName().trim());
|
||||||
|
userService.updateById(updateUser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return JsonResult.ok("修改成功");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除供应商
|
* 删除供应商(同时删除关联用户)
|
||||||
*/
|
*/
|
||||||
|
@Transactional
|
||||||
@RequiresPermissions("sys:supplier:remove")
|
@RequiresPermissions("sys:supplier:remove")
|
||||||
@OperLog(value = "供应商管理", desc = "删除", result = true)
|
@OperLog(value = "供应商管理", desc = "删除", result = true)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping("/remove")
|
@RequestMapping("/remove")
|
||||||
public JsonResult remove(Integer id) {
|
public JsonResult remove(Integer id) {
|
||||||
|
// 删除关联用户
|
||||||
|
userService.remove(new QueryWrapper<User>().eq("supplier_id", id));
|
||||||
|
// 删除供应商
|
||||||
if (supplierService.removeById(id)) {
|
if (supplierService.removeById(id)) {
|
||||||
return JsonResult.ok("删除成功");
|
return JsonResult.ok("删除成功");
|
||||||
}
|
}
|
||||||
@@ -114,17 +167,46 @@ public class SupplierController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除供应商
|
* 批量删除供应商(同时删除关联用户)
|
||||||
*/
|
*/
|
||||||
|
@Transactional
|
||||||
@RequiresPermissions("sys:supplier:remove")
|
@RequiresPermissions("sys:supplier:remove")
|
||||||
@OperLog(value = "供应商管理", desc = "批量删除", result = true)
|
@OperLog(value = "供应商管理", desc = "批量删除", result = true)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping("/removeBatch")
|
@RequestMapping("/removeBatch")
|
||||||
public JsonResult removeBatch(@RequestBody List<Integer> ids) {
|
public JsonResult removeBatch(@RequestBody List<Integer> ids) {
|
||||||
|
// 批量删除关联用户
|
||||||
|
userService.remove(new QueryWrapper<User>().in("supplier_id", ids));
|
||||||
|
// 批量删除供应商
|
||||||
if (supplierService.removeByIds(ids)) {
|
if (supplierService.removeByIds(ids)) {
|
||||||
return JsonResult.ok("删除成功");
|
return JsonResult.ok("删除成功");
|
||||||
}
|
}
|
||||||
return JsonResult.error("删除失败");
|
return JsonResult.error("删除失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置供应商账号密码
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("sys:supplier:update")
|
||||||
|
@OperLog(value = "供应商管理", desc = "重置密码", param = false, result = true)
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/psw/reset")
|
||||||
|
public JsonResult resetPsw(Integer id, String password) {
|
||||||
|
if (password == null || password.trim().isEmpty()) {
|
||||||
|
return JsonResult.error("密码不能为空");
|
||||||
|
}
|
||||||
|
User linkedUser = userService.getOne(
|
||||||
|
new QueryWrapper<User>().eq("supplier_id", id));
|
||||||
|
if (linkedUser == null) {
|
||||||
|
return JsonResult.error("该供应商没有关联的登录账号");
|
||||||
|
}
|
||||||
|
User updateUser = new User();
|
||||||
|
updateUser.setUserId(linkedUser.getUserId());
|
||||||
|
updateUser.setPassword(userService.encodePsw(password));
|
||||||
|
if (userService.updateById(updateUser)) {
|
||||||
|
return JsonResult.ok("重置成功");
|
||||||
|
}
|
||||||
|
return JsonResult.error("重置失败");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import com.bomaos.common.system.entity.DictionaryData;
|
|||||||
import com.bomaos.common.system.entity.Organization;
|
import com.bomaos.common.system.entity.Organization;
|
||||||
import com.bomaos.common.system.entity.Role;
|
import com.bomaos.common.system.entity.Role;
|
||||||
import com.bomaos.common.system.entity.User;
|
import com.bomaos.common.system.entity.User;
|
||||||
import com.bomaos.common.system.entity.Supplier;
|
|
||||||
import com.bomaos.common.system.service.*;
|
import com.bomaos.common.system.service.*;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -45,8 +44,6 @@ public class UserController extends BaseController {
|
|||||||
private RoleService roleService;
|
private RoleService roleService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrganizationService organizationService;
|
private OrganizationService organizationService;
|
||||||
@Autowired
|
|
||||||
private SupplierService supplierService;
|
|
||||||
|
|
||||||
@RequiresPermissions("sys:user:view")
|
@RequiresPermissions("sys:user:view")
|
||||||
@RequestMapping()
|
@RequestMapping()
|
||||||
@@ -54,7 +51,6 @@ public class UserController extends BaseController {
|
|||||||
model.addAttribute("sexList", dictionaryDataService.listByDictCode("sex"));
|
model.addAttribute("sexList", dictionaryDataService.listByDictCode("sex"));
|
||||||
model.addAttribute("organizationTypeList", dictionaryDataService.listByDictCode("organization_type"));
|
model.addAttribute("organizationTypeList", dictionaryDataService.listByDictCode("organization_type"));
|
||||||
model.addAttribute("rolesJson", JSON.toJSONString(roleService.list()));
|
model.addAttribute("rolesJson", JSON.toJSONString(roleService.list()));
|
||||||
model.addAttribute("supplierListJson", JSON.toJSONString(supplierService.list()));
|
|
||||||
return "system/user.html";
|
return "system/user.html";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.bomaos.common.system.entity;
|
package com.bomaos.common.system.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -49,4 +50,28 @@ public class Supplier implements Serializable {
|
|||||||
* 更新时间
|
* 更新时间
|
||||||
*/
|
*/
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联用户ID
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Integer userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录账号
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录密码(仅创建时使用)
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户昵称
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String nickName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,12 @@
|
|||||||
|
|
||||||
<!-- 关联查询sql -->
|
<!-- 关联查询sql -->
|
||||||
<sql id="relSelect">
|
<sql id="relSelect">
|
||||||
SELECT a.*
|
SELECT a.*,
|
||||||
|
u.user_id as userId,
|
||||||
|
u.username as username,
|
||||||
|
u.nick_name as nickName
|
||||||
FROM sys_supplier a
|
FROM sys_supplier a
|
||||||
|
LEFT JOIN sys_user u ON u.supplier_id = a.id AND u.deleted = 0
|
||||||
<where>
|
<where>
|
||||||
<if test="page!=null and page.pageData!=null">
|
<if test="page!=null and page.pageData!=null">
|
||||||
<if test="page.pageData.id != null">
|
<if test="page.pageData.id != null">
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import com.bomaos.common.core.utils.DateUtil;
|
|||||||
import com.bomaos.common.core.utils.FormCheckUtil;
|
import com.bomaos.common.core.utils.FormCheckUtil;
|
||||||
import com.bomaos.common.core.utils.RequestParamsUtil;
|
import com.bomaos.common.core.utils.RequestParamsUtil;
|
||||||
import com.bomaos.common.core.web.*;
|
import com.bomaos.common.core.web.*;
|
||||||
|
import com.bomaos.common.system.entity.Supplier;
|
||||||
import com.bomaos.common.system.service.EmailService;
|
import com.bomaos.common.system.service.EmailService;
|
||||||
|
import com.bomaos.common.system.service.SupplierService;
|
||||||
import com.bomaos.orders.entity.Orders;
|
import com.bomaos.orders.entity.Orders;
|
||||||
import com.bomaos.orders.service.OrdersService;
|
import com.bomaos.orders.service.OrdersService;
|
||||||
import com.bomaos.orders.vo.OrdersVo;
|
import com.bomaos.orders.vo.OrdersVo;
|
||||||
@@ -67,6 +69,9 @@ public class OrdersController extends BaseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ShopSettingsService shopSettingsService;
|
private ShopSettingsService shopSettingsService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SupplierService supplierService;
|
||||||
|
|
||||||
@RequiresPermissions("orders:orders:view")
|
@RequiresPermissions("orders:orders:view")
|
||||||
@RequestMapping()
|
@RequestMapping()
|
||||||
public String view() {
|
public String view() {
|
||||||
@@ -409,6 +414,17 @@ public class OrdersController extends BaseController {
|
|||||||
|
|
||||||
if (ordersService.updateById(orders1)) {
|
if (ordersService.updateById(orders1)) {
|
||||||
cardsService.save(cards);
|
cardsService.save(cards);
|
||||||
|
// 手动发货完成后,将订单金额累加到供应商余额
|
||||||
|
if (orders.getSupplierId() != null && orders.getSupplierId() > 0) {
|
||||||
|
Supplier supplier = supplierService.getById(orders.getSupplierId());
|
||||||
|
if (supplier != null) {
|
||||||
|
Supplier updateSupplier = new Supplier();
|
||||||
|
updateSupplier.setId(supplier.getId());
|
||||||
|
updateSupplier.setBalance(supplier.getBalance().add(orders.getMoney()));
|
||||||
|
updateSupplier.setUpdateTime(new Date());
|
||||||
|
supplierService.updateById(updateSupplier);
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 邮件通知
|
* 邮件通知
|
||||||
* 后台开启邮件通知,
|
* 后台开启邮件通知,
|
||||||
@@ -652,6 +668,19 @@ public class OrdersController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 补单完成后,将订单金额累加到供应商余额
|
||||||
|
if (member.getSupplierId() != null && member.getSupplierId() > 0) {
|
||||||
|
Supplier supplier = supplierService.getById(member.getSupplierId());
|
||||||
|
if (supplier != null) {
|
||||||
|
Supplier updateSupplier = new Supplier();
|
||||||
|
updateSupplier.setId(supplier.getId());
|
||||||
|
updateSupplier.setBalance(supplier.getBalance().add(member.getMoney()));
|
||||||
|
updateSupplier.setUpdateTime(new Date());
|
||||||
|
supplierService.updateById(updateSupplier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return JsonResult.ok("补单成功!!");
|
return JsonResult.ok("补单成功!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ import com.bomaos.common.core.utils.FormCheckUtil;
|
|||||||
import com.bomaos.common.core.utils.RequestParamsUtil;
|
import com.bomaos.common.core.utils.RequestParamsUtil;
|
||||||
import com.bomaos.common.core.utils.StringUtil;
|
import com.bomaos.common.core.utils.StringUtil;
|
||||||
import com.bomaos.common.core.web.JsonResult;
|
import com.bomaos.common.core.web.JsonResult;
|
||||||
|
import com.bomaos.common.system.entity.Supplier;
|
||||||
import com.bomaos.common.system.service.EmailService;
|
import com.bomaos.common.system.service.EmailService;
|
||||||
|
import com.bomaos.common.system.service.SupplierService;
|
||||||
import com.bomaos.orders.entity.Orders;
|
import com.bomaos.orders.entity.Orders;
|
||||||
import com.bomaos.orders.service.OrdersService;
|
import com.bomaos.orders.service.OrdersService;
|
||||||
import com.bomaos.products.entity.Products;
|
import com.bomaos.products.entity.Products;
|
||||||
@@ -90,6 +92,9 @@ public class NotifyController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ShopSettingsService shopSettingsService;
|
private ShopSettingsService shopSettingsService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SupplierService supplierService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SynchronizedByKeyService synchronizedByKeyService;
|
private SynchronizedByKeyService synchronizedByKeyService;
|
||||||
|
|
||||||
@@ -1089,6 +1094,20 @@ public class NotifyController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 订单完成后,将订单金额累加到供应商余额
|
||||||
|
if (member.getSupplierId() != null && member.getSupplierId() > 0) {
|
||||||
|
Supplier supplier = supplierService.getById(member.getSupplierId());
|
||||||
|
if (supplier != null) {
|
||||||
|
Supplier updateSupplier = new Supplier();
|
||||||
|
updateSupplier.setId(supplier.getId());
|
||||||
|
BigDecimal orderMoney = new BigDecimal(money);
|
||||||
|
updateSupplier.setBalance(supplier.getBalance().add(orderMoney));
|
||||||
|
updateSupplier.setUpdateTime(new Date());
|
||||||
|
supplierService.updateById(updateSupplier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
<!-- 表格操作列 -->
|
<!-- 表格操作列 -->
|
||||||
<script type="text/html" id="supplierTbBar">
|
<script type="text/html" id="supplierTbBar">
|
||||||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
|
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
|
||||||
|
<a class="layui-btn layui-btn-xs" lay-event="reset">重置密码</a>
|
||||||
<a class="layui-btn layui-btn-danger layui-btn-xs"
|
<a class="layui-btn layui-btn-danger layui-btn-xs"
|
||||||
data-dropdown="#supplierTbDelDrop{{d.LAY_INDEX}}" no-shade="true">删除</a>
|
data-dropdown="#supplierTbDelDrop{{d.LAY_INDEX}}" no-shade="true">删除</a>
|
||||||
<div class="dropdown-menu-nav dropdown-popconfirm dropdown-top-right layui-hide"
|
<div class="dropdown-menu-nav dropdown-popconfirm dropdown-top-right layui-hide"
|
||||||
@@ -77,6 +78,26 @@
|
|||||||
<input name="balance" placeholder="请输入余额" class="layui-input" value="0"/>
|
<input name="balance" placeholder="请输入余额" class="layui-input" value="0"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="layui-form-item" id="usernameItem">
|
||||||
|
<label class="layui-form-label layui-form-required">登录账号:</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input name="username" placeholder="请输入登录账号" class="layui-input"
|
||||||
|
lay-verType="tips" lay-verify="required" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item" id="passwordItem">
|
||||||
|
<label class="layui-form-label layui-form-required">登录密码:</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input name="password" type="password" placeholder="请输入登录密码" class="layui-input"
|
||||||
|
lay-verType="tips" lay-verify="required" required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">用户昵称:</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input name="nickName" placeholder="默认使用供应商名称" class="layui-input"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="layui-form-item text-right">
|
<div class="layui-form-item text-right">
|
||||||
<button class="layui-btn" lay-filter="supplierEditSubmit" lay-submit>保存</button>
|
<button class="layui-btn" lay-filter="supplierEditSubmit" lay-submit>保存</button>
|
||||||
<button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
|
<button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
|
||||||
@@ -109,6 +130,7 @@
|
|||||||
{type: 'checkbox'},
|
{type: 'checkbox'},
|
||||||
{type: 'numbers'},
|
{type: 'numbers'},
|
||||||
{field: 'name', title: '供应商名称', sort: true},
|
{field: 'name', title: '供应商名称', sort: true},
|
||||||
|
{field: 'username', title: '登录账号', sort: true, width: 150},
|
||||||
{field: 'contact', title: '联系方式', sort: true},
|
{field: 'contact', title: '联系方式', sort: true},
|
||||||
{field: 'balance', title: '余额', sort: true, width: 120},
|
{field: 'balance', title: '余额', sort: true, width: 120},
|
||||||
{
|
{
|
||||||
@@ -116,7 +138,7 @@
|
|||||||
return util.toDateString(d.createTime);
|
return util.toDateString(d.createTime);
|
||||||
}, sort: true, width: 180
|
}, sort: true, width: 180
|
||||||
},
|
},
|
||||||
{title: '操作', toolbar: '#supplierTbBar', align: 'center', minWidth: 160, fixed: 'right'}
|
{title: '操作', toolbar: '#supplierTbBar', align: 'center', minWidth: 220, fixed: 'right'}
|
||||||
]]
|
]]
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -132,6 +154,19 @@
|
|||||||
showEditModel(obj.data);
|
showEditModel(obj.data);
|
||||||
} else if ('del' === obj.event) {
|
} else if ('del' === obj.event) {
|
||||||
doDel(obj);
|
doDel(obj);
|
||||||
|
} else if ('reset' === obj.event) {
|
||||||
|
admin.prompt({formType: 1, title: '请输入新密码'}, function (value, i) {
|
||||||
|
layer.close(i);
|
||||||
|
var loadIndex = layer.load(2);
|
||||||
|
$.post('supplier/psw/reset', {id: obj.data.id, password: value}, function (res) {
|
||||||
|
layer.close(loadIndex);
|
||||||
|
if (0 === res.code) {
|
||||||
|
layer.msg(res.msg, {icon: 1});
|
||||||
|
} else {
|
||||||
|
layer.msg(res.msg, {icon: 2, anim: 6});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -158,6 +193,11 @@
|
|||||||
title: (mData ? '修改' : '添加') + '供应商',
|
title: (mData ? '修改' : '添加') + '供应商',
|
||||||
content: $('#supplierEditDialog').html(),
|
content: $('#supplierEditDialog').html(),
|
||||||
success: function (layero, dIndex) {
|
success: function (layero, dIndex) {
|
||||||
|
// 编辑模式隐藏账号和密码字段
|
||||||
|
if (mData) {
|
||||||
|
$(layero).find('#usernameItem').remove();
|
||||||
|
$(layero).find('#passwordItem').remove();
|
||||||
|
}
|
||||||
form.val('supplierEditForm', mData);
|
form.val('supplierEditForm', mData);
|
||||||
form.on('submit(supplierEditSubmit)', function (data) {
|
form.on('submit(supplierEditSubmit)', function (data) {
|
||||||
var loadIndex = layer.load(2);
|
var loadIndex = layer.load(2);
|
||||||
|
|||||||
@@ -113,12 +113,6 @@
|
|||||||
<div id="userEditRoleSel"></div>
|
<div id="userEditRoleSel"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item" id="supplierItem" style="display:none">
|
|
||||||
<label class="layui-form-label layui-form-required">供应商:</label>
|
|
||||||
<div class="layui-input-block">
|
|
||||||
<div id="userEditSupplierSel"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label layui-form-required">登录密码:</label>
|
<label class="layui-form-label layui-form-required">登录密码:</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
@@ -146,13 +140,6 @@
|
|||||||
var roleList = JSON.parse('${rolesJson!}').map(function (d) {
|
var roleList = JSON.parse('${rolesJson!}').map(function (d) {
|
||||||
return {name: d.roleName, value: d.roleId}
|
return {name: d.roleName, value: d.roleId}
|
||||||
});
|
});
|
||||||
var supplierRoleId = null;
|
|
||||||
roleList.forEach(function (d) {
|
|
||||||
if (d.name === '供应商') supplierRoleId = d.value;
|
|
||||||
});
|
|
||||||
var supplierList = JSON.parse('${supplierListJson!}').map(function (d) {
|
|
||||||
return {name: d.name, value: d.id}
|
|
||||||
});
|
|
||||||
|
|
||||||
/* 渲染表格 */
|
/* 渲染表格 */
|
||||||
var insTb = tableX.render({
|
var insTb = tableX.render({
|
||||||
@@ -250,7 +237,6 @@
|
|||||||
// 表单提交事件
|
// 表单提交事件
|
||||||
form.on('submit(userEditSubmit)', function (data) {
|
form.on('submit(userEditSubmit)', function (data) {
|
||||||
data.field.roleIds = insRoleSel.getValue('value');
|
data.field.roleIds = insRoleSel.getValue('value');
|
||||||
data.field.supplierId = insSupplierSel.getValue('value')[0] || '';
|
|
||||||
var loadIndex = layer.load(2);
|
var loadIndex = layer.load(2);
|
||||||
admin.req(mData ? 'user/update' : 'user/save', JSON.stringify(data.field), function (res) {
|
admin.req(mData ? 'user/update' : 'user/save', JSON.stringify(data.field), function (res) {
|
||||||
layer.close(loadIndex);
|
layer.close(loadIndex);
|
||||||
@@ -264,42 +250,18 @@
|
|||||||
}, 'post');
|
}, 'post');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
// 切换供应商选择框显隐
|
|
||||||
function toggleSupplierSel(selectedRoleIds) {
|
|
||||||
var show = supplierRoleId && selectedRoleIds.indexOf(supplierRoleId) !== -1;
|
|
||||||
$(layero).find('#supplierItem')[show ? 'show' : 'hide']();
|
|
||||||
if (!show) insSupplierSel.setValue([]);
|
|
||||||
}
|
|
||||||
// 渲染角色多选下拉框
|
// 渲染角色多选下拉框
|
||||||
var insRoleSel = xmSelect.render({
|
var insRoleSel = xmSelect.render({
|
||||||
el: '#userEditRoleSel',
|
el: '#userEditRoleSel',
|
||||||
name: 'userEditRoleSel',
|
name: 'userEditRoleSel',
|
||||||
layVerify: 'required',
|
layVerify: 'required',
|
||||||
layVerType: 'tips',
|
layVerType: 'tips',
|
||||||
data: roleList,
|
data: roleList
|
||||||
on: function (data) {
|
|
||||||
toggleSupplierSel(data.arr.map(function (d) { return d.value; }));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// 渲染供应商单选下拉框
|
|
||||||
var insSupplierSel = xmSelect.render({
|
|
||||||
el: '#userEditSupplierSel',
|
|
||||||
name: 'userEditSupplierSel',
|
|
||||||
radio: true,
|
|
||||||
clickClose: true,
|
|
||||||
layVerify: 'required',
|
|
||||||
layVerType: 'tips',
|
|
||||||
data: supplierList
|
|
||||||
});
|
});
|
||||||
// 回显选中角色
|
// 回显选中角色
|
||||||
if (mData && mData.roles) {
|
if (mData && mData.roles) {
|
||||||
var roleIds = mData.roles.map(function (item) { return item.roleId; });
|
var roleIds = mData.roles.map(function (item) { return item.roleId; });
|
||||||
insRoleSel.setValue(roleIds);
|
insRoleSel.setValue(roleIds);
|
||||||
toggleSupplierSel(roleIds);
|
|
||||||
}
|
|
||||||
// 回显选中供应商
|
|
||||||
if (mData && mData.supplierId && mData.supplierId > 0) {
|
|
||||||
insSupplierSel.setValue([mData.supplierId]);
|
|
||||||
}
|
}
|
||||||
// 禁止弹窗出现滚动条
|
// 禁止弹窗出现滚动条
|
||||||
$(layero).children('.layui-layer-content').css('overflow', 'visible');
|
$(layero).children('.layui-layer-content').css('overflow', 'visible');
|
||||||
|
|||||||
Reference in New Issue
Block a user