企事业单位添加修改

This commit is contained in:
luozhun 2024-09-03 17:05:05 +08:00
parent c20eb9f1be
commit 87ce7659ca
23 changed files with 741 additions and 39 deletions

View File

@ -1,9 +1,25 @@
package com.changhu.module.management.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.changhu.common.annotation.JsonBody;
import com.changhu.common.pojo.vo.TreeNodeVo;
import com.changhu.common.utils.JavaClassToTsUtil;
import com.changhu.mapper.AdministrativeDivisionMapper;
import com.changhu.module.management.pojo.params.EnterprisesUnitSaveOrUpdateParams;
import com.changhu.module.management.pojo.queryParams.EnterprisesUnitPagerQueryParams;
import com.changhu.module.management.pojo.vo.EnterprisesUnitPagerVo;
import com.changhu.module.management.service.EnterprisesUnitService;
import com.changhu.support.mybatisplus.pojo.params.PageParams;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
/**
* @author 20252
* @createTime 2024/9/3 上午10:17
@ -13,4 +29,24 @@ import org.springframework.web.bind.annotation.RequestMapping;
@JsonBody
@RequestMapping("/enterprisesUnit")
public class EnterprisesUnitController {
@Autowired
private EnterprisesUnitService enterprisesUnitService;
@Operation(summary = "分页查询")
@PostMapping("/pager")
public Page<EnterprisesUnitPagerVo> pager(@RequestBody @Valid PageParams<EnterprisesUnitPagerQueryParams, EnterprisesUnitPagerVo> queryParams) {
return enterprisesUnitService.pager(queryParams);
}
@Operation(summary = "新增或保存")
@PostMapping("/saveOrUpdate")
public void saveOrUpdate(@RequestBody @Valid EnterprisesUnitSaveOrUpdateParams params) {
enterprisesUnitService.saveOrUpdate(params);
}
public static void main(String[] args) {
System.out.println(JavaClassToTsUtil.parse(EnterprisesUnitSaveOrUpdateParams.class));
}
}

View File

@ -1,8 +1,14 @@
package com.changhu.module.management.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.changhu.common.annotation.JsonBody;
import com.changhu.module.management.pojo.params.ManagementSecurityUnitUserSaveOrUpdateParams;
import com.changhu.module.management.pojo.queryParams.ManagementSecurityUnitUserPagerQueryParams;
import com.changhu.module.management.pojo.vo.ManagementSecurityUnitUserPagerVo;
import com.changhu.module.management.service.ManagementSecurityUnitUserService;
import com.changhu.support.mybatisplus.pojo.params.PageParams;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
@ -14,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
* @createTime 2024/9/3 上午10:22
* @desc ManagementSecurityUnitUserController...
*/
@Tag(name = "后台-保安用户")
@JsonBody
@RequestMapping("/managementSecurityUnitUser")
public class ManagementSecurityUnitUserController {
@ -21,8 +28,15 @@ public class ManagementSecurityUnitUserController {
@Autowired
private ManagementSecurityUnitUserService managementSecurityUnitUserService;
@Operation(summary = "新增或修改")
@PostMapping("/saveOrUpdate")
public void saveOrUpdate(@RequestBody @Valid ManagementSecurityUnitUserSaveOrUpdateParams saveOrUpdateParams) {
managementSecurityUnitUserService.saveOrUpdate(saveOrUpdateParams);
}
@Operation(summary = "分页查询")
@PostMapping("/pager")
public Page<ManagementSecurityUnitUserPagerVo> pager(@RequestBody PageParams<ManagementSecurityUnitUserPagerQueryParams, ManagementSecurityUnitUserPagerVo> queryParams) {
return managementSecurityUnitUserService.pager(queryParams);
}
}

View File

@ -1,8 +1,12 @@
package com.changhu.module.management.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.changhu.module.management.pojo.entity.EnterprisesUnit;
import com.changhu.module.management.pojo.queryParams.EnterprisesUnitPagerQueryParams;
import com.changhu.module.management.pojo.vo.EnterprisesUnitPagerVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* enterprises_unit (企事业单位) 固化类
@ -12,4 +16,13 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface EnterprisesUnitMapper extends BaseMapper<EnterprisesUnit> {
/**
* 分页查询
*
* @param page 分页参数
* @param params 查询参数
* @return 结果
*/
Page<EnterprisesUnitPagerVo> pager(@Param("page") Page<EnterprisesUnitPagerVo> page,
@Param("params") EnterprisesUnitPagerQueryParams params);
}

View File

@ -1,8 +1,14 @@
package com.changhu.module.management.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.changhu.module.management.pojo.entity.ManagementSecurityUnitUser;
import com.changhu.module.management.pojo.queryParams.ManagementSecurityUnitUserPagerQueryParams;
import com.changhu.module.management.pojo.vo.ManagementSecurityUnitUserPagerVo;
import com.changhu.support.mybatisplus.annotation.DataScope;
import com.changhu.support.mybatisplus.handler.permission.management.ManagementSecurityUnitUserPagerPermissionHandler;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* management_security_unit_user (后台-保安单位用户表) 固化类
@ -12,4 +18,14 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ManagementSecurityUnitUserMapper extends BaseMapper<ManagementSecurityUnitUser> {
/**
* 分页查询
*
* @param page 分页参数
* @param params 查询参数
* @return 结果
*/
@DataScope(permissionHandler = ManagementSecurityUnitUserPagerPermissionHandler.class)
Page<ManagementSecurityUnitUserPagerVo> pager(@Param("page") Page<ManagementSecurityUnitUserPagerVo> page,
@Param("params") ManagementSecurityUnitUserPagerQueryParams params);
}

View File

@ -0,0 +1,43 @@
package com.changhu.module.management.pojo.params;
import com.changhu.module.management.pojo.model.ContactPersonInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.util.List;
/**
* @author 20252
* @createTime 2024/9/3 下午4:06
* @desc EnterprisesUnitSaveOrUpdateParams...
*/
@Data
public class EnterprisesUnitSaveOrUpdateParams {
@Schema(description = "id")
private Long snowFlakeId;
@Schema(description = "公安单位id")
@NotNull(message = "公安单位不能为空")
private Long policeUnitId;
@Schema(description = "名称")
@NotBlank(message = "名称不能为空")
private String name;
@Schema(description = "行政区划编码")
@NotEmpty(message = "行政区划不能为空")
private List<String> administrativeDivisionCodes;
@Schema(description = "详细地址")
private String address;
@Schema(description = "联系人")
private ContactPersonInfo contactPersonInfo;
@Schema(description = "备注")
private String remark;
}

View File

@ -0,0 +1,18 @@
package com.changhu.module.management.pojo.queryParams;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
/**
* @author 20252
* @createTime 2024/9/3 下午3:27
* @desc EnterprisesUnitPagerQueryParams...
*/
@Data
public class EnterprisesUnitPagerQueryParams {
@NotNull(message = "公安单位id不能为空")
@Schema(description = "公安单位id")
private Long policeUnitId;
}

View File

@ -0,0 +1,20 @@
package com.changhu.module.management.pojo.queryParams;
import com.changhu.common.db.enums.Sex;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @author 20252
* @createTime 2024/9/3 上午11:02
* @desc ManagementSecurityUnitUserPagerQueryParams...
*/
@Data
public class ManagementSecurityUnitUserPagerQueryParams {
@Schema(description = "名字")
private String name;
@Schema(description = "手机号")
private String telephone;
@Schema(description = "性别")
private Sex sex;
}

View File

@ -0,0 +1,54 @@
package com.changhu.module.management.pojo.vo;
import com.changhu.module.management.pojo.model.ContactPersonInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @author 20252
* @createTime 2024/9/3 下午3:22
* @desc EnterprisesUnitPagerVo...
*/
@Data
public class EnterprisesUnitPagerVo {
@Schema(description = "id")
private Long snowFlakeId;
@Schema(description = "名字")
private String name;
@Schema(description = "公安单位id")
private Long policeUnitId;
@Schema(description = "省编码")
private String province;
@Schema(description = "省名称")
private String provinceName;
@Schema(description = "市编码")
private String city;
@Schema(description = "市名称")
private String cityName;
@Schema(description = "区编码")
private String districts;
@Schema(description = "区名称")
private String districtsName;
@Schema(description = "街编码")
private String street;
@Schema(description = "街名称")
private String streetName;
@Schema(description = "地址")
private String address;
@Schema(description = "联系方式")
private ContactPersonInfo contactPersonInfo;
@Schema(description = "备注")
private String remark;
@Schema(description = "创建时间")
private String createTime;
}

View File

@ -0,0 +1,49 @@
package com.changhu.module.management.pojo.vo;
import com.changhu.common.db.enums.IsEnable;
import com.changhu.common.db.enums.IsOrNot;
import com.changhu.common.db.enums.Sex;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @author 20252
* @createTime 2024/9/3 上午10:59
* @desc ManagementSecurityUnitUserPagerVo...
*/
@Data
public class ManagementSecurityUnitUserPagerVo {
@Schema(description = "id")
private Long snowFlakeId;
@Schema(description = "名称")
private String name;
@Schema(description = "性别")
private Sex sex;
@Schema(description = "性别")
private String account;
@Schema(description = "手机号")
private String telephone;
@Schema(description = "是否启用")
private IsEnable isEnable;
@Schema(description = "是否是超管")
private IsOrNot isAdmin;
@Schema(description = "备注")
private String remark;
@Schema(description = "创建人")
private String createUserName;
@Schema(description = "创建时间")
private LocalDateTime createTime;
}

View File

@ -1,7 +1,12 @@
package com.changhu.module.management.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.changhu.module.management.pojo.entity.EnterprisesUnit;
import com.changhu.module.management.pojo.params.EnterprisesUnitSaveOrUpdateParams;
import com.changhu.module.management.pojo.queryParams.EnterprisesUnitPagerQueryParams;
import com.changhu.module.management.pojo.vo.EnterprisesUnitPagerVo;
import com.changhu.support.mybatisplus.pojo.params.PageParams;
/**
* enterprises_unit (企事业单位) 服务类
@ -10,4 +15,18 @@ import com.changhu.module.management.pojo.entity.EnterprisesUnit;
*/
public interface EnterprisesUnitService extends IService<EnterprisesUnit> {
/**
* 分页查询
*
* @param queryParams 查询参数
* @return 结果
*/
Page<EnterprisesUnitPagerVo> pager(PageParams<EnterprisesUnitPagerQueryParams, EnterprisesUnitPagerVo> queryParams);
/**
* 新增或保存
*
* @param params 参数
*/
void saveOrUpdate(EnterprisesUnitSaveOrUpdateParams params);
}

View File

@ -1,8 +1,12 @@
package com.changhu.module.management.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.changhu.module.management.pojo.entity.ManagementSecurityUnitUser;
import com.changhu.module.management.pojo.params.ManagementSecurityUnitUserSaveOrUpdateParams;
import com.changhu.module.management.pojo.queryParams.ManagementSecurityUnitUserPagerQueryParams;
import com.changhu.module.management.pojo.vo.ManagementSecurityUnitUserPagerVo;
import com.changhu.support.mybatisplus.pojo.params.PageParams;
/**
* management_security_unit_user (后台-保安单位用户表) 服务类
@ -17,4 +21,12 @@ public interface ManagementSecurityUnitUserService extends IService<ManagementSe
* @param saveOrUpdateParams 参数
*/
void saveOrUpdate(ManagementSecurityUnitUserSaveOrUpdateParams saveOrUpdateParams);
/**
* 分页查询
*
* @param queryParams 查询参数
* @return 分页结果
*/
Page<ManagementSecurityUnitUserPagerVo> pager(PageParams<ManagementSecurityUnitUserPagerQueryParams, ManagementSecurityUnitUserPagerVo> queryParams);
}

