202505301539

This commit is contained in:
张潘 2025-05-30 15:39:17 +08:00
parent 487ee3663c
commit 7624d92bc6
13 changed files with 661 additions and 544 deletions

View File

@ -1,6 +1,9 @@
package com.ruoyi.system.controller; package com.ruoyi.system.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -20,12 +23,13 @@ import com.ruoyi.system.domain.DiyCity;
import com.ruoyi.system.service.IDiyCityService; import com.ruoyi.system.service.IDiyCityService;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import java.util.Objects;
/** /**
* 自定义地区Controller * 自定义地区Controller
* *
* @author ruoyi * @author ruoyi
* @date 2025-05-13 * @date 2025-05-30
*/ */
@RestController @RestController
@RequestMapping("/system/DiyCity") @RequestMapping("/system/DiyCity")
@ -45,7 +49,44 @@ public class DiyCityController extends BaseController
List<DiyCity> list = diyCityService.selectDiyCityList(diyCity); List<DiyCity> list = diyCityService.selectDiyCityList(diyCity);
return getDataTable(list); return getDataTable(list);
} }
/**
* 获取自定义地区树形结构数据
*/
@PreAuthorize("@ss.hasPermi('system:DiyCity:query')")
@GetMapping("/getTreeData")
public AjaxResult getTreeData() {
List<DiyCity> list = diyCityService.selectDiyCityList(new DiyCity());
List<Map<String, Object>> rootList = new ArrayList<>();
for (DiyCity city : list) {
Long parentId = city.getParentId();
Long id = Long.valueOf(city.getId());
// 一级节点
if (parentId == null || parentId == 0L) {
Map<String, Object> node = toMap(city);
// 组装children
List<Map<String, Object>> children = new ArrayList<>();
for (DiyCity child : list) {
Long childParentId = child.getParentId();
if (id != null && Objects.equals(id, childParentId)) {
children.add(toMap(child));
}
}
node.put("children", children);
rootList.add(node);
}
}
return success(rootList);
}
private Map<String, Object> toMap(DiyCity city) {
Map<String, Object> map = new HashMap<>();
map.put("id", city.getId());
map.put("label", city.getTitle());
map.put("parentId", city.getParentId());
// 其他字段按需添加
return map;
}
/** /**
* 导出自定义地区列表 * 导出自定义地区列表
*/ */
@ -96,9 +137,122 @@ public class DiyCityController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('system:DiyCity:remove')") @PreAuthorize("@ss.hasPermi('system:DiyCity:remove')")
@Log(title = "自定义地区", businessType = BusinessType.DELETE) @Log(title = "自定义地区", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids) public AjaxResult remove(@PathVariable Integer[] ids)
{ {
return toAjax(diyCityService.deleteDiyCityByIds(ids)); return toAjax(diyCityService.deleteDiyCityByIds(ids));
} }
} }
//package com.ruoyi.system.controller;
//
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//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.system.domain.DiyCity;
//import com.ruoyi.system.service.IDiyCityService;
//import com.ruoyi.common.utils.poi.ExcelUtil;
//import com.ruoyi.common.core.page.TableDataInfo;
//
///**
// * 自定义地区Controller
// *
// * @author ruoyi
// * @date 2025-05-13
// */
//@RestController
//@RequestMapping("/system/DiyCity")
//public class DiyCityController extends BaseController
//{
// @Autowired
// private IDiyCityService diyCityService;
//
// /**
// * 查询自定义地区列表
// */
// @PreAuthorize("@ss.hasPermi('system:DiyCity:list')")
// @GetMapping("/list")
// public TableDataInfo list(DiyCity diyCity)
// {
// startPage();
// List<DiyCity> list = diyCityService.selectDiyCityList(diyCity);
// return getDataTable(list);
// }
//
//
//
// /**
// * 导出自定义地区列表
// */
// @PreAuthorize("@ss.hasPermi('system:DiyCity:export')")
// @Log(title = "自定义地区", businessType = BusinessType.EXPORT)
// @PostMapping("/export")
// public void export(HttpServletResponse response, DiyCity diyCity)
// {
// List<DiyCity> list = diyCityService.selectDiyCityList(diyCity);
// ExcelUtil<DiyCity> util = new ExcelUtil<DiyCity>(DiyCity.class);
// util.exportExcel(response, list, "自定义地区数据");
// }
//
// /**
// * 获取自定义地区详细信息
// */
// @PreAuthorize("@ss.hasPermi('system:DiyCity:query')")
// @GetMapping(value = "/{id}")
// public AjaxResult getInfo(@PathVariable("id") Integer id)
// {
// return success(diyCityService.selectDiyCityById(id));
// }
//
// /**
// * 新增自定义地区
// */
// @PreAuthorize("@ss.hasPermi('system:DiyCity:add')")
// @Log(title = "自定义地区", businessType = BusinessType.INSERT)
// @PostMapping
// public AjaxResult add(@RequestBody DiyCity diyCity)
// {
// return toAjax(diyCityService.insertDiyCity(diyCity));
// }
//
// /**
// * 修改自定义地区
// */
// @PreAuthorize("@ss.hasPermi('system:DiyCity:edit')")
// @Log(title = "自定义地区", businessType = BusinessType.UPDATE)
// @PutMapping
// public AjaxResult edit(@RequestBody DiyCity diyCity)
// {
// return toAjax(diyCityService.updateDiyCity(diyCity));
// }
//
// /**
// * 删除自定义地区
// */
// @PreAuthorize("@ss.hasPermi('system:DiyCity:remove')")
// @Log(title = "自定义地区", businessType = BusinessType.DELETE)
// @DeleteMapping("/{ids}")
// public AjaxResult remove(@PathVariable Integer[] ids)
// {
// return toAjax(diyCityService.deleteDiyCityByIds(ids));
// }
//}

