|
@@ -737,7 +737,7 @@ class TreeService extends Service {
|
|
selfOperate: '-',
|
|
selfOperate: '-',
|
|
});
|
|
});
|
|
this.sqlBuilder.setUpdateData(this.setting.fullPath, {
|
|
this.sqlBuilder.setUpdateData(this.setting.fullPath, {
|
|
- value: [this.setting.fullPath, this.db.escape(select[this.setting.pid] + '-'), this.db.escape('')],
|
|
|
|
|
|
+ value: [this.setting.fullPath, this.db.escape(`-${select[this.setting.pid]}-`), this.db.escape('-')],
|
|
literal: 'Replace',
|
|
literal: 'Replace',
|
|
});
|
|
});
|
|
const [sql, sqlParam] = this.sqlBuilder.build(this.tableName, 'update');
|
|
const [sql, sqlParam] = this.sqlBuilder.build(this.tableName, 'update');
|
|
@@ -842,7 +842,7 @@ class TreeService extends Service {
|
|
updateData[this.setting.pid] = parent[this.setting.pid];
|
|
updateData[this.setting.pid] = parent[this.setting.pid];
|
|
updateData[this.setting.order] = parent[this.setting.order] + i + 1;
|
|
updateData[this.setting.order] = parent[this.setting.order] + i + 1;
|
|
updateData[this.setting.level] = s[this.setting.level] - 1;
|
|
updateData[this.setting.level] = s[this.setting.level] - 1;
|
|
- updateData[this.setting.fullPath] = s[this.setting.fullPath].replace(s[this.setting.pid] + '-', '');
|
|
|
|
|
|
+ updateData[this.setting.fullPath] = s[this.setting.fullPath].replace(`-${s[this.setting.pid]}-`, '-');
|
|
newPath.push(updateData[this.setting.fullPath]);
|
|
newPath.push(updateData[this.setting.fullPath]);
|
|
if (s.is_leaf && s.id === last.id) {
|
|
if (s.is_leaf && s.id === last.id) {
|
|
const nexts = await this.getNextsData(mid, parent[this.setting.kid], last[this.setting.order]);
|
|
const nexts = await this.getNextsData(mid, parent[this.setting.kid], last[this.setting.order]);
|
|
@@ -881,7 +881,7 @@ class TreeService extends Service {
|
|
* @return {Promise<*>}
|
|
* @return {Promise<*>}
|
|
* @private
|
|
* @private
|
|
*/
|
|
*/
|
|
- async _syncDownlevelChildren(select, pre) {
|
|
|
|
|
|
+ async _syncDownlevelChildren(select, newFullPath) {
|
|
this.initSqlBuilder();
|
|
this.initSqlBuilder();
|
|
this.sqlBuilder.setAndWhere(this.setting.mid, {
|
|
this.sqlBuilder.setAndWhere(this.setting.mid, {
|
|
value: select[this.setting.mid],
|
|
value: select[this.setting.mid],
|
|
@@ -896,7 +896,7 @@ class TreeService extends Service {
|
|
selfOperate: '+',
|
|
selfOperate: '+',
|
|
});
|
|
});
|
|
this.sqlBuilder.setUpdateData(this.setting.fullPath, {
|
|
this.sqlBuilder.setUpdateData(this.setting.fullPath, {
|
|
- value: [this.setting.fullPath, this.db.escape(select[this.setting.kid] + '-'), this.db.escape(pre[this.setting.kid] + '-' + select[this.setting.kid] + '-')],
|
|
|
|
|
|
+ value: [this.setting.fullPath, this.db.escape(select[this.setting.fullPath] + '-'), this.db.escape(newFullPath + '-')],
|
|
literal: 'Replace',
|
|
literal: 'Replace',
|
|
});
|
|
});
|
|
const [sql, sqlParam] = this.sqlBuilder.build(this.tableName, 'update');
|
|
const [sql, sqlParam] = this.sqlBuilder.build(this.tableName, 'update');
|
|
@@ -933,13 +933,16 @@ class TreeService extends Service {
|
|
updateData[this.setting.pid] = pre[this.setting.kid];
|
|
updateData[this.setting.pid] = pre[this.setting.kid];
|
|
updateData[this.setting.order] = preLastChild ? preLastChild[this.setting.order] + i + 1 : i + 1;
|
|
updateData[this.setting.order] = preLastChild ? preLastChild[this.setting.order] + i + 1 : i + 1;
|
|
updateData[this.setting.level] = s[this.setting.level] + 1;
|
|
updateData[this.setting.level] = s[this.setting.level] + 1;
|
|
- const orgLastPath = s[this.setting.level] === 1 ? s[this.setting.kid] : '-' + s[this.setting.kid];
|
|
|
|
- const newLastPath = s[this.setting.level] === 1 ? pre[this.setting.kid] + '-' + s[this.setting.kid] : '-' + pre[this.setting.kid] + '-' + s[this.setting.kid];
|
|
|
|
- updateData[this.setting.fullPath] = s[this.setting.fullPath].replace(orgLastPath, newLastPath);
|
|
|
|
|
|
+ if (s[this.setting.level] === 1) {
|
|
|
|
+ updateData[this.setting.fullPath] = pre[this.setting.kid] + '-' + s[this.setting.kid];
|
|
|
|
+ } else {
|
|
|
|
+ const index = s[this.setting.fullPath].lastIndexOf(s[this.setting.kid]);
|
|
|
|
+ updateData[this.setting.fullPath] = s[this.setting.fullPath].substring(0, index) + '-' + pre[this.setting.kid] + '-' + s[this.setting.kid];
|
|
|
|
+ }
|
|
newPath.push(updateData[this.setting.fullPath]);
|
|
newPath.push(updateData[this.setting.fullPath]);
|
|
await this.transaction.update(this.tableName, updateData);
|
|
await this.transaction.update(this.tableName, updateData);
|
|
// 选中节点--全部子节点(含孙) level++, full_path
|
|
// 选中节点--全部子节点(含孙) level++, full_path
|
|
- await this._syncDownlevelChildren(s, pre);
|
|
|
|
|
|
+ await this._syncDownlevelChildren(s, updateData[this.setting.fullPath]);
|
|
}
|
|
}
|
|
// 选中节点--前兄弟节点 is_leaf应为false, 清空计算相关字段
|
|
// 选中节点--前兄弟节点 is_leaf应为false, 清空计算相关字段
|
|
const updateData2 = { id: pre.id };
|
|
const updateData2 = { id: pre.id };
|