图床功能、部分bug修改
This commit is contained in:
parent
87f925a9c7
commit
74c92216f8
|
@ -31,6 +31,11 @@
|
|||
<span slot="title">用户列表</span>
|
||||
</el-menu-item>
|
||||
|
||||
<el-menu-item index="/Upload">
|
||||
<el-icon><List /></el-icon>
|
||||
<span slot="title">图片上传</span>
|
||||
</el-menu-item>
|
||||
|
||||
</el-sub-menu>
|
||||
|
||||
<el-sub-menu index="2">
|
||||
|
|
|
@ -18,6 +18,11 @@ export const routes = [
|
|||
name:'个人中心',
|
||||
component: ()=> import("../views/User/PersonalCenter.vue")
|
||||
},
|
||||
{
|
||||
path: '/Upload',
|
||||
name:'文件上传',
|
||||
component: ()=> import("../views/User/Upload.vue")
|
||||
},
|
||||
{
|
||||
path: '/UserManagement',
|
||||
name:'用户列表',
|
||||
|
|
|
@ -180,7 +180,9 @@ const total = ref(0); //总页数
|
|||
const id = ref([]);
|
||||
const searchParams: any = ref({ //封装分页
|
||||
current: 1, //当前页码
|
||||
pageSize: 5 //每页显示条数
|
||||
pageSize: 5, //每页显示条数
|
||||
sortField: "id", //根据ID分类
|
||||
sortOrder: "descend" //降序
|
||||
})
|
||||
const fileSimple = ref()
|
||||
const disabled = ref(true)
|
||||
|
|
|
@ -1,74 +1,84 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-input style="width: 200px; height: 30px; margin-right: 10px;" suffix-icon="Search" placeholder="请输入订单编号"
|
||||
v-model="name"></el-input>
|
||||
v-model="name"></el-input>
|
||||
<el-button class="ml-5" type="primary" @click="load" style="height: 25px;">搜索</el-button>
|
||||
<el-button type="warning" @click="reset" style="height:25px">重置</el-button>
|
||||
</div>
|
||||
<div style="margin: 15px 0">
|
||||
<el-popconfirm class="ml-5" confirm-button-text='确定' cancel-button-text='取消' icon="InfoFilled" icon-color="red"
|
||||
title="您确定批量删除这些数据吗?" @confirm="delBatch" width=180>
|
||||
<template #reference>
|
||||
<el-button style="height: 25px" class="ml-5" type="danger">批量删除 <el-icon style="margin-left: 5px;">
|
||||
<div style="margin: 15px 0">
|
||||
<el-popconfirm class="ml-5" confirm-button-text='确定' cancel-button-text='取消' icon="InfoFilled" icon-color="red"
|
||||
title="您确定批量删除这些数据吗?" @confirm="delBatch" width=180>
|
||||
<template #reference>
|
||||
<el-button style="height: 25px" class="ml-5" type="danger">批量删除 <el-icon style="margin-left: 5px;">
|
||||
<Remove />
|
||||
</el-icon></el-button>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</div>
|
||||
<!-- 数据展示层 -->
|
||||
<el-table :data="tableData" border stripe header-cell-class-name="headerBg"
|
||||
:cell-style="{ 'text-align': 'center', 'font-size': '16px' }" @selection-change="handleSelectionChange"
|
||||
:header-cell-style="{ 'text-align': 'center' }">
|
||||
<el-table-column type="selection" width="55" fixed="left"></el-table-column>
|
||||
<el-table-column prop="id" label="订单编号" width="80"></el-table-column>
|
||||
<el-table-column prop="userId" label="用户id"></el-table-column>
|
||||
<el-table-column prop="orderNumber" label="订单编号" width="150"></el-table-column>
|
||||
<!-- 商品信息需要发第二次请求 -->
|
||||
<el-table-column label="所购买的商品" width="100">
|
||||
<el-table-column label="展开所有商品" type="expand" width="100">
|
||||
<el-table :data="orderDetail">
|
||||
<el-table-column label="商品编号" prop="id" />
|
||||
<el-table-column label="商品名称" prop="orderDetail[num].type" />
|
||||
<el-table-column label="商品图片" prop="orderDetail[num].price" />
|
||||
<el-table-column label="类别" prop="city" />
|
||||
<el-table-column label="商品单价" prop="address" />
|
||||
<el-table-column label="是否是限定商品" prop="zip" />
|
||||
<el-table-column label="数量" prop="address" />
|
||||
</el-table>
|
||||
</el-table-column>
|
||||
</el-table-column>
|
||||
<el-table-column label="地址信息快照" width="180">
|
||||
<el-table-column prop="addressSnapshot.name" label="收货人" />
|
||||
<el-table-column prop="addressSnapshot.phone" label="手机号" />
|
||||
<el-table-column prop="addressSnapshot.region" label="地区" />
|
||||
<el-table-column prop="addressSnapshot.detailAddress" label="详细地址" />
|
||||
</el-table-column>
|
||||
<el-table-column label="优惠卷信息快照" width="50">
|
||||
<el-table-column prop="couponSnapshot.name" label="优惠卷名称" />
|
||||
<el-table-column prop="couponSnapshot.conditionAmount" label="优惠金额" />
|
||||
</el-table-column>
|
||||
<el-table-column prop="totalAmount" label="订单总金额"></el-table-column>
|
||||
<el-table-column prop="orderStatus" label="订单状态"></el-table-column>
|
||||
<el-table-column label="操作" width="120px" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button size="small" @click="showDetail(scope.$index, scope.row , 0)">
|
||||
详情
|
||||
</el-button>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</div>
|
||||
<!-- 数据展示层 -->
|
||||
<el-table :data="tableData" border stripe header-cell-class-name="headerBg"
|
||||
:cell-style="{ 'text-align': 'center', 'font-size': '16px' }" @selection-change="handleSelectionChange"
|
||||
:header-cell-style="{ 'text-align': 'center' }">
|
||||
<el-table-column type="selection" width="55" fixed="left"></el-table-column>
|
||||
<el-table-column prop="id" label="订单编号" width="80"></el-table-column>
|
||||
<el-table-column prop="userId" label="用户id"></el-table-column>
|
||||
<el-table-column prop="userName" label="用户名" width="100"></el-table-column>
|
||||
<el-table-column prop="orderNumber" label="订单编号" width="150"></el-table-column>
|
||||
<el-table-column label="所购买的商品" width="100">
|
||||
<el-table-column label="展开所有商品" type="expand" width="100">
|
||||
<template #default="props">
|
||||
<el-table :data="props.row.orderItemList">
|
||||
<el-table-column label="商品名称" prop="goodSnapshot.name" />
|
||||
<el-table-column label="商品图片" prop="goodSnapshot.goodImg">
|
||||
<template #default="scope">
|
||||
<div>
|
||||
<img :src="scope.row.goodSnapshot.goodImg" alt="" style="height: 50px;">
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="类别" prop="goodSnapshot.type" />
|
||||
<el-table-column label="商品单价" prop="goodSnapshot.price" />
|
||||
<el-table-column label="是否是限定商品" prop="goodSnapshot.festivalOrder" />
|
||||
<el-table-column label="数量" prop="quantity" />
|
||||
<el-table-column label="总价" prop="itemTotalAmount" />
|
||||
</el-table>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div style="padding: 10px 0">
|
||||
<el-pagination @size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
:current-page="searchParams.current"
|
||||
:page-size="searchParams.pageSize"
|
||||
:page-sizes="[5, 10, 15, 20]"
|
||||
:small="null" :disabled="null"
|
||||
:background="null"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="total" />
|
||||
</div>
|
||||
<!-- <el-dialog title="订单详情信息" v-model="orderList" width="60%">
|
||||
</el-table-column>
|
||||
<el-table-column label="地址信息快照" width="180">
|
||||
<el-table-column prop="addressSnapshot.name" label="收货人" />
|
||||
<el-table-column prop="addressSnapshot.phone" label="手机号" />
|
||||
<el-table-column prop="addressSnapshot.region" label="地区" />
|
||||
<el-table-column prop="addressSnapshot.detailAddress" label="详细地址" />
|
||||
</el-table-column>
|
||||
<el-table-column label="优惠卷信息快照" width="50">
|
||||
<el-table-column prop="couponSnapshot.name" label="优惠卷名称" />
|
||||
<el-table-column prop="couponSnapshot.conditionAmount" label="优惠金额" />
|
||||
</el-table-column>
|
||||
<el-table-column prop="totalAmount" label="订单总金额"></el-table-column>
|
||||
<el-table-column prop="orderStatus" label="订单状态"></el-table-column>
|
||||
<el-table-column prop="orderStatus" label="快递单号"></el-table-column>
|
||||
<el-table-column label="操作" width="220px" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button size="small" @click="showDetail(scope.$index, scope.row, 0)">
|
||||
详情
|
||||
</el-button>
|
||||
<el-button size="small" @click="">
|
||||
发货
|
||||
</el-button>
|
||||
<el-button size="small" @click="" type="warning" plain>
|
||||
取消订单
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div style="padding: 10px 0">
|
||||
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
|
||||
:current-page="searchParams.current" :page-size="searchParams.pageSize" :page-sizes="[5, 10, 15, 20]"
|
||||
:small="null" :disabled="null" :background="null" layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="total" />
|
||||
</div>
|
||||
<!-- <el-dialog title="订单详情信息" v-model="orderList" width="60%">
|
||||
<el-form label-width="100px" size="default">
|
||||
<el-form-item label="订单id">
|
||||
<el-input v-model="orderList.id" autocomplete="off"></el-input>
|
||||
|
@ -117,103 +127,85 @@
|
|||
</div>
|
||||
</template>
|
||||
</el-dialog> -->
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {onMounted, ref} from "vue";
|
||||
import myAxios from "@/api/myAxios";
|
||||
import {ElMessage} from "element-plus";
|
||||
const tableData : any= ref([]); //表单展示数据
|
||||
const total = ref(0);
|
||||
const title = ref('')
|
||||
const editForm : any = ref({});
|
||||
const DialogVisible = ref(true);
|
||||
const name =ref('')
|
||||
const searchParams: any = ref({ //封装分页
|
||||
current: 1, //当前页码
|
||||
pageSize: 5 //每页显示条数
|
||||
})
|
||||
const num = ref(0)
|
||||
const orderDetail : any = ref([]) //订单中的商品明细,多个商品
|
||||
//订单列表
|
||||
const orderList = ref([{}])
|
||||
onMounted(()=>{
|
||||
getOrderList() //页面加载获取订单列表
|
||||
})
|
||||
const handleSizeChange = (newSize: any) => {
|
||||
searchParams.value.pageSize = newSize //新的页面数
|
||||
getOrderList()
|
||||
}
|
||||
const handleCurrentChange = (Current: any) => {
|
||||
searchParams.value.current = Current
|
||||
getOrderList()
|
||||
}
|
||||
const handleSelectionChange = (row: any) => {
|
||||
// id.value = JSON.parse(JSON.stringify(row));
|
||||
}
|
||||
const getOrderList = async () => {
|
||||
try {
|
||||
const res = await myAxios.post('/order/list/page', { ...searchParams.value});
|
||||
console.log('订单信息--->',res.data.data);
|
||||
</template>
|
||||
|
||||
if (res.data.code === 1) {
|
||||
tableData.value = res.data.data;
|
||||
total.value = res.data.data.length
|
||||
|
||||
|
||||
// console.log('tableData-->',tableData.value);
|
||||
//获取订单记录成功后,获取订单详情的商品记录
|
||||
// console.log('数组长度--->',tableData.value.length);
|
||||
// for(let key in tableData.value) {
|
||||
// num.value = parseInt(key)
|
||||
// const resOrderDetail = await myAxios.post('/order/list/item',{id:tableData.value[key].id}) //获取订单中详情记录
|
||||
// if( resOrderDetail.data.code === 1 ) {
|
||||
// orderDetail.value[num.value] = resOrderDetail.data.data //订单中的商品明细,多个商品
|
||||
// }
|
||||
// console.log('请求返回的resOrderDetail--->',resOrderDetail.data);
|
||||
// console.log('第',key,'次返回的orderDetail-->',orderDetail.value[num.value]);
|
||||
// console.log('总的orderDetail-->',orderDetail.value);
|
||||
// }
|
||||
// console.log(orderDetail.value);
|
||||
} else {
|
||||
ElMessage({
|
||||
message: '获取数据失败',
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, ref } from "vue";
|
||||
import myAxios from "@/api/myAxios";
|
||||
import { ElMessage } from "element-plus";
|
||||
const tableData: any = ref([]); //表单展示数据
|
||||
const total = ref(0);
|
||||
const title = ref('')
|
||||
const editForm: any = ref({});
|
||||
const DialogVisible = ref(true);
|
||||
const name = ref('')
|
||||
const searchParams: any = ref({ //封装分页
|
||||
current: 1, //当前页码
|
||||
pageSize: 5 //每页显示条数
|
||||
})
|
||||
const num = ref(0)
|
||||
const orderDetail: any = ref([]) //订单中的商品明细,多个商品
|
||||
//订单列表
|
||||
const orderList = ref([{}])
|
||||
onMounted(() => {
|
||||
getOrderList() //页面加载获取订单列表
|
||||
})
|
||||
const handleSizeChange = (newSize: any) => {
|
||||
searchParams.value.pageSize = newSize //新的页面数
|
||||
getOrderList()
|
||||
}
|
||||
const handleCurrentChange = (Current: any) => {
|
||||
searchParams.value.current = Current
|
||||
getOrderList()
|
||||
}
|
||||
const handleSelectionChange = (row: any) => {
|
||||
// id.value = JSON.parse(JSON.stringify(row));
|
||||
}
|
||||
//获取订单列表
|
||||
const getOrderList = async () => {
|
||||
try {
|
||||
const res = await myAxios.post('/order/list/page', { ...searchParams.value });
|
||||
console.log('订单信息--->', res.data.data);
|
||||
if (res.data.code === 1) {
|
||||
tableData.value = res.data.data.records;
|
||||
total.value = parseInt(res.data.data.total)
|
||||
console.log('表单信息--->', tableData.value[0].orderItemList);
|
||||
} else {
|
||||
ElMessage({
|
||||
message: '发生错误',
|
||||
message: '获取数据失败',
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
ElMessage({
|
||||
message: '发生错误',
|
||||
});
|
||||
}
|
||||
const delBatch =()=>{
|
||||
//批量删除
|
||||
}
|
||||
const showDetail = (index: number, row: any , flag : number) => {
|
||||
}
|
||||
const delBatch = () => {
|
||||
//批量删除
|
||||
}
|
||||
const showDetail = (index: number, row: any, flag: number) => {
|
||||
title.value = "订单详情"
|
||||
DialogVisible.value = true;
|
||||
editForm.value = row;
|
||||
};
|
||||
const deleteProduct = async (index: number) => {
|
||||
// console.log(typeof index)
|
||||
const res = await myAxios.post('/goods/delete', { id: index })
|
||||
console.log(res)
|
||||
if (res.data.code === 1) {
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '删除成功',
|
||||
})
|
||||
getOrderList()
|
||||
}
|
||||
DialogVisible.value = true;
|
||||
editForm.value = row;
|
||||
};
|
||||
const deleteProduct = async (index: number) => {
|
||||
// console.log(typeof index)
|
||||
const res = await myAxios.post('/goods/delete', { id: index })
|
||||
console.log(res)
|
||||
if (res.data.code === 1) {
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '删除成功',
|
||||
})
|
||||
getOrderList()
|
||||
}
|
||||
const reset = () => {
|
||||
name.value = '';
|
||||
|
||||
};
|
||||
const load =()=>{}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
|
||||
}
|
||||
const reset = () => {
|
||||
name.value = '';
|
||||
|
||||
};
|
||||
const load = () => { }
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
61
src/views/User/Upload.vue
Normal file
61
src/views/User/Upload.vue
Normal file
|
@ -0,0 +1,61 @@
|
|||
<template>
|
||||
<el-upload
|
||||
ref="uploadProductImg"
|
||||
action="#"
|
||||
list-type="picture-card"
|
||||
:auto-upload="false"
|
||||
multiple="true"
|
||||
:on-remove="handleRemove"
|
||||
@change="(event: any) => handleChange(event, 0)"
|
||||
:on-exceed="Exceed_ProductImg"
|
||||
limit="1" >
|
||||
<el-icon>
|
||||
<Plus />
|
||||
</el-icon>
|
||||
</el-upload>
|
||||
<div>图片url: {{ imgUrl }}</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted , inject} from 'vue';
|
||||
import { Plus } from '@element-plus/icons-vue';
|
||||
import { ElMessage, type UploadFile , type UploadProps , genFileId , type UploadRawFile} from 'element-plus';
|
||||
import myAxios from "@/api/myAxios";
|
||||
const fileSimple = ref() //单个文件
|
||||
const uploadProductImg : any = ref() //图片上传的ref绑定
|
||||
const imgUrl = ref('')
|
||||
const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
|
||||
console.log(uploadFile, uploadFiles)
|
||||
}
|
||||
const handleChange = async (file: any, flag: number) => {
|
||||
fileSimple.value = file
|
||||
let formData = new FormData() //这一步很重要 创建一个FormData对象
|
||||
formData.append("file", fileSimple.value.raw) //fileSimple.value.raw 才是文件主体 将其以文件的格式插入formData
|
||||
const res = await myAxios({ //编写请求,与以前的请求不同,这一次要指定好头部类型和文件类型
|
||||
url: '/file/upload/server/not_login',
|
||||
method: 'post',
|
||||
headers: {
|
||||
'content-Type': 'multipart/form-data'
|
||||
},
|
||||
data: {
|
||||
biz: "test",
|
||||
// 取出formData对象中的file
|
||||
file: formData.get("file")
|
||||
}
|
||||
})
|
||||
if (res.data.code === 1) {
|
||||
//三元运算 当flag为0时,赋值给商品图片 flag为1时,赋值给详情图片
|
||||
imgUrl.value = res.data.data
|
||||
}
|
||||
}
|
||||
const Exceed_ProductImg: UploadProps['onExceed'] = (files) => { //覆盖商品照片
|
||||
uploadProductImg.value!.clearFiles()
|
||||
const file = files[0] as UploadRawFile
|
||||
file.uid = genFileId()
|
||||
uploadProductImg.value!.handleStart(file)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user