View File

@ -1,7 +1,6 @@
package com.ruoyi.system.domain; package com.ruoyi.system.domain;
import java.util.Date; import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
@ -12,7 +11,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
* 自定义地区对象 diy_city * 自定义地区对象 diy_city
* *
* @author ruoyi * @author ruoyi
* @date 2025-05-13 * @date 2025-05-30
*/ */
public class DiyCity extends BaseEntity public class DiyCity extends BaseEntity
{ {
@ -61,8 +60,6 @@ public class DiyCity extends BaseEntity
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Date updatedAt; private Date updatedAt;
private List<DiyCity> children;
public void setId(Integer id) public void setId(Integer id)
{ {
this.id = id; this.id = id;
@ -173,28 +170,20 @@ public class DiyCity extends BaseEntity
return updatedAt; return updatedAt;
} }
public List<DiyCity> getChildren() {
return children;
}
public void setChildren(List<DiyCity> children) {
this.children = children;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId()) .append("id", getId())
.append("title", getTitle()) .append("title", getTitle())
.append("parentId", getParentId()) .append("parentId", getParentId())
.append("order", getOrder()) .append("order", getOrder())
.append("lat", getLat()) .append("lat", getLat())
.append("lng", getLng()) .append("lng", getLng())
.append("provinceId", getProvinceId()) .append("provinceId", getProvinceId())
.append("cityId", getCityId()) .append("cityId", getCityId())
.append("districtId", getDistrictId()) .append("districtId", getDistrictId())
.append("createdAt", getCreatedAt()) .append("createdAt", getCreatedAt())
.append("updatedAt", getUpdatedAt()) .append("updatedAt", getUpdatedAt())
.toString(); .toString();
} }
} }

View File

