组织机构管理-单位管理:新增上级单位修改功能,新增单位等级修改功能;允许三级机构,四级机构修改机构信息;
This commit is contained in:
@@ -33,8 +33,14 @@ public class SysActivityUnitListener implements SysCommonDataChange {
|
|||||||
case UPDATE -> {
|
case UPDATE -> {
|
||||||
Sys_unit sys_unit = dao.fetch(Sys_unit.class, bizId);
|
Sys_unit sys_unit = dao.fetch(Sys_unit.class, bizId);
|
||||||
ActivityBasicUnit basicUnit = dao.fetch(ActivityBasicUnit.class, Cnd.where("id", "=", sys_unit.getId()));
|
ActivityBasicUnit basicUnit = dao.fetch(ActivityBasicUnit.class, Cnd.where("id", "=", sys_unit.getId()));
|
||||||
BeanUtil.copyProperties(sys_unit, basicUnit, "id");
|
if (basicUnit == null) {
|
||||||
dao.update(basicUnit);
|
// 历史拉取的深层级机构可能未同步到活动单位表,编辑时补齐数据
|
||||||
|
basicUnit = BeanUtil.copyProperties(sys_unit, ActivityBasicUnit.class);
|
||||||
|
dao.insert(basicUnit);
|
||||||
|
} else {
|
||||||
|
BeanUtil.copyProperties(sys_unit, basicUnit, "id");
|
||||||
|
dao.update(basicUnit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case DELETE -> {
|
case DELETE -> {
|
||||||
dao.clear(ActivityBasicUnit.class, Cnd.where("id", "=", bizId));
|
dao.clear(ActivityBasicUnit.class, Cnd.where("id", "=", bizId));
|
||||||
|
|||||||
+91
-2
@@ -45,8 +45,10 @@ import java.io.File;
|
|||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,17 +140,39 @@ public class SysUnitController2 {
|
|||||||
@RequiresPermissions("sys.manager.unit")
|
@RequiresPermissions("sys.manager.unit")
|
||||||
@Aop(TransAop.READ_COMMITTED)
|
@Aop(TransAop.READ_COMMITTED)
|
||||||
public Object doAdd(Sys_unit sys_unit) {
|
public Object doAdd(Sys_unit sys_unit) {
|
||||||
|
if (Strings.isBlank(sys_unit.getUnitcode())) {
|
||||||
|
return Result.error("单位代码不能为空");
|
||||||
|
}
|
||||||
sys_unit.setId(sys_unit.getUnitcode());
|
sys_unit.setId(sys_unit.getUnitcode());
|
||||||
|
if (Strings.isBlank(sys_unit.getParentId())) {
|
||||||
|
return Result.error("上级单位不能为空");
|
||||||
|
}
|
||||||
if (sysUnitService.count(Cnd.where("unitcode", "=", sys_unit.getUnitcode())) > 0) {
|
if (sysUnitService.count(Cnd.where("unitcode", "=", sys_unit.getUnitcode())) > 0) {
|
||||||
return Result.error("单位代码已存在");
|
return Result.error("单位代码已存在");
|
||||||
}
|
}
|
||||||
|
Sys_unit parentUnit = sysUnitService.fetch(sys_unit.getParentId());
|
||||||
|
if (parentUnit == null) {
|
||||||
|
return Result.error("上级单位不存在");
|
||||||
|
}
|
||||||
|
int calculatedUnitLevel = calculateUnitLevel(parentUnit, sys_unit.getId());
|
||||||
|
if (calculatedUnitLevel < 0) {
|
||||||
|
return Result.error("单位层级关系异常");
|
||||||
|
}
|
||||||
|
Integer unitLevel = sys_unit.getUnitlevel();
|
||||||
|
if (unitLevel == null) {
|
||||||
|
unitLevel = calculatedUnitLevel;
|
||||||
|
} else if (unitLevel < 1) {
|
||||||
|
return Result.error("单位等级不能小于1");
|
||||||
|
}
|
||||||
|
sys_unit.setUnitlevel(unitLevel);
|
||||||
|
sys_unit.setPath(sysUnitService.getSubPath("sys_unit", "path", parentUnit.getPath()));
|
||||||
sysUnitService.update(Chain.make("hasChildren", true), Cnd.where("id", "=", sys_unit.getParentId()));
|
sysUnitService.update(Chain.make("hasChildren", true), Cnd.where("id", "=", sys_unit.getParentId()));
|
||||||
sysUnitService.insert(sys_unit);
|
sysUnitService.insert(sys_unit);
|
||||||
|
|
||||||
// 通知系统单位发生变更
|
// 通知系统单位发生变更
|
||||||
SysCommonDataChangeCenter.publish(SysCommonDataChangeType.INSERT, Sys_unit.class, sys_unit.getId());
|
SysCommonDataChangeCenter.publish(SysCommonDataChangeType.INSERT, Sys_unit.class, sys_unit.getId());
|
||||||
|
|
||||||
return null;
|
return Result.success().addData(sysUnitService.fetch(sys_unit.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -157,15 +181,80 @@ public class SysUnitController2 {
|
|||||||
@RequiresPermissions("sys.manager.unit")
|
@RequiresPermissions("sys.manager.unit")
|
||||||
@Aop(TransAop.READ_COMMITTED)
|
@Aop(TransAop.READ_COMMITTED)
|
||||||
public Object doEdit(Sys_unit sys_unit) {
|
public Object doEdit(Sys_unit sys_unit) {
|
||||||
|
if (Strings.isBlank(sys_unit.getId()) || Strings.isBlank(sys_unit.getParentId())) {
|
||||||
|
return Result.error("单位或上级单位不能为空");
|
||||||
|
}
|
||||||
if (sysUnitService.count(Cnd.where("unitcode", "=", sys_unit.getUnitcode()).and("id", "!=", sys_unit.getId())) > 0) {
|
if (sysUnitService.count(Cnd.where("unitcode", "=", sys_unit.getUnitcode()).and("id", "!=", sys_unit.getId())) > 0) {
|
||||||
return Result.error("单位代码已存在");
|
return Result.error("单位代码已存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Sys_unit oldUnit = sysUnitService.fetch(sys_unit.getId());
|
||||||
|
Sys_unit parentUnit = sysUnitService.fetch(sys_unit.getParentId());
|
||||||
|
if (oldUnit == null || parentUnit == null) {
|
||||||
|
return Result.error("单位信息不存在");
|
||||||
|
}
|
||||||
|
if (sys_unit.getId().equals(sys_unit.getParentId())) {
|
||||||
|
return Result.error("上级单位不能选择自身");
|
||||||
|
}
|
||||||
|
|
||||||
|
String oldParentId = oldUnit.getParentId();
|
||||||
|
boolean parentChanged = !Strings.sBlank(oldParentId).equals(Strings.sBlank(sys_unit.getParentId()));
|
||||||
|
int calculatedUnitLevel = calculateUnitLevel(parentUnit, sys_unit.getId());
|
||||||
|
if (calculatedUnitLevel < 0) {
|
||||||
|
return Result.error("上级单位不能选择当前单位或其下级单位");
|
||||||
|
}
|
||||||
|
Integer unitLevel = sys_unit.getUnitlevel();
|
||||||
|
if (unitLevel == null) {
|
||||||
|
unitLevel = calculatedUnitLevel;
|
||||||
|
} else if (unitLevel < 1) {
|
||||||
|
return Result.error("单位等级不能小于1");
|
||||||
|
}
|
||||||
|
|
||||||
|
sys_unit.setUnitlevel(unitLevel);
|
||||||
|
sys_unit.setHasChildren(oldUnit.isHasChildren());
|
||||||
|
if (parentChanged) {
|
||||||
|
sys_unit.setPath(sysUnitService.getSubPath("sys_unit", "path", parentUnit.getPath()));
|
||||||
|
} else {
|
||||||
|
sys_unit.setPath(oldUnit.getPath());
|
||||||
|
}
|
||||||
sys_unit.setOpAt(System.currentTimeMillis());
|
sys_unit.setOpAt(System.currentTimeMillis());
|
||||||
sysUnitService.update(sys_unit);
|
sysUnitService.update(sys_unit);
|
||||||
|
// 单位等级允许手工指定,未填写时使用根据父级链计算出的等级
|
||||||
|
sysUnitService.update(Chain.make("parentId", sys_unit.getParentId())
|
||||||
|
.add("unitlevel", unitLevel)
|
||||||
|
.add("path", sys_unit.getPath()),
|
||||||
|
Cnd.where("id", "=", sys_unit.getId()));
|
||||||
|
|
||||||
|
if (parentChanged) {
|
||||||
|
int oldParentChildren = sysUnitService.count(Cnd.where("parentId", "=", oldParentId));
|
||||||
|
sysUnitService.update(Chain.make("hasChildren", oldParentChildren > 0), Cnd.where("id", "=", oldParentId));
|
||||||
|
sysUnitService.update(Chain.make("hasChildren", true), Cnd.where("id", "=", sys_unit.getParentId()));
|
||||||
|
}
|
||||||
|
|
||||||
// 通知系统单位发生变更
|
// 通知系统单位发生变更
|
||||||
SysCommonDataChangeCenter.publish(SysCommonDataChangeType.UPDATE, Sys_unit.class, sys_unit.getId());
|
SysCommonDataChangeCenter.publish(SysCommonDataChangeType.UPDATE, Sys_unit.class, sys_unit.getId());
|
||||||
return null;
|
return Result.success().addData(sysUnitService.fetch(sys_unit.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据实际父级链计算单位等级,根单位为0级,根单位的下级为1级。
|
||||||
|
*/
|
||||||
|
private int calculateUnitLevel(Sys_unit parentUnit, String unitId) {
|
||||||
|
int unitLevel = 0;
|
||||||
|
Set<String> parentIds = new HashSet<>();
|
||||||
|
Sys_unit currentUnit = parentUnit;
|
||||||
|
while (currentUnit != null) {
|
||||||
|
if ((Strings.isNotBlank(unitId) && unitId.equals(currentUnit.getId())) ||
|
||||||
|
!parentIds.add(currentUnit.getId())) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
unitLevel++;
|
||||||
|
if (Strings.isBlank(currentUnit.getParentId()) || currentUnit.getId().equals(currentUnit.getParentId())) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
currentUnit = sysUnitService.fetch(currentUnit.getParentId());
|
||||||
|
}
|
||||||
|
return unitLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@At
|
@At
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ layout("/layouts/platform.html"){
|
|||||||
<el-card shadow="never" class="mt10">
|
<el-card shadow="never" class="mt10">
|
||||||
<el-tabs v-model="secondaryTabActiveName" type="card"
|
<el-tabs v-model="secondaryTabActiveName" type="card"
|
||||||
@tab-click="secondaryDataSearch()">
|
@tab-click="secondaryDataSearch()">
|
||||||
<el-tab-pane label="三级单位" name="thirdLevelUnit"></el-tab-pane>
|
<el-tab-pane label="二级单位" name="thirdLevelUnit"></el-tab-pane>
|
||||||
<el-tab-pane label="单位人员" name="unitPersonnel"></el-tab-pane>
|
<el-tab-pane label="单位人员" name="unitPersonnel"></el-tab-pane>
|
||||||
<el-tab-pane label="单位负责人" name="unitLeader"></el-tab-pane>
|
<el-tab-pane label="单位负责人" name="unitLeader"></el-tab-pane>
|
||||||
<el-tab-pane label="单位分管校领导" name="unitSchoolLeader"></el-tab-pane>
|
<el-tab-pane label="单位分管校领导" name="unitSchoolLeader"></el-tab-pane>
|
||||||
@@ -413,7 +413,7 @@ layout("/layouts/platform.html"){
|
|||||||
</el-card>
|
</el-card>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="checkNode.level===3" style="padding: 0 10px">
|
<div v-if="checkNode.level>=3" style="padding: 0 10px">
|
||||||
<el-card shadow="never">
|
<el-card shadow="never">
|
||||||
<div class="btn-group tool-button mt5">
|
<div class="btn-group tool-button mt5">
|
||||||
<el-input placeholder="请输入内容" clearable
|
<el-input placeholder="请输入内容" clearable
|
||||||
@@ -432,6 +432,13 @@ layout("/layouts/platform.html"){
|
|||||||
<div class="btn-group tool-button mt5">
|
<div class="btn-group tool-button mt5">
|
||||||
<el-button type="primary" icon="el-icon-search" @click="thirdPageData"></el-button>
|
<el-button type="primary" icon="el-icon-search" @click="thirdPageData"></el-button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="pull-right offscreen-right mt5">
|
||||||
|
<div class="btn-group tool-button">
|
||||||
|
<el-button icon="el-icon-edit" type="primary" @click="openEdit(checkData.id)">
|
||||||
|
编辑单位
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<el-card shadow="never" class="mt10">
|
<el-card shadow="never" class="mt10">
|
||||||
@@ -500,19 +507,30 @@ layout("/layouts/platform.html"){
|
|||||||
label-width="120px"
|
label-width="120px"
|
||||||
style="padding: 0 30px">
|
style="padding: 0 30px">
|
||||||
<el-row gutter="30">
|
<el-row gutter="30">
|
||||||
<el-col :span="24">
|
<el-col :span="12">
|
||||||
<el-form-item label="上级单位">
|
<el-form-item label="上级单位" prop="parentId">
|
||||||
<el-input maxlength="100" disabled :value="checkData.name"
|
<el-cascader v-model="formData.parentId"
|
||||||
type="text"></el-input>
|
:options="parentUnitOptions"
|
||||||
|
:props="parentUnitProps"
|
||||||
|
:show-all-levels="false"
|
||||||
|
placeholder="请选择上级单位"
|
||||||
|
style="width: 100%"></el-cascader>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="单位名称" prop="name">
|
<el-form-item label="单位名称" prop="name">
|
||||||
<el-input maxlength="100" placeholder="请输入单位名称" v-model="formData.name"
|
<el-input maxlength="100" placeholder="请输入单位名称" v-model="formData.name"
|
||||||
type="text"></el-input>
|
type="text"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row gutter="30">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="单位等级" prop="unitlevel">
|
||||||
|
<el-input v-model="formData.unitlevel" clearable @input="unitLevelInput"
|
||||||
|
placeholder="不填写则按上级单位自动计算"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="单位代码" prop="unitcode">
|
<el-form-item label="单位代码" prop="unitcode">
|
||||||
<el-input maxlength="100" placeholder="请输入单位编码" v-model="formData.unitcode"
|
<el-input maxlength="100" placeholder="请输入单位编码" v-model="formData.unitcode"
|
||||||
@@ -520,7 +538,8 @@ layout("/layouts/platform.html"){
|
|||||||
type="text"></el-input>
|
type="text"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row gutter="30">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="单位简称" prop="aliasName">
|
<el-form-item label="单位简称" prop="aliasName">
|
||||||
<el-input maxlength="100" placeholder="请输入单位简称" v-model="formData.aliasName"
|
<el-input maxlength="100" placeholder="请输入单位简称" v-model="formData.aliasName"
|
||||||
@@ -533,7 +552,8 @@ layout("/layouts/platform.html"){
|
|||||||
type="text"></el-input>
|
type="text"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row gutter="30">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="单位邮箱" prop="email">
|
<el-form-item label="单位邮箱" prop="email">
|
||||||
<el-input maxlength="100" placeholder="请输入单位邮箱" v-model="formData.email"
|
<el-input maxlength="100" placeholder="请输入单位邮箱" v-model="formData.email"
|
||||||
@@ -546,13 +566,16 @@ layout("/layouts/platform.html"){
|
|||||||
type="text"></el-input>
|
type="text"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row gutter="30">
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-form-item label="单位地址" prop="address">
|
<el-form-item label="单位地址" prop="address">
|
||||||
<el-input maxlength="100" placeholder="请输入单位地址" v-model="formData.address"
|
<el-input maxlength="100" placeholder="请输入单位地址" v-model="formData.address"
|
||||||
type="text"></el-input>
|
type="text"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row gutter="30">
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-form-item label="单位介绍" prop="note">
|
<el-form-item label="单位介绍" prop="note">
|
||||||
<el-input maxlength="500" type="textarea" placeholder="请输入单位介绍"
|
<el-input maxlength="500" type="textarea" placeholder="请输入单位介绍"
|
||||||
@@ -665,7 +688,15 @@ layout("/layouts/platform.html"){
|
|||||||
},
|
},
|
||||||
formRules: {
|
formRules: {
|
||||||
name: [{required: true, message: '必填', trigger: ['blur', 'change']}],
|
name: [{required: true, message: '必填', trigger: ['blur', 'change']}],
|
||||||
code: [{required: true, message: '必填', trigger: ['blur', 'change']}],
|
unitcode: [{required: true, message: '必填', trigger: ['blur', 'change']}],
|
||||||
|
parentId: [{required: true, message: '必填', trigger: 'change'}],
|
||||||
|
},
|
||||||
|
parentUnitProps: {
|
||||||
|
value: 'id',
|
||||||
|
label: 'name',
|
||||||
|
children: 'child',
|
||||||
|
checkStrictly: true,
|
||||||
|
emitPath: false,
|
||||||
},
|
},
|
||||||
checkNode: {level: 1},
|
checkNode: {level: 1},
|
||||||
checkData: {},
|
checkData: {},
|
||||||
@@ -710,6 +741,29 @@ layout("/layouts/platform.html"){
|
|||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
parentUnitOptions() {
|
||||||
|
const disabledIds = new Set()
|
||||||
|
const collectDisabledIds = (units, parentDisabled) => units.forEach(unit => {
|
||||||
|
const disabled = parentDisabled || unit.id === this.formData.id
|
||||||
|
if (disabled) {
|
||||||
|
disabledIds.add(unit.id)
|
||||||
|
}
|
||||||
|
if (unit.child && unit.child.length) {
|
||||||
|
collectDisabledIds(unit.child, disabled)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
collectDisabledIds(this.treeData, false)
|
||||||
|
|
||||||
|
const buildOptions = units => units.map(unit => ({
|
||||||
|
...unit,
|
||||||
|
// 当前单位及其所有下级不能作为上级单位,避免形成循环层级
|
||||||
|
disabled: disabledIds.has(unit.id),
|
||||||
|
child: unit.child && unit.child.length ? buildOptions(unit.child) : undefined,
|
||||||
|
}))
|
||||||
|
return buildOptions(this.treeData)
|
||||||
|
}
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this.$refs.firstTable) {
|
if (this.$refs.firstTable) {
|
||||||
@@ -727,6 +781,37 @@ layout("/layouts/platform.html"){
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
async confirmUnitLevel() {
|
||||||
|
const inputLevel = this.formData.unitlevel
|
||||||
|
if (inputLevel === '' || inputLevel === null || inputLevel === undefined) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
const parentNode = this.$refs.tree.getNode(this.formData.parentId)
|
||||||
|
if (!parentNode || Number(inputLevel) === parentNode.level) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await this.$confirm(
|
||||||
|
'根据当前上级单位,推荐单位等级为' + parentNode.level +
|
||||||
|
'级,当前填写为' + inputLevel + '级,是否仍按当前等级保存?',
|
||||||
|
'单位等级确认',
|
||||||
|
{
|
||||||
|
confirmButtonText: '继续保存',
|
||||||
|
cancelButtonText: '返回修改',
|
||||||
|
type: 'warning'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return true
|
||||||
|
} catch (e) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
unitLevelInput(value) {
|
||||||
|
const unitLevel = String(value || '').replace(/\D/g, '')
|
||||||
|
if (unitLevel !== value) {
|
||||||
|
this.$set(this.formData, 'unitlevel', unitLevel)
|
||||||
|
}
|
||||||
|
},
|
||||||
async openAddOtherRole() {
|
async openAddOtherRole() {
|
||||||
this.otherRoleDialogVisible = true
|
this.otherRoleDialogVisible = true
|
||||||
if (this.$refs.otherRoleTransfer) {
|
if (this.$refs.otherRoleTransfer) {
|
||||||
@@ -856,7 +941,7 @@ layout("/layouts/platform.html"){
|
|||||||
this.doSearch()
|
this.doSearch()
|
||||||
} else if (node.level === 2) {
|
} else if (node.level === 2) {
|
||||||
this.secondaryDataSearch()
|
this.secondaryDataSearch()
|
||||||
} else if (node.level === 3) {
|
} else if (node.level >= 3) {
|
||||||
this.thirdPageData()
|
this.thirdPageData()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -891,14 +976,31 @@ layout("/layouts/platform.html"){
|
|||||||
doEdit() {
|
doEdit() {
|
||||||
this.$refs["form"].validate(async (valid) => {
|
this.$refs["form"].validate(async (valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
if (!await this.confirmUnitLevel()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
this.loading = true
|
this.loading = true
|
||||||
const resp = await $.post(loc() + "/doEdit", this.formData)
|
const resp = await $.post(loc() + "/doEdit", this.formData)
|
||||||
this.loading = false
|
this.loading = false
|
||||||
if (resp.code === 0) {
|
if (resp.code === 0) {
|
||||||
this.loadTree(false)
|
const editedUnit = resp.data || this.formData
|
||||||
this.pageData();
|
if (this.checkData.id === this.formData.id) {
|
||||||
this.secondaryDataSearch()
|
this.checkData = Object.assign({}, this.checkData, editedUnit)
|
||||||
this.thirdPageData()
|
}
|
||||||
|
await this.loadTree(false)
|
||||||
|
await this.$nextTick()
|
||||||
|
const currentNode = this.$refs.tree.getNode(this.checkData.id)
|
||||||
|
if (currentNode) {
|
||||||
|
this.checkNode = currentNode
|
||||||
|
this.checkData = currentNode.data
|
||||||
|
}
|
||||||
|
if (this.checkNode.level === 1) {
|
||||||
|
this.pageData()
|
||||||
|
} else if (this.checkNode.level === 2) {
|
||||||
|
this.secondaryDataSearch()
|
||||||
|
} else {
|
||||||
|
this.thirdPageData()
|
||||||
|
}
|
||||||
this.$refs.guava.index()
|
this.$refs.guava.index()
|
||||||
} else {
|
} else {
|
||||||
this.$notify.warning(resp.msg)
|
this.$notify.warning(resp.msg)
|
||||||
@@ -922,6 +1024,9 @@ layout("/layouts/platform.html"){
|
|||||||
doAdd() {
|
doAdd() {
|
||||||
this.$refs["form"].validate(async (valid) => {
|
this.$refs["form"].validate(async (valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
if (!await this.confirmUnitLevel()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
this.loading = true
|
this.loading = true
|
||||||
const resp = await $.post(loc() + "/doAdd", this.formData)
|
const resp = await $.post(loc() + "/doAdd", this.formData)
|
||||||
this.loading = false
|
this.loading = false
|
||||||
@@ -938,10 +1043,9 @@ layout("/layouts/platform.html"){
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
openAdd() {
|
openAdd() {
|
||||||
const {id, unitlevel} = this.checkData
|
const {id} = this.checkData
|
||||||
this.formData = {
|
this.formData = {
|
||||||
parentId: id,
|
parentId: id,
|
||||||
unitlevel: unitlevel + 1,
|
|
||||||
}
|
}
|
||||||
this.$refs.guava.edit()
|
this.$refs.guava.edit()
|
||||||
if (this.$refs['form']) {
|
if (this.$refs['form']) {
|
||||||
|
|||||||
Reference in New Issue
Block a user