jiangchengfeiyi-Web/src/views/Orders/OrderList.vue
2024-11-04 18:47:06 +08:00

181 lines
6.8 KiB
Vue

<template>
<div>
<el-input style="width: 200px; height: 30px; margin-right: 10px;" suffix-icon="Search" placeholder="请输入商品名称"
v-model="id"></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;">
<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"></el-table-column>
<el-table-column prop="id" label="订单id" width="80"></el-table-column>
<el-table-column prop="userId" label="用户id"></el-table-column>
<el-table-column prop="orderNumber" label="订单编号" width="180"></el-table-column>
<!-- <el-table-column prop="addressSnapshot" label="地址信息快照"></el-table-column>-->
<!-- <el-table-column prop="contactsSnapshot" label="联系人信息快照"></el-table-column>-->
<!-- <el-table-column prop="couponSnapshot" 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="250px">
<template #default="scope">
<el-button size="small" @click="ReviseOrView(scope.$index, scope.row , 0)">
详情
</el-button>
<el-popconfirm class="ml-5" confirm-button-text='确定' cancel-button-text='取消' icon="InfoFilled" icon-color="red"
title="是否确认删除" @confirm="deleteProduct(scope.row.id)" width=180>
<template #reference>
<el-button class="ml-5" type="danger">删除</el-button>
</template>
</el-popconfirm>
<el-popconfirm confirm-button-text='确定' cancel-button-text='取消' icon="el-icon-info" icon-color="red"
title="您确定删除吗?">
</el-popconfirm>
</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="" width="30%">
<el-form label-width="100px" size="default">
<el-form-item label="订单id">
<el-input v-model="" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="用户id">
<el-input v-model="" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="用户名称">
<el-input v-model="" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="订单编号">
<el-input v-model="" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="收货地址">
<el-input v-model="" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="详细地址">
<el-input v-model="" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="电话">
<el-input v-model="" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="优惠券名称">
<el-input v-model="" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="优惠券名称">
<el-input v-model="" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="满减金额">
<el-input v-model="" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="订单总金额">
<el-input v-model="" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="订单状态">
<el-input v-model="" autocomplete="off"></el-input>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button style="height: 30px;" @click="dialogFormVisible = false">取消</el-button>
<el-button style="height: 30px" type="primary" @click=save>确认</el-button>
</div>
</template>
</el-dialog>
</template>
<script lang="ts" setup>
import {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 searchParams: any = ref({ //封装分页
current: 1, //当前页码
pageSize: 5 //每页显示条数
})
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('', { ...searchParams.value });
if (res.data.code === 1) {
tableData.value = res.data.data.records;
total.value = parseInt(res.data.data.total)
} else {
ElMessage({
message: '获取数据失败',
});
}
} catch (error) {
ElMessage({
message: '发生错误',
});
}
}
const delBatch =()=>{
//批量删除
}
const ReviseOrView = (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()
}
}
const reset = () => {
id.value = '';
};
const load =()=>{}
</script>
<style lang="scss" scoped>
</style>
<script setup lang="ts">
</script>
<script setup lang="ts">
</script>
<script setup lang="ts">
</script>
<script setup lang="ts">
</script>
<script setup lang="ts">
</script>