任务类型管理 问题修改 6.20

master
zhc077 1 year ago
parent 986baeb3d7
commit cc41bcc9e9
  1. 2
      ant-design-vue-jeecg/src/views/cms/admin/modules/CmsColumnModal.vue
  2. 6
      ant-design-vue-jeecg/src/views/taskType/TaskTypeList.vue
  3. 230
      ant-design-vue-jeecg/src/views/taskType/modules/TaskTypeForm.vue
  4. 174
      ant-design-vue-jeecg/src/views/taskType/modules/TaskTypeModal.vue
  5. 16
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/taskType/controller/TaskTypeController.java
  6. 2
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/taskType/entity/TaskType.java
  7. 14
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/taskType/service/impl/TaskTypeServiceImpl.java

@ -16,7 +16,7 @@
<a-form-model-item label="显示" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isShow"> <a-form-model-item label="显示" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isShow">
<j-dict-select-tag type="radio" v-model="model.isShow" dictCode="isShow" placeholder="请选择显示" /> <j-dict-select-tag type="radio" v-model="model.isShow" dictCode="isShow" placeholder="请选择显示" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="栏目" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pid"> <a-form-model-item label="栏目(不指定时为顶级)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pid">
<j-tree-select <j-tree-select
ref="treeSelect" ref="treeSelect"
placeholder="请选择父级节点" placeholder="请选择父级节点"

@ -105,8 +105,8 @@ export default {
}, },
// { // {
// title: '', // title: '',
// align: "upperId", // align: "pid",
// dataIndex: 'upperId_dictText' // dataIndex: 'pid_dictText'
// }, // },
{ {
title: '创建人', title: '创建人',
@ -141,7 +141,7 @@ export default {
superFieldList: [], superFieldList: [],
expandedRowKeys: [], expandedRowKeys: [],
hasChildrenField: "hasChild", hasChildrenField: "hasChild",
pidField: "upperId", pidField: "pid",
loadParent: false, loadParent: false,
} }
}, },

