商户的增删改
diff --git a/src/main/java/com/supwisdom/dlpay/framework/dao/ShopDao.java b/src/main/java/com/supwisdom/dlpay/framework/dao/ShopDao.java
index 968804e..e7cc15f 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/dao/ShopDao.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/dao/ShopDao.java
@@ -24,4 +24,10 @@
@Query("from TShop where status='normal' and fshopid=?1 ")
List<TShop> getChildShopsByShopid(Integer shopid);
+
+ @Query(value = "select count(t.shopid) from TB_SHOP t where t.status='normal' and t.shopname=?1 and t.fshopid=?2 and t.shopid!=?3", nativeQuery = true)
+ long checkShopnameExist(String shopname, int fshopid, int oldShopid);
+
+ @Query("from TShop where status='normal' order by shopid asc ")
+ List<TShop> getNormalShops();
}
diff --git a/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccDao.java b/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccDao.java
index 4e1f9ef..73f6bdc 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccDao.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/dao/ShopaccDao.java
@@ -2,12 +2,11 @@
import com.supwisdom.dlpay.framework.data.ExistBean;
import com.supwisdom.dlpay.framework.domain.TShopacc;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.Lock;
-import org.springframework.data.jpa.repository.Query;
-import org.springframework.data.jpa.repository.QueryHints;
+import org.springframework.data.jpa.repository.*;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
import javax.persistence.LockModeType;
import javax.persistence.QueryHint;
@@ -42,4 +41,9 @@
TShopacc getByShopaccno(String shopaccno);
+ @Transactional
+ @Modifying
+ @Query("update TShopacc set shopname=?1 where shopaccno=?2")
+ void updateShopnameByShopaccno(String shopname, String shopaccno);
+
}
diff --git a/src/main/java/com/supwisdom/dlpay/framework/domain/TShopacc.java b/src/main/java/com/supwisdom/dlpay/framework/domain/TShopacc.java
index 83aaeb0..71ef3a8 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/domain/TShopacc.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/domain/TShopacc.java
@@ -105,6 +105,10 @@
this.closedate = closedate;
}
+ public void setBalance(Double balance) {
+ this.balance = balance;
+ }
+
public Double getBalance() {
return balance;
}
diff --git a/src/main/java/com/supwisdom/dlpay/system/controller/ShopController.java b/src/main/java/com/supwisdom/dlpay/system/controller/ShopController.java
index 2c8e088..a94f906 100644
--- a/src/main/java/com/supwisdom/dlpay/system/controller/ShopController.java
+++ b/src/main/java/com/supwisdom/dlpay/system/controller/ShopController.java
@@ -2,15 +2,14 @@
import com.supwisdom.dlpay.api.bean.JsonResult;
import com.supwisdom.dlpay.framework.domain.TShop;
+import com.supwisdom.dlpay.framework.util.StringUtil;
+import com.supwisdom.dlpay.framework.util.TradeDict;
import com.supwisdom.dlpay.system.service.ShopDataService;
import com.supwisdom.dlpay.util.WebCheckException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
@Controller
public class ShopController {
@@ -50,4 +49,87 @@
return JsonResult.error("系统处理异常").put("exception", e);
}
}
+
+ @GetMapping("/shop/getshopinfo")
+ @PreAuthorize("hasPermission('/shop/getshopinfo','')")
+ @ResponseBody
+ public JsonResult getShopInfo(@RequestParam("shopid") Integer shopid) {
+ TShop shop = shopDataService.getShopByShopid(shopid);
+ if (null == shop) {
+ return JsonResult.error("商户不存在,请重新查询"); //商户不存在,请重新查询
+ }
+ return JsonResult.ok("查询成功").put("shop", shop);
+ }
+
+ @PostMapping("/shop/saveorupdate")
+ @PreAuthorize("hasPermission('/shop/saveorupdate','')")
+ @ResponseBody
+ public JsonResult saveOrUpdateShop(@RequestParam("shopid") Integer shopid, @RequestParam("shopname") String shopname,
+ @RequestParam("fshopid") Integer fshopid, @RequestParam("shoptype") Integer shoptype,
+ @RequestParam(value = "contactman", required = false) String contactman,
+ @RequestParam(value = "idtype", required = false) String idtype,
+ @RequestParam(value = "idno", required = false) String idno,
+ @RequestParam(value = "mobile", required = false) String mobile,
+ @RequestParam(value = "tel", required = false) String tel,
+ @RequestParam(value = "email", required = false) String email,
+ @RequestParam(value = "addr", required = false) String addr,
+ @RequestParam(value = "zipcode", required = false) String zipcode) {
+ if (null == shopid || StringUtil.isEmpty(shopname) || null == fshopid || (shoptype != 0 && shoptype != 1)) {
+ return JsonResult.error("参数传递错误");
+ }
+
+ TShop shop;
+ boolean addflag = false;
+ if (shopid == 0) {
+ //新增
+ addflag = true;
+ shop = new TShop();
+ shop.setFshopid(fshopid);
+ shop.setShopname(shopname);
+ shop.setShoptype(shoptype);
+ shop.setStatus(TradeDict.STATUS_NORMAL);
+ } else {
+ //修改
+ shop = shopDataService.getShopByShopid(shopid);
+ if (null == shop) {
+ return JsonResult.error("商户不存在,修改失败!请重新查询");
+ }
+ shop.setFshopid(fshopid);
+ shop.setShopname(shopname);
+// shop.setShoptype(shoptype); //商户类型不能改
+ }
+ shop.setContactman(contactman == null ? null : contactman.trim());
+ shop.setIdno(idno == null ? null : idno.trim());
+ shop.setIdtype(idtype == null ? null : idtype.trim());
+ if (!StringUtil.isEmpty(shop.getIdno()) && StringUtil.isEmpty(shop.getIdtype())) {
+ return JsonResult.error("填写证件号时必须制定证件类型!");
+ } else if (!StringUtil.isEmpty(shop.getIdno()) && "1".equals(shop.getIdtype()) && !StringUtil.isIdentity(shop.getIdno())) {
+ return JsonResult.error("身份证格式错误!");
+ }
+ shop.setMobile(mobile == null ? null : mobile);
+ if (!StringUtil.isEmpty(shop.getMobile()) && !StringUtil.isMobile(shop.getMobile())) {
+ return JsonResult.error("请正确填写手机号!");
+ }
+ shop.setTel(tel == null ? null : tel.trim());
+ shop.setEmail(email == null ? null : email.trim());
+ if (!StringUtil.isEmpty(shop.getEmail()) && !StringUtil.isEmail(shop.getEmail())) {
+ return JsonResult.error("请正确填写邮箱地址!");
+ }
+ shop.setAddr(addr == null ? null : addr.trim());
+ shop.setZipcode(zipcode == null ? null : zipcode.trim());
+
+ try{
+ if(shopDataService.saveOrUpdateShop(shop)){
+ return JsonResult.ok(addflag?"新增成功":"修改成功").put("shop",shop);
+ }else{
+ return JsonResult.error(addflag?"新增失败":"修改失败");
+ }
+ }catch (WebCheckException ex){
+ return JsonResult.error(ex.getMessage());
+ }catch (Exception e){
+ return JsonResult.error("系统处理异常").put("exception", e);
+ }
+ }
+
+
}
diff --git a/src/main/java/com/supwisdom/dlpay/system/service/ShopDataService.java b/src/main/java/com/supwisdom/dlpay/system/service/ShopDataService.java
index 087bec2..9a5dd9a 100644
--- a/src/main/java/com/supwisdom/dlpay/system/service/ShopDataService.java
+++ b/src/main/java/com/supwisdom/dlpay/system/service/ShopDataService.java
@@ -17,4 +17,7 @@
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
boolean deleteShop(TShop shop) throws WebCheckException;
+
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+ boolean saveOrUpdateShop(TShop shop) throws WebCheckException;
}
diff --git a/src/main/java/com/supwisdom/dlpay/system/service/impl/ShopDataServiceImpl.java b/src/main/java/com/supwisdom/dlpay/system/service/impl/ShopDataServiceImpl.java
index 33d227d..a06e334 100644
--- a/src/main/java/com/supwisdom/dlpay/system/service/impl/ShopDataServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/system/service/impl/ShopDataServiceImpl.java
@@ -1,13 +1,19 @@
package com.supwisdom.dlpay.system.service.impl;
+import com.supwisdom.dlpay.api.dao.ShopPaytypeDao;
+import com.supwisdom.dlpay.api.domain.TShopPaytype;
import com.supwisdom.dlpay.framework.dao.ShopDao;
import com.supwisdom.dlpay.framework.dao.ShopaccDao;
+import com.supwisdom.dlpay.framework.data.SystemDateTime;
import com.supwisdom.dlpay.framework.domain.TShop;
import com.supwisdom.dlpay.framework.domain.TShopacc;
+import com.supwisdom.dlpay.framework.service.SystemUtilService;
import com.supwisdom.dlpay.framework.util.StringUtil;
+import com.supwisdom.dlpay.framework.util.Subject;
import com.supwisdom.dlpay.framework.util.TradeDict;
import com.supwisdom.dlpay.system.bean.ZTreeNode;
import com.supwisdom.dlpay.system.service.ShopDataService;
+import com.supwisdom.dlpay.util.ConstantUtil;
import com.supwisdom.dlpay.util.WebCheckException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -21,17 +27,21 @@
private ShopDao shopDao;
@Autowired
private ShopaccDao shopaccDao;
+ @Autowired
+ private ShopPaytypeDao shopPaytypeDao;
+ @Autowired
+ private SystemUtilService systemUtilService;
@Override
public List<ZTreeNode> getAllShopNodes() {
List<ZTreeNode> result = new ArrayList<>(0);
- List<TShop> shoplist = shopDao.findAll();
+ List<TShop> shoplist = shopDao.getNormalShops();
if (!StringUtil.isEmpty(shoplist)) {
for (TShop shop : shoplist) {
if (null == shop || !TradeDict.STATUS_NORMAL.equals(shop.getStatus())) continue; //跳过注销商户
ZTreeNode node = new ZTreeNode();
node.setId(shop.getShopid().toString());
- node.setName(shop.getShopname());
+ node.setName(shop.getShopid()+"_"+shop.getShopname());
node.setpId(shop.getFshopid() == null ? "" : shop.getFshopid().toString());
node.setChecked(false);
node.setOpen(true);
@@ -57,11 +67,13 @@
if(!StringUtil.isEmpty(childShops))
throw new WebCheckException("请先删除下级商户");
shop.setStatus(TradeDict.STATUS_CLOSED);
+ shop.setClosedate(systemUtilService.getSysdatetime().getHostdate());
shopDao.save(shop);
if(!StringUtil.isEmpty(shop.getShopaccno())){
TShopacc shopacc=shopaccDao.getByShopaccno(shop.getShopaccno());
if(null==shopacc) throw new WebCheckException("数据异常!对应的商户账户不存在!");
shopacc.setStatus(TradeDict.STATUS_CLOSED);
+ shopacc.setClosedate(shop.getClosedate());
shopaccDao.save(shopacc);
}
return true;
@@ -69,5 +81,54 @@
return false;
}
+ @Override
+ public boolean saveOrUpdateShop(TShop shop) throws WebCheckException {
+ if (shop.getFshopid() != 0) {
+ TShop fshop = shopDao.getTShopByShopid(shop.getFshopid());
+ if (null == fshop) {
+ throw new WebCheckException("上级商户不存在!");
+ }else if(fshop.getShoptype()==1){
+ throw new WebCheckException("上级商户不是商户组!");
+ }
+ }
+ if (shopDao.checkShopnameExist(shop.getShopname(), shop.getFshopid(), shop.getShopid() == null ? 0 : shop.getShopid()) > 0) {
+ throw new WebCheckException("商户名称在同级下已经存在!");
+ }
+ if (null != shop.getShopid() && shop.getShopid() > 0) {
+ //修改
+ shopDao.save(shop);
+ if (!StringUtil.isEmpty(shop.getShopaccno())) {
+ shopaccDao.updateShopnameByShopaccno(shop.getShopname(), shop.getShopaccno()); //更新商户名
+ }
+ return true;
+ } else {
+ //新增
+ SystemDateTime dt = systemUtilService.getSysdatetime();
+ shop.setOpendate(dt.getHostdate());
+ shopDao.save(shop);
+ if (shop.getShoptype() == 1) {
+ TShopacc shopacc = new TShopacc();
+ shopacc.setShopaccno(String.format("2%09d", shop.getShopid()));
+ shopacc.setShopid(shop.getShopid());
+ shopacc.setShopname(shop.getShopname());
+ shopacc.setSubjno(Subject.SUBJNO_MACHANT_INCOME);
+ shopacc.setStatus(TradeDict.STATUS_NORMAL);
+ shopacc.setOpendate(dt.getHostdate());
+ shopacc.setBalance(0D);
+ shopaccDao.save(shopacc);
+
+ TShopPaytype shopPaytype = new TShopPaytype();
+ shopPaytype.setShopaccno(shopacc.getShopaccno());
+ shopPaytype.setPaytype(TradeDict.PAYTYPE_BALANCE);
+ shopPaytype.setConsumeEnable(ConstantUtil.ENABLE_YES);
+ shopPaytype.setAnonymousEnable(ConstantUtil.ENABLE_NO);
+ shopPaytype.setReverseEnable(ConstantUtil.ENABLE_NO);
+ shopPaytype.setCreatetime(dt.getHostdatetime());
+ shopPaytypeDao.save(shopPaytype); //默认增加余额支付方式
+ }
+ return true;
+ }
+ }
+
}
diff --git a/src/main/resources/templates/system/shop/index.html b/src/main/resources/templates/system/shop/index.html
index 1211547..558ab56 100644
--- a/src/main/resources/templates/system/shop/index.html
+++ b/src/main/resources/templates/system/shop/index.html
@@ -17,17 +17,127 @@
</div>
</div>
<div class="layui-col-xs7 layui-col-md9">
- <div class="layui-card">
- <div class="layui-card-body">
- <div class="layui-form toolbar">
- 搜索:
- <input id="search-value" class="layui-input search-input" type="text" placeholder="输入角色名称"/> 
- <button id="btn-search" class="layui-btn icon-btn" data-type="search"><i class="layui-icon"></i>搜索
- </button>
- <button id="btn-add" class="layui-btn icon-btn" data-type="add"><i class="layui-icon"></i>添加角色
- </button>
+ <div class="layui-card" style="min-height: 600px;">
+ <div id="shop-info" class="layui-form toolbar" lay-filter="shop-info-form" style="display: none;">
+ <div class="layui-card-header">商户基本信息</div>
+ <div class="layui-card-body">
+ <div class="layui-form-item">
+ <div class="layui-inline" style="width: 40%;">
+ <label class="layui-form-label">商户号</label>
+ <div class="layui-input-inline">
+ <input type="text" name="shopid" class="layui-input"
+ readonly="readonly"/>
+ </div>
+ </div>
+ <div class="layui-inline" style="width: 55%;">
+ <label class="layui-form-label">商户名</label>
+ <div class="layui-input-inline" style="width: 65%;">
+ <input type="text" name="shopname" autocomplete="off"
+ class="layui-input" maxlength="30" lay-verify="required"/>
+ </div>
+ </div>
+ </div>
+ <div class="layui-form-item">
+ <div class="layui-inline" style="width: 40%;">
+ <label class="layui-form-label">上级商户号</label>
+ <div class="layui-input-inline">
+ <input type="text" name="fshopid" id="fshopid" class="layui-input" autocomplete="off"
+ lay-verify="required|number"/>
+ </div>
+ </div>
+ <div class="layui-inline" style="width: 55%;">
+ <label class="layui-form-label">商户账号</label>
+ <div class="layui-input-inline" style="width: 65%;">
+ <input type="text" name="shopaccno" autocomplete="off"
+ class="layui-input" readonly="readonly"/>
+ </div>
+ </div>
+ </div>
+ <div class="layui-form-item">
+ <label class="layui-form-label">商户类型</label>
+ <div class="layui-input-inline">
+ <select name="shoptype" id="shoptype" lay-filter="shoptype-filter" lay-verify="required">
+ <option value="0">商户组</option>
+ <option value="1">结算商户</option>
+ </select>
+ </div>
+ <div class="layui-form-mid layui-word-aux">
+ 注意:商户组无商户账号,且能创建下级商户。结算商户是叶子商户,会创建商户账号。保存后无法修改!!!
+ </div>
+ </div>
+ <div class="layui-form-item">
+ <div class="layui-inline" style="width: 40%;">
+ <label class="layui-form-label">邮编</label>
+ <div class="layui-input-inline">
+ <input type="text" name="zipcode" class="layui-input" autocomplete="off" />
+ </div>
+ </div>
+ <div class="layui-inline" style="width: 55%;">
+ <label class="layui-form-label">地址</label>
+ <div class="layui-input-inline" style="width: 65%;">
+ <input type="text" name="addr" class="layui-input" maxlength="40" autocomplete="off" />
+ </div>
+ </div>
+ </div>
</div>
- <table class="layui-table" id="shoptable" lay-filter="shoptable-filter"></table>
+ <div class="layui-card-header">商户联系人信息</div>
+ <div class="layui-card-body">
+ <div class="layui-form-item">
+ <div class="layui-inline" style="width: 40%;">
+ <label class="layui-form-label">姓名</label>
+ <div class="layui-input-inline">
+ <input type="text" name="contactman" class="layui-input" autocomplete="off"/>
+ </div>
+ </div>
+ <div class="layui-inline" style="width: 55%;">
+ <label class="layui-form-label">手机号</label>
+ <div class="layui-input-inline" style="width: 65%;">
+ <input type="text" name="mobile" class="layui-input" maxlength="20" autocomplete="off"
+ lay-verify="mobile" />
+ </div>
+ </div>
+ </div>
+ <div class="layui-form-item">
+ <div class="layui-inline" style="width: 40%;">
+ <label class="layui-form-label">证件类型</label>
+ <div class="layui-input-inline">
+ <select name="idtype" lay-filter="idtype-filter">
+ <option value="1">身份证</option>
+ <option value="2">护照</option>
+ <option value="3">驾照</option>
+ <option value="4">港澳通行证</option>
+ <option value="5">学生证</option>
+ <option value="9">其他</option>
+ </select>
+ </div>
+ </div>
+ <div class="layui-inline" style="width: 55%;">
+ <label class="layui-form-label">证件号</label>
+ <div class="layui-input-inline" style="width: 65%;">
+ <input type="text" name="idno" class="layui-input" maxlength="20" autocomplete="off"/>
+ </div>
+ </div>
+ </div>
+ <div class="layui-form-item">
+ <div class="layui-inline" style="width: 40%;">
+ <label class="layui-form-label">邮箱</label>
+ <div class="layui-input-inline">
+ <input type="text" name="email" class="layui-input" autocomplete="off" lay-verify="swEmail"/>
+ </div>
+ </div>
+ <div class="layui-inline" style="width: 55%;">
+ <label class="layui-form-label">电话</label>
+ <div class="layui-input-inline" style="width: 65%;">
+ <input type="text" name="tel" class="layui-input" maxlength="20" autocomplete="off" />
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="layui-form-item" style="padding-bottom: 20px;text-align: center;">
+ <button class="layui-btn" lay-filter="form-submit" lay-submit id="submitbtn">保存</button>
+ <button class="layui-btn layui-btn-primary" type="button" id="cancelbtn">取消</button>
+ </div>
</div>
</div>
</div>
@@ -40,6 +150,20 @@
var form = layui.form;
var table = layui.table;
var admin = layui.admin;
+ form.render('select');
+ form.verify({
+ "mobile": function (e) {
+ if (null != e && e.length > 0 && !(/^1\d{10}$/.test(e))) {
+ return "请输入正确的手机号";
+ }
+ },
+ "swEmail": function (e) {
+ if (null != e && e.length > 0 && !(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(e))) {
+ return "邮箱格式不正确";
+ }
+ }
+ });
+
var initTree = function (nodes) {
var menuSetting = {
view: {
@@ -95,7 +219,7 @@
shopid: treeNode.id,
_csrf: $("meta[name='_csrf_token']").attr("value")
},
- success : function(result) {
+ success: function (result) {
console.log(result);
layer.closeAll('loading');
if (result.code == 200) {
@@ -110,7 +234,7 @@
layer.msg(result.msg, {icon: 2});
}
},
- error : function() {
+ error: function () {
console.log(ret);
layer.closeAll('loading');
layer.msg("请求服务器失败!", {icon: 2});
@@ -124,7 +248,58 @@
$("#addBtn_" + treeNode.tId).unbind().remove();
}
- newCount = 10000
+ $('#cancelbtn').click(function () {
+ $("#shop-info").hide();
+ });
+
+ form.on('submit(form-submit)', function (data) {
+ layer.load(2);
+ var vdata = data.field;
+ vdata["_csrf"] = $("meta[name='_csrf_token']").attr("value");
+ $.ajax({
+ type: "POST",
+ dataType: "json",
+ url: '/shop/saveorupdate',
+ data: vdata,
+ success: function (result) {
+ layer.closeAll('loading');
+ debugger
+ if (result.code == 200) {
+ var zTree = $.fn.zTree.getZTreeObj("shoptree");
+ var treeNode = zTree.getNodeByParam("id", '' + result.shop.shopid, null);
+ if (undefined != treeNode && null != treeNode) {
+ treeNode.id = ''+result.shop.shopid;
+ treeNode.pId = '' + result.shop.fshopid;
+ treeNode.name = '' + result.shop.shopid + '_' + result.shop.shopname;
+ zTree.updateNode(treeNode); //修改节点
+ } else {
+ var ftreeNode = zTree.getNodeByParam("id", '' + result.shop.fshopid, null);
+ zTree.addNodes(ftreeNode, {
+ id: '' + result.shop.shopid,
+ pId: '' + result.shop.fshopid,
+ name: '' + result.shop.shopid + '_' + result.shop.shopname,
+ shoptype: result.shop.shoptype
+ }); //新加树节点
+ }
+ layer.msg(result.msg, {icon: 1});
+ $("#shop-info").hide();
+ } else if (result.code == 401) {
+ layer.msg(result.msg, {icon: 2, time: 1500}, function () {
+ location.replace('/login');
+ }, 1000);
+ return;
+ } else {
+ console.log('err:' + result.code);
+ layer.msg(result.msg, {icon: 2});
+ }
+ },
+ error: function () {
+ layer.closeAll('loading');
+ layer.msg("请求服务器失败!", {icon: 2});
+ }
+ });
+ });
+
function addHoverDom(treeId, treeNode) {
if (treeNode.shoptype == 0) {
var sObj = $("#" + treeNode.tId + "_span");
@@ -134,16 +309,54 @@
sObj.after(addStr);
var btn = $("#addBtn_" + treeNode.tId);
if (btn) btn.bind("click", function () {
- debugger
- var zTree = $.fn.zTree.getZTreeObj("shoptree");
- zTree.addNodes(treeNode, {id: (100 + newCount), pId: treeNode.id, shoptype: 0, name: "new node" + (newCount++)});
+ form.val("shop-info-form",{
+ "shopid":"0",
+ "shopname": "",
+ "fshopid":treeNode.id,
+ "shoptype":"0",
+ "zipcode":"",
+ "addr":"",
+ "contactman":"",
+ "idtype":"1",
+ "idno":"",
+ "mobile":"",
+ "email":"",
+ "tel":""
+ });
+ $("#fshopid").attr("readonly", "readonly");
+ $("#shoptype").removeAttr("disabled");
+ form.render('select');
+ $("#submitbtn").text("新增");
+ $("#shop-info").show();
return false;
});
}
}
- function ondblclick(event, treeId, treeNode){
- alert("treeId=["+treeId+"],nodename=["+treeNode.name+"]");
+ function ondblclick(event, treeId, treeNode) {
+ admin.dgo('/shop/getshopinfo', {
+ "shopid": treeNode.id
+ }, function (data) {
+ console.log("getshopinfo返回",data);
+ if (data.code == 200) {
+ form.val("shop-info-form",data.shop);
+ $("#fshopid").removeAttr("readonly");
+ $("#shoptype").attr('disabled', 'disabled');
+ form.render('select');
+ $("#submitbtn").text("保存");
+ $("#shop-info").show();
+ } else if (data.code == 401) {
+ layer.msg(data.msg, {icon: 2, time: 1500}, function () {
+ location.replace('/login');
+ }, 1000);
+ return;
+ } else {
+ layer.msg(data.msg, {icon: 2, time: 2000});
+ }
+ }, function (ret) {
+ console.log(ret);
+ layer.msg('查询商户失败了,请求服务器异常', {icon: 2});
+ });
}
admin.dgo('/shop/shoptree', {}, function (data) {
@@ -161,7 +374,5 @@
console.log(ret);
layer.msg('查询商户树失败了,请稍后再试', {icon: 2});
});
-
-
});
</script>
\ No newline at end of file