Commit 3e312830 authored by 蒋凌峰's avatar 蒋凌峰 😉

提交

parent 8d8172b8
package com.ruoyi.system.controller;
package com.ruoyi.web.controller.finance;
import ch.qos.logback.core.pattern.ConverterUtil;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.EmptyUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.FncSubjectType;
import com.ruoyi.system.domain.vo.FncSubjectTypeVo;
......@@ -11,12 +15,14 @@ import com.ruoyi.system.service.IFncSubjectTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.core.page.TableDataInfo;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
......@@ -48,6 +54,50 @@ public class FncSubjectTypeController extends BaseController {
return AjaxResult.success("查询成功", fncSubjectTypeService.queryAll(entity));
}
/**
* 查询部门列表(排除节点)
*/
@PreAuthorize("@ss.hasPermi('finance:subjectType:list')")
@GetMapping("/list/exclude/{id}")
public AjaxResult excludeChild(@PathVariable(value = "id", required = false) Long id)
{
List<FncSubjectType> list = fncSubjectTypeService.list();
List<Long> ids = new ArrayList<>();
//递归获取
if (EmptyUtil.isNotEmpty(list) && EmptyUtil.isNotEmpty(id)) {
list.stream().filter(item -> item.getParentId() == 0).forEach(item -> {
if (item.getSubjectTypeId().equals(id)) {
return;
} else {
list.stream().filter(child -> child.getParentId() == item.getSubjectTypeId()).forEach(child -> {
ids.add(child.getSubjectTypeId());
excludeChild(list,child,id,ids);
});
}
});
}
list.removeIf(d -> d.getSubjectTypeId().intValue() == id || ids.contains(d.getSubjectTypeId()));
return success(list);
}
public void excludeChild(List<FncSubjectType> list,FncSubjectType entity, Long id, List<Long> ids) {
if (EmptyUtil.isNotEmpty(entity)) {
if (entity.getSubjectTypeId().equals(id)) {
return;
} else {
list.stream().filter(item -> item.getParentId() == entity.getSubjectTypeId()).forEach(child -> {
ids.add(child.getSubjectTypeId());
excludeChild(list,child,id,ids);
});
}
}
}
@ApiOperation("导出科目类别列表")
@PreAuthorize("@ss.hasPermi('finance:subjectType:export')")
@Log(title = "科目类别", businessType = BusinessType.EXPORT)
......
package com.ruoyi.common.utils;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 一站式健全判空工具类(可判空 集合、字符串、对象 等各种特殊情况)
*
* @author daizhichao
* @date 2021/9/7
*/
public class EmptyUtil {
/**
* 对象是否为空
*
* @param o String,List,Map,Object[],int[],long[]
* @return
*/
@SuppressWarnings("rawtypes")
public static boolean isEmpty(Object o) {
if (o == null) {
return true;
}
if (o instanceof String) {
if ("".equals(o.toString().trim())) {
return true;
}
} else if (o instanceof List) {
if (((List) o).size() == 0) {
return true;
}
} else if (o instanceof Map) {
if (((Map) o).size() == 0) {
return true;
}
} else if (o instanceof Set) {
if (((Set) o).size() == 0) {
return true;
}
} else if (o instanceof Object[]) {
if (((Object[]) o).length == 0) {
return true;
}
} else if (o instanceof int[]) {
if (((int[]) o).length == 0) {
return true;
}
} else if (o instanceof long[]) {
if (((long[]) o).length == 0) {
return true;
}
}
return false;
}
public static boolean isEmpty(Object... o) {
boolean empty = false;
for (Object o1 : o) {
if (isEmpty(o1)) {
empty = true;
break;
}
}
return empty;
}
/**
* 对象是否不为空
*
* @param o String,List,Map,Object[],int[],long[]
* @return
*/
public static boolean isNotEmpty(Object o) {
return !isEmpty(o);
}
/**
* 对象组中是否存在 Empty Object
*
* @param os 对象组
* @return
*/
public static boolean isOneEmpty(Object... os) {
for (Object o : os) {
return isEmpty(o);
}
return false;
}
/**
* 对象组中是否全是 Empty Object
*
* @param os
* @return
*/
public static boolean isAllEmpty(Object... os) {
for (Object o : os) {
if (!isEmpty(o)) {
return false;
}
}
return true;
}
}
package com.ruoyi.system.domain;
import com.baomidou.mybatisplus.annotation.*;
import com.ruoyi.common.annotation.Excel;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
......@@ -24,6 +23,7 @@ public class FncSubjectType extends BaseEntity {
/**
* 科目类别id
*/
@TableId( value = "subject_type_id", type = IdType.AUTO)
private Long subjectTypeId;
/**
......@@ -45,6 +45,8 @@ public class FncSubjectType extends BaseEntity {
private Integer orderNum;
// @TableLogic(value = "1",delval = "2")
@TableField(fill = FieldFill.INSERT)
private Integer deleteStatus;
}
......@@ -20,7 +20,7 @@
<select id="queryById" resultType="com.ruoyi.system.domain.vo.FncSubjectTypeVo">
<include refid="querySql"/>
and A.id = #{id}
and A.subject_type_id = #{id}
</select>
<sql id="allField">
......
......@@ -8,11 +8,27 @@ export function listSubjectType(query) {
params: query
})
}
// 查询上级科目类别列表(排除节点)
export function listExcludeChild(id) {
return request({
url: '/finance/subjectType/list/exclude/' + id,
method: 'get'
})
}
// 查询科目类别所有列表
export function listAllSubjectType(query) {
return request({
url: '/finance/subjectType/listAll',
method: 'get',
params: query
})
}
// 查询科目类别详细
export function getSubjectType(subjectTypeId) {
return request({
url: '/finance/subjectType/' + subjectTypeId,
url: '/finance/subjectType/getInfo/' + subjectTypeId,
method: 'get'
})
}
......@@ -29,8 +45,8 @@ export function addSubjectType(data) {
// 修改科目类别
export function updateSubjectType(data) {
return request({
url: '/finance/subjectType/update',
method: 'put',
url: '/finance/subjectType/edit',
method: 'post',
data: data
})
}
......@@ -38,7 +54,7 @@ export function updateSubjectType(data) {
// 删除科目类别
export function delSubjectType(subjectTypeId) {
return request({
url: '/finance/subjectType/' + subjectTypeId,
method: 'delete'
url: '/finance/subjectType/remove/' + subjectTypeId,
method: 'get'
})
}
......@@ -167,7 +167,9 @@ export function handleTree(data, id, parentId, children) {
var childrenListMap = {};
var nodeIds = {};
var tree = [];
if(!data) {
return [];
}
for (let d of data) {
let parentId = d[config.parentId];
if (childrenListMap[parentId] == null) {
......
......@@ -2,21 +2,12 @@
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
<el-form-item label="部门名称" prop="deptName">
<el-input
v-model="queryParams.deptName"
placeholder="请输入部门名称"
clearable
@keyup.enter.native="handleQuery"
/>
<el-input v-model="queryParams.deptName" placeholder="请输入部门名称" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="部门状态" clearable>
<el-option
v-for="dict in dict.type.sys_normal_disable"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
<el-option v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.label"
:value="dict.value" />
</el-select>
</el-form-item>
<el-form-item>
......@@ -27,40 +18,22 @@
<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:dept:add']"
>新增</el-button>
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
v-hasPermi="['system:dept:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-sort"
size="mini"
@click="toggleExpandAll"
>展开/折叠</el-button>
<el-button type="info" plain icon="el-icon-sort" size="mini" @click="toggleExpandAll">展开/折叠</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table
v-if="refreshTable"
v-loading="loading"
:data="deptList"
row-key="deptId"
:default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
<el-table v-if="refreshTable" v-loading="loading" :data="deptList" row-key="deptId"
:default-expand-all="isExpandAll" :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
<el-table-column prop="deptName" label="部门名称" width="260"></el-table-column>
<el-table-column prop="orderNum" label="排序" width="200"></el-table-column>
<el-table-column prop="status" label="状态" width="100">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="200">
......@@ -70,28 +43,12 @@
</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:dept:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-plus"
@click="handleAdd(scope.row)"
v-hasPermi="['system:dept:add']"
>新增</el-button>
<el-button
v-if="scope.row.parentId != 0"
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:dept:remove']"
>删除</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
v-hasPermi="['system:dept:edit']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-plus" @click="handleAdd(scope.row)"
v-hasPermi="['system:dept:add']">新增</el-button>
<el-button v-if="scope.row.parentId != 0" size="mini" type="text" icon="el-icon-delete"
@click="handleDelete(scope.row)" v-hasPermi="['system:dept:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
......@@ -102,7 +59,8 @@
<el-row>
<el-col :span="24" v-if="form.parentId !== 0">
<el-form-item label="上级部门" prop="parentId">
<treeselect v-model="form.parentId" :options="deptOptions" :normalizer="normalizer" placeholder="选择上级部门" />
<treeselect v-model="form.parentId" :options="deptOptions" :normalizer="normalizer"
placeholder="选择上级部门" />
</el-form-item>
</el-col>
</el-row>
......@@ -139,11 +97,8 @@
<el-col :span="12">
<el-form-item label="部门状态">
<el-radio-group v-model="form.status">
<el-radio
v-for="dict in dict.type.sys_normal_disable"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
<el-radio v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.value">
{{ dict.label }}</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
......@@ -307,7 +262,7 @@ export default {
});
},
/** 提交按钮 */
submitForm: function() {
submitForm: function () {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.deptId != undefined) {
......@@ -328,12 +283,12 @@ export default {
},
/** 删除按钮操作 */
handleDelete(row) {
this.$modal.confirm('是否确认删除名称为"' + row.deptName + '"的数据项?').then(function() {
this.$modal.confirm('是否确认删除名称为"' + row.deptName + '"的数据项?').then(function () {
return delDept(row.deptId);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
}).catch(() => { });
}
}
};
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment