소스 검색

Merge branch 'dev' of http://192.168.1.41:3000/lanjianrong/financial_audit_console into dev

outaozhen 3 년 전
부모
커밋
9fa6da4eec
3개의 변경된 파일13개의 추가작업 그리고 12개의 파일을 삭제
  1. 0 1
      src/components/Modal/index.tsx
  2. 12 10
      src/pages/Business/Inventory/hooks/useRowScript.tsx
  3. 1 1
      src/pages/Business/Inventory/index.tsx

+ 0 - 1
src/components/Modal/index.tsx

@@ -68,7 +68,6 @@ const MyModal = memo(
         },
         // 注入Modal参数
         injectModalProps: props => {
-          console.log(props)
           setModalProps(source => {
             return {
               ...source,

+ 12 - 10
src/pages/Business/Inventory/hooks/useRowScript.tsx

@@ -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()
         }
       }

+ 1 - 1
src/pages/Business/Inventory/index.tsx

@@ -133,7 +133,7 @@ const Inventory = () => {
             size="small"
             type="primary"
             ghost
-            disabled={!record?.moveable}
+            disabled={!record?.folder && !record?.moveable}
             onClick={move}>
             移动至
           </Button>