import { shallowRef, ref, reactive, computed } from 'vue' import { v4 } from 'uuid' import { useDataTable } from '@/hooks/datatable' import { queryGzbscinOutOrder, queryBScinOutOrderDetail, queryBScOutOrderDetailatt, queryGzbscusermonthpay, queryGzbscuserpowerfee, queryBscinoutorder, bscInAndOutWareHouseApply, bscUploadFile, bscConfirmPay } from '@/services/api/bonded' import { loginStore } from '@/stores' import Long from 'long' const { userId } = loginStore.$mapGetters() export type RequiredType = Partial & Pick // 指定某个属性为必选 // 保税仓出入库申请列表 export function useGzbscinOutOrder() { const { dataList, total, pageIndex, pageSize } = useDataTable() const loading = shallowRef(false) const getGzbscinOutOrder = (params: RequiredType) => { loading.value = true return queryGzbscinOutOrder({ data: { page: pageIndex.value, pagesize: pageSize.value, userid: userId.value, ...params, }, success: (res) => { total.value = res.total dataList.value = res.data }, complete: () => { loading.value = false } }) } return { loading, dataList, total, pageIndex, pageSize, getGzbscinOutOrder, } } // 保税仓出库申请明细附表 export function useBScinOutOrderDetail(orderid: string) { const orderDetailList = ref([]) // 明细列表 const orderDetailAttList = ref([]) // 附表列表 const getBScinOutOrderDetail = (params: Partial = {}) => { return queryBScinOutOrderDetail({ data: { userid: userId.value, orderid, ...params, }, success: (res) => { orderDetailList.value = res.data }, }) } const getBScOutOrderDetailatt = (params: Partial = {}) => { return queryBScOutOrderDetailatt({ data: { userid: userId.value, orderid, ...params, }, success: (res) => { orderDetailAttList.value = res.data }, }) } return { orderDetailList, orderDetailAttList, getBScinOutOrderDetail, getBScOutOrderDetailatt, } } // 保税仓进出仓申请 export function useBscInAndOutWareHouseApply(OrderType: number) { const { UserID, LoginID, LoginCode } = loginStore.state.loginInfo const loading = shallowRef(false) const formData = reactive({ UserID, // 用户ID,必填 UserName: '', // 申请方名称,必填 UserAddress: '', // 申请方地点,必填 ContactName: '', // 申请方联系人,必填 ContactNum: '', // 申请方联系电话,必填 LogisticsCompany: '', // 物流公司名称,必填 LogisticsNo: '', // 托运单号,选填 OrderType, // 单据类型,必填1:进仓2:出仓 BSCGoodsListDetails: [], // 明细列表(数组),必填 BSCOutWareHouseSchedules: [], // 出仓附表(数组),必填 OperateID: LoginID, // 操作人ID,必填 OperateAccount: LoginCode, // 操作人账户,必填 ClientSerialNo: '', // 客户端流水号 }) const formSubmit = () => { loading.value = true return bscInAndOutWareHouseApply({ data: { ...formData, ClientSerialNo: v4(), }, complete: () => { loading.value = false } }) } return { loading, formData, formSubmit, } } // 保税仓上传文件 export function useBscUploadFile(orderId: string) { const { UserID, LoginID, LoginCode } = loginStore.state.loginInfo const loading = shallowRef(false) const formData = reactive({ UserID, // 用户ID,必填 OrderID: Long.fromString(orderId), // 单据ID,必填 FileDetails: [], // 文件列表,必填 ClientSerialNo: '', // 客户端流水号 OperateID: LoginID, // 操作人ID,必填 OperateAccount: LoginCode, // 操作人账户,必填 }) const formSubmit = () => { loading.value = true return bscUploadFile({ data: { ...formData, ClientSerialNo: v4(), }, complete: () => { loading.value = false } }) } return { loading, formData, formSubmit, } } // 保税仓计费管理列表 export function useGzbscusermonthpay() { const { dataList, total, pageIndex, pageSize } = useDataTable() const loading = shallowRef(false) const getGzbscusermonthpay = (params: Partial = {}) => { loading.value = true return queryGzbscusermonthpay({ data: { page: pageIndex.value, pagesize: pageSize.value, userid: userId.value, ...params, }, success: (res) => { total.value = res.total dataList.value = res.data }, complete: () => { loading.value = false } }) } return { loading, dataList, total, pageIndex, pageSize, getGzbscusermonthpay, } } // 保税仓计费管理详情 export function useGzbscusermonthpayDetails(trademonth: string) { const powerfeeList = shallowRef([]) // 电费明细列表 const bondedList = shallowRef([]) // 保税仓明细列表 // 进口明细列表 const importList = computed(() => bondedList.value.filter((e) => e.ordertype === 1)) // 出境明细列表 const exportList = computed(() => bondedList.value.filter((e) => e.ordertype === 2 && e.outtype === 1)) // 转厂明细列表 const transferList = computed(() => bondedList.value.filter((e) => e.ordertype === 2 && e.outtype === 2)) queryGzbscuserpowerfee({ data: { userid: userId.value, trademonth, }, success: (res) => { powerfeeList.value = res.data } }) queryBscinoutorder({ data: { userid: userId.value, jckdate: trademonth, }, success: (res) => { bondedList.value = res.data } }) return { powerfeeList, importList, exportList, transferList, } } // 保税仓确认支付 export function useBscConfirmPay(TradeMonth: string) { const loading = shallowRef(false) const formSubmit = () => { loading.value = true return bscConfirmPay({ data: { UserID: userId.value, // 用户ID,必填 TradeMonth, // 月份(yyyMM),必填 ClientSerialNo: v4() // 客户端流水号 }, complete: () => { loading.value = false } }) } return { loading, formSubmit, } }