View File

@ -1,11 +1,20 @@
package com.changhu.module.management.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.changhu.common.exception.MessageException;
import com.changhu.module.management.mapper.EnterprisesUnitMapper;
import com.changhu.module.management.pojo.entity.EnterprisesUnit;
import com.changhu.module.management.pojo.params.EnterprisesUnitSaveOrUpdateParams;
import com.changhu.module.management.pojo.queryParams.EnterprisesUnitPagerQueryParams;
import com.changhu.module.management.pojo.vo.EnterprisesUnitPagerVo;
import com.changhu.module.management.service.EnterprisesUnitService;
import com.changhu.support.mybatisplus.pojo.params.PageParams;
import org.springframework.stereotype.Service;
import java.util.Optional;
/**
* enterprises_unit (企事业单位) 服务实现类
* author: luozhun
@ -14,4 +23,32 @@ import org.springframework.stereotype.Service;
@Service
public class EnterprisesUnitServiceImpl extends ServiceImpl<EnterprisesUnitMapper, EnterprisesUnit> implements EnterprisesUnitService {
@Override
public Page<EnterprisesUnitPagerVo> pager(PageParams<EnterprisesUnitPagerQueryParams, EnterprisesUnitPagerVo> queryParams) {
return baseMapper.pager(queryParams.getPage(), queryParams.getParams());
}
@Override
public void saveOrUpdate(EnterprisesUnitSaveOrUpdateParams params) {
EnterprisesUnit enterprisesUnit = BeanUtil.copyProperties(params, EnterprisesUnit.class);
Optional.ofNullable(params.getAdministrativeDivisionCodes())
.ifPresent(codes -> {
if (!codes.isEmpty()) {
enterprisesUnit.setProvince(codes.get(0));
}
if (codes.size() >= 2) {
enterprisesUnit.setCity(codes.get(1));
}
if (codes.size() >= 3) {
enterprisesUnit.setDistricts(codes.get(2));
}
if (codes.size() >= 4) {
enterprisesUnit.setStreet(codes.get(3));
}
});
boolean b = this.saveOrUpdate(enterprisesUnit);
if (!b) {
throw new MessageException();
}
}
}

View File

@ -3,13 +3,17 @@ package com.changhu.module.management.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.changhu.common.exception.MessageException;
import com.changhu.common.utils.UserUtil;
import com.changhu.module.management.mapper.ManagementSecurityUnitUserMapper;
import com.changhu.module.management.pojo.entity.ManagementSecurityUnitUser;
import com.changhu.module.management.pojo.params.ManagementSecurityUnitUserSaveOrUpdateParams;
import com.changhu.module.management.pojo.queryParams.ManagementSecurityUnitUserPagerQueryParams;
import com.changhu.module.management.pojo.vo.ManagementSecurityUnitUserPagerVo;
import com.changhu.module.management.service.ManagementSecurityUnitUserService;
import com.changhu.support.mybatisplus.pojo.params.PageParams;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -53,4 +57,9 @@ public class ManagementSecurityUnitUserServiceImpl extends ServiceImpl<Managemen
}
this.saveOrUpdate(managementSecurityUnitUser);
}
@Override
public Page<ManagementSecurityUnitUserPagerVo> pager(PageParams<ManagementSecurityUnitUserPagerQueryParams, ManagementSecurityUnitUserPagerVo> queryParams) {
return baseMapper.pager(queryParams.getPage(), queryParams.getParams());
}
}

View File

@ -40,10 +40,10 @@ public class SecurityUnitServiceImpl extends ServiceImpl<SecurityUnitMapper, Sec
securityUnit.setCity(codes.get(1));
}
if (codes.size() >= 3) {
securityUnit.setCity(codes.get(2));
securityUnit.setDistricts(codes.get(2));
}
if (codes.size() >= 4) {
securityUnit.setCity(codes.get(3));
securityUnit.setStreet(codes.get(3));
}
});
this.saveOrUpdate(securityUnit);

View File

@ -0,0 +1,40 @@
package com.changhu.support.mybatisplus.handler.permission.management;
import com.baomidou.mybatisplus.extension.toolkit.Db;
import com.changhu.common.enums.ResultCode;
import com.changhu.common.exception.MessageException;
import com.changhu.common.utils.UserUtil;
import com.changhu.module.management.pojo.entity.ManagementSecurityUnitUser;
import com.changhu.support.mybatisplus.handler.permission.AbstractDataPermissionHandler;
import com.changhu.support.mybatisplus.pojo.entity.BaseEntity;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.LongValue;
import net.sf.jsqlparser.expression.operators.relational.EqualsTo;
import net.sf.jsqlparser.schema.Column;
import net.sf.jsqlparser.schema.Table;
/**
* @author 20252
* @createTime 2024/9/3 上午11:11
* @desc 后台安保人员分页权限
*/
public class ManagementSecurityUnitUserPagerPermissionHandler implements AbstractDataPermissionHandler {
@Override
public Expression apply(Table table, Expression where, String mappedStatementId) {
if ("msuu".equals(table.getAlias().getName())) {
return sqlFragment();
}
return null;
}
@Override
public Expression sqlFragment() {
//查出当前用户
ManagementSecurityUnitUser managementSecurityUnitUser = Db.lambdaQuery(ManagementSecurityUnitUser.class)
.select(BaseEntity::getSnowFlakeId, ManagementSecurityUnitUser::getSecurityUnitId)
.eq(BaseEntity::getSnowFlakeId, UserUtil.getUserId())
.oneOpt()
.orElseThrow(() -> new MessageException(ResultCode.USER_NOT_FOUND));
return new EqualsTo(new Column("msuu.security_unit_id"), new LongValue(managementSecurityUnitUser.getSecurityUnitId()));
}
}

