|
@@ -37,29 +37,29 @@ function formatTreeTable(nodes: API.ProfileTemplateItem[]) {
|
|
|
|
|
|
/**
|
|
|
* 格式化新增目录/移动操作所需的TreeNode
|
|
|
- * @param currentID 不传则为新增目录
|
|
|
+ * @param currentPID 不传则为新增目录
|
|
|
* */
|
|
|
-function formatTreeNode(nodes: API.ProfileTemplateItem[], currentID?: string): TreeNodeProps[] {
|
|
|
+function formatTreeNode(nodes: API.ProfileTemplateItem[], ID?: string, PID?: string): TreeNodeProps[] {
|
|
|
return nodes.map(item => {
|
|
|
const newItem: TreeNodeProps = {
|
|
|
title: item.name,
|
|
|
value: item.ID,
|
|
|
- disable: false
|
|
|
+ disabled: item.folder ? false : true // 文件默认不可选择
|
|
|
}
|
|
|
// 移动操作判断逻辑
|
|
|
- if (currentID) {
|
|
|
- if (item.ID === currentID || !item.moveable) {
|
|
|
- newItem.disable = true
|
|
|
+ if (ID || PID) {
|
|
|
+ if (item.ID === ID || item.ID === PID) {
|
|
|
+ newItem.disabled = true
|
|
|
}
|
|
|
if (item.children?.length) {
|
|
|
- newItem.children = formatTreeNode(item.children)
|
|
|
+ newItem.children = formatTreeNode(item.children, ID, PID)
|
|
|
}
|
|
|
} else {
|
|
|
if (!item.folder) {
|
|
|
newItem.disabled = true
|
|
|
}
|
|
|
if (item.children?.length) {
|
|
|
- newItem.children = formatTreeNode(item.children)
|
|
|
+ newItem.children = formatTreeNode(item.children, ID, PID)
|
|
|
}
|
|
|
}
|
|
|
return newItem
|
|
@@ -83,7 +83,7 @@ export function useRowScript(modal: ModalAction) {
|
|
|
okText: '确认',
|
|
|
type: 'form',
|
|
|
cancelText: '取消',
|
|
|
- initialValues: { parentID: state.record?.parentID },
|
|
|
+ initialValues: { parentID: state.record?.ID },
|
|
|
children: (
|
|
|
<ProForm submitter={false} layout="horizontal" labelCol={{ span: 4 }} isKeyPressSubmit>
|
|
|
<ProFormTreeSelect
|
|
@@ -214,6 +214,7 @@ export function useRowScript(modal: ModalAction) {
|
|
|
const { code = -1 } = await moveTemplateWithOperation({ ID: state.record?.ID, operation })
|
|
|
if (code === consts.RET_CODE.SUCCESS) {
|
|
|
message.success('移动成功')
|
|
|
+ setState({ ...state, record: null })
|
|
|
refresh()
|
|
|
}
|
|
|
}
|
|
@@ -230,7 +231,7 @@ export function useRowScript(modal: ModalAction) {
|
|
|
<ProFormTreeSelect
|
|
|
name="moveID"
|
|
|
label="目录名称"
|
|
|
- fieldProps={{ options: formatTreeNode(state.list, state.record?.ID) }}
|
|
|
+ fieldProps={{ options: formatTreeNode(state.list, state.record?.ID, state.record?.parentID) }}
|
|
|
rules={[{ required: true, message: '请选择目标节点' }]}
|
|
|
/>
|
|
|
</ProForm>
|
|
@@ -242,6 +243,7 @@ export function useRowScript(modal: ModalAction) {
|
|
|
if (code === consts.RET_CODE.SUCCESS) {
|
|
|
message.success('移动成功')
|
|
|
modal.close()
|
|
|
+ setState({ ...state, record: null })
|
|
|
refresh()
|
|
|
}
|
|
|
}
|