Browse Source

管理商品修改

master
wangfukang 1 month ago
parent
commit
60894726b8
  1. 22
      src/api/app.js
  2. 2
      src/views/app/shop/addType.vue
  3. 315
      src/views/app/shop/dictManage.vue
  4. 7
      src/views/app/shop/editDictType.vue
  5. 2
      src/views/app/shop/shop.vue

22
src/api/app.js

@ -65,7 +65,22 @@ export const categoryList = (params) => {
export const categorySonList = (params) => {
return getRequest('/app/productAttributeValue/selectByAttributeId', params)
}
//上架商品
export const productUp = (params) => {
return postRequest('/app/product/up', params)
}
//下架商品
export const productDown = (params) => {
return postRequest('/app/product/down', params)
}
//是否设为推荐商品
export const productisPush = (params) => {
return postRequest('/app/product/isPush', params)
}
//是否设为推荐商品
export const productisMust = (params) => {
return postRequest('/app/product/isMust', params)
}
//新增商品
export const productSave = (params) => {
return postBodyRequest('/app/product/save', params)
@ -75,6 +90,11 @@ export const productEdit = (params) => {
return postBodyRequest('/app/product/edit', params)
}
//删除商品
export const productDelete = (params) => {
return postRequest('/app/product/delById', params)
}
//商品列表
export const getShareList = (params) => {
return postBodyRequest('/app/product/getShareList', params)

2
src/views/app/shop/addType.vue

@ -52,7 +52,7 @@
trigger: "blur"
}],
sort: [{
required: true,
required: false,
type: "number",
message: "请输入排序值",
trigger: "blur",

315
src/views/app/shop/dictManage.vue

@ -90,16 +90,10 @@
<Col :span="span">
<Row v-show="openSearch" @keydown.enter.native="handleSearch">
<Form ref="searchForm" :model="searchForm" inline :label-width="70">
<FormItem label="数据名称" prop="title">
<Input type="text" v-model="searchForm.title" placeholder="请输入" clearable
<FormItem label="商品名称" prop="title">
<Input type="text" v-model="searchForm.productName" placeholder="请输入" clearable
style="width: 200px" />
</FormItem>
<FormItem label="状态" prop="status">
<Select v-model="searchForm.status" placeholder="请选择" clearable style="width: 200px">
<Option value="0">正常</Option>
<Option value="-1">禁用</Option>
</Select>
</FormItem>
<FormItem style="margin-left: -35px" class="br">
<Button @click="handleSearch" type="primary" icon="ios-search">搜索</Button>
<Button @click="handleReset">重置</Button>
@ -109,7 +103,6 @@
<Row align="middle" justify="space-between" class="operation">
<div>
<Button @click="add" type="primary" icon="md-add">新增商品</Button>
<Button @click="delAll" icon="md-trash">批量删除</Button>
</div>
<div class="icons">
<Tooltip content="刷新" placement="top" transfer>
@ -178,8 +171,8 @@
<div>
<div v-for="(item,index) in addGoodsForm.attributeListPrice" style="display: flex;margin-top:5px;">
<Input v-model="item.specName" v-if="item.specName != ''&& addGoodsForm.attributeListPrice.length != 1" style="padding-right: 10px;" disabled />
<Input v-model="item.specPrice" style="padding-right: 10px;" placeholder="商品价格" />
<Input v-model="item.specNum" style="padding-right: 10px;" placeholder="商品库存"/>
<Input v-model="item.specPrice" style="padding-right: 10px;" @click="changePrice(index)" placeholder="商品价格" />
<Input v-model="item.specNum" style="padding-right: 10px;" @click="changecount(index)" placeholder="商品库存"/>
<button @click="deldantiaoguige(index)" v-if="addGoodsForm.attributeListPrice.length>1" style="width: 120px;height: 30px;line-height: 30px;color: red;border:none;background: #fff;">删除</button>
</div>
<div @click="checkSpec('guige')" style="margin-top:5px;width: 80px;height: 30px;text-align: center;line-height: 30px;background: #008ba0;color:#fff;">
@ -291,7 +284,12 @@
categorySonList,
productSave,
getShareList,
productEdit
productEdit,
productDelete,
productisMust,
productisPush,
productUp,
productDown
} from "@/api/app";
import addType from "./addType.vue";
import editDictType from "./editDictType.vue";
@ -408,7 +406,7 @@
{
title: "图片",
key: "productPicture",
minWidth: 160,
minWidth: 60,
render: (h, params) => {
return h("img", {
attrs: {
@ -432,12 +430,12 @@
{
title: "名称",
key: "productName",
minWidth: 160,
minWidth: 60,
},
{
title: "起售数量",
key: "startPayNum",
width: 150,
width: 100,
},
// {
// title: "",
@ -470,10 +468,82 @@
{
title: "操作",
key: "action",
width: 150,
width: 350,
align: "center",
fixed: "right",
render: (h, params) => {
let enableOrdelFlag = "";
if(params.row.delFlag ==0){
enableOrdelFlag = h(
"a", {
on: {
click: () => {
this.upDown(params.row,1);
},
},
},
"上架"
);
}else{
enableOrdelFlag = h(
"a", {
on: {
click: () => {
this.upDown(params.row,0);
},
},
},
"下架"
);
}
let enableOrisPush = "";
if(params.row.isPush ==0){
enableOrisPush = h(
"a", {
on: {
click: () => {
this.isPush(params.row,1);
},
},
},
"设为推荐"
);
}else{
enableOrisPush = h(
"a", {
on: {
click: () => {
this.isPush(params.row,0);
},
},
},
"取消推荐"
);
}
let enableOrisMust = "";
if(params.row.isMust ==0){
enableOrisMust = h(
"a", {
on: {
click: () => {
this.isMust(params.row,1);
},
},
},
"设为必点"
);
}else{
enableOrisMust = h(
"a", {
on: {
click: () => {
this.isMust(params.row,0);
},
},
},
"取消必点"
);
}
return h("div", [
h(
"a", {
@ -490,6 +560,26 @@
type: "vertical",
},
}),
enableOrdelFlag,
h("Divider", {
props: {
type: "vertical",
},
}),
enableOrisPush,
h("Divider", {
props: {
type: "vertical",
},
}),
enableOrisMust,
h("Divider", {
props: {
type: "vertical",
},
}),
h(
"a", {
on: {
@ -521,6 +611,12 @@
//
// this.getDataList();
},
changePrice(index){
this.specValueArr[index].specPrice = this.addGoodsForm.attributeListPrice[index].specPrice
},
changeCount(index){
this.specValueArr[index].specNum = this.addGoodsForm.attributeListPrice[index].specNum
},
getGoodsType() {
this.treeLoading = true;
goodsType({
@ -529,9 +625,35 @@
this.treeLoading = false;
if (res.success) {
this.treeData = res.result;
let bidain ={
"id": "bidian",
"delFlag": 0,
"categoryName": '必点',
"shopId": this.shopId,
"count": 0,
"stockCount": 0,
"minusStockCount": null,
"sort": null,
"title": '必点',
"nodeKey": 0
}
let tuijian ={
"id": "tuijian",
"delFlag": 0,
"categoryName": '推荐',
"shopId": this.shopId,
"count": 0,
"stockCount": 0,
"minusStockCount": null,
"sort": null,
"title": '推荐',
"nodeKey": 0
}
for (let i = 0; i < this.treeData.length; i++) {
this.treeData[i].title = this.treeData[i].categoryName
}
this.treeData.unshift(bidain)
this.treeData.unshift(tuijian)
}
});
},
@ -586,15 +708,17 @@
},
deldantiaoguige(index){
for (var m = 0; m < this.specValueArr.length; m++) {
if(this.specValueArr[m].title == this.addGoodsForm.attributeListPrice[index].specName){
if(this.specValueArr[m].id == this.addGoodsForm.attributeListPrice[index].id){
this.specValueArr.splice(m,1)
this.addGoodsForm.attributeListPrice.splice(index,1)
console.log("11",this.addGoodsForm.attributeListPrice)
if(this.addGoodsForm.attributeListPrice.length == 1){
this.addGoodsForm.attributeListPrice = {
this.addGoodsForm.attributeListPrice = []
this.addGoodsForm.attributeListPrice.push({
specName:"",
specPrice:'',
specNum:9999
}
})
this.specValueArr = []
}
this.$forceUpdate()
@ -634,21 +758,21 @@
}).then((res) => {
if(res.code == 200){
this.categorySonData = res.result.content
console.log("this.modalclassType",this.modalclassType)
console.log("this.categorySonData",this.categorySonData)
if(this.modalclassType == 'shuxing'){
console.log('属性',this.attrValueArr)
if(this.attrValueArr == ""){
this.attrValueArr = this.addGoodsForm.attributeListPrice
}
for (var i = 0; i < this.categorySonData.length; i++) {
if(this.attrValueArr.length>0){
let index1 = false
for (var m = 0; m < this.attrValueArr.length; m++) {
if(this.attrValueArr[m].id == this.categorySonData[i].id){
if(this.attrValueArr[m].title == this.categorySonData[i].title){
index1 = true
this.categorySonData[i].checked = true
}else{
this.categorySonData[i].checked = false
}
}
if(index1){
this.categorySonData[i].checked = true
}
}else{
this.categorySonData[i].checked = false
}
@ -691,6 +815,8 @@
},
checkSpecValue(index){
//this.typeToAttrName = res.result.content[this.categoryIndex].title
console.log("this.categorySonData[index]",this.categorySonData[index])
console.log("this.modalclassType",this.modalclassType)
this.categorySonData[index].checked = !this.categorySonData[index].checked
if(this.modalclassType == 'shuxing'){
if(this.categorySonData[index].checked == true){
@ -698,7 +824,7 @@
this.attrValueArr.push(this.categorySonData[index])
}else{
for(let i=0;i<this.attrValueArr.length;i++){
if(this.categorySonData[index].id == this.attrValueArr[i].id){
if(this.categorySonData[index].title == this.attrValueArr[i].title){
this.attrValueArr.splice(i,1)
}
}
@ -715,13 +841,12 @@
}
}
}
this.$forceUpdate()
},
guigeSubmit(){
if(this.modalclassType == 'shuxing'){
console.log("this.addGoodsForm.attributeList1",this.addGoodsForm.attributeList1)
console.log("this.attrValueArr",this.attrValueArr)
for(let i=0;i<this.attrValueArr.length;i++){
if(this.addGoodsForm.attributeList1.size == 0){
//set has get
@ -731,7 +856,7 @@
data.title.push(this.attrValueArr[i].title)
this.addGoodsForm.attributeList1.set(this.attrValueArr[i].parentName,data)
}else{
if(this.addGoodsForm.attributeList1.has(this.attrValueArr[i].parentName)){
if(this.addGoodsForm.attributeList1.has(this.attrValueArr[i].parentName) && this.addGoodsForm.attributeList1.get(this.attrValueArr[i].parentName).title.indexOf(this.attrValueArr[i].title) == -1){
this.addGoodsForm.attributeList1.get(this.attrValueArr[i].parentName).title.push(this.attrValueArr[i].title)
}else{
let data = {
@ -744,14 +869,24 @@
}
}else{
//guige
this.addGoodsForm.attributeListPrice = []
let message = []
console.log("this.specValueArr",this.specValueArr)
for(let i=0;i<this.specValueArr.length;i++){
this.addGoodsForm.attributeListPrice.push({
specName:this.specValueArr[i].title,
specPrice:'',
specNum:9999
for(let m=0;m<this.addGoodsForm.attributeListPrice.length;m++){
if(this.specValueArr[i].id == this.addGoodsForm.attributeListPrice[m].id){
this.specValueArr[i].specPrice = this.addGoodsForm.attributeListPrice[m].specPrice
this.specValueArr[i].specName = this.addGoodsForm.attributeListPrice[m].specName
this.specValueArr[i].specNum = this.addGoodsForm.attributeListPrice[m].specNum
}
}
message.push({
id:this.specValueArr[i].id,
specName:this.specValueArr[i].specName == undefined ? this.specValueArr[i].title : this.specValueArr[i].specName,
specPrice:this.specValueArr[i].specPrice == undefined ? '' : this.specValueArr[i].specPrice,
specNum:this.specValueArr[i].specNum == undefined ? 9999 : this.specValueArr[i].specNum
})
}
this.addGoodsForm.attributeListPrice = message
}
this.modalclass = false;
@ -842,7 +977,7 @@
handleSearch() {
this.searchForm.pageNum = 1;
this.searchForm.pageSize = 10;
// this.getDataList();
this.getDataList();
},
handleReset() {
this.$refs.searchForm.resetFields();
@ -944,6 +1079,30 @@
this.modalTitle = "添加分类 " + this.editTitle + " 的数据";
this.$refs.form.resetFields();
this.form.sort = this.data.length + 1;
this.addGoodsForm = {
id:'',
shopId:'',
categoryId:'', //id
categoryName:'', //
productPicture:'', //
productName:'', //
lunchBox:0, //
startPayNum:'', //
attributeListPrice:[{ //
specPrice:"",
specNum:9999
}],
sellTime:0, //
sellBeginTime:'', //---
sellEndTime:'', //---
attributeList:'',
productGroupBuyPrices:[],
attributeList1:new Map(), //
productIntro:"" //
}
this.specValueArr = []
this.attrValueArr = []
this.addGoodsForm.shopId = this.shopId
this.addGoodsForm.categoryId = this.selectNode.id
this.addGoodsForm.categoryName = this.selectNode.categoryName
this.modalVisible = true;
@ -967,8 +1126,22 @@
this.addGoodsForm = data;
this.addGoodsForm.attributeList1 = JSON.parse(this.addGoodsForm.attributeList)
this.addGoodsForm.attributeList1 = new Map(Object.entries(this.addGoodsForm.attributeList1));
this.addGoodsForm.attributeListPrice = JSON.parse(this.addGoodsForm.attributeListPrice)
console.log("this.addGoodsForm.attributeList1",this.addGoodsForm.attributeList1)
console.log("this.addGoodsForm.attributeListPrice",this.addGoodsForm.attributeListPrice)
this.addGoodsForm.attributeList1.forEach((value, key) => {
for(let i = 0;i<value.title.length;i++){
this.attrValueArr.push({
parentName:key,
title:value.title[i]
})
}
});
this.specValueArr = this.addGoodsForm.attributeListPrice
this.addGoodsForm.sellTime = this.addGoodsForm.sellBeginTime != '' ? 1 : 0
this.modalVisible = true;
},
@ -976,6 +1149,7 @@
this.$refs.form.validate((valid) => {
if (valid) {
this.submitLoading = true;
if (this.modalType == 0) {
// id
@ -987,6 +1161,7 @@
this.submitLoading = false;
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
this.modalVisible = false;
}
});
@ -1000,7 +1175,7 @@
this.submitLoading = false;
if (res.success) {
this.$Message.success("操作成功");
// this.getDataList();
this.getDataList();
this.modalVisible = false;
}
});
@ -1011,23 +1186,75 @@
remove(v) {
this.$Modal.confirm({
title: "确认删除",
content: "您确认要删除 " + v.title + " ?",
content: "您确认要删除 " + v.productName + " ?",
loading: true,
onOk: () => {
//
deleteData({
ids: v.id
productDelete({
id: v.id
}).then((res) => {
this.$Modal.remove();
if (res.success) {
this.clearSelectAll();
this.$Message.success("操作成功");
// this.getDataList();
this.getDataList();
}
});
},
});
},
upDown(v,value) {
if(value == 0){
productDown({
id: v.id
}).then((res) => {
this.$Modal.remove();
if (res.success) {
this.clearSelectAll();
this.$Message.success("操作成功");
this.getDataList();
}
});
}else{
productUp({
id: v.id
}).then((res) => {
this.$Modal.remove();
if (res.success) {
this.clearSelectAll();
this.$Message.success("操作成功");
this.getDataList();
}
});
}
},
isPush(v,value) {
productisPush({
id: v.id,
isPush:value
}).then((res) => {
this.$Modal.remove();
if (res.success) {
this.clearSelectAll();
this.$Message.success("操作成功");
this.getDataList();
}
});
},
isMust(v,value) {
productisMust({
id: v.id,
isMust:value
}).then((res) => {
this.$Modal.remove();
if (res.success) {
this.clearSelectAll();
this.$Message.success("操作成功");
this.getDataList();
}
});
},
delAll() {
if (this.selectList.length <= 0) {
this.$Message.warning("您还未选择要删除的数据");

7
src/views/app/shop/editDictType.vue

@ -51,12 +51,7 @@
required: true,
message: "请输入",
trigger: "blur"
}],
sort: [{
required: true,
message: "请输入排序值",
trigger: "blur",
}, ],
}]
},
};
},

2
src/views/app/shop/shop.vue

@ -380,7 +380,7 @@
},
},
},
"新增商品"
"管理商品"
),
]);
},

Loading…
Cancel
Save