评估内容部分代码

This commit is contained in:
sk1551 2020-10-23 17:30:46 +08:00
parent 6c9880a58e
commit 3dbe1e5003
6 changed files with 48 additions and 41 deletions

View File

@ -23,14 +23,6 @@
@click="handleQuery" @click="handleQuery"
>搜索</el-button >搜索</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 <el-button
type="primary" type="primary"
icon="el-icon-plus" icon="el-icon-plus"
@ -39,30 +31,11 @@
v-hasPermi="['benyi:assessmentcontent:add']" v-hasPermi="['benyi:assessmentcontent:add']"
>新增</el-button >新增</el-button
> >
</el-col> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
<el-col :span="1.5"> >重置</el-button
<el-button
type="success"
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['benyi:assessmentcontent:edit']"
>修改</el-button
> >
</el-col> </el-form-item>
<el-col :span="1.5"> </el-form>
<el-button
type="danger"
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['benyi:assessmentcontent:remove']"
>删除</el-button
>
</el-col>
</el-row>
<el-table <el-table
v-loading="loading" v-loading="loading"
@ -72,7 +45,6 @@
default-expand-all default-expand-all
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }" :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
> >
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="评估名称" align="center" prop="name" /> <el-table-column label="评估名称" align="center" prop="name" />
<el-table-column <el-table-column
label="是否元素" label="是否元素"
@ -93,6 +65,7 @@
> >
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
v-if="scope.row.parentId !== 0"
size="mini" size="mini"
type="text" type="text"
icon="el-icon-edit" icon="el-icon-edit"
@ -101,6 +74,7 @@
>修改</el-button >修改</el-button
> >
<el-button <el-button
v-if="scope.row.parentId !== 0"
size="mini" size="mini"
type="text" type="text"
icon="el-icon-delete" icon="el-icon-delete"
@ -251,9 +225,7 @@ export default {
getList() { getList() {
this.loading = true; this.loading = true;
listAssessmentcontent(this.queryParams).then((response) => { listAssessmentcontent(this.queryParams).then((response) => {
// this.assessmentcontentList = response.rows;
this.assessmentcontentList = this.handleTree(response.rows, "id"); this.assessmentcontentList = this.handleTree(response.rows, "id");
//console.log(this.assessmentcontentList);
this.total = response.total; this.total = response.total;
this.loading = false; this.loading = false;
}); });
@ -263,7 +235,6 @@ export default {
getTreeselect() { getTreeselect() {
listAssessmentcontent(null).then((response) => { listAssessmentcontent(null).then((response) => {
this.parentidOptions = this.handleTree(response.rows, "id"); this.parentidOptions = this.handleTree(response.rows, "id");
console.log(this.parentidOptions);
}); });
}, },
@ -329,6 +300,7 @@ export default {
const id = row.id || this.ids; const id = row.id || this.ids;
getAssessmentcontent(id).then((response) => { getAssessmentcontent(id).then((response) => {
this.form = response.data; this.form = response.data;
this.form.parentId = response.data.parentId;
this.open = true; this.open = true;
this.title = "修改评估内容"; this.title = "修改评估内容";
}); });
@ -359,9 +331,8 @@ export default {
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm( this.$confirm(
'是否确认删除评估内容的数据项?', '是否确认删除名称为"' + row.name + '"的数据项?',
"警告", "警告",
{ {
confirmButtonText: "确定", confirmButtonText: "确定",
@ -370,7 +341,7 @@ export default {
} }
) )
.then(function () { .then(function () {
return delAssessmentcontent(ids); return delAssessmentcontent(row.id);
}) })
.then(() => { .then(() => {
this.getList(); this.getList();

View File

@ -113,9 +113,12 @@ public class ByAssessmentcontentController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('benyi:assessmentcontent:remove')") @PreAuthorize("@ss.hasPermi('benyi:assessmentcontent:remove')")
@Log(title = "评估内容", businessType = BusinessType.DELETE) @Log(title = "评估内容", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{id}")
public AjaxResult remove(@PathVariable Long[] ids) public AjaxResult remove(@PathVariable Long id)
{ {
return toAjax(byAssessmentcontentService.deleteByAssessmentcontentByIds(ids)); if (byAssessmentcontentService.hasChildByAssessmentcontentId(id)) {
return AjaxResult.error("存在下级内容,不允许删除");
}
return toAjax(byAssessmentcontentService.deleteByAssessmentcontentById(id));
} }
} }

View File

@ -58,4 +58,12 @@ public interface ByAssessmentcontentMapper {
* @return 结果 * @return 结果
*/ */
public int deleteByAssessmentcontentByIds(Long[] ids); public int deleteByAssessmentcontentByIds(Long[] ids);
/**
* 是否存在子节点
*
* @param id 内容ID
* @return 结果
*/
public int hasChildByAssessmentcontentId(Long id);
} }

View File

@ -60,6 +60,14 @@ public interface IByAssessmentcontentService {
*/ */
public int updateByAssessmentcontent(ByAssessmentcontent byAssessmentcontent); public int updateByAssessmentcontent(ByAssessmentcontent byAssessmentcontent);
/**
* 是否存在内容子节点
*
* @param id 部门ID
* @return 结果
*/
public boolean hasChildByAssessmentcontentId(Long id);
/** /**
* 批量删除评估内容 * 批量删除评估内容
* *

View File

@ -108,6 +108,18 @@ public class ByAssessmentcontentServiceImpl implements IByAssessmentcontentServi
return byAssessmentcontentMapper.updateByAssessmentcontent(byAssessmentcontent); return byAssessmentcontentMapper.updateByAssessmentcontent(byAssessmentcontent);
} }
/**
* 是否存在子节点
*
* @param id 内容ID
* @return 结果
*/
@Override
public boolean hasChildByAssessmentcontentId(Long id) {
int result = byAssessmentcontentMapper.hasChildByAssessmentcontentId(id);
return result > 0 ? true : false;
}
/** /**
* 批量删除评估内容 * 批量删除评估内容
* *

View File

@ -33,6 +33,11 @@
where id = #{id} where id = #{id}
</select> </select>
<select id="hasChildByAssessmentcontentId" parameterType="Long" resultType="int">
select count(1) from by_assessmentcontent
where parentId = #{id}
</select>
<insert id="insertByAssessmentcontent" parameterType="ByAssessmentcontent" useGeneratedKeys="true" keyProperty="id"> <insert id="insertByAssessmentcontent" parameterType="ByAssessmentcontent" useGeneratedKeys="true" keyProperty="id">
insert into by_assessmentcontent insert into by_assessmentcontent
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">