|
@@ -32,7 +32,7 @@ module.exports = app => {
|
|
|
if (parentFolderInfo.is_leaf) {
|
|
|
await transaction.update(this.tableName, { id: parentFolderInfo.id, is_leaf: 0 });
|
|
|
}
|
|
|
- parent_path = parentFolderInfo.parent_path ? parentFolderInfo.parent_path + '-' + parentFolderInfo.id : parentFolderInfo.id;
|
|
|
+ parent_path = parentFolderInfo.parent_path ? parentFolderInfo.parent_path + '-' + parentFolderInfo.folder_id : parentFolderInfo.folder_id;
|
|
|
}
|
|
|
const childrenCount = await transaction.select(this.tableName, { where: { spid: this.ctx.subProject.id, parent_id: parentId }, orders: [['order', 'desc']] });
|
|
|
const order = childrenCount && childrenCount.length > 0 ? childrenCount[0].order + 1 : 1;
|
|
@@ -67,23 +67,23 @@ module.exports = app => {
|
|
|
if (info.uid !== this.ctx.session.sessionUser.accountId && !this.ctx.session.sessionUser.is_admin) {
|
|
|
throw '您没有权限删除此文件夹';
|
|
|
}
|
|
|
- let ids = [info.id];
|
|
|
+ let ids = [info.folder_id];
|
|
|
if (info.parent_id === 0) {
|
|
|
- const childList = await this.getAllDataByCondition({ where: { spid: this.ctx.subProject.id, parent_id: info.id } });
|
|
|
+ const childList = await this.getAllDataByCondition({ where: { spid: this.ctx.subProject.id, parent_id: info.folder_id } });
|
|
|
if (childList.length > 0) {
|
|
|
- ids = [...ids, ...this._.map(childList, 'id')];
|
|
|
+ ids = [...ids, ...this._.map(childList, 'folder_id')];
|
|
|
for (const c of childList) {
|
|
|
- const deleteData = await this.getDataByParentPath(this.tableName, c.parent_path + '-' + c.id + '%', transaction);
|
|
|
+ const deleteData = await this.getDataByParentPath(this.tableName, c.parent_path + '-' + c.folder_id + '%', transaction);
|
|
|
if (deleteData.length > 0) {
|
|
|
- const delids = this._.map(deleteData, 'id');
|
|
|
+ const delids = this._.map(deleteData, 'folder_id');
|
|
|
ids = [...ids, ...delids];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else if (info.parent_path) {
|
|
|
- const deleteData = await this.getDataByParentPath(this.tableName, info.parent_path + '-' + info.id + '%', transaction);
|
|
|
+ const deleteData = await this.getDataByParentPath(this.tableName, info.parent_path + '-' + info.folder_id + '%', transaction);
|
|
|
if (deleteData.length > 0) {
|
|
|
- const delids = this._.map(deleteData, 'id');
|
|
|
+ const delids = this._.map(deleteData, 'folder_id');
|
|
|
ids = [...ids, ...delids];
|
|
|
}
|
|
|
}
|
|
@@ -92,7 +92,7 @@ module.exports = app => {
|
|
|
if (tenderCount > 0) {
|
|
|
throw '文件夹下存在标段,无法删除';
|
|
|
}
|
|
|
- await transaction.delete(this.tableName, { id: ids });
|
|
|
+ await transaction.delete(this.tableName, { spid: this.ctx.subProject.id, folder_id: ids });
|
|
|
await transaction.commit();
|
|
|
} catch (err) {
|
|
|
await transaction.rollback();
|
|
@@ -103,7 +103,7 @@ module.exports = app => {
|
|
|
async getDataByParentPath(tableName, parent_path, transaction = null) {
|
|
|
this.initSqlBuilder();
|
|
|
this.sqlBuilder.setAndWhere('spid', {
|
|
|
- value: this.ctx.subProject.id,
|
|
|
+ value: this.db.escape(this.ctx.subProject.id),
|
|
|
operate: '=',
|
|
|
});
|
|
|
this.sqlBuilder.setAndWhere('parent_path', {
|