|
|
@@ -1,8 +1,9 @@
|
|
|
import { shallowRef, reactive } from 'vue'
|
|
|
import { useDataTable } from '@/hooks/datatable'
|
|
|
import { getTableColumns } from '@/business/table'
|
|
|
-import { queryUserReceiveInfo, queryWrUserReceiptInfo, userReceiveInfo } from '@/services/api/user'
|
|
|
+import { queryUserReceiveInfo, queryWrUserReceiptInfo, userReceiveInfo, delUserReceiveInfo, userReceiveIsDefault, userReceiptInfo, delUserReceiptInfo } from '@/services/api/user'
|
|
|
import { sessionData } from '@/stores'
|
|
|
+import { getCertificateTypeList } from '@/constants/certificate'
|
|
|
|
|
|
export function useAddress() {
|
|
|
const { dataList, total, pageIndex, pageSize } = useDataTable<Ermcp.UserReceiveInfoRsp>()
|
|
|
@@ -37,24 +38,29 @@ export function useAddress() {
|
|
|
}
|
|
|
|
|
|
export function useAddressForm(selectedRow?: Ermcp.UserReceiveInfoRsp) {
|
|
|
+ const { UserID } = sessionData.getValue('loginInfo')
|
|
|
const loading = shallowRef(false)
|
|
|
+ const certificateTypeList = getCertificateTypeList()
|
|
|
+
|
|
|
const formData = reactive<Proto.UserReceiveInfoReq>({
|
|
|
- ClientSerialID: 0,
|
|
|
- UserID: sessionData.getLoginInfo('UserID'),
|
|
|
+ ReceiveInfoId: 0,
|
|
|
+ UserID,
|
|
|
+ CardTypeID: 0,
|
|
|
ReceiverName: '',
|
|
|
CardNum: '',
|
|
|
PhoneNum: '',
|
|
|
- CountryID: 0,
|
|
|
Address: '',
|
|
|
TakeRemark: '',
|
|
|
})
|
|
|
|
|
|
if (selectedRow?.autoid) {
|
|
|
({
|
|
|
+ autoid: formData.ReceiveInfoId,
|
|
|
userid: formData.UserID,
|
|
|
receivername: formData.ReceiverName,
|
|
|
cardtypeid: formData.CardTypeID,
|
|
|
cardnum: formData.CardNum,
|
|
|
+ phonenum: formData.PhoneNum,
|
|
|
countryid: formData.CountryID,
|
|
|
provinceid: formData.ProvinceID,
|
|
|
cityid: formData.CityID,
|
|
|
@@ -64,7 +70,7 @@ export function useAddressForm(selectedRow?: Ermcp.UserReceiveInfoRsp) {
|
|
|
} = selectedRow)
|
|
|
}
|
|
|
|
|
|
- const formSubmit = () => {
|
|
|
+ const addOrUpdate = () => {
|
|
|
loading.value = true
|
|
|
return userReceiveInfo({
|
|
|
data: formData,
|
|
|
@@ -74,10 +80,38 @@ export function useAddressForm(selectedRow?: Ermcp.UserReceiveInfoRsp) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ const deleteAddress = () => {
|
|
|
+ loading.value = true
|
|
|
+ return delUserReceiveInfo({
|
|
|
+ data: {
|
|
|
+ ReceiveInfoId: formData.ReceiveInfoId
|
|
|
+ },
|
|
|
+ complete: () => {
|
|
|
+ loading.value = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const updateAddressIsDefault = () => {
|
|
|
+ loading.value = true
|
|
|
+ return userReceiveIsDefault({
|
|
|
+ data: {
|
|
|
+ UserId: UserID,
|
|
|
+ AutoId: formData.ReceiveInfoId
|
|
|
+ },
|
|
|
+ complete: () => {
|
|
|
+ loading.value = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
return {
|
|
|
loading,
|
|
|
+ certificateTypeList,
|
|
|
formData,
|
|
|
- formSubmit,
|
|
|
+ addOrUpdate,
|
|
|
+ deleteAddress,
|
|
|
+ updateAddressIsDefault,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -111,4 +145,67 @@ export function useInvoice() {
|
|
|
pageSize,
|
|
|
getUserInvoiceList,
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+export function useInvoiceForm(selectedRow?: Ermcp.WrUserReceiptInfoRsp) {
|
|
|
+ const { UserID } = sessionData.getValue('loginInfo')
|
|
|
+ const loading = shallowRef(false)
|
|
|
+ const certificateTypeList = getCertificateTypeList()
|
|
|
+
|
|
|
+ const formData = reactive<Proto.UserReceiptInfoReq>({
|
|
|
+ UserID, // 用户ID
|
|
|
+ UserName: '', // 发票抬头姓名
|
|
|
+ ReceiptType: 1, // 发票类型
|
|
|
+ TaxpayerID: '', // 纳税人识别号
|
|
|
+ ContactInfo: '', // 联系方式
|
|
|
+ ReceiptInfoId: 0, // 修改时填用户发票信息id
|
|
|
+ ReceiptBank: '', // 发票开户行[发票类型:企业]
|
|
|
+ ReceiptAccount: '', // 发票帐号[发票类型:企业]
|
|
|
+ Address: '', // 地址[发票类型:企业]
|
|
|
+ })
|
|
|
+
|
|
|
+ if (selectedRow?.autoid) {
|
|
|
+ ({
|
|
|
+ autoid: formData.ReceiptInfoId,
|
|
|
+ userid: formData.UserID,
|
|
|
+ username: formData.UserName,
|
|
|
+ receipttype: formData.ReceiptType,
|
|
|
+ taxpayerid: formData.TaxpayerID,
|
|
|
+ contactinfo: formData.ContactInfo,
|
|
|
+ receiptbank: formData.ReceiptBank,
|
|
|
+ receiptaccount: formData.ReceiptAccount,
|
|
|
+ address: formData.Address,
|
|
|
+ idnum: formData.IDNum,
|
|
|
+ } = selectedRow)
|
|
|
+ }
|
|
|
+
|
|
|
+ const addOrUpdate = () => {
|
|
|
+ loading.value = true
|
|
|
+ return userReceiptInfo({
|
|
|
+ data: formData,
|
|
|
+ complete: () => {
|
|
|
+ loading.value = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const deleteInvoice = () => {
|
|
|
+ loading.value = true
|
|
|
+ return delUserReceiptInfo({
|
|
|
+ data: {
|
|
|
+ ReceiptInfoId: formData.ReceiptInfoId
|
|
|
+ },
|
|
|
+ complete: () => {
|
|
|
+ loading.value = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ return {
|
|
|
+ loading,
|
|
|
+ certificateTypeList,
|
|
|
+ formData,
|
|
|
+ addOrUpdate,
|
|
|
+ deleteInvoice,
|
|
|
+ }
|
|
|
}
|