index.ts 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. import { shallowRef, ref, reactive, computed } from 'vue'
  2. import { v4 } from 'uuid'
  3. import { useDataTable } from '@/hooks/datatable'
  4. import { queryGzbscinOutOrder, queryBScinOutOrderDetail, queryBScOutOrderDetailatt, queryGzbscusermonthpay, queryGzbscuserpowerfee, queryBscinoutorder, bscInAndOutWareHouseApply, bscUploadFile, bscConfirmPay } from '@/services/api/bonded'
  5. import { loginStore } from '@/stores'
  6. import Long from 'long'
  7. const { userId } = loginStore.$mapGetters()
  8. export type RequiredType<T, K extends keyof T> = Partial<T> & Pick<T, K> // 指定某个属性为必选
  9. // 保税仓出入库申请列表
  10. export function useGzbscinOutOrder() {
  11. const { dataList, total, pageIndex, pageSize } = useDataTable<Ermcp.GzbscinOutOrderRsp>()
  12. const loading = shallowRef(false)
  13. const getGzbscinOutOrder = (params: RequiredType<Ermcp.GzbscinOutOrderReq, 'ordertype'>) => {
  14. loading.value = true
  15. return queryGzbscinOutOrder({
  16. data: {
  17. page: pageIndex.value,
  18. pagesize: pageSize.value,
  19. userid: userId.value,
  20. ...params,
  21. },
  22. success: (res) => {
  23. total.value = res.total
  24. dataList.value = res.data
  25. },
  26. complete: () => {
  27. loading.value = false
  28. }
  29. })
  30. }
  31. return {
  32. loading,
  33. dataList,
  34. total,
  35. pageIndex,
  36. pageSize,
  37. getGzbscinOutOrder,
  38. }
  39. }
  40. // 保税仓出库申请明细附表
  41. export function useBScinOutOrderDetail(orderid: string) {
  42. const orderDetailList = ref<Ermcp.BScinOutOrderDetailRsp[]>([]) // 明细列表
  43. const orderDetailAttList = ref<Ermcp.BScOutOrderDetailattRsp[]>([]) // 附表列表
  44. const getBScinOutOrderDetail = (params: Partial<Ermcp.BScinOutOrderDetailReq> = {}) => {
  45. return queryBScinOutOrderDetail({
  46. data: {
  47. userid: userId.value,
  48. orderid,
  49. ...params,
  50. },
  51. success: (res) => {
  52. orderDetailList.value = res.data
  53. },
  54. })
  55. }
  56. const getBScOutOrderDetailatt = (params: Partial<Ermcp.BScOutOrderDetailattReq> = {}) => {
  57. return queryBScOutOrderDetailatt({
  58. data: {
  59. userid: userId.value,
  60. orderid,
  61. ...params,
  62. },
  63. success: (res) => {
  64. orderDetailAttList.value = res.data
  65. },
  66. })
  67. }
  68. return {
  69. orderDetailList,
  70. orderDetailAttList,
  71. getBScinOutOrderDetail,
  72. getBScOutOrderDetailatt,
  73. }
  74. }
  75. // 保税仓进出仓申请
  76. export function useBscInAndOutWareHouseApply(OrderType: number) {
  77. const { UserID, LoginID, LoginCode } = loginStore.state.loginInfo
  78. const loading = shallowRef(false)
  79. const formData = reactive<Proto.BSCInAndOutWareHouseApplyReq>({
  80. UserID, // 用户ID,必填
  81. UserName: '', // 申请方名称,必填
  82. UserAddress: '', // 申请方地点,必填
  83. ContactName: '', // 申请方联系人,必填
  84. ContactNum: '', // 申请方联系电话,必填
  85. LogisticsCompany: '', // 物流公司名称,必填
  86. LogisticsNo: '', // 托运单号,选填
  87. OrderType, // 单据类型,必填1:进仓2:出仓
  88. BSCGoodsListDetails: [], // 明细列表(数组),必填
  89. BSCOutWareHouseSchedules: [], // 出仓附表(数组),必填
  90. OperateID: LoginID, // 操作人ID,必填
  91. OperateAccount: LoginCode, // 操作人账户,必填
  92. ClientSerialNo: '', // 客户端流水号
  93. })
  94. const formSubmit = () => {
  95. loading.value = true
  96. return bscInAndOutWareHouseApply({
  97. data: {
  98. ...formData,
  99. ClientSerialNo: v4(),
  100. },
  101. complete: () => {
  102. loading.value = false
  103. }
  104. })
  105. }
  106. return {
  107. loading,
  108. formData,
  109. formSubmit,
  110. }
  111. }
  112. // 保税仓上传文件
  113. export function useBscUploadFile(orderId: string) {
  114. const { UserID, LoginID, LoginCode } = loginStore.state.loginInfo
  115. const loading = shallowRef(false)
  116. const formData = reactive<Proto.BSCUploadFileReq>({
  117. UserID, // 用户ID,必填
  118. OrderID: Long.fromString(orderId), // 单据ID,必填
  119. FileDetails: [], // 文件列表,必填
  120. ClientSerialNo: '', // 客户端流水号
  121. OperateID: LoginID, // 操作人ID,必填
  122. OperateAccount: LoginCode, // 操作人账户,必填
  123. })
  124. const formSubmit = () => {
  125. loading.value = true
  126. return bscUploadFile({
  127. data: {
  128. ...formData,
  129. ClientSerialNo: v4(),
  130. },
  131. complete: () => {
  132. loading.value = false
  133. }
  134. })
  135. }
  136. return {
  137. loading,
  138. formData,
  139. formSubmit,
  140. }
  141. }
  142. // 保税仓计费管理列表
  143. export function useGzbscusermonthpay() {
  144. const { dataList, total, pageIndex, pageSize } = useDataTable<Ermcp.GzbscusermonthpayRsp>()
  145. const loading = shallowRef(false)
  146. const getGzbscusermonthpay = (params: Partial<Ermcp.GzbscusermonthpayReq> = {}) => {
  147. loading.value = true
  148. return queryGzbscusermonthpay({
  149. data: {
  150. page: pageIndex.value,
  151. pagesize: pageSize.value,
  152. userid: userId.value,
  153. ...params,
  154. },
  155. success: (res) => {
  156. total.value = res.total
  157. dataList.value = res.data
  158. },
  159. complete: () => {
  160. loading.value = false
  161. }
  162. })
  163. }
  164. return {
  165. loading,
  166. dataList,
  167. total,
  168. pageIndex,
  169. pageSize,
  170. getGzbscusermonthpay,
  171. }
  172. }
  173. // 保税仓计费管理详情
  174. export function useGzbscusermonthpayDetails(trademonth: string) {
  175. const powerfeeList = shallowRef<Ermcp.GzbscuserpowerfeeRsp[]>([]) // 电费明细列表
  176. const bondedList = shallowRef<Ermcp.BscinoutorderRsp[]>([]) // 保税仓明细列表
  177. // 进口明细列表
  178. const importList = computed(() => bondedList.value.filter((e) => e.ordertype === 1))
  179. // 出境明细列表
  180. const exportList = computed(() => bondedList.value.filter((e) => e.ordertype === 2 && e.outtype === 1))
  181. // 转厂明细列表
  182. const transferList = computed(() => bondedList.value.filter((e) => e.ordertype === 2 && e.outtype === 2))
  183. queryGzbscuserpowerfee({
  184. data: {
  185. userid: userId.value,
  186. trademonth,
  187. },
  188. success: (res) => {
  189. powerfeeList.value = res.data
  190. }
  191. })
  192. queryBscinoutorder({
  193. data: {
  194. userid: userId.value,
  195. jckdate: trademonth,
  196. },
  197. success: (res) => {
  198. bondedList.value = res.data
  199. }
  200. })
  201. return {
  202. powerfeeList,
  203. importList,
  204. exportList,
  205. transferList,
  206. }
  207. }
  208. // 保税仓确认支付
  209. export function useBscConfirmPay(TradeMonth: string) {
  210. const loading = shallowRef(false)
  211. const formSubmit = () => {
  212. loading.value = true
  213. return bscConfirmPay({
  214. data: {
  215. UserID: userId.value, // 用户ID,必填
  216. TradeMonth, // 月份(yyyMM),必填
  217. ClientSerialNo: v4() // 客户端流水号
  218. },
  219. complete: () => {
  220. loading.value = false
  221. }
  222. })
  223. }
  224. return {
  225. loading,
  226. formSubmit,
  227. }
  228. }