@ -7,7 +7,7 @@ import com.ruoyi.system.domain.DiyCity;
* 自定义地区Mapper接口 * 自定义地区Mapper接口
* *
* @author ruoyi * @author ruoyi
* @date 2025-05-13 * @date 2025-05-30
*/ */
public interface DiyCityMapper public interface DiyCityMapper
{ {

View File

@ -7,7 +7,7 @@ import com.ruoyi.system.domain.DiyCity;
* 自定义地区Service接口 * 自定义地区Service接口
* *
* @author ruoyi * @author ruoyi
* @date 2025-05-13 * @date 2025-05-30
*/ */
public interface IDiyCityService public interface IDiyCityService
{ {

View File

@ -1,9 +1,6 @@
package com.ruoyi.system.service.impl; package com.ruoyi.system.service.impl;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.ArrayList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.DiyCityMapper; import com.ruoyi.system.mapper.DiyCityMapper;
@ -14,7 +11,7 @@ import com.ruoyi.system.service.IDiyCityService;
* 自定义地区Service业务层处理 * 自定义地区Service业务层处理
* *
* @author ruoyi * @author ruoyi
* @date 2025-05-13 * @date 2025-05-30
*/ */
@Service @Service
public class DiyCityServiceImpl implements IDiyCityService public class DiyCityServiceImpl implements IDiyCityService
@ -43,31 +40,7 @@ public class DiyCityServiceImpl implements IDiyCityService
@Override @Override
public List<DiyCity> selectDiyCityList(DiyCity diyCity) public List<DiyCity> selectDiyCityList(DiyCity diyCity)
{ {
List<DiyCity> cities = diyCityMapper.selectDiyCityList(diyCity); return diyCityMapper.selectDiyCityList(diyCity);
return buildTree(cities);
}
private List<DiyCity> buildTree(List<DiyCity> cities) {
Map<Integer, DiyCity> map = new HashMap<>();
List<DiyCity> roots = new ArrayList<>();
for (DiyCity city : cities) {
map.put(city.getId(), city);
city.setChildren(new ArrayList<>());
}
for (DiyCity city : cities) {
if (city.getParentId() == null) {
roots.add(city);
} else {
DiyCity parent = map.get(city.getParentId());
if (parent != null) {
parent.getChildren().add(city);
}
}
}
return roots;
} }
/** /**

View File

@ -36,7 +36,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createdAt != null "> and created_at = #{createdAt}</if> <if test="createdAt != null "> and created_at = #{createdAt}</if>
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if> <if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
</where> </where>
order by id desc
</select> </select>
<select id="selectDiyCityById" parameterType="Integer" resultMap="DiyCityResult"> <select id="selectDiyCityById" parameterType="Integer" resultMap="DiyCityResult">
@ -55,8 +54,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="provinceId != null">province_id,</if> <if test="provinceId != null">province_id,</if>
<if test="cityId != null">city_id,</if> <if test="cityId != null">city_id,</if>
<if test="districtId != null">district_id,</if> <if test="districtId != null">district_id,</if>
created_at, <if test="createdAt != null">created_at,</if>
updated_at <if test="updatedAt != null">updated_at,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="title != null and title != ''">#{title},</if> <if test="title != null and title != ''">#{title},</if>
@ -67,8 +66,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="provinceId != null">#{provinceId},</if> <if test="provinceId != null">#{provinceId},</if>
<if test="cityId != null">#{cityId},</if> <if test="cityId != null">#{cityId},</if>
<if test="districtId != null">#{districtId},</if> <if test="districtId != null">#{districtId},</if>
NOW(), <if test="createdAt != null">#{createdAt},</if>
NOW() <if test="updatedAt != null">#{updatedAt},</if>
</trim> </trim>
</insert> </insert>
@ -83,7 +82,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="provinceId != null">province_id = #{provinceId},</if> <if test="provinceId != null">province_id = #{provinceId},</if>
<if test="cityId != null">city_id = #{cityId},</if> <if test="cityId != null">city_id = #{cityId},</if>
<if test="districtId != null">district_id = #{districtId},</if> <if test="districtId != null">district_id = #{districtId},</if>
updated_at=NOW() <if test="createdAt != null">created_at = #{createdAt},</if>
<if test="updatedAt != null">updated_at = #{updatedAt},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>

View File

@ -16,6 +16,15 @@ export function getDiyCity(id) {
method: 'get' method: 'get'
}) })
} }
// 查询自定义地区详细
export function getTreeDataList() {
return request({
url: '/system/DiyCity/getTreeData',
method: 'get'
})
}
// 新增自定义地区 // 新增自定义地区
export function addDiyCity(data) { export function addDiyCity(data) {

View File

@ -48,3 +48,11 @@ export function delWorkerApply(id) {
method: 'delete' method: 'delete'
}) })
} }
// 获取地区列表
export function selectAreaList(pid) {
return request({
url: '/system/area/selectAreaList/' + pid,
method: 'get'
})
}

View File

@ -1,246 +1,72 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <div class="header-bar">
<el-form-item label="名称" prop="title"> <el-button type="primary" size="small" @click="expandAll">展开</el-button>
<el-input <el-button type="primary" size="small" @click="collapseAll">收起</el-button>
v-model="queryParams.title" <el-button size="small" @click="refreshTree">刷新</el-button>
placeholder="请输入名称" <el-button type="primary" size="small" icon="el-icon-plus" @click="handleAdd" v-hasPermi="['system:DiyCity:add']">新增</el-button>
clearable </div>
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="父级ID" prop="parentId">
<el-input
v-model="queryParams.parentId"
placeholder="请输入父级ID"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="排序" prop="order">
<el-input
v-model="queryParams.order"
placeholder="请输入排序"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="纬度" prop="lat">
<el-input
v-model="queryParams.lat"
placeholder="请输入纬度"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="经度" prop="lng">
<el-input
v-model="queryParams.lng"
placeholder="请输入经度"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="省id" prop="provinceId">
<el-input
v-model="queryParams.provinceId"
placeholder="请输入省id"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="市" prop="cityId">
<el-input
v-model="queryParams.cityId"
placeholder="请输入市"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="区" prop="districtId">
<el-input
v-model="queryParams.districtId"
placeholder="请输入区"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="${comment}" prop="createdAt">
<el-date-picker clearable
v-model="queryParams.createdAt"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择${comment}">
</el-date-picker>
</el-form-item>
<el-form-item label="${comment}" prop="updatedAt">
<el-date-picker clearable
v-model="queryParams.updatedAt"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择${comment}">
</el-date-picker>
</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="['system:DiyCity: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="['system:DiyCity: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="['system:DiyCity: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="['system:DiyCity:export']"
>导出</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-expand"
size="mini"
@click="expandAll"
>展开</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-fold"
size="mini"
@click="collapseAll"
>收起</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-tree <el-tree
:data="DiyCityList"
:props="defaultProps"
node-key="id"
ref="tree" ref="tree"
highlight-current :data="treeDataList"
@node-click="handleNodeClick" node-key="id"
:expand-on-click-node="false" :default-expanded-keys="expandedKeys"
> :default-expand-all="true">
<span slot-scope="{ data }"> <template #default="{ data }">
{{ data.title }} <span>{{ data.id }} - {{ data.label }}</span>
<el-button </template>
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(data)"
v-hasPermi="['system:DiyCity:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(data)"
v-hasPermi="['system:DiyCity:remove']"
>删除</el-button>
</span>
</el-tree> </el-tree>
<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-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="父级" prop="parentId">
<el-select v-model="form.parentId" placeholder="父级" filterable clearable style="width: 100%">
<el-option v-for="item in parentOptions" :key="item.id" :label="item.title" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="名称" prop="title"> <el-form-item label="名称" prop="title">
<el-input v-model="form.title" placeholder="请输入名称" /> <el-input v-model="form.title" placeholder="请输入名称" />
</el-form-item> </el-form-item>
<el-form-item label="父级ID" prop="parentId"> <el-form-item label="地址">
<el-input v-model="form.parentId" placeholder="请输入父级ID" /> <el-input
v-model="searchAddress"
placeholder="请输入地址"
style="width: 200px; margin-right: 8px;"
@keyup.enter.native="searchMapAddress"
/>
<el-button icon="el-icon-search" @click="searchMapAddress"></el-button>
<el-input
v-model="latlng"
placeholder="经纬度"
style="width: 220px; margin-left: 8px;"
readonly
/>
</el-form-item> </el-form-item>
<div id="map" style="width: 100%; height: 250px; margin-bottom: 16px;"></div>
<el-form-item label="排序" prop="order"> <el-form-item label="排序" prop="order">
<el-input v-model="form.order" placeholder="请输入排序" /> <div class="sort-input">
</el-form-item> <el-button icon="el-icon-minus" @click="decreaseOrder" size="small"></el-button>
<el-form-item label="纬度" prop="lat"> <el-input-number v-model="form.order" :min="0" :controls="false" style="width: 100px; text-align: center;" />
<el-input v-model="form.lat" placeholder="请输入纬度" /> <el-button icon="el-icon-plus" @click="increaseOrder" size="small"></el-button>
</el-form-item> </div>
<el-form-item label="经度" prop="lng">
<el-input v-model="form.lng" placeholder="请输入经度" />
</el-form-item>
<el-form-item label="省id" prop="provinceId">
<el-input v-model="form.provinceId" placeholder="请输入省id" />
</el-form-item>
<el-form-item label="市" prop="cityId">
<el-input v-model="form.cityId" placeholder="请输入市" />
</el-form-item>
<el-form-item label="区" prop="districtId">
<el-input v-model="form.districtId" placeholder="请输入区" />
</el-form-item>
<el-form-item label="${comment}" prop="createdAt">
<el-date-picker clearable
v-model="form.createdAt"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择${comment}">
</el-date-picker>
</el-form-item>
<el-form-item label="${comment}" prop="updatedAt">
<el-date-picker clearable
v-model="form.updatedAt"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择${comment}">
</el-date-picker>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div class="dialog-footer custom-footer">
<el-button type="primary" @click="submitForm"> </el-button> <el-button @click="resetForm">重置</el-button>
<el-button @click="cancel"> </el-button> <div class="footer-right">
<el-checkbox v-model="continueEdit">继续编辑</el-checkbox>
<el-checkbox v-model="continueCreate">继续创建</el-checkbox>
<el-checkbox v-model="viewAfter">查看</el-checkbox>
<el-button type="primary" @click="submitForm">提交</el-button>
</div>
</div> </div>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { listDiyCity, getDiyCity, delDiyCity, addDiyCity, updateDiyCity } from "@/api/system/DiyCity" import { listDiyCity, getDiyCity, delDiyCity, addDiyCity, updateDiyCity,getTreeDataList } from "@/api/system/DiyCity"
export default { export default {
name: "DiyCity", name: "DiyCity",
@ -258,6 +84,11 @@ export default {
showSearch: true, showSearch: true,
// //
total: 0, total: 0,
latlng:"",
treeDataList: [],
expandedKeys: [],
searchAddress: '',
// //
DiyCityList: [], DiyCityList: [],
// //
@ -275,6 +106,7 @@ export default {
lng: null, lng: null,
provinceId: null, provinceId: null,
cityId: null, cityId: null,
districtId: null, districtId: null,
createdAt: null, createdAt: null,
updatedAt: null updatedAt: null
@ -290,24 +122,31 @@ export default {
{ required: true, message: "父级ID不能为空", trigger: "blur" } { required: true, message: "父级ID不能为空", trigger: "blur" }
], ],
}, },
defaultProps: { parentOptions: [],
children: 'children', cityOptions: ['西安市', '上海市', '长沙市', '合肥市'],
label: 'title' continueEdit: false,
} continueCreate: false,
viewAfter: false,
searchKeyword: '',
amap: null,
marker: null,
geocoder: null,
} }
}, },
created() { created() {
this.getList() this.getList()
this.gettreeDataList()
this.loadParentOptions()
}, },
methods: { methods: {
/** 查询自定义地区列表 */ /** 查询自定义地区列表 */
getList() { getList() {
this.loading = true; this.loading = true
listDiyCity(this.queryParams).then(response => { listDiyCity(this.queryParams).then(response => {
this.DiyCityList = response; this.DiyCityList = response.rows
this.total = response.length; this.total = response.total
this.loading = false; this.loading = false
}); })
}, },
// //
cancel() { cancel() {
@ -341,6 +180,15 @@ export default {
this.resetForm("queryForm") this.resetForm("queryForm")
this.handleQuery() this.handleQuery()
}, },
gettreeDataList(){
getTreeDataList().then(response => {
this.treeDataList=response.data
//
this.expandedKeys = []
})
},
// //
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.id) this.ids = selection.map(item => item.id)
@ -352,6 +200,11 @@ export default {
this.reset() this.reset()
this.open = true this.open = true
this.title = "添加自定义地区" this.title = "添加自定义地区"
this.$nextTick(()=>{
this.initMap()
})
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
@ -361,6 +214,11 @@ export default {
this.form = response.data this.form = response.data
this.open = true this.open = true
this.title = "修改自定义地区" this.title = "修改自定义地区"
this.$nextTick(() => {
this.searchAddress = ''
this.latlng = this.form.longitude && this.form.latitude ? `${this.form.longitude},${this.form.latitude}` : ''
this.initMap()
})
}) })
}, },
/** 提交按钮 */ /** 提交按钮 */
@ -400,18 +258,136 @@ export default {
}, `DiyCity_${new Date().getTime()}.xlsx`) }, `DiyCity_${new Date().getTime()}.xlsx`)
}, },
expandAll() { expandAll() {
this.$refs.tree.store.nodesMap.forEach(node => { //
this.$refs.tree.store.expandNode(node, true) this.expandedKeys = this.treeDataList.map(item => item.id)
})
}, },
collapseAll() { collapseAll() {
this.$refs.tree.store.nodesMap.forEach(node => { this.expandedKeys = []
this.$refs.tree.store.collapseNode(node, true) },
refreshTree() {
this.gettreeDataList();
},
loadParentOptions() {
// listDiyCity
listDiyCity({parentId:0}).then(res => {
this.parentOptions = res.rows || []
}) })
}, },
handleNodeClick(data) { decreaseOrder() {
console.log(data) if (this.form.order > 0) {
} this.form.order--
}
},
increaseOrder() {
this.form.order++
},
resetForm() {
if (this.$refs.form) {
this.$refs.form.resetFields();
}
},
initMap() {
//
if (this.map) {
this.map.destroy();
this.map = null;
this.marker = null;
this.geocoder = null;
this.mapInited = false;
}
this.map = new AMap.Map('map', {
zoom: 16,
center: [this.form.longitude || 108.94141, this.form.latitude || 34.209883],
});
this.geocoder = new AMap.Geocoder();
// if (this.form.longitude && this.form.latitude) {
// this.setMapMarker([this.form.longitude, this.form.latitude]);
// this.map.setCenter([this.form.longitude, this.form.latitude]);
// }
this.map.on('click', (e) => {
const lnglat = [e.lnglat.lng, e.lnglat.lat];
this.setMapMarker(lnglat);
this.form.longitude = e.lnglat.lng;
this.form.latitude = e.lnglat.lat;
this.latlng = `${e.lnglat.lng},${e.lnglat.lat}`;
this.geocoder.getAddress(lnglat, (status, result) => {
// if (status === 'complete' && result.regeocode) {
// this.form.info = result.regeocode.formattedAddress;
// }
});
});
this.mapInited = true;
},
setMapMarker(lnglat) {
if (this.marker) {
this.marker.setMap(null);
}
this.marker = new AMap.Marker({
position: lnglat,
map: this.map,
});
},
searchMapAddress() {
if (!this.searchAddress) {
this.$message.warning('请输入要搜索的地址');
return;
}
if (!this.mapInited || !this.geocoder) {
this.$message.warning('地图未初始化,请稍后再试');
return;
}
this.geocoder.getLocation(this.searchAddress, (status, result) => {
if (status === 'complete' && result.geocodes.length) {
const lnglat = result.geocodes[0].location;
this.setMapMarker([lnglat.lng, lnglat.lat]);
this.map.setCenter([lnglat.lng, lnglat.lat]);
this.form.longitude = lnglat.lng;
this.form.latitude = lnglat.lat;
this.latlng = `${lnglat.lng},${lnglat.lat}`;
// this.form.info = result.geocodes[0].formattedAddress;
if ('addressName' in this.form) {
this.form.addressName = result.geocodes[0].formattedAddress;
}
if ('addressInfo' in this.form) {
this.form.addressInfo = result.geocodes[0].formattedAddress;
}
} else {
this.$message.warning('未找到该地址,请输入更详细的地址');
}
});
},
} }
} }
</script> </script>
<style scoped>
.header-bar {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 16px;
}
.sort-input {
display: flex;
align-items: center;
}
.sort-input .el-input-number {
margin: 0 5px;
}
.sort-input .el-button {
padding: 7px;
min-width: 32px;
}
.custom-footer {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px 0 0 0;
}
.footer-right {
display: flex;
align-items: center;
gap: 12px;
}
</style>