View File

@ -0,0 +1,25 @@
<?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.changhu.module.management.mapper.EnterprisesUnitMapper">
<resultMap id="EnterprisesUnitPagerVoResultMap" type="com.changhu.module.management.pojo.vo.EnterprisesUnitPagerVo">
<result
column="contact_person_info"
typeHandler="com.baomidou.mybatisplus.extension.handlers.Fastjson2TypeHandler"
property="contactPersonInfo"/>
</resultMap>
<select id="pager" resultMap="EnterprisesUnitPagerVoResultMap">
select eu.*,
ad1.name as provinceName,
ad2.name as cityName,
ad3.name as districtsName,
ad4.name as streetName
from enterprises_unit eu
left join administrative_division ad1 on eu.province = ad1.code and ad1.delete_flag = 0
left join administrative_division ad2 on eu.city = ad2.code and ad2.delete_flag = 0
left join administrative_division ad3 on eu.districts = ad3.code and ad3.delete_flag = 0
left join administrative_division ad4 on eu.street = ad4.code and ad4.delete_flag = 0
where eu.delete_flag = 0
and eu.police_unit_id = #{params.policeUnitId}
order by eu.create_time desc
</select>
</mapper>

View File

@ -0,0 +1,23 @@
<?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.changhu.module.management.mapper.ManagementSecurityUnitUserMapper">
<select id="pager" resultType="com.changhu.module.management.pojo.vo.ManagementSecurityUnitUserPagerVo">
select
msuu.*,
msuu2.name as 'createUserName'
from management_security_unit_user msuu
left join management_security_unit_user msuu2 on msuu.create_by = msuu2.snow_flake_id
where
msuu.delete_flag = 0
<if test="params.name!=null and params.name!=''">
and msuu.name like concat('%',#{params.name},'%')
</if>
<if test="params.telephone!=null and params.telephone!=''">
and msuu.telephone like concat('%',#{params.telephone},'%')
</if>
<if test="params.sex!=null">
and msuu.sex = #{params.sex.value}
</if>
order by msuu.create_time desc
</select>
</mapper>

View File

@ -0,0 +1,54 @@
import {h, Ref, ref, VNode} from "vue";
import {Modal} from "ant-design-vue";
import {FormExpose} from "ant-design-vue/es/form/Form";
import {ExclamationCircleOutlined} from "@ant-design/icons-vue";
import FormProMax from "@/components/form/FormProMax.vue";
import {FormProMaxItemOptions, FormProMaxProps} from "@/types/components/form";
export function submitSimpleFormModal<T>(props: {
title: string,
formParams?: T & Record<string, any>,
formProps?: Omit<FormProMaxProps<T>, 'formItemOptions'>,
formOptions: FormProMaxItemOptions<T>
submit: (params: T) => Promise<any>,
cancel?: (params: T) => Promise<any>,
icon?: () => VNode,
maskClosable?: boolean,
width?: string | number
}) {
if (!props.formParams) props.formParams = {} as T
if (!props.width) props.width = 520
const formRef = ref<FormExpose>(null)
const _formParams = ref<T>({
...props.formParams
}) as Ref<T>
Modal.confirm({
icon: props.icon ? props.icon() : ' ',
width: props.width,
maskClosable: props.maskClosable ?? true,
title: props.title,
content: () => <FormProMax
ref={formRef}
v-model={[_formParams.value, 'value']}
{...props.formProps}
formItemOptions={props.formOptions}
/>,
onOk: async () => {
await formRef.value?.validate()
await props.submit(_formParams.value);
},
onCancel: async () => props.cancel && await props.cancel(_formParams.value)
})
}
export const deleteDataModal = (name: string, submit: () => Promise<any>, cancel?: () => Promise<any>) => {
Modal.confirm({
title: `确认删除【${name}】吗?`,
icon: h(ExclamationCircleOutlined),
content: h('div', {style: 'color:red;'}, '此操作将删除数据,且无法找回!'),
onOk: async () => await submit(),
onCancel: async () => cancel && await cancel()
});
}

View File

@ -32,12 +32,6 @@ export const SYSTEM_MENUS: SystemMenu[] = [
path: '/securityUnit',
type: 'menu',
component: () => import('@/views/unitManage/securityUnit/index.vue')
}, {
title: '企事业单位',
name: 'enterprisesUnit',
path: '/enterprisesUnit',
type: 'menu',
component: () => import('@/views/unitManage/enterprisesUnit/index.vue')
}
]
}

