bibi 3 years ago
parent 6e58f4c30a
commit e070925cf8

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

@ -8,7 +8,7 @@
:columns="columns" :columns="columns"
:data-source="tableData" :data-source="tableData"
:pagination="pagination" :pagination="pagination"
:scroll="{ x: 1400 }" :scroll="{ x: 2400 }"
@change="handleTableChange" @change="handleTableChange"
:row-selection="{ :row-selection="{
selectedRowKeys: selectedRowKeys, selectedRowKeys: selectedRowKeys,
@ -24,8 +24,12 @@
<a-space> <a-space>
<a class="ant-dropdown-link" @click="onSell([row.id])"></a> <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="offSell([row.id])"></a>
<a class="ant-dropdown-link" @click="edit(row.id)"></a>
</a-space> </a-space>
</span> </span>
<span slot="mainPhoto" slot-scope="text, row">
<img :src="row.mainPhoto" class="table-img" alt="" />
</span>
</a-table> </a-table>
<div class="action"> <div class="action">
<a-dropdown :disabled="!hasSelected"> <a-dropdown :disabled="!hasSelected">
@ -41,20 +45,36 @@
</template> </template>
</span> </span>
</div> </div>
<addForm
:show="drawer.show"
@success="success"
@addClose="addClose"
:goodsId="goodsId"
></addForm>
</div> </div>
</template> </template>
<script> <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 { shopPushList,offShelf,onShelf} from "@/api/shop/goods";
import addForm from "./depend/form.vue";
export default { export default {
components: {
addForm,
},
data() { data() {
return { return {
drawer: {
show: false,
},
searchForm: { searchForm: {
skuId:undefined, skuId: undefined,
skuName:undefined skuName: undefined,
}, },
columns,pagination,formItem, columns,
goodsId:null,
pagination,
formItem,
tableData: [], tableData: [],
selectedRowKeys: [], selectedRowKeys: [],
}; };
@ -90,6 +110,10 @@ export default {
this.pagination = pager; this.pagination = pager;
this.getData(); this.getData();
}, },
edit(id) {
this.goodsId = id;
this.drawer.show = true;
},
onSell(ids) { onSell(ids) {
console.log(ids); console.log(ids);
this.$confirm({ this.$confirm({
@ -126,10 +150,17 @@ export default {
console.log(data); console.log(data);
if (data.key === "on") { if (data.key === "on") {
this.onSell(this.selectedRowKeys); this.onSell(this.selectedRowKeys);
}else if(data.key === "off"){ } else if (data.key === "off") {
this.offSell(this.selectedRowKeys); this.offSell(this.selectedRowKeys);
} }
}, },
addClose() {
this.drawer.show = false;
this.goodsId = null;
},
success() {
this.getData();
},
}, },
computed: { computed: {
hasSelected() { hasSelected() {
@ -139,4 +170,9 @@ export default {
}; };
</script> </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%", width: "8%",
dataIndex: "skuName", dataIndex: "skuName",
}, },
{
title: "主图url",
width: "4%",
dataIndex: "mainPhoto",
scopedSlots: { customRender: "mainPhoto"}
},
{ {
title: "sku编码", title: "sku编码",
width: "8%", width: "8%",
@ -71,11 +77,6 @@ export const columns = [
} }
} }
}, },
{
title: "主图url",
width: "8%",
dataIndex: "mainPhoto",
},
{ {
title: "供货价", title: "供货价",
width: "5%", width: "5%",

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

@ -1,10 +1,10 @@
<template> <template>
<div> <div>
<a-drawer <a-drawer
:title="title" title="jcook商品上架推送"
:width="720" :width="720"
:visible="show" :visible="show"
:body-style="{ paddingBottom: '80px' }" :body-style="{ paddingBottom: '60px' }"
@close="addClose" @close="addClose"
> >
<div class="drawer-content"> <div class="drawer-content">
@ -17,63 +17,82 @@
layout="vertical" layout="vertical"
> >
<a-row> <a-row>
<a-col :span="12"> <a-form-model-item prop="defaultSkuName" label="使用默认商品名称">
<a-form-model-item prop="title" label="标题"> <a-switch v-model="form.defaultSkuName"></a-switch>
<a-input
v-model="form.title"
placeholder="请输入标题"
style="width: 80%"
></a-input>
</a-form-model-item> </a-form-model-item>
</a-col> <a-form-model-item
<a-col :span="12"> v-if="form.defaultSkuName === false"
<a-form-model-item prop="categoryId" label="资讯分类"> prop="skuName"
<a-select label="自定义商品名称"
v-model="form.categoryId"
placeholder="请选择"
style="width: 80%"
> >
<a-select-option <a-input v-model="form.skuName" style="width: 60%"></a-input>
v-for="item in options.categoryId" </a-form-model-item>
:key="item.id" <a-form-model-item prop="defaultShopName" label="使用默认店铺">
:value="item.id" <a-switch v-model="form.defaultShopName"></a-switch>
>{{ item.name }}</a-select-option </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-select>
</a-form-model-item> </a-form-model-item>
</a-col> <a-form-model-item prop="defaultVendorName" label="使用默认供应商">
<a-col :span="12"> <a-switch v-model="form.defaultVendorName"></a-switch>
<a-form-model-item prop="status" label="发布状态"> </a-form-model-item>
<a-select <a-form-model-item
v-model="form.status" v-if="form.defaultVendorName === false"
placeholder="请选择" prop="vendorId"
style="width: 80%" label="自定义选择供应商"
> >
<a-select-option <a-select v-model="form.vendorId" style="width: 60%">
v-for="item in options.status" <a-select-option v-for="item in options.vendor" :key="item.id" :value="item.id">{{item.name}}</a-select-option>
:key="item.id" </a-select>
:value="item.id" </a-form-model-item>
>{{ item.name }}</a-select-option <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-select>
</a-form-model-item> </a-form-model-item>
</a-col> <a-form-model-item prop="defaultCategoryName" label="使用默认分类">
<a-col :span="24"> <a-switch v-model="form.defaultCategoryName"></a-switch>
<a-form-model-item prop="content" label="内容"> </a-form-model-item>
<a-textarea <a-form-model-item
v-model="form.content" v-if="form.defaultCategoryName === false"
placeholder="请输入内容" prop="cateValue"
style="width: 80%" label="自定义选择分类"
></a-textarea> >
<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-form-model-item>
</a-col>
<a-col :span="24">
资讯封面图片
<commonUpload
:fileList="fileList"
@handleChange="handleChange"
></commonUpload>
</a-col>
</a-row> </a-row>
</a-form-model> </a-form-model>
</div> </div>
@ -89,61 +108,58 @@
<script> <script>
import { form, rules, options } from "./form.js"; import { form, rules, options } from "./form.js";
import { import { cateSelect,shopSelect,vendorSelect,brandSelect,jcookGoodsPush } from "@/api/shop/goods"
newsInsert,
newsUpdate,
newsInfo,
itemSelect
} from "@/api/operation/news/index.js";
export default { export default {
props: { props: {
show: { show: {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
editId: Number, goodsId: Number,
}, },
data() { data() {
return { return {
title: "新增资讯",
form, form,
rules, rules,
options, options,
fileList: [], fileList: [],
cateValue: [],
}; };
}, },
mounted() { mounted() {
this.getItem(); // this.getItem();
}, },
methods: { methods: {
async getItem() { getItem() {
let res = await itemSelect(); //
this.options.categoryId = res.data; 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() { addClose() {
this.$refs.ruleForm.resetFields(); this.$refs.ruleForm.resetFields();
this.fileList = []; this.form.categoryFirstId = undefined;
this.form.imgUrls = []; this.form.categorySecondId = undefined;
this.form.categoryThirdId = undefined;
this.cateValue = [];
this.$emit("addClose"); this.$emit("addClose");
}, },
success() { success() {
this.$emit("success"); this.$emit("success");
this.addClose(); this.addClose();
}, },
change(data) {
this.form.categoryFirstId = data[0];
this.form.categorySecondId = data[1];
this.form.categoryThirdId = data[2];
},
submit() { submit() {
this.$refs.ruleForm.validate(async (valid) => { this.$refs.ruleForm.validate(async (valid) => {
if (valid) { if (valid) {
if (this.editId === null) { let res = await jcookGoodsPush(this.form);
let res = await newsInsert(this.form);
if (res.code === 200) {
this.$message.success(res.msg);
this.success();
} else {
this.$message.error(res.msg);
}
} else {
console.log(this.form);
let res = await newsUpdate(this.form);
if (res.code === 200) { if (res.code === 200) {
this.$message.success(res.msg); this.$message.success(res.msg);
this.success(); this.success();
@ -151,48 +167,17 @@ export default {
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: { watch: {
editId: { goodsId: {
handler(val) { handler(val) {
if (val !== null) { if (val !== null) {
this.title = "修改资讯";
this.form.id = val; 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"> <span slot="action" slot-scope="text, row">
<a-space> <a-space>
<a class="ant-dropdown-link" @click="push(row)"></a> <a class="ant-dropdown-link" @click="push(row.id)"></a>
</a-space> </a-space>
</span>
<span slot="mainPhoto" slot-scope="text, row">
<img
:src="row.mainPhoto"
class="table-img"
alt=""
/>
</span> </span>
</a-table> </a-table>
<div class="action"> <div class="action">
@ -41,7 +48,7 @@
:show="drawer.show" :show="drawer.show"
@success="success" @success="success"
@addClose="addClose" @addClose="addClose"
:editId="editId" :goodsId="goodsId"
></addForm> ></addForm>
</div> </div>
</template> </template>
@ -58,9 +65,8 @@ export default {
return { return {
drawer: { drawer: {
show: false, show: false,
detail:false
}, },
editId: null, goodsId: null,
tableData: [], tableData: [],
searchForm: { searchForm: {
jcookSkuId:'', jcookSkuId:'',
@ -96,8 +102,8 @@ export default {
this.pagination.total = res.data.total; this.pagination.total = res.data.total;
this.selectedRowKeys=[] this.selectedRowKeys=[]
}, },
edit(id) { push(id) {
this.editId = id; this.goodsId = id;
this.drawer.show = true; this.drawer.show = true;
}, },
handleMenuClick(data) { handleMenuClick(data) {
@ -135,7 +141,7 @@ export default {
}, },
addClose() { addClose() {
this.drawer.show = false; this.drawer.show = false;
this.editId = null; this.goodsId = null;
}, },
success() { success() {
this.getData(); this.getData();

Loading…
Cancel
Save