diff --git a/src/views/refund/gold/addCoinRefund.vue b/src/views/refund/gold/addCoinRefund.vue index 6c743c7..1795349 100644 --- a/src/views/refund/gold/addCoinRefund.vue +++ b/src/views/refund/gold/addCoinRefund.vue @@ -3,26 +3,24 @@ import { computed, onMounted, reactive, ref, watch } from 'vue' import { ElMessage, ElMessageBox } from 'element-plus' import API from '@/util/http.js' import moment from 'moment' -// import _ from 'lodash' +import {useAdminStore} from "@/store/index.js"; +import {storeToRefs} from "pinia"; +import {findMenuById, permissionMapping} from "@/utils/menuTreePermission.js" +import { ta } from 'element-plus/es/locales.mjs'; + +const adminStore = useAdminStore(); +const {adminData, menuTree} = storeToRefs(adminStore); const addRe = ref({ typeR: '0' }) +const tableData = ref([]) +const pagination = ref({ + pageNum: 1, + pageSize: 10, + total: 0 +}) - -//这是获取用户信息的接口 -const adminData = ref({}) -const getAdminData = async function () { - try { - const result = await API({ url: '/admin/userinfo', data: {} }) - adminData.value = result - addRefund.value.adminId = adminData.value.id - console.log('请求成功', result) - console.log('用户信息', user.value) - } catch (error) { - console.log('请求失败', error) - } -} // 精网号去空格 const trimJwCode = () => { if (addRefund.value.jwcode) { @@ -41,8 +39,8 @@ const addRefund = ref({ sumGold: 0, remark: '', adminId: null, - orderCode: '' - + orderCode: '', + type: 0 }) // 取消按钮 @@ -63,15 +61,20 @@ const cancel = function () { addRe.value.typeR = '0' } - +const show = function () { + console.log('===================================', addRefund.value.refundType) +} // 这是添加退款信息的接口 const add = async function () { try { // 更新 refundModel addRefund.value.refundModel = parseInt(addRe.value.typeR); - - + if (addRefund.value.refundType === '商品退款') { + addRefund.value.type = 1 + } else { + addRefund.value.type = 0 + } // 对提交的金币数乘以 100 const processedRefund = { ...addRefund.value, @@ -86,6 +89,7 @@ const add = async function () { url: '/refund/add', data: processedRefund }) + addDisabled.value = false if (result.code === 0) { ElMessage.error(result.msg) @@ -254,30 +258,10 @@ const getUser = async function (jwcode) { // 退款类型,写死为商品退款 -const refundType = ref([{ value: '商品退款', label: '商品退款' }]); - -// 获取退款类型 -// const getRefundTypes = async function () { -// try { -// // 发送请求获取退款类型 -// const result = await API({ -// url: '/refund/refundType', //这里应该写上一个退款类型的接口 -// data: {} }) -// console.log('退款类型请求成功', result) -// // 检查返回的数据是否为数组 -// if (Array.isArray(result.data)) { -// // 将字符串数组转换为 { value, label } 格式 -// refundType.value = result.data.map(item => ({ value: item, label: item })); -// } else { -// console.error('退款类型数据格式错误', result) -// ElMessage.error('退款类型数据格式错误,请联系管理员') -// } -// console.log('退款类型', refundType.value) -// } catch (error) { -// console.log('退款类型请求失败', error) -// } -// } - +const refundType = ref([ + { value: '商品退款', label: '商品退款' }, + { value: '金币退款', label: '金币退款' } +]); // 根据精网号查询商品 const goodsName = ref([]) // 存储所有商品信息 @@ -295,12 +279,25 @@ const getGoods = async function (jwcode) { orderCodes.value = [] return; } - + console.log('=======================', addRefund.value.refundType) + if (addRefund.value.refundType === '商品退款') { + addRefund.value.type = 1 + } else { + addRefund.value.type = 0 + } try { const result = await API({ url: '/refund/selectGoods', - data: { jwcode: addRefund.value.jwcode } + data: { + jwcode: addRefund.value.jwcode, + type: addRefund.value.type + } }) + tableData.value = result.data + if (result.data.length === 0) { + ElMessage.error('该用户没有商品订单') + return + } if (Array.isArray(result.data)) { // 存储完整商品数据 @@ -466,29 +463,29 @@ watch(calculatedRechargeGoods, (newVal) => { addRefund.value.sumGold = newVal console.log('计算的总金币', newVal) }) +const handlePageSizeChange = function (val) { + pagination.value.pageSize = val +} +const handleCurrentChange = function (val) { + pagination.value.pageNum = val +} - -// 挂载 -onMounted(async function () { - await getAdminData() - // await getRefundTypes() - // await getGoods() -})