bibi 3 years ago
parent 6e58f4c30a
commit e070925cf8

@ -36,4 +36,58 @@ export function jcookGoodsBatchPush(params) {
method: 'post',
data: params,
})
}
export function jcookGoodsPush(params) {
return httpService({
url: `/user/shop/jcookGoodsPush`,
method: 'post',
data: params,
})
}
export function goodsEdit(params) {
return httpService({
url: `/user/shop/update`,
method: 'post',
data: params,
})
}
export function goodsInfo(params) {
return httpService({
url: `/user/shop/findById`,
method: 'get',
params: params,
})
}
// 分类
export function cateSelect(params) {
return httpService({
url: `/user/shopCategory/listAll`,
method: 'get',
params: params,
})
}
// 店铺
export function shopSelect(params) {
return httpService({
url: `/user/shop/?`,
method: 'get',
params: params,
})
}
// 供应商
export function vendorSelect(params) {
return httpService({
url: `/user/shop/?`,
method: 'get',
params: params,
})
}
// 品牌
export function brandSelect(params) {
return httpService({
url: `/user/shop/?`,
method: 'get',
params: params,
})
}

@ -4,14 +4,20 @@ export const columns = [
width: "12%",
dataIndex: "skuName",
},
{
title: "主图url",
width: "4%",
dataIndex: "mainPhoto",
scopedSlots: { customRender: "mainPhoto"}
},
{
title: "sku编码",
width: "12%",
width: "10%",
dataIndex: "skuId",
},
{
title: "商品类型",
width: "7%",
width: "4%",
dataIndex: "mallType",
customRender: function (mallType) {
switch (mallType) {
@ -40,44 +46,39 @@ export const columns = [
},
{
title: "一级分类名称",
width: "8%",
width: "6%",
dataIndex: "categoryFirstName",
},
{
title: "二级分类名称",
width: "8%",
width: "6%",
dataIndex: "categorySecondName",
},
{
title: "三级分类名称",
width: "8%",
width: "6%",
dataIndex: "categoryThirdName",
},
{
title: "主图url",
width: "8%",
dataIndex: "mainPhoto",
},
{
title: "售卖价",
width: "8%",
width: "4%",
dataIndex: "sellPrice",
},
{
title: "折扣价",
width: "8%",
width: "4%",
dataIndex: "discountPrice",
},
{
title: "浏览量",
width: "8%",
width: "5%",
dataIndex: "viewsNum",
},
{
title: "操作",
dataIndex: "action",
key: "action",
width: "180",
width: "250",
fixed: "right",
scopedSlots: { customRender: "action" },
},

@ -0,0 +1,29 @@
export const form = {
id:undefined,
status:undefined,
skuName:undefined,
shopId:undefined,
vendorId:undefined,
brandId:undefined,
categoryFirstId:undefined,
categorySecondId:undefined,
categoryThirdId:undefined,
sellPrice:undefined,
discountPrice:undefined,
}
export const rules = {
skuName:[{required:true,message:'请输入',trigger:'blur'}],
shopId:[{required:true,message:'请选择',trigger:'change'}],
status:[{required:true,message:'请选择',trigger:'change'}],
vendorId:[{required:true,message:'请选择',trigger:'change'}],
brandId: [{ required: true, message: '请选择', trigger: 'change' }],
cateValue: [{ required: true, message: '请选择', trigger: 'change',type: 'array'}],
sellPrice:[{required:true,message:'请输入',trigger:'blur'}],
discountPrice:[{required:true,message:'请输入',trigger:'blur'}],
}
export const options = {
cate:[],
shop: [],
vendor: [],
brand:[],
}

@ -0,0 +1,189 @@
<template>
<div>
<a-drawer
title="jcook商品上架推送"
:width="720"
:visible="show"
:body-style="{ paddingBottom: '60px' }"
@close="addClose"
>
<div class="drawer-content">
基本信息
<a-divider></a-divider>
<a-form-model
ref="ruleForm"
:model="form"
:rules="rules"
layout="vertical"
>
<a-row>
<a-form-model-item prop="defaultSkuName" label="使用默认商品名称">
<a-switch v-model="form.defaultSkuName"></a-switch>
</a-form-model-item>
<a-form-model-item
v-if="form.defaultSkuName === false"
prop="skuName"
label="自定义商品名称"
>
<a-input v-model="form.skuName" style="width: 60%"></a-input>
</a-form-model-item>
<a-form-model-item prop="defaultShopName" label="使用默认店铺">
<a-switch v-model="form.defaultShopName"></a-switch>
</a-form-model-item>
<a-form-model-item
v-if="form.defaultShopName === false"
prop="shopId"
label="自定义选择店铺"
>
<a-select v-model="form.shopId" style="width: 60%">
<a-select-option v-for="item in options.shop" :key="item.id" :value="item.id">{{item.name}}</a-select-option>
</a-select>
</a-form-model-item>
<a-form-model-item prop="defaultVendorName" label="使用默认供应商">
<a-switch v-model="form.defaultVendorName"></a-switch>
</a-form-model-item>
<a-form-model-item
v-if="form.defaultVendorName === false"
prop="vendorId"
label="自定义选择供应商"
>
<a-select v-model="form.vendorId" style="width: 60%">
<a-select-option v-for="item in options.vendor" :key="item.id" :value="item.id">{{item.name}}</a-select-option>
</a-select>
</a-form-model-item>
<a-form-model-item prop="defaultBrandName" label="使用默认品牌">
<a-switch v-model="form.defaultBrandName"></a-switch>
</a-form-model-item>
<a-form-model-item
v-if="form.defaultBrandName === false"
prop="brandId"
label="自定义选择品牌"
>
<a-select v-model="form.brandId" style="width: 60%">
<a-select-option v-for="item in options.brand" :key="item.id" :value="item.id">{{item.name}}</a-select-option>
</a-select>
</a-form-model-item>
<a-form-model-item prop="defaultCategoryName" label="使用默认分类">
<a-switch v-model="form.defaultCategoryName"></a-switch>
</a-form-model-item>
<a-form-model-item
v-if="form.defaultCategoryName === false"
prop="cateValue"
label="自定义选择分类"
>
<a-cascader
v-model="cateValue"
:options="options.cate"
placeholder="请选择分类"
:field-names="{
label: 'name',
value: 'id',
children: 'shopCategoryVoList',
}"
@change="change"
style="width: 60%"
></a-cascader>
</a-form-model-item>
<a-form-model-item prop="sellPrice" label="售卖价">
<a-input v-model="form.sellPrice" style="width: 60%"></a-input>
</a-form-model-item>
<a-form-model-item prop="discountPrice" label="划线价">
<a-input
v-model="form.discountPrice"
style="width: 60%"
></a-input>
</a-form-model-item>
</a-row>
</a-form-model>
</div>
<div class="drawer-footer">
<a-button :style="{ marginRight: '8px' }" @click="addClose">
关闭
</a-button>
<a-button type="primary" @click="submit"> </a-button>
</div>
</a-drawer>
</div>
</template>
<script>
import { form, rules, options } from "./form.js";
import { cateSelect,shopSelect,vendorSelect,brandSelect,goodsEdit,goodsInfo } from "@/api/shop/goods"
export default {
props: {
show: {
type: Boolean,
default: false,
},
goodsId: Number,
},
data() {
return {
form,
rules,
options,
fileList: [],
cateValue: [],
};
},
mounted() {
// this.getItem();
},
methods: {
getItem() {
//
Promise.all([cateSelect(),shopSelect(),vendorSelect(),brandSelect()]).then(res=>{
this.options.cate = res[0].data
this.options.shop = res[1].data
this.options.vendor = res[2].data
this.options.brand = res[3].data
})
},
addClose() {
this.$refs.ruleForm.resetFields();
this.form.categoryFirstId = undefined;
this.form.categorySecondId = undefined;
this.form.categoryThirdId = undefined;
this.cateValue = [];
this.$emit("addClose");
},
success() {
this.$emit("success");
this.addClose();
},
change(data) {
this.form.categoryFirstId = data[0];
this.form.categorySecondId = data[1];
this.form.categoryThirdId = data[2];
},
submit() {
this.$refs.ruleForm.validate(async (valid) => {
if (valid) {
let res = await goodsEdit(this.form);
if (res.code === 200) {
this.$message.success(res.msg);
this.success();
} else {
this.$message.error(res.msg);
}
}
});
},
},
watch: {
goodsId: {
handler(val) {
if (val !== null) {
this.form.id = val;
goodsInfo({appGoodsPushId:val}).then(res=>{
this.form = res.data
})
}
},
immediate: true,
},
},
};
</script>
<style></style>

@ -1,14 +1,14 @@
<template>
<div>
<div class="cardTitle">
<span>商品管理</span>
</div>
<div class="cardTitle">
<span>商品管理</span>
</div>
<searchForm :formItem="formItem" @getSearch="getData($event)"></searchForm>
<a-table
:columns="columns"
:data-source="tableData"
:pagination="pagination"
:scroll="{ x: 1400 }"
:scroll="{ x: 2400 }"
@change="handleTableChange"
:row-selection="{
selectedRowKeys: selectedRowKeys,
@ -20,14 +20,18 @@
}
"
>
<span slot="action" slot-scope="text, row">
<a-space>
<a class="ant-dropdown-link" @click="onSell([row.id])"></a>
<a class="ant-dropdown-link" @click="offSell([row.id])"></a>
</a-space>
</span>
<span slot="action" slot-scope="text, row">
<a-space>
<a class="ant-dropdown-link" @click="onSell([row.id])"></a>
<a class="ant-dropdown-link" @click="offSell([row.id])"></a>
<a class="ant-dropdown-link" @click="edit(row.id)"></a>
</a-space>
</span>
<span slot="mainPhoto" slot-scope="text, row">
<img :src="row.mainPhoto" class="table-img" alt="" />
</span>
</a-table>
<div class="action">
<div class="action">
<a-dropdown :disabled="!hasSelected">
<a-menu slot="overlay" @click="handleMenuClick">
<a-menu-item key="on"> 批量上架 </a-menu-item>
@ -41,20 +45,36 @@
</template>
</span>
</div>
<addForm
:show="drawer.show"
@success="success"
@addClose="addClose"
:goodsId="goodsId"
></addForm>
</div>
</template>
<script>
import { columns,pagination,formItem } from "./depend/config.js";
import { columns, pagination, formItem } from "./depend/config.js";
import { shopPushList,offShelf,onShelf} from "@/api/shop/goods";
import addForm from "./depend/form.vue";
export default {
components: {
addForm,
},
data() {
return {
drawer: {
show: false,
},
searchForm: {
skuId:undefined,
skuName:undefined
skuId: undefined,
skuName: undefined,
},
columns,pagination,formItem,
columns,
goodsId:null,
pagination,
formItem,
tableData: [],
selectedRowKeys: [],
};
@ -90,6 +110,10 @@ export default {
this.pagination = pager;
this.getData();
},
edit(id) {
this.goodsId = id;
this.drawer.show = true;
},
onSell(ids) {
console.log(ids);
this.$confirm({
@ -126,10 +150,17 @@ export default {
console.log(data);
if (data.key === "on") {
this.onSell(this.selectedRowKeys);
}else if(data.key === "off"){
} else if (data.key === "off") {
this.offSell(this.selectedRowKeys);
}
},
addClose() {
this.drawer.show = false;
this.goodsId = null;
},
success() {
this.getData();
},
},
computed: {
hasSelected() {
@ -139,4 +170,9 @@ export default {
};
</script>
<style lang="less" scoped></style>
<style lang="less" scoped>
.table-img {
width: 40px;
height: 40px;
}
</style>

@ -4,6 +4,12 @@ export const columns = [
width: "8%",
dataIndex: "skuName",
},
{
title: "主图url",
width: "4%",
dataIndex: "mainPhoto",
scopedSlots: { customRender: "mainPhoto"}
},
{
title: "sku编码",
width: "8%",
@ -71,11 +77,6 @@ export const columns = [
}
}
},
{
title: "主图url",
width: "8%",
dataIndex: "mainPhoto",
},
{
title: "供货价",
width: "5%",

@ -1,21 +1,32 @@
export const form = {
id:undefined,
title:undefined,
categoryId:undefined,
status:undefined,
content:undefined,
imgUrls:[]
defaultSkuName:true,
defaultShopName: true,
defaultVendorName:true,
defaultBrandName:true,
defaultCategoryName:true,
skuName:undefined,
shopId:undefined,
vendorId:undefined,
brandId:undefined,
categoryFirstId:undefined,
categorySecondId:undefined,
categoryThirdId:undefined,
sellPrice:undefined,
discountPrice:undefined,
}
export const rules = {
title:[{required:true,message:'请输入标题',trigger:'blur'}],
categoryId:[{required:true,message:'请选择分类',trigger:'change'}],
status:[{required:true,message:'请选择',trigger:'change'}],
content:[{required:true,message:'请输入',trigger:'blur'}],
skuName:[{required:true,message:'请输入',trigger:'blur'}],
shopId:[{required:true,message:'请选择',trigger:'change'}],
vendorId:[{required:true,message:'请选择',trigger:'change'}],
brandId: [{ required: true, message: '请选择', trigger: 'change' }],
cateValue: [{ required: true, message: '请选择', trigger: 'change',type: 'array'}],
sellPrice:[{required:true,message:'请输入',trigger:'blur'}],
discountPrice:[{required:true,message:'请输入',trigger:'blur'}],
}
export const options = {
status:[
{ id:1, name:'未发布' },
{ id:2, name:'已发布' },
],
categoryId:[]
}
cate:[],
shop: [],
vendor: [],
brand:[],
}

@ -1,10 +1,10 @@
<template>
<div>
<a-drawer
:title="title"
title="jcook商品上架推送"
:width="720"
:visible="show"
:body-style="{ paddingBottom: '80px' }"
:body-style="{ paddingBottom: '60px' }"
@close="addClose"
>
<div class="drawer-content">
@ -17,63 +17,82 @@
layout="vertical"
>
<a-row>
<a-col :span="12">
<a-form-model-item prop="title" label="标题">
<a-input
v-model="form.title"
placeholder="请输入标题"
style="width: 80%"
></a-input>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item prop="categoryId" label="资讯分类">
<a-select
v-model="form.categoryId"
placeholder="请选择"
style="width: 80%"
>
<a-select-option
v-for="item in options.categoryId"
:key="item.id"
:value="item.id"
>{{ item.name }}</a-select-option
>
</a-select>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item prop="status" label="发布状态">
<a-select
v-model="form.status"
placeholder="请选择"
style="width: 80%"
>
<a-select-option
v-for="item in options.status"
:key="item.id"
:value="item.id"
>{{ item.name }}</a-select-option
>
</a-select>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item prop="content" label="内容">
<a-textarea
v-model="form.content"
placeholder="请输入内容"
style="width: 80%"
></a-textarea>
</a-form-model-item>
</a-col>
<a-col :span="24">
资讯封面图片
<commonUpload
:fileList="fileList"
@handleChange="handleChange"
></commonUpload>
</a-col>
<a-form-model-item prop="defaultSkuName" label="使用默认商品名称">
<a-switch v-model="form.defaultSkuName"></a-switch>
</a-form-model-item>
<a-form-model-item
v-if="form.defaultSkuName === false"
prop="skuName"
label="自定义商品名称"
>
<a-input v-model="form.skuName" style="width: 60%"></a-input>
</a-form-model-item>
<a-form-model-item prop="defaultShopName" label="使用默认店铺">
<a-switch v-model="form.defaultShopName"></a-switch>
</a-form-model-item>
<a-form-model-item
v-if="form.defaultShopName === false"
prop="shopId"
label="自定义选择店铺"
>
<a-select v-model="form.shopId" style="width: 60%">
<a-select-option v-for="item in options.shop" :key="item.id" :value="item.id">{{item.name}}</a-select-option>
</a-select>
</a-form-model-item>
<a-form-model-item prop="defaultVendorName" label="使用默认供应商">
<a-switch v-model="form.defaultVendorName"></a-switch>
</a-form-model-item>
<a-form-model-item
v-if="form.defaultVendorName === false"
prop="vendorId"
label="自定义选择供应商"
>
<a-select v-model="form.vendorId" style="width: 60%">
<a-select-option v-for="item in options.vendor" :key="item.id" :value="item.id">{{item.name}}</a-select-option>
</a-select>
</a-form-model-item>
<a-form-model-item prop="defaultBrandName" label="使用默认品牌">
<a-switch v-model="form.defaultBrandName"></a-switch>
</a-form-model-item>
<a-form-model-item
v-if="form.defaultBrandName === false"
prop="brandId"
label="自定义选择品牌"
>
<a-select v-model="form.brandId" style="width: 60%">
<a-select-option v-for="item in options.brand" :key="item.id" :value="item.id">{{item.name}}</a-select-option>
</a-select>
</a-form-model-item>
<a-form-model-item prop="defaultCategoryName" label="使用默认分类">
<a-switch v-model="form.defaultCategoryName"></a-switch>
</a-form-model-item>
<a-form-model-item
v-if="form.defaultCategoryName === false"
prop="cateValue"
label="自定义选择分类"
>
<a-cascader
v-model="cateValue"
:options="options.cate"
placeholder="请选择分类"
:field-names="{
label: 'name',
value: 'id',
children: 'shopCategoryVoList',
}"
@change="change"
style="width: 60%"
></a-cascader>
</a-form-model-item>
<a-form-model-item prop="sellPrice" label="售卖价">
<a-input v-model="form.sellPrice" style="width: 60%"></a-input>
</a-form-model-item>
<a-form-model-item prop="discountPrice" label="划线价">
<a-input
v-model="form.discountPrice"
style="width: 60%"
></a-input>
</a-form-model-item>
</a-row>
</a-form-model>
</div>
@ -89,110 +108,76 @@
<script>
import { form, rules, options } from "./form.js";
import {
newsInsert,
newsUpdate,
newsInfo,
itemSelect
} from "@/api/operation/news/index.js";
import { cateSelect,shopSelect,vendorSelect,brandSelect,jcookGoodsPush } from "@/api/shop/goods"
export default {
props: {
show: {
type: Boolean,
default: false,
},
editId: Number,
goodsId: Number,
},
data() {
return {
title: "新增资讯",
form,
rules,
options,
fileList: [],
cateValue: [],
};
},
mounted() {
this.getItem();
// this.getItem();
},
methods: {
async getItem() {
let res = await itemSelect();
this.options.categoryId = res.data;
getItem() {
//
Promise.all([cateSelect(),shopSelect(),vendorSelect(),brandSelect()]).then(res=>{
this.options.cate = res[0].data
this.options.shop = res[1].data
this.options.vendor = res[2].data
this.options.brand = res[3].data
})
},
addClose() {
this.$refs.ruleForm.resetFields();
this.fileList = [];
this.form.imgUrls = [];
this.form.categoryFirstId = undefined;
this.form.categorySecondId = undefined;
this.form.categoryThirdId = undefined;
this.cateValue = [];
this.$emit("addClose");
},
success() {
this.$emit("success");
this.addClose();
},
change(data) {
this.form.categoryFirstId = data[0];
this.form.categorySecondId = data[1];
this.form.categoryThirdId = data[2];
},
submit() {
this.$refs.ruleForm.validate(async (valid) => {
if (valid) {
if (this.editId === null) {
let res = await newsInsert(this.form);
if (res.code === 200) {
this.$message.success(res.msg);
this.success();
} else {
this.$message.error(res.msg);
}
let res = await jcookGoodsPush(this.form);
if (res.code === 200) {
this.$message.success(res.msg);
this.success();
} else {
console.log(this.form);
let res = await newsUpdate(this.form);
if (res.code === 200) {
this.$message.success(res.msg);
this.success();
} else {
this.$message.error(res.msg);
}
this.$message.error(res.msg);
}
}
});
},
handleChange(data) {
this.fileList = data;
if (data[0].status === "done") {
console.log("-------done-------");
this.form.imgUrls.push(data[0].response.data);
}
},
},
watch: {
editId: {
goodsId: {
handler(val) {
if (val !== null) {
this.title = "修改资讯";
this.form.id = val;
newsInfo({ informationId: val }).then((res) => {
this.form = res.data;
if (res.data.imgList.length > 0) {
console.log(res.data.imgList);
const pic = [];
for (let item of res.data.imgList) {
let obj = {
name: item.url.split("_")[0] + "." + item.url.split(".")[1],
url: this.$ImgUrl(item.url),
uid: item.url.split("_")[1],
status: "done",
thumbUrl: this.$ImgUrl(item.url),
};
pic.push(obj);
}
this.fileList = pic;
} else {
this.form.imgUrls = [];
}
});
} else {
this.title = "新增资讯";
}
},
// immediate: true,
immediate: true,
},
},
};

@ -20,8 +20,15 @@
>
<span slot="action" slot-scope="text, row">
<a-space>
<a class="ant-dropdown-link" @click="push(row)"></a>
<a class="ant-dropdown-link" @click="push(row.id)"></a>
</a-space>
</span>
<span slot="mainPhoto" slot-scope="text, row">
<img
:src="row.mainPhoto"
class="table-img"
alt=""
/>
</span>
</a-table>
<div class="action">
@ -41,7 +48,7 @@
:show="drawer.show"
@success="success"
@addClose="addClose"
:editId="editId"
:goodsId="goodsId"
></addForm>
</div>
</template>
@ -58,9 +65,8 @@ export default {
return {
drawer: {
show: false,
detail:false
},
editId: null,
goodsId: null,
tableData: [],
searchForm: {
jcookSkuId:'',
@ -96,8 +102,8 @@ export default {
this.pagination.total = res.data.total;
this.selectedRowKeys=[]
},
edit(id) {
this.editId = id;
push(id) {
this.goodsId = id;
this.drawer.show = true;
},
handleMenuClick(data) {
@ -135,7 +141,7 @@ export default {
},
addClose() {
this.drawer.show = false;
this.editId = null;
this.goodsId = null;
},
success() {
this.getData();

Loading…
Cancel
Save