Compare commits
2 Commits
8bdd2ab425
...
6bd1d4f49f
Author | SHA1 | Date | |
---|---|---|---|
6bd1d4f49f | |||
393e3d9dc9 |
12
src/App.vue
12
src/App.vue
|
@ -1,9 +1,17 @@
|
|||
<template>
|
||||
<RouterView></RouterView>
|
||||
<RouterView v-if="isRouterActive"></RouterView>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
// 引入组件刷新功能
|
||||
import { provide , nextTick , ref } from 'vue'
|
||||
const isRouterActive = ref(true)
|
||||
provide('reload', () => {
|
||||
isRouterActive.value = false
|
||||
nextTick(() => {
|
||||
isRouterActive.value = true
|
||||
})
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
|
|
|
@ -5,12 +5,14 @@
|
|||
<el-form-item label="添加商品图片">
|
||||
<!-- 下面的event的作用,传入当前事件对象 -->
|
||||
<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 />
|
||||
|
@ -20,11 +22,13 @@
|
|||
<!-- 添加图文描述-->
|
||||
<el-form-item label="添加图文描述">
|
||||
<el-upload
|
||||
ref="uploadProductDetail"
|
||||
action="#"
|
||||
list-type="picture-card"
|
||||
:auto-upload="false"
|
||||
multiple="true"
|
||||
:on-change="(event: any) => handleChange(event, 1)"
|
||||
:on-exceed="Exceed_ProductDetail"
|
||||
limit="1"
|
||||
:on-remove="handleRemove"
|
||||
>
|
||||
|
@ -77,9 +81,9 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { ref, onMounted , inject} from 'vue';
|
||||
import { Plus } from '@element-plus/icons-vue';
|
||||
import { ElMessage, type UploadFile , type UploadProps } from 'element-plus';
|
||||
import { ElMessage, type UploadFile , type UploadProps , genFileId , type UploadRawFile} from 'element-plus';
|
||||
import myAxios from "@/api/myAxios";
|
||||
const fileSimple = ref() //单个文件
|
||||
const uploadedFiles = ref<UploadFile[]>([]);//商品图片数组
|
||||
|
@ -97,12 +101,16 @@ const form = ref({
|
|||
detailImg: '', //图文详情url
|
||||
inventory: '' //库存
|
||||
})
|
||||
//导入组件刷新
|
||||
const reload : any = inject("reload")
|
||||
const typeList: any = ref([
|
||||
{
|
||||
value1: '',
|
||||
label: ''
|
||||
}
|
||||
])
|
||||
const uploadProductImg : any = ref() //图片上传的ref绑定
|
||||
const uploadProductDetail : any = ref() //图片上传的ref绑定
|
||||
onMounted(() => {
|
||||
getTypeList() //加载类别列表,渲染在产品列表的select选项里面
|
||||
})
|
||||
|
@ -135,8 +143,10 @@ const onSubmit = async () => {
|
|||
type: 'success',
|
||||
message: "提交成功"
|
||||
})
|
||||
reload() //上传完后重置表单
|
||||
} else {
|
||||
ElMessage.error("服务错误")
|
||||
return;
|
||||
}
|
||||
}
|
||||
//图片上传请求 此请求只要选择了图片,就会默认上传
|
||||
|
@ -169,4 +179,16 @@ const loadForm = (value: any, flag: number) => {
|
|||
const resetForm = () =>{
|
||||
resetFormData.value.resetFields()
|
||||
}
|
||||
const Exceed_ProductImg: UploadProps['onExceed'] = (files) => { //覆盖商品照片
|
||||
uploadProductImg.value!.clearFiles()
|
||||
const file = files[0] as UploadRawFile
|
||||
file.uid = genFileId()
|
||||
uploadProductImg.value!.handleStart(file)
|
||||
}
|
||||
const Exceed_ProductDetail: UploadProps['onExceed'] = (files) => { //覆盖商品详情图片
|
||||
uploadProductDetail.value!.clearFiles()
|
||||
const file = files[0] as UploadRawFile
|
||||
file.uid = genFileId()
|
||||
uploadProductDetail.value!.handleStart(file)
|
||||
}
|
||||
</script>
|
|
@ -3,23 +3,19 @@
|
|||
<!-- 搜索 -->
|
||||
<div>
|
||||
<el-input style="width: 200px; height: 30px; margin-right: 10px;" suffix-icon="Search" placeholder="请输入商品名称"
|
||||
v-model="username"></el-input>
|
||||
v-model="productName"></el-input>
|
||||
<el-form-item label="商品类型" style="width: 200px; margin-right: 10px;display: inline-block">
|
||||
<el-select v-model="types" placeholder="请选择">
|
||||
<el-option label="材料包" value="材料包" />
|
||||
<el-option label="手持物" value="手持物" />
|
||||
<el-option label="头饰" value="头饰" />
|
||||
<el-option label="定制" value="定制" />
|
||||
<el-option label="积分兑换" value="积分兑换" />
|
||||
<el-select v-model="editForm.type" @change="(event: any) => searchByType(event)" placeholder="请选择">
|
||||
<el-option v-for="item in typeList" :key="item.value" :label="item.label" :value="item.value1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品状态" style="width: 200px;margin-right: 10px;display: inline-block">
|
||||
<el-select v-model="Region" placeholder="请选择">
|
||||
<el-option label="已上架" value="上架" />
|
||||
<el-option label="已下架" value="下架" />
|
||||
<el-select v-model="state" placeholder="请选择" @change="(event: any) => searchByState(event)">
|
||||
<el-option label="已上架" value="1" />
|
||||
<el-option label="已下架" value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-button class="ml-5" type="primary" @click="load" style="height: 25px;">搜索</el-button>
|
||||
<el-button class="ml-5" type="primary" @click="onSearch(productName)" style="height: 25px;">搜索</el-button>
|
||||
<el-button type="warning" @click="reset" style="height:25px">重置</el-button>
|
||||
</div>
|
||||
<div style="margin: 15px 0">
|
||||
|
@ -101,12 +97,14 @@
|
|||
<img :src="editForm.goodImg" alt="商品图标" class="thumbnail" style="width: 100px; height: 100px;" />
|
||||
</div>
|
||||
<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/>
|
||||
|
@ -147,12 +145,14 @@
|
|||
<img :src="editForm.detailImg" alt="商品图标" class="thumbnail" style="width: 100px; height: 100px;" />
|
||||
</div>
|
||||
<el-upload
|
||||
ref="uploadProductDetail"
|
||||
action="#"
|
||||
list-type="picture-card"
|
||||
:auto-upload="false"
|
||||
multiple="true"
|
||||
:on-remove="handleRemove"
|
||||
@change="(event: any) => handleChange(event, 0)"
|
||||
@change="(event: any) => handleChange(event, 1)"
|
||||
:on-exceed="Exceed_ProductDetail"
|
||||
limit="1" >
|
||||
<el-icon>
|
||||
<Plus/>
|
||||
|
@ -173,8 +173,8 @@
|
|||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ElMessage , type UploadProps } from 'element-plus';
|
||||
import { ref, onMounted, toRaw } from 'vue';
|
||||
import { ElMessage , type UploadProps , genFileId ,type UploadRawFile } from 'element-plus';
|
||||
import { ref, onMounted, inject } from 'vue';
|
||||
import myAxios from "@/api/myAxios";
|
||||
const total = ref(0); //总页数
|
||||
const id = ref([]);
|
||||
|
@ -184,13 +184,15 @@ const searchParams: any = ref({ //封装分页
|
|||
})
|
||||
const fileSimple = ref()
|
||||
const disabled = ref(true)
|
||||
const title = ref('')
|
||||
const username = ref('');
|
||||
const title = ref('') //表单名字
|
||||
const productName = ref('');
|
||||
const DialogVisible = ref(false);
|
||||
const types = ref('');
|
||||
const Region = ref('');
|
||||
const state = ref(''); //根据商品上架状态select栏
|
||||
const tableData : any= ref([]);
|
||||
const editForm : any = ref({});
|
||||
const reload : any = inject("reload") //页面重新刷新
|
||||
const uploadProductImg : any = ref() //图片上传的ref绑定
|
||||
const uploadProductDetail : any = ref() //图片上传的ref绑定
|
||||
const typeList: any = ref([
|
||||
{
|
||||
value1: '',
|
||||
|
@ -207,11 +209,12 @@ const getProductList = async () => {
|
|||
// console.log(res.data)
|
||||
if (res.data.code === 1) {
|
||||
tableData.value = res.data.data.records;
|
||||
total.value = parseInt(res.data.data.total)//总数据量,用于分页
|
||||
total.value = parseInt(res.data.data.total) //总数据量,用于分页
|
||||
} else {
|
||||
ElMessage({
|
||||
message: '获取数据失败',
|
||||
});
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
ElMessage({
|
||||
|
@ -240,6 +243,16 @@ const saveEdit = async () => { //编辑商品
|
|||
ElMessage.error('更新失败,请检查字段')
|
||||
}
|
||||
}
|
||||
const searchByType =(event : any)=>{ //通过类别搜索
|
||||
searchParams.value.type = event
|
||||
searchParams.value.current = 1
|
||||
getProductList()
|
||||
}
|
||||
const searchByState = (event : any) => { //通过商品是否上架/下架搜索
|
||||
searchParams.value.isShelves = event
|
||||
searchParams.value.current = 1
|
||||
getProductList()
|
||||
}
|
||||
//删除商品
|
||||
const deleteProduct = async (index: number) => {
|
||||
console.log(typeof index)
|
||||
|
@ -286,15 +299,26 @@ const handleCurrentChange = (Current: any) => {
|
|||
searchParams.value.current = Current
|
||||
getProductList()
|
||||
}
|
||||
//重置按钮
|
||||
const reset = () => {
|
||||
username.value = '';
|
||||
types.value = '';
|
||||
Region.value = '';
|
||||
reload()
|
||||
};
|
||||
//上传图片移除 --逻辑上移除
|
||||
const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
|
||||
console.log(uploadFile, uploadFiles)
|
||||
}
|
||||
const Exceed_ProductImg: UploadProps['onExceed'] = (files , flag) => { //覆盖商品照片
|
||||
uploadProductImg.value!.clearFiles()
|
||||
const file = files[0] as UploadRawFile
|
||||
file.uid = genFileId()
|
||||
uploadProductImg.value!.handleStart(file)
|
||||
}
|
||||
const Exceed_ProductDetail: UploadProps['onExceed'] = (files) => { //覆盖商品详情图片
|
||||
uploadProductDetail.value!.clearFiles()
|
||||
const file = files[0] as UploadRawFile
|
||||
file.uid = genFileId()
|
||||
uploadProductDetail.value!.handleStart(file)
|
||||
}
|
||||
//将 商品类别 赋值到表格里
|
||||
const loadForm = (value: any, flag: number) => {
|
||||
flag ? editForm.value.type = value : editForm.value.festivalOrder = value //三元运算符 flag=1 是关于"商品类别"选项的值 flag=0 是关于“是否为节日限定”选项的值
|
||||
|
@ -321,6 +345,11 @@ const handleChange = async (file: any, flag: number) => {
|
|||
}
|
||||
}
|
||||
|
||||
const onSearch = (data : String)=>{ //搜索按钮方法
|
||||
searchParams.value.name = data
|
||||
searchParams.value.current = 1
|
||||
getProductList()
|
||||
}
|
||||
const delBatch =()=>{
|
||||
//批量删除
|
||||
}
|
||||
|
|
|
@ -67,136 +67,101 @@
|
|||
<!-- </div>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-dialog>-->
|
||||
</template>
|
||||
<!--</template>-->
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref,onMounted} from "vue";
|
||||
import myAxios from "@/api/myAxios";
|
||||
import {ElMessage} from "element-plus";
|
||||
const tableData : any= ref([]);
|
||||
const total = ref(0);
|
||||
const num = ref(0)
|
||||
const dialogFormVisible = ref(false)
|
||||
const formLabelWidth = '140px'
|
||||
onMounted(()=>{
|
||||
getOrderList()
|
||||
})
|
||||
<!--<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 dialogFormVisible = ref(false)-->
|
||||
<!--const formLabelWidth = '140px'-->
|
||||
<!--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 orderList = ref({-->
|
||||
<!--id:'',-->
|
||||
<!--userId:'',-->
|
||||
<!--addressSnapshot:{-->
|
||||
<!--name:'',-->
|
||||
<!--phone:'',-->
|
||||
<!--region:'',-->
|
||||
<!--detailAddress:''-->
|
||||
<!--},-->
|
||||
<!--couponSnapshot:{-->
|
||||
<!--name:'',-->
|
||||
<!--conditionAmount:''-->
|
||||
<!--},-->
|
||||
<!--totalAmount:'',-->
|
||||
<!--orderStatus:'',-->
|
||||
<!--createTime:'',-->
|
||||
<!--updateTime:'',-->
|
||||
<!--isDelete:'',-->
|
||||
<!--orderNumber:''-->
|
||||
<!--})-->
|
||||
<!--const delBatch =()=>{-->
|
||||
<!-- //批量取消-->
|
||||
<!--}-->
|
||||
<!--//发货-->
|
||||
<!--const shipments = (index: number, row: any , flag : number) => {-->
|
||||
|
||||
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('/order/list/page', { ...searchParams.value });
|
||||
// console.log(res)
|
||||
if (res.data.code === 1) {
|
||||
tableData.value = res.data.data.records
|
||||
total.value = parseInt(res.data.data.total)
|
||||
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 ) {
|
||||
tableData.value.goodSnapshot= resOrderDetail.data.data[key].goodSnapshot
|
||||
tableData.value.quantity = resOrderDetail.data.data[key].quality
|
||||
// console.log(resOrderDetail.data.data[0].goodSnapshot.name)
|
||||
console.log( tableData.value.goodSnapshot.name)
|
||||
console.log( resOrderDetail.data.data[key].quantity)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ElMessage({
|
||||
message: '获取数据失败',
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
ElMessage({
|
||||
message: '发生错误',
|
||||
});
|
||||
}
|
||||
}
|
||||
<!--};-->
|
||||
<!--//编辑-->
|
||||
<!--const ReviseOrView = (index: number, row: any , flag : number) => {-->
|
||||
|
||||
<!--};-->
|
||||
<!--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 getItemList = async (id: number) => {
|
||||
// try {
|
||||
// const res = await myAxios.post('/order/list/item', { id:tableData.value[key].id});
|
||||
// console.log(res)
|
||||
// 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 load =()=>{}-->
|
||||
<!--</script>-->
|
||||
|
||||
// const orderList = ref({
|
||||
// id:'',
|
||||
// userId:'',
|
||||
// addressSnapshot:{
|
||||
// name:'',
|
||||
// phone:'',
|
||||
// region:'',
|
||||
// detailAddress:''
|
||||
// },
|
||||
// couponSnapshot:{
|
||||
// name:'',
|
||||
// conditionAmount:''
|
||||
// },
|
||||
// totalAmount:'',
|
||||
// orderStatus:'',
|
||||
// createTime:'',
|
||||
// updateTime:'',
|
||||
// isDelete:'',
|
||||
// orderNumber:''
|
||||
// })
|
||||
const delBatch =()=>{
|
||||
//批量取消
|
||||
}
|
||||
//发货
|
||||
const shipments = (index: number, row: any , flag : number) => {
|
||||
<!--<style lang="scss" scoped>-->
|
||||
|
||||
};
|
||||
//编辑
|
||||
const ReviseOrView = (index: number, row: any , flag : number) => {
|
||||
|
||||
};
|
||||
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>
|
||||
<!--</style> -->
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
<script setup lang="ts">
|
||||
import { ElMessage } from 'element-plus';
|
||||
import myAxios from '@/api/myAxios';
|
||||
import {ref, onMounted} from 'vue'
|
||||
import {ref, onMounted , inject} from 'vue'
|
||||
|
||||
//获取的所有数据
|
||||
const tableData = ref([])
|
||||
|
@ -84,15 +84,15 @@ const searchParams: any = ref({
|
|||
//每页显示条数
|
||||
pageSize: 5
|
||||
})
|
||||
|
||||
//导入组件刷新
|
||||
const reload : any = inject("reload")
|
||||
onMounted(() => {
|
||||
getUserList()
|
||||
})
|
||||
const username = ref('')
|
||||
//重置按钮
|
||||
const reset =()=>{
|
||||
username.value = ''
|
||||
onSearch(username.value)
|
||||
getUserList()
|
||||
reload()
|
||||
}
|
||||
//用户信息列表
|
||||
const getUserList = async () => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user