View File

@ -117,34 +117,32 @@
/> />
<!-- 添加或修改师傅技能配置对话框 --> <!-- 添加或修改师傅技能配置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px" class="custom-form">
<el-form-item label="名称" prop="title"> <el-form-item label="名称" prop="title">
<el-input v-model="form.title" placeholder="请输入名称" /> <el-input v-model="form.title" placeholder="输入名称">
<template slot="prepend">
<i class="el-icon-edit"></i>
</template>
</el-input>
</el-form-item> </el-form-item>
<el-form-item label="排序" prop="sort"> <el-form-item label="排序" prop="sort" required>
<el-input v-model="form.sort" placeholder="请输入排序" /> <div class="sort-input">
<el-button icon="el-icon-minus" @click="decreaseSort" size="small"></el-button>
<el-input-number v-model="form.sort" :min="0" :controls="false" style="width: 100px; text-align: center;" />
<el-button icon="el-icon-plus" @click="increaseSort" size="small"></el-button>
</div>
</el-form-item> </el-form-item>
<el-form-item label="${comment}" prop="createdAt"> <el-form-item label="状态">
<el-date-picker clearable <el-switch v-model="form.status" :active-value="1" :inactive-value="0" />
v-model="form.createdAt"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择${comment}">
</el-date-picker>
</el-form-item>
<el-form-item label="${comment}" prop="updatedAt">
<el-date-picker clearable
v-model="form.updatedAt"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择${comment}">
</el-date-picker>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div class="dialog-footer custom-footer">
<el-button type="primary" @click="submitForm"> </el-button> <el-button @click="resetForm">重置</el-button>
<el-button @click="cancel"> </el-button> <div class="footer-right">
<el-button type="primary" @click="submitForm">提交</el-button>
</div>
</div> </div>
</el-dialog> </el-dialog>
</div> </div>
@ -198,7 +196,10 @@ export default {
status: [ status: [
{ required: true, message: "状态不能为空", trigger: "change" } { required: true, message: "状态不能为空", trigger: "change" }
], ],
} },
continueEdit: false,
continueCreate: false,
viewAfter: false
} }
}, },
created() { created() {
@ -224,12 +225,24 @@ export default {
this.form = { this.form = {
id: null, id: null,
title: null, title: null,
sort: null, sort: 0,
status: null, status: 1,
createdAt: null, createdAt: null,
updatedAt: null updatedAt: null
} }
this.resetForm("form") },
resetForm() {
if (this.$refs.form) {
this.$refs.form.resetFields();
}
},
decreaseSort() {
if (this.form.sort > 0) {
this.form.sort--
}
},
increaseSort() {
this.form.sort++
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
@ -238,7 +251,7 @@ export default {
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
this.resetForm("queryForm") this.resetForm()
this.handleQuery() this.handleQuery()
}, },
@ -314,3 +327,31 @@ export default {
} }
} }
</script> </script>
<style scoped>
.custom-form {
padding-top: 20px;
}
.sort-input {
display: flex;
align-items: center;
}
.sort-input .el-input-number {
margin: 0 5px;
}
.sort-input .el-button {
padding: 7px;
min-width: 32px;
}
.custom-footer {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px 0 0 0;
}
.footer-right {
display: flex;
align-items: center;
gap: 12px;
}
</style>

