Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
linweijiong
jinfa-platform
Commits
8eaea579
Commit
8eaea579
authored
Aug 04, 2021
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 抽离 单据页面 组件
parent
e98d1f98
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
243 additions
and
0 deletions
+243
-0
index.ts
...llStorage/bills/components/BillsFormPage/effects/index.ts
+53
-0
useBusinessEffects.ts
...ls/components/BillsFormPage/effects/useBusinessEffects.ts
+30
-0
index.less
...tockSellStorage/bills/components/BillsFormPage/index.less
+0
-0
index.tsx
...stockSellStorage/bills/components/BillsFormPage/index.tsx
+160
-0
schema.ts
...stockSellStorage/bills/components/BillsFormPage/schema.ts
+0
-0
No files found.
src/pages/transaction/stockSellStorage/bills/components/BillsFormPage/effects/index.ts
0 → 100644
View file @
8eaea579
/*
* @Author: XieZhiXiong
* @Date: 2021-08-04 14:42:57
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-08-04 17:59:35
* @Description:
*/
import
{
FormPath
,
FormEffectHooks
}
from
'@formily/antd'
;
import
{
useAsyncSelect
}
from
'@/formSchema/effects/useAsyncSelect'
;
import
{
PublicApi
}
from
'@/services/api'
;
import
{
useBusinessEffects
}
from
'./useBusinessEffects'
;
const
{
onFieldMount$
,
}
=
FormEffectHooks
;
// 获取单据类型
const
fetchInvoicesType
=
():
Promise
<
any
[]
>
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
PublicApi
.
getProductInvoicesTypeAll
().
then
(
res
=>
{
if
(
res
.
code
===
1000
)
{
resolve
(
res
.
data
);
}
reject
();
}).
catch
(()
=>
{
reject
();
});
});
};
// 获取仓库
const
fetchInventory
=
():
Promise
<
any
[]
>
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
PublicApi
.
getProductWarehouseAll
().
then
(
res
=>
{
if
(
res
.
code
===
1000
)
{
resolve
(
res
.
data
);
}
reject
();
}).
catch
(()
=>
{
reject
();
});
});
};
export
const
createEffects
=
(
context
,
actions
)
=>
{
const
{
setFieldState
}
=
actions
;
useBusinessEffects
(
context
,
actions
);
useAsyncSelect
(
'billType'
,
fetchInvoicesType
,
[
'name'
,
'id'
]);
useAsyncSelect
(
'inventoryId'
,
fetchInventory
,
[
'name'
,
'id'
]);
};
\ No newline at end of file
src/pages/transaction/stockSellStorage/bills/components/BillsFormPage/effects/useBusinessEffects.ts
0 → 100644
View file @
8eaea579
/*
* @Author: XieZhiXiong
* @Date: 2021-08-04 14:43:14
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-08-04 18:00:12
* @Description:
*/
import
{
FormEffectHooks
,
FormPath
,
IFormActions
}
from
'@formily/antd'
;
import
{
useLinkageUtils
}
from
'@/utils/formEffectUtils'
;
const
{
onFieldInputChange$
,
onFieldValueChange$
,
}
=
FormEffectHooks
;
export
const
useBusinessEffects
=
(
context
,
actions
:
IFormActions
)
=>
{
const
{
getFieldValue
,
setFieldState
,
setFieldValue
,
getFieldState
}
=
actions
;
const
linkage
=
useLinkageUtils
();
// 对应仓库改变
onFieldInputChange$
(
'inventoryId'
).
subscribe
(
fieldState
=>
{
const
current
=
fieldState
.
originAsyncData
.
find
(
item
=>
item
.
id
===
fieldState
.
value
);
if
(
current
)
{
linkage
.
value
(
'inventoryRole'
,
current
.
principal
);
}
});
}
\ No newline at end of file
src/pages/transaction/stockSellStorage/bills/components/BillsFormPage/index.less
0 → 100644
View file @
8eaea579
src/pages/transaction/stockSellStorage/bills/components/BillsFormPage/index.tsx
0 → 100644
View file @
8eaea579
/*
* @Author: XieZhiXiong
* @Date: 2021-08-04 11:33:33
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-08-04 17:55:28
* @Description: 单据表单组件,提供基础的表单内容,单据明细相关由外部传入控制
*/
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
Button
,
Spin
}
from
'antd'
;
import
{
createFormActions
,
FormEffectHooks
,
ISchemaFormActions
,
ISchemaFormAsyncActions
}
from
'@formily/antd'
;
import
{
Radio
,
ArrayTable
}
from
'@formily/antd-components'
;
import
{
DOC_TYPE_PURCHASE_RECEIPT
,
DOC_TYPE_SALES_INVOICE
,
DOC_TYPE_PROCESS_RECEIPT
,
DOC_TYPE_PROCESS_INVOICE
,
DOC_TYPE_RETURN_INVOICE
,
DOC_TYPE_RETURN_RECEIPT
,
DOC_TYPE_EXCHANGE_RETURN_INVOICE
,
DOC_TYPE_EXCHANGE_RETURN_RECEIPT
,
DOC_TYPE_EXCHANGE_INVOICE
,
DOC_TYPE_EXCHANGE_RECEIPT
,
}
from
'@/constants/commodity'
;
import
AnchorPage
from
'@/layouts/AnchorPage'
;
import
NiceForm
from
'@/components/NiceForm'
;
import
createSchema
,
{
BillDetailSchemaType
,
BILL_DETAIL_KEY
}
from
'./schema'
;
import
{
createEffects
}
from
'./effects'
;
import
EllipsisText
from
'../EllipsisText'
;
const
TITLE_MAP
=
{
[
DOC_TYPE_PURCHASE_RECEIPT
]:
'采购入库单'
,
[
DOC_TYPE_SALES_INVOICE
]:
'销售发货单'
,
[
DOC_TYPE_PROCESS_RECEIPT
]:
'加工入库单'
,
[
DOC_TYPE_PROCESS_INVOICE
]:
'加工发货单'
,
[
DOC_TYPE_RETURN_INVOICE
]:
'退货发货单'
,
[
DOC_TYPE_RETURN_RECEIPT
]:
'退货入库单'
,
[
DOC_TYPE_EXCHANGE_RETURN_INVOICE
]:
'换货退货发货单'
,
[
DOC_TYPE_EXCHANGE_RETURN_RECEIPT
]:
'换货退货入货单'
,
[
DOC_TYPE_EXCHANGE_INVOICE
]:
'换货发货单'
,
[
DOC_TYPE_EXCHANGE_RECEIPT
]:
'换货入库单'
,
};
const
formActions
=
createFormActions
();
const
{
onFieldValueChange$
,
onFieldInputChange$
,
onFormInputChange$
,
}
=
FormEffectHooks
;
export
type
RelatedInfoType
=
{
/**
* 关联单据编号
*/
relatedNo
:
string
,
/**
* 会员名称
*/
memberName
:
string
,
/**
* 收货地址 或 发货地址
*/
address
:
string
,
/**
* 物流方式名称
*/
logisticsTypeName
:
string
,
}
interface
IProps
{
/**
* 单据类型
*/
billType
:
number
,
/**
* 是否可编辑的
*/
editable
?:
boolean
,
/**
* 获取对应单据详情
*/
fetchRelatedInfo
:
()
=>
Promise
<
RelatedInfoType
>
,
}
const
BillsFormPage
:
React
.
FC
<
IProps
>
=
(
props
:
IProps
)
=>
{
const
{
billType
,
editable
=
true
,
fetchRelatedInfo
,
}
=
props
;
const
[
relatedLoading
,
setRelatedLoading
]
=
useState
(
false
);
const
[
unsaved
,
setUnsaved
]
=
useState
(
false
);
const
getRelatedInfo
=
()
=>
{
if
(
fetchRelatedInfo
)
{
setRelatedLoading
(
true
);
fetchRelatedInfo
().
then
((
res
)
=>
{
console
.
log
(
'res'
,
res
)
}).
finally
(()
=>
{
setRelatedLoading
(
false
);
});
}
};
useEffect
(()
=>
{
getRelatedInfo
();
},
[]);
const
anchorsArr
=
[
{
key
:
'basicInfo'
,
name
:
'基本信息'
,
},
{
key
:
'billDetail'
,
name
:
'单据明细'
,
},
];
const
handleSubmit
=
(
values
:
any
)
=>
{
};
return
(
<
Spin
spinning=
{
relatedLoading
}
>
<
AnchorPage
title=
{
TITLE_MAP
[
1
]
}
anchors=
{
anchorsArr
}
extra=
{
(
<
Button
type=
"primary"
>
保存
</
Button
>
)
}
>
<
NiceForm
previewPlaceholder=
" "
onSubmit=
{
handleSubmit
}
actions=
{
formActions
}
initialValues=
{
{}
}
components=
{
{
RadioGroup
:
Radio
.
Group
,
ArrayTable
,
Text
:
EllipsisText
,
}
}
effects=
{
(
$
,
actions
)
=>
{
createEffects
(
$
,
actions
);
onFormInputChange$
().
subscribe
(()
=>
{
if
(
!
unsaved
)
{
setUnsaved
(
true
);
}
});
}
}
schema=
{
createSchema
(
billType
)
}
editable=
{
!!
editable
}
/>
</
AnchorPage
>
</
Spin
>
);
};
export
default
BillsFormPage
;
src/pages/transaction/stockSellStorage/bills/components/BillsFormPage/schema.ts
0 → 100644
View file @
8eaea579
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment