Merge branch 'main' of http://154.8.193.216:3030/admin1/jiangchengfeiyi-Web
# Conflicts: # src/router/routes.ts # src/views/Commodity/AddProduct.vue
This commit is contained in:
commit
658b79a19e
|
@ -21,15 +21,16 @@
|
||||||
<span>用户管理</span>
|
<span>用户管理</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<el-menu-item index="/PersonalCenter">
|
||||||
|
<el-icon><UserFilled /></el-icon>
|
||||||
|
<span slot="title">个人中心</span>
|
||||||
|
</el-menu-item>
|
||||||
|
|
||||||
<el-menu-item index="/UserManagement">
|
<el-menu-item index="/UserManagement">
|
||||||
<el-icon><List /></el-icon>
|
<el-icon><List /></el-icon>
|
||||||
<span slot="title">用户列表</span>
|
<span slot="title">用户列表</span>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
|
|
||||||
<el-menu-item index="/PersonalCenter">
|
|
||||||
<el-icon><UserFilled /></el-icon>
|
|
||||||
<span slot="title">个人中心</span>
|
|
||||||
</el-menu-item>
|
|
||||||
</el-sub-menu>
|
</el-sub-menu>
|
||||||
|
|
||||||
<el-sub-menu index="2">
|
<el-sub-menu index="2">
|
||||||
|
@ -64,6 +65,17 @@
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
</el-sub-menu>
|
</el-sub-menu>
|
||||||
|
|
||||||
|
<el-sub-menu index="3">
|
||||||
|
<template #title>
|
||||||
|
<el-icon><HomeFilled /></el-icon>
|
||||||
|
<span>订单管理</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<el-menu-item index="/OrderList">
|
||||||
|
<el-icon><Menu /></el-icon>
|
||||||
|
<span slot="title">订单列表</span>
|
||||||
|
</el-menu-item>
|
||||||
|
</el-sub-menu>
|
||||||
</el-menu>
|
</el-menu>
|
||||||
</el-aside>
|
</el-aside>
|
||||||
</el-aside>
|
</el-aside>
|
||||||
|
|
|
@ -13,16 +13,16 @@ export const routes = [
|
||||||
path: '/manage',
|
path: '/manage',
|
||||||
component: () => import("@/layout/Manage.vue"),
|
component: () => import("@/layout/Manage.vue"),
|
||||||
children:[
|
children:[
|
||||||
{
|
|
||||||
path: '/UserManagement',
|
|
||||||
name:'用户列表',
|
|
||||||
component: ()=> import("../views/User/UserManagement.vue")
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: '/PersonalCenter',
|
path: '/PersonalCenter',
|
||||||
name:'个人中心',
|
name:'个人中心',
|
||||||
component: ()=> import("../views/User/PersonalCenter.vue")
|
component: ()=> import("../views/User/PersonalCenter.vue")
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/UserManagement',
|
||||||
|
name:'用户列表',
|
||||||
|
component: ()=> import("../views/User/UserManagement.vue")
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/AddProduct',
|
path: '/AddProduct',
|
||||||
name: '添加商品',
|
name: '添加商品',
|
||||||
|
@ -39,10 +39,15 @@ export const routes = [
|
||||||
component: ()=> import("../views/Commodity/TypeManagement.vue")
|
component: ()=> import("../views/Commodity/TypeManagement.vue")
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path:'/AddCoupons',
|
path: '/OrderList',
|
||||||
name:'添加优惠券',
|
name: '订单列表',
|
||||||
component:()=>import("../views/Coupons/AddCoupons.vue")
|
component: ()=> import("../views/Orders/OrderList.vue")
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/Test',
|
||||||
|
name:'测试页面',
|
||||||
|
component: () => import("../views/test.vue")
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import myAxios from '../api/myAxios'
|
|
||||||
|
|
||||||
export const userStore = defineStore( 'user' , {
|
export const userStore = defineStore( 'user' , {
|
||||||
//state是应用的核心数据,通常用于管理用户信息、应用设置、数据列表等。
|
//state是应用的核心数据,通常用于管理用户信息、应用设置、数据列表等。
|
||||||
|
@ -26,7 +25,6 @@ export const userStore = defineStore( 'user' , {
|
||||||
//更新state
|
//更新state
|
||||||
updateUser(payLoad : any) {
|
updateUser(payLoad : any) {
|
||||||
this.loginUser = payLoad
|
this.loginUser = payLoad
|
||||||
console.log(payLoad,2654615165)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
|
@ -1,190 +1,172 @@
|
||||||
<template>
|
<template>
|
||||||
<!-- 添加商品图片-->
|
<div>
|
||||||
<div style="height: auto;margin-bottom: 10px;width: 480px;">
|
<!-- 表单 ref 和 prop绑定 用于重置表单 -->
|
||||||
<div style="font-size: 20px;margin-bottom: 10px">添加商品图片</div>
|
<el-form ref="resetFormData" :model="form" label-width="auto" style="width: 750px" size="large">
|
||||||
<el-upload action="#" v-model:file-list="uploadedFiles" list-type="picture-card" :auto-upload="false" multiple="true">
|
<el-form-item label="添加商品图片">
|
||||||
<el-icon><Plus /></el-icon>
|
<!-- 下面的event的作用,传入当前事件对象 -->
|
||||||
|
<el-upload
|
||||||
<template #file="{ file }">
|
action="#"
|
||||||
<div>
|
list-type="picture-card"
|
||||||
<img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
|
:auto-upload="false"
|
||||||
<span class="el-upload-list__item-actions">
|
multiple="true"
|
||||||
<span
|
:on-remove="handleRemove"
|
||||||
class="el-upload-list__item-preview"
|
@change="(event: any) => handleChange(event, 0)"
|
||||||
@click="handlePictureCardPreview(file)"
|
limit="1" >
|
||||||
|
<el-icon>
|
||||||
|
<Plus />
|
||||||
|
</el-icon>
|
||||||
|
</el-upload>
|
||||||
|
</el-form-item>
|
||||||
|
<!-- 添加图文描述-->
|
||||||
|
<el-form-item label="添加图文描述">
|
||||||
|
<el-upload
|
||||||
|
action="#"
|
||||||
|
list-type="picture-card"
|
||||||
|
:auto-upload="false"
|
||||||
|
multiple="true"
|
||||||
|
:on-change="(event: any) => handleChange(event, 1)"
|
||||||
|
limit="1"
|
||||||
|
:on-remove="handleRemove"
|
||||||
>
|
>
|
||||||
<el-icon><zoom-in /></el-icon>
|
<el-icon>
|
||||||
</span>
|
<Plus />
|
||||||
<span
|
</el-icon>
|
||||||
v-if="!disabled"
|
</el-upload>
|
||||||
class="el-upload-list__item-delete"
|
</el-form-item>
|
||||||
@click="handleRemove(file)"
|
<el-form-item label="产品名称" prop="name">
|
||||||
>
|
|
||||||
<el-icon><Delete /></el-icon>
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</el-upload>
|
|
||||||
<!-- 添加图文描述-->
|
|
||||||
<div style="margin-bottom: 10px;">
|
|
||||||
<div style="font-size: 20px;margin-bottom: 10px">添加图文描述</div>
|
|
||||||
<el-upload action="#" v-model:file-list="uploadedDescription" list-type="picture-card" :auto-upload="false" multiple="true">
|
|
||||||
<el-icon><Plus /></el-icon>
|
|
||||||
|
|
||||||
<template #file="{ file }">
|
|
||||||
<div>
|
|
||||||
<img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
|
|
||||||
<span class="el-upload-list__item-actions">
|
|
||||||
<span
|
|
||||||
class="el-upload-list__item-preview"
|
|
||||||
@click="handlePictureCardPreview(file)"
|
|
||||||
>
|
|
||||||
<el-icon><zoom-in /></el-icon>
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
v-if="!disabled"
|
|
||||||
class="el-upload-list__item-delete"
|
|
||||||
@click="descriptionRemove(file)"
|
|
||||||
>
|
|
||||||
<el-icon><Delete /></el-icon>
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</el-upload>
|
|
||||||
|
|
||||||
<el-dialog v-model="dialogVisible">
|
|
||||||
<img w-full :src="dialogImageUrl" alt="Preview Image" />
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-dialog v-model="dialogVisible">
|
|
||||||
<img w-full :src="dialogImageUrl" alt="Preview Image" />
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
<!-- 表单-->
|
|
||||||
<div style="position: absolute;right: 20px;top: 100px;max-width: 50%" >
|
|
||||||
<el-form :model="form" label-width="auto" style="width: 750px" size="large">
|
|
||||||
<el-form-item label="产品名称">
|
|
||||||
<el-input v-model="form.name" />
|
<el-input v-model="form.name" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="产品价格">
|
<el-form-item label="产品价格" prop="price">
|
||||||
<el-input v-model="form.price" />
|
<el-input v-model="form.price" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="产品">
|
<el-form-item label="产品简介" prop="intro">
|
||||||
<el-input v-model="form.quantity" />
|
<el-input v-model="form.intro" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="是否为限定类产品" >
|
<el-form-item label="当前库存" prop="inventory">
|
||||||
<el-select v-model="form.region" placeholder="否">
|
<el-input v-model="form.inventory" />
|
||||||
<el-option label="是" value="ture" />
|
</el-form-item>
|
||||||
<el-option label="否" value="false" />
|
<el-form-item label="是否为限定类产品" prop="festivalOrder">
|
||||||
|
<el-select v-model="form.festivalOrder" placeholder="请选择" @change="(event: any) => loadForm(event, 0)">
|
||||||
|
<el-option label="是" value="1" />
|
||||||
|
<el-option label="否" value="0" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-if="form.region=='ture' " label="节日名称">
|
<!-- <el-form-item v-if="form.region=='ture' " label="节日名称">
|
||||||
<el-input v-model="form.festivalName" />
|
<el-input v-model="form.festivalName" />
|
||||||
|
</el-form-item> -->
|
||||||
|
<el-form-item label="产品类别" prop="type">
|
||||||
|
<el-select v-model="typeList.value" placeholder="请选择" @change="(event: any) => loadForm(event, 1)">
|
||||||
|
<el-option v-for="item in typeList" :key="item.value" :label="item.label" :value="item.value1" />
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="产品类型" >
|
<el-form-item label="商品标签" prop="label">
|
||||||
<el-radio-group v-model="form.resource" >
|
<el-input v-model="form.label" type="textarea" placeholder="" />
|
||||||
<el-radio value="1">材料包</el-radio>
|
|
||||||
<el-radio value="2">手持物</el-radio>
|
|
||||||
<el-radio value="3">头饰</el-radio>
|
|
||||||
<el-radio value="4">定制</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="商品标签">
|
<el-form-item label="商品详细描述" prop="introDetail">
|
||||||
<el-input v-model="form.label" type="textarea" placeholder=""/>
|
<el-input v-model="form.introDetail" type="textarea" placeholder="产品尺寸,服务等" />
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="详情描述">
|
|
||||||
<el-input v-model="form.desc" type="textarea" placeholder="产品尺寸,服务等"/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="addProduct">上架</el-button>
|
<el-button type="primary" @click="onSubmit">上架</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="resetForm">重置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref,reactive,onMounted } from 'vue';
|
import { ref, onMounted } from 'vue';
|
||||||
import { Delete, Plus, ZoomIn } from '@element-plus/icons-vue';
|
import { Plus } from '@element-plus/icons-vue';
|
||||||
import {ElMessage, type UploadFile} from 'element-plus';
|
import { ElMessage, type UploadFile , type UploadProps } from 'element-plus';
|
||||||
import myAxios from "@/api/myAxios";
|
import myAxios from "@/api/myAxios";
|
||||||
|
const fileSimple = ref() //单个文件
|
||||||
const dialogImageUrl = ref('');
|
|
||||||
const dialogVisible = ref(false);
|
|
||||||
const disabled = ref(false);
|
|
||||||
const uploadedFiles = ref<UploadFile[]>([]);//商品图片数组
|
const uploadedFiles = ref<UploadFile[]>([]);//商品图片数组
|
||||||
const uploadedDescription = ref<UploadFile[]>([]);//商品图文描述数组
|
const uploadedDescription = ref<UploadFile[]>([]);//商品图文描述数组
|
||||||
const handleRemove = (file: UploadFile) => {
|
const resetFormData = ref()
|
||||||
uploadedFiles.value = uploadedFiles.value.filter((f) => f.uid !== file.uid);
|
const form = ref({
|
||||||
};
|
name: '',
|
||||||
const descriptionRemove = (file: UploadFile) => {
|
price: '', //商品价格
|
||||||
uploadedDescription.value = uploadedDescription.value.filter((f) => f.uid !== file.uid);
|
intro: '',//产品简介
|
||||||
}
|
festivalOrder: '',//是否为限定
|
||||||
const handlePictureCardPreview = (file: UploadFile) => {
|
type: '',//类别
|
||||||
dialogImageUrl.value = file.url!;
|
label: '',//商品标签
|
||||||
dialogVisible.value = true;
|
introDetail: '',//详情描述
|
||||||
};
|
goodImg: '', //商品图片url
|
||||||
const form = reactive({
|
detailImg: '', //图文详情url
|
||||||
name:'',
|
inventory: '' //库存
|
||||||
price:'',
|
|
||||||
quantity:'',//产品数量
|
|
||||||
region:'',//是否为限定
|
|
||||||
festivalName:'',//节日名称
|
|
||||||
resource:'',//类型
|
|
||||||
label:'',//商品标签
|
|
||||||
desc:'',//详情描述
|
|
||||||
})
|
})
|
||||||
onMounted(()=>{
|
const typeList: any = ref([
|
||||||
upload()
|
{
|
||||||
addProduct()
|
value1: '',
|
||||||
})
|
label: ''
|
||||||
const addProduct = async () => {
|
}
|
||||||
const res = await myAxios.post('goods/add',{
|
])
|
||||||
name : form.name,
|
onMounted(() => {
|
||||||
price : form.price,
|
getTypeList() //加载类别列表,渲染在产品列表的select选项里面
|
||||||
inventory : form.quantity,
|
})
|
||||||
type: form.resource,
|
const getTypeList = async () => { //获取类别列表作为可选项
|
||||||
label : form.label,
|
const res = await myAxios.post('/category/list', {}) //获取商品列表
|
||||||
intro : form.desc,
|
for (let key in res.data.data) { //循环赋值
|
||||||
festivalOrder : form.festivalName
|
typeList.value[key] = {
|
||||||
})
|
value1: res.data.data[key].typeName,
|
||||||
|
label: res.data.data[key].typeName
|
||||||
// if(res.data.code == 1){
|
}
|
||||||
// ElMessage({
|
|
||||||
// message: '上架成功',
|
|
||||||
// type: 'success'
|
|
||||||
// })
|
|
||||||
// }else{
|
|
||||||
// ElMessage({
|
|
||||||
// message: '上架失败',
|
|
||||||
// type: 'error'
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
const upload = async () => {
|
|
||||||
const res = await myAxios.post('file/upload/server',{
|
|
||||||
multipartFile : uploadedFiles.value,
|
|
||||||
biz : uploadedDescription.value
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
// onMounted(() => {
|
const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
|
||||||
// getProductInformation()
|
console.log(uploadFile, uploadFiles)
|
||||||
// })
|
}
|
||||||
// const getProductInformation = async () => {
|
//提交表单
|
||||||
// const res: any = await myAxios.get('')
|
const onSubmit = async () => {
|
||||||
// console.log(res)
|
const values = Object.values(form.value);
|
||||||
// if (res.code === 1 && res.data) {
|
// 使用some()方法来检查是否有任何值为空
|
||||||
//
|
if (values.some(value => value === null || value === undefined || value === '')) {
|
||||||
//
|
ElMessage({
|
||||||
// } else {
|
type:'warning',
|
||||||
// message.error(`获取数据失败:${res.message}`);
|
message:'请检查表单数据是否完整填写'
|
||||||
// backPage()
|
})
|
||||||
// }
|
return; //空返回结束函数
|
||||||
// }
|
}
|
||||||
const onSubmit = () => {
|
const res = await myAxios.post('/goods/add', { ...form.value })
|
||||||
console.log('submit!')
|
if (res.data.code === 1) {
|
||||||
|
ElMessage({
|
||||||
|
type: 'success',
|
||||||
|
message: "提交成功"
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
ElMessage.error("服务错误")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//图片上传请求 此请求只要选择了图片,就会默认上传
|
||||||
|
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时,赋值给详情图片
|
||||||
|
flag ? form.value.detailImg = res.data.data : form.value.goodImg = res.data.data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//将 商品类别 赋值到表格里
|
||||||
|
const loadForm = (value: any, flag: number) => {
|
||||||
|
flag ? form.value.type = value : form.value.festivalOrder = value //三元运算符 flag=1 是关于"商品类别"选项的值 flag=0 是关于“是否为节日限定”选项的值
|
||||||
|
}
|
||||||
|
//清除表单
|
||||||
|
const resetForm = () =>{
|
||||||
|
resetFormData.value.resetFields()
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
|
@ -1,7 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<!-- 修改前请注释以前的 -->
|
||||||
|
<!-- 搜索 -->
|
||||||
<div>
|
<div>
|
||||||
<el-input style="width: 200px; height: 30px; margin-right: 10px;" suffix-icon="Search" placeholder="请输入商品名称" v-model="username"></el-input>
|
<el-input style="width: 200px; height: 30px; margin-right: 10px;" suffix-icon="Search" placeholder="请输入商品名称"
|
||||||
|
v-model="username"></el-input>
|
||||||
<el-form-item label="商品类型" style="width: 200px; margin-right: 10px;display: inline-block">
|
<el-form-item label="商品类型" style="width: 200px; margin-right: 10px;display: inline-block">
|
||||||
<el-select v-model="types" placeholder="请选择">
|
<el-select v-model="types" placeholder="请选择">
|
||||||
<el-option label="材料包" value="材料包" />
|
<el-option label="材料包" value="材料包" />
|
||||||
|
@ -21,185 +23,94 @@
|
||||||
<el-button type="warning" @click="reset" style="height:25px">重置</el-button>
|
<el-button type="warning" @click="reset" style="height:25px">重置</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div style="margin: 15px 0">
|
<div style="margin: 15px 0">
|
||||||
<el-popconfirm
|
<el-popconfirm class="ml-5" confirm-button-text='确定' cancel-button-text='取消' icon="InfoFilled" icon-color="red"
|
||||||
class="ml-5"
|
title="您确定批量删除这些数据吗?" @confirm="delBatch" width=180>
|
||||||
confirm-button-text='确定'
|
|
||||||
cancel-button-text='取消'
|
|
||||||
icon="InfoFilled"
|
|
||||||
icon-color="red"
|
|
||||||
title="您确定批量删除这些数据吗?"
|
|
||||||
@confirm="delBatch"
|
|
||||||
width=180
|
|
||||||
>
|
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<el-button style="height: 25px" class="ml-5" type="danger">批量删除 <el-icon style="margin-left: 5px;"><Remove /></el-icon></el-button>
|
<el-button style="height: 25px" class="ml-5" type="danger">批量删除 <el-icon style="margin-left: 5px;">
|
||||||
|
<Remove />
|
||||||
|
</el-icon></el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-popconfirm>
|
</el-popconfirm>
|
||||||
</div>
|
</div>
|
||||||
<el-table :data="tableData" border stripe header-cell-class-name="headerBg" :cell-style="{textAlign: 'center'}"
|
<!-- 数据展示 -->
|
||||||
@selection-change="handleSelectionChange" :header-cell-style="{'text-align': 'center'}"
|
<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 type="selection" width="55"></el-table-column>
|
||||||
<el-table-column label="商品编号" width="80">
|
<el-table-column prop="id" label="商品编号" width="80"></el-table-column>
|
||||||
<template #default="scope">
|
<el-table-column prop="goodImg" label="商品图片">
|
||||||
<div>
|
|
||||||
<span style="align-items: center">{{ scope.row.id }}</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="商品图片">
|
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<div>
|
<div>
|
||||||
<img :src="scope.row.goodImg" alt="" style="height: 50px;">
|
<img :src="scope.row.goodImg" alt="" style="height: 50px;">
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="商品名称">
|
<el-table-column prop="name" label="商品名称"></el-table-column>
|
||||||
<template #default="scope">
|
<el-table-column prop="price" label="商品价格" width="180"></el-table-column>
|
||||||
<div>
|
<el-table-column prop="type" label="商品类型"></el-table-column>
|
||||||
<span style="margin-left: 10px">{{ scope.row.name }}</span>
|
<el-table-column prop="inventory" label="商品数量"></el-table-column>
|
||||||
</div>
|
<el-table-column prop="createTime" label="创建时间"></el-table-column>
|
||||||
</template>
|
<el-table-column prop="updateTime" label="更新时间"></el-table-column>
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="商品价格" width="180">
|
|
||||||
<template #default="scope">
|
|
||||||
<div>
|
|
||||||
<span style="margin-left: 10px">{{ scope.row.price }}</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="商品类型">
|
|
||||||
<template #default="scope">
|
|
||||||
<div>
|
|
||||||
<span style="margin-left: 10px">{{ scope.row.type }}</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="商品数量">
|
|
||||||
<template #default="scope">
|
|
||||||
<div>
|
|
||||||
<span style="margin-left: 10px">{{ scope.row.inventory }}</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="商品状态">
|
<el-table-column label="商品状态">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<div>
|
<div>
|
||||||
<span style="margin-left: 10px" v-if="scope.row.isShelves==1">上架</span>
|
<span style="margin-left: 10px" v-if="scope.row.isShelves == 1">上架</span>
|
||||||
<span style="margin-left: 10px" v-if="scope.row.isShelves==0">下架</span>
|
<span style="margin-left: 10px" v-if="scope.row.isShelves == 0">下架</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" width="250px">
|
<el-table-column label="操作" width="250px">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button size="small" @click="handleView(scope.$index, scope.row)">
|
<el-button size="small" @click="ReviseOrView(scope.$index, scope.row , 0)">
|
||||||
详情
|
详情
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button size="small" @click="handleRevise(scope.$index, scope.row)">
|
<el-button size="small" @click="ReviseOrView(scope.$index, scope.row, 1)">
|
||||||
编辑
|
编辑
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button size="small" @click="handleOff(scope.$index, scope.row)">
|
<el-button size="small" @click="handleOff(scope.$index, scope.row)">
|
||||||
<div v-if="scope.row.isShelves==1">下架 </div>
|
<div v-if="scope.row.isShelves == 1">下架 </div>
|
||||||
<div v-if="scope.row.isShelves==0">上架 </div>
|
<div v-if="scope.row.isShelves == 0">上架 </div>
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-popconfirm class="ml-5" confirm-button-text='确定' cancel-button-text='取消' icon="InfoFilled" icon-color="red"
|
||||||
size="small"
|
title="是否确认删除" @confirm="deleteProduct(scope.row.id)" width=180>
|
||||||
type="danger"
|
<template #reference>
|
||||||
@click="handleDelete(scope.$index, scope.row)"
|
<el-button class="ml-5" type="danger">删除</el-button>
|
||||||
>
|
</template>
|
||||||
删除
|
</el-popconfirm>
|
||||||
</el-button>
|
<el-popconfirm confirm-button-text='确定' cancel-button-text='取消' icon="el-icon-info" icon-color="red"
|
||||||
<el-popconfirm
|
title="您确定删除吗?">
|
||||||
confirm-button-text='确定'
|
|
||||||
cancel-button-text='取消'
|
|
||||||
icon="el-icon-info"
|
|
||||||
icon-color="red"
|
|
||||||
title="您确定删除吗?"
|
|
||||||
>
|
|
||||||
</el-popconfirm>
|
</el-popconfirm>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
<!-- 分页器 -->
|
||||||
<div style="padding: 10px 0">
|
<div style="padding: 10px 0">
|
||||||
<el-pagination
|
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
|
||||||
@size-change="handleSizeChange"
|
:current-page="searchParams.current" :page-size="searchParams.pageSize" :page-sizes="[5, 10, 15, 20]"
|
||||||
@current-change="handleCurrentChange"
|
:small="null" :disabled="null" :background="null" layout="total, sizes, prev, pager, next, jumper"
|
||||||
:current-page="pageNum"
|
:total="total" />
|
||||||
:page-size="pageSize"
|
|
||||||
:page-sizes="[2, 5, 10, 20]"
|
|
||||||
:small="null"
|
|
||||||
:disabled="null"
|
|
||||||
:background="null"
|
|
||||||
layout="total, sizes, prev, pager, next, jumper"
|
|
||||||
:total="total"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<!-- 编辑/详情表单 -->
|
||||||
<el-dialog v-model="detailDialogVisible" title="商品详情">
|
<el-dialog v-model="DialogVisible" :title="title">
|
||||||
<el-form label-width="100px">
|
<el-form label-width="100px" :disabled="disabled">
|
||||||
<el-form-item label="商品编号">
|
<el-form-item label="商品编号">
|
||||||
<el-input v-model="selectedProduct.id" disabled></el-input>
|
<el-input v-model="editForm.id" disabled></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="商品图片">
|
<el-form-item label="商品图片">
|
||||||
<div v-if="selectedProduct.goodImg">
|
<div v-if="editForm.goodImg">
|
||||||
<img :src="selectedProduct.goodImg" alt="类别图标" class="thumbnail" style="width: 100px; height: 100px;"/>
|
<img :src="editForm.goodImg" alt="商品图标" class="thumbnail" style="width: 100px; height: 100px;" />
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
<el-upload
|
||||||
<el-form-item label="商品名称">
|
action="#"
|
||||||
<el-input v-model="selectedProduct.name" disabled></el-input>
|
list-type="picture-card"
|
||||||
</el-form-item>
|
:auto-upload="false"
|
||||||
<el-form-item label="商品价格">
|
multiple="true"
|
||||||
<el-input v-model="selectedProduct.price" disabled></el-input>
|
:on-remove="handleRemove"
|
||||||
</el-form-item>
|
@change="(event: any) => handleChange(event, 0)"
|
||||||
<el-form-item label="商品类型">
|
limit="1" >
|
||||||
<el-select v-model="selectedProduct.type" placeholder="请选择" disabled>
|
<el-icon>
|
||||||
<el-option label="材料包" value="材料包" />
|
<Plus/>
|
||||||
<el-option label="手持物" value="手持物" />
|
</el-icon>
|
||||||
<el-option label="头饰" value="头饰" />
|
|
||||||
<el-option label="定制" value="定制" />
|
|
||||||
<el-option label="积分兑换" value="积分兑换" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="商品数量">
|
|
||||||
<el-input v-model="selectedProduct.inventory" disabled></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="商品状态">
|
|
||||||
<el-select v-model="selectedProduct.isShelves" placeholder="请选择" disabled>
|
|
||||||
<el-option label="上架" value="上架" />
|
|
||||||
<el-option label="下架" value="下架" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="是否为限定产品">
|
|
||||||
<el-select v-model="selectedProduct.region" placeholder="请选择" disabled>
|
|
||||||
<el-option label="是" value="是" />
|
|
||||||
<el-option label="否" value="否" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="商品标签">
|
|
||||||
<el-input v-model="selectedProduct.label" disabled></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="商品描述">
|
|
||||||
<el-input type="textarea" v-model="selectedProduct.introDetailintroDetail" disabled></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<template #footer>
|
|
||||||
<span class="dialog-footer">
|
|
||||||
<el-button @click="detailDialogVisible = false">取消</el-button>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
|
|
||||||
<el-dialog v-model="editDialogVisible" title="商品编辑">
|
|
||||||
<el-form label-width="100px">
|
|
||||||
<el-form-item label="商品编号">
|
|
||||||
<el-input v-model="editForm.id"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="商品图片">
|
|
||||||
<el-upload action="#" list-type="picture" :auto-upload="false">
|
|
||||||
<el-icon><Plus /></el-icon>
|
|
||||||
<template #file="{ file }">
|
|
||||||
<img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
|
|
||||||
</template>
|
|
||||||
</el-upload>
|
</el-upload>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="商品名称">
|
<el-form-item label="商品名称">
|
||||||
|
@ -208,123 +119,92 @@
|
||||||
<el-form-item label="商品价格">
|
<el-form-item label="商品价格">
|
||||||
<el-input v-model="editForm.price"></el-input>
|
<el-input v-model="editForm.price"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="商品类型">
|
<el-form-item label="产品类别" prop="type">
|
||||||
<el-select v-model="editForm.type" placeholder="请选择">
|
<el-select v-model="editForm.type" @change="(event: any) => loadForm(event, 1)">
|
||||||
<el-option label="材料包" value="材料包" />
|
<el-option v-for="item in typeList" :key="item.value" :label="item.label" :value="item.value1" />
|
||||||
<el-option label="手持物" value="手持物" />
|
|
||||||
<el-option label="头饰" value="头饰" />
|
|
||||||
<el-option label="定制" value="定制" />
|
|
||||||
<el-option label="积分兑换" value="定制" />
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="商品数量">
|
<el-form-item label="商品数量">
|
||||||
<el-input v-model="editForm.inventory"></el-input>
|
<el-input v-model="editForm.inventory"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="商品状态">
|
<el-form-item label="商品状态">
|
||||||
<el-select v-model="editForm.isShelves" disabled>
|
<el-select v-model="editForm.isShelves">
|
||||||
<el-option label="上架" value="上架" />
|
<el-option label="上架" value="上架" />
|
||||||
<el-option label="下架" value="下架" />
|
<el-option label="下架" value="下架" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="是否为限定产品">
|
<el-form-item label="是否为限定类产品" prop="festivalOrder">
|
||||||
<el-select v-model="editForm.region" placeholder="请选择">
|
<el-select v-model="editForm.festivalOrder" @change="(event: any) => loadForm(event, 0)">
|
||||||
<el-option label="是" value="是" />
|
<el-option label="是" value="1" />
|
||||||
<el-option label="否" value="否" />
|
<el-option label="否" value="0" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="商品标签">
|
<el-form-item label="商品标签">
|
||||||
<el-input v-model="editForm.label"></el-input>
|
<el-input v-model="editForm.label"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="商品图文">
|
||||||
|
<div v-if="editForm.detailImg">
|
||||||
|
<img :src="editForm.detailImg" alt="商品图标" class="thumbnail" style="width: 100px; height: 100px;" />
|
||||||
|
</div>
|
||||||
|
<el-upload
|
||||||
|
action="#"
|
||||||
|
list-type="picture-card"
|
||||||
|
:auto-upload="false"
|
||||||
|
multiple="true"
|
||||||
|
:on-remove="handleRemove"
|
||||||
|
@change="(event: any) => handleChange(event, 0)"
|
||||||
|
limit="1" >
|
||||||
|
<el-icon>
|
||||||
|
<Plus/>
|
||||||
|
</el-icon>
|
||||||
|
</el-upload>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="商品描述">
|
<el-form-item label="商品描述">
|
||||||
<el-input type="textarea" v-model="editForm.introDetail"></el-input>
|
<el-input type="textarea" v-model="editForm.introDetail"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<template #footer>
|
<template #footer >
|
||||||
<span class="dialog-footer">
|
<span class="dialog-footer">
|
||||||
<el-button @click="editDialogVisible = false">取消</el-button>
|
<el-button @click="DialogVisible = false" :disabled="disabled">取消</el-button>
|
||||||
<el-button type="primary" @click="saveEdit">保存</el-button>
|
<el-button type="primary" @click="saveEdit" :disabled="disabled">确认</el-button>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage , type UploadProps } from 'element-plus';
|
||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted, toRaw } from 'vue';
|
||||||
import myAxios from "@/api/myAxios";
|
import myAxios from "@/api/myAxios";
|
||||||
//总页数
|
const total = ref(0); //总页数
|
||||||
const total = ref(0);
|
|
||||||
const id = ref([]);
|
const id = ref([]);
|
||||||
//封装分页
|
const searchParams: any = ref({ //封装分页
|
||||||
const searchParams: any = ref({
|
current: 1, //当前页码
|
||||||
//当前页码
|
pageSize: 5 //每页显示条数
|
||||||
current: 1,
|
|
||||||
//每页显示条数
|
|
||||||
pageSize: 5
|
|
||||||
})
|
})
|
||||||
|
const fileSimple = ref()
|
||||||
|
const disabled = ref(true)
|
||||||
|
const title = ref('')
|
||||||
const username = ref('');
|
const username = ref('');
|
||||||
const detailDialogVisible = ref(false);
|
const DialogVisible = ref(false);
|
||||||
const editDialogVisible = ref(false);
|
|
||||||
const types = ref('');
|
const types = ref('');
|
||||||
const Region = ref('');
|
const Region = ref('');
|
||||||
let selectedProduct = ref('');
|
const tableData : any= ref([]);
|
||||||
const loading = ref(false)
|
const editForm : any = ref({});
|
||||||
const tableData = ref([]);
|
const typeList: any = ref([
|
||||||
let editForm = ref({
|
{
|
||||||
id: '',
|
value1: '',
|
||||||
goodImg: '',
|
label: ''
|
||||||
name: '',
|
}
|
||||||
price: '',
|
])
|
||||||
type: '',
|
onMounted(() => { //页面加载时获取商品列表和分类页表
|
||||||
inventory: '',
|
getProductList()
|
||||||
isShelves: '',
|
getTypeList()
|
||||||
attribute:'',
|
|
||||||
region: '',
|
|
||||||
label: '',
|
|
||||||
introDetail: '',
|
|
||||||
});
|
|
||||||
//页面加载时获取商品列表
|
|
||||||
onMounted(() => {
|
|
||||||
getGoodList()
|
|
||||||
})
|
})
|
||||||
const handleSelectionChange = (row: any) => {
|
const getProductList = async () => {
|
||||||
id.value = JSON.parse(JSON.stringify(row));
|
|
||||||
};
|
|
||||||
const handleView = (index: number, row: any) => {
|
|
||||||
selectedProduct = row;
|
|
||||||
detailDialogVisible.value = true;
|
|
||||||
};
|
|
||||||
const handleRevise = (index: number, row: any) => {
|
|
||||||
selectedProduct = row;
|
|
||||||
editDialogVisible.value = true;
|
|
||||||
editForm.value = row;
|
|
||||||
};
|
|
||||||
const handleOff = (index: number, row: any) => {
|
|
||||||
console.log()
|
|
||||||
if (row.isShelves === 0) {
|
|
||||||
row.isShelves = 1;//0下架,1上架
|
|
||||||
console.log(row.isShelves)
|
|
||||||
} else if (row.isShelves ===1) {
|
|
||||||
row.isShelves = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleDelete = (index: number, row: any) => {
|
|
||||||
const confirmDelete = window.confirm('您确定要删除该商品吗?');
|
|
||||||
if (confirmDelete) {
|
|
||||||
tableData.value = tableData.value.filter((item, i) => i!== index);
|
|
||||||
ElMessage({
|
|
||||||
message: '删除成功',
|
|
||||||
type: 'success',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const getGoodList = async () => {
|
|
||||||
loading.value = true;
|
|
||||||
try {
|
try {
|
||||||
const res = await myAxios.post('/goods/list/page', {...searchParams.value });
|
const res = await myAxios.post('/goods/list/page', { ...searchParams.value });
|
||||||
console.log(res.data)
|
// console.log(res.data)
|
||||||
if (res.data.code === 1) {
|
if (res.data.code === 1) {
|
||||||
tableData.value = res.data.data.records;
|
tableData.value = res.data.data.records;
|
||||||
total.value = parseInt(res.data.data.total)//总数据量,用于分页
|
total.value = parseInt(res.data.data.total)//总数据量,用于分页
|
||||||
|
@ -339,67 +219,116 @@ const getGoodList = async () => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//处理行数大小变化
|
const getTypeList = async () => {
|
||||||
const handleSizeChange =(newSize : any)=>{
|
const res = await myAxios.post('/category/list', {}) //获取商品列表
|
||||||
searchParams.value.pageSize = newSize //新的页面数
|
for (let key in res.data.data) { //循环赋值
|
||||||
getGoodList()
|
typeList.value[key] = {
|
||||||
|
value1: res.data.data[key].typeName,
|
||||||
|
label: res.data.data[key].typeName
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//处理当前页面变化
|
const saveEdit = async () => { //编辑商品
|
||||||
const handleCurrentChange = (Current : any) => {
|
const res = await myAxios.post('/goods/update',{...editForm.value})
|
||||||
searchParams.value.current = Current
|
if( res.data.code === 1 ) {
|
||||||
getGoodList()
|
ElMessage({
|
||||||
|
type: 'success',
|
||||||
|
message: '更新成功'
|
||||||
|
})
|
||||||
|
DialogVisible.value = false
|
||||||
|
} else {
|
||||||
|
ElMessage.error('更新失败,请检查字段')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//删除商品
|
||||||
|
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: '删除成功',
|
||||||
|
})
|
||||||
|
getProductList()
|
||||||
|
}
|
||||||
|
getTypeList()
|
||||||
|
}
|
||||||
|
const handleSelectionChange = (row: any) => {
|
||||||
|
id.value = JSON.parse(JSON.stringify(row));
|
||||||
|
};
|
||||||
|
//详情或编辑
|
||||||
|
const ReviseOrView = (index: number, row: any , flag : number) => {
|
||||||
|
//flag值不同显示不同内容 disabled开启和关闭
|
||||||
|
flag ? (title.value = "编辑商品" , disabled.value = false) : (title.value = "商品详情" , disabled.value = true)
|
||||||
|
DialogVisible.value = true;
|
||||||
|
editForm.value = row;
|
||||||
|
};
|
||||||
|
//下架商品(待优化,有问题,逻辑有问题)
|
||||||
|
const handleOff = async (index: number, row: any) => {
|
||||||
|
row.isShelves ? row.isShelves = 0 : row.isShelves = 1 //三元运算符 改变那一行的上架值
|
||||||
|
editForm.value = row;
|
||||||
|
const res = await myAxios.post('/goods/update',{...editForm.value})
|
||||||
|
if(res.data.code === 1) {
|
||||||
|
ElMessage({
|
||||||
|
type:'success',
|
||||||
|
message:'更新成功'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//处理行数大小变化
|
||||||
|
const handleSizeChange = (newSize: any) => {
|
||||||
|
searchParams.value.pageSize = newSize //新的页面数
|
||||||
|
getProductList()
|
||||||
|
}
|
||||||
|
//处理当前表格变化
|
||||||
|
const handleCurrentChange = (Current: any) => {
|
||||||
|
searchParams.value.current = Current
|
||||||
|
getProductList()
|
||||||
}
|
}
|
||||||
const reset = () => {
|
const reset = () => {
|
||||||
username.value = '';
|
username.value = '';
|
||||||
types.value = '';
|
types.value = '';
|
||||||
Region.value = '';
|
Region.value = '';
|
||||||
};
|
};
|
||||||
// const saveEdit = () => {
|
//上传图片移除 --逻辑上移除
|
||||||
// const indexToUpdate = tableData.findIndex(item => item.id === editForm.value.id);
|
const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
|
||||||
// if (indexToUpdate!== -1) {
|
console.log(uploadFile, uploadFiles)
|
||||||
// tableData[indexToUpdate] = {
|
}
|
||||||
// ...tableData[indexToUpdate],
|
//将 商品类别 赋值到表格里
|
||||||
// ...editForm.value,
|
const loadForm = (value: any, flag: number) => {
|
||||||
// };
|
flag ? editForm.value.type = value : editForm.value.festivalOrder = value //三元运算符 flag=1 是关于"商品类别"选项的值 flag=0 是关于“是否为节日限定”选项的值
|
||||||
// ElMessage({
|
}
|
||||||
// message: '编辑成功',
|
//图片上传请求 此请求只要选择了图片,就会默认上传
|
||||||
// type: 'success',
|
const handleChange = async (file: any, flag: number) => {
|
||||||
// });
|
fileSimple.value = file
|
||||||
// editDialogVisible.value = false;
|
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",
|
||||||
|
file: formData.get("file") // 取出formData对象中的file
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (res.data.code === 1) {
|
||||||
|
//三元运算 当flag为0时,赋值给商品图片 flag为1时,赋值给详情图片
|
||||||
|
flag ? editForm.value.detailImg = res.data.data : editForm.value.goodImg = res.data.data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// const getListPage = async () => {
|
const delBatch =()=>{
|
||||||
// await instance.post('/goods/list/page').then(res => {
|
//批量删除
|
||||||
// console.log(res.data.data);
|
}
|
||||||
// res.data.data.forEach(item => {
|
const load =()=>{}
|
||||||
// console.log(item);
|
|
||||||
// });
|
|
||||||
// tableData.value = res.data.data;
|
|
||||||
// });
|
|
||||||
// };
|
|
||||||
const delBatchSuccess = () => {
|
|
||||||
ElMessage({
|
|
||||||
message: '批量删除成功',
|
|
||||||
type: 'success',
|
|
||||||
});
|
|
||||||
};
|
|
||||||
// const delBatch = async () => {
|
|
||||||
// await instance.post('').then(res => {
|
|
||||||
// if (res.data.code === '200') {
|
|
||||||
// load();
|
|
||||||
// } else {
|
|
||||||
// ElMessage({
|
|
||||||
// message: '批量删除失败',
|
|
||||||
// type: 'error',
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// };
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.headerBg {
|
.headerBg {
|
||||||
background-color: #eee!important;
|
background-color: #eee !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
|
@ -6,11 +6,20 @@
|
||||||
|
|
||||||
<el-dialog v-model="dialogVisible" title="商品类别" width="500">
|
<el-dialog v-model="dialogVisible" title="商品类别" width="500">
|
||||||
<el-form :model="typeForm" label-width="auto" style="max-width: 600px">
|
<el-form :model="typeForm" label-width="auto" style="max-width: 600px">
|
||||||
<el-form-item label="类别图标">
|
<el-form-item label="添加类别图片">
|
||||||
<div v-if="typeForm.typeUrl">
|
<!-- 下面的event的作用,传入当前事件对象 -->
|
||||||
<img :src="typeForm.typeUrl" alt="类别图标" class="thumbnail" style="width: 100px; height: 100px;" />
|
<el-upload
|
||||||
</div>
|
action="#"
|
||||||
<input type="file" @change="handleFileUpload" accept="image/*" />
|
list-type="picture-card"
|
||||||
|
:auto-upload="false"
|
||||||
|
multiple="true"
|
||||||
|
:on-remove="handleRemove"
|
||||||
|
@change="(event: any) => handleChange(event)"
|
||||||
|
limit="1" >
|
||||||
|
<el-icon>
|
||||||
|
<Plus />
|
||||||
|
</el-icon>
|
||||||
|
</el-upload>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="类别名">
|
<el-form-item label="类别名">
|
||||||
<el-input v-model="typeForm.typeName" />
|
<el-input v-model="typeForm.typeName" />
|
||||||
|
@ -19,7 +28,6 @@
|
||||||
<el-input v-model="typeForm.typeIntro" />
|
<el-input v-model="typeForm.typeIntro" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<template #footer #default="{ row, $index }">
|
<template #footer #default="{ row, $index }">
|
||||||
<div class="dialog-footer">
|
<div class="dialog-footer">
|
||||||
<el-button @click="cancel">取消</el-button>
|
<el-button @click="cancel">取消</el-button>
|
||||||
|
@ -33,6 +41,7 @@
|
||||||
<el-table :data="tableData" border style="width: 100%;" :header-cell-style="{ 'text-align': 'center' }"
|
<el-table :data="tableData" border style="width: 100%;" :header-cell-style="{ 'text-align': 'center' }"
|
||||||
@selection-change="handleSelectionChange" :cell-style="{ 'text-align': 'center', 'font-size': '16px' }">
|
@selection-change="handleSelectionChange" :cell-style="{ 'text-align': 'center', 'font-size': '16px' }">
|
||||||
<el-table-column type="selection" width="55"></el-table-column>
|
<el-table-column type="selection" width="55"></el-table-column>
|
||||||
|
<el-table-column prop="id" label="类别编号" width="150"></el-table-column>
|
||||||
<el-table-column prop="typeUrl" label="类别图片" width="300">
|
<el-table-column prop="typeUrl" label="类别图片" width="300">
|
||||||
<!-- 插槽,拿到父组件的值typeUrl -->
|
<!-- 插槽,拿到父组件的值typeUrl -->
|
||||||
<!-- scope 提供了关于当前行的信息 -->
|
<!-- scope 提供了关于当前行的信息 -->
|
||||||
|
@ -56,11 +65,11 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage ,type UploadProps} from 'element-plus';
|
||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import myAxios from '@/api/myAxios';
|
import myAxios from '@/api/myAxios';
|
||||||
|
const fileSimple = ref() //单个文件
|
||||||
const selectedItems = ref([])
|
const selectedItems = ref([])
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
//表单数据
|
//表单数据
|
||||||
const typeForm = ref({
|
const typeForm = ref({
|
||||||
|
@ -84,9 +93,34 @@ const getTypeList = async () => {
|
||||||
// console.log(res.data.data)
|
// console.log(res.data.data)
|
||||||
if (res.data.code === 1) {
|
if (res.data.code === 1) {
|
||||||
tableData.value = res.data.data
|
tableData.value = res.data.data
|
||||||
|
} else {
|
||||||
|
ElMessage.error('获取类别列表失败,请检查服务')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//上传图片,一张图片,不需要flag值
|
||||||
|
const handleChange = async (file: any) => {
|
||||||
|
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",
|
||||||
|
file: formData.get("file") // 取出formData对象中的file
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if ( res.data.code === 1) {
|
||||||
|
typeForm.value.typeUrl = res.data.data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//上传图片移除 --逻辑上移除
|
||||||
|
const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
|
||||||
|
console.log(uploadFile, uploadFiles)
|
||||||
|
}
|
||||||
//新增类别
|
//新增类别
|
||||||
const showForm = async () => {
|
const showForm = async () => {
|
||||||
dialogVisible.value = true;
|
dialogVisible.value = true;
|
||||||
|
@ -99,7 +133,7 @@ const cancel = () => {
|
||||||
}
|
}
|
||||||
//新增类别 很繁杂 不知道怎么改 只能不断判空
|
//新增类别 很繁杂 不知道怎么改 只能不断判空
|
||||||
const addOrUpdateType = async () => {
|
const addOrUpdateType = async () => {
|
||||||
//判空
|
//判空(*后期引入对象判空)
|
||||||
if (typeForm.value.typeName?.indexOf(' ') !== -1 ||
|
if (typeForm.value.typeName?.indexOf(' ') !== -1 ||
|
||||||
typeForm.value.typeName == '' || typeForm.value.typeUrl == '') {
|
typeForm.value.typeName == '' || typeForm.value.typeUrl == '') {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
|
@ -114,7 +148,7 @@ const addOrUpdateType = async () => {
|
||||||
const res = await myAxios.post('/category/add', {
|
const res = await myAxios.post('/category/add', {
|
||||||
//对齐后端请求体
|
//对齐后端请求体
|
||||||
typeName: typeForm.value.typeName,
|
typeName: typeForm.value.typeName,
|
||||||
typeUrl: typeForm.value.typeUrl.substring(0, 10),
|
typeUrl: typeForm.value.typeUrl,
|
||||||
typeIntro: typeForm.value.typeIntro
|
typeIntro: typeForm.value.typeIntro
|
||||||
})
|
})
|
||||||
if (res.data.code === 1) {
|
if (res.data.code === 1) {
|
||||||
|
@ -155,25 +189,12 @@ const resetForm = () => {
|
||||||
const handleSelectionChange = (row: any) => {
|
const handleSelectionChange = (row: any) => {
|
||||||
selectedItems.value = JSON.parse(JSON.stringify(row))
|
selectedItems.value = JSON.parse(JSON.stringify(row))
|
||||||
}
|
}
|
||||||
//图片文件上传
|
//编辑
|
||||||
const handleFileUpload = (event: Event) => {
|
|
||||||
const target = event.target as HTMLInputElement;
|
|
||||||
const file = target.files?.[0];
|
|
||||||
if (file) {
|
|
||||||
const reader = new FileReader();
|
|
||||||
reader.onload = (e) => {
|
|
||||||
if (e.target?.result) {
|
|
||||||
typeForm.value.typeUrl = e.target.result as string; // 将图片URL赋值给表单
|
|
||||||
}
|
|
||||||
};
|
|
||||||
reader.readAsDataURL(file); // 读取文件为Data URL
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const editShowForm = (index: number, row: any) => {
|
const editShowForm = (index: number, row: any) => {
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
typeForm.value = row
|
typeForm.value = row
|
||||||
flag.value = 1
|
flag.value = 1
|
||||||
console.log(row)
|
// console.log(row)
|
||||||
}
|
}
|
||||||
//删除类别 请求体里只传id即可
|
//删除类别 请求体里只传id即可
|
||||||
const Delete_type = async (index: number) => {
|
const Delete_type = async (index: number) => {
|
||||||
|
|
|
@ -62,12 +62,6 @@
|
||||||
await router.replace('/PersonalCenter')
|
await router.replace('/PersonalCenter')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// const login = () => {
|
|
||||||
// // console.log(username)
|
|
||||||
// // console.log(password)
|
|
||||||
// if(username.value ==="a"&& password.value ==="1"){
|
|
||||||
// router.push("/UserManagement")
|
|
||||||
// }}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
13
src/views/Orders/OrderList.vue
Normal file
13
src/views/Orders/OrderList.vue
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
|
||||||
|
</style>
|
51
src/views/test.vue
Normal file
51
src/views/test.vue
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
v-for="(item, index) in items"
|
||||||
|
:key="index"
|
||||||
|
class="box"
|
||||||
|
@click="changeColor(index)"
|
||||||
|
:style="getBoxStyle(index)"
|
||||||
|
>
|
||||||
|
{{ item }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setup() {
|
||||||
|
const items = ref(['Box 1', 'Box 2', 'Box 3']);
|
||||||
|
const currentColor = ref(null);
|
||||||
|
|
||||||
|
const changeColor = (index) => {
|
||||||
|
currentColor.value = index;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getBoxStyle = (index) => ({
|
||||||
|
backgroundColor: currentColor.value === index ? 'lightblue' : 'gray'
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
items,
|
||||||
|
changeColor,
|
||||||
|
getBoxStyle,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.box {
|
||||||
|
width: 200px;
|
||||||
|
height: 100px;
|
||||||
|
color: black;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
cursor: pointer;
|
||||||
|
margin: 5px 0;
|
||||||
|
}
|
||||||
|
</style>
|
Loading…
Reference in New Issue
Block a user