@ -1,121 +1,121 @@
<template> <!--<template>-->
<a-spin :spinning="confirmLoading"> <!-- <a-spin :spinning="confirmLoading">-->
<j-form-container :disabled="formDisabled"> <!-- <j-form-container :disabled="formDisabled">-->
<a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail"> <!-- <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">-->
<a-row> <!-- <a-row>-->
<a-col :span="80"> <!-- <a-col :span="80">-->
<a-form-model-item label="类型名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="typeName"> <!-- <a-form-model-item label="类型名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="typeName">-->
<a-input v-model="model.typeName" placeholder="请输入类型名称"></a-input> <!-- <a-input v-model="model.typeName" placeholder="请输入类型名称"></a-input>-->
</a-form-model-item>
</a-col>
<!-- <a-col :span="24">-->
<!-- <a-form-model-item label="上级类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="upperId">-->
<!-- <j-tree-select-->
<!-- ref="treeSelect"-->
<!-- placeholder="请选择上级类型"-->
<!-- v-model="model.upperId"-->
<!-- dict="task_type,type_name,id"-->
<!-- pidField="upper_id"-->
<!-- pidValue=""-->
<!-- >-->
<!-- </j-tree-select>-->
<!-- </a-form-model-item>--> <!-- </a-form-model-item>-->
<!-- </a-col>--> <!-- </a-col>-->
<a-col :span="80"> <!--&lt;!&ndash; <a-col :span="24">&ndash;&gt;-->
<a-form-model-item label="所属类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="upperId"> <!--&lt;!&ndash; <a-form-model-item label="上级类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="upperId">&ndash;&gt;-->
<j-dict-select-tag type="list" v-model="model.upperId" dictCode="task_type,type_name,id" <!--&lt;!&ndash; <j-tree-select&ndash;&gt;-->
placeholder="请选择所属类型"/> <!--&lt;!&ndash; ref="treeSelect"&ndash;&gt;-->
</a-form-model-item> <!--&lt;!&ndash; placeholder="请选择上级类型"&ndash;&gt;-->
</a-col> <!--&lt;!&ndash; v-model="model.upperId"&ndash;&gt;-->
</a-row> <!--&lt;!&ndash; dict="task_type,type_name,id"&ndash;&gt;-->
</a-form-model> <!--&lt;!&ndash; pidField="upper_id"&ndash;&gt;-->
</j-form-container> <!--&lt;!&ndash; pidValue=""&ndash;&gt;-->
</a-spin> <!--&lt;!&ndash; >&ndash;&gt;-->
</template> <!--&lt;!&ndash; </j-tree-select>&ndash;&gt;-->
<!--&lt;!&ndash; </a-form-model-item>&ndash;&gt;-->
<!--&lt;!&ndash; </a-col>&ndash;&gt;-->
<!-- <a-col :span="80">-->
<!-- <a-form-model-item label="所属类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="upperId">-->
<!-- <j-dict-select-tag type="list" v-model="model.upperId" dictCode="task_type,type_name,id"-->
<!-- placeholder="请选择所属类型"/>-->
<!-- </a-form-model-item>-->
<!-- </a-col>-->
<!-- </a-row>-->
<!-- </a-form-model>-->
<!-- </j-form-container>-->
<!-- </a-spin>-->
<!--</template>-->
<script> <!--<script>-->
import {httpAction, getAction} from '@api/manage' <!--import {httpAction, getAction} from '@api/manage'-->
import {validateDuplicateValue} from '@/utils/util' <!--import {validateDuplicateValue} from '@/utils/util'-->
export default { <!--export default {-->
name: 'TaskTypeForm', <!-- name: 'TaskTypeForm',-->
components: {}, <!-- components: {},-->
props: { <!-- props: {-->
// <!-- //-->
disabled: { <!-- disabled: {-->
type: Boolean, <!-- type: Boolean,-->
default: false, <!-- default: false,-->
required: false <!-- required: false-->
} <!-- }-->
}, <!-- },-->
data() { <!-- data() {-->
return { <!-- return {-->
model: {}, <!-- model: {},-->
labelCol: { <!-- labelCol: {-->
xs: {span: 24}, <!-- xs: {span: 24},-->
sm: {span: 5}, <!-- sm: {span: 5},-->
}, <!-- },-->
wrapperCol: { <!-- wrapperCol: {-->
xs: {span: 24}, <!-- xs: {span: 24},-->
sm: {span: 16}, <!-- sm: {span: 16},-->
}, <!-- },-->
confirmLoading: false, <!-- confirmLoading: false,-->
validatorRules: {}, <!-- validatorRules: {},-->
url: { <!-- url: {-->
add: "/taskType/taskType/add", <!-- add: "/taskType/taskType/add",-->
edit: "/taskType/taskType/edit", <!-- edit: "/taskType/taskType/edit",-->
queryById: "/taskType/taskType/queryById" <!-- queryById: "/taskType/taskType/queryById"-->
} <!-- }-->
} <!-- }-->
}, <!-- },-->
computed: { <!-- computed: {-->
formDisabled() { <!-- formDisabled() {-->
return this.disabled <!-- return this.disabled-->
}, <!-- },-->
}, <!-- },-->
created() { <!-- created() {-->
//model <!-- //model-->
this.modelDefault = JSON.parse(JSON.stringify(this.model)); <!-- this.modelDefault = JSON.parse(JSON.stringify(this.model));-->
}, <!-- },-->
methods: { <!-- methods: {-->
add() { <!-- add() {-->
this.edit(this.modelDefault); <!-- this.edit(this.modelDefault);-->
}, <!-- },-->
edit(record) { <!-- edit(record) {-->
this.model = Object.assign({}, record); <!-- this.model = Object.assign({}, record);-->
// console.log('this.model',this.model) <!-- // console.log('this.model',this.model)-->
this.visible = true; <!-- this.visible = true;-->
}, <!-- },-->
submitForm() { <!-- submitForm() {-->
const that = this; <!-- const that = this;-->
// <!-- // -->
this.$refs.form.validate(valid => { <!-- this.$refs.form.validate(valid => {-->
if (valid) { <!-- if (valid) {-->
that.confirmLoading = true; <!-- that.confirmLoading = true;-->
let httpurl = ''; <!-- let httpurl = '';-->
let method = ''; <!-- let method = '';-->
if (!this.model.id) { <!-- if (!this.model.id) {-->
httpurl += this.url.add; <!-- httpurl += this.url.add;-->
method = 'post'; <!-- method = 'post';-->
} else { <!-- } else {-->
httpurl += this.url.edit; <!-- httpurl += this.url.edit;-->
method = 'put'; <!-- method = 'put';-->
} <!-- }-->
httpAction(httpurl, this.model, method).then((res) => { <!-- httpAction(httpurl, this.model, method).then((res) => {-->
if (res.success) { <!-- if (res.success) {-->
that.$message.success(res.message); <!-- that.$message.success(res.message);-->
that.$emit('ok'); <!-- that.$emit('ok');-->
} else { <!-- } else {-->
that.$message.warning(res.message); <!-- that.$message.warning(res.message);-->
} <!-- }-->
}).finally(() => { <!-- }).finally(() => {-->
that.confirmLoading = false; <!-- that.confirmLoading = false;-->
}) <!-- })-->
} <!-- }-->
}) <!-- })-->
}, <!-- },-->
} <!-- }-->
} <!--}-->
</script> <!--</script>-->

