商品中心模块功能开发对接后台
This commit is contained in:
parent
e3ced12a92
commit
f70341a24a
@ -6,7 +6,7 @@
|
|||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
<meta name="renderer" content="webkit">
|
<meta name="renderer" content="webkit">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||||
<link rel="icon" href="/favicon.ico">
|
<link rel="icon" href="/src/assets/logo/yunying.png">
|
||||||
<title>后台管理系统</title>
|
<title>后台管理系统</title>
|
||||||
<!--[if lt IE 11]><script>window.location.href='/html/ie.html';</script><![endif]-->
|
<!--[if lt IE 11]><script>window.location.href='/html/ie.html';</script><![endif]-->
|
||||||
<style>
|
<style>
|
||||||
|
@ -1,94 +1,157 @@
|
|||||||
import request from '@/utils/request'
|
import request from "@/utils/request";
|
||||||
|
|
||||||
// 获取商品管理列表
|
// 获取商品管理列表
|
||||||
export function getGoodManageInfo(query) {
|
export function getGoodManageInfo(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '/goods/goodInfoManage/getGoodManage',
|
url: "/goods/goodInfoManage/getGoodManage",
|
||||||
method: 'get',
|
method: "get",
|
||||||
params: query
|
params: query,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
// 获取商品列表页顶部tab中的数据
|
// 获取商品列表页顶部tab中的数据
|
||||||
export function getGoodManageCount(query) {
|
export function getGoodManageCount(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '/goods/goodInfoManage/getGoodManageCount',
|
url: "/goods/goodInfoManage/getGoodManageCount",
|
||||||
method: 'get',
|
method: "get",
|
||||||
params: query
|
params: query,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取商品分类列表
|
// 获取商品分类列表
|
||||||
export function getGoodType(query) {
|
export function getGoodType(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '/goods/goodInfoManage/goodType',
|
url: "/goods/goodInfoManage/goodType",
|
||||||
method: 'get',
|
method: "get",
|
||||||
params: query
|
params: query,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新商品发布
|
// 新增商品
|
||||||
export function goodAdd(data) {
|
export function goodAdd(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/goods/goodInfoManage/goodSave',
|
url: "/goods/goodInfoManage/goodSave",
|
||||||
method: 'post',
|
method: "post",
|
||||||
data: data
|
data: data,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
// 编辑商品发布
|
// 编辑商品
|
||||||
export function goodEdit(data) {
|
export function goodEdit(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/goods/goodInfoManage/goodEdit',
|
url: "/goods/goodInfoManage/goodEdit",
|
||||||
method: 'put',
|
method: "put",
|
||||||
data: data
|
data: data,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
// 商品删除
|
// 商品删除
|
||||||
export function goodDelete(id) {
|
export function goodDelete(id) {
|
||||||
return request({
|
return request({
|
||||||
url: '/goods/goodInfoManage/deleteGoodInfo/id=' + id,
|
url: "/goods/goodInfoManage/deleteGoodInfo?id=" + id,
|
||||||
method: 'delete',
|
method: "delete",
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 商品上架下架
|
// 商品上架下架
|
||||||
export function goodUpAndDown(data) {
|
export function goodUpAndDown(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/goods/goodInfoManage/goodOnSale',
|
url: "/goods/goodInfoManage/goodOnSale",
|
||||||
method: 'put',
|
method: "put",
|
||||||
data: data
|
data: data,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取商品信息(id)
|
// 获取商品信息(id)
|
||||||
export function getGoodInfo(id) {
|
export function getGoodInfo(id) {
|
||||||
return request({
|
return request({
|
||||||
url: '/goods/goodInfoManage/getGoodInfo/' + id,
|
url: "/goods/goodInfoManage/getGoodInfo/" + id,
|
||||||
method: 'get'
|
method: "get",
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取商品优惠信息配置项
|
// 获取商品优惠信息配置项
|
||||||
export function getActiveInfos() {
|
export function getActiveInfos() {
|
||||||
return request({
|
return request({
|
||||||
url: '/goods/goodInfoManage/getActiveInfos',
|
url: "/goods/goodInfoManage/getActiveInfos",
|
||||||
method: 'get'
|
method: "get",
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 获取商品分类列表
|
// 获取商品分类列表
|
||||||
export function getGoodCategoryInfo(query) {
|
export function getGoodCategoryInfo(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '/goods/business/category/list',
|
url: "/goods/business/category/list",
|
||||||
method: 'get',
|
method: "get",
|
||||||
params: query
|
params: query,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
// 新增商品分类
|
// 新增商品分类
|
||||||
export function categoryAdd(data) {
|
export function categoryAdd(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/goods/business/category/add',
|
url: "/goods/business/category/add",
|
||||||
method: 'post',
|
method: "post",
|
||||||
data: data
|
data: data,
|
||||||
})
|
});
|
||||||
|
}
|
||||||
|
// 编辑商品分类
|
||||||
|
export function categoryEdit(data) {
|
||||||
|
return request({
|
||||||
|
url: "/goods/business/category/edit",
|
||||||
|
method: "post",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 商品分类删除
|
||||||
|
export function categoryRemove(data) {
|
||||||
|
const formData = new FormData();
|
||||||
|
// 将data对象的每个属性添加到FormData
|
||||||
|
Object.keys(data).forEach((key) => {
|
||||||
|
formData.append(key, data[key]);
|
||||||
|
});
|
||||||
|
return request({
|
||||||
|
url: "/goods/business/category/remove",
|
||||||
|
method: "post",
|
||||||
|
data: formData,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "multipart/form-data",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 启用或禁用商品分类
|
||||||
|
export function enableAndDisableCategory(data) {
|
||||||
|
return request({
|
||||||
|
url: "/goods/business/category/add",
|
||||||
|
method: "post",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取违禁物品列表
|
||||||
|
export function getViolateGoodPage(query) {
|
||||||
|
return request({
|
||||||
|
url: "/goods/violate/getViolateGoodPage",
|
||||||
|
method: "get",
|
||||||
|
params: query,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 违禁物品新增
|
||||||
|
export function violateGoodSave(data) {
|
||||||
|
return request({
|
||||||
|
url: "/goods/violate/violateGoodSave",
|
||||||
|
method: "post",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 违禁物品编辑
|
||||||
|
export function violateGoodEdit(data) {
|
||||||
|
return request({
|
||||||
|
url: "/goods/violate/violateGoodEdit",
|
||||||
|
method: "put",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 违禁物品删除
|
||||||
|
export function deleteContraband(id) {
|
||||||
|
return request({
|
||||||
|
url: "/goods/violate/deleteViolateGoodInfo?id=" + id,
|
||||||
|
method: "delete",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
@ -5,165 +5,86 @@
|
|||||||
<div ref="searchBarRef" class="search-box">
|
<div ref="searchBarRef" class="search-box">
|
||||||
<div class="search-bar">
|
<div class="search-bar">
|
||||||
<div class="search-bar-left">
|
<div class="search-bar-left">
|
||||||
<el-form
|
<el-form ref="searchForm" :inline="true" :model="formInline" class="demo-form-inline" :label-width="'auto'">
|
||||||
ref="searchForm"
|
<el-form-item label="物品名称" prop="violateGoodName">
|
||||||
:inline="true"
|
<el-input v-model="formInline.violateGoodName" placeholder="请输入物品名称" clearable />
|
||||||
:model="formInline"
|
|
||||||
class="demo-form-inline"
|
|
||||||
:label-width="'auto'"
|
|
||||||
>
|
|
||||||
<el-form-item label="物品名称" prop="contrabandName">
|
|
||||||
<el-input
|
|
||||||
v-model="formInline.contrabandName"
|
|
||||||
placeholder="请输入物品名称"
|
|
||||||
clearable
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<br>
|
<br>
|
||||||
<el-form-item
|
<el-form-item label="添加时间" prop="startDate" style="margin-right: 0">
|
||||||
label="添加时间"
|
<el-date-picker v-model="formInline.startDate" type="date" value-format="YYYY-MM-DD"
|
||||||
prop="startDate"
|
placeholder="请选择起始日期" clearable :disabled-date="disableStartDate" style="width: 160px" />
|
||||||
style="margin-right: 0"
|
<span style="width: 30px; text-align: center; display: inline-block">
|
||||||
>
|
|
||||||
<el-date-picker
|
|
||||||
v-model="formInline.startDate"
|
|
||||||
type="date"
|
|
||||||
value-format="YYYY-MM-DD"
|
|
||||||
placeholder="请选择起始日期"
|
|
||||||
clearable
|
|
||||||
:disabled-date="disableStartDate"
|
|
||||||
style="width: 160px"
|
|
||||||
/>
|
|
||||||
<span
|
|
||||||
style="width: 30px; text-align: center; display: inline-block"
|
|
||||||
>
|
|
||||||
-
|
-
|
||||||
</span>
|
</span>
|
||||||
<el-date-picker
|
<el-date-picker v-model="formInline.endDate" type="date" value-format="YYYY-MM-DD" placeholder="请选择截止日期"
|
||||||
v-model="formInline.endDate"
|
clearable :disabled-date="disableEndDate" style="width: 160px" />
|
||||||
type="date"
|
|
||||||
value-format="YYYY-MM-DD"
|
|
||||||
placeholder="请选择截止日期"
|
|
||||||
clearable
|
|
||||||
:disabled-date="disableEndDate"
|
|
||||||
style="width: 160px"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
<div class="search-bar-right">
|
<div class="search-bar-right">
|
||||||
<el-button type="primary" icon="Search" @click="onSubmit"
|
<el-button type="primary" icon="Search" @click="onSubmit">查询</el-button>
|
||||||
>查询</el-button
|
<el-button icon="Refresh" style="margin: 16px 0 0 0" @click="resetForm">重置</el-button>
|
||||||
>
|
|
||||||
<el-button
|
|
||||||
icon="Refresh"
|
|
||||||
style="margin: 16px 0 0 0"
|
|
||||||
@click="resetForm"
|
|
||||||
>重置</el-button
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 表格 -->
|
<!-- 表格 -->
|
||||||
<div class="table-cont" :style="{ height: tableViewportHeight + 'px' }">
|
<div class="table-cont" :style="{ height: tableViewportHeight + 'px' }">
|
||||||
<div class="table-toolbar">
|
<div class="table-toolbar">
|
||||||
<el-button
|
<el-button icon="delete" @click="batchDelete" :disabled="btnStatus" style="margin-right: 0px">批量删除</el-button>
|
||||||
icon="delete"
|
<el-button type="primary" icon="plus" @click="addItem">添加物品</el-button>
|
||||||
@click="batchDelete"
|
|
||||||
:disabled="btnStatus"
|
|
||||||
style="margin-right: 10px"
|
|
||||||
>批量删除</el-button
|
|
||||||
>
|
|
||||||
<router-link to="/goods/addGoods">
|
|
||||||
<el-button type="primary" icon="plus" @click="onSubmit"
|
|
||||||
>添加分类</el-button
|
|
||||||
>
|
|
||||||
</router-link>
|
|
||||||
</div>
|
</div>
|
||||||
<tableComponent
|
<tableComponent :table-data="tableData" :columns="columns" :show-border="false" :show-selection="true"
|
||||||
:table-data="tableData"
|
:header-cell-class-name="getHeaderClass" @page-change="handlePaginationChange" :loading="tableLoading"
|
||||||
:columns="columns"
|
@selection-change="handleSelectionChange" :total="tableTotal" :current-page="formInline.current"
|
||||||
:show-border="false"
|
:page-size="formInline.size" :showSort="true">
|
||||||
:show-selection="true"
|
|
||||||
:header-cell-class-name="getHeaderClass"
|
|
||||||
@page-change="handlePaginationChange"
|
|
||||||
:loading="tableLoading"
|
|
||||||
@selection-change="handleSelectionChange"
|
|
||||||
:total="tableTotal"
|
|
||||||
:current-page="formInline.current"
|
|
||||||
:page-size="formInline.size"
|
|
||||||
:showSort="true"
|
|
||||||
>
|
|
||||||
<!-- 自定义-状态 -->
|
<!-- 自定义-状态 -->
|
||||||
<template #goodsUrl="slotProps">
|
<template #goodsUrl="slotProps">
|
||||||
<div class="table-cell-img-box">
|
<div class="table-cell-img-box">
|
||||||
<img
|
<img :src="slotProps.row.goodsUrl" class="table-cell-img" alt="" />
|
||||||
:src="slotProps.row.goodsUrl"
|
|
||||||
class="table-cell-img"
|
|
||||||
alt=""
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- 自定义-操作 -->
|
<!-- 自定义-操作 -->
|
||||||
<template #action="slotProps">
|
<template #action="slotProps">
|
||||||
<el-tooltip effect="dark" placement="bottom-end">
|
<el-button text class="el-button-custom" @click="handleEdit(slotProps.row)">编辑</el-button>
|
||||||
<template #content>
|
<el-button text class="el-button-delete" @click="handleDelete(slotProps.row)">删除</el-button>
|
||||||
<div class="custom-tooltip-content">
|
|
||||||
<el-icon
|
|
||||||
class="el-icon-custom"
|
|
||||||
@click="seeDetails(slotProps.row)"
|
|
||||||
>
|
|
||||||
<View />
|
|
||||||
</el-icon>
|
|
||||||
<el-icon
|
|
||||||
class="el-icon-custom"
|
|
||||||
@click="toUpload(slotProps.row)"
|
|
||||||
>
|
|
||||||
<Upload />
|
|
||||||
</el-icon>
|
|
||||||
<el-icon
|
|
||||||
class="el-icon-custom"
|
|
||||||
@click="toDownload(slotProps.row)"
|
|
||||||
>
|
|
||||||
<Download />
|
|
||||||
</el-icon>
|
|
||||||
<el-icon
|
|
||||||
class="el-icon-custom"
|
|
||||||
@click="handleEdit(slotProps.row)"
|
|
||||||
>
|
|
||||||
<Edit />
|
|
||||||
</el-icon>
|
|
||||||
<el-icon
|
|
||||||
class="el-icon-custom"
|
|
||||||
@click="handleDelete(slotProps.row)"
|
|
||||||
>
|
|
||||||
<Delete />
|
|
||||||
</el-icon>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<span class="el-dropdown-link">
|
|
||||||
<el-icon>
|
|
||||||
<More />
|
|
||||||
</el-icon>
|
|
||||||
</span>
|
|
||||||
</el-tooltip>
|
|
||||||
</template>
|
</template>
|
||||||
</tableComponent>
|
</tableComponent>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 添加物品 -->
|
||||||
|
<el-dialog v-model="dialogFormVisible" :title="dialogTitle" width="500">
|
||||||
|
<el-form :model="dialogForm" :label-width="'110'" :rules="dialogFormRules" ref="dialogRef">
|
||||||
|
<el-form-item label="违禁物品名称" prop="violateGoodName">
|
||||||
|
<el-input v-model="dialogForm.violateGoodName" autocomplete="off" placeholder="请输入违禁物品名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="违禁物品参数" prop="goodParameter">
|
||||||
|
<el-input v-model="dialogForm.goodParameter" autocomplete="off" placeholder="请输入违禁物品参数" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="onSaveCategory">
|
||||||
|
保存
|
||||||
|
</el-button>
|
||||||
|
<el-button @click="cancelDialog">取消</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, reactive, computed, onMounted, onBeforeUnmount } from "vue";
|
import { ref, reactive, computed, onMounted, onBeforeUnmount } from "vue";
|
||||||
import tableComponent from "@/components/tableComponent.vue";
|
import tableComponent from "@/components/tableComponent.vue";
|
||||||
import Mock from "mockjs";
|
import Mock from "mockjs";
|
||||||
import { getGoodManageInfo } from "@/api/goods/info";
|
import { getViolateGoodPage, violateGoodSave, violateGoodEdit, deleteContraband } from "@/api/goods/info";
|
||||||
import { ca } from "element-plus/es/locales.mjs";
|
import { ca } from "element-plus/es/locales.mjs";
|
||||||
|
const { proxy } = getCurrentInstance()
|
||||||
|
|
||||||
const formInline = reactive({
|
const formInline = reactive({
|
||||||
contrabandName: "",
|
violateGoodName: "",
|
||||||
startDate: "",
|
startDate: "",
|
||||||
endDate: "",
|
endDate: "",
|
||||||
current: 1,
|
current: 1,
|
||||||
@ -186,9 +107,7 @@ const disableEndDate = (time) => {
|
|||||||
|
|
||||||
const searchForm = ref(null);
|
const searchForm = ref(null);
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
console.log("submit!");
|
|
||||||
formInline.current = 1;
|
formInline.current = 1;
|
||||||
console.log(formInline);
|
|
||||||
loadData();
|
loadData();
|
||||||
};
|
};
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
@ -208,8 +127,8 @@ let nowClickRow = ref({});
|
|||||||
const columns = ref([]);
|
const columns = ref([]);
|
||||||
const columns1 = ref([
|
const columns1 = ref([
|
||||||
{ prop: "id", label: "ID" },
|
{ prop: "id", label: "ID" },
|
||||||
{ prop: "contrabandName", label: "违禁物品名称" },
|
{ prop: "violateGoodName", label: "违禁物品名称" },
|
||||||
{ prop: "contrabandParameter", label: "违禁物品参数" },
|
{ prop: "goodParameter", label: "违禁物品参数" },
|
||||||
{ prop: "createTime", label: "创建时间" },
|
{ prop: "createTime", label: "创建时间" },
|
||||||
{ prop: "action", label: "操作", slotName: "action" },
|
{ prop: "action", label: "操作", slotName: "action" },
|
||||||
]);
|
]);
|
||||||
@ -220,8 +139,8 @@ const generateMockData = () => {
|
|||||||
"list|10": [
|
"list|10": [
|
||||||
{
|
{
|
||||||
"id|+1": 10000,
|
"id|+1": 10000,
|
||||||
contrabandName: '@pick(["毒品", "炸药", "血腥"])', //分类名称
|
violateGoodName: '@pick(["毒品", "炸药", "血腥"])', //分类名称
|
||||||
contrabandParameter: '@pick(["手动编辑", "图片上传"])', //状态
|
goodParameter: '@pick(["手动编辑", "图片上传"])', //状态
|
||||||
createTime: "@datetime", //添加时间
|
createTime: "@datetime", //添加时间
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -230,18 +149,17 @@ const generateMockData = () => {
|
|||||||
// 加载数据
|
// 加载数据
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
tableLoading.value = true;
|
tableLoading.value = true;
|
||||||
tableData.value = generateMockData();
|
// tableData.value = generateMockData();
|
||||||
tableTotal.value = tableData.value.length;
|
// tableTotal.value = tableData.value.length;
|
||||||
// try {
|
try {
|
||||||
// let response = await getGoodManageInfo(formInline);
|
let response = await getViolateGoodPage(formInline);
|
||||||
// console.log(response);
|
if (response.code == 200) {
|
||||||
// if (response.code == 200) {
|
tableData.value = response.data.records;
|
||||||
// tableData.value = response.data.records;
|
tableTotal.value = response.data.total;
|
||||||
// tableTotal.value = response.data.total;
|
}
|
||||||
// }
|
} catch (error) {
|
||||||
// } catch (error) {
|
|
||||||
// console.log(error);
|
}
|
||||||
// }
|
|
||||||
tableLoading.value = false;
|
tableLoading.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -251,7 +169,6 @@ const getHeaderClass = ({ column }) => {
|
|||||||
};
|
};
|
||||||
// 分页变化
|
// 分页变化
|
||||||
const handlePaginationChange = ({ page, pageSize }) => {
|
const handlePaginationChange = ({ page, pageSize }) => {
|
||||||
console.log("分页变化:", page, pageSize);
|
|
||||||
formInline.current = page;
|
formInline.current = page;
|
||||||
formInline.size = pageSize;
|
formInline.size = pageSize;
|
||||||
// 这里可以调用API获取新数据
|
// 这里可以调用API获取新数据
|
||||||
@ -262,32 +179,107 @@ const handleSelectionChange = (selection, ids) => {
|
|||||||
console.log("选中项:", selection, ids);
|
console.log("选中项:", selection, ids);
|
||||||
selectedIds.value = ids;
|
selectedIds.value = ids;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 查看详情
|
|
||||||
const seeDetails = (row) => {
|
|
||||||
nowClickRow.value = row;
|
|
||||||
console.log("要查看详情的行:", row);
|
|
||||||
};
|
|
||||||
const toUpload = () => {
|
|
||||||
console.log("向上移动:");
|
|
||||||
};
|
|
||||||
const toDownload = () => {
|
|
||||||
console.log("向下移动:");
|
|
||||||
};
|
|
||||||
// 编辑操作
|
// 编辑操作
|
||||||
const handleEdit = (row) => {
|
const handleEdit = (row) => {
|
||||||
nowClickRow.value = row;
|
nowClickRow.value = row;
|
||||||
|
dialogTitle.value = "编辑违禁物品";
|
||||||
|
dialogFormVisible.value = true;
|
||||||
console.log("要编辑的行:", row);
|
console.log("要编辑的行:", row);
|
||||||
|
dialogForm.id = row.id;
|
||||||
|
dialogForm.violateGoodName = row.violateGoodName;
|
||||||
|
dialogForm.goodParameter = row.goodParameter;
|
||||||
};
|
};
|
||||||
// 删除操作
|
// 删除操作
|
||||||
const handleDelete = (row) => {
|
const handleDelete = (row) => {
|
||||||
nowClickRow.value = row;
|
|
||||||
console.log("要删除的行:", row);
|
console.log("要删除的行:", row);
|
||||||
|
onDelete(row.id)
|
||||||
};
|
};
|
||||||
// 批量删除
|
// 批量删除
|
||||||
const batchDelete = () => {
|
const batchDelete = () => {
|
||||||
console.log("要删除的行:", selectedIds.value);
|
console.log("要删除的行:", selectedIds.value);
|
||||||
|
onDelete(selectedIds.value.join(","))
|
||||||
};
|
};
|
||||||
|
const onDelete = async (param) => {
|
||||||
|
try {
|
||||||
|
tableLoading.value = true;
|
||||||
|
let res = await deleteContraband(param);
|
||||||
|
tableLoading.value = false;
|
||||||
|
if (res.code == 200) {
|
||||||
|
onsubmit();
|
||||||
|
ElMessage.success("删除成功");
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res.msg);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
tableLoading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const dialogFormVisible = ref(false);
|
||||||
|
const dialogRef = ref(null);
|
||||||
|
const dialogTitle = ref("添加违禁物品");
|
||||||
|
const dialogForm = reactive({
|
||||||
|
violateGoodName: "",
|
||||||
|
goodParameter: "",
|
||||||
|
});
|
||||||
|
const dialogFormRules = ref({
|
||||||
|
violateGoodName: [
|
||||||
|
{ required: true, message: "请输入违禁物品名称", trigger: "blur" },
|
||||||
|
{ min: 2, max: 10, message: "长度在 2 到 10 个字符", trigger: "blur" },
|
||||||
|
],
|
||||||
|
goodParameter: [
|
||||||
|
{ required: true, message: "请输入违禁物品参数", trigger: "blur" },
|
||||||
|
{ min: 2, max: 10, message: "长度在 2 到 10 个字符", trigger: "blur" },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
// 级联选择器配置
|
||||||
|
const cascaderProps = ref({
|
||||||
|
label: "name", // 选项标签字段名
|
||||||
|
value: "id", // 选项值字段名
|
||||||
|
children: "children", // 子选项字段名
|
||||||
|
emitPath: true,
|
||||||
|
expandTrigger: "hover",
|
||||||
|
});
|
||||||
|
const onSaveCategory = () => {
|
||||||
|
console.log(dialogForm);
|
||||||
|
dialogRef.value.validate(async (valid, fields) => {
|
||||||
|
if (valid) {
|
||||||
|
try {
|
||||||
|
proxy.$modal.loading("正在保存...")
|
||||||
|
let response;
|
||||||
|
if (dialogTitle.value == "添加违禁物品") {
|
||||||
|
response = await violateGoodSave(dialogForm);
|
||||||
|
} else {
|
||||||
|
response = await violateGoodEdit(dialogForm);
|
||||||
|
}
|
||||||
|
proxy.$modal.closeLoading()
|
||||||
|
if (response.code == 200) {
|
||||||
|
cancelDialog();
|
||||||
|
onSubmit();
|
||||||
|
if (dialogTitle.value == "添加违禁物品") {
|
||||||
|
ElMessage.success("添加成功!");
|
||||||
|
} else {
|
||||||
|
ElMessage.success("编辑成功!");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ElMessage.error(response.msg);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
proxy.$modal.closeLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const addItem = () => {
|
||||||
|
dialogTitle.value = "添加违禁物品";
|
||||||
|
dialogFormVisible.value = true;
|
||||||
|
};
|
||||||
|
const cancelDialog = () => {
|
||||||
|
dialogRef.value.resetFields();
|
||||||
|
dialogFormVisible.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const titleRef = ref(null);
|
const titleRef = ref(null);
|
||||||
const searchBarRef = ref(null);
|
const searchBarRef = ref(null);
|
||||||
@ -307,7 +299,6 @@ const calculateTableHeight = () => {
|
|||||||
// 最终计算
|
// 最终计算
|
||||||
tableViewportHeight.value =
|
tableViewportHeight.value =
|
||||||
windowHeight - headerHeight - searchBarHeight - paddingCompensation;
|
windowHeight - headerHeight - searchBarHeight - paddingCompensation;
|
||||||
// console.log(tableViewportHeight.value);
|
|
||||||
};
|
};
|
||||||
// 组件挂载时加载数据
|
// 组件挂载时加载数据
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
@ -5,180 +5,76 @@
|
|||||||
<div ref="searchBarRef" class="search-box">
|
<div ref="searchBarRef" class="search-box">
|
||||||
<div class="search-bar">
|
<div class="search-bar">
|
||||||
<div class="search-bar-left">
|
<div class="search-bar-left">
|
||||||
<el-form
|
<el-form ref="searchForm" :inline="true" :model="formInline" class="demo-form-inline" :label-width="'auto'">
|
||||||
ref="searchForm"
|
|
||||||
:inline="true"
|
|
||||||
:model="formInline"
|
|
||||||
class="demo-form-inline"
|
|
||||||
:label-width="'auto'"
|
|
||||||
>
|
|
||||||
<el-form-item label="分类名称" prop="name">
|
<el-form-item label="分类名称" prop="name">
|
||||||
<el-input
|
<el-input v-model="formInline.name" placeholder="请输入分类名称" clearable />
|
||||||
v-model="formInline.name"
|
|
||||||
placeholder="请输入分类名称"
|
|
||||||
clearable
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-select
|
<el-select v-model="formInline.status" placeholder="请选择" clearable>
|
||||||
v-model="formInline.status"
|
<el-option v-for="item in statusList" :key="item.id" :value="item.id" :label="item.name" />
|
||||||
placeholder="请选择"
|
|
||||||
clearable
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in statusList"
|
|
||||||
:key="item.id"
|
|
||||||
:value="item.id"
|
|
||||||
:label="item.name"
|
|
||||||
/>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<br />
|
<br />
|
||||||
<el-form-item
|
<el-form-item label="添加时间" prop="startDate" style="margin-right: 0">
|
||||||
label="添加时间"
|
<el-date-picker v-model="formInline.startDate" type="date" value-format="YYYY-MM-DD"
|
||||||
prop="startDate"
|
placeholder="请选择起始日期" clearable :disabled-date="disableStartDate" style="width: 160px" />
|
||||||
style="margin-right: 0"
|
<span style="width: 30px; text-align: center; display: inline-block">
|
||||||
>
|
|
||||||
<el-date-picker
|
|
||||||
v-model="formInline.startDate"
|
|
||||||
type="date"
|
|
||||||
value-format="YYYY-MM-DD"
|
|
||||||
placeholder="请选择起始日期"
|
|
||||||
clearable
|
|
||||||
:disabled-date="disableStartDate"
|
|
||||||
style="width: 160px"
|
|
||||||
/>
|
|
||||||
<span
|
|
||||||
style="width: 30px; text-align: center; display: inline-block"
|
|
||||||
>
|
|
||||||
-
|
-
|
||||||
</span>
|
</span>
|
||||||
<el-date-picker
|
<el-date-picker v-model="formInline.endDate" type="date" value-format="YYYY-MM-DD" placeholder="请选择截止日期"
|
||||||
v-model="formInline.endDate"
|
clearable :disabled-date="disableEndDate" style="width: 160px" />
|
||||||
type="date"
|
|
||||||
value-format="YYYY-MM-DD"
|
|
||||||
placeholder="请选择截止日期"
|
|
||||||
clearable
|
|
||||||
:disabled-date="disableEndDate"
|
|
||||||
style="width: 160px"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
<div class="search-bar-right">
|
<div class="search-bar-right">
|
||||||
<el-button type="primary" icon="Search" @click="onSubmit"
|
<el-button type="primary" icon="Search" @click="onSubmit">查询</el-button>
|
||||||
>查询</el-button
|
<el-button icon="Refresh" style="margin: 16px 0 0 0" @click="resetForm">重置</el-button>
|
||||||
>
|
|
||||||
<el-button
|
|
||||||
icon="Refresh"
|
|
||||||
style="margin: 16px 0 0 0"
|
|
||||||
@click="resetForm"
|
|
||||||
>重置</el-button
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 表格 -->
|
<!-- 表格 -->
|
||||||
<div class="table-cont" :style="{ height: tableViewportHeight + 'px' }">
|
<div class="table-cont" :style="{ height: tableViewportHeight + 'px' }">
|
||||||
<div class="table-toolbar">
|
<div class="table-toolbar">
|
||||||
<el-button
|
<el-button icon="delete" @click="batchDelete" :disabled="btnStatus" style="margin-right: 0px">批量删除</el-button>
|
||||||
icon="delete"
|
<el-button type="primary" icon="plus" @click="addCategory">添加分类</el-button>
|
||||||
@click="batchDelete"
|
|
||||||
:disabled="btnStatus"
|
|
||||||
style="margin-right: 0px"
|
|
||||||
>批量删除</el-button
|
|
||||||
>
|
|
||||||
<el-button type="primary" icon="plus" @click="addCategory"
|
|
||||||
>添加分类</el-button
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
<tableComponent
|
<tableComponent :table-data="tableData" :columns="columns" :show-border="false" :show-selection="true"
|
||||||
:table-data="tableData"
|
:header-cell-class-name="getHeaderClass" @page-change="handlePaginationChange" :loading="tableLoading"
|
||||||
:columns="columns"
|
@selection-change="handleSelectionChange" :total="tableTotal" :current-page="formInline.current"
|
||||||
:show-border="false"
|
:page-size="formInline.size" :showSort="true">
|
||||||
:show-selection="true"
|
|
||||||
:header-cell-class-name="getHeaderClass"
|
|
||||||
@page-change="handlePaginationChange"
|
|
||||||
:loading="tableLoading"
|
|
||||||
@selection-change="handleSelectionChange"
|
|
||||||
:total="tableTotal"
|
|
||||||
:current-page="formInline.current"
|
|
||||||
:page-size="formInline.size"
|
|
||||||
:showSort="true"
|
|
||||||
:rowkey="'goodId'"
|
|
||||||
>
|
|
||||||
<!-- 自定义-状态 -->
|
<!-- 自定义-状态 -->
|
||||||
<template #goodsUrl="slotProps">
|
<template #level="slotProps">
|
||||||
<div class="table-cell-img-box">
|
{{ slotProps.row.level }}级分类
|
||||||
<img
|
|
||||||
:src="slotProps.row.goodsUrl"
|
|
||||||
class="table-cell-img"
|
|
||||||
alt=""
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- 自定义-状态 -->
|
<!-- 自定义-状态 -->
|
||||||
<template #status="slotProps">
|
<template #status="slotProps">
|
||||||
<span v-if="slotProps.row.status == 1" class="color-green"
|
<span v-if="slotProps.row.status == 1" class="color-green">已启用</span>
|
||||||
>已启用</span
|
|
||||||
>
|
|
||||||
<span v-else class="color-gray">未启用</span>
|
<span v-else class="color-gray">未启用</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- 自定义-操作 -->
|
<!-- 自定义-操作 -->
|
||||||
<template #action="slotProps">
|
<template #action="slotProps">
|
||||||
<el-button
|
<el-button text v-if="slotProps.row.status == 2" class="el-button-custom"
|
||||||
text
|
@click="enableAndDisable(slotProps.row, 1)">启用</el-button>
|
||||||
v-if="slotProps.row.status == 2"
|
<el-button text v-if="slotProps.row.status == 1" class="el-button-custom"
|
||||||
class="el-button-custom"
|
@click="enableAndDisable(slotProps.row, 2)">禁用</el-button>
|
||||||
@click="seeDetails(slotProps.row)"
|
<el-button text class="el-button-custom" @click="handleEdit(slotProps.row)">编辑</el-button>
|
||||||
>启用</el-button
|
<el-button text class="el-button-delete" @click="handleDelete(slotProps.row)">删除</el-button>
|
||||||
>
|
|
||||||
<el-button
|
|
||||||
text
|
|
||||||
v-if="slotProps.row.status == 1"
|
|
||||||
class="el-button-custom"
|
|
||||||
@click="seeDetails(slotProps.row)"
|
|
||||||
>禁用</el-button
|
|
||||||
>
|
|
||||||
<el-button
|
|
||||||
text
|
|
||||||
class="el-button-custom"
|
|
||||||
@click="handleEdit(slotProps.row)"
|
|
||||||
>编辑</el-button
|
|
||||||
>
|
|
||||||
<el-button
|
|
||||||
text
|
|
||||||
class="el-button-delete"
|
|
||||||
@click="handleDelete(slotProps.row)"
|
|
||||||
>删除</el-button
|
|
||||||
>
|
|
||||||
</template>
|
</template>
|
||||||
</tableComponent>
|
</tableComponent>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 添加分类 -->
|
<!-- 添加分类 -->
|
||||||
<el-dialog v-model="dialogFormVisible" :title="dialogTitle" width="500">
|
<el-dialog v-model="dialogFormVisible" :title="dialogTitle" width="500" :close-on-click-modal="false">
|
||||||
<el-form
|
<el-form :model="dialogForm" :label-width="'80'" :rules="dialogFormRules" ref="dialogRef">
|
||||||
:model="dialogForm"
|
|
||||||
:label-width="'80'"
|
|
||||||
:rules="dialogFormRules"
|
|
||||||
ref="dialogRef"
|
|
||||||
>
|
|
||||||
<el-form-item label="分类名称" prop="name">
|
<el-form-item label="分类名称" prop="name">
|
||||||
<el-input v-model="dialogForm.name" autocomplete="off" placeholder="请输入分类名称" />
|
<el-input v-model="dialogForm.name" autocomplete="off" placeholder="请输入分类名称" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="父级分类" prop="parentId">
|
<el-form-item label="父级分类" prop="parentId">
|
||||||
<el-cascader
|
<el-cascader v-model="dialogForm.parentId" :options="goodsOptions" :props="cascaderProps"
|
||||||
v-model="dialogForm.parentId"
|
placeholder="请选择父级分类" clearable style="width: 100%" @change="handleCascaderChange" />
|
||||||
:options="goodsOptions"
|
|
||||||
:props="cascaderProps"
|
|
||||||
placeholder="请选择父级分类"
|
|
||||||
clearable
|
|
||||||
style="width: 100%"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="是否禁用" prop="status" required>
|
<el-form-item label="是否禁用" prop="status" required>
|
||||||
<el-radio-group v-model="dialogForm.status" style="margin-top: -3px">
|
<el-radio-group v-model="dialogForm.status" style="margin-top: -3px">
|
||||||
@ -190,7 +86,7 @@
|
|||||||
<template #footer>
|
<template #footer>
|
||||||
<div class="dialog-footer">
|
<div class="dialog-footer">
|
||||||
<el-button type="primary" @click="onSaveCategory">
|
<el-button type="primary" @click="onSaveCategory">
|
||||||
确认添加
|
保存
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button @click="cancelDialog">取消</el-button>
|
<el-button @click="cancelDialog">取消</el-button>
|
||||||
</div>
|
</div>
|
||||||
@ -202,9 +98,14 @@
|
|||||||
import { ref, reactive, computed, onMounted, onBeforeUnmount } from "vue";
|
import { ref, reactive, computed, onMounted, onBeforeUnmount } from "vue";
|
||||||
import tableComponent from "@/components/tableComponent.vue";
|
import tableComponent from "@/components/tableComponent.vue";
|
||||||
import Mock from "mockjs";
|
import Mock from "mockjs";
|
||||||
import { getGoodCategoryInfo, getGoodType, categoryAdd } from "@/api/goods/info";
|
import {
|
||||||
|
getGoodCategoryInfo,
|
||||||
|
getGoodType,
|
||||||
|
categoryAdd, categoryEdit,
|
||||||
|
categoryRemove,enableAndDisableCategory
|
||||||
|
} from "@/api/goods/info";
|
||||||
import { ca } from "element-plus/es/locales.mjs";
|
import { ca } from "element-plus/es/locales.mjs";
|
||||||
const { proxy } = getCurrentInstance()
|
const { proxy } = getCurrentInstance();
|
||||||
|
|
||||||
const formInline = reactive({
|
const formInline = reactive({
|
||||||
name: "",
|
name: "",
|
||||||
@ -235,10 +136,8 @@ const disableEndDate = (time) => {
|
|||||||
|
|
||||||
const searchForm = ref(null);
|
const searchForm = ref(null);
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
console.log("submit!");
|
|
||||||
formInline.current = 1;
|
formInline.current = 1;
|
||||||
formInline.status = formInline.status == undefined ? "" : formInline.status;
|
formInline.status = formInline.status == undefined ? "" : formInline.status;
|
||||||
console.log(formInline);
|
|
||||||
loadData();
|
loadData();
|
||||||
};
|
};
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
@ -257,8 +156,9 @@ let nowClickRow = ref({});
|
|||||||
// 列配置
|
// 列配置
|
||||||
const columns = ref([]);
|
const columns = ref([]);
|
||||||
const columns1 = ref([
|
const columns1 = ref([
|
||||||
{ prop: "id", label: "ID" },
|
// { prop: "id", label: "ID" },
|
||||||
{ prop: "name", label: "类别" },
|
{ prop: "name", label: "类别名称" },
|
||||||
|
{ prop: "level", label: "分类级别", slotName: "level" },
|
||||||
{ prop: "createTime", label: "添加时间" },
|
{ prop: "createTime", label: "添加时间" },
|
||||||
{ prop: "status", label: "状态", slotName: "status" },
|
{ prop: "status", label: "状态", slotName: "status" },
|
||||||
{ prop: "action", label: "操作", slotName: "action", width: 150 },
|
{ prop: "action", label: "操作", slotName: "action", width: 150 },
|
||||||
@ -296,6 +196,7 @@ const generateMockData = () => {
|
|||||||
name: '@pick(["种子", "化肥", "农药"])', //分类名称
|
name: '@pick(["种子", "化肥", "农药"])', //分类名称
|
||||||
createTime: "@datetime", //添加时间
|
createTime: "@datetime", //添加时间
|
||||||
status: "@pick([1, 2])", //状态
|
status: "@pick([1, 2])", //状态
|
||||||
|
level: "@pick([1, 2, 3])", //状态
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}).list;
|
}).list;
|
||||||
@ -307,13 +208,12 @@ const loadData = async () => {
|
|||||||
// tableTotal.value = tableData.value.length;
|
// tableTotal.value = tableData.value.length;
|
||||||
try {
|
try {
|
||||||
let response = await getGoodCategoryInfo(formInline);
|
let response = await getGoodCategoryInfo(formInline);
|
||||||
console.log(response);
|
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
tableData.value = response.data.records;
|
tableData.value = response.data.records;
|
||||||
tableTotal.value = response.data.total;
|
tableTotal.value = response.data.total;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
|
||||||
}
|
}
|
||||||
tableLoading.value = false;
|
tableLoading.value = false;
|
||||||
};
|
};
|
||||||
@ -324,7 +224,6 @@ const getHeaderClass = ({ column }) => {
|
|||||||
};
|
};
|
||||||
// 分页变化
|
// 分页变化
|
||||||
const handlePaginationChange = ({ page, pageSize }) => {
|
const handlePaginationChange = ({ page, pageSize }) => {
|
||||||
console.log("分页变化:", page, pageSize);
|
|
||||||
formInline.current = page;
|
formInline.current = page;
|
||||||
formInline.size = pageSize;
|
formInline.size = pageSize;
|
||||||
// 这里可以调用API获取新数据
|
// 这里可以调用API获取新数据
|
||||||
@ -332,28 +231,67 @@ const handlePaginationChange = ({ page, pageSize }) => {
|
|||||||
};
|
};
|
||||||
// 多选框变化
|
// 多选框变化
|
||||||
const handleSelectionChange = (selection, ids) => {
|
const handleSelectionChange = (selection, ids) => {
|
||||||
console.log("选中项:", selection, ids);
|
|
||||||
selectedIds.value = ids;
|
selectedIds.value = ids;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 查看详情
|
// 启用禁用
|
||||||
const seeDetails = (row) => {
|
const enableAndDisable = async (row, num) => {
|
||||||
nowClickRow.value = row;
|
nowClickRow.value = row;
|
||||||
console.log("要查看详情的行:", row);
|
try {
|
||||||
|
tableLoading.value = true;
|
||||||
|
let res = await enableAndDisableCategory({
|
||||||
|
id: row.id,
|
||||||
|
status: num,
|
||||||
|
});
|
||||||
|
tableLoading.value = false;
|
||||||
|
if (res.code == 200) {
|
||||||
|
onSubmit();
|
||||||
|
ElMessage.success(res.message);
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
tableLoading.value = false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// 编辑操作
|
// 编辑操作
|
||||||
const handleEdit = (row) => {
|
const handleEdit = (row) => {
|
||||||
nowClickRow.value = row;
|
nowClickRow.value = row;
|
||||||
console.log("要编辑的行:", row);
|
console.log("要编辑的行:", row);
|
||||||
|
dialogTitle.value = "编辑分类";
|
||||||
|
dialogFormVisible.value = true;
|
||||||
|
getGoodTypeList();
|
||||||
|
dialogForm.id = row.id;
|
||||||
|
dialogForm.type = row.type;
|
||||||
|
dialogForm.name = row.name;
|
||||||
|
dialogForm.level = row.level;
|
||||||
|
dialogForm.parentId = row.parentId;
|
||||||
|
dialogForm.status = row.status.toString();
|
||||||
};
|
};
|
||||||
// 删除操作
|
// 删除操作
|
||||||
const handleDelete = (row) => {
|
const handleDelete = (row) => {
|
||||||
nowClickRow.value = row;
|
|
||||||
console.log("要删除的行:", row);
|
console.log("要删除的行:", row);
|
||||||
|
deleteGoods(row.id);
|
||||||
};
|
};
|
||||||
// 批量删除
|
// 批量删除
|
||||||
const batchDelete = () => {
|
const batchDelete = () => {
|
||||||
console.log("要删除的行:", selectedIds.value);
|
console.log("要删除的行:", selectedIds.value);
|
||||||
|
deleteGoods(selectedIds.value.join(","));
|
||||||
|
};
|
||||||
|
const deleteGoods = async (ids) => {
|
||||||
|
try {
|
||||||
|
tableLoading.value = true;
|
||||||
|
let res = await categoryRemove({ id: ids });
|
||||||
|
tableLoading.value = false;
|
||||||
|
if (res.code == 200) {
|
||||||
|
onSubmit();
|
||||||
|
ElMessage.success("删除成功");
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res.msg);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
tableLoading.value = false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const dialogFormVisible = ref(false);
|
const dialogFormVisible = ref(false);
|
||||||
@ -363,7 +301,7 @@ const dialogForm = reactive({
|
|||||||
type: null, //分类类型归属,类型1->农资交易,2->供应商服务,3->采购商服务,4->土地交易
|
type: null, //分类类型归属,类型1->农资交易,2->供应商服务,3->采购商服务,4->土地交易
|
||||||
name: "", //分类名字
|
name: "", //分类名字
|
||||||
parentId: [], //父级id
|
parentId: [], //父级id
|
||||||
level: "", //分类层级
|
level: "", //分类层级,parentId的长度
|
||||||
sort: "", //排序值
|
sort: "", //排序值
|
||||||
status: "1", //分类状态(1-启用 2-禁用)
|
status: "1", //分类状态(1-启用 2-禁用)
|
||||||
});
|
});
|
||||||
@ -375,65 +313,83 @@ const dialogFormRules = ref({
|
|||||||
parentId: [
|
parentId: [
|
||||||
{ required: true, message: "请选择父级分类", trigger: ["blur", "change"] },
|
{ required: true, message: "请选择父级分类", trigger: ["blur", "change"] },
|
||||||
],
|
],
|
||||||
|
status: [{ required: true, message: "请选择分类状态", trigger: "change" }],
|
||||||
});
|
});
|
||||||
// 级联选择器配置
|
// 级联选择器配置
|
||||||
const cascaderProps = ref({
|
const cascaderProps = ref({
|
||||||
label: "name", // 选项标签字段名
|
label: "name", // 选项标签字段名
|
||||||
value: "id", // 选项值字段名
|
value: "id", // 选项值字段名
|
||||||
children: "children", // 子选项字段名
|
children: "children", // 子选项字段名
|
||||||
emitPath: true,
|
emitPath: false, // 只返回当前节点值,不返回路径
|
||||||
expandTrigger: "hover",
|
checkStrictly: true, //可以点击任意层级节点直接选中(不再需要展开到最后一级)
|
||||||
|
expandTrigger: "hover", // 展开触发方式,默认为点击,可选值为 hover
|
||||||
|
selectedNode: {},
|
||||||
});
|
});
|
||||||
const goodsOptions = ref([]);
|
const goodsOptions = ref([]);
|
||||||
const getGoodTypeList = async () => {
|
const getGoodTypeList = async () => {
|
||||||
try {
|
try {
|
||||||
let response = await getGoodType();
|
let response = await getGoodType();
|
||||||
console.log(response);
|
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
goodsOptions.value = response.data;
|
goodsOptions.value = response.data;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const onSaveCategory = async () => {
|
// 递归查找节点对象
|
||||||
console.log("保存分类");
|
const findNodeById = (options, id) => {
|
||||||
console.log(dialogForm);
|
for (const node of options) {
|
||||||
await dialogRef.value.validate(async (valid, fields) => {
|
if (node.id === id) return node
|
||||||
|
if (node.children) {
|
||||||
|
const found = findNodeById(node.children, id)
|
||||||
|
if (found) return found
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
const handleCascaderChange = (selectedId) => {
|
||||||
|
const selectedNode = findNodeById(goodsOptions.value, selectedId)
|
||||||
|
dialogForm.selectedNode = selectedNode
|
||||||
|
}
|
||||||
|
const onSaveCategory = () => {
|
||||||
|
dialogRef.value.validate(async (valid, fields) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
try {
|
try {
|
||||||
console.log("验证通过!");
|
proxy.$modal.loading("正在保存...");
|
||||||
proxy.$modal.loading("正在添加中...")
|
|
||||||
let param = { ...dialogForm };
|
let param = { ...dialogForm };
|
||||||
param.parentId = dialogForm.parentId.join(",");
|
param.level = dialogForm.selectedNode.level;
|
||||||
let response = await categoryAdd(param);
|
let response;
|
||||||
proxy.$modal.closeLoading()
|
if (dialogTitle.value == "编辑分类") {
|
||||||
|
response = await categoryEdit(param);
|
||||||
|
} else {
|
||||||
|
response = await categoryAdd(param);
|
||||||
|
}
|
||||||
|
proxy.$modal.closeLoading();
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
console.log(response);
|
cancelDialog();
|
||||||
dialogFormVisible.value = false;
|
onSubmit();
|
||||||
ElMessage.success(response.msg);
|
if (dialogTitle.value == "编辑分类") {
|
||||||
loadData();
|
ElMessage.success("编辑成功!");
|
||||||
|
} else {
|
||||||
|
ElMessage.success("添加成功!");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ElMessage.error(response.msg);
|
ElMessage.error(response.msg);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
proxy.$modal.closeLoading()
|
proxy.$modal.closeLoading();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
// 添加分类
|
// 添加分类
|
||||||
const addCategory = () => {
|
const addCategory = () => {
|
||||||
console.log("添加分类");
|
dialogTitle.value = "添加分类";
|
||||||
dialogFormVisible.value = true;
|
getGoodTypeList();
|
||||||
};
|
|
||||||
const EditCategory = () => {
|
|
||||||
console.log("编辑分类");
|
|
||||||
dialogTitle.value = "编辑分类";
|
|
||||||
dialogFormVisible.value = true;
|
dialogFormVisible.value = true;
|
||||||
};
|
};
|
||||||
const cancelDialog = () => {
|
const cancelDialog = () => {
|
||||||
console.log("取消");
|
dialogRef.value.resetFields();
|
||||||
dialogFormVisible.value = false;
|
dialogFormVisible.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -455,13 +411,11 @@ const calculateTableHeight = () => {
|
|||||||
// 最终计算
|
// 最终计算
|
||||||
tableViewportHeight.value =
|
tableViewportHeight.value =
|
||||||
windowHeight - headerHeight - searchBarHeight - paddingCompensation;
|
windowHeight - headerHeight - searchBarHeight - paddingCompensation;
|
||||||
// console.log(tableViewportHeight.value);
|
|
||||||
};
|
};
|
||||||
// 组件挂载时加载数据
|
// 组件挂载时加载数据
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
columns.value = columns1.value;
|
columns.value = columns1.value;
|
||||||
loadData();
|
loadData();
|
||||||
getGoodTypeList();
|
|
||||||
|
|
||||||
calculateTableHeight();
|
calculateTableHeight();
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
<el-radio value="2" size="large">多规格</el-radio>
|
<el-radio value="2" size="large">多规格</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<div v-if="formInline.specStyle == 1">
|
<div v-if="formInline.specStyle == '1'">
|
||||||
<!-- 销售价格 -->
|
<!-- 销售价格 -->
|
||||||
<el-form-item label="销售价格" prop="salePrice" required>
|
<el-form-item label="销售价格" prop="salePrice" required>
|
||||||
<el-input-number v-model="formInline.salePrice" :min="1" :precision="2" :controls="false"></el-input-number>
|
<el-input-number v-model="formInline.salePrice" :min="1" :precision="2" :controls="false"></el-input-number>
|
||||||
@ -108,6 +108,7 @@
|
|||||||
<el-select v-model="item.unit" style="width: 80px; margin-left: 10px">
|
<el-select v-model="item.unit" style="width: 80px; margin-left: 10px">
|
||||||
<el-option label="kg" value="kg" />
|
<el-option label="kg" value="kg" />
|
||||||
<el-option label="g" value="g" />
|
<el-option label="g" value="g" />
|
||||||
|
<el-option label="ml" value="L" />
|
||||||
<el-option label="ml" value="ml" />
|
<el-option label="ml" value="ml" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</div>
|
</div>
|
||||||
@ -144,9 +145,9 @@
|
|||||||
<el-form-item label="发货地址" required>
|
<el-form-item label="发货地址" required>
|
||||||
<div style="display: flex; gap: 16px;">
|
<div style="display: flex; gap: 16px;">
|
||||||
<el-form-item prop="selectedAddress">
|
<el-form-item prop="selectedAddress">
|
||||||
<!-- 省市区级联选择器 -->
|
<!-- 区域级联选择器 -->
|
||||||
<el-cascader v-model="formInline.selectedAddress" :options="addressOptions" :props="cascaderProps"
|
<el-cascader v-model="formInline.selectedAddress" :options="addressOptions" :props="cascaderProps"
|
||||||
placeholder="请选择省市区" clearable />
|
placeholder="请选择区域" clearable style="width: 300px;"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item prop="detailAddress">
|
<el-form-item prop="detailAddress">
|
||||||
<!-- 详细地址输入框 -->
|
<!-- 详细地址输入框 -->
|
||||||
@ -238,7 +239,7 @@ const formInline = reactive({
|
|||||||
value: '', //内容
|
value: '', //内容
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
selectedAddress: [], //选中的省市区编码数组
|
selectedAddress: [], //选中的区域编码数组
|
||||||
areaAddress: '', //区域地址
|
areaAddress: '', //区域地址
|
||||||
detailAddress: "", //详细地址
|
detailAddress: "", //详细地址
|
||||||
sendAddress: "",
|
sendAddress: "",
|
||||||
@ -311,7 +312,7 @@ const rules = reactive({
|
|||||||
specStyle: [
|
specStyle: [
|
||||||
{ required: true, message: '请选择规格样式', trigger: 'change' }
|
{ required: true, message: '请选择规格样式', trigger: 'change' }
|
||||||
],
|
],
|
||||||
salePrice: formInline.specStyle === '1' ? [
|
salePrice: formInline.specStyle == '1' ? [
|
||||||
{
|
{
|
||||||
validator: (rule, value, callback) => {
|
validator: (rule, value, callback) => {
|
||||||
if (!value || Number(value) <= 0) {
|
if (!value || Number(value) <= 0) {
|
||||||
@ -323,7 +324,7 @@ const rules = reactive({
|
|||||||
trigger: ['blur', 'change']
|
trigger: ['blur', 'change']
|
||||||
},
|
},
|
||||||
] : [],
|
] : [],
|
||||||
stock: formInline.specStyle === '1' ? [
|
stock: formInline.specStyle == '1' ? [
|
||||||
{
|
{
|
||||||
validator: (rule, value, callback) => {
|
validator: (rule, value, callback) => {
|
||||||
if (!value || Number(value) <= 0) {
|
if (!value || Number(value) <= 0) {
|
||||||
@ -335,7 +336,7 @@ const rules = reactive({
|
|||||||
trigger: ['blur', 'change']
|
trigger: ['blur', 'change']
|
||||||
},
|
},
|
||||||
] : [],
|
] : [],
|
||||||
netContent: formInline.specStyle === '1' ? [
|
netContent: formInline.specStyle == '1' ? [
|
||||||
{
|
{
|
||||||
validator: (rule, value, callback) => {
|
validator: (rule, value, callback) => {
|
||||||
if (!value || Number(value) <= 0) {
|
if (!value || Number(value) <= 0) {
|
||||||
@ -347,7 +348,7 @@ const rules = reactive({
|
|||||||
trigger: ['blur', 'change']
|
trigger: ['blur', 'change']
|
||||||
},
|
},
|
||||||
] : [],
|
] : [],
|
||||||
netWeight: formInline.specStyle === '2' ? [
|
netWeight: [
|
||||||
{
|
{
|
||||||
validator: (rule, value, callback) => {
|
validator: (rule, value, callback) => {
|
||||||
// 检查是否至少有一个属性
|
// 检查是否至少有一个属性
|
||||||
@ -365,7 +366,7 @@ const rules = reactive({
|
|||||||
},
|
},
|
||||||
trigger: 'blur'
|
trigger: 'blur'
|
||||||
}
|
}
|
||||||
] : [],
|
],
|
||||||
attribute: [
|
attribute: [
|
||||||
{
|
{
|
||||||
validator: (rule, value, callback) => {
|
validator: (rule, value, callback) => {
|
||||||
@ -390,7 +391,7 @@ const rules = reactive({
|
|||||||
required: true,
|
required: true,
|
||||||
validator: (rule, value, callback) => {
|
validator: (rule, value, callback) => {
|
||||||
if (!value || value.length !== 3) {
|
if (!value || value.length !== 3) {
|
||||||
callback(new Error('请选择完整的省市区'));
|
callback(new Error('请选择完整的区域'));
|
||||||
} else {
|
} else {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
@ -404,7 +405,6 @@ const rules = reactive({
|
|||||||
safeguard: [
|
safeguard: [
|
||||||
{
|
{
|
||||||
validator: (rule, value, callback) => {
|
validator: (rule, value, callback) => {
|
||||||
console.log(value);
|
|
||||||
if (value.isSelected !== 1) { // 如果值不是 1(未选中)
|
if (value.isSelected !== 1) { // 如果值不是 1(未选中)
|
||||||
callback(new Error('必须选择保障服务')); // 报错
|
callback(new Error('必须选择保障服务')); // 报错
|
||||||
} else {
|
} else {
|
||||||
@ -476,42 +476,6 @@ const isDiscountRebate = computed({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 文件上传前的校验
|
|
||||||
// const beforeUpload = (file) => {
|
|
||||||
// const isImage = ['image/jpeg', 'image/png', 'image/gif'].includes(file.type)
|
|
||||||
// const isLt2M = file.size / 1024 / 1024 < 2
|
|
||||||
|
|
||||||
// if (!isImage) {
|
|
||||||
// ElMessage.error('只能上传JPG/PNG/GIF格式的图片!')
|
|
||||||
// return false
|
|
||||||
// }
|
|
||||||
// if (!isLt2M) {
|
|
||||||
// ElMessage.error('图片大小不能超过2MB!')
|
|
||||||
// return false
|
|
||||||
// }
|
|
||||||
// return true
|
|
||||||
// }
|
|
||||||
// 文件变化时触发验证
|
|
||||||
// const handleChange = () => {
|
|
||||||
// console.log('文件变化时触发验证')
|
|
||||||
// nextTick(() => {
|
|
||||||
// console.log(formInline.images)
|
|
||||||
// formRef.value.validateField('images')
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
// 移除文件时触发验证
|
|
||||||
// const handleRemove = (file) => {
|
|
||||||
// console.log('移除文件时触发验证')
|
|
||||||
// console.log(file)
|
|
||||||
// console.log(formInline.images)
|
|
||||||
// formInline.images = formInline.images.filter(item => item.uid !== file.uid)
|
|
||||||
// formRef.value.validateField('images')
|
|
||||||
// }
|
|
||||||
// 超出限制提示
|
|
||||||
// const handleExceed = () => {
|
|
||||||
// ElMessage.warning('最多只能上传5张图片!')
|
|
||||||
// }
|
|
||||||
|
|
||||||
const categoryList1 = ref([]);
|
const categoryList1 = ref([]);
|
||||||
const categoryList2 = ref([]);
|
const categoryList2 = ref([]);
|
||||||
const categoryList3 = ref([]);
|
const categoryList3 = ref([]);
|
||||||
@ -519,16 +483,14 @@ const categoryList3 = ref([]);
|
|||||||
const getGoodTypeList = async () => {
|
const getGoodTypeList = async () => {
|
||||||
try {
|
try {
|
||||||
let response = await getGoodType();
|
let response = await getGoodType();
|
||||||
console.log(response);
|
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
categoryList1.value = response.data;
|
categoryList1.value = response.data;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const changeCategory1 = (id) => {
|
const changeCategory1 = (id) => {
|
||||||
console.log(id);
|
|
||||||
formInline.categoryId1 = id;
|
formInline.categoryId1 = id;
|
||||||
formInline.categoryId2 = "";
|
formInline.categoryId2 = "";
|
||||||
categoryList2.value = categoryList1.value.filter((item) => item.id == id)[0].children;
|
categoryList2.value = categoryList1.value.filter((item) => item.id == id)[0].children;
|
||||||
@ -544,23 +506,19 @@ const changeCategory1 = (id) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const changeCategory2 = (id) => {
|
const changeCategory2 = (id) => {
|
||||||
console.log(id);
|
|
||||||
formInline.categoryId2 = id;
|
formInline.categoryId2 = id;
|
||||||
categoryList3.value = categoryList2.value.filter((item) => item.id == id)[0].children;
|
categoryList3.value = categoryList2.value.filter((item) => item.id == id)[0].children;
|
||||||
formInline.categoryId3 = "";
|
formInline.categoryId3 = "";
|
||||||
formInline.categoryId = "";
|
formInline.categoryId = "";
|
||||||
};
|
};
|
||||||
const changeCategory3 = (id) => {
|
const changeCategory3 = (id) => {
|
||||||
console.log(id);
|
|
||||||
formInline.categoryId3 = id;
|
formInline.categoryId3 = id;
|
||||||
formInline.categoryId = id;
|
formInline.categoryId = id;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
console.log(formInline);
|
|
||||||
try {
|
try {
|
||||||
await formRef.value.validate()
|
await formRef.value.validate()
|
||||||
console.log('验证通过!', formRef.value)
|
|
||||||
// 整理提交的参数
|
// 整理提交的参数
|
||||||
let params = { ...formInline };
|
let params = { ...formInline };
|
||||||
if (formInline.specStyle == '1') {
|
if (formInline.specStyle == '1') {
|
||||||
@ -601,7 +559,6 @@ const onGoodSave = async (params) => {
|
|||||||
|
|
||||||
const getArea = async () => {
|
const getArea = async () => {
|
||||||
const res = await getRegion();
|
const res = await getRegion();
|
||||||
console.log(res);
|
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
addressOptions.value = res.data.list;
|
addressOptions.value = res.data.list;
|
||||||
} else {
|
} else {
|
||||||
@ -612,7 +569,6 @@ const activeInfoList = ref([]);
|
|||||||
// 获取商品优惠信息配置项
|
// 获取商品优惠信息配置项
|
||||||
const getActiveInfo = async () => {
|
const getActiveInfo = async () => {
|
||||||
const res = await getActiveInfos();
|
const res = await getActiveInfos();
|
||||||
console.log(res);
|
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
activeInfoList.value = res.data;
|
activeInfoList.value = res.data;
|
||||||
formInline.safeguard.options = [...activeInfoList.value.safeguard.options];
|
formInline.safeguard.options = [...activeInfoList.value.safeguard.options];
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
<el-radio value="2" size="large">多规格</el-radio>
|
<el-radio value="2" size="large">多规格</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<div v-if="formInline.specStyle == 1">
|
<div v-if="formInline.specStyle == '1'">
|
||||||
<!-- 销售价格 -->
|
<!-- 销售价格 -->
|
||||||
<el-form-item label="销售价格" prop="salePrice" required>
|
<el-form-item label="销售价格" prop="salePrice" required>
|
||||||
<el-input-number v-model="formInline.salePrice" :min="1" :precision="2" :controls="false"></el-input-number>
|
<el-input-number v-model="formInline.salePrice" :min="1" :precision="2" :controls="false"></el-input-number>
|
||||||
@ -108,6 +108,7 @@
|
|||||||
<el-select v-model="item.unit" style="width: 80px; margin-left: 10px">
|
<el-select v-model="item.unit" style="width: 80px; margin-left: 10px">
|
||||||
<el-option label="kg" value="kg" />
|
<el-option label="kg" value="kg" />
|
||||||
<el-option label="g" value="g" />
|
<el-option label="g" value="g" />
|
||||||
|
<el-option label="ml" value="L" />
|
||||||
<el-option label="ml" value="ml" />
|
<el-option label="ml" value="ml" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</div>
|
</div>
|
||||||
@ -144,9 +145,9 @@
|
|||||||
<el-form-item label="发货地址" required>
|
<el-form-item label="发货地址" required>
|
||||||
<div style="display: flex; gap: 16px;">
|
<div style="display: flex; gap: 16px;">
|
||||||
<el-form-item prop="selectedAddress">
|
<el-form-item prop="selectedAddress">
|
||||||
<!-- 省市区级联选择器 -->
|
<!-- 区域级联选择器 -->
|
||||||
<el-cascader v-model="formInline.selectedAddress" :options="addressOptions" :props="cascaderProps"
|
<el-cascader v-model="formInline.selectedAddress" :options="addressOptions" :props="cascaderProps"
|
||||||
placeholder="请选择省市区" clearable />
|
placeholder="请选择区域" clearable style="width: 300px;"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item prop="detailAddress">
|
<el-form-item prop="detailAddress">
|
||||||
<!-- 详细地址输入框 -->
|
<!-- 详细地址输入框 -->
|
||||||
@ -243,7 +244,7 @@ const formInline = reactive({
|
|||||||
value: '', //内容
|
value: '', //内容
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
selectedAddress: [], //选中的省市区编码数组
|
selectedAddress: [], //选中的区域编码数组
|
||||||
areaAddress: '', //区域地址
|
areaAddress: '', //区域地址
|
||||||
detailAddress: "", //详细地址
|
detailAddress: "", //详细地址
|
||||||
sendAddress: "",
|
sendAddress: "",
|
||||||
@ -316,7 +317,7 @@ const rules = reactive({
|
|||||||
specStyle: [
|
specStyle: [
|
||||||
{ required: true, message: '请选择规格样式', trigger: 'change' }
|
{ required: true, message: '请选择规格样式', trigger: 'change' }
|
||||||
],
|
],
|
||||||
salePrice: formInline.specStyle === '1' ? [
|
salePrice: formInline.specStyle == '1' ? [
|
||||||
{
|
{
|
||||||
validator: (rule, value, callback) => {
|
validator: (rule, value, callback) => {
|
||||||
if (!value || Number(value) <= 0) {
|
if (!value || Number(value) <= 0) {
|
||||||
@ -328,7 +329,7 @@ const rules = reactive({
|
|||||||
trigger: ['blur', 'change']
|
trigger: ['blur', 'change']
|
||||||
},
|
},
|
||||||
] : [],
|
] : [],
|
||||||
stock: formInline.specStyle === '1' ? [
|
stock: formInline.specStyle == '1' ? [
|
||||||
{
|
{
|
||||||
validator: (rule, value, callback) => {
|
validator: (rule, value, callback) => {
|
||||||
if (!value || Number(value) <= 0) {
|
if (!value || Number(value) <= 0) {
|
||||||
@ -340,7 +341,7 @@ const rules = reactive({
|
|||||||
trigger: ['blur', 'change']
|
trigger: ['blur', 'change']
|
||||||
},
|
},
|
||||||
] : [],
|
] : [],
|
||||||
netContent: formInline.specStyle === '1' ? [
|
netContent: formInline.specStyle == '1' ? [
|
||||||
{
|
{
|
||||||
validator: (rule, value, callback) => {
|
validator: (rule, value, callback) => {
|
||||||
if (!value || Number(value) <= 0) {
|
if (!value || Number(value) <= 0) {
|
||||||
@ -352,7 +353,7 @@ const rules = reactive({
|
|||||||
trigger: ['blur', 'change']
|
trigger: ['blur', 'change']
|
||||||
},
|
},
|
||||||
] : [],
|
] : [],
|
||||||
netWeight: formInline.specStyle === '2' ? [
|
netWeight: [
|
||||||
{
|
{
|
||||||
validator: (rule, value, callback) => {
|
validator: (rule, value, callback) => {
|
||||||
// 检查是否至少有一个属性
|
// 检查是否至少有一个属性
|
||||||
@ -370,7 +371,7 @@ const rules = reactive({
|
|||||||
},
|
},
|
||||||
trigger: 'blur'
|
trigger: 'blur'
|
||||||
}
|
}
|
||||||
] : [],
|
],
|
||||||
attribute: [
|
attribute: [
|
||||||
{
|
{
|
||||||
validator: (rule, value, callback) => {
|
validator: (rule, value, callback) => {
|
||||||
@ -395,7 +396,7 @@ const rules = reactive({
|
|||||||
required: true,
|
required: true,
|
||||||
validator: (rule, value, callback) => {
|
validator: (rule, value, callback) => {
|
||||||
if (!value || value.length !== 3) {
|
if (!value || value.length !== 3) {
|
||||||
callback(new Error('请选择完整的省市区'));
|
callback(new Error('请选择完整的区域'));
|
||||||
} else {
|
} else {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
@ -430,7 +431,7 @@ const deleteAttr = (index) => {
|
|||||||
formInline.attribute.splice(index, 1)
|
formInline.attribute.splice(index, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 选中的省市区编码数组(如:['云南省', '昆明市', '呈贡区'])
|
// 选中的区域编码数组(如:['云南省', '昆明市', '呈贡区'])
|
||||||
const selectedAddress = ref([]);
|
const selectedAddress = ref([]);
|
||||||
const detailAddress = ref('');
|
const detailAddress = ref('');
|
||||||
// 级联选择器配置
|
// 级联选择器配置
|
||||||
@ -441,7 +442,7 @@ const cascaderProps = ref({
|
|||||||
emitPath: true,
|
emitPath: true,
|
||||||
expandTrigger: 'hover',
|
expandTrigger: 'hover',
|
||||||
});
|
});
|
||||||
// 省市区数据(示例)
|
// 区域数据(示例)
|
||||||
const addressOptions = ref([]);
|
const addressOptions = ref([]);
|
||||||
addressOptions.value = areaList.data;
|
addressOptions.value = areaList.data;
|
||||||
|
|
||||||
@ -467,42 +468,6 @@ const isDiscountRebate = computed({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 文件上传前的校验
|
|
||||||
// const beforeUpload = (file) => {
|
|
||||||
// const isImage = ['image/jpeg', 'image/png', 'image/gif'].includes(file.type)
|
|
||||||
// const isLt2M = file.size / 1024 / 1024 < 2
|
|
||||||
|
|
||||||
// if (!isImage) {
|
|
||||||
// ElMessage.error('只能上传JPG/PNG/GIF格式的图片!')
|
|
||||||
// return false
|
|
||||||
// }
|
|
||||||
// if (!isLt2M) {
|
|
||||||
// ElMessage.error('图片大小不能超过2MB!')
|
|
||||||
// return false
|
|
||||||
// }
|
|
||||||
// return true
|
|
||||||
// }
|
|
||||||
// 文件变化时触发验证
|
|
||||||
// const handleChange = () => {
|
|
||||||
// console.log('文件变化时触发验证')
|
|
||||||
// nextTick(() => {
|
|
||||||
// console.log(formInline.images)
|
|
||||||
// formRef.value.validateField('images')
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
// 移除文件时触发验证
|
|
||||||
// const handleRemove = (file) => {
|
|
||||||
// console.log('移除文件时触发验证')
|
|
||||||
// console.log(file)
|
|
||||||
// console.log(formInline.images)
|
|
||||||
// formInline.images = formInline.images.filter(item => item.uid !== file.uid)
|
|
||||||
// formRef.value.validateField('images')
|
|
||||||
// }
|
|
||||||
// 超出限制提示
|
|
||||||
// const handleExceed = () => {
|
|
||||||
// ElMessage.warning('最多只能上传5张图片!')
|
|
||||||
// }
|
|
||||||
|
|
||||||
const categoryList1 = ref([]);
|
const categoryList1 = ref([]);
|
||||||
const categoryList2 = ref([]);
|
const categoryList2 = ref([]);
|
||||||
const categoryList3 = ref([]);
|
const categoryList3 = ref([]);
|
||||||
@ -510,16 +475,14 @@ const categoryList3 = ref([]);
|
|||||||
const getGoodTypeList = async () => {
|
const getGoodTypeList = async () => {
|
||||||
try {
|
try {
|
||||||
let response = await getGoodType();
|
let response = await getGoodType();
|
||||||
console.log(response);
|
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
categoryList1.value = response.data;
|
categoryList1.value = response.data;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const changeCategory1 = (id) => {
|
const changeCategory1 = (id) => {
|
||||||
console.log(id);
|
|
||||||
formInline.categoryId1 = id;
|
formInline.categoryId1 = id;
|
||||||
formInline.categoryId2 = "";
|
formInline.categoryId2 = "";
|
||||||
categoryList2.value = categoryList1.value.filter((item) => item.id == id)[0].children;
|
categoryList2.value = categoryList1.value.filter((item) => item.id == id)[0].children;
|
||||||
@ -535,23 +498,19 @@ const changeCategory1 = (id) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const changeCategory2 = (id) => {
|
const changeCategory2 = (id) => {
|
||||||
console.log(id);
|
|
||||||
formInline.categoryId2 = id;
|
formInline.categoryId2 = id;
|
||||||
categoryList3.value = categoryList2.value.filter((item) => item.id == id)[0].children;
|
categoryList3.value = categoryList2.value.filter((item) => item.id == id)[0].children;
|
||||||
formInline.categoryId3 = "";
|
formInline.categoryId3 = "";
|
||||||
formInline.categoryId = "";
|
formInline.categoryId = "";
|
||||||
};
|
};
|
||||||
const changeCategory3 = (id) => {
|
const changeCategory3 = (id) => {
|
||||||
console.log(id);
|
|
||||||
formInline.categoryId3 = id;
|
formInline.categoryId3 = id;
|
||||||
formInline.categoryId = id;
|
formInline.categoryId = id;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
console.log(formInline);
|
|
||||||
try {
|
try {
|
||||||
await formRef.value.validate()
|
await formRef.value.validate()
|
||||||
console.log('验证通过!', formRef.value)
|
|
||||||
// 整理提交的参数
|
// 整理提交的参数
|
||||||
let params = { ...formInline };
|
let params = { ...formInline };
|
||||||
if (formInline.specStyle == '1') {
|
if (formInline.specStyle == '1') {
|
||||||
@ -616,7 +575,6 @@ const getGoodsInfo = async (goodId) => {
|
|||||||
formInline.specStyle = '2';
|
formInline.specStyle = '2';
|
||||||
} else {
|
} else {
|
||||||
formInline.specStyle = '1';
|
formInline.specStyle = '1';
|
||||||
console.log(res.data.netWeight[0]);
|
|
||||||
formInline.salePrice = formData.value.netWeight[0]?.goodPrice ?? 1;
|
formInline.salePrice = formData.value.netWeight[0]?.goodPrice ?? 1;
|
||||||
formInline.stock = formData.value.netWeight[0]?.goodStock ?? 1;
|
formInline.stock = formData.value.netWeight[0]?.goodStock ?? 1;
|
||||||
formInline.netContent = formData.value.netWeight[0]?.netContent ?? 1;
|
formInline.netContent = formData.value.netWeight[0]?.netContent ?? 1;
|
||||||
@ -657,22 +615,18 @@ const getGoodsInfo = async (goodId) => {
|
|||||||
categoryList3.value = item[0].children;
|
categoryList3.value = item[0].children;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log(formInline);
|
|
||||||
} else {
|
} else {
|
||||||
ElMessage.error(res.msg);
|
ElMessage.error(res.msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(() => route.query, (newVal) => {
|
watch(() => route.query, (newVal) => {
|
||||||
console.log("watch商品id:", newVal.goodId);
|
|
||||||
if (newVal.goodId) {
|
if (newVal.goodId) {
|
||||||
getGoodsInfo(newVal.goodId);
|
getGoodsInfo(newVal.goodId);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const { edit, goodId } = route.query;
|
const { edit, goodId } = route.query;
|
||||||
console.log("onMounted商品id:", goodId);
|
|
||||||
getActiveInfo();
|
getActiveInfo();
|
||||||
await getGoodTypeList();
|
await getGoodTypeList();
|
||||||
getArea();
|
getArea();
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
v-model="formInline.goodCategoryId"
|
v-model="formInline.goodCategoryId"
|
||||||
:options="goodsOptions"
|
:options="goodsOptions"
|
||||||
:props="cascaderProps"
|
:props="cascaderProps"
|
||||||
placeholder="请选择省市区"
|
placeholder="请选择商品分类"
|
||||||
clearable
|
clearable
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -207,9 +207,7 @@ const goodsBrandList = ref([
|
|||||||
|
|
||||||
const searchForm = ref(null);
|
const searchForm = ref(null);
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
console.log("submit!");
|
|
||||||
formInline.current = 1;
|
formInline.current = 1;
|
||||||
console.log(formInline);
|
|
||||||
loadData();
|
loadData();
|
||||||
};
|
};
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
@ -223,7 +221,6 @@ let bottomList = reactive([
|
|||||||
{ title: "已下架", id: "3", value: "" },
|
{ title: "已下架", id: "3", value: "" },
|
||||||
]);
|
]);
|
||||||
const tabChange = (Event) => {
|
const tabChange = (Event) => {
|
||||||
console.log(Event.index);
|
|
||||||
if (Event.index == "0") {
|
if (Event.index == "0") {
|
||||||
// 请求全部
|
// 请求全部
|
||||||
formInline.type = "1";
|
formInline.type = "1";
|
||||||
@ -317,7 +314,6 @@ const loadData = async () => {
|
|||||||
// 测试
|
// 测试
|
||||||
// tableData.value = generateMockData();
|
// tableData.value = generateMockData();
|
||||||
// tableTotal.value = tableData.value.length;
|
// tableTotal.value = tableData.value.length;
|
||||||
// console.log(tableData.value);
|
|
||||||
|
|
||||||
let prams = { ...formInline };
|
let prams = { ...formInline };
|
||||||
prams.goodCategoryId =
|
prams.goodCategoryId =
|
||||||
@ -325,13 +321,12 @@ const loadData = async () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
let response = await getGoodManageInfo(prams);
|
let response = await getGoodManageInfo(prams);
|
||||||
console.log(response);
|
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
tableData.value = response.data.records;
|
tableData.value = response.data.records;
|
||||||
tableTotal.value = response.data.total;
|
tableTotal.value = response.data.total;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
|
||||||
}
|
}
|
||||||
tableLoading.value = false;
|
tableLoading.value = false;
|
||||||
};
|
};
|
||||||
@ -342,7 +337,6 @@ const getHeaderClass = ({ column }) => {
|
|||||||
};
|
};
|
||||||
// 分页变化
|
// 分页变化
|
||||||
const handlePaginationChange = ({ page, pageSize }) => {
|
const handlePaginationChange = ({ page, pageSize }) => {
|
||||||
console.log("分页变化:", page, pageSize);
|
|
||||||
formInline.current = page;
|
formInline.current = page;
|
||||||
formInline.size = pageSize;
|
formInline.size = pageSize;
|
||||||
// 这里可以调用API获取新数据
|
// 这里可以调用API获取新数据
|
||||||
@ -358,13 +352,16 @@ const handleSelectionChange = (selection, ids) => {
|
|||||||
const seeDetails = (row) => {
|
const seeDetails = (row) => {
|
||||||
nowClickRow.value = row;
|
nowClickRow.value = row;
|
||||||
console.log("要查看详情的行:", row);
|
console.log("要查看详情的行:", row);
|
||||||
|
// router.push({
|
||||||
|
// path: "/goods/goodsManage/editGoods",
|
||||||
|
// query: { goodId: row.goodId },
|
||||||
|
// meta: { title: '商品详情'}
|
||||||
|
// });
|
||||||
};
|
};
|
||||||
const toUpload = async (row) => {
|
const toUpload = async (row) => {
|
||||||
console.log("上架:", row);
|
|
||||||
goodsUpAndDown(row.goodId, 2);
|
goodsUpAndDown(row.goodId, 2);
|
||||||
};
|
};
|
||||||
const toDownload = (row) => {
|
const toDownload = (row) => {
|
||||||
console.log("下架:", row);
|
|
||||||
goodsUpAndDown(row.goodId, 3);
|
goodsUpAndDown(row.goodId, 3);
|
||||||
};
|
};
|
||||||
const goodsUpAndDown = async (id, isListed) => {
|
const goodsUpAndDown = async (id, isListed) => {
|
||||||
@ -381,11 +378,10 @@ const goodsUpAndDown = async (id, isListed) => {
|
|||||||
// 编辑操作
|
// 编辑操作
|
||||||
const handleEdit = (row) => {
|
const handleEdit = (row) => {
|
||||||
nowClickRow.value = row;
|
nowClickRow.value = row;
|
||||||
console.log("要编辑的行:", row);
|
|
||||||
// 跳转路由并携带参数,行数据,和query的值edit
|
// 跳转路由并携带参数,行数据,和query的值edit
|
||||||
router.push({
|
router.push({
|
||||||
path: "/goods/goodsManage/editGoods",
|
path: "/goods/goodsManage/editGoods",
|
||||||
query: { goodId: row.goodId },
|
query: { goodId: row.goodId, edit: true },
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
// 删除操作
|
// 删除操作
|
||||||
@ -394,7 +390,6 @@ const handleDelete = async (row) => {
|
|||||||
};
|
};
|
||||||
// 批量删除
|
// 批量删除
|
||||||
const batchDelete = async () => {
|
const batchDelete = async () => {
|
||||||
console.log("要删除的行:", selectedIds.value);
|
|
||||||
deleteGoods(selectedIds.value.join(","))
|
deleteGoods(selectedIds.value.join(","))
|
||||||
};
|
};
|
||||||
const deleteGoods = async (param) => {
|
const deleteGoods = async (param) => {
|
||||||
@ -425,12 +420,11 @@ const goodsOptions = ref([]);
|
|||||||
const getGoodTypeList = async () => {
|
const getGoodTypeList = async () => {
|
||||||
try {
|
try {
|
||||||
let response = await getGoodType();
|
let response = await getGoodType();
|
||||||
console.log(response);
|
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
goodsOptions.value = response.data;
|
goodsOptions.value = response.data;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -443,7 +437,7 @@ const getGoodsManageCount = async () => {
|
|||||||
bottomList[2].value = `(${response.data?.removedCount ?? ""})`;
|
bottomList[2].value = `(${response.data?.removedCount ?? ""})`;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -465,7 +459,6 @@ const calculateTableHeight = () => {
|
|||||||
// 最终计算
|
// 最终计算
|
||||||
tableViewportHeight.value =
|
tableViewportHeight.value =
|
||||||
windowHeight - headerHeight - searchBarHeight - paddingCompensation;
|
windowHeight - headerHeight - searchBarHeight - paddingCompensation;
|
||||||
// console.log(tableViewportHeight.value);
|
|
||||||
};
|
};
|
||||||
// 组件挂载时加载数据
|
// 组件挂载时加载数据
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
@ -103,7 +103,7 @@ const { proxy } = getCurrentInstance();
|
|||||||
const showType = ref(2);
|
const showType = ref(2);
|
||||||
|
|
||||||
const loginForm = ref({
|
const loginForm = ref({
|
||||||
username: "super",
|
username: "admin",
|
||||||
password: "admin123",
|
password: "admin123",
|
||||||
rememberMe: false,
|
rememberMe: false,
|
||||||
code: "",
|
code: "",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user