| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- import { shallowRef } from 'vue'
- import { useDataTable } from '@/hooks/datatable'
- import { queryTHJWrstandard, queryTHJWrstandardDetail, addUserFavoriteGoods, removeUserFavoriteGoods, queryTHJProduct, queryMarketRun, queryTHJTradeData, querySpotGoodsPrice } from '@/services/api/goods'
- import { useLoginStore } from '@/stores'
- // 采购列表
- export function useWrstandardList() {
- const { dataList, total, pageIndex, pageSize, pageCount } = useDataTable<Model.THJWrstandardRsp>()
- const loading = shallowRef(false)
- const getWrstandardList = async () => {
- loading.value = true
- await queryTHJWrstandard({
- data: {
- page: pageIndex.value,
- pagesize: pageSize.value,
- },
- success: (res) => {
- total.value = res.total
- dataList.value = res.data
- },
- complete: () => {
- loading.value = false
- }
- })
- return dataList.value
- }
- return {
- loading,
- dataList,
- total,
- pageIndex,
- pageSize,
- pageCount,
- getWrstandardList,
- }
- }
- // 采购详细
- export function useWrstandardDetails(wrstandardid: number) {
- const details = shallowRef<Partial<Model.THJWrstandardDetailRsp>>({})
- const getWrstandardDetails = () => {
- return queryTHJWrstandardDetail({
- data: {
- wrstandardid,
- },
- success: (res) => {
- details.value = res.data
- }
- })
- }
- return {
- details,
- getWrstandardDetails,
- }
- }
- // 添加用户商品收藏信息
- export function useAddUserFavoriteGoods(goodsid: number) {
- const { getUserId } = useLoginStore()
- const getAddUserFavoriteGoods = () => {
- return addUserFavoriteGoods({
- data: {
- userID: getUserId(),
- goodsID: goodsid
- },
- success: (res) => { console.log(res) }
- })
- }
- return { getAddUserFavoriteGoods }
- }
- // 移除用户商品收藏信息
- export function useRemoveUserFavoriteGoods(goodsid: number) {
- const { getUserId } = useLoginStore()
- const getRemoveUserFavoriteGoods = () => {
- return removeUserFavoriteGoods({
- data: {
- userID: getUserId(),
- goodsID: goodsid
- },
- success: (res) => { console.log(res) }
- })
- }
- return { getRemoveUserFavoriteGoods }
- }
- // 获取我的推广-交易数据
- export function useQueryTHJTradeDataList() {
- const { dataList, total, pageIndex, pageSize, pageCount } = useDataTable<Model.THJTradeDataRsp>()
- const loading = shallowRef(false)
- const { getUserId } = useLoginStore()
- const getQueryTHJTradeDataList = async (marketid: number) => {
- loading.value = true
- await queryTHJTradeData({
- data: {
- userid: getUserId(),
- marketid: marketid,
- page: pageIndex.value,
- pagesize: pageSize.value,
- },
- success: (res) => {
- total.value = res.total
- dataList.value = res.data
- },
- complete: () => {
- loading.value = false
- }
- })
- return dataList.value
- }
- return {
- loading,
- dataList,
- total,
- pageIndex,
- pageSize,
- pageCount,
- getQueryTHJTradeDataList,
- }
- }
- // 获取产品介绍列表
- export function useQueryTHJProductLists() {
- const { dataList, total, pageIndex, pageSize, pageCount } = useDataTable<Model.THJProductRsp>()
- const loading = shallowRef(false)
- const { getUserId } = useLoginStore()
- const active = shallowRef(0)
- const getQueryTHJProductLists = async () => {
- loading.value = true
- await queryTHJProduct({
- data: {
- userid: getUserId(),
- favoriteflag: active.value === 0,
- page: pageIndex.value,
- pagesize: pageSize.value,
- },
- success: (res) => {
- total.value = res.total
- dataList.value = res.data
- },
- complete: () => {
- loading.value = false
- }
- })
- return dataList.value
- }
- return {
- loading,
- dataList,
- active,
- total,
- pageIndex,
- pageSize,
- pageCount,
- getQueryTHJProductLists,
- }
- }
- // 获取现货行情
- export function useQuerySpotGoodsPriceLists() {
- const { dataList, total, pageIndex, pageSize, pageCount } = useDataTable<Model.SpotGoodsPriceRsp>()
- const loading = shallowRef(false)
- const getQuerySpotGoodsPriceLists = () => {
- loading.value = true
- return querySpotGoodsPrice({
- data: {
- page: pageIndex.value,
- pagesize: pageSize.value,
- },
- success: (res) => {
- total.value = res.total
- dataList.value = res.data
- },
- complete: () => {
- loading.value = false
- }
- })
- }
- return {
- loading,
- dataList,
- total,
- pageIndex,
- pageSize,
- pageCount,
- getQuerySpotGoodsPriceLists,
- }
- }
- // 查询市场运行信息
- export function useQueryMarketRunLists() {
- const { dataList, total, pageIndex, pageSize, pageCount } = useDataTable<Model.MarketRunRsp>()
- const loading = shallowRef(false)
- const getQueryMarketRunLists = (marketid?: number) => {
- loading.value = true
- return queryMarketRun({
- data: {
- marketID: marketid
- },
- success: (res) => {
- total.value = res.total
- dataList.value = res.data
- },
- complete: () => {
- loading.value = false
- }
- })
- }
- return {
- loading,
- dataList,
- total,
- pageIndex,
- pageSize,
- pageCount,
- getQueryMarketRunLists,
- }
- }
|