添加地址管理
This commit is contained in:
@ -0,0 +1,104 @@
|
|||||||
|
package com.ruoyi.carpool.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.carpool.domain.PAddress;
|
||||||
|
import com.ruoyi.carpool.service.IPAddressService;
|
||||||
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地址详情Controller
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-12-18
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/carpool/address")
|
||||||
|
public class PAddressController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private IPAddressService pAddressService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询地址详情列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('address:address:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(PAddress pAddress)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<PAddress> list = pAddressService.selectPAddressList(pAddress);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出地址详情列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('address:address:export')")
|
||||||
|
@Log(title = "地址详情", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, PAddress pAddress)
|
||||||
|
{
|
||||||
|
List<PAddress> list = pAddressService.selectPAddressList(pAddress);
|
||||||
|
ExcelUtil<PAddress> util = new ExcelUtil<PAddress>(PAddress.class);
|
||||||
|
util.exportExcel(response, list, "地址详情数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取地址详情详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('address:address:query')")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||||
|
{
|
||||||
|
return AjaxResult.success(pAddressService.selectPAddressById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增地址详情
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('address:address:add')")
|
||||||
|
@Log(title = "地址详情", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@RequestBody PAddress pAddress)
|
||||||
|
{
|
||||||
|
return toAjax(pAddressService.insertPAddress(pAddress));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改地址详情
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('address:address:edit')")
|
||||||
|
@Log(title = "地址详情", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@RequestBody PAddress pAddress)
|
||||||
|
{
|
||||||
|
return toAjax(pAddressService.updatePAddress(pAddress));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除地址详情
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('address:address:remove')")
|
||||||
|
@Log(title = "地址详情", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] ids)
|
||||||
|
{
|
||||||
|
return toAjax(pAddressService.deletePAddressByIds(ids));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
package com.ruoyi.carpool.domain;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import com.ruoyi.common.annotation.Excel;
|
||||||
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地址详情对象 p_address
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-12-18
|
||||||
|
*/
|
||||||
|
public class PAddress extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 自增ID */
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 地址 */
|
||||||
|
@Excel(name = "地址")
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
/** 地址类型,1:出发地;2:目的地 */
|
||||||
|
@Excel(name = "地址类型,1:出发地;2:目的地")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
public void setId(Long id)
|
||||||
|
{
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setAddress(String address)
|
||||||
|
{
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddress()
|
||||||
|
{
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
public void setType(String type)
|
||||||
|
{
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType()
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("id", getId())
|
||||||
|
.append("address", getAddress())
|
||||||
|
.append("type", getType())
|
||||||
|
.append("createBy", getCreateBy())
|
||||||
|
.append("createTime", getCreateTime())
|
||||||
|
.append("updateBy", getUpdateBy())
|
||||||
|
.append("updateTime", getUpdateTime())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
package com.ruoyi.carpool.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.ruoyi.carpool.domain.PAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地址详情Mapper接口
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-12-18
|
||||||
|
*/
|
||||||
|
public interface PAddressMapper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询地址详情
|
||||||
|
*
|
||||||
|
* @param id 地址详情主键
|
||||||
|
* @return 地址详情
|
||||||
|
*/
|
||||||
|
public PAddress selectPAddressById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询地址详情列表
|
||||||
|
*
|
||||||
|
* @param pAddress 地址详情
|
||||||
|
* @return 地址详情集合
|
||||||
|
*/
|
||||||
|
public List<PAddress> selectPAddressList(PAddress pAddress);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增地址详情
|
||||||
|
*
|
||||||
|
* @param pAddress 地址详情
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertPAddress(PAddress pAddress);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改地址详情
|
||||||
|
*
|
||||||
|
* @param pAddress 地址详情
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updatePAddress(PAddress pAddress);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除地址详情
|
||||||
|
*
|
||||||
|
* @param id 地址详情主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deletePAddressById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除地址详情
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deletePAddressByIds(Long[] ids);
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
package com.ruoyi.carpool.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.ruoyi.carpool.domain.PAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地址详情Service接口
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-12-18
|
||||||
|
*/
|
||||||
|
public interface IPAddressService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询地址详情
|
||||||
|
*
|
||||||
|
* @param id 地址详情主键
|
||||||
|
* @return 地址详情
|
||||||
|
*/
|
||||||
|
public PAddress selectPAddressById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询地址详情列表
|
||||||
|
*
|
||||||
|
* @param pAddress 地址详情
|
||||||
|
* @return 地址详情集合
|
||||||
|
*/
|
||||||
|
public List<PAddress> selectPAddressList(PAddress pAddress);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增地址详情
|
||||||
|
*
|
||||||
|
* @param pAddress 地址详情
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertPAddress(PAddress pAddress);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改地址详情
|
||||||
|
*
|
||||||
|
* @param pAddress 地址详情
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updatePAddress(PAddress pAddress);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除地址详情
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的地址详情主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deletePAddressByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除地址详情信息
|
||||||
|
*
|
||||||
|
* @param id 地址详情主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deletePAddressById(Long id);
|
||||||
|
}
|
@ -0,0 +1,96 @@
|
|||||||
|
package com.ruoyi.carpool.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.ruoyi.carpool.mapper.PAddressMapper;
|
||||||
|
import com.ruoyi.carpool.domain.PAddress;
|
||||||
|
import com.ruoyi.carpool.service.IPAddressService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地址详情Service业务层处理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-12-18
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class PAddressServiceImpl implements IPAddressService
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private PAddressMapper pAddressMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询地址详情
|
||||||
|
*
|
||||||
|
* @param id 地址详情主键
|
||||||
|
* @return 地址详情
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PAddress selectPAddressById(Long id)
|
||||||
|
{
|
||||||
|
return pAddressMapper.selectPAddressById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询地址详情列表
|
||||||
|
*
|
||||||
|
* @param pAddress 地址详情
|
||||||
|
* @return 地址详情
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<PAddress> selectPAddressList(PAddress pAddress)
|
||||||
|
{
|
||||||
|
return pAddressMapper.selectPAddressList(pAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增地址详情
|
||||||
|
*
|
||||||
|
* @param pAddress 地址详情
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertPAddress(PAddress pAddress)
|
||||||
|
{
|
||||||
|
pAddress.setCreateTime(DateUtils.getNowDate());
|
||||||
|
return pAddressMapper.insertPAddress(pAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改地址详情
|
||||||
|
*
|
||||||
|
* @param pAddress 地址详情
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updatePAddress(PAddress pAddress)
|
||||||
|
{
|
||||||
|
pAddress.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
return pAddressMapper.updatePAddress(pAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除地址详情
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的地址详情主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deletePAddressByIds(Long[] ids)
|
||||||
|
{
|
||||||
|
return pAddressMapper.deletePAddressByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除地址详情信息
|
||||||
|
*
|
||||||
|
* @param id 地址详情主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deletePAddressById(Long id)
|
||||||
|
{
|
||||||
|
return pAddressMapper.deletePAddressById(id);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
<?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.ruoyi.carpool.mapper.PAddressMapper">
|
||||||
|
|
||||||
|
<resultMap type="PAddress" id="PAddressResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="address" column="address" />
|
||||||
|
<result property="type" column="type" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectPAddressVo">
|
||||||
|
select id, address, type, create_by, create_time, update_by, update_time from p_address
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectPAddressList" parameterType="PAddress" resultMap="PAddressResult">
|
||||||
|
<include refid="selectPAddressVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="address != null and address != ''"> and address = #{address}</if>
|
||||||
|
<if test="type != null and type != ''"> and type = #{type}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectPAddressById" parameterType="Long" resultMap="PAddressResult">
|
||||||
|
<include refid="selectPAddressVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertPAddress" parameterType="PAddress" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into p_address
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="address != null">address,</if>
|
||||||
|
<if test="type != null">type,</if>
|
||||||
|
<if test="createBy != null">create_by,</if>
|
||||||
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="updateBy != null">update_by,</if>
|
||||||
|
<if test="updateTime != null">update_time,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="address != null">#{address},</if>
|
||||||
|
<if test="type != null">#{type},</if>
|
||||||
|
<if test="createBy != null">#{createBy},</if>
|
||||||
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updatePAddress" parameterType="PAddress">
|
||||||
|
update p_address
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="address != null">address = #{address},</if>
|
||||||
|
<if test="type != null">type = #{type},</if>
|
||||||
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deletePAddressById" parameterType="Long">
|
||||||
|
delete from p_address where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deletePAddressByIds" parameterType="String">
|
||||||
|
delete from p_address where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
53
ruoyi-ui/src/api/carpool/address.js
Normal file
53
ruoyi-ui/src/api/carpool/address.js
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询地址详情列表
|
||||||
|
export function listAddress(query) {
|
||||||
|
return request({
|
||||||
|
url: '/carpool/address/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询地址详情详细
|
||||||
|
export function getAddress(id) {
|
||||||
|
return request({
|
||||||
|
url: '/carpool/address/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增地址详情
|
||||||
|
export function addAddress(data) {
|
||||||
|
return request({
|
||||||
|
url: '/carpool/address',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改地址详情
|
||||||
|
export function updateAddress(data) {
|
||||||
|
return request({
|
||||||
|
url: '/carpool/address',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除地址详情
|
||||||
|
export function delAddress(id) {
|
||||||
|
return request({
|
||||||
|
url: '/carpool/address/' + id,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出地址详情
|
||||||
|
export function exportAddress(query) {
|
||||||
|
return request({
|
||||||
|
url: '/carpool/address/export',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
268
ruoyi-ui/src/views/carpool/address/index.vue
Normal file
268
ruoyi-ui/src/views/carpool/address/index.vue
Normal file
@ -0,0 +1,268 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
<el-form-item label="地址" prop="address">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.address"
|
||||||
|
placeholder="请输入地址"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="地址类型" prop="type">
|
||||||
|
<el-select v-model="queryParams.type" placeholder="请选择地址类型" clearable size="small">
|
||||||
|
<el-option v-for="dict in dict.type.carpool_address_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
icon="el-icon-plus"
|
||||||
|
size="mini"
|
||||||
|
@click="handleAdd"
|
||||||
|
v-hasPermi="['address:address:add']"
|
||||||
|
>新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
icon="el-icon-edit"
|
||||||
|
size="mini"
|
||||||
|
:disabled="single"
|
||||||
|
@click="handleUpdate"
|
||||||
|
v-hasPermi="['address:address:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
icon="el-icon-delete"
|
||||||
|
size="mini"
|
||||||
|
:disabled="multiple"
|
||||||
|
@click="handleDelete"
|
||||||
|
v-hasPermi="['address:address:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
plain
|
||||||
|
icon="el-icon-download"
|
||||||
|
size="mini"
|
||||||
|
@click="handleExport"
|
||||||
|
v-hasPermi="['address:address:export']"
|
||||||
|
>导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="addressList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
<!-- <el-table-column label="自增ID" align="center" prop="id" />-->
|
||||||
|
<el-table-column label="地址" align="center" prop="address" />
|
||||||
|
<el-table-column label="地址类型" align="center" prop="type">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<dict-tag :options="dict.type.carpool_address_type" :value="scope.row.type" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
@click="handleUpdate(scope.row)"
|
||||||
|
v-hasPermi="['address:address:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['address:address:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination
|
||||||
|
v-show="total>0"
|
||||||
|
:total="total"
|
||||||
|
:page.sync="queryParams.pageNum"
|
||||||
|
:limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 添加或修改地址详情对话框 -->
|
||||||
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="地址" prop="address">
|
||||||
|
<el-input v-model="form.address" placeholder="请输入地址" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="地址类型" prop="type">
|
||||||
|
<el-select v-model="form.type" placeholder="请选择地址类型">
|
||||||
|
<el-option v-for="dict in dict.type.carpool_address_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { listAddress, getAddress, delAddress, addAddress, updateAddress } from "@/api/carpool/address";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "Address",
|
||||||
|
dicts: ["carpool_address_type"],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 地址详情表格数据
|
||||||
|
addressList: [],
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
address: null,
|
||||||
|
type: null,
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
// 表单校验
|
||||||
|
rules: {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询地址详情列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
listAddress(this.queryParams).then(response => {
|
||||||
|
this.addressList = response.rows;
|
||||||
|
this.total = response.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancel() {
|
||||||
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
id: null,
|
||||||
|
address: null,
|
||||||
|
type: null,
|
||||||
|
createBy: null,
|
||||||
|
createTime: null,
|
||||||
|
updateBy: null,
|
||||||
|
updateTime: null
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNum = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.ids = selection.map(item => item.id)
|
||||||
|
this.single = selection.length!==1
|
||||||
|
this.multiple = !selection.length
|
||||||
|
},
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd() {
|
||||||
|
this.reset();
|
||||||
|
this.open = true;
|
||||||
|
this.title = "添加地址详情";
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate(row) {
|
||||||
|
this.reset();
|
||||||
|
const id = row.id || this.ids
|
||||||
|
getAddress(id).then(response => {
|
||||||
|
this.form = response.data;
|
||||||
|
this.open = true;
|
||||||
|
this.title = "修改地址详情";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm() {
|
||||||
|
this.$refs["form"].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
if (this.form.id != null) {
|
||||||
|
updateAddress(this.form).then(response => {
|
||||||
|
this.$modal.msgSuccess("修改成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
addAddress(this.form).then(response => {
|
||||||
|
this.$modal.msgSuccess("新增成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
const ids = row.id || this.ids;
|
||||||
|
this.$modal.confirm('是否确认删除地址详情编号为"' + ids + '"的数据项?').then(function() {
|
||||||
|
return delAddress(ids);
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.$modal.msgSuccess("删除成功");
|
||||||
|
}).catch(() => {});
|
||||||
|
},
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
this.download('address/address/export', {
|
||||||
|
...this.queryParams
|
||||||
|
}, `address_${new Date().getTime()}.xlsx`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
Reference in New Issue
Block a user