@ -3,58 +3,158 @@
:title="title" :title="title"
:width="width" :width="width"
:visible="visible" :visible="visible"
:confirmLoading="confirmLoading"
switchFullscreen switchFullscreen
@ok="handleOk" @ok="handleOk"
:okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
@cancel="handleCancel" @cancel="handleCancel"
cancelText="关闭"> cancelText="关闭">
<task-type-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit"></task-type-form> <a-spin :spinning="confirmLoading">
<a-form-model ref="form" :model="model" :rules="validatorRules">
<a-form-model-item label="名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="typeName">
<a-input v-model="model.typeName" placeholder="请输入名称" ></a-input>
</a-form-model-item>
<!-- <a-form-model-item label="显示" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isShow">-->
<!-- <j-dict-select-tag type="radio" v-model="model.isShow" dictCode="isShow" placeholder="请选择显示" />-->
<!-- </a-form-model-item>-->
<a-form-model-item label="所属类型(不指定时为顶级)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pid">
<j-tree-select
ref="treeSelect"
placeholder="请选择父级节点"
v-model="model.pid"
dict="task_type,type_name,id"
pidField="pid"
>
</j-tree-select>
</a-form-model-item>
</a-form-model>
</a-spin>
</j-modal> </j-modal>
</template> </template>
<script> <script>
import TaskTypeForm from './TaskTypeForm' import { httpAction } from '@/api/manage'
export default { export default {
name: 'TaskTypeModal', name: "TaskTypeModal",
components: { components: {
TaskTypeForm },
}, data () {
data () { return {
return { title:"操作",
title:'', width:800,
width:800, visible: false,
visible: false, model:{
disableSubmit: false isShow:1,
}
},
methods: {
add () {
this.visible=true
this.$nextTick(()=>{
this.$refs.realForm.add();
})
}, },
edit (record) { labelCol: {
this.visible=true xs: { span: 24 },
this.$nextTick(()=>{ sm: { span: 5 },
this.$refs.realForm.edit(record);
})
}, },
close () { wrapperCol: {
this.$emit('close'); xs: { span: 24 },
this.visible = false; sm: { span: 16 },
}, },
handleOk () {
this.$refs.realForm.submitForm(); confirmLoading: false,
validatorRules: {
typeName: [
{required: true, message: "类型名称不能为空"},
],
// sort: [
// {required: true, message: ""},
// {pattern: /^[0-9]{0,100}$/, message: ''}
// ],
}, },
submitCallback(){ url: {
this.$emit('ok'); add: "/taskType/taskType/add",
this.visible = false; edit: "/taskType/taskType/edit",
}, },
handleCancel () { expandedRowKeys:[],
this.close() pidField:"pid"
}
},
created () {
//model
this.modelDefault = JSON.parse(JSON.stringify(this.model));
},
methods: {
add (obj) {
this.modelDefault.pid=''
this.edit(Object.assign(this.modelDefault , obj));
},
edit (record) {
this.model = Object.assign({}, record);
this.visible = true;
},
close () {
this.$emit('close');
this.visible = false;
this.$refs.form.clearValidate()
},
handleOk () {
const that = this;
//
this.$refs.form.validate(valid => {
if (valid) {
that.confirmLoading = true;
let httpurl = '';
let method = '';
if(!this.model.id){
httpurl+=this.url.add;
method = 'post';
}else{
httpurl+=this.url.edit;
method = 'put';
}
if(this.model.id && this.model.id === this.model[this.pidField]){
that.$message.warning("父级节点不能选择自己");
that.confirmLoading = false;
return;
}
httpAction(httpurl,this.model,method).then((res)=>{
if(res.success){
that.$message.success(res.message);
this.$emit('ok');
}else{
that.$message.warning(res.message);
}
}).finally(() => {
that.confirmLoading = false;
that.close();
})
}else{
return false
}
})
},
handleCancel () {
this.close()
},
submitSuccess(formData,flag){
if(!formData.id){
let treeData = this.$refs.treeSelect.getCurrTreeData()
this.expandedRowKeys=[]
this.getExpandKeysByPid(formData[this.pidField],treeData,treeData)
this.$emit('ok',formData,this.expandedRowKeys.reverse());
}else{
this.$emit('ok',formData,flag);
}
},
getExpandKeysByPid(pid,arr,all){
if(pid && arr && arr.length>0){
for(let i=0;i<arr.length;i++){
if(arr[i].key==pid){
this.expandedRowKeys.push(arr[i].key)
this.getExpandKeysByPid(arr[i]['parentId'],all,all)
}else{
this.getExpandKeysByPid(pid,arr[i].children,all)
}
}
} }
} }
} }
}
</script> </script>