View File

@ -0,0 +1,36 @@
import {onMounted, reactive, toRefs} from "vue";
import api from "@/axios";
interface SelectAndTreeNodeType {
administrativeDivisionTree: TreeNodeVo<string>[];
}
export const callbackResult: { [key in keyof SelectAndTreeNodeType]: (params?: Record<string, any>) => Promise<SelectAndTreeNodeType[key]> } = {
administrativeDivisionTree: async (params = {level: 4}) => (await api.get<TreeNodeVo<string>[]>('/common/administrativeDivisionTree', params)).data,
}
export default (type?: keyof SelectAndTreeNodeType | (keyof SelectAndTreeNodeType)[], params?: { [key in keyof SelectAndTreeNodeType]?: Record<string, any> }) => {
const allData = reactive<SelectAndTreeNodeType>({
administrativeDivisionTree: [],
})
const refreshData = (type: keyof SelectAndTreeNodeType | (keyof SelectAndTreeNodeType)[]) => {
if (typeof type === "string") {
//@ts-ignore
callbackResult[type](params?.[type]).then(data => allData[type] = data)
} else {
//@ts-ignore
type.forEach(t => callbackResult[t](params?.[t]).then(data => allData[t] = data))
}
}
onMounted(() => type && refreshData(type))
return {
refreshData,
...toRefs(allData),
callbackResult
}
}