View File

@ -69,16 +69,7 @@
v-hasPermi="['system:users:remove']" v-hasPermi="['system:users:remove']"
>删除</el-button> >删除</el-button>
</el-col> </el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:users:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
@ -136,119 +127,76 @@
/> />
<!-- 添加或修改用户列表对话框 --> <!-- 添加或修改用户列表对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="ID" v-if="form.id">
<el-input v-model="form.id" disabled />
</el-form-item>
<el-form-item label="昵称" prop="name"> <el-form-item label="昵称" prop="name">
<el-input v-model="form.name" placeholder="请输入昵称" /> <el-input v-model="form.name" placeholder="请输入昵称" />
</el-form-item> </el-form-item>
<el-form-item label="微信昵称" prop="nickname">
<el-input v-model="form.nickname" placeholder="请输入微信昵称" />
</el-form-item>
<el-form-item label="电话" prop="phone"> <el-form-item label="电话" prop="phone">
<el-input v-model="form.phone" placeholder="请输入电话" /> <el-input v-model="form.phone" placeholder="请输入电话" />
</el-form-item> </el-form-item>
<el-form-item label="${comment}" prop="password">
<el-input v-model="form.password" placeholder="请输入${comment}" />
</el-form-item>
<el-form-item label="${comment}" prop="rememberToken">
<el-input v-model="form.rememberToken" placeholder="请输入${comment}" />
</el-form-item>
<el-form-item label="${comment}" prop="openid">
<el-input v-model="form.openid" placeholder="请输入${comment}" />
</el-form-item>
<el-form-item label="头像" prop="avatar"> <el-form-item label="头像" prop="avatar">
<image-upload v-model="form.avatar"/> <image-upload v-model="form.avatar" :limit="1"/>
</el-form-item> </el-form-item>
<el-form-item label="师傅签到时间" prop="workerTime">
<el-date-picker clearable
v-model="form.workerTime" <el-row>
type="date" <el-col :span="12">
value-format="yyyy-MM-dd" <el-form-item label="可用积分">
placeholder="请选择师傅签到时间"> <div class="integral-input">
</el-date-picker> <el-button icon="el-icon-minus" @click="decreaseIntegral"></el-button>
</el-form-item> <el-input-number
<el-form-item label="可用积分" prop="integral"> v-model="form.integral"
<el-input v-model="form.integral" placeholder="请输入可用积分" /> :min="0"
</el-form-item> :controls="false"
<el-form-item label="累计积分" prop="totalIntegral"> placeholder="请输入可用积分" />
<el-input v-model="form.totalIntegral" placeholder="请输入累计积分" /> <el-button icon="el-icon-plus" @click="increaseIntegral"></el-button>
</el-form-item> </div>
<el-form-item label="1:启用 0关闭" prop="status"> </el-form-item>
<el-radio-group v-model="form.status"> </el-col>
<el-radio <el-col :span="12">
v-for="dict in dict.type.users_status" <el-form-item label="累计积分">
:key="dict.value" <div class="integral-input">
:label="parseInt(dict.value)" <el-button icon="el-icon-minus" @click="decreaseTotalIntegral"></el-button>
>{{dict.label}}</el-radio> <el-input-number
</el-radio-group> v-model="form.totalIntegral"
</el-form-item> :min="0"
<el-form-item label="师傅等级" prop="level"> :controls="false"
<el-input v-model="form.level" placeholder="请输入师傅等级" /> placeholder="请输入累计积分" />
</el-form-item> <el-button icon="el-icon-plus" @click="increaseTotalIntegral"></el-button>
<el-form-item label="师傅佣金" prop="commission"> </div>
<el-input v-model="form.commission" placeholder="请输入师傅佣金" /> </el-form-item>
</el-form-item> </el-col>
<el-form-item label="累计佣金" prop="totalComm"> </el-row>
<el-input v-model="form.totalComm" placeholder="请输入累计佣金" />
</el-form-item>
<el-form-item label="质保金" prop="margin">
<el-input v-model="form.margin" placeholder="请输入质保金" /> <el-form-item label="创建时间" prop="createdAt" >
</el-form-item>
<el-form-item label="工号" prop="jobNumber">
<el-input v-model="form.jobNumber" placeholder="请输入工号" />
</el-form-item>
<el-form-item label="禁止接单开始时间" prop="prohibitTime">
<el-date-picker clearable
v-model="form.prohibitTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择禁止接单开始时间">
</el-date-picker>
</el-form-item>
<el-form-item label="禁止接单时长" prop="prohibitTimeNum">
<el-input v-model="form.prohibitTimeNum" placeholder="请输入禁止接单时长" />
</el-form-item>
<el-form-item label="师傅累计接单" prop="toa">
<el-input v-model="form.toa" placeholder="请输入师傅累计接单" />
</el-form-item>
<el-form-item label="师傅服务城市" prop="serviceCityPid">
<el-input v-model="form.serviceCityPid" placeholder="请输入师傅服务城市" />
</el-form-item>
<el-form-item label="师傅服务区域" prop="serviceCityIds">
<el-input v-model="form.serviceCityIds" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="师傅技能ID" prop="skillIds">
<el-input v-model="form.skillIds" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="累计提现" prop="propose">
<el-input v-model="form.propose" placeholder="请输入累计提现" />
</el-form-item>
<el-form-item label="0:默认 1停止接单" prop="isStop">
<el-input v-model="form.isStop" placeholder="请输入0:默认 1停止接单" />
</el-form-item>
<el-form-item label="1虚拟号码-已认证" prop="middleAuth">
<el-input v-model="form.middleAuth" placeholder="请输入1虚拟号码-已认证" />
</el-form-item>
<el-form-item label="${comment}" prop="createdAt">
<el-date-picker clearable <el-date-picker clearable
disabled
v-model="form.createdAt" v-model="form.createdAt"
type="date" type="date"
value-format="yyyy-MM-dd" value-format="yyyy-MM-dd"
placeholder="请选择${comment}"> placeholder="自动获取">
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
<el-form-item label="${comment}" prop="updatedAt"> <el-form-item label="修改时间" prop="updatedAt" disabled>
<el-date-picker clearable <el-date-picker clearable
disabled
v-model="form.updatedAt" v-model="form.updatedAt"
type="date" type="date"
value-format="yyyy-MM-dd" value-format="yyyy-MM-dd"
placeholder="请选择${comment}"> placeholder="自动获取">
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button> <el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button> <el-button @click="cancel"> </el-button>
<el-button icon="el-icon-refresh" @click="resetForm('form')">重置</el-button>
</div> </div>
</el-dialog> </el-dialog>
</div> </div>
@ -320,6 +268,25 @@ export default {
this.loading = false this.loading = false
}) })
}, },
//
increaseIntegral() {
this.form.integral = Number(this.form.integral || 0) + 1
},
decreaseIntegral() {
if (this.form.integral > 0) {
this.form.integral = Number(this.form.integral) - 1
}
},
increaseTotalIntegral() {
this.form.totalIntegral = Number(this.form.totalIntegral || 0) + 1
},
decreaseTotalIntegral() {
if (this.form.totalIntegral > 0) {
this.form.totalIntegral = Number(this.form.totalIntegral) - 1
}
},
// //
cancel() { cancel() {
this.open = false this.open = false
@ -434,3 +401,50 @@ export default {
} }
} }
</script> </script>
<style scoped>
.avatar-upload-box {
width: 100%;
min-height: 200px;
border: 2px dashed #dcdfe6;
border-radius: 6px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #f5f7fa;
cursor: pointer;
transition: all 0.3s;
}
.avatar-upload-box:hover {
border-color: #409eff;
background-color: #ecf5ff;
}
.upload-tip {
margin-top: 10px;
color: #909399;
font-size: 14px;
}
.integral-input {
display: flex;
align-items: center;
}
.integral-input .el-input-number {
margin: 0 5px;
flex: 1;
}
.integral-input .el-button {
padding: 8px;
}
.el-input-number.is-controls-right .el-input__inner {
padding-left: 15px;
padding-right: 15px;
text-align: center;
}
</style>

View File

@ -389,15 +389,29 @@ export default {
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.editUser = {}; this.editUser = {
name: undefined,
phone: undefined,
avatar: undefined,
prohibitTime: undefined,
prohibitTimeNum: 0,
serviceCityPid: undefined,
serviceCityIds: undefined,
skillIds: undefined,
commission: undefined,
status: 1
};
this.editMode = 'add'; this.editMode = 'add';
this.editDialogVisible = true; this.editDialogVisible = true;
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.editUser = { ...row }; const id = row.id || this.ids
this.editMode = 'edit'; getUsers(id).then(response => {
this.editDialogVisible = true; this.editUser = response.data;
this.editMode = 'edit';
this.editDialogVisible = true;
})
}, },
// //
handleStatusChange(row) { handleStatusChange(row) {

View File

@ -22,51 +22,7 @@
</el-form-item> </el-form-item>
</el-form> </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="['system:WorkerSign: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="['system:WorkerSign: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="['system:WorkerSign: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="['system:WorkerSign:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="WorkerSignList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="WorkerSignList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
@ -83,24 +39,7 @@
</template> </template>
</el-table-column> </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="['system:WorkerSign:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:WorkerSign:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table> </el-table>
<pagination <pagination