@ -60,14 +60,14 @@ public class TaskTypeController extends JeecgController<TaskType, ITaskTypeServi
//// Collections.sort(records, Comparator.comparingInt(TaskType::getSort)); //// Collections.sort(records, Comparator.comparingInt(TaskType::getSort));
return Result.OK(pageList); return Result.OK(pageList);
} else { } else {
String parentId = taskType.getUpperId(); String parentId = taskType.getPid();
if (oConvertUtils.isEmpty(parentId)) { if (oConvertUtils.isEmpty(parentId)) {
parentId = "0"; parentId = "0";
} }
taskType.setUpperId(null); taskType.setPid(null);
QueryWrapper<TaskType> queryWrapper = QueryGenerator.initQueryWrapper(taskType, req.getParameterMap()); QueryWrapper<TaskType> queryWrapper = QueryGenerator.initQueryWrapper(taskType, req.getParameterMap());
// 使用 eq 防止模糊查询 // 使用 eq 防止模糊查询
queryWrapper.eq("upper_id", parentId); queryWrapper.eq("pid", parentId);
// queryWrapper.last(" ,sort asc "); // queryWrapper.last(" ,sort asc ");
Page<TaskType> page = new Page<TaskType>(pageNo, pageSize); Page<TaskType> page = new Page<TaskType>(pageNo, pageSize);
IPage<TaskType> pageList = taskTypeService.page(page, queryWrapper); IPage<TaskType> pageList = taskTypeService.page(page, queryWrapper);
@ -109,7 +109,7 @@ public class TaskTypeController extends JeecgController<TaskType, ITaskTypeServi
try { try {
QueryWrapper<TaskType> queryWrapper = new QueryWrapper<>(); QueryWrapper<TaskType> queryWrapper = new QueryWrapper<>();
List<String> parentIdList = Arrays.asList(parentIds.split(",")); List<String> parentIdList = Arrays.asList(parentIds.split(","));
queryWrapper.in("upper_id", parentIdList); queryWrapper.in("pid", parentIdList);
List<TaskType> list = taskTypeService.list(queryWrapper); List<TaskType> list = taskTypeService.list(queryWrapper);
IPage<TaskType> pageList = new Page<>(1, 10, list.size()); IPage<TaskType> pageList = new Page<>(1, 10, list.size());
pageList.setRecords(list); pageList.setRecords(list);
@ -191,10 +191,10 @@ public class TaskTypeController extends JeecgController<TaskType, ITaskTypeServi
@DeleteMapping(value = "/delete") @DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name = "id", required = true) String id) { public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
TaskType cmsColumn = taskTypeService.getById(id); TaskType cmsColumn = taskTypeService.getById(id);
if (StringUtils.equals(ADMIN_COLUMN_KEY, cmsColumn.getId())) { // if (StringUtils.equals(ADMIN_COLUMN_KEY, cmsColumn.getId())) {
throw new JeecgBootException("预留类型不可删除"); // throw new JeecgBootException("预留类型不可删除");
} // }
int count = taskTypeService.count(new LambdaQueryWrapper<TaskType>().eq(TaskType::getUpperId, cmsColumn.getId())); int count = taskTypeService.count(new LambdaQueryWrapper<TaskType>().eq(TaskType::getPid, cmsColumn.getId()));
if (count > 0) { if (count > 0) {
throw new JeecgBootException("存在子类型暂不可删除"); throw new JeecgBootException("存在子类型暂不可删除");
} }

@ -68,7 +68,7 @@ public class TaskType implements Serializable {
@Excel(name = "上级类型id", width = 15) @Excel(name = "上级类型id", width = 15)
@ApiModelProperty(value = "上级类型id") @ApiModelProperty(value = "上级类型id")
@Dict(dictTable = "task_type", dicText = "type_name",dicCode = "id") @Dict(dictTable = "task_type", dicText = "type_name",dicCode = "id")
private String upperId; private String pid;
/** /**
* 类型名称 * 类型名称
*/ */

@ -3,9 +3,7 @@ package org.jeecg.modules.taskType.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.util.oConvertUtils; import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.cms.admin.entity.CmsColumn;
import org.jeecg.modules.cms.admin.service.ICmsColumnService; import org.jeecg.modules.cms.admin.service.ICmsColumnService;
import org.jeecg.modules.task.entity.Task;
import org.jeecg.modules.taskType.entity.TaskType; import org.jeecg.modules.taskType.entity.TaskType;
import org.jeecg.modules.taskType.mapper.TaskTypeMapper; import org.jeecg.modules.taskType.mapper.TaskTypeMapper;
import org.jeecg.modules.taskType.service.ITaskTypeService; import org.jeecg.modules.taskType.service.ITaskTypeService;
@ -32,7 +30,7 @@ public class TaskTypeServiceImpl extends ServiceImpl<TaskTypeMapper, TaskType> i
List<TaskType> dataList = baseMapper.selectList(queryWrapper); List<TaskType> dataList = baseMapper.selectList(queryWrapper);
List<TaskType> mapList = new ArrayList<>(); List<TaskType> mapList = new ArrayList<>();
for (TaskType data : dataList) { for (TaskType data : dataList) {
String pidVal = data.getUpperId(); String pidVal = data.getPid();
//递归查询子节点的根节点 //递归查询子节点的根节点
if (pidVal != null && !"0".equals(pidVal)) { if (pidVal != null && !"0".equals(pidVal)) {
TaskType rootVal = this.getTreeRoot(pidVal); TaskType rootVal = this.getTreeRoot(pidVal);
@ -52,11 +50,11 @@ public class TaskTypeServiceImpl extends ServiceImpl<TaskTypeMapper, TaskType> i
public void addTaskType(TaskType taskType) { public void addTaskType(TaskType taskType) {
//新增时设置hasChild为0 //新增时设置hasChild为0
taskType.setHasChild(ICmsColumnService.NOCHILD); taskType.setHasChild(ICmsColumnService.NOCHILD);
if (oConvertUtils.isEmpty(taskType.getUpperId())) { if (oConvertUtils.isEmpty(taskType.getPid())) {
taskType.setUpperId(ICmsColumnService.ROOT_PID_VALUE); taskType.setPid(ICmsColumnService.ROOT_PID_VALUE);
} else { } else {
//如果当前节点父ID不为空 则设置父节点的hasChildren 为1 //如果当前节点父ID不为空 则设置父节点的hasChildren 为1
TaskType parent = baseMapper.selectById(taskType.getUpperId()); TaskType parent = baseMapper.selectById(taskType.getPid());
if (parent != null && !"1".equals(parent.getHasChild())) { if (parent != null && !"1".equals(parent.getHasChild())) {
parent.setHasChild("1"); parent.setHasChild("1");
baseMapper.updateById(parent); baseMapper.updateById(parent);
@ -67,8 +65,8 @@ public class TaskTypeServiceImpl extends ServiceImpl<TaskTypeMapper, TaskType> i
private TaskType getTreeRoot(String pidVal) { private TaskType getTreeRoot(String pidVal) {
TaskType data = taskTypeMapper.selectById(pidVal); TaskType data = taskTypeMapper.selectById(pidVal);
if (data != null && !"0".equals(data.getUpperId())) { if (data != null && !"0".equals(data.getPid())) {
return this.getTreeRoot(data.getUpperId()); return this.getTreeRoot(data.getPid());
} else { } else {
return data; return data;
} }

Loading…
Cancel
Save