View File

@ -46,3 +46,60 @@ export interface PoliceUnitPagerVo extends BaseTableRowRecord {
/** 审核状态 **/
checkStatus?: BaseEnum<number>;
}
export interface EnterprisesUnitPagerQueryParams {
/** 公安单位id **/
policeUnitId: string;
}
export interface EnterprisesUnitPagerVo extends BaseTableRowRecord {
/** 名字 **/
name?: string;
/** 公安单位id **/
policeUnitId: string;
/** 省编码 **/
province?: string;
/** 省名称 **/
provinceName?: string;
/** 市编码 **/
city?: string;
/** 市名称 **/
cityName?: string;
/** 区编码 **/
districts?: string;
/** 区名称 **/
districtsName?: string;
/** 街编码 **/
street?: string;
/** 街名称 **/
streetName?: string;
/** 地址 **/
address?: string;
/** 联系方式 **/
contactPersonInfo?: {
name: string;
telephone: string;
};
/** 备注 **/
remark?: string;
}
export interface EnterprisesUnitSaveOrUpdateParams {
/** id **/
snowFlakeId?: string;
/** 公安单位id **/
policeUnitId: string;
/** 名称 **/
name: string;
/** 行政区划编码 **/
administrativeDivisionCodes: string[];
/** 详细地址 **/
address?: string;
/** 联系人 **/
contactPersonInfo?: {
name: string;
telephone: string;
};
/** 备注 **/
remark?: string;
}

View File

@ -1,13 +0,0 @@
<template>
<div>
企事业单位管理
</div>
</template>
<script setup lang="ts">
</script>
<style scoped lang="scss">
</style>

View File

@ -13,15 +13,24 @@
import TableProMax from "@/components/table/TableProMax.vue";
import {ref} from "vue";
import {ComponentExposed} from "vue-component-type-helpers";
import {TableProMaxProps} from "@/types/components/table";
import {PoliceUnitPagerQueryParams, PoliceUnitPagerVo} from "@/types/views/unitManage/policeUnit.ts";
import {TableProMaxProps, TableProMaxSlots} from "@/types/components/table";
import {
EnterprisesUnitPagerQueryParams, EnterprisesUnitPagerVo, EnterprisesUnitSaveOrUpdateParams,
PoliceUnitPagerQueryParams,
PoliceUnitPagerVo
} from "@/types/views/unitManage/policeUnit.ts";
import api from "@/axios";
import {dictSelectNodes} from "@/config/dict.ts";
import {message} from "ant-design-vue";
import {message, Modal} from "ant-design-vue";
import {UNIT_TYPE} from "@/config";
import {PageParams} from "@/types/hooks/useTableProMax.ts";
import {submitSimpleFormModal} from "@/components/tsx/ModalPro.tsx";
import useSelectAndTreeNodeVos from "@/hooks/useSelectAndTreeNodeVos.ts";
type TableProps = TableProMaxProps<PoliceUnitPagerVo, PoliceUnitPagerQueryParams>
const {administrativeDivisionTree} = useSelectAndTreeNodeVos('administrativeDivisionTree')
const tableRef = ref<ComponentExposed<typeof TableProMax>>(null!)
const reqApi: TableProps['requestApi'] = (params) => api.post('/policeUnit/pager', params)
const columns: TableProps['columns'] = [
@ -56,8 +65,9 @@ const columns: TableProps['columns'] = [
dataIndex: 'opt',
title: '操作',
customRender({record}) {
if (record.checkStatus.value === 1) {
return <a-space>
{record.checkStatus.value === 1 && <a-popconfirm
<a-popconfirm
title="确认审核通过嘛?"
onConfirm={async () => {
const resp = await api.post('/management/checkPass', {
@ -70,7 +80,14 @@ const columns: TableProps['columns'] = [
<a-button type="primary">审核通过
</a-button>
</a-popconfirm>
</a-space>
}
return <a-space>
<a-button
class="btn-success"
onClick={() => showEnterprisesUnit(record)}
>企事业单位
</a-button>
<a-button
class={record.isEnable.value === 0 ? 'btn-danger' : 'btn-success'}
onClick={async () => {
@ -114,6 +131,135 @@ const searchFormOptions: TableProps["searchFormOptions"] = {
}
}
type _TableProps = TableProMaxProps<EnterprisesUnitPagerVo, EnterprisesUnitPagerQueryParams>;
const showEnterprisesUnit = (policeUnitPagerVo: PoliceUnitPagerVo) => {
const saveOrUpdateEnterprisesUnit = (data?: EnterprisesUnitSaveOrUpdateParams & {
contactPersonInfoName?: string;
contactPersonInfoTelephone?: string
}) => {
submitSimpleFormModal<EnterprisesUnitSaveOrUpdateParams & {
contactPersonInfoName?: string;
contactPersonInfoTelephone?: string
}>({
title: data.snowFlakeId ? `${data.name}】 信息编辑` : '新增企事业单位',
formOptions: {
name: {
type: 'input',
label: '单位名称',
required: true
},
administrativeDivisionCodes: {
type: 'cascader',
label: '行政区划',
required: true,
options: administrativeDivisionTree.value,
componentsProps: {
showSearch: true
}
},
address: {
type: 'inputTextArea',
label: '详细地址'
},
contactPersonInfoName: {
type: 'input',
label: '联系人名称'
},
contactPersonInfoTelephone: {
type: 'input',
label: '联系人电话'
},
remark: {
type: 'inputTextArea',
label: '备注'
}
},
formParams: data,
submit: async (params) => {
params.contactPersonInfo = {
name: params.contactPersonInfoName,
telephone: params.contactPersonInfoTelephone
}
const resp = await api.post('/enterprisesUnit/saveOrUpdate', params)
message.success(resp.message)
await _tableRef.value?.requestGetTableData()
}
})
}
const _tableRef = ref<ComponentExposed<typeof TableProMax>>(null)
const _columns: _TableProps['columns'] = [
{
dataIndex: 'name',
title: '名称'
}, {
dataIndex: 'contactPersonInfo',
title: '联系人',
customRender: ({text}) => text?.name + "/" + text.telephone
}, {
dataIndex: 'province',
title: '行政区划',
customRender: ({record}) => [record.provinceName, record.cityName, record.districtsName, record.streetName].filter(Boolean).join("/")
}, {
dataIndex: 'address',
title: '详细地址'
}, {
dataIndex: 'remark',
title: '备注'
}, {
dataIndex: 'createTime',
title: '创建时间'
}, {
dataIndex: 'opt',
title: '操作',
customRender: ({record}) => <a-space>
<a-button
class="btn-warn"
onClick={() => saveOrUpdateEnterprisesUnit({
snowFlakeId: record.snowFlakeId,
policeUnitId: record.policeUnitId,
name: record.name,
administrativeDivisionCodes: [record.province, record.city, record.districts, record.street].filter(Boolean),
address: record.address,
contactPersonInfoName: record.contactPersonInfo?.name,
contactPersonInfoTelephone: record.contactPersonInfo?.telephone,
remark: record.remark
})}
>编辑
</a-button>
</a-space>
}
]
const _reqApi: _TableProps["requestApi"] = (params) => {
(params as PageParams<EnterprisesUnitPagerQueryParams>).params.policeUnitId = policeUnitPagerVo.snowFlakeId
return api.post('/enterprisesUnit/pager', params)
}
Modal.info({
title: `${policeUnitPagerVo.name}】 管辖企事业单位`,
width: '80%',
content: () => <TableProMax
ref={_tableRef}
columns={_columns}
requestApi={_reqApi}
v-slots={{
tableHeader: (_) => {
return <a-space>
<a-button
class="btn-success"
onClick={() => saveOrUpdateEnterprisesUnit({
name: undefined,
policeUnitId: policeUnitPagerVo.snowFlakeId,
administrativeDivisionCodes: [policeUnitPagerVo.province, policeUnitPagerVo.city, policeUnitPagerVo.districts, policeUnitPagerVo.street].filter(Boolean)
})}
>新增
</a-button>
<a-button disabled>导入</a-button>
</a-space>
}
} as TableProMaxSlots<PoliceUnitPagerVo>}
/>
})
}
</script>
<style scoped lang="scss">