任务类型管理 问题修改 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">
<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">
<a-form-model-item label="栏目(不指定时为顶级)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pid">
<j-tree-select
ref="treeSelect"
placeholder="请选择父级节点"

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

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

@ -3,58 +3,158 @@
:title="title"
:width="width"
:visible="visible"
:confirmLoading="confirmLoading"
switchFullscreen
@ok="handleOk"
:okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
@cancel="handleCancel"
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>
</template>
<script>
import TaskTypeForm from './TaskTypeForm'
export default {
name: 'TaskTypeModal',
components: {
TaskTypeForm
},
data () {
return {
title:'',
width:800,
visible: false,
disableSubmit: false
}
},
methods: {
add () {
this.visible=true
this.$nextTick(()=>{
this.$refs.realForm.add();
})
import { httpAction } from '@/api/manage'
export default {
name: "TaskTypeModal",
components: {
},
data () {
return {
title:"操作",
width:800,
visible: false,
model:{
isShow:1,
},
edit (record) {
this.visible=true
this.$nextTick(()=>{
this.$refs.realForm.edit(record);
})
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
close () {
this.$emit('close');
this.visible = false;
wrapperCol: {
xs: { span: 24 },
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(){
this.$emit('ok');
this.visible = false;
url: {
add: "/taskType/taskType/add",
edit: "/taskType/taskType/edit",
},
handleCancel () {
this.close()
expandedRowKeys:[],
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>

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

@ -68,7 +68,7 @@ public class TaskType implements Serializable {
@Excel(name = "上级类型id", width = 15)
@ApiModelProperty(value = "上级类型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.extension.service.impl.ServiceImpl;
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.task.entity.Task;
import org.jeecg.modules.taskType.entity.TaskType;
import org.jeecg.modules.taskType.mapper.TaskTypeMapper;
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> mapList = new ArrayList<>();
for (TaskType data : dataList) {
String pidVal = data.getUpperId();
String pidVal = data.getPid();
//递归查询子节点的根节点
if (pidVal != null && !"0".equals(pidVal)) {
TaskType rootVal = this.getTreeRoot(pidVal);
@ -52,11 +50,11 @@ public class TaskTypeServiceImpl extends ServiceImpl<TaskTypeMapper, TaskType> i
public void addTaskType(TaskType taskType) {
//新增时设置hasChild为0
taskType.setHasChild(ICmsColumnService.NOCHILD);
if (oConvertUtils.isEmpty(taskType.getUpperId())) {
taskType.setUpperId(ICmsColumnService.ROOT_PID_VALUE);
if (oConvertUtils.isEmpty(taskType.getPid())) {
taskType.setPid(ICmsColumnService.ROOT_PID_VALUE);
} else {
//如果当前节点父ID不为空 则设置父节点的hasChildren 为1
TaskType parent = baseMapper.selectById(taskType.getUpperId());
TaskType parent = baseMapper.selectById(taskType.getPid());
if (parent != null && !"1".equals(parent.getHasChild())) {
parent.setHasChild("1");
baseMapper.updateById(parent);
@ -67,8 +65,8 @@ public class TaskTypeServiceImpl extends ServiceImpl<TaskTypeMapper, TaskType> i
private TaskType getTreeRoot(String pidVal) {
TaskType data = taskTypeMapper.selectById(pidVal);
if (data != null && !"0".equals(data.getUpperId())) {
return this.getTreeRoot(data.getUpperId());
if (data != null && !"0".equals(data.getPid())) {
return this.getTreeRoot(data.getPid());
} else {
return data;
}

Loading…
Cancel
Save