Commit 22d47957 authored by 黎聪聪's avatar 黎聪聪

收货地址管理

parent 6e1433a6
......@@ -105,7 +105,11 @@
<table id="table" class="table table-bordered table-striped">
<thead>
<tr>
<td hidden="true">Id</td><th>粉丝openid</th><th>二维码类型</th><th>二维码</th><th>扫码时间</th>
<td hidden="true">Id</td
><th>粉丝openid</th>
<th>二维码类型</th>
<th>二维码</th>
<th>扫码时间</th>
</tr>
</thead>
<tbody id="tablebody">
......
......@@ -18,6 +18,7 @@
<module>member-module-web</module>
<module>membercard-module</module>
<module>membercard-module-web</module>
<module>shipping-address-module</module>
</modules>
<dependencies>
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>membercard-modules</artifactId>
<groupId>com.cftech</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>shipping-address-module</artifactId>
</project>
\ No newline at end of file
package com.cftech.addresst.dao;
import com.cftech.addresst.model.Address;
import com.cftech.addresst.model.Area;
import com.cftech.core.generic.GenericDao;
import java.util.List;
/**
* 收货地址管理Mapper
*
* @author Licc
* @date: 2020-09-29 17:17
*/
public interface AddressMapper extends GenericDao<Address> {
List<Area> listArea();
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cftech.addresst.dao.AddressMapper">
<resultMap id="resultMap" type="com.cftech.addresst.model.Address">
<id column="id" property="id"/>
<result column="open_id" property="openId"/>
<result column="address_name" property="addressName"/>
<result column="address" property="address"/>
<result column="province_id" property="provinceId"/>
<result column="city_id" property="cityId"/>
<result column="area_id" property="areaId"/>
<result column="sex" property="sex"/>
<result column="phone" property="phone"/>
<result column="whether" property="whether"/>
<result column="accounts_id" property="accountsId"/>
<result column="del_flag" property="delFlag"/>
<result column="status" property="status"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="description" property="description"/>
<result column="create_by" property="createBy"/>
<result column="update_by" property="updateBy"/>
</resultMap>
<sql id="sqlWhere">
<if test="conds!=null">
<trim prefix="WHERE" prefixOverrides="AND|OR">
<foreach collection="conds.conds" index="index" item="cond">
${cond.linkType}
<if test="cond.condType == 'EQUAL'">${cond.param} = #{cond.value}</if>
<if test="cond.condType == 'NOTEQUAL'">${cond.param} &lt;&gt; #{cond.value}</if>
<if test="cond.condType == 'GREATEQUAL'">${cond.param} &gt;= #{cond.value}</if>
<if test="cond.condType == 'GREATTHAN'">${cond.param} &gt; #{cond.value}</if>
<if test="cond.condType == 'LESSEQUAL'">${cond.param} &lt;= #{cond.value}</if>
<if test="cond.condType == 'LESSTHAN'">${cond.param} &lt; #{cond.value}</if>
<if test="cond.condType == 'BETWEEN'">${cond.param} BETWEEN #{cond.startValue} AND
#{cond.endValue}
</if>
<if test="cond.condType == 'ISNULL'">${cond.param} IS NULL</if>
<if test="cond.condType == 'NOTNULL'">${cond.param} IS NOT NULL</if>
<if test="cond.condType == 'LIKE'">${cond.param} LIKE #{cond.value}</if>
<if test="cond.condType == 'IN'">${cond.param} IN
<foreach item="item" index="index" collection="cond.value" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</foreach>
</trim>
</if>
</sql>
<sql id="sqlColumns">
t.id,
t.open_id,
t.address_name,
t.address,
t.province_id,
t.city_id,
t.area_id,
t.sex,
t.phone,
t.whether,
t.accounts_id,
t.del_flag,
t.STATUS,
t.create_time,
t.update_time,
t.description,
t.create_by,
t.update_by,
a.areaid,
a.citytype,
a.areaname provinceName,
b.areaname cityName,
c.areaname countyName
</sql>
<insert id="save" parameterType="com.cftech.addresst.model.Address" useGeneratedKeys="true"
keyProperty="id">
insert into t_shipping_address
(
<include refid="sqlColumns"/>
)
values
(
#{id, jdbcType=BIGINT},
#{openId, jdbcType=BIGINT},
#{addressName, jdbcType=VARCHAR},
#{address, jdbcType=VARCHAR},
#{province_id, jdbcType=BIGINT},
now(),
now(),
#{sex, jdbcType=BIGINT},
#{Phone, jdbcType=VARCHAR},
#{whether, jdbcType=VARCHAR},
#{accountsId, jdbcType=BIGINT},
#{delFlag, jdbcType=TINYINT},
#{status, jdbcType=VARCHAR},
now(),
now(),
#{description, jdbcType=VARCHAR},
#{createBy, jdbcType=BIGINT},
#{updateBy, jdbcType=BIGINT}
)
</insert>
<select id="fetchById" parameterType="java.lang.Long" resultMap="resultMap">
SELECT
<include refid="sqlColumns"/>
FROM t_shipping_address t
LEFT JOIN area a ON t.province_id = a.areaid
LEFT JOIN area b ON t.city_id = b.areaid
LEFT JOIN area c ON t.area_id = c.areaid
WHERE t.id=#{id}
</select>
<select id="count" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT COUNT(1) FROM t_shipping_address t
LEFT JOIN area a ON t.province_id = a.areaid
LEFT JOIN area b ON t.city_id = b.areaid
LEFT JOIN area c ON t.area_id = c.areaid
<include refid="sqlWhere"/>
</select>
<select id="fetchSearchByPage" parameterType="java.util.Map" resultMap="resultMap">
SELECT
<include refid="sqlColumns"/>
FROM t_shipping_address t
LEFT JOIN area a ON t.province_id = a.areaid
LEFT JOIN area b ON t.city_id = b.areaid
LEFT JOIN area c ON t.area_id = c.areaid
<include refid="sqlWhere"/>
<if test="sort!=null">ORDER BY ${sort.param} ${sort.type}</if>
<if test="limit>0">limit #{offset},#{limit}</if>
</select>
<update id="update" parameterType="com.cftech.addresst.model.Address">
update t_shipping_address
<set>
<if test="id != null">
id = #{id, jdbcType=BIGINT},
</if>
<if test="openId != null">
open_id = #{openId, jdbcType=BIGINT},
</if>
<if test="addressName != null">
address_name = #{addressName, jdbcType=VARCHAR},
</if>
<if test="address != null">
address = #{address, jdbcType=VARCHAR},
</if>
<if test="provinceId != null">
province_id = #{provinceId, jdbcType=BIGINT},
</if>
<if test="cityId != null">
city_id = #{cityId, jdbcType=TIMESTAMP},
</if>
<if test="areaId != null">
area_id = #{areaId, jdbcType=TIMESTAMP},
</if>
<if test="sex != null">
sex = #{sex, jdbcType=BIGINT},
</if>
<if test="phone != null">
phone = #{phone, jdbcType=VARCHAR},
</if>
<if test="whether != null">
whether = #{whether, jdbcType=VARCHAR},
</if>
<if test="accountsId != null">
accounts_id = #{accountsId, jdbcType=BIGINT},
</if>
<if test="delFlag != null">
del_flag = #{delFlag, jdbcType=TINYINT},
</if>
<if test="status != null">
status = #{status, jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime, jdbcType=TIMESTAMP},
</if>
<if test="description != null">
description = #{description, jdbcType=VARCHAR},
</if>
<if test="createBy != null">
create_by = #{createBy, jdbcType=BIGINT},
</if>
<if test="updateBy != null">
update_by = #{updateBy, jdbcType=BIGINT},
</if>
</set>
where id=#{id,jdbcType=BIGINT}
</update>
<update id="delete" parameterType="java.lang.Long">
update t_shipping_address set del_flag=1 where id=#{id,jdbcType=BIGINT}
</update>
<select id="listArea" resultType="com.cftech.addresst.model.Area">
select areaid,areaname,affiliationareaId,citytype from area
</select>
</mapper>
\ No newline at end of file
package com.cftech.addresst.model;
import com.cftech.core.poi.ExportConfig;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 收货地址管理
*
* @author Licc
* @date: 2020-09-29 17:17
*/
@Data
public class Address extends Area implements Serializable {
/* 主键id */
private Long id;
/* openId */
@ExportConfig(value = "openId", width = 100, showLevel = 1)
private String openId;
/* 收货人name */
@ExportConfig(value = "收货人name", width = 100, showLevel = 1)
private String addressName;
/* 详细收货地址 */
@ExportConfig(value = "详细收货地址", width = 100, showLevel = 1)
private String address;
/* 省份id */
@ExportConfig(value = "省份id", width = 100, showLevel = 1)
private Long provinceId;
/* 城市id */
@ExportConfig(value = "城市id", width = 100, showLevel = 1)
private Long cityId;
/* 区县id*/
@ExportConfig(value = "区县id", width = 100, showLevel = 1)
private Long areaId;
/* 性别 */
@ExportConfig(value = "性别", width = 100, showLevel = 1)
private Long sex;
/* 手机号 */
@ExportConfig(value = "手机号", width = 100, showLevel = 1)
private String phone;
/* 是否为默认地址 */
@ExportConfig(value = "是否为默认地址", width = 100, showLevel = 1)
private String whether;
/* 所属的账号 */
private Long accountsId;
/* 删除标识 */
private boolean delFlag;
/* 状态 */
private String status;
/* 创建时间 */
private Date createTime;
/* 更新时间 */
private Date updateTime;
/* 备注 */
private String description;
/* 创建人 */
private Long createBy;
/* 更新人 */
private Long updateBy;
public Address() {
this.delFlag = false;
this.status = "0";
}
}
\ No newline at end of file
package com.cftech.addresst.model;
import lombok.Data;
/**
* @author :licc
* @date :Created in 2020/9/30 10:38
* @description:
*/
@Data
public class Area {
private Long areaId;
private String areaName;
private Long cityType;
private Long affiliationareaId;
private String provinceName;
private String cityName;
private String countyName;
}
package com.cftech.addresst.service;
import com.cftech.addresst.model.Address;
import com.cftech.addresst.model.Area;
import com.cftech.core.generic.GenericService;
import java.util.List;
/**
* 收货地址管理Service
*
* @author Licc
* @date: 2020-09-29 17:17
*/
public interface AddressService extends GenericService<Address> {
List<Area> listArea();
}
package com.cftech.addresst.service.impl;
import com.cftech.addresst.model.Address;
import com.cftech.addresst.dao.AddressMapper;
import com.cftech.addresst.model.Area;
import com.cftech.addresst.service.AddressService;
import com.cftech.core.generic.GenericDao;
import com.cftech.core.generic.GenericServiceImpl;
import com.cftech.core.sql.Conds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 收货地址管理ServiceImpl
*
* @author Licc
* @date: 2020-09-29 17:17
*/
@Service("addressService")
public class AddressServiceImpl extends GenericServiceImpl<Address> implements AddressService {
@Autowired
@Qualifier("addressMapper")
private AddressMapper addressMapper;
@Override
public GenericDao<Address> getGenericMapper() {
return addressMapper;
}
@Override
public List<Area> listArea() {
return addressMapper.listArea();
}
}
\ No newline at end of file
package com.cftech.addresst.web;
import com.alibaba.fastjson.JSONObject;
import com.cftech.addresst.model.Address;
import com.cftech.addresst.model.Area;
import com.cftech.addresst.service.AddressService;
import com.cftech.core.poi.ExcelKit;
import com.cftech.core.scope.OrderType;
import com.cftech.core.sql.Conds;
import com.cftech.core.sql.Sort;
import com.cftech.core.util.Constants;
import com.cftech.sys.security.PermissionSign;
import com.cftech.sys.security.UserUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.List;
/**
* 收货地址管理Controller
* <p>
* 权限字符串说明:
* 查看:public static final String ADDRESS_VIEW = "qy:address:view"
* 查看:public static final String ADDRESS_EDIT = "qy:address:edit"
*
* @author Licc
* @date: 2020-09-29 17:17
*/
@Slf4j
@Controller
@RequestMapping("/a/address")
public class AddressController {
public static final String ADDRESS_VIEW = "qy:address:view";
public static final String ADDRESS_EDIT = "qy:address:edit";
@Autowired
private AddressService addressService;
//列表页面
@RequiresPermissions(value = ADDRESS_VIEW)
@RequestMapping("/list")
public String list(HttpServletRequest request, Model model) {
Long accountId = UserUtils.getmpaccounts(request);
model.addAttribute("accountId", accountId);
return "address/addresslist";
}
//编辑页面(新增、修改)
@RequiresPermissions(value = ADDRESS_VIEW)
@RequestMapping("/form")
public String form(HttpServletRequest request, String id, Model model) {
if (!StringUtils.isEmpty(id)) {
Address address = addressService.fetchById(id);
model.addAttribute("data", address);
}
return "address/addressform";
}
//提交数据(新增、修改)
@RequiresPermissions(value = ADDRESS_EDIT)
@RequestMapping(value = "/formData",method = {RequestMethod.GET})
@ResponseBody
public JSONObject formData(Address address, Model model, HttpServletRequest request) {
Long accountsId = UserUtils.getmpaccounts(request);
JSONObject rtnJson = new JSONObject();
try {
if (address != null && address.getId() != null) {
address.setUpdateBy(UserUtils.getUser().getId());
addressService.update(address);
rtnJson.put("errorNo", 0);
} else {
address.setAccountsId(accountsId);
address.setDelFlag(false);
address.setAccountsId(UserUtils.getmpaccounts(request));
address.setCreateBy(UserUtils.getUser().getId());
address.setUpdateBy(UserUtils.getUser().getId());
addressService.save(address);
rtnJson.put("errorNo", 2);
}
} catch (Exception e) {
rtnJson.put("errorNo", 1);
}
return rtnJson;
}
//获取列表数据
@RequiresPermissions(value = ADDRESS_VIEW)
@RequestMapping(value = "/listData")
@ResponseBody
public JSONObject listData(int iDisplayStart, int iDisplayLength, Address address, HttpServletRequest request) {
Long accountsId = UserUtils.getmpaccounts(request);
Conds conds = new Conds();
conds.equal("t.del_flag", Constants.DEL_FLAG_0);
conds.equal("t.accounts_id", accountsId);
if (!StringUtils.isEmpty(address.getAddressName())){
conds.like("t.address_name",address.getAddressName());
}
if (!StringUtils.isEmpty(address.getProvinceId())){
conds.equal("t.province_id",address.getProvinceId());
}
if (!StringUtils.isEmpty(address.getCityId())){
conds.equal("t.city_id",address.getCityId());
}
if (!StringUtils.isEmpty(address.getAreaId())){
conds.equal("t.area_id",address.getAreaId());
}
Sort sort = new Sort("t.create_time", OrderType.DESC);
List<Address> list = addressService.fetchSearchByPage(conds, sort, iDisplayStart, iDisplayLength);
Integer counts = addressService.count(conds);
JSONObject rtnJson = new JSONObject();
rtnJson.put("iTotalRecords", counts);
rtnJson.put("iTotalDisplayRecords", counts);
rtnJson.put("aaData", list);
return rtnJson;
}
//删除数据
@RequiresPermissions(value = ADDRESS_EDIT)
@RequestMapping("/delete")
@ResponseBody
public JSONObject delete(String id) {
JSONObject rtnJosn = new JSONObject();
try {
addressService.delete(id);
rtnJosn.put("errorNo", 0);
} catch (Exception e) {
rtnJosn.put("errorNo", 1);
}
return rtnJosn;
}
@GetMapping("/listArea")
@ResponseBody
public List<Area> listArea(){
return addressService.listArea();
}
@RequestMapping("/exportExcel")
@RequiresPermissions(value = ADDRESS_VIEW)
public void exportExcel(HttpServletRequest request, HttpServletResponse response) {
Long accountId = UserUtils.getmpaccounts(request);
Sort sort = new Sort("create_time", OrderType.ASC);
Conds conds = new Conds();
conds.equal("del_flag", 0);
conds.equal("accounts_id", accountId);
List<Address> list = addressService.fetchSearchByPage(conds, sort, 0, 0);
ExcelKit.$Export(Address.class, response).toExcel(list, "收货地址管理信息");
}
@RequestMapping("/templateExcel")
@RequiresPermissions(value = ADDRESS_VIEW)
public void templateExcel(HttpServletRequest request, HttpServletResponse response) {
ExcelKit.$Export(Address.class, response).toExcel(null, "收货地址管理信息");
}
@RequestMapping("/importExcel")
@RequiresPermissions(value = ADDRESS_EDIT)
public String importExcel(HttpServletRequest request, MultipartFile file, Model model) {
Long accountId = UserUtils.getmpaccounts(request);
if (file == null) {
return list(request, model);
}
// 构造临时路径来存储上传的文件
String uploadPath = System.getProperty("java.io.tmpdir");
File uploadDir = new File(uploadPath);
if (!uploadDir.exists()) {
uploadDir.mkdir();
}
String fileName = file.getOriginalFilename();
String filePath = uploadPath + File.separator + fileName;
File storeFile = new File(filePath);
try {
file.transferTo(storeFile);
ExcelKit.$Import().setEmptyCellValue("").readExcel(storeFile, rowData -> {
if (!StringUtils.isEmpty(rowData.get(0))) {
Address address = new Address();
address.setAccountsId(accountId);
addressService.save(address);
}
});
} catch (IOException e) {
log.error(e.getMessage());
}
return list(request, model);
}
}
CREATE TABLE `t_shipping_address` (`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id',`_id` bigint(20) NULL DEFAULT NULL COMMENT '收货地址id',`open_id` bigint(20) NULL DEFAULT NULL COMMENT 'openId',`_address_name` varchar(50) NULL DEFAULT NULL COMMENT '收货人name',`_address` varchar(50) NULL DEFAULT NULL COMMENT '详细收货地址',`province_id` bigint(20) NULL DEFAULT NULL COMMENT '',`city_id` datetime NULL DEFAULT NULL COMMENT '',`area_id` datetime NULL DEFAULT NULL COMMENT '',`sex` bigint(20) NULL DEFAULT NULL COMMENT '性别',`_phone` varchar(20) NULL DEFAULT NULL COMMENT '手机号',`whether` varchar(50) NULL DEFAULT NULL COMMENT '是否为默认地址',`accounts_id` bigint(20) NULL DEFAULT NULL COMMENT '所属的账号',`del_flag` tinyint(4) NOT NULL DEFAULT 0 COMMENT '删除标识',`status` varchar(10) NULL DEFAULT '0' COMMENT '状态',`create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',`update_time` datetime NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',`description` varchar(100) NULL DEFAULT NULL COMMENT '备注',`create_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',`update_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='收货地址管理表';
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>membercard-modules</artifactId>
<groupId>com.cftech</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>consult-module-web</artifactId>
<packaging>war</packaging>
<name>consult-module-web Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>com.cftech</groupId>
<artifactId>shipping-address-module</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<finalName>shipping-address-web</finalName>
</build>
</project>
\ No newline at end of file
<!DOCTYPE html>
<!--[if IE 8]>
<html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]>
<html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html>
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<base href="#springUrl('/assets/adminlte/')"/>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>工作台</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.5 -->
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="plugins/font-awesome/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="plugins/ionicons/css/ionicons.min.css">
<!-- DataTables -->
<link rel="stylesheet" href="plugins/datatables/dataTables.bootstrap.css">
<!-- Theme style -->
<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
<!-- iCheck -->
<link rel="stylesheet" href="plugins/iCheck/flat/blue.css">
<!-- Date Picker -->
<link rel="stylesheet" href="plugins/datepicker/datepicker3.css">
<!-- Daterange picker -->
<link rel="stylesheet" href="plugins/daterangepicker/daterangepicker-bs3.css">
<!-- bootstrap wysihtml5 - text editor -->
<link rel="stylesheet" href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
<!--validate css-->
<link rel="stylesheet" href="plugins/jquery-validation/css/validate.css">
<!--fileinput css-->
<link rel="stylesheet" href="plugins/bootstrap-fileinput/bootstrap-fileinput.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<!-- END HEAD -->
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<div class="content-wrapper" style="margin-left:0;">
<section class="content-header">
<h1>
收货地址管理管理
<small>收货地址管理</small>
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-dashboard"></i>首页</a></li>
<li><a class="active">收货地址管理</a></li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-xs-12">
<!-- general form elements disabled -->
<div class="box box-primary">
<form role="form" id="myForm">
<input id="id" name="id" value="$!{data.id}" hidden="true"/>
<div class="box-body">
<div class="form-group form-md-line-input">
<label>openId<font style="color: red"></font></label>
<input type="text"
class="form-control" name="consultId"
id="openId" readonly="readonly"
maxlength="50" placeholder="openId"
value="$!{data.openId}"
>
<label>患者姓名<font style="color: red"></font></label>
<input type="text"
class="form-control" name="addressName"
id="addressName" readonly="readonly"
maxlength="50" placeholder="患者姓名"
value="$!{data.addressName}"
>
<label>性别<font style="color: red"></font></label>
<input type="text"
class="form-control" name="sex"
id="sex" readonly="readonly"
maxlength="50" placeholder="性别"
value="$!{data.sex}"
>
<label>联系方式<font style="color: red"></font></label>
<input type="text"
class="form-control" name="phone"
id="phone" readonly="readonly"
maxlength="50" placeholder="联系方式"
value="$!{data.phone}"
>
<!-- $!{data.provinceId}-->
<!-- $!{data.provinceName}-->
<label>省份<font style="color: red"></font></label><br>
<input class="form-control" id="province" name="provinceName"
type="text" readonly="readonly"
maxlength="50" placeholder="省份"
value="$!{data.provinceName}"
>
<!-- onchange="getCityList(this.value);"-->
<!-- <option></option>-->
</input><br>
<label>城市<font style="color: #ff0000"></font></label><br>
<input class="form-control" id="city" name="cityName"
type="text" readonly="readonly"
maxlength="50" placeholder="城市"
value="$!{data.cityName}"
>
<!-- onchange="getReginList(this.value);"-->
<!-- <option></option>-->
</input><br>
<label>区/县<font style="color: red"></font></label><br>
<input class="form-control" id="county" name="countyName"
type="text" readonly="readonly"
maxlength="50" placeholder="城市"
value="$!{data.countyName}"
>
<!-- <option></option>-->
</input><br>
<label>详细地址<font style="color: red"></font></label>
<input type="text"
class="form-control" name="address"
id="address" readonly="readonly"
maxlength="50" placeholder="联系方式"
value="$!{data.address}"
>
</div>
<div class="box-footer">
<!-- #if($shiro.hasPermission("qy:address:edit"))-->
<!-- <input class="btn btn-primary" id="save" value="保存" type="button" onclick="tijiao()">-->
<!-- #end-->
<a href="#springUrl('/a/address/list')" class="btn btn-default">返回</a>
</div>
</form>
<!-- /.box-body -->
</div><!-- /.box -->
</div><!-- /.col -->
</div><!-- /.row -->
</section><!-- /.content -->
</div><!-- /.content-wrapper -->
<!-- Add the sidebar's background. This div must be placed
immediately after the control sidebar -->
<div class="control-sidebar-bg"></div>
</div><!-- ./wrapper -->
<script src="plugins/jQuery/jQuery-2.1.4.min.js"></script>
<!-- Bootstrap 3.3.5 -->
<script src="bootstrap/js/bootstrap.min.js"></script>
<!-- DataTables -->
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables/extensions/i18n/lanauage_ch.js"></script>
<script src="plugins/datatables/dataTables.bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="plugins/fastclick/fastclick.min.js"></script>
<!--fileinput js-->
<script src="plugins/bootstrap-fileinput/bootstrap-fileinput.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/app.min.js"></script>
<script src="plugins/bootstrap-maxlength/bootstrap-maxlength.min.js" type="text/javascript"></script>
<script src="plugins/security/sha256.js" type="text/javascript"></script>
<script src="plugins/jquery-validation/js/jquery.validate.min.js"></script>
<script src="js/jquery.form.min.js"></script>
<script type="text/javascript" charset="utf-8" src="plugins/ueditor-min-1.4.3/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="plugins/ueditor-min-1.4.3/ueditor.all.js"></script>
<script type="text/javascript" charset="utf-8" src="plugins/ueditor-min-1.4.3/lang/zh-cn/zh-cn.js"></script>
<script src="common/js/cfapp.js"></script>
<!-- END PAGE LEVEL PLUGINS -->
<script>
let areaList=null
let listProvince=null
let listCity=null
let listRegin=null
function tijiao(){
var url = "#springUrl('/a/address/formData')"
var provinceId = $("#province").val();
var cityId = $("#city").val();
var areaId = $("#county").val();
var address =$("#address").val();
var id= $("#id").val();
$.ajax({
type: "GET", //提交的方法
url:url, //提交的地址
data:{ id,provinceId,cityId,areaId,address},// 序列化表单值
async: false,
success: function(data) { //成功
if (data){
location.href = "#springUrl('/a/address/list')";
}else {
alert("修改失败")
}
}
});
}
$().ready(function () {
var sex = $("#sex").val();
if (sex == '0') {
$("#sex").val("女");
} else if (sex == '0') {
$("#sex").val("男");
} else {
$("#sex").val("");
}
})
// var url = "#springUrl('/a/address/listArea')"
// $.ajax({
// url:url,
// type:"GET",
// success:function(data){
// console.log(data)
// areaList=data
// listProvince=data.filter(x=>x.cityType==1)
// var province = document.querySelector('#province') //querySelector获取id="province"的元素
// for (index in listProvince) {
// var op = new Option(listProvince[index].areaName, listProvince[index].areaId, false, false)
// //将循环出来的元素追加到province下拉框里
// province.options[province.length] = op
// }
// var provinceId = "$!{data.provinceId}";
// $('#province option').each(function () {
// if($(this).val() == provinceId){
// $(this).attr('selected', 'selected');
// getCityList(provinceId);
// }
// })
//
// }
// });
// // var all_select = $('#province > option')
// //
// // for (var i = 0; i < all_select.length; i++) {
// // console.log(all_select.length)
// // var svalue = all_select[i]
// // console.log(svalue+"$!{data.provinceId}")
// // if (svalue == '') {
// // console.log("$!{data.provinceName}")
// // //取select中所有的option的值与其进行对比,相等则令这个option添加上selected属性
// // $("#province option[value='" + svalue + "']").attr('selected', 'selected')
// // }
// // }'
//
//
//
//
// Cfapp.init();
// // recdTypeAdd.init();
// });
//
// function getCityList(areaId) {
// listCity=areaList.filter(x=>x.affiliationareaId==areaId&&x.cityType==2)
// $("#city").empty();
// $("#county").empty();
// var city = document.querySelector('#city')
// for (index in listCity) {
// var op = new Option(listCity[index].areaName, listCity[index].areaId, false, false)
// //将循环出来的元素追加到province下拉框里
// city.options[city.length] = op
// }
// var cityId = "$!{data.cityId}";
// $('#city option').each(function () {
// if($(this).val() == cityId){
// $(this).attr('selected', 'selected');
// getReginList(cityId);
// }
// })
//
// }
//
// function getReginList(areaId) {
// listRegin=areaList.filter(x=>x.affiliationareaId==areaId&&x.cityType==3)
// $("#county").empty();
// var county = document.querySelector('#county')
// for (index in listRegin) {
// // 1、new Option("文本","值",true,true).后面两个true分别表示默认被选中和有效
// var op = new Option(listRegin[index].areaName, listRegin[index].areaId, false, false)
// //将循环出来的元素追加到province下拉框里,第一次训话length=1,第二次循环length=2
// county.options[county.length] = op
// }
// var countyId = "$!{data.countyId}";
// $('#county option').each(function () {
// if($(this).val() == countyId){
// $(this).attr('selected', 'selected');
// }
// })
// }
//
//
//
//
// var recdTypeAdd = function () {
// var initForm = function () {
// var initFormCtrl = function () {
// bindEvent();
// };
// var bindEvent = function () {
//
// $("#myForm").validate({
// rules: {},
// messages: {},
// submitHandler: function (form) {
// // $("#save").attr("disabled", true);
//
// $.getJSON("#springUrl('/a/address/formData')",$("#myForm").serialize(), function (returnobj) {
// // $("#save").attr("disabled", false);
// if (returnobj.errorNo == 2) { //保存成功
// Cfapp.confirm({
// message: "添加成功",
// btnoktext: "继续添加",
// btncanceltext: "关闭",
// success: function () {
// location.href = "#springUrl('/a/address/form')";
// },
// cancel: function () {
// location.href = "#springUrl('/a/address/list')";
// }
// });
// } else if (returnobj.errorNo == 0) { //修改成功
// Cfapp.alert({
// message: "更新成功",
// btntext: "确定",
// success: function () {
// location.href = "#springUrl('/a/address/list')";
// }
// });
// } else {
// Cfapp.alert({
// message: "创建失败",
// btntext: "确定",
// success: function () {
// location.href = "#springUrl('/a/address/list')";
// }
// });
// }
// });
// }
// })
// }
// initFormCtrl();
// }
// return {
//
// //main function to initiate the module
// init: function () {
// initForm();
// }
//
// };
// }();
</script>
</body>
<!-- END BODY -->
</html>
\ No newline at end of file
<!DOCTYPE html>
<!--[if IE 8]>
<html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]>
<html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html>
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<base href="#springUrl('/assets/adminlte/')"/>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>工作台</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.5 -->
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="plugins/font-awesome/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="plugins/ionicons/css/ionicons.min.css">
<!-- DataTables -->
<link rel="stylesheet" href="plugins/datatables/dataTables.bootstrap.css">
<!-- Theme style -->
<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
<!-- iCheck -->
<link rel="stylesheet" href="plugins/iCheck/flat/blue.css">
<!-- Morris chart -->
<link rel="stylesheet" href="plugins/morris/morris.css">
<!-- jvectormap -->
<link rel="stylesheet" href="plugins/jvectormap/jquery-jvectormap-1.2.2.css">
<!-- Date Picker -->
<link rel="stylesheet" href="plugins/datepicker/datepicker3.css">
<!-- Daterange picker -->
<link rel="stylesheet" href="plugins/daterangepicker/daterangepicker-bs3.css">
<link rel="stylesheet"
href="plugins\bootstrap-fileinput\fileinput.min.css">
<!-- bootstrap wysihtml5 - text editor -->
<link rel="stylesheet" href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<div class="content-wrapper" style="margin-left:0;">
<div id="importExcelDiv"></div>
<section class="content-header">
<h1>
收货地址管理管理
<small>收货地址管理</small>
</h1>
<ol class="breadcrumb">
<li><a><i class="fa fa-dashboard"></i>首页</a></li>
<li><a class="active">收货地址管理管理列表</a></li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header">
<form id="seachTableForm" action="#springUrl('/a/address/list')" method="get">
<div class="col-xs-5">
<div class="col-xs-2" style=" display: flex">
<input style="width: 100px ; height: 41px" type="text" class="form-control required"
id="addressName" name="addressName" placeholder="患者姓名">
&nbsp;&nbsp; &nbsp;
<select style="width: 100px" id="province" name="cityId" onchange="getCityList(this.value)">
<option value="">请选择省份</option>
</select>
&nbsp;&nbsp;
<select id="city" name="cityId" onchange="getReginList(this.value);">
<option value="">请选择城市</option>
</select>
&nbsp;&nbsp;
<select id="county" name="areaId">
<option value="">请选择区/县</option>
</select>
&nbsp;&nbsp;
<!-- href="javascript:void(0)"-->
#if($shiro.hasPermission("qy:address:view"))
<a href="javascript:void(0)" class="btn btn-primary search">搜索</a>
#end
</div>
<!-- #if($shiro.hasPermission("qy:address:edit"))-->
<!-- <a href="#springUrl('/a/address/form')" class="btn btn-primary">新增</a>-->
<!-- <a href="#springUrl('/a/address/exportExcel')" class="btn btn-primary">导出</a>-->
<!-- <a onclick="importExcel();" class="btn btn-primary">导入</a>-->
<!-- #end-->
</div>
</form>
</div><!-- /.box-header -->
<div class="box-body">
<table id="table" class="table table-bordered table-striped">
<thead>
<tr>
<td hidden="true">Id
</td>
<th>openId</th>
<th>患者姓名</th>
<th>性别</th>
<th>联系方式</th>
<th>省份</th>
<th>城市</th>
<th>区/县</th>
<th>详细地址</th>
<th>操作</th>
</tr>
</thead>
<tbody id="tablebody">
</tbody>
</table>
</div><!-- /.box-body -->
</div><!-- /.box -->
</div><!-- /.col -->
</div><!-- /.row -->
</section><!-- /.content -->
</div><!-- /.content-wrapper -->
<!-- Add the sidebar's background. This div must be placed
immediately after the control sidebar -->
<div class="control-sidebar-bg"></div>
</div><!-- ./wrapper -->
<!-- jQuery 2.1.4 -->
<script src="plugins/jQuery/jQuery-2.1.4.min.js"></script>
<!-- Bootstrap 3.3.5 -->
<script src="bootstrap/js/bootstrap.min.js"></script>
<!-- DataTables -->
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables/extensions/i18n/lanauage_ch.js"></script>
<script src="plugins/datatables/dataTables.bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
<script src="plugins/datepicker/bootstrap-datepicker.js"></script>
<script src="plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
<!-- FastClick -->
<script src="plugins/fastclick/fastclick.min.js"></script>
<!--fileinput js-->
<script src="plugins\bootstrap-fileinput\fileinput.js"></script>
<script src="plugins/bootstrap-fileinput/zh.js"></script>
<script src="plugins/bootstrap-fileinput/zh2.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/app.min.js"></script>
<script type="text/javascript"
src="plugins/jquery-validation/js/jquery.validate.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="common/js/cfapp.js"></script>
<script>
let areaList = null
let listProvince = null
let listCity = null
let listRegin = null
function formatDates(now) {
var now = new Date(now);
var year = now.getFullYear();
var month = now.getMonth() + 1;
var date = now.getDate();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
return year + "-" + month + "-" + date + " " + hour + ":"
+ minute + ":" + second;
}
function seachTable() {
var sSource = "#springUrl('/a/address/listData')";
var aoData = {
iDisplayStart: 1,
iDosplayLength: 10
}
var retrieveData = function (sSource, aoData, fnCallback) {
$("#seachTableForm input,select").each(function () {
var params = {
name: $(this).attr("name"),
value: $(this).val()
};
aoData.push(params);
})
$.ajax({
"type": "GET",
"url": sSource,
"dataType": "json",
"data": aoData, //以json格式传递
"success": fnCallback
});
};
$('#table').DataTable({
"lengthChange": false,
"searching": false,
"ordering": false,
"bFiltered": false,
"bStateSave": true, // save datatable state(pagination, sort, etc) in cookie.
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": sSource,
"fnServerData": retrieveData,
"pagingType": "full_numbers",
"aoColumns": [
{
"mData": "id"
},
{
"mData": "openId"
},
{
"mData": "addressName"
},
{
"mData": "sex"
},
{
"mData": "phone"
},
{
"mData": "provinceName"
},
{
"mData": "cityName"
},
{
"mData": "countyName"
},
{
"mData": "address"
}
,
{
"mData": "id"
}],
"aoColumnDefs": [
{ // set default column settings
'visible': false,
'targets': [0]
},
{
"aTargets": [1],
"mData": "openId",
"mRender": function (a, b, c, d) {
return a;
}
},
{
"aTargets": [2],
"mData": "addressName",
"mRender": function (a, b, c, d) {
return a;
}
},
{
"aTargets": [3],
"mData": "sex",
"mRender": function (a, b, c, d) {
if (a == '0') {
return "女";
} else {
return "男";
}
}
},
{
"aTargets": [4],
"mData": "phone",
"mRender": function (a, b, c, d) {
return a;
}
},
{
"aTargets": [5],
"mData": "provinceName",
"mRender": function (a, b, c, d) {
return a;
}
},
{
"aTargets": [6],
"mData": "cityName",
"mRender": function (a, b, c, d) {
return a;
}
},
{
"aTargets": [7],
"mData": "countyName",
"mRender": function (a, b, c, d) {
return a;
}
},
{
"aTargets": [8],
"mData": "address",
"mRender": function (a, b, c, d) {
return a;
}
},
{
"aTargets": [9],
"mData": "id",
"mRender": function (a, b, c, d) {
var html = '#if($shiro.hasPermission("qy:wxQrcode:edit"))';
html += '<div class="btn-group">\n' +
'<button type="button" class="btn btn-success btn-flat">操作</button>\n' +
'<button type="button" class="btn btn-success btn-flat dropdown-toggle" data-toggle="dropdown">\n' +
' <span class="caret"></span>\n' +
' <span class="sr-only">Toggle Dropdown</span>\n' +
'</button>\n' +
'<ul class="dropdown-menu" role="menu">\n';
html += '<li><a href="#springUrl("/a/address/form?id=' + a + '")">查看</a></li>';
html += '<li><a href="javascript:removeData(' + a + ')">删除</a></li>';
html += '</ul>';
html += '#end';
return html;
}
}
]
});
}
// return '<a href="#springUrl("/a/address/form?id=' + c.id + '")" data-id="' + c.id + '" data-action="view">' + formatDates(a, "yyyy-MM-dd HH:mm:ss");
// +'</a>';
jQuery(document).ready(function () {
var url = "#springUrl('/a/address/listArea')"
$.ajax({
url: url,
type: "GET",
success: function (data) {
console.log(data)
areaList = data
listProvince = data.filter(x => x.cityType == 1)
var province = document.querySelector('#province') //querySelector获取id="province"的元素
for (index in listProvince) {
var op = new Option(listProvince[index].areaName, listProvince[index].areaId, false, false)
//将循环出来的元素追加到province下拉框里
province.options[province.length] = op
}
}
});
seachTable();
$('.datepicker').datepicker({
show: true,
format: 'yyyy-mm-dd',
autoclose: true,
language: 'zh-CN',
todayBtn: 'linked',
clearBtn: 'linked'
});
$('.search').click(function () {
$("#table").dataTable().fnClearTable();
});
});
Cfapp.init();
function getCityList(areaId) {
listCity = areaList.filter(x => x.affiliationareaId == areaId && x.cityType == 2)
$("#city").empty();
$("#county").empty();
var city = document.querySelector('#city')
for (index in listCity) {
var op = new Option(listCity[index].areaName, listCity[index].areaId, false, false)
//将循环出来的元素追加到province下拉框里
city.options[city.length] = op
}
if (listCity.length==1){
getReginList(listCity[0].areaId);
}
getReginList($("#city").val())
}
function getReginList(areaId) {
listRegin = areaList.filter(x => x.affiliationareaId == areaId && x.cityType == 3)
$("#county").empty();
var county = document.querySelector('#county')
for (index in listRegin) {
var op = new Option(listRegin[index].areaName, listRegin[index].areaId, false, false)
//将循环出来的元素追加到province下拉框里,第一次训话length=1,第二次循环length=2
county.options[county.length] = op
}
}
function removeData(data) {
Cfapp.confirm({
message: "确定要删除吗",
btnoktext: "确定",
btncanceltext: "取消",
success: function () {
$.ajax({
type: "POST",
url: "#springUrl('/a/address/delete')",
data: {id: data},
dataType: "json",
success: function (data) {
if (data.errorNo == 0) {
Cfapp.alert({
message: "删除成功",
btntext: "确定",
success: function () {
location.href = "#springUrl('/a/address/list')";
}
});
}
},
error: function () {
}
})
},
cancel: function () {
$(".modal-backdrop").fadeOut();
}
});
}
// function importExcel() {
// var templateExcelUrl = "#springUrl('/a/address/templateExcel')";
// var importExcelUrl = "#springUrl('/a/address/importExcel')";
// Cfapp.importExcel({
// title: '收货地址管理导入',
// importurl: importExcelUrl,
// templateurl: templateExcelUrl,
// cancel: function () {
//
// },
// success: function () {
//
// }
// });
// }
</script>
</body>
</html>
......@@ -86,7 +86,7 @@
<input type="text" style="display: none" name="_csrf_header" value="${_csrf.headerName}"/>
<div class="box-footer">
<input class="btn btn-primary" id="save" value="保存" type="submit">
<input class="btn btn-primary" id="save" value="保存" type="button">
<a href="#springUrl('/a/fanssgroup/list')" class="btn btn-default">取消</a>
</div>
</form>
......@@ -133,7 +133,7 @@
recdTypeAdd.init();
});
var recdTypeAdd = function () {
var initForm = function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment