商品上架审核设置模块开发

This commit is contained in:
Xulinchuan 2025-06-10 13:44:45 +08:00
parent f70341a24a
commit c7ecaa82fc
10 changed files with 2603 additions and 39 deletions

View File

@ -5,5 +5,5 @@ VITE_APP_TITLE = 运营云后台管理系统
VITE_APP_ENV = 'development'
# 开发环境
VITE_APP_BASE_API = 'http://192.168.18.151:8080'
VITE_APP_BASE_API = 'http://192.168.18.99:8080/'
VITE_APP_PLATFORM = 'http://localhost:9000/platform'

View File

@ -155,3 +155,11 @@ export function deleteContraband(id) {
method: "delete",
});
}
//商品审核
export function goodaudit(data) {
return request({
url: '/goods/goodInfoManage/goodExamine',
method: 'put',
data: data
})
}

View File

@ -46,10 +46,6 @@
width: 100px;
text-align: right;
padding-right: 8px;
.el-button-gry{
background-color: #25bf82;
border:none
}
}
.demo-form-inline {
@ -307,3 +303,8 @@
justify-content: flex-start;
align-items: flex-start;
}
.el-button-gry{
background-color: #25bf82;
border:none
}

View File

@ -92,6 +92,12 @@ export const constantRoutes = [
component: () => import('@/views/goods/goodsManage/editGoods'),
name: 'editGoods',
meta: { title: '编辑商品', icon: '' }
},
{
path: '/goods/goodsReview/auditGoods/:activeTab?',
component: () => import('@/views/goods/goodsReview/auditGoods'),
name: 'auditGoods',
meta: { title: '审核商品', icon: '' }
}
]
},
@ -198,7 +204,19 @@ export const constantRoutes = [
noCache: false,
link: null,
},
}
},
{
path: 'goods/goodsReview',
component: () => import('@/views/goods/goodsReview/index'),
name: 'goodsReview',
hidden: false,
meta: {
title: "上架审核设置",
icon: "",
noCache: false,
link: null,
},
},
],
},
{

View File

@ -64,7 +64,7 @@
</el-form>
</div>
<div class="search-bar-right">
<el-button type="primary" icon="Search" @click="onSubmit"
<el-button class="el-button-gry" type="primary" icon="Search" @click="onSubmit"
>查询</el-button
>
<el-button
@ -100,34 +100,9 @@
<!-- 自定义-操作 -->
<template #action="slotProps">
<el-tooltip effect="dark" placement="bottom-end">
<template #content>
<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="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>
<el-button text 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>
</tableComponent>
</div>
@ -201,7 +176,7 @@ const columns = ref([
{ prop: "userCategory", label: "用户分类" },
{ prop: "unitPrice", label: "客单价" },
{ prop: "ordersNums", label: "订单数目" },
{ prop: "action", label: "操作", slotName: "action" },
{ prop: "action", label: "操作", slotName: "action",width: "140",align: "center" },
]);
//

View File

@ -85,9 +85,9 @@
<!-- 自定义-操作 -->
<template #action="slotProps">
<el-button text class="el-button-custom" :dark="isDark" @click="seeDetails(slotProps.row)">查看</el-button>
<el-button text class="el-button-custom" :dark="isDark" @click="handleEdit(slotProps.row)">编辑</el-button>
<el-button text class="el-button-delete" :dark="isDark" @click="handleDelete(slotProps.row)">删除</el-button>
<el-button text 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>
</tableComponent>
</div>

View File

@ -0,0 +1,632 @@
<template>
<div class="app-container customer-control">
<div class="customer-box">
<el-form ref="formRef" :model="formInline" :rules="rules" class="demo-form-inline" :label-width="'auto'">
<!-- 商品名称 -->
<el-form-item label="商品名称" prop="goodName">
<el-input v-model="formInline.goodName" clearable show-word-limit maxlength="30" placeholder="请输入商品名称"
style="width: 800px" />
</el-form-item>
<!-- 商品分类 -->
<el-form-item label="商品分类" required>
<div style="display: flex; gap: 16px;">
<el-form-item prop="categoryId1">
<el-select v-model="formInline.categoryId1" placeholder="请选择" class="my-el-select"
@change="changeCategory1($event)">
<el-option v-for="item in categoryList1" :key="item.id" :value="item.id" :label="item.name" />
</el-select>
</el-form-item>
<el-form-item prop="categoryId2">
<el-select v-model="formInline.categoryId2" placeholder="请选择" class="my-el-select"
@change="changeCategory2($event)">
<el-option v-for="item in categoryList2" :key="item.id" :value="item.id" :label="item.name" />
</el-select>
</el-form-item>
<el-form-item prop="categoryId3">
<el-select v-model="formInline.categoryId3" placeholder="请选择" class="my-el-select"
@change="changeCategory3($event)">
<el-option v-for="item in categoryList3" :key="item.id" :value="item.id" :label="item.name" />
</el-select>
</el-form-item>
</div>
</el-form-item>
<!-- 公共品牌 -->
<el-form-item label="公共品牌" prop="brandId" v-show="formInline.goodCategorySelectType == 1">
<el-input v-model="formInline.brandId" clearable placeholder="请输入公共品牌" style="width: 800px" />
</el-form-item>
<!-- 溯源编码 -->
<el-form-item label="溯源编码" prop="traceCode" v-show="formInline.goodCategorySelectType == 1">
<el-input v-model="formInline.traceCode" clearable placeholder="请输入溯源编码" style="width: 800px" />
</el-form-item>
<!-- 商品图片 -->
<el-form-item label="商品图片" prop="goodUrl" required>
<div>
<myUploadImage v-model="formInline.goodUrl"></myUploadImage>
</div>
</el-form-item>
<!-- 规格样式 -->
<el-form-item label="规格样式" prop="specStyle" required>
<el-radio-group v-model="formInline.specStyle" style="margin-top: -3px;">
<el-radio value="1" size="large">单规格</el-radio>
<el-radio value="2" size="large">多规格</el-radio>
</el-radio-group>
</el-form-item>
<div v-if="formInline.specStyle == 1">
<!-- 销售价格 -->
<el-form-item label="销售价格" prop="salePrice" required>
<el-input-number v-model="formInline.salePrice" :min="1" :precision="2" :controls="false"></el-input-number>
<span style="padding: 0 10px;"></span>
</el-form-item>
<!-- 库存数量 -->
<el-form-item label="库存数量" prop="stock" required>
<el-input-number v-model="formInline.stock" :min="1" :controls="false" />
</el-form-item>
<!-- 净含量 -->
<el-form-item label="净含量" prop="netContent" required>
<el-input-number v-model="formInline.netContent" :min="1" :controls="false" />
<el-select v-model="formInline.unit" style="width: 80px; margin-left: 10px">
<el-option label="kg" value="kg" />
<el-option label="g" value="g" />
<el-option label="ml" value="ml" />
</el-select>
</el-form-item>
</div>
<!-- 多规格 -->
<div v-else>
<el-form-item label="商品规格" prop="netWeight" required>
<div v-for="(item, index) in formInline.netWeight" :key="index" class="attr-item">
<el-input v-model="item.goodSpecs" :value="item.goodSpecs" class="attr-clomn" placeholder="请输入规格名称" />
<el-icon size="20px" v-if="index !== 0" @click="deleteSpecs(index)" style="cursor: pointer;">
<Delete />
</el-icon>
</div>
<el-button icon="plus" type="primary" plain style="margin: 0" @click="addSpecs">添加属性</el-button>
</el-form-item>
<!-- 价格库存 -->
<el-form-item label="价格库存" prop="netWeight" required>
<div class="attr-box">
<div class="attr-row">
<div class="attr-clomn color-gray">商品规格</div>
<div class="attr-clomn200 color-gray">销售价格</div>
<div class="attr-clomn color-gray">库存数量</div>
<div class="attr-clomn220 color-gray">净含量</div>
</div>
<div v-for="(item, index) in formInline.netWeight" :key="index" class="attr-row">
<div class="attr-clomn">{{ item.goodSpecs }}</div>
<div class="attr-clomn200 flex-left-top">
<el-input-number v-model="item.goodPrice" :min="1" :precision="2" :controls="false"></el-input-number>
<span style="padding: 0 10px;"></span>
</div>
<div class="attr-clomn">
<el-input-number v-model="item.goodStock" :min="1" :controls="false" />
</div>
<div class="attr-clomn220 flex-left-top">
<el-input-number v-model="item.netContent" :min="1" :controls="false" />
<el-select v-model="item.unit" style="width: 80px; margin-left: 10px">
<el-option label="kg" value="kg" />
<el-option label="g" value="g" />
<el-option label="ml" value="ml" />
</el-select>
</div>
</div>
</div>
</el-form-item>
</div>
<!-- 商品属性 -->
<el-form-item label="商品属性" prop="attribute" required>
<div v-for="(item, index) in formInline.attribute" :key="index" class="attr-item">
<el-input v-model="item.name" :value="item.name" class="attr-input" placeholder="请输入属性名称" />
<el-icon size="20px" v-if="index !== 0" @click="deleteAttr(index)" style="cursor: pointer;">
<Delete />
</el-icon>
</div>
<el-button icon="plus" type="primary" plain style="margin: 0" @click="addAttr">添加属性</el-button>
</el-form-item>
<!-- 属性内容 -->
<el-form-item label="属性内容" prop="attribute" required>
<div class="attr-box">
<div class="attr-row">
<div class="attr-input color-gray">属性名称</div>
<div class="attr-input color-gray">属性内容</div>
</div>
<div v-for="(item, index) in formInline.attribute" :key="index" class="attr-row">
<div class="attr-input">{{ item.name }}</div>
<el-input v-model="item.value" class="attr-input" />
</div>
</div>
</el-form-item>
<!-- 发货地址 -->
<el-form-item label="发货地址" required>
<div style="display: flex; gap: 16px;">
<el-form-item prop="selectedAddress">
<!-- 省市区级联选择器 -->
<el-cascader v-model="formInline.selectedAddress" :options="addressOptions" :props="cascaderProps"
placeholder="请选择省市区" clearable />
</el-form-item>
<el-form-item prop="detailAddress">
<!-- 详细地址输入框 -->
<el-input v-model="formInline.detailAddress" placeholder="详细地址(如街道、门牌号等)" style="width: 220px;" />
</el-form-item>
</div>
</el-form-item>
<!-- 保障服务 -->
<el-form-item label="保障服务" prop="safeguard" required style="margin-bottom: 10px;">
<el-checkbox v-model="isSafeguardSelected" size="large" style="margin-top: -3px;">
<div style="color: #333;" v-for="(item) in formInline.safeguard.options" :key="item.id">服务承诺{{ item.text }}
</div>
</el-checkbox>
</el-form-item>
<!-- 优惠折扣 -->
<el-form-item label="优惠折扣" style="margin-bottom: 10px;">
<div style="width: 100%;">
<el-checkbox v-model="isDiscountSettings" size="large" style="margin-top: -3px;">
<div style="color: #333;" v-for="(item) in formInline.discountSettings.options" :key="item.id">
优惠设置{{
item.text }}</div>
</el-checkbox>
</div>
<div style="width: 100%;">
<el-checkbox v-model="isDiscountRebate" size="large" style="margin-top: -3px;">
<div style="color: #333;" v-for="(item) in formInline.discountSettings.options" :key="item.id">
折扣设置{{
item.text }}</div>
</el-checkbox>
</div>
</el-form-item>
<!-- 商品详情 -->
<el-form-item label="商品详情" prop="detailUrl">
<div>
<myUploadImage v-model="formInline.detailUrl" :isShowSubscript="false"></myUploadImage>
</div>
</el-form-item>
<!-- 商品视频 -->
<el-form-item label="商品视频" prop="videoUrl">
<div>
<myUploadVideo v-model="formInline.videoUrl"></myUploadVideo>
</div>
</el-form-item>
</el-form>
<el-button type="primary" @click="onSubmit" style="margin: 10px 0 0 80px;width: 150px;">确认新增</el-button>
</div>
</div>
</template>
<script setup name="addGoods">
import { ca } from "element-plus/es/locales.mjs";
import { ref, reactive, nextTick, onMounted } from "vue";
import myUploadImage from "@/components/myUploadImage.vue";
import myUploadVideo from "@/components/myUploadVideo.vue";
import { getGoodType, goodAdd, getActiveInfos } from "@/api/goods/info";
import { getRegion } from "@/api/common";
import { ElMessage } from "element-plus";
import areaList from "./areaList";
const formRef = ref(null)
const formInline = reactive({
goodName: "",
categoryId: "", //,
categoryId1: "", //,
categoryId2: "", //
categoryId3: "", //
goodUrl: "", //
goodCategorySelectType: 2, //
brandId: "", //
traceCode: "", //
specStyle: "1",// 1 2
salePrice: 1,//-
stock: 1,//-
netContent: 1,//-
unit: "kg",//-
netWeight: [ //
{
goodSpecs: "",
goodPrice: 1,
goodStock: 1,
netContent: 1,
unit: "kg"
}
], //
attribute: [
{
name: '', //
value: '', //
},
],
selectedAddress: [], //
areaAddress: '', //
detailAddress: "", //
sendAddress: "",
safeguard: {
isSelected: 1, //0 1
options: [
// { id: 10, text: '退' },
]
}, //
discountSettings: {
isSelected: 0, //0 1
options: [
// { id: 11, text: '10010' },
// { id: 13, text: '20020' },
]
}, //
discountRebate: {
isSelected: 0, //0 1
options: [
// { id: 12, text: '-8' },
// { id: 14, text: '-905' },
]
}, //
detailUrl: "",
brandId: "",
traceCode: "",
videoUrl: "",
});
const rules = reactive({
goodName: [
{
required: true,
message: '请输入商品名称',
trigger: 'blur'
},
],
categoryId1: [
{
required: true,
message: '请选择',
trigger: 'change',
},
],
categoryId2: [
{
required: true,
message: '请选择',
trigger: 'change',
},
],
categoryId3: [
{
required: true,
message: '请选择',
trigger: 'change',
},
],
goodUrl: [
{
validator: (rule, value, callback) => {
if (value === "" || value.trim() === "") {
callback(new Error('请至少上传一张商品图片'))
} else {
callback()
}
},
trigger: 'change'
}
],
specStyle: [
{ required: true, message: '请选择规格样式', trigger: 'change' }
],
salePrice: formInline.specStyle === '1' ? [
{
validator: (rule, value, callback) => {
if (!value || Number(value) <= 0) {
callback(new Error('请输入销售价格'))
} else {
callback()
}
},
trigger: ['blur', 'change']
},
] : [],
stock: formInline.specStyle === '1' ? [
{
validator: (rule, value, callback) => {
if (!value || Number(value) <= 0) {
callback(new Error('请输入库存数量'))
} else {
callback()
}
},
trigger: ['blur', 'change']
},
] : [],
netContent: formInline.specStyle === '1' ? [
{
validator: (rule, value, callback) => {
if (!value || Number(value) <= 0) {
callback(new Error('请输入净含量'))
} else {
callback()
}
},
trigger: ['blur', 'change']
},
] : [],
netWeight: formInline.specStyle === '2' ? [
{
validator: (rule, value, callback) => {
//
if (!value || value.length === 0) {
return callback(new Error('至少需要添加一个属性'))
}
//
const emptyNames = value.filter(item => !item.goodSpecs?.trim())
if (emptyNames.length > 0) {
return callback(new Error('请填写所有商品规格'))
}
callback()
},
trigger: 'blur'
}
] : [],
attribute: [
{
validator: (rule, value, callback) => {
//
if (!value || value.length === 0) {
return callback(new Error('至少需要添加一个属性'))
}
//
const emptyNames = value.filter(item => !item.name?.trim())
if (emptyNames.length > 0) {
return callback(new Error('请填写所有属性名称和内容'))
}
callback()
},
trigger: 'blur'
}
],
selectedAddress: [
{
required: true,
validator: (rule, value, callback) => {
if (!value || value.length !== 3) {
callback(new Error('请选择完整的省市区'));
} else {
callback();
}
},
trigger: 'blur'
}
],
detailAddress: [
{ required: true, message: '请输入详细地址', trigger: 'blur' }
],
safeguard: [
{
validator: (rule, value, callback) => {
console.log(value);
if (value.isSelected !== 1) { // 1
callback(new Error('必须选择保障服务')); //
} else {
callback(); //
}
},
trigger: 'change', //
},
],
});
const addSpecs = () => {
formInline.netWeight.push({
goodSpecs: "",
goodPrice: 1.00,
goodStock: 1,
netContent: 1,
unit: "kg"
})
}
const deleteSpecs = (index) => {
formInline.netWeight.splice(index, 1)
}
const addAttr = () => {
formInline.attribute.push({
name: '',
value: '',
})
}
const deleteAttr = (index) => {
formInline.attribute.splice(index, 1)
}
// ['', '', '']
const selectedAddress = ref([]);
const detailAddress = ref('');
//
const cascaderProps = ref({
label: 'areaName', //
value: 'areaCode', //
children: 'areaChildVOS', //
emitPath: true,
expandTrigger: 'hover',
});
//
const addressOptions = ref([]);
addressOptions.value = areaList.data;
//
const isSafeguardSelected = computed({
get: () => formInline.safeguard.isSelected === 1,
set: (val) => {
formInline.safeguard.isSelected = val ? 1 : 0
}
})
//
const isDiscountSettings = computed({
get: () => formInline.discountSettings.isSelected === 1,
set: (val) => {
formInline.discountSettings.isSelected = val ? 1 : 0
}
})
//
const isDiscountRebate = computed({
get: () => formInline.discountRebate.isSelected === 1,
set: (val) => {
formInline.discountRebate.isSelected = val ? 1 : 0
}
})
//
// 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 categoryList2 = ref([]);
const categoryList3 = ref([]);
const getGoodTypeList = async () => {
try {
let response = await getGoodType();
console.log(response);
if (response.code == 200) {
categoryList1.value = response.data;
}
} catch (error) {
console.log(error);
}
};
const changeCategory1 = (id) => {
console.log(id);
formInline.categoryId1 = id;
formInline.categoryId2 = "";
categoryList2.value = categoryList1.value.filter((item) => item.id == id)[0].children;
formInline.categoryId3 = "";
formInline.categoryId = "";
categoryList3.value = [];
if (id == 70) {
//
formInline.goodCategorySelectType = 1;
} else {
//
formInline.goodCategorySelectType = 2;
}
};
const changeCategory2 = (id) => {
console.log(id);
formInline.categoryId2 = id;
categoryList3.value = categoryList2.value.filter((item) => item.id == id)[0].children;
formInline.categoryId3 = "";
formInline.categoryId = "";
};
const changeCategory3 = (id) => {
console.log(id);
formInline.categoryId3 = id;
formInline.categoryId = id;
};
const onSubmit = async () => {
console.log(formInline);
try {
await formRef.value.validate()
console.log('验证通过!', formRef.value)
//
let params = { ...formInline };
if (formInline.specStyle == '1') {
params.netWeight = [
{
goodSpecs: "",
goodPrice: formInline.salePrice,
goodStock: formInline.stock,
netContent: formInline.netContent,
unit: formInline.unit
}
];
} else {
params.netWeight = formInline.netWeight
}
params.areaAddress = params.selectedAddress.join(',');
params.safeguardSelected = formInline.safeguard.isSelected; //
params.discountSettingsSelected = formInline.discountSettings.isSelected; //
params.discountRebateSelected = formInline.discountRebate.isSelected; //
//
onGoodSave(params)
} catch (error) {
console.log('验证失败', error)
}
};
const onGoodSave = async (params) => {
let response = await goodAdd(params);
if (response.code === 200) {
ElMessage.success("新增成功!");
formRef.value.resetFields();
} else {
ElMessage.error(response.message);
}
}
const getArea = async () => {
const res = await getRegion();
console.log(res);
if (res.code === 200) {
addressOptions.value = res.data.list;
} else {
ElMessage.error(res.message);
}
};
const activeInfoList = ref([]);
//
const getActiveInfo = async () => {
const res = await getActiveInfos();
console.log(res);
if (res.code === 200) {
activeInfoList.value = res.data;
formInline.safeguard.options = [...activeInfoList.value.safeguard.options];
formInline.discountSettings.options = [...activeInfoList.value.discountSettings.options];
formInline.discountRebate.options = [...activeInfoList.value.discountRebate.options];
} else {
ElMessage.error(res.message);
}
};
onMounted(() => {
getActiveInfo();
getGoodTypeList();
getArea();
});
</script>
<style lang="scss" scoped></style>

View File

@ -0,0 +1,792 @@
export default {
"code": 200,
"msg": null,
"data": [
{
"id": "3",
"areaName": "耿马傣族佤族自治县",
"parentId": "530900",
"areaCode": "530926",
"level": 2,
"areaChildVOS": [
{
"id": "4",
"areaName": "耿马镇",
"parentId": "530926",
"areaCode": "530926100",
"level": 3,
"areaChildVOS": [
{
"id": "16",
"areaName": "甘东社区",
"parentId": "530926100",
"areaCode": "5309261001",
"level": 4,
"areaChildVOS": []
},
{
"id": "17",
"areaName": "白马社区",
"parentId": "530926100",
"areaCode": "5309261002",
"level": 4,
"areaChildVOS": []
},
{
"id": "18",
"areaName": "白塔社区",
"parentId": "530926100",
"areaCode": "5309261003",
"level": 4,
"areaChildVOS": []
},
{
"id": "19",
"areaName": "团结村",
"parentId": "530926100",
"areaCode": "5309261004",
"level": 4,
"areaChildVOS": []
},
{
"id": "20",
"areaName": "新城村",
"parentId": "530926100",
"areaCode": "5309261005",
"level": 4,
"areaChildVOS": []
},
{
"id": "21",
"areaName": "芒蚌村",
"parentId": "530926100",
"areaCode": "5309261006",
"level": 4,
"areaChildVOS": []
},
{
"id": "22",
"areaName": "芒国村",
"parentId": "530926100",
"areaCode": "5309261007",
"level": 4,
"areaChildVOS": []
},
{
"id": "23",
"areaName": "复兴村",
"parentId": "530926100",
"areaCode": "5309261008",
"level": 4,
"areaChildVOS": []
},
{
"id": "24",
"areaName": "允楞村",
"parentId": "530926100",
"areaCode": "5309261009",
"level": 4,
"areaChildVOS": []
},
{
"id": "25",
"areaName": "石灰窑村",
"parentId": "530926100",
"areaCode": "53092610010",
"level": 4,
"areaChildVOS": []
},
{
"id": "26",
"areaName": "南木弄村",
"parentId": "530926100",
"areaCode": "53092610011",
"level": 4,
"areaChildVOS": []
},
{
"id": "27",
"areaName": "允捧村",
"parentId": "530926100",
"areaCode": "53092610012",
"level": 4,
"areaChildVOS": []
},
{
"id": "28",
"areaName": "菜籽地村",
"parentId": "530926100",
"areaCode": "53092610013",
"level": 4,
"areaChildVOS": []
},
{
"id": "29",
"areaName": "弄巴村",
"parentId": "530926100",
"areaCode": "53092610014",
"level": 4,
"areaChildVOS": []
}
]
},
{
"id": "5",
"areaName": "勐永镇",
"parentId": "530926",
"areaCode": "530926101",
"level": 3,
"areaChildVOS": [
{
"id": "30",
"areaName": "勐永村",
"parentId": "530926101",
"areaCode": "5309261011",
"level": 4,
"areaChildVOS": []
},
{
"id": "31",
"areaName": "新和村",
"parentId": "530926101",
"areaCode": "5309261012",
"level": 4,
"areaChildVOS": []
},
{
"id": "32",
"areaName": "芒来村",
"parentId": "530926101",
"areaCode": "5309261013",
"level": 4,
"areaChildVOS": []
},
{
"id": "33",
"areaName": "芒佑村",
"parentId": "530926101",
"areaCode": "5309261014",
"level": 4,
"areaChildVOS": []
},
{
"id": "34",
"areaName": "芒糯村",
"parentId": "530926101",
"areaCode": "5309261015",
"level": 4,
"areaChildVOS": []
},
{
"id": "35",
"areaName": "帮令村",
"parentId": "530926101",
"areaCode": "5309261016",
"level": 4,
"areaChildVOS": []
},
{
"id": "36",
"areaName": "香竹林村",
"parentId": "530926101",
"areaCode": "5309261017",
"level": 4,
"areaChildVOS": []
},
{
"id": "37",
"areaName": "光木林村",
"parentId": "530926101",
"areaCode": "5309261018",
"level": 4,
"areaChildVOS": []
}
]
},
{
"id": "6",
"areaName": "勐撒镇",
"parentId": "530926",
"areaCode": "530926102",
"level": 3,
"areaChildVOS": [
{
"id": "38",
"areaName": "丙令村",
"parentId": "530926102",
"areaCode": "5309261021",
"level": 4,
"areaChildVOS": []
},
{
"id": "39",
"areaName": "芒茂村",
"parentId": "530926102",
"areaCode": "5309261022",
"level": 4,
"areaChildVOS": []
},
{
"id": "40",
"areaName": "城子村",
"parentId": "530926102",
"areaCode": "5309261023",
"level": 4,
"areaChildVOS": []
},
{
"id": "41",
"areaName": "芒枕村",
"parentId": "530926102",
"areaCode": "5309261024",
"level": 4,
"areaChildVOS": []
},
{
"id": "42",
"areaName": "箐门口村",
"parentId": "530926102",
"areaCode": "5309261025",
"level": 4,
"areaChildVOS": []
},
{
"id": "43",
"areaName": "班必村",
"parentId": "530926102",
"areaCode": "5309261026",
"level": 4,
"areaChildVOS": []
},
{
"id": "44",
"areaName": "翁达村",
"parentId": "530926102",
"areaCode": "5309261027",
"level": 4,
"areaChildVOS": []
},
{
"id": "45",
"areaName": "琅琊村",
"parentId": "530926102",
"areaCode": "5309261028",
"level": 4,
"areaChildVOS": []
},
{
"id": "46",
"areaName": "户肯村",
"parentId": "530926102",
"areaCode": "5309261029",
"level": 4,
"areaChildVOS": []
}
]
},
{
"id": "7",
"areaName": "孟定镇",
"parentId": "530926",
"areaCode": "530926103",
"level": 3,
"areaChildVOS": [
{
"id": "47",
"areaName": "城关村",
"parentId": "530926103",
"areaCode": "5309261031",
"level": 4,
"areaChildVOS": []
},
{
"id": "48",
"areaName": "下城村",
"parentId": "530926103",
"areaCode": "5309261032",
"level": 4,
"areaChildVOS": []
},
{
"id": "49",
"areaName": "罕宏村",
"parentId": "530926103",
"areaCode": "5309261033",
"level": 4,
"areaChildVOS": []
},
{
"id": "50",
"areaName": "贺海村",
"parentId": "530926103",
"areaCode": "5309261034",
"level": 4,
"areaChildVOS": []
},
{
"id": "51",
"areaName": "遮哈村",
"parentId": "530926103",
"areaCode": "5309261035",
"level": 4,
"areaChildVOS": []
},
{
"id": "52",
"areaName": "下坝村",
"parentId": "530926103",
"areaCode": "5309261036",
"level": 4,
"areaChildVOS": []
},
{
"id": "53",
"areaName": "河西村",
"parentId": "530926103",
"areaCode": "5309261037",
"level": 4,
"areaChildVOS": []
},
{
"id": "54",
"areaName": "新寨村",
"parentId": "530926103",
"areaCode": "5309261038",
"level": 4,
"areaChildVOS": []
},
{
"id": "55",
"areaName": "景信村",
"parentId": "530926103",
"areaCode": "5309261039",
"level": 4,
"areaChildVOS": []
},
{
"id": "56",
"areaName": "糯峨村",
"parentId": "530926103",
"areaCode": "5309261040",
"level": 4,
"areaChildVOS": []
},
{
"id": "57",
"areaName": "芒美村",
"parentId": "530926103",
"areaCode": "5309261041",
"level": 4,
"areaChildVOS": []
},
{
"id": "58",
"areaName": "邱山村",
"parentId": "530926103",
"areaCode": "5309261042",
"level": 4,
"areaChildVOS": []
},
{
"id": "59",
"areaName": "德龙村",
"parentId": "530926103",
"areaCode": "5309261043",
"level": 4,
"areaChildVOS": []
},
{
"id": "60",
"areaName": "芒撒村",
"parentId": "530926103",
"areaCode": "5309261044",
"level": 4,
"areaChildVOS": []
},
{
"id": "61",
"areaName": "崇岗村",
"parentId": "530926103",
"areaCode": "5309261045",
"level": 4,
"areaChildVOS": []
},
{
"id": "62",
"areaName": "芒艾村",
"parentId": "530926103",
"areaCode": "5309261046",
"level": 4,
"areaChildVOS": []
},
{
"id": "63",
"areaName": "色树坝村",
"parentId": "530926103",
"areaCode": "5309261047",
"level": 4,
"areaChildVOS": []
},
{
"id": "64",
"areaName": "尖坪村",
"parentId": "530926103",
"areaCode": "5309261048",
"level": 4,
"areaChildVOS": []
},
{
"id": "65",
"areaName": "山头寨村",
"parentId": "530926103",
"areaCode": "5309261049",
"level": 4,
"areaChildVOS": []
},
{
"id": "66",
"areaName": "班幸村",
"parentId": "530926103",
"areaCode": "5309261050",
"level": 4,
"areaChildVOS": []
},
{
"id": "67",
"areaName": "清水河村",
"parentId": "530926103",
"areaCode": "5309261051",
"level": 4,
"areaChildVOS": []
},
{
"id": "68",
"areaName": "尖山村",
"parentId": "530926103",
"areaCode": "5309261052",
"level": 4,
"areaChildVOS": []
},
{
"id": "69",
"areaName": "大水井村",
"parentId": "530926103",
"areaCode": "5309261053",
"level": 4,
"areaChildVOS": []
},
{
"id": "70",
"areaName": "和顺新村",
"parentId": "530926103",
"areaCode": "5309261054",
"level": 4,
"areaChildVOS": []
},
{
"id": "71",
"areaName": "沙源新村",
"parentId": "530926103",
"areaCode": "5309261055",
"level": 4,
"areaChildVOS": []
}
]
},
{
"id": "8",
"areaName": "大兴乡",
"parentId": "530926",
"areaCode": "530926200",
"level": 3,
"areaChildVOS": [
{
"id": "72",
"areaName": "大兴村",
"parentId": "530926200",
"areaCode": "5309262001",
"level": 4,
"areaChildVOS": []
},
{
"id": "73",
"areaName": "岩榴村",
"parentId": "530926200",
"areaCode": "5309262002",
"level": 4,
"areaChildVOS": []
},
{
"id": "74",
"areaName": "永胜村",
"parentId": "530926200",
"areaCode": "5309262003",
"level": 4,
"areaChildVOS": []
},
{
"id": "75",
"areaName": "户肯村",
"parentId": "530926200",
"areaCode": "5309262004",
"level": 4,
"areaChildVOS": []
},
{
"id": "76",
"areaName": "龚家寨村",
"parentId": "530926200",
"areaCode": "5309262005",
"level": 4,
"areaChildVOS": []
},
{
"id": "77",
"areaName": "班坝村",
"parentId": "530926200",
"areaCode": "5309262006",
"level": 4,
"areaChildVOS": []
}
]
},
{
"id": "9",
"areaName": "芒洪拉祜族布朗族乡",
"parentId": "530926",
"areaCode": "530926201",
"level": 3,
"areaChildVOS": [
{
"id": "78",
"areaName": "芒洪村",
"parentId": "530926201",
"areaCode": "5309262011",
"level": 4,
"areaChildVOS": []
},
{
"id": "79",
"areaName": "科且村",
"parentId": "530926201",
"areaCode": "5309262012",
"level": 4,
"areaChildVOS": []
},
{
"id": "80",
"areaName": "安雅村",
"parentId": "530926201",
"areaCode": "5309262013",
"level": 4,
"areaChildVOS": []
},
{
"id": "81",
"areaName": "新联村",
"parentId": "530926201",
"areaCode": "5309262014",
"level": 4,
"areaChildVOS": []
},
{
"id": "82",
"areaName": "马厂村",
"parentId": "530926201",
"areaCode": "5309262015",
"level": 4,
"areaChildVOS": []
}
]
},
{
"id": "10",
"areaName": "四排山乡",
"parentId": "530926",
"areaCode": "530926202",
"level": 3,
"areaChildVOS": [
{
"id": "83",
"areaName": "老寨村",
"parentId": "530926202",
"areaCode": "5309262021",
"level": 4,
"areaChildVOS": []
},
{
"id": "84",
"areaName": "关弄村",
"parentId": "530926202",
"areaCode": "5309262022",
"level": 4,
"areaChildVOS": []
},
{
"id": "85",
"areaName": "芒关村",
"parentId": "530926202",
"areaCode": "5309262023",
"level": 4,
"areaChildVOS": []
},
{
"id": "86",
"areaName": "芒翁村",
"parentId": "530926202",
"areaCode": "5309262024",
"level": 4,
"areaChildVOS": []
},
{
"id": "87",
"areaName": "梁子寨村",
"parentId": "530926202",
"areaCode": "5309262025",
"level": 4,
"areaChildVOS": []
},
{
"id": "88",
"areaName": "石佛洞村",
"parentId": "530926202",
"areaCode": "5309262026",
"level": 4,
"areaChildVOS": []
},
{
"id": "89",
"areaName": "东坡村",
"parentId": "530926202",
"areaCode": "5309262027",
"level": 4,
"areaChildVOS": []
},
{
"id": "90",
"areaName": "班康村",
"parentId": "530926202",
"areaCode": "5309262028",
"level": 4,
"areaChildVOS": []
}
]
},
{
"id": "11",
"areaName": "贺派乡",
"parentId": "530926",
"areaCode": "530926203",
"level": 3,
"areaChildVOS": [
{
"id": "91",
"areaName": "贺派村",
"parentId": "530926203",
"areaCode": "5309262031",
"level": 4,
"areaChildVOS": []
},
{
"id": "92",
"areaName": "芒抗村",
"parentId": "530926203",
"areaCode": "5309262032",
"level": 4,
"areaChildVOS": []
},
{
"id": "93",
"areaName": "水平村",
"parentId": "530926203",
"areaCode": "5309262033",
"level": 4,
"areaChildVOS": []
},
{
"id": "94",
"areaName": "落阳村",
"parentId": "530926203",
"areaCode": "5309262034",
"level": 4,
"areaChildVOS": []
},
{
"id": "95",
"areaName": "崩弄村",
"parentId": "530926203",
"areaCode": "5309262035",
"level": 4,
"areaChildVOS": []
},
{
"id": "96",
"areaName": "芒底村",
"parentId": "530926203",
"areaCode": "5309262036",
"level": 4,
"areaChildVOS": []
},
{
"id": "97",
"areaName": "帮卖村",
"parentId": "530926203",
"areaCode": "5309262037",
"level": 4,
"areaChildVOS": []
}
]
},
{
"id": "12",
"areaName": "勐简乡",
"parentId": "530926",
"areaCode": "530926204",
"level": 3,
"areaChildVOS": [
{
"id": "98",
"areaName": "勐简村",
"parentId": "530926204",
"areaCode": "5309262041",
"level": 4,
"areaChildVOS": []
},
{
"id": "99",
"areaName": "班望村",
"parentId": "530926204",
"areaCode": "5309262042",
"level": 4,
"areaChildVOS": []
},
{
"id": "100",
"areaName": "迎们寨村",
"parentId": "530926204",
"areaCode": "5309262043",
"level": 4,
"areaChildVOS": []
},
{
"id": "101",
"areaName": "大寨村",
"parentId": "530926204",
"areaCode": "5309262044",
"level": 4,
"areaChildVOS": []
},
{
"id": "102",
"areaName": "老厂村",
"parentId": "530926204",
"areaCode": "5309262045",
"level": 4,
"areaChildVOS": []
}
]
}
]
}
]
}

View File

@ -0,0 +1,660 @@
<template>
<div class="app-container customer-control">
<div class="customer-box">
<el-form ref="formRef" :disabled="true" :model="formInline" :rules="rules" class="demo-form-inline" :label-width="'auto'">
<!-- 商品名称 -->
<el-form-item label="商品名称" prop="goodName">
<el-input v-model="formInline.goodName" clearable show-word-limit maxlength="30" placeholder="请输入商品名称"
style="width: 800px" />
</el-form-item>
<!-- 商品分类 -->
<el-form-item label="商品分类" required>
<div style="display: flex; gap: 16px;">
<el-form-item prop="categoryId1">
<el-select v-model="formInline.categoryId1" placeholder="请选择" class="my-el-select"
@change="changeCategory1($event)">
<el-option v-for="item in categoryList1" :key="item.id" :value="item.id" :label="item.name" />
</el-select>
</el-form-item>
<el-form-item prop="categoryId2">
<el-select v-model="formInline.categoryId2" placeholder="请选择" class="my-el-select"
@change="changeCategory2($event)">
<el-option v-for="item in categoryList2" :key="item.id" :value="item.id" :label="item.name" />
</el-select>
</el-form-item>
<el-form-item prop="categoryId3">
<el-select v-model="formInline.categoryId3" placeholder="请选择" class="my-el-select"
@change="changeCategory3($event)">
<el-option v-for="item in categoryList3" :key="item.id" :value="item.id" :label="item.name" />
</el-select>
</el-form-item>
</div>
</el-form-item>
<!-- 公共品牌 -->
<el-form-item label="公共品牌" prop="brandId" v-show="formInline.goodCategorySelectType == 1">
<el-input v-model="formInline.brandId" clearable placeholder="请输入公共品牌" style="width: 800px" />
</el-form-item>
<!-- 溯源编码 -->
<el-form-item label="溯源编码" prop="traceCode" v-show="formInline.goodCategorySelectType == 1">
<el-input v-model="formInline.traceCode" clearable placeholder="请输入溯源编码" style="width: 800px" />
</el-form-item>
<!-- 商品图片 -->
<el-form-item label="商品图片" prop="goodUrl" required>
<div>
<!-- <myUploadImage v-model="formInline.goodUrl"></myUploadImage> -->
<img style="width: 200px;" :src="formInline.goodUrl" alt="">
</div>
</el-form-item>
<!-- 规格样式 -->
<el-form-item label="规格样式" prop="specStyle" required>
<el-radio-group v-model="formInline.specStyle" style="margin-top: -3px;">
<el-radio value="1" size="large">单规格</el-radio>
<el-radio value="2" size="large">多规格</el-radio>
</el-radio-group>
</el-form-item>
<div v-if="formInline.specStyle == 1">
<!-- 销售价格 -->
<el-form-item label="销售价格" prop="salePrice" required>
<el-input-number v-model="formInline.salePrice" :min="1" :precision="2" :controls="false"></el-input-number>
<span style="padding: 0 10px;"></span>
</el-form-item>
<!-- 库存数量 -->
<el-form-item label="库存数量" prop="stock" required>
<el-input-number v-model="formInline.stock" :min="1" :controls="false" />
</el-form-item>
<!-- 净含量 -->
<el-form-item label="净含量" prop="netContent" required>
<el-input-number v-model="formInline.netContent" :min="1" :controls="false" />
<el-select v-model="formInline.unit" style="width: 80px; margin-left: 10px">
<el-option label="kg" value="kg" />
<el-option label="g" value="g" />
<el-option label="ml" value="ml" />
</el-select>
</el-form-item>
</div>
<!-- 多规格 -->
<div v-else>
<el-form-item label="商品规格" prop="netWeight" required>
<div v-for="(item, index) in formInline.netWeight" :key="index" class="attr-item">
<el-input v-model="item.goodSpecs" :value="item.goodSpecs" class="attr-clomn" placeholder="请输入规格名称" />
<el-icon size="20px" v-if="index !== 0" @click="deleteSpecs(index)" style="cursor: pointer;">
<Delete />
</el-icon>
</div>
<el-button icon="plus" type="primary" plain style="margin: 0" @click="addSpecs">添加属性</el-button>
</el-form-item>
<!-- 价格库存 -->
<el-form-item label="价格库存" prop="netWeight" required>
<div class="attr-box">
<div class="attr-row">
<div class="attr-clomn color-gray">商品规格</div>
<div class="attr-clomn200 color-gray">销售价格</div>
<div class="attr-clomn color-gray">库存数量</div>
<div class="attr-clomn220 color-gray">净含量</div>
</div>
<div v-for="(item, index) in formInline.netWeight" :key="index" class="attr-row">
<div class="attr-clomn">{{ item.goodSpecs }}</div>
<div class="attr-clomn200 flex-left-top">
<el-input-number v-model="item.goodPrice" :min="1" :precision="2" :controls="false"></el-input-number>
<span style="padding: 0 10px;"></span>
</div>
<div class="attr-clomn">
<el-input-number v-model="item.goodStock" :min="1" :controls="false" />
</div>
<div class="attr-clomn220 flex-left-top">
<el-input-number v-model="item.netContent" :min="1" :controls="false" />
<el-select v-model="item.unit" style="width: 80px; margin-left: 10px">
<el-option label="kg" value="kg" />
<el-option label="g" value="g" />
<el-option label="ml" value="ml" />
</el-select>
</div>
</div>
</div>
</el-form-item>
</div>
<!-- 商品属性 -->
<el-form-item label="商品属性" prop="attribute" required>
<div v-for="(item, index) in formInline.attribute" :key="index" class="attr-item">
<el-input v-model="item.name" :value="item.name" class="attr-input" placeholder="请输入属性名称" />
<el-icon size="20px" v-if="index !== 0" @click="deleteAttr(index)" style="cursor: pointer;">
<Delete />
</el-icon>
</div>
<el-button icon="plus" type="primary" plain style="margin: 0" @click="addAttr">添加属性</el-button>
</el-form-item>
<!-- 属性内容 -->
<el-form-item label="属性内容" prop="attribute" required>
<div class="attr-box">
<div class="attr-row">
<div class="attr-input color-gray">属性名称</div>
<div class="attr-input color-gray">属性内容</div>
</div>
<div v-for="(item, index) in formInline.attribute" :key="index" class="attr-row">
<div class="attr-input">{{ item.name }}</div>
<el-input v-model="item.value" class="attr-input" />
</div>
</div>
</el-form-item>
<!-- 发货地址 -->
<el-form-item label="发货地址" required>
<div style="display: flex; gap: 16px;">
<el-form-item prop="selectedAddress">
<!-- 省市区级联选择器 -->
<el-cascader v-model="formInline.selectedAddress" :options="addressOptions" :props="cascaderProps"
placeholder="请选择省市区" clearable style="width: 300px;" />
</el-form-item>
<el-form-item prop="detailAddress">
<!-- 详细地址输入框 -->
<el-input v-model="formInline.detailAddress" placeholder="详细地址(如街道、门牌号等)" style="width: 220px;" />
</el-form-item>
</div>
</el-form-item>
<!-- 保障服务 -->
<el-form-item label="保障服务" prop="safeguard" required style="margin-bottom: 10px;">
<el-checkbox v-model="isSafeguardSelected" size="large" style="margin-top: -3px;">
<div style="color: #333;" v-for="(item, index) in formInline.safeguard.options" :key="index">服务承诺{{
item.text }}
</div>
</el-checkbox>
</el-form-item>
<!-- 优惠折扣 -->
<el-form-item label="优惠折扣" style="margin-bottom: 10px;">
<div style="width: 100%;">
<el-checkbox v-model="isDiscountSettings" size="large" style="margin-top: -3px;">
<div style="color: #333;" v-for="(item, index) in formInline.discountSettings.options" :key="index">
优惠设置{{
item.text }}</div>
</el-checkbox>
</div>
<div style="width: 100%;">
<el-checkbox v-model="isDiscountRebate" size="large" style="margin-top: -3px;">
<div style="color: #333;" v-for="(item, index) in formInline.discountSettings.options" :key="index">
折扣设置{{
item.text }}</div>
</el-checkbox>
</div>
</el-form-item>
<!-- 商品详情 -->
<el-form-item label="商品详情" prop="detailUrl">
<div style="display:inherit">
<!-- <myUploadImage v-model="formInline.detailUrl" :isShowSubscript="false"></myUploadImage> -->
<img v-for="(item, index) in formInline.detailUrl.split(',')" :key="index" style="width: 100px;margin-right: 5px;" :src="item" alt="">
</div>
</el-form-item>
<!-- 商品视频 -->
<el-form-item label="商品视频" prop="videoUrl" v-if="formInline.videoUrl">
<div>
<!-- <myUploadVideo v-model="formInline.videoUrl"></myUploadVideo> -->
<video :src="formInline.videoUrl" controls style="width: 300px;"></video>
</div>
</el-form-item>
</el-form>
<el-button type="primary" @click="approved(1)" style="margin: 10px 0 0 80px;width: 150px;">审核通过</el-button>
<el-button type="danger" @click="approved(2)" style="margin: 10px 0 0 20px;width: 150px;">驳回</el-button>
</div>
</div>
</template>
<script setup name="editGoods">
import { ca } from "element-plus/es/locales.mjs";
import { ref, reactive, nextTick, onMounted, watch } from "vue";
import myUploadImage from "@/components/myUploadImage.vue";
import myUploadVideo from "@/components/myUploadVideo.vue";
import { getGoodType, goodEdit, getGoodInfo, getActiveInfos,goodaudit } from "@/api/goods/info";
import { getRegion } from "@/api/common";
import { ElMessage } from "element-plus";
import areaList from "./areaList";
const route = useRoute()
const router = useRouter()
const formRef = ref(null)
const formData = ref({});
const formInline = reactive({
goodName: "",
categoryId: "", //,
categoryId1: "", //,
categoryId2: "", //
categoryId3: "", //
goodUrl: "", //
goodCategorySelectType: 2, //
brandId: "", //
traceCode: "", //
specStyle: "1",// 1 2
salePrice: 1,//-
stock: 1,//-
netContent: 1,//-
unit: "kg",//-
netWeight: [ //
{
goodSpecs: "",
goodPrice: 1,
goodStock: 1,
netContent: 1,
unit: "kg"
}
], //
attribute: [
{
name: '', //
value: '', //
},
],
selectedAddress: [], //
areaAddress: '', //
detailAddress: "", //
sendAddress: "",
safeguard: {
isSelected: 1, //0 1
options: [
// { id: 10, text: '退' },
]
}, //
discountSettings: {
isSelected: 0, //0 1
options: [
// { id: 11, text: '10010' },
// { id: 13, text: '20020' },
]
}, //
discountRebate: {
isSelected: 0, //0 1
options: [
// { id: 12, text: '-8' },
// { id: 14, text: '-905' },
]
}, //
detailUrl: "",
brandId: "",
traceCode: "",
videoUrl: "",
});
const rules = reactive({
goodName: [
{
required: true,
message: '请输入商品名称',
trigger: 'blur'
},
],
categoryId1: [
{
required: true,
message: '请选择',
trigger: 'change',
},
],
categoryId2: [
{
required: true,
message: '请选择',
trigger: 'change',
},
],
categoryId3: [
{
required: true,
message: '请选择',
trigger: 'change',
},
],
goodUrl: [
{
validator: (rule, value, callback) => {
if (value === "" || value.trim() === "") {
callback(new Error('请至少上传一张商品图片'))
} else {
callback()
}
},
trigger: 'change'
}
],
specStyle: [
{ required: true, message: '请选择规格样式', trigger: 'change' }
],
salePrice: formInline.specStyle === '1' ? [
{
validator: (rule, value, callback) => {
if (!value || Number(value) <= 0) {
callback(new Error('请输入销售价格'))
} else {
callback()
}
},
trigger: ['blur', 'change']
},
] : [],
stock: formInline.specStyle === '1' ? [
{
validator: (rule, value, callback) => {
if (!value || Number(value) <= 0) {
callback(new Error('请输入库存数量'))
} else {
callback()
}
},
trigger: ['blur', 'change']
},
] : [],
netContent: formInline.specStyle === '1' ? [
{
validator: (rule, value, callback) => {
if (!value || Number(value) <= 0) {
callback(new Error('请输入净含量'))
} else {
callback()
}
},
trigger: ['blur', 'change']
},
] : [],
netWeight: formInline.specStyle === '2' ? [
{
validator: (rule, value, callback) => {
//
if (!value || value.length === 0) {
return callback(new Error('至少需要添加一个属性'))
}
//
const emptyNames = value.filter(item => !item.goodSpecs?.trim())
if (emptyNames.length > 0) {
return callback(new Error('请填写所有商品规格'))
}
callback()
},
trigger: 'blur'
}
] : [],
attribute: [
{
validator: (rule, value, callback) => {
//
if (!value || value.length === 0) {
return callback(new Error('至少需要添加一个属性'))
}
//
const emptyNames = value.filter(item => !item.name?.trim())
if (emptyNames.length > 0) {
return callback(new Error('请填写所有属性名称和内容'))
}
callback()
},
trigger: 'blur'
}
],
selectedAddress: [
{
required: true,
validator: (rule, value, callback) => {
if (!value || value.length !== 3) {
callback(new Error('请选择完整的省市区'));
} else {
callback();
}
},
trigger: 'blur'
}
],
detailAddress: [
{ required: true, message: '请输入详细地址', trigger: 'blur' }
],
})
const addSpecs = () => {
formInline.netWeight.push({
goodSpecs: "",
goodPrice: 1.00,
goodStock: 1,
netContent: 1,
unit: "kg"
})
}
const deleteSpecs = (index) => {
formInline.netWeight.splice(index, 1)
}
const addAttr = () => {
formInline.attribute.push({
name: '',
value: '',
})
}
const deleteAttr = (index) => {
formInline.attribute.splice(index, 1)
}
// ['', '', '']
const selectedAddress = ref([]);
const detailAddress = ref('');
//
const cascaderProps = ref({
label: 'areaName', //
value: 'areaCode', //
children: 'areaChildVOS', //
emitPath: true,
expandTrigger: 'hover',
});
//
const addressOptions = ref([]);
addressOptions.value = areaList.data;
//
const isSafeguardSelected = computed({
get: () => formInline.safeguard.isSelected === 1,
set: (val) => {
formInline.safeguard.isSelected = val ? 1 : 0
}
})
//
const isDiscountSettings = computed({
get: () => formInline.discountSettings.isSelected === 1,
set: (val) => {
formInline.discountSettings.isSelected = val ? 1 : 0
}
})
//
const isDiscountRebate = computed({
get: () => formInline.discountRebate.isSelected === 1,
set: (val) => {
formInline.discountRebate.isSelected = val ? 1 : 0
}
})
//
// 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 categoryList2 = ref([]);
const categoryList3 = ref([]);
const getGoodTypeList = async () => {
try {
let response = await getGoodType();
console.log(response);
if (response.code == 200) {
categoryList1.value = response.data;
}
} catch (error) {
console.log(error);
}
};
const changeCategory1 = (id) => {
console.log(id);
formInline.categoryId1 = id;
formInline.categoryId2 = "";
categoryList2.value = categoryList1.value.filter((item) => item.id == id)[0].children;
formInline.categoryId3 = "";
formInline.categoryId = "";
categoryList3.value = [];
if (id == 70) {
// 70
formInline.goodCategorySelectType = 1;
} else {
// 88
formInline.goodCategorySelectType = 2;
}
};
const changeCategory2 = (id) => {
console.log(id);
formInline.categoryId2 = id;
categoryList3.value = categoryList2.value.filter((item) => item.id == id)[0].children;
formInline.categoryId3 = "";
formInline.categoryId = "";
};
const changeCategory3 = (id) => {
console.log(id);
formInline.categoryId3 = id;
formInline.categoryId = id;
};
///
const approved = async (index) => {
console.log('formInline',formInline);
let res = await goodaudit({ id: formInline.id, examineStatus: index });
let text = index == 1 ? "已审核" : "已驳回";
if (res.code == 200) {
ElMessage.success(`${text}`);
//
router.go(-1);
} else {
ElMessage.error(res.msg);
}
};
const getArea = async () => {
const res = await getRegion();
if (res.code === 200) {
addressOptions.value = res.data.list;
}
};
const activeInfoList = ref([]);
//
const getActiveInfo = async () => {
const res = await getActiveInfos();
if (res.code === 200) {
activeInfoList.value = res.data;
} else {
ElMessage.error(res.message);
}
};
const getGoodsInfo = async (goodId) => {
const res = await getGoodInfo(goodId);
if (res.code == 200) {
Object.assign(formData.value, res.data);
Object.assign(formInline, res.data);
if (res.data.netWeight.length > 1) {
formInline.specStyle = '2';
} else {
formInline.specStyle = '1';
console.log(res.data.netWeight[0]);
formInline.salePrice = formData.value.netWeight[0]?.goodPrice ?? 1;
formInline.stock = formData.value.netWeight[0]?.goodStock ?? 1;
formInline.netContent = formData.value.netWeight[0]?.netContent ?? 1;
formInline.unit = formData.value.netWeight[0]?.unit ?? "kg";
}
formInline.categoryId1 = formData.value?.categoryId1 ?? "88"
formInline.categoryId2 = formData.value?.categoryId2 ?? "";
formInline.categoryId3 = formData.value?.categoryId3 ?? "";
formInline.netWeight = formData.value?.netWeight ?? [
{
goodSpecs: "",
goodPrice: 1,
goodStock: 1,
netContent: 1,
unit: "kg"
}
];
formInline.attribute = formData.value?.attribute ?? [{
name: '', //
value: '', //
}];
formInline.selectedAddress = formData.value?.areaAddress?.split(",") ?? [];
formInline.goodUrl = formData.value?.goodUrl?.split(",").slice(0, 5).join(',') ?? "";
formInline.detailUrl = formData.value?.detailUrl?.split(",").slice(0, 5).join(',') ?? "";
formInline.videoUrl = formData.value?.videoUrl?.split(",").slice(0, 1).join(',') ?? "";
formInline.safeguard = { isSelected: formData.value?.safeguard?.isSelected ?? 1, options:[...activeInfoList.value.safeguard.options] }
formInline.discountSettings = { isSelected: formData.value?.discountSettings?.isSelected ?? 0, options:[...activeInfoList.value.discountSettings.options] }
formInline.discountRebate = { isSelected: formData.value?.discountRebate?.isSelected ?? 0, options:[...activeInfoList.value.discountRebate.options] }
if (formInline.categoryId1) {
categoryList2.value = categoryList1.value.filter((item) => item.id == formInline.categoryId1)[0].children;
if (formInline.categoryId2) {
let item = categoryList2.value.filter(item => item.id === formInline.categoryId2);
categoryList3.value = item[0].children;
}
}
// console.log(formInline);
} else {
ElMessage.error(res.msg);
}
};
watch(() => route.query, (newVal) => {
console.log("watch商品id:", newVal.goodId);
if (newVal.goodId) {
getGoodsInfo(newVal.goodId);
}
})
onMounted(async () => {
const { edit, goodId } = route.query;
console.log("onMounted商品id:", goodId);
getActiveInfo();
await getGoodTypeList();
getArea();
if (goodId) {
getGoodsInfo(goodId);
}
});
</script>
<style lang="scss" scoped></style>

View File

@ -0,0 +1,478 @@
<template>
<div class="app-container customer-control">
<div class="container-custom">
<!-- 搜索栏 -->
<div ref="searchBarRef" class="search-box">
<div class="search-bar">
<div class="search-bar-left">
<!-- <div class="order-tab" style="margin-top: -10px">
<el-tabs v-model="activeCurrent" @tab-click="tabChange">
<el-tab-pane
v-for="t in bottomList"
:key="t.id"
:label="t.title + t.value"
:name="t.id"
>
</el-tab-pane>
</el-tabs>
</div> -->
<el-form
ref="searchForm"
:inline="true"
:model="formInline"
class="demo-form-inline"
:label-width="'auto'"
>
<el-form-item label="商品名称" prop="goodName">
<el-input
v-model="formInline.goodName"
placeholder="请输入商品名称"
clearable
/>
</el-form-item>
<el-form-item
label="商品分类"
prop="goodCategoryId"
class="custom-form-inline"
>
<!-- <el-select v-model="formInline.goodCategoryId" placeholder="请选择" clearable>
<el-option v-for="item in goodsCategoryList" :key="item.id" :value="item.id" :label="item.name" />
</el-select> -->
<el-cascader
v-model="formInline.goodCategoryId"
:options="goodsOptions"
:props="cascaderProps"
placeholder="请选择省市区"
clearable
/>
</el-form-item>
<!-- <el-form-item label="商品品牌" prop="storeId">
<el-select v-model="formInline.storeId" placeholder="请选择" clearable>
<el-option v-for="item in goodsBrandList" :key="item.id" :value="item.id" :label="item.name" />
</el-select>
</el-form-item> -->
</el-form>
</div>
<div class="search-bar-right">
<el-button type="primary" class="el-button-gry" icon="Search" @click="onSubmit"
>查询</el-button
>
<el-button
icon="Refresh"
style="margin: 16px 0 0 0"
@click="resetForm"
>重置</el-button
>
</div>
</div>
</div>
<!-- 表格 -->
<div class="table-cont" :style="{ height: tableViewportHeight + 'px' }">
<!-- <div class="table-toolbar">
<el-button
icon="delete"
@click="batchDelete"
:disabled="btnStatus"
style="margin-right: 10px"
>批量删除</el-button
>
<router-link to="/goods/goodsManage/addGoods">
<el-button type="primary" class="el-button-gry" icon="plus" @click="onSubmit"
>新增商品</el-button
>
</router-link>
</div> -->
<tableComponent
:table-data="tableData"
:columns="columns"
:show-border="false"
: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 #goodUrl="slotProps">
<div class="table-cell-img-box">
<img :src="slotProps.row.goodUrl" class="table-cell-img" alt="" />
</div>
</template>
<!-- 自定义 - 序号 -->
<template #sort="slotProps">
<span v-if="slotProps.row.goodPrice"
>{{ slotProps.row.goodPrice }}</span
>
</template>
<!-- 自定义-状态 -->
<template #examineStatus="slotProps">
<span v-if="slotProps.row.examineStatus == 0" class="color-red"
>待审核</span
>
<span v-else-if="slotProps.row.examineStatus == 1" class="color-green"
>审核成功</span
>
<span v-else-if="slotProps.row.examineStatus == 2" class="color-orange"
>驳回</span
>
</template>
<!-- 自定义-操作 -->
<template #action="slotProps">
<el-button
v-if="slotProps.row.examineStatus != 1"
text
class="el-button-custom"
@click="handleAudit(slotProps.row)"
>审核</el-button
>
<el-button
text
class="el-button-delete"
@click="handleDelete(slotProps.row)"
>删除</el-button
>
</template>
</tableComponent>
</div>
</div>
</div>
</template>
<script setup>
import { ref, reactive, computed, onMounted, onBeforeUnmount } from "vue";
import tableComponent from "@/components/tableComponent.vue";
import Mock from "mockjs";
import {
getGoodManageInfo,
getGoodType,
goodDelete,
getGoodManageCount,
goodUpAndDown,
} from "@/api/goods/info";
import { id } from "element-plus/es/locales.mjs";
import { ElMessage } from "element-plus";
const route = useRoute();
const router = useRouter();
const { proxy } = getCurrentInstance();
const formInline = reactive({
goodName: "",
goodCategoryId: [],
storeId: "",
// type: "1",
current: 1,
size: 10,
});
const goodsCategoryList = ref([
{ name: "蔬菜", id: 1 },
{ name: "肥料", id: 2 },
{ name: "农药", id: 3 },
]);
const goodsBrandList = ref([
{ name: "品牌1", id: 1 },
{ name: "品牌2", id: 2 },
{ name: "品牌3", id: 3 },
]);
const searchForm = ref(null);
const onSubmit = () => {
console.log("submit!");
formInline.current = 1;
console.log(formInline);
loadData();
};
const resetForm = () => {
searchForm.value.resetFields();
loadData();
};
let activeCurrent = ref("1");
let bottomList = reactive([
{ title: "全部", id: "1", value: "" },
{ title: "已上架", id: "2", value: "" },
{ title: "已下架", id: "3", value: "" },
]);
const tabChange = (Event) => {
console.log(Event.index);
if (Event.index == "0") {
//
formInline.type = "1";
} else if (Event.index == "1") {
//
formInline.type = "2";
} else if (Event.index == "2") {
//
formInline.type = "3";
}
loadData();
};
//
const tableData = ref([]);
const selectedIds = ref([]);
const btnStatus = computed(() => {
return selectedIds.value.length <= 0;
});
const tableLoading = ref(false);
const tableTotal = ref(0);
let nowClickRow = ref({});
//
const columns = ref([]);
const columns1 = ref([
{ prop: "goodId", label: "ID", width: "150" },
{ prop: "goodUrl", label: "商品图片", slotName: "goodUrl" },
{ prop: "goodName", label: "商品名称", width: "120" },
{ prop: "categoryName", label: "分类名称" },
{ prop: "goodPrice", label: "商品售价" },
{ prop: "salesVolume", label: "销量" },
{ prop: "pageView", label: "浏览量" },
{ prop: "stock", label: "库存" },
{ prop: "examineStatus", label: "状态", slotName: "examineStatus" },
{
prop: "action",
label: "操作",
slotName: "action",
fixed: "right",
width: "150",
},
]);
//
const generateFoodNickname = () => {
//
const foods = [
"辣椒",
"西瓜",
"土豆",
"番茄",
"黄瓜",
"苹果",
"蛋糕",
"面包",
"披萨",
"冰淇淋",
"奶茶",
"咖啡",
"啤酒",
"炸鸡",
];
// +
return Mock.mock(`@pick(${foods})`);
};
//
const generateMockData = () => {
return Mock.mock({
"list|10": [
{
"id|+1": 10000,
"goodId|+1": 10000,
"sort|+1": 1,
goodUrl: " @image", //
goodName: () => generateFoodNickname(), //
categoryName: '@pick(["蔬菜", "肥料", "农药"])', //
goodPrice: "@float(10, 200, 2, 2)", //
salesVolume: "@integer(1000, 20000)", //
pageView: Mock.mock("@id").toString().slice(0, 6), //
stock: "@integer(5000, 90000)", //
examineStatus: "@pick([0, 1, 2, 3, 4])", //
ordersNums: "@integer(10, 200)",
},
],
}).list;
};
//
const loadData = async () => {
tableLoading.value = true;
//
// tableData.value = generateMockData();
// tableTotal.value = tableData.value.length;
// console.log(tableData.value);
let prams = { ...formInline };
prams.goodCategoryId =
formInline.goodCategoryId[prams.goodCategoryId.length - 1];
try {
let response = await getGoodManageInfo(prams);
console.log(response);
if (response.code == 200) {
tableData.value = response.data.records;
tableTotal.value = response.data.total;
}
} catch (error) {
console.log(error);
}
tableLoading.value = false;
};
// ,columnsheaderClassName: 'custom-header'
const getHeaderClass = ({ column }) => {
return "custom-header";
};
//
const handlePaginationChange = ({ page, pageSize }) => {
console.log("分页变化:", page, pageSize);
formInline.current = page;
formInline.size = pageSize;
// API
loadData();
};
//
const handleSelectionChange = (selection, ids) => {
console.log("选中项:", selection, ids);
selectedIds.value = ids;
};
//
const seeDetails = (row) => {
nowClickRow.value = row;
console.log("要查看详情的行:", row);
};
const toUpload = async (row) => {
console.log("上架:", row);
goodsUpAndDown(row.goodId, 2);
};
const toDownload = (row) => {
console.log("下架:", row);
goodsUpAndDown(row.goodId, 3);
};
const goodsUpAndDown = async (id, examineStatus) => {
// 2->3->
let res = await goodUpAndDown({ id: id, examineStatus: examineStatus });
let text = examineStatus == 2 ? "上架" : "下架";
if (res.code == 200) {
ElMessage.success(`${text}成功`);
loadData();
} else {
ElMessage.error(res.msg);
}
};
//
const handleAudit = (row) => {
nowClickRow.value = row;
console.log("要编辑的行:", row);
// queryedit
router.push({
path: "/goods/goodsReview/auditGoods",
query: { goodId: row.goodId },
});
};
//
const handleDelete = async (row) => {
deleteGoods(row.goodId)
};
//
const batchDelete = async () => {
console.log("要删除的行:", selectedIds.value);
deleteGoods(selectedIds.value.join(","))
};
const deleteGoods = async (param) => {
try {
tableLoading.value = true;
let res = await goodDelete(param);
tableLoading.value = false;
if (res.code == 200) {
ElMessage.success("删除成功");
loadData();
} else {
ElMessage.error(res.msg);
}
} catch (error) {
tableLoading.value = false;
}
};
//
const cascaderProps = ref({
label: "name", //
value: "id", //
children: "children", //
emitPath: true,
expandTrigger: "hover",
});
const goodsOptions = ref([]);
const getGoodTypeList = async () => {
try {
let response = await getGoodType();
console.log(response);
if (response.code == 200) {
goodsOptions.value = response.data;
}
} catch (error) {
console.log(error);
}
};
const getGoodsManageCount = async () => {
try {
let response = await getGoodManageCount();
if (response.code == 200) {
bottomList[0].value = `(${response.data?.allGoodCount ?? ""})`;
bottomList[1].value = `(${response.data?.alreadyListedCount ?? ""})`;
bottomList[2].value = `(${response.data?.removedCount ?? ""})`;
}
} catch (error) {
console.log(error);
}
};
const titleRef = ref(null);
const searchBarRef = ref(null);
const tableViewportHeight = ref(0);
//
const calculateTableHeight = () => {
//
const windowHeight = window.innerHeight;
//
const headerHeight = titleRef.value?.$el?.offsetHeight || 0;
const searchBarHeight = searchBarRef.value?.offsetHeight || 0;
//
const paddingCompensation = 130;
//
tableViewportHeight.value =
windowHeight - headerHeight - searchBarHeight - paddingCompensation;
// console.log(tableViewportHeight.value);
};
//
onMounted(() => {
columns.value = columns1.value;
loadData();
getGoodTypeList();
// getGoodsManageCount();
calculateTableHeight();
//
window.addEventListener("resize", calculateTableHeight);
// DOMheader/searchbar
const observer = new ResizeObserver(calculateTableHeight);
if (titleRef.value?.$el) observer.observe(titleRef.value.$el);
if (searchBarRef.value) observer.observe(searchBarRef.value);
});
onBeforeUnmount(() => {
window.removeEventListener("resize", calculateTableHeight);
});
</script>
<style lang="scss" scoped>
.table-toolbar {
width: 300px;
height: 50px;
position: absolute;
right: 0;
top: 0;
display: flex;
justify-content: end;
padding: 14px 16px 0 0;
}
</style>