dev
wxy 2024-05-09 16:17:35 +08:00
parent 7f58a595b0
commit 24249a6caa
5 changed files with 437 additions and 129 deletions

View File

@ -83,17 +83,23 @@
<img :src="scope.row.logo" alt="品牌logo" width="50px" height="50px" /> <img :src="scope.row.logo" alt="品牌logo" width="50px" height="50px" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column label="品牌状态" align="center" prop="status" >
label="品牌状态"
width="180">
<template slot-scope="scope"> <template slot-scope="scope">
是否上下架<el-switch <el-switch
v-model="scope.row.status" v-model="scope.row.status"
:active-value="1" active-color="#13ce66"
:inactive-value="0" inactive-color="#ff4949"
@change="updateBrandStatus" active-text="上架"
></el-switch> inactive-text="下架"
inactive-value="0"
active-value="1"
@change="updateBrandStatus(scope.row)"
>
</el-switch>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">

View File

@ -70,7 +70,18 @@
<el-table-column type="selection" width="60" align="center" /> <el-table-column type="selection" width="60" align="center" />
<el-table-column label="ID" align="center" prop="id" /> <el-table-column label="ID" align="center" prop="id" />
<el-table-column label="商品名称" align="center" prop="name" /> <el-table-column label="商品名称" align="center" prop="name" />
<el-table-column label="商品描述" align="center" prop="productDesc" /> <el-table-column label="商品描述" align="center" prop="productDesc">
<template slot-scope="scope">
<el-popover
placement="right"
title="商品描述"
width="500"
trigger="click">
<div v-html="scope.row.productDesc"></div>
<el-button slot="reference" type="text">查看</el-button>
</el-popover>
</template>
</el-table-column>
<el-table-column label="商品类型" align="center" prop="type" /> <el-table-column label="商品类型" align="center" prop="type" />
<el-table-column label="冗余字段" align="center" prop="typeIds" /> <el-table-column label="冗余字段" align="center" prop="typeIds" />
<el-table-column label="商品主图" align="center" prop="img"> <el-table-column label="商品主图" align="center" prop="img">
@ -90,7 +101,19 @@
<el-table-column label="单位" align="center" prop="unit" /> <el-table-column label="单位" align="center" prop="unit" />
<el-table-column label="搜索关键字" align="center" prop="keywords" /> <el-table-column label="搜索关键字" align="center" prop="keywords" />
<el-table-column label="规格信息" align="center" prop="ruleId" /> <el-table-column label="规格信息" align="center" prop="ruleId" />
<el-table-column label="0添加商品信息 1添加规格信息 2添加描述信息" align="center" prop="step" /> <el-table-column label="0添加商品信息 1添加规格信息 2添加描述信息" align="center" prop="step"/>
<el-table-column label="商品描述" align="center" prop="productDesc">
<template slot-scope="scope">
<el-popover
placement="right"
title="商品描述"
width="500"
trigger="click">
<div v-html="scope.row.productDesc"></div>
<el-button slot="reference" type="text">查看</el-button>
</el-popover>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@ -163,29 +186,102 @@
</div> </div>
<div v-show="active == 1"> <div v-show="active == 1">
<el-form-item label="规格信息" prop="ruleId"> <el-form-item label="规格信息" prop="ruleId">
<el-select v-model="form.rule" placeholder="请选择规格" v-on:change="changeRuleInfoListByRuleId" clearable> <el-select v-model="form.rule" placeholder="请选择规格" v-on:change="changeRuleInfoListByRuleId" clearable>
<el-option v-for="item in ruleList" :label="item.name" :value="item.id" :key="item.id"></el-option> <el-option v-for="item in ruleList" :label="item.name" :value="item.id" :key="item.id"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form ref="form" :model="skuFormTemplate" label-width="80px">
<el-row>
<el-col :span="5">
<el-form-item label="商品库存">
<el-input-number v-model="skuFormTemplate.stock" :min="1" :max="99999" style="width: 100px" ></el-input-number>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="商品价格">
<el-input-number v-model="skuFormTemplate.price" :min="1" :max="99999" style="width: 100px"></el-input-number>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="商品进价">
<el-input-number v-model="skuFormTemplate.purchasePrice":min="1" :max="99999" style="width: 100px"></el-input-number>
</el-form-item>
</el-col>
<el-form-item label="商品售价">
<el-input-number v-model="skuFormTemplate.sellingPrice":min="1" :max="99999" style="width: 100px"></el-input-number>
</el-form-item>
<el-form-item label="规格图片">
<ImageUpload v-model="skuFormTemplate.image" :limit="1"></ImageUpload>
</el-form-item>
<el-col :span="5">
<el-form-item label="编号">
<el-input-number v-model="skuFormTemplate.number":min="1" :max="99999" style="width: 100px"></el-input-number>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="重量">
<el-input-number v-model="skuFormTemplate.weight":min="1" :max="99999" style="width: 100px"></el-input-number>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="体积">
<el-input-number v-model="skuFormTemplate.volume":min="1" :max="99999" style="width: 100px"></el-input-number>
</el-form-item>
</el-col>
<el-col :span="5">
<el-button type="primary" @click="onSubmit"></el-button>
<el-button type="primary" @click="onClear"></el-button>
</el-col>
</el-row>>
</el-form>
<template> <template>
<el-table <el-table
:data="tableColumnHeaderTemplate" :data="tableBodyTemplate"
style="width: 100%"> style="width: 100%">
<!-- <el-table-column label="商品轮播图" align="center" prop="carouselImages" >-->
<!-- <template slot-scope="scope">-->
<!-- <img :src="scope.row.carouselImages" alt="加载失败" width="80px" height="80px"/>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column v-for="column in tableColumnHeaderTemplate" <el-table-column v-for="column in tableColumnHeaderTemplate"
:prop="column.prop" :prop="column.prop"
:label="column.label"> :label="column.label">
<template slot-scope="scope">
{{scope.row[column.prop]}}
<el-input-number v-if="column.prop.indexOf('image') == -1 && column.prop.indexOf('xxx') == -1"
v-model="scope.row[column.prop]" :min="1" :max="9999999999" label="描述" style="width: 120px" ></el-input-number>
<ImageUpload v-else-if="column.prop.indexOf('image') > -1 " v-model="scope.row[column.prop]" :limit="1" style="width: 120px "></ImageUpload>
</template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</template> </template>
</div> </div>
<div v-show="active==2"> <div v-show="active==2">
<el-form-item label="商品描述" prop="productDesc"> <el-form-item label="商品描述" prop="productDesc">
<el-input v-model="form.productDesc" type="textarea" placeholder="请输入内容" /> <el-input v-model="form.productDesc" type="textarea" placeholder="请输入内容" />
</el-form-item> </el-form-item>
</div> </div>
</el-form> </el-form>
<el-button style="margin-top: 12px;" @click="step" :disabled="active <1">上一步</el-button> <el-button style="margin-top: 12px;" @click="step" :disabled="active <1">上一步</el-button>
<el-button style="margin-top: 12px;" @click="next" :disabled="active >= 2">下一步</el-button> <el-button style="margin-top: 12px;" @click="next" :disabled="active >= 2">下一步</el-button>
@ -210,11 +306,32 @@ export default {
data() { data() {
return { return {
tableColumnHeaderTemplate:[], tableColumnHeaderTemplate:[],
tableBodyTemplate:[
// {'stock':'1',price: "1",purchasePrice:"1",sellingPrice:"1",image:"1",number:"1",weight:"1",volume:"1"},
// {'stock':'2',price: "1",purchasePrice:"1",sellingPrice:"1",image:"1",number:"1",weight:"1",volume:"1"},
// {'stock':'3',price: "1",purchasePrice:"1",sellingPrice:"1",image:"1",number:"1",weight:"1",volume:"1"},
// {'stock':'4',price: "1",purchasePrice:"1",sellingPrice:"1",image:"1",number:"1",weight:"1",volume:"1"},
// {'stock':'5',price: "1",purchasePrice:"1",sellingPrice:"1",image:"1",number:"1",weight:"1",volume:"1"},
// {'stock':'6',price: "1",purchasePrice:"1",sellingPrice:"1",image:"1",number:"1",weight:"1",volume:"1"},
// {'stock':'7',price: "1",purchasePrice:"1",sellingPrice:"1",image:"1",number:"1",weight:"1",volume:"1"},
// {'stock':'8',price: "1",purchasePrice:"1",sellingPrice:"1",image:"1",number:"1",weight:"1",volume:"1"},
// {'stock':'9',price: "1",purchasePrice:"1",sellingPrice:"1",image:"1",number:"1",weight:"1",volume:"1"},
],
active: 0, active: 0,
rule: [], rule: [],
ruleAttrList:[],
brandList:[], brandList:[],
ruleList:[], ruleList:[],
tableData:[], tableData:[],
skuFormTemplate:{
'stock': '0',
'price': '0',
purchasePrice: '0',
sellingPrice: '0',
image: '',
number: '0',
weight: '0',
volume: '0'},
// //
loading: true, loading: true,
// //
@ -262,21 +379,64 @@ export default {
this.initRuleListInfo(); this.initRuleListInfo();
}, },
methods: { methods: {
changeRuleInfoListByRuleId(object){ onSubmit(){
this.tableColumnHeaderTemplate = []; this.settingsOrnClear(true)
let ruleInfo = null },
this.ruleList.forEach(item => {
if(object == item.id){ onClear(){
ruleInfo = item; this.settingsOrnClear();
} },
})
if(null == ruleInfo){ settingsOrnClear(flag){
return; for (let skuFormTemplateKey in this.skuFormTemplate) {
this.tableBodyTemplate.forEach(item=>{
for (let itemKey in item) {
if(skuFormTemplateKey==itemKey){
if(flag){
item[itemKey]=this.skuFormTemplate[skuFormTemplateKey]
}else{
item[itemKey]=''
}
}
}
});
} }
let ruleAttrJson=JSON.parse(ruleInfo.ruleAttr) },
ruleAttrJson.forEach(ruleAttr => {
this.tableColumnHeaderTemplate.push({'prop':'xxx','label':ruleAttr.ruleType}) changeRuleInfoListByRuleId(object) {
}) this.tableColumnHeaderTemplate = [];
this.tableBodyTemplate = [];
let ruleInfo = this.ruleList.find(item => object == item.id);
if (!ruleInfo) {
return;
}
let ruleAttrJson;
try {
ruleAttrJson = JSON.parse(ruleInfo.ruleAttr);
} catch (error) {
console.error('Error parsing ruleAttr JSON:', error);
return;
}
ruleAttrJson.forEach((ruleAttr, index) => {
this.tableColumnHeaderTemplate.push({'prop': `xxx${index}`, 'label': ruleAttr.ruleType});
});
const cartesian = (ruleAttrJson, index, current) => {
if (index === ruleAttrJson.length) {
this.tableBodyTemplate.push({...current});
return;
}
for (let i = 0; i < ruleAttrJson[index].ruleAttrList.length; i++) {
const updatedCurrent = {...current}; // Create a copy of current object
updatedCurrent[`xxx${index}`] = ruleAttrJson[index].ruleAttrList[i];
cartesian(ruleAttrJson, index + 1, updatedCurrent);
}
};
cartesian(ruleAttrJson, 0, {});
this.tableColumnHeaderTemplate.push( this.tableColumnHeaderTemplate.push(
{prop:'stock',label:'商品库存'}, {prop:'stock',label:'商品库存'},
{prop:'price',label:'商品价格'}, {prop:'price',label:'商品价格'},

View File

@ -1,20 +1,12 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-card> <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="规格名称" prop="name"> <el-form-item label="规格名称" prop="name">
<el-input <el-input
v-model="queryParams.name" v-model="queryParams.name"
placeholder="请输入规格名称" placeholder="请输入规格名称"
clearable clearable
@keyup.enter.native="handleQuery" size="small"
/>
</el-form-item>
<el-form-item label="乐观锁" prop="revision">
<el-input
v-model="queryParams.revision"
placeholder="请输入乐观锁"
clearable
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
@ -69,19 +61,34 @@
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
</el-card>
<el-card> <el-table v-loading="loading" :data="ruleInfoList" @selection-change="handleSelectionChange">
<i class="el-icon-tickets">商品规格数据列表</i>
</el-card>
<el-card>
<el-table v-loading="loading" :data="infoList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="ID" align="center" prop="id" /> <el-table-column label="ID" align="center" prop="id" />
<el-table-column label="规格名称" align="center" prop="name" /> <el-table-column label="规格名称" align="center" prop="name" />
<el-table-column label="规格详情" align="center" prop="ruleAttr" /> <el-table-column label="规格详情" align="center" prop="ruleAttr">
<el-table-column label="规格状态" align="center" prop="status" /> <template v-slot="scope">
<p v-html="scope.row.ruleAttr"></p>
</template>
</el-table-column>
<el-table-column label="规格状态" align="center" prop="status" >
<template slot-scope="scope">
<el-switch
v-model="scope.row.status"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="上架"
inactive-text="下架"
inactive-value="0"
active-value="1"
@change="updateRuleStatus(scope.row)"
>
</el-switch>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@ -118,7 +125,57 @@
</el-form-item> </el-form-item>
<el-form-item label="规格详情" prop="ruleAttr"> <el-form-item label="规格详情" prop="ruleAttr">
<el-input v-model="form.ruleAttr" type="textarea" placeholder="请输入内容" /> <span v-for="(rule,index) in templateRuleInfo">
<el-tag
:key="rule"
closable
:disable-transitions="false"
@close="handleCloseRule(index)">
{{ rule.ruleType }}
</el-tag>
<br>
<span v-for="(ruleAttr,ruleAttrIndex) in rule.ruleAttrList">
<el-tag
:key="ruleAttr"
closable
:disable-transitions="false"
@close="handleCloseRuleAttr(index,ruleAttrIndex)">
{{ ruleAttr }}
</el-tag>
</span>
<el-button type="primary" icon="el-icon-plus" size="mini" style="margin-left: 5px"v-show="rule.addRuleAttrValButton" @click="rule.addRuleAttrValButton=false;rule.addRuleAttrValForm=true"></el-button>
<el-form :inline="true" :model="ruleInfoForm" v-show="rule.addRuleAttrValForm">
<el-form-item label="规格属性">
<el-input v-model="ruleInfoForm.attr"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="pushTemplateRuleAttrInfo(index)"></el-button>
<el-button @click="cancel"> </el-button>
</el-form-item>
</el-form>
<hr>
</span>
<el-button type="primary" icon="el-icon-edit" circle v-show="ruleInfoForm.addRuleAttrValButton" @click="ruleInfoForm.addRuleAttrValButton=false;ruleInfoForm.addRuleAttrValForm=true"></el-button>
<el-form :inline="true" :model="ruleInfoForm" v-show="ruleInfoForm.addRuleAttrValForm">
<el-form-item label="规格属性">
<el-input v-model="ruleInfoForm.ruleType" ></el-input>
</el-form-item>
<el-form-item label="规格属性详情">
<el-input v-model="ruleInfoForm.attr" ></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="pushTemplateRuleInfo"></el-button>
<el-button @click="cancel"> </el-button>
</el-form-item>
</el-form>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -127,17 +184,15 @@
<el-button @click="cancel"> </el-button> <el-button @click="cancel"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
</el-card>
</div> </div>
</template> </template>
<script> <script>
import { listRule, getRule, delRule, addRule, updateRule } from "@/api/product/rule"; import { listRule, getRule, delRule, addRule, updateRule } from "@/api/product/rule";
import {delInfo} from "@/api/product/info";
import {getAttributeGroup} from "@/api/product/attributeGroup";
export default { export default {
name: "Info", name: "Rule",
data() { data() {
return { return {
// //
@ -153,7 +208,7 @@ export default {
// //
total: 0, total: 0,
// //
infoList: [], ruleInfoList: [],
// //
title: "", title: "",
// //
@ -163,29 +218,23 @@ export default {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
name: null, name: null,
ruleAttr: null,
status: null,
revision: null,
}, },
// //
form: {}, form: {},
// //
rules: { rules: {
name: [ name: [
{ required: true, message: "规格名称不能为空", trigger: "blur" } {required: true, message: "规格名称不能为空", trigger: "blur"}
],
ruleAttr: [
{ required: true, message: "规格详情不能为空", trigger: "blur" }
],
status: [
{ required: true, message: "规格状态不能为空", trigger: "change" }
],
createBy: [
{ required: true, message: "创建人不能为空", trigger: "blur" }
],
createTime: [
{ required: true, message: "创建时间不能为空", trigger: "blur" }
], ],
},
templateRuleInfo: [],
ruleInfoForm: {
"ruleType": "",
"attr": "",
"ruleAttrList": [],
"addRuleAttrValButton": true,
"addRuleAttrValForm": false
} }
}; };
}, },
@ -193,11 +242,81 @@ export default {
this.getList(); this.getList();
}, },
methods: { methods: {
pushTemplateRuleAttrInfo(index) {
let templateRuleInfoElement = this.templateRuleInfo[index];
let ruleAttrList = templateRuleInfoElement.ruleAttrList;
let attrInfo = this.ruleInfoForm.attr.trim();
let isExist = -1;
ruleAttrList.forEach((item, attrIndex) => {
if (item.indexOf(attrInfo) > -1) {
isExist = attrIndex
}
});
if (isExist != -1) {
this.$modal.msgWarning(`ruleAttrList中${ruleAttrList[isExist]}存在`)
return
}
ruleAttrList.push(attrInfo)
templateRuleInfoElement.addRuleAttrValButton = true
templateRuleInfoElement.addRuleAttrValForm = false
this.ruleInfoForm.attr = '';
},
pushTemplateRuleInfo() {
let items = this.ruleInfoForm;
let ruleType = items.ruleType;
if (null == ruleType || undefined == ruleType || '' == ruleType) {
return;
}
const attr = items.attr;
if (attr) {
items.ruleAttrList.push(attr)
}
this.templateRuleInfo.push(items)
this.ruleInfoForm = {
"ruleType": "",
"attr": "",
"ruleAttrList": [],
"addRuleAttrValButton": true,
"addRuleAttrValForm": false
}
},
handleCloseRuleAttr(index, ruleAttrIndex) {
this.templateRuleInfo[index].ruleAttrList.splice(ruleAttrIndex, 1);
},
handleCloseRule(index) {
console.log(index);
this.templateRuleInfo.splice(index, 1)
},
updateRuleStatus(params) {
const {id, status} = params
this.updateRuleInfo({id, status})
},
/** 查询商品规格列表 */ /** 查询商品规格列表 */
getList() { getList() {
this.loading = true; this.loading = true;
listRule(this.queryParams).then(response => { listRule(this.queryParams).then(response => {
this.infoList = response.data.list; let ruleInfoList = response.data.list;
ruleInfoList.forEach(item => {
let ruleAttrString = '';
let ruleAttrJsonString = item.ruleAttr;
let ruleInfoList = JSON.parse(ruleAttrJsonString);
ruleInfoList.forEach(ruleInfo => {
let ruleType = ruleInfo.ruleType;
ruleAttrString = ruleAttrString + ruleType + "<br>"
let ruleAttrListString = ruleInfo.ruleAttrList.join(",");
ruleAttrString = ruleAttrListString + "<br>";
});
item.ruleAttr = ruleAttrString;
});
this.ruleInfoList = ruleInfoList;
this.total = response.data.total; this.total = response.data.total;
this.loading = false; this.loading = false;
}); });
@ -207,13 +326,12 @@ export default {
this.open = false; this.open = false;
this.reset(); this.reset();
}, },
//
reset() { reset() {
this.form = { this.form = {
id: null, id: null,
name: null, name: null,
ruleAttr: null, ruleAttr: null,
status: null, status: "0",
revision: null, revision: null,
createBy: null, createBy: null,
createTime: null, createTime: null,
@ -222,49 +340,42 @@ export default {
}; };
this.resetForm("form"); this.resetForm("form");
}, },
/** 搜索按钮操作 */
handleQuery() { handleQuery() {
this.queryParams.pageNum = 1; this.queryParams.pageNum = 1;
this.getList(); this.getList();
}, },
/** 重置按钮操作 */
resetQuery() { resetQuery() {
this.resetForm("queryForm"); this.resetForm("queryForm");
this.handleQuery(); this.handleQuery();
}, },
//
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.id) this.ids = selection.map(item => item.id)
this.single = selection.length!==1 this.single = selection.length !== 1
this.multiple = !selection.length this.multiple = !selection.length
}, },
/** 新增按钮操作 */
handleAdd() { handleAdd() {
this.reset(); this.reset();
this.open = true; this.open = true;
this.title = "添加商品规格"; this.title = "添加商品规格";
}, },
/** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.reset(); this.reset();
const id = row.id || this.ids const id = row.id || this.ids
getRule(id).then(response => { getRule(id).then(response => {
this.form = response.data; let form = response.data;
this.templateRuleInfo = JSON.parse(form.ruleAttr)
this.form = form;
this.open = true; this.open = true;
this.title = "修改商品规格"; this.title = "修改商品规格";
}); });
}, },
/** 提交按钮 */
submitForm() { submitForm() {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
if (this.form.id != null) { if (this.form.id != null) {
updateRule(this.form).then(response => { this.updateRuleInfo(this.form)
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else { } else {
this.form.ruleAttr = JSON.stringify(this.templateRuleInfo)
addRule(this.form).then(response => { addRule(this.form).then(response => {
this.$modal.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
@ -274,7 +385,14 @@ export default {
} }
}); });
}, },
/** 删除按钮操作 */
updateRuleInfo(data) {
updateRule(data).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
},
handleDelete(row) { handleDelete(row) {
const ids = row.id || this.ids; const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除商品规格编号为"' + ids + '"的数据项?').then(function () { this.$modal.confirm('是否确认删除商品规格编号为"' + ids + '"的数据项?').then(function () {
@ -285,11 +403,10 @@ export default {
}).catch(() => { }).catch(() => {
}); });
}, },
/** 导出按钮操作 */
handleExport() { handleExport() {
this.download('product/rule/export', { this.download('product/rule/export', {
...this.queryParams ...this.queryParams
}, `info_${new Date().getTime()}.xlsx`) }, `ruleInfo_${new Date().getTime()}.xlsx`)
} }
} }
}; };

View File

@ -174,8 +174,9 @@
<script> <script>
import { listSku, getSku, delSku, addSku, updateSku } from "@/api/product/sku"; import { listSku, getSku, delSku, addSku, updateSku } from "@/api/product/sku";
import ImageUpload from "@/components/ImageUpload"
export default { export default {
components:{ImageUpload},
name: "Sku", name: "Sku",
data() { data() {
return { return {

View File

@ -1,28 +1,12 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-card> <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="分类名称" prop="name"> <el-form-item label="分类名称" prop="name">
<el-input <el-input
v-model="queryParams.name" v-model="queryParams.name"
placeholder="请输入分类名称" placeholder="请输入分类名称"
clearable clearable
@keyup.enter.native="handleQuery" size="small"
/>
</el-form-item>
<el-form-item label="排序" prop="sort">
<el-input
v-model="queryParams.sort"
placeholder="请输入排序"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="商品数量" prop="productCount">
<el-input
v-model="queryParams.productCount"
placeholder="请输入商品数量"
clearable
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
@ -77,24 +61,51 @@
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
</el-card>
<el-card> <el-table v-loading="loading" :data="categoryList" @selection-change="handleSelectionChange">
<i class="el-icon-tickets">商品分类数据列表</i>
</el-card>
<el-card>
<el-table v-loading="loading" :data="typeList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="分类id" align="center" prop="catId" /> <el-table-column label="分类id" align="center" prop="catId" />
<el-table-column label="分类名称" align="center" prop="name" /> <el-table-column label="分类名称" align="center" prop="name" />
<el-table-column label="父分类id" align="center" prop="parentCid" /> <el-table-column label="父分类id" align="center" prop="parentCid">
<el-table-column label="层级" align="center" prop="catLevel" /> <template slot-scope="scope">
<el-table-column label="是否显示[0-不显示1显示]" align="center" prop="showStatus"/> <span style="margin-left: 10px" v-if="scope.row.parentCid==0"></span>
<span style="margin-left: 10px" v-if="scope.row.parentCid==1"></span>
<span style="margin-left: 10px" v-if="scope.row.parentCid==2"></span>
</template>
</el-table-column>
<el-table-column label="层级" align="center" prop="catLevel" >
<template slot-scope="scope">
<span style="margin-left: 10px" v-if="scope.row.catLevel==1"></span>
<span style="margin-left: 10px" v-if="scope.row.catLevel==2"></span>
<span style="margin-left: 10px" v-if="scope.row.catLevel==3"></span>
</template>
</el-table-column>
<el-table-column align="center" prop="showStatus" >
<template slot-scope="scope">
<el-switch
v-model="scope.row.showStatus"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="显式"
inactive-text="不显示"
inactive-value="1"
active-value="0"
@change="updateShowStatus(scope.row)"
>
</el-switch>
</template>
</el-table-column>
<el-table-column label="排序" align="center" prop="sort" /> <el-table-column label="排序" align="center" prop="sort" />
<el-table-column label="图标地址" align="center" prop="icon" /> <el-table-column label="图标地址" align="center" prop="icon">
<template slot-scope="scope">
<img :src="scope.row.icon">
</template>
</el-table-column>
<el-table-column label="计量单位" align="center" prop="productUnit" /> <el-table-column label="计量单位" align="center" prop="productUnit" />
<el-table-column label="商品数量" align="center" prop="productCount" /> <el-table-column label="商品数量" align="center" prop="productCount" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@ -111,6 +122,7 @@
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['product:type:remove']" v-hasPermi="['product:type:remove']"
>删除</el-button> >删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -147,21 +159,22 @@
<el-form-item label="商品数量" prop="productCount"> <el-form-item label="商品数量" prop="productCount">
<el-input v-model="form.productCount" placeholder="请输入商品数量" /> <el-input v-model="form.productCount" placeholder="请输入商品数量" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button> <el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button> <el-button @click="cancel"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
</el-card>
</div> </div>
</template> </template>
<script> <script>
import { listType, getType, delType, addType, updateType } from "@/api/product/type"; import {listType, getType, delType, addType, updateType} from "@/api/product/type";
export default { export default {
name: "Type", name: "Category",
data() { data() {
return { return {
// //
@ -177,7 +190,7 @@ export default {
// //
total: 0, total: 0,
// //
typeList: [], categoryList: [],
// //
title: "", title: "",
// //
@ -186,6 +199,7 @@ export default {
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
name: null,
}, },
// //
form: {}, form: {},
@ -198,11 +212,17 @@ export default {
this.getList(); this.getList();
}, },
methods: { methods: {
updateShowStatus(params){
const {catId,showStatus}=params
this.updateInfoByCategoryId({catId,showStatus})
},
/** 查询商品三级分类列表 */ /** 查询商品三级分类列表 */
getList() { getList() {
this.loading = true; this.loading = true;
listType(this.queryParams).then(response => { listType(this.queryParams).then(response => {
this.typeList = response.data.list; this.categoryList = response.data.list;
this.total = response.data.total; this.total = response.data.total;
this.loading = false; this.loading = false;
}); });
@ -219,7 +239,7 @@ export default {
name: null, name: null,
parentCid: null, parentCid: null,
catLevel: null, catLevel: null,
showStatus: null, showStatus: 0,
sort: null, sort: null,
icon: null, icon: null,
productUnit: null, productUnit: null,
@ -265,11 +285,7 @@ export default {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
if (this.form.catId != null) { if (this.form.catId != null) {
updateType(this.form.data).then(response => { this.updateInfoByCategoryId(this.form)
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else { } else {
addType(this.form).then(response => { addType(this.form).then(response => {
this.$modal.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
@ -294,8 +310,16 @@ export default {
handleExport() { handleExport() {
this.download('product/type/export', { this.download('product/type/export', {
...this.queryParams ...this.queryParams
}, `type_${new Date().getTime()}.xlsx`) }, `category_${new Date().getTime()}.xlsx`)
} },
updateInfoByCategoryId(data){
updateType(data).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
},
} }
}; };
</script> </script>