2024-10-23 09:55:22 +00:00
|
|
|
|
<template>
|
2024-11-03 04:40:56 +00:00
|
|
|
|
<!-- 修改前请注释以前的 -->
|
2025-03-11 08:31:52 +00:00
|
|
|
|
<!-- 搜索 -->
|
|
|
|
|
<div>
|
2025-03-12 23:10:56 +00:00
|
|
|
|
<el-input style="width: 240px; margin-right: 10px;" suffix-icon="Search" placeholder="请输入商品名称" size="default"
|
2025-03-11 08:31:52 +00:00
|
|
|
|
v-model="productName"></el-input>
|
2025-03-12 23:10:56 +00:00
|
|
|
|
<el-button type="primary" @click="onSearch(productName)" style="margin-right: 10px;" size="default">
|
2025-03-11 08:31:52 +00:00
|
|
|
|
搜索
|
|
|
|
|
</el-button>
|
2025-03-12 23:10:56 +00:00
|
|
|
|
<el-select v-model="productType" @change="(event: any) => searchByType(event)" placeholder="商品类别"
|
|
|
|
|
style="width: 240px; margin-right: 10px;" size="default" :clearable="true">
|
2025-03-11 08:31:52 +00:00
|
|
|
|
<el-option v-for="item in typeList" :key="item.value" :label="item.label" :value="item.value1"/>
|
|
|
|
|
</el-select>
|
2025-03-12 23:10:56 +00:00
|
|
|
|
<el-select v-model="state" placeholder="商品状态" @change="(event: any) => searchByState(event)" size="default"
|
2025-03-11 08:31:52 +00:00
|
|
|
|
style="width: 240px; margin-right: 10px;">
|
|
|
|
|
<el-option label="已上架" value="1"/>
|
|
|
|
|
<el-option label="已下架" value="0"/>
|
|
|
|
|
</el-select>
|
2025-03-12 23:10:56 +00:00
|
|
|
|
<el-button type="warning" @click="reset" size="default">重置</el-button>
|
2025-03-11 08:31:52 +00:00
|
|
|
|
</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"
|
|
|
|
|
@select="selectChange"
|
|
|
|
|
:header-cell-style="{ 'text-align': 'center' }">
|
|
|
|
|
<el-table-column type="selection" width="55"></el-table-column>
|
|
|
|
|
<el-table-column prop="id" label="商品编号" width="80">
|
|
|
|
|
<template #default="{ $index }">
|
|
|
|
|
{{ $index + 1 }}
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column prop="goodImg" label="商品图片">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<div>
|
|
|
|
|
<img :src="scope.row.goodImg.split(';')[0]" alt="" style="height: 50px;">
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column prop="name" label="商品名称"></el-table-column>
|
|
|
|
|
<el-table-column prop="price" label="商品价格" width="180">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<div>
|
|
|
|
|
{{ scope.row.price }} 元
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column prop="type" label="商品类型"></el-table-column>
|
|
|
|
|
<el-table-column prop="inventory" label="商品数量"></el-table-column>
|
|
|
|
|
<el-table-column label="商品状态">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<div>
|
|
|
|
|
<span style="margin-left: 10px" v-if="scope.row.isShelves == 1">上架</span>
|
|
|
|
|
<span style="margin-left: 10px" v-if="scope.row.isShelves == 0">下架</span>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</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-button size="small" @click="ReviseOrView(scope.$index, scope.row, 1)">
|
|
|
|
|
编辑
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button size="small" @click="handleOff(scope.$index, scope.row)">
|
|
|
|
|
<div v-if="scope.row.isShelves == 1">下架</div>
|
|
|
|
|
<div v-if="scope.row.isShelves == 0">上架</div>
|
|
|
|
|
</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>
|
2024-11-03 04:40:56 +00:00
|
|
|
|
<template #reference>
|
2025-03-11 08:31:52 +00:00
|
|
|
|
<el-button class="ml-5" type="danger">删除</el-button>
|
2024-11-03 04:40:56 +00:00
|
|
|
|
</template>
|
|
|
|
|
</el-popconfirm>
|
2025-03-11 08:31:52 +00:00
|
|
|
|
</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>
|
2024-11-03 04:40:56 +00:00
|
|
|
|
<!-- 编辑/详情表单 -->
|
|
|
|
|
<el-dialog v-model="DialogVisible" :title="title">
|
2025-03-11 08:31:52 +00:00
|
|
|
|
<el-form label-width="100px" :disabled="disabled" v-model="editForm">
|
2024-10-27 11:05:39 +00:00
|
|
|
|
<el-form-item label="商品编号">
|
2024-12-20 07:58:31 +00:00
|
|
|
|
<el-input v-model="editForm.id" disabled style="width: 60px;"></el-input>
|
2024-10-27 11:05:39 +00:00
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="商品图片">
|
2025-03-11 08:31:52 +00:00
|
|
|
|
<el-upload
|
|
|
|
|
v-model:file-list="ImgArr"
|
|
|
|
|
ref="uploadProductImg"
|
|
|
|
|
action="#"
|
|
|
|
|
list-type="picture-card"
|
|
|
|
|
:auto-upload="false"
|
|
|
|
|
multiple="true"
|
|
|
|
|
:on-remove="removePic"
|
|
|
|
|
@change="(event: any) => handleChange(event, 0)"
|
|
|
|
|
:on-exceed="Exceed_ProductImg"
|
|
|
|
|
limit="7">
|
2024-11-03 04:40:56 +00:00
|
|
|
|
<el-icon>
|
|
|
|
|
<Plus/>
|
|
|
|
|
</el-icon>
|
2024-10-27 11:05:39 +00:00
|
|
|
|
</el-upload>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="商品名称">
|
2024-12-20 07:58:31 +00:00
|
|
|
|
<el-input v-model="editForm.name" style="width: 200px;"></el-input>
|
2024-10-27 11:05:39 +00:00
|
|
|
|
</el-form-item>
|
2024-12-19 10:55:48 +00:00
|
|
|
|
<el-form-item label="产品价格" prop="price">
|
2025-03-11 08:31:52 +00:00
|
|
|
|
<el-input-number v-model="editForm.price" min="0.01" :precision="2" :step="0.5"/>
|
2024-12-20 07:58:31 +00:00
|
|
|
|
<p style="margin-left: 5px">元</p>
|
2024-10-27 11:05:39 +00:00
|
|
|
|
</el-form-item>
|
2024-12-20 07:58:31 +00:00
|
|
|
|
<div style="display: flex;">
|
|
|
|
|
<el-form-item label="产品类别" prop="type">
|
|
|
|
|
<el-select v-model="editForm.type" @change="(event: any) => loadForm(event, 1)" style="width: 120px;">
|
2025-03-11 08:31:52 +00:00
|
|
|
|
<el-option v-for="item in typeList" :key="item.value" :label="item.label" :value="item.value1"/>
|
2024-12-20 07:58:31 +00:00
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
2025-01-02 12:27:34 +00:00
|
|
|
|
<!-- <el-form-item label="商品数量">
|
2024-12-20 07:58:31 +00:00
|
|
|
|
<el-input v-model="editForm.inventory" style="width: 50px;"></el-input>
|
2025-01-02 12:27:34 +00:00
|
|
|
|
</el-form-item> -->
|
|
|
|
|
<el-form-item label="库存" prop="inventory">
|
|
|
|
|
<el-input-number v-model="editForm.inventory" min="0" :precision="0" :step="1"/>
|
2024-12-20 07:58:31 +00:00
|
|
|
|
</el-form-item>
|
|
|
|
|
</div>
|
|
|
|
|
<div style="display: flex;">
|
|
|
|
|
<el-form-item label="是否为限定类产品" prop="festivalOrder">
|
|
|
|
|
<el-select v-model="editForm.festivalOrder" @change="(event: any) => loadForm(event, 0)" style="width: 70px;">
|
2025-03-11 08:31:52 +00:00
|
|
|
|
<el-option label="是" value="1"/>
|
|
|
|
|
<el-option label="否" value="0"/>
|
2024-12-20 07:58:31 +00:00
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="商品标签">
|
|
|
|
|
<el-input v-model="editForm.label" style="width: auto;"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</div>
|
2024-11-03 04:40:56 +00:00
|
|
|
|
<el-form-item label="商品图文">
|
|
|
|
|
<div v-if="editForm.detailImg">
|
2025-03-11 08:31:52 +00:00
|
|
|
|
<img :src="editForm.detailImg" alt="商品图标" class="thumbnail" style="width: 100px; height: 100px;"/>
|
2024-11-03 04:40:56 +00:00
|
|
|
|
</div>
|
2025-03-11 08:31:52 +00:00
|
|
|
|
<el-upload
|
|
|
|
|
ref="uploadProductDetail"
|
|
|
|
|
action="#"
|
|
|
|
|
list-type="picture-card"
|
|
|
|
|
:auto-upload="false"
|
|
|
|
|
multiple="true"
|
|
|
|
|
:on-remove="handleRemove"
|
|
|
|
|
@change="(event: any) => handleChange(event, 1)"
|
|
|
|
|
:on-exceed="Exceed_ProductDetail"
|
|
|
|
|
limit="1">
|
2024-11-03 04:40:56 +00:00
|
|
|
|
<el-icon>
|
|
|
|
|
<Plus/>
|
|
|
|
|
</el-icon>
|
|
|
|
|
</el-upload>
|
|
|
|
|
</el-form-item>
|
2024-10-27 11:05:39 +00:00
|
|
|
|
<el-form-item label="商品描述">
|
2024-10-29 11:52:21 +00:00
|
|
|
|
<el-input type="textarea" v-model="editForm.introDetail"></el-input>
|
2024-10-27 11:05:39 +00:00
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
2025-03-11 08:31:52 +00:00
|
|
|
|
<template #footer>
|
2024-10-27 11:05:39 +00:00
|
|
|
|
<span class="dialog-footer">
|
2024-11-03 04:40:56 +00:00
|
|
|
|
<el-button @click="DialogVisible = false" :disabled="disabled">取消</el-button>
|
|
|
|
|
<el-button type="primary" @click="saveEdit" :disabled="disabled">确认</el-button>
|
2024-10-27 11:05:39 +00:00
|
|
|
|
</span>
|
2024-10-23 09:55:22 +00:00
|
|
|
|
</template>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</template>
|
|
|
|
|
|
2024-11-03 04:40:56 +00:00
|
|
|
|
<script setup lang="ts">
|
2025-03-11 08:31:52 +00:00
|
|
|
|
import {ElMessage, type UploadProps, genFileId, type UploadRawFile} from 'element-plus';
|
|
|
|
|
import {ref, onMounted, inject} from 'vue';
|
2024-10-29 11:52:21 +00:00
|
|
|
|
import myAxios from "@/api/myAxios";
|
2025-03-11 08:31:52 +00:00
|
|
|
|
import {
|
|
|
|
|
handleChange,
|
|
|
|
|
removePic,
|
|
|
|
|
handleRemove,
|
|
|
|
|
Exceed_ProductImg,
|
|
|
|
|
ImgArr,
|
|
|
|
|
editForm
|
|
|
|
|
} from '@/utils/entityProduct/picUpload';
|
2024-12-19 10:55:48 +00:00
|
|
|
|
// import { handleChange, handleRemove, form, Exceed_ProductImg } from '@/utils/entityProduct/picUpload';
|
2024-11-03 04:40:56 +00:00
|
|
|
|
const total = ref(0); //总页数
|
2025-03-02 03:29:54 +00:00
|
|
|
|
const idList = ref<Number[]>([]);
|
2024-11-03 04:40:56 +00:00
|
|
|
|
const searchParams: any = ref({ //封装分页
|
|
|
|
|
current: 1, //当前页码
|
2024-11-08 02:05:50 +00:00
|
|
|
|
pageSize: 5, //每页显示条数
|
|
|
|
|
sortField: "id", //根据ID分类
|
|
|
|
|
sortOrder: "descend" //降序
|
2024-10-31 09:56:15 +00:00
|
|
|
|
})
|
2024-11-03 04:40:56 +00:00
|
|
|
|
const disabled = ref(true)
|
2024-12-19 10:55:48 +00:00
|
|
|
|
//表单变量
|
2024-11-05 12:19:45 +00:00
|
|
|
|
const title = ref('') //表单名字
|
|
|
|
|
const productName = ref('');
|
2024-11-03 04:40:56 +00:00
|
|
|
|
const DialogVisible = ref(false);
|
2024-11-05 12:19:45 +00:00
|
|
|
|
const state = ref(''); //根据商品上架状态select栏
|
2025-03-11 08:31:52 +00:00
|
|
|
|
const tableData: any = ref([]); //实体类商品表格
|
|
|
|
|
const reload: any = inject("reload") //页面重新刷新
|
|
|
|
|
const uploadProductImg: any = ref() //图片上传的ref绑定
|
|
|
|
|
const uploadProductDetail: any = ref() //图片上传的ref绑定
|
2024-11-03 04:40:56 +00:00
|
|
|
|
const typeList: any = ref([
|
|
|
|
|
{
|
|
|
|
|
value1: '',
|
|
|
|
|
label: ''
|
2024-10-27 11:05:39 +00:00
|
|
|
|
}
|
2024-11-03 04:40:56 +00:00
|
|
|
|
])
|
2025-03-12 23:10:56 +00:00
|
|
|
|
const productType = ref('') //商品类别
|
2024-11-03 04:40:56 +00:00
|
|
|
|
onMounted(() => { //页面加载时获取商品列表和分类页表
|
|
|
|
|
getProductList()
|
|
|
|
|
getTypeList()
|
|
|
|
|
})
|
|
|
|
|
const getProductList = async () => {
|
2024-10-31 08:25:23 +00:00
|
|
|
|
try {
|
2025-03-11 08:31:52 +00:00
|
|
|
|
const res = await myAxios.post('/goods/list/page', {...searchParams.value});
|
|
|
|
|
console.log('res--->', res.data)
|
2024-10-31 08:25:23 +00:00
|
|
|
|
if (res.data.code === 1) {
|
|
|
|
|
tableData.value = res.data.data.records;
|
2024-11-05 12:19:45 +00:00
|
|
|
|
total.value = parseInt(res.data.data.total) //总数据量,用于分页
|
2024-10-31 08:25:23 +00:00
|
|
|
|
} else {
|
|
|
|
|
ElMessage({
|
|
|
|
|
message: '获取数据失败',
|
|
|
|
|
});
|
2024-11-05 12:19:45 +00:00
|
|
|
|
return;
|
2024-10-31 08:25:23 +00:00
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
2024-10-29 11:52:21 +00:00
|
|
|
|
ElMessage({
|
2024-10-31 08:25:23 +00:00
|
|
|
|
message: '发生错误',
|
|
|
|
|
});
|
2024-10-29 11:52:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-03 04:40:56 +00:00
|
|
|
|
const getTypeList = async () => {
|
|
|
|
|
const res = await myAxios.post('/category/list', {}) //获取商品列表
|
|
|
|
|
for (let key in res.data.data) { //循环赋值
|
|
|
|
|
typeList.value[key] = {
|
|
|
|
|
value1: res.data.data[key].typeName,
|
|
|
|
|
label: res.data.data[key].typeName
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const saveEdit = async () => { //编辑商品
|
2025-03-11 08:31:52 +00:00
|
|
|
|
const res = await myAxios.post('/goods/update', {...editForm.value})
|
|
|
|
|
if (res.data.code === 1) {
|
2024-11-03 04:40:56 +00:00
|
|
|
|
ElMessage({
|
|
|
|
|
type: 'success',
|
|
|
|
|
message: '更新成功'
|
|
|
|
|
})
|
|
|
|
|
DialogVisible.value = false
|
2025-03-13 02:29:48 +00:00
|
|
|
|
getProductList()
|
2024-11-03 04:40:56 +00:00
|
|
|
|
} else {
|
|
|
|
|
ElMessage.error('更新失败,请检查字段')
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-03-11 08:31:52 +00:00
|
|
|
|
const searchByType = (event: any) => { //通过类别搜索
|
2024-11-05 12:19:45 +00:00
|
|
|
|
searchParams.value.type = event
|
|
|
|
|
searchParams.value.current = 1
|
|
|
|
|
getProductList()
|
|
|
|
|
}
|
2025-03-11 08:31:52 +00:00
|
|
|
|
const searchByState = (event: any) => { //通过商品是否上架/下架搜索
|
2024-11-05 12:19:45 +00:00
|
|
|
|
searchParams.value.isShelves = event
|
|
|
|
|
searchParams.value.current = 1
|
|
|
|
|
getProductList()
|
|
|
|
|
}
|
2024-11-03 04:40:56 +00:00
|
|
|
|
//删除商品
|
|
|
|
|
const deleteProduct = async (index: number) => {
|
|
|
|
|
console.log(typeof index)
|
2025-03-11 08:31:52 +00:00
|
|
|
|
const res = await myAxios.post('/goods/delete', {id: index})
|
2024-11-03 04:40:56 +00:00
|
|
|
|
console.log(res)
|
|
|
|
|
if (res.data.code === 1) {
|
|
|
|
|
ElMessage({
|
|
|
|
|
type: 'success',
|
|
|
|
|
message: '删除成功',
|
|
|
|
|
})
|
|
|
|
|
getProductList()
|
|
|
|
|
}
|
|
|
|
|
getTypeList()
|
|
|
|
|
}
|
|
|
|
|
//详情或编辑
|
2025-03-11 08:31:52 +00:00
|
|
|
|
const ReviseOrView = (index: number, row: any, flag: number) => {
|
|
|
|
|
ImgArr.value.splice(0, ImgArr.value.length)
|
2024-12-19 10:55:48 +00:00
|
|
|
|
var tempArr = row.goodImg.split(';')
|
2025-03-11 08:31:52 +00:00
|
|
|
|
tempArr.forEach((item: any) => {
|
2024-12-19 10:55:48 +00:00
|
|
|
|
ImgArr.value.push({
|
|
|
|
|
url: item
|
|
|
|
|
})
|
|
|
|
|
})
|
2025-03-11 08:31:52 +00:00
|
|
|
|
flag ? (title.value = "编辑商品" , disabled.value = false) : (title.value = "商品详情" , disabled.value = true)
|
2024-11-03 04:40:56 +00:00
|
|
|
|
DialogVisible.value = true;
|
2025-03-11 08:31:52 +00:00
|
|
|
|
editForm.value = JSON.parse(JSON.stringify(row))
|
|
|
|
|
}
|
2024-12-19 10:55:48 +00:00
|
|
|
|
//下架商品
|
2025-03-11 08:31:52 +00:00
|
|
|
|
const handleOff = async (index: number, row: any) => {
|
2024-11-03 04:40:56 +00:00
|
|
|
|
row.isShelves ? row.isShelves = 0 : row.isShelves = 1 //三元运算符 改变那一行的上架值
|
|
|
|
|
editForm.value = row;
|
2025-03-11 08:31:52 +00:00
|
|
|
|
const res = await myAxios.post('/goods/update', {...editForm.value})
|
|
|
|
|
if (res.data.code === 1) {
|
2024-11-03 04:40:56 +00:00
|
|
|
|
ElMessage({
|
2025-03-11 08:31:52 +00:00
|
|
|
|
type: 'success',
|
|
|
|
|
message: '更新成功'
|
2024-11-03 04:40:56 +00:00
|
|
|
|
})
|
2025-03-11 08:31:52 +00:00
|
|
|
|
}
|
2024-11-03 04:40:56 +00:00
|
|
|
|
}
|
2024-10-31 09:56:15 +00:00
|
|
|
|
//处理行数大小变化
|
2024-11-03 04:40:56 +00:00
|
|
|
|
const handleSizeChange = (newSize: any) => {
|
2024-10-31 09:56:15 +00:00
|
|
|
|
searchParams.value.pageSize = newSize //新的页面数
|
2024-11-03 04:40:56 +00:00
|
|
|
|
getProductList()
|
2024-10-31 09:56:15 +00:00
|
|
|
|
}
|
2024-11-03 04:40:56 +00:00
|
|
|
|
//处理当前表格变化
|
|
|
|
|
const handleCurrentChange = (Current: any) => {
|
|
|
|
|
searchParams.value.current = Current
|
|
|
|
|
getProductList()
|
2024-10-31 09:56:15 +00:00
|
|
|
|
}
|
2024-11-05 12:19:45 +00:00
|
|
|
|
//重置按钮
|
2024-10-27 11:05:39 +00:00
|
|
|
|
const reset = () => {
|
2024-11-05 12:19:45 +00:00
|
|
|
|
reload()
|
2024-10-27 11:05:39 +00:00
|
|
|
|
};
|
2024-11-05 12:19:45 +00:00
|
|
|
|
const Exceed_ProductDetail: UploadProps['onExceed'] = (files) => { //覆盖商品详情图片
|
|
|
|
|
uploadProductDetail.value!.clearFiles()
|
|
|
|
|
const file = files[0] as UploadRawFile
|
|
|
|
|
file.uid = genFileId()
|
|
|
|
|
uploadProductDetail.value!.handleStart(file)
|
|
|
|
|
}
|
2024-11-03 04:40:56 +00:00
|
|
|
|
//将 商品类别 赋值到表格里
|
|
|
|
|
const loadForm = (value: any, flag: number) => {
|
|
|
|
|
flag ? editForm.value.type = value : editForm.value.festivalOrder = value //三元运算符 flag=1 是关于"商品类别"选项的值 flag=0 是关于“是否为节日限定”选项的值
|
|
|
|
|
}
|
2025-03-11 08:31:52 +00:00
|
|
|
|
const onSearch = (data: String) => { //搜索按钮方法
|
2024-11-05 12:19:45 +00:00
|
|
|
|
searchParams.value.name = data
|
|
|
|
|
searchParams.value.current = 1
|
|
|
|
|
getProductList()
|
|
|
|
|
}
|
2025-03-11 08:31:52 +00:00
|
|
|
|
//批量删除
|
|
|
|
|
const delBatch = async () => {
|
2024-11-12 11:50:54 +00:00
|
|
|
|
console.log(idList.value);
|
2025-03-11 08:31:52 +00:00
|
|
|
|
const res = await myAxios.post('/goods/delBatch', {
|
2024-11-12 11:50:54 +00:00
|
|
|
|
idList: idList.value
|
|
|
|
|
})
|
|
|
|
|
console.log(res.data);
|
2025-03-11 08:31:52 +00:00
|
|
|
|
if (res.data.code === 1) {
|
2024-11-12 11:50:54 +00:00
|
|
|
|
ElMessage({
|
|
|
|
|
type: 'success',
|
|
|
|
|
message: '批量删除成功'
|
|
|
|
|
})
|
|
|
|
|
getProductList()
|
|
|
|
|
} else {
|
|
|
|
|
ElMessage.error('删除失败')
|
|
|
|
|
}
|
2024-11-03 04:40:56 +00:00
|
|
|
|
}
|
2025-03-11 08:31:52 +00:00
|
|
|
|
const handleSelectionChange = () => {
|
|
|
|
|
}
|
|
|
|
|
const selectChange = (selection: any, row: any) => { //selction是对象数组,row是当前行对象
|
|
|
|
|
idList.value.splice(0, idList.value.length) //删掉
|
|
|
|
|
selection.forEach((item: any) => {
|
2025-03-02 03:29:54 +00:00
|
|
|
|
idList.value.push(item.id)
|
|
|
|
|
})
|
|
|
|
|
// console.log('idList--->',idList.value);
|
|
|
|
|
}
|
2024-10-23 09:55:22 +00:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2024-10-27 11:05:39 +00:00
|
|
|
|
.headerBg {
|
2024-11-03 04:40:56 +00:00
|
|
|
|
background-color: #eee !important;
|
2024-10-23 09:55:22 +00:00
|
|
|
|
}
|
|
|
|
|
</style>
|