商品详情页面 2.0

master
rouchen 2024-03-26 20:22:14 +08:00
parent 49e12e5f3a
commit 59913537a6
7 changed files with 938 additions and 60 deletions

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询【请填写功能名称】列表
export function listShoppingcard(query) {
return request({
url: '/product/shoppingcard/list',
method: 'get',
params: query
})
}
// 查询【请填写功能名称】详细
export function getShoppingcard(id) {
return request({
url: '/product/shoppingcard/' + id,
method: 'get'
})
}
// 新增【请填写功能名称】
export function addShoppingcard(data) {
return request({
url: '/product/shoppingcard',
method: 'post',
data: data
})
}
// 修改【请填写功能名称】
export function updateShoppingcard(data) {
return request({
url: '/product/shoppingcard/'+data.id,
method: 'put',
data: data
})
}
// 删除【请填写功能名称】
export function delShoppingcard(id) {
return request({
url: '/product/shoppingcard/' + id,
method: 'delete'
})
}

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询购物车列表
export function listInfo(query) {
return request({
url: '/shopCart/info/list',
method: 'get',
params: query
})
}
// 查询购物车详细
export function getInfo(id) {
return request({
url: '/shopCart/info/' + id,
method: 'get'
})
}
// 新增购物车
export function addInfo(data) {
return request({
url: '/shopCart/info',
method: 'post',
data: data
})
}
// 修改购物车
export function updateInfo(data) {
return request({
url: '/shopCart/info/'+data.id,
method: 'put',
data: data
})
}
// 删除购物车
export function delInfo(id) {
return request({
url: '/shopCart/info/' + id,
method: 'delete'
})
}

View File

@ -80,17 +80,17 @@ export const constantRoutes = [
redirect: 'product-detail', redirect: 'product-detail',
children: [ children: [
{ {
path: 'product-detail', path: 'product-detail/:detailId(\\d+)',
component: () => import('@/views/product/shop/index'), component: () => import('@/views/product/info/detail/index'),
name: 'ShopProduct', name: 'ShopProduct',
meta: {title: '商品详情', icon: 'dashboard', affix: true} meta: {title: '商品详情', icon: 'dashboard', affix: true}
} }
] ]
}, },
{ // {
path: '/gb', // path: '/gb',
component: detail // component: detail
}, // },
{ {
path: '/user', path: '/user',
component: Layout, component: Layout,

View File

@ -92,47 +92,57 @@
:label="value" :key="value" :value="value" border>{{value}}</el-radio> :label="value" :key="value" :value="value" border>{{value}}</el-radio>
</el-form-item> </el-form-item>
<el-form-item label="数量"> <el-form-item label="数量">
<el-input-number v-model="form.num" :min="1" :max="10" label="描述文字"></el-input-number> <el-input-number v-model="form.num" :min="1" :max="10" label="描述文字" ></el-input-number>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" >加入购物车</el-button> <el-button type="primary" >加入购物车</el-button>
<el-button>立即购买</el-button> <el-button>立即购买</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
总价格{{num}}
</el-col> </el-col>
</el-row> </el-row>
<el-row style="margin-top: 50px"> <el-row style="margin-top: 50px">
<el-card class="box-card"> <el-card class="box-card">
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
<span style="">商品详情</span> <span style="">商品详情</span>
</div>
<el-descriptions title="分组1" :column="1"> <el-descriptions v-for="item in receivedShop.attributeGroupList" :title="attributeGroup.groupName" :column="1" >
<el-descriptions-item label="用户名">kooriookami</el-descriptions-item> <el-descriptions-item v-for="attribute in item.attributeList" :label="attribute.name">
<el-descriptions-item label="手机号">18100000000</el-descriptions-item> {{attributeMap[attribute.id]}}
<el-descriptions-item label="居住地">苏州市</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="联系地址">江苏省苏州市吴中区吴中大道 1188 </el-descriptions-item> </el-descriptions>
</el-descriptions>
<el-descriptions title="其他属性" :column="1">
<el-descriptions-item label="用户名">kooriookami</el-descriptions-item> <el-descriptions v-if=" receivedShop.attributeInfoList.length !==0"
<el-descriptions-item label="手机号">18100000000</el-descriptions-item> title="其他属性" :column="1" >
<el-descriptions-item label="居住地">苏州市</el-descriptions-item> <el-descriptions-item v-for="attributeInfo in receivedShop.attributeInfoList"
<el-descriptions-item label="备注"> :label="attributeInfo.name">
<el-tag size="small">学校</el-tag> {{attributeMap[attributeInfo.id]}}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="联系地址">江苏省苏州市吴中区吴中大道 1188 </el-descriptions-item> </el-descriptions>
</el-descriptions>
<el-descriptions v-if=" receivedShop.attributeInfoList.length !==0"
title="其他属性" :column="1" >
<el-descriptions-item v-for="attributeInfo in receivedShop.attributeInfoList"
:label="attributeInfo.name">
{{attributeMap[attributeInfo.id]}}
</el-descriptions-item>
</el-descriptions>
<editor v-model="editorValue" :read-only="true"></editor> <editor v-model="editorValue" :read-only="true"></editor>
</div>
</el-card> </el-card>
</el-row> </el-row>
</div> </div>
</template> </template>
<script> <script>
import {getInfo} from "@/api/product/info"; import {getDetailInfo} from "@/api/product/info";
export default { export default {
name: "Detailindex", name: "productDetail",
data() { data() {
return { return {
breadcrumbList: [ breadcrumbList: [
@ -149,29 +159,51 @@ export default {
price: 0 price: 0
}, },
shopData: {}, shopData: {},
receivedShop: {}, receivedShop: {
projectInfo: {
name: ""
},
brandInfo: {
nam: ""
},
attributeInfoList: []
},
num: 1,
editorValue: "阿萨德刚", editorValue: "阿萨德刚",
attributeMap: [],
// //
Products: [], Products: [],
checkSkuInfo: { checkSkuInfo: {
price : 0.00 price : 0.00
}, },
price: 0.00,
attributeGroup: [],
deadline2 : Date.now() + 1 * 10000 // 10 * 60/ * 60/ * 1000/ deadline2 : Date.now() + 1 * 10000 // 10 * 60/ * 60/ * 1000/
} }
}, },
created() { created() {
this.parseShopFromRoute(); const detailId=this.$route.params && this.$route.params.detailId
this.initProjectDetailInfo(detailId)
// this.parseShopFromRoute();
// //
const timerId = setTimeout(() => { const timerId = setTimeout(() => {
// hilarity // hilarity
this.hilarity(); this.hilarity();
clearTimeout(timerId); clearTimeout(timerId);
}, this.deadline2 - Date.now()); }, this.deadline2 - Date.now());
},
watch: {
'form.num':{
handler:"updateNum",
immediate:true
}
}, },
methods:{ methods:{
updateNum() {
this.num = this.price * this.form.num
console.log("qqqqq",this.num)
},
hilarity() { hilarity() {
this.$notify({ this.$notify({
title: "提示", title: "提示",
@ -186,6 +218,7 @@ export default {
this.form['rule'+index] = rule this.form['rule'+index] = rule
}) })
this.selectRuleSku() this.selectRuleSku()
}, },
selectRuleSku(){ selectRuleSku(){
let ruleSize =this.receivedShop.ruleAttrAddModelList.length let ruleSize =this.receivedShop.ruleAttrAddModelList.length
@ -199,24 +232,52 @@ export default {
} }
this.checkSkuInfo= this.receivedShop.projectSkuInfoList.find(skuInfo => skuInfo.sku === sku) this.checkSkuInfo= this.receivedShop.projectSkuInfoList.find(skuInfo => skuInfo.sku === sku)
console.log("sdf",this.checkSkuInfo) console.log("sdf",this.checkSkuInfo)
console.log("ppp",this.checkSkuInfo.price)
this.price = this.checkSkuInfo.price
this.updateNum()
}, },
parseShopFromRoute() { initProjectDetailInfo(detailId){
// shop getDetailInfo(detailId).then(response => {
this.receivedShop = this.$route.query.shop; this.receivedShop = response.data
// receivedShopdatadataname console.log("商品",this.receivedShop)
console.log("hhhh ",this.receivedShop); // let ccc = this.receivedShop.projectInfo.carouselImages.split(',')
// this.Products.push(...ccc)
let ccc = this.receivedShop.projectInfo.carouselImages.split(',') this.receivedShop.productAttributeInfoList.map(productAttributeInfo => {
this.Products.push(...ccc) let key =productAttributeInfo.attributeId;
this.attributeMap[key] = productAttributeInfo["value"]
let ruleAttrLength = this.receivedShop.ruleAttrAddModelList.length; })
console.log("hieng",ruleAttrLength)
for (let index = 0 ;index < ruleAttrLength ;index++){
this.form["rule"+index] = null
}
this.initSku()
let ruleAttrLength = this.receivedShop.ruleAttrAddModelList.length;
console.log("hieng",ruleAttrLength)
for (let index = 0 ;index < ruleAttrLength ;index++){
this.form["rule"+index] = null
}
console.log("shjo",this.receivedShop.ruleAttrAddModelList)
this.initSku()
})
}, },
//
// parseShopFromRoute() {
// // shop
// this.receivedShop = this.$route.query.shop;
// // receivedShopdatadataname
// console.log("hhhh ",this.receivedShop); //
// //
// let ccc = this.receivedShop.projectInfo.carouselImages.split(',')
// this.Products.push(...ccc)
// this.receivedShop.productAttributeInfoList.map(productAttributeInfo => {
// let key =productAttributeInfo.attributeId;
// this.attributeMap[key] = productAttributeInfo["value"]
// })
//
// let ruleAttrLength = this.receivedShop.ruleAttrAddModelList.length;
// console.log("hieng",ruleAttrLength)
// for (let index = 0 ;index < ruleAttrLength ;index++){
// this.form["rule"+index] = null
// }
// console.log("shjo",this.receivedShop.ruleAttrAddModelList)
// this.initSku()
// },
}, },
beforeDestroy() { beforeDestroy() {
} }

View File

@ -115,6 +115,9 @@
<el-table-column label="备注" align="center" prop="remark" /> <el-table-column label="备注" align="center" prop="remark" />
<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 class="link-type" @click="toProjectDetail(scope.row.id)">
商品詳情
</el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
@ -555,8 +558,8 @@ export default {
}); });
}); });
} }
}); });
} }
} }
} }
}, },
@ -564,6 +567,10 @@ export default {
this.getList(); this.getList();
}, },
methods: { methods: {
toProjectDetail(detailId){
let url = `${window.location.origin}/product-detail/${detailId}`;
window.open(url)
},
oneSetting(){ oneSetting(){
this.skuList.forEach(skuInfo => { this.skuList.forEach(skuInfo => {
console.log(skuInfo) console.log(skuInfo)
@ -573,22 +580,21 @@ export default {
}) })
}, },
changeRule(ruleId){ changeRule(ruleId){
console.log("ruleId",ruleId)
this.titleList = [] this.titleList = []
let ruleInfo = this.ruleList.find(ruleInfo => ruleInfo.id === ruleId); let ruleInfo = this.ruleList.find(ruleInfo => ruleInfo.id == ruleId);
console.log("ruleInfo",ruleInfo)
const {ruleAttrList} = ruleInfo; const {ruleAttrList} = ruleInfo;
console.log(ruleInfo)
console.log(ruleAttrList) console.log(ruleAttrList)
let skuTotal = 1; let skuTotal = 1;
for (let ruleAttrListKey in ruleAttrList) { for (let ruleAttrListKey of Object.keys(ruleAttrList)) {
let ruleAttrInfo = ruleAttrList[ruleAttrListKey]; let ruleAttrInfo = ruleAttrList[ruleAttrListKey];
this.titleList.push({ this.titleList.push({
"label":ruleAttrInfo.name, "label": ruleAttrInfo.name,
"prop":"prop"+ruleAttrListKey "prop": "prop" + ruleAttrListKey
}) });
skuTotal = skuTotal * ruleAttrInfo.valueList.length; skuTotal *= ruleAttrInfo.valueList.length;
} }
this.titleList.push(...this.templateTitleList) ; this.titleList.push(...this.templateTitleList) ;
this.skuList = []; this.skuList = [];
for (let i = 0; i < skuTotal; i++) { for (let i = 0; i < skuTotal; i++) {
@ -784,7 +790,7 @@ export default {
this.oneSettingForm = response.data.projectSkuInfos this.oneSettingForm = response.data.projectSkuInfos
this.categoryOptionValue = [Number(response.data.mianType),Number(response.data.parentType),Number(response.data.type)] this.categoryOptionValue = [Number(response.data.mianType),Number(response.data.parentType),Number(response.data.type)]
this.changeRule(response.data.ruleId) this.changeRule(response.data.ruleId)
console.log("sku",this.skuList) console.log("sku",this.changeRule)
console.log("skuu",response.data.projectSkuInfos) console.log("skuu",response.data.projectSkuInfos)
for (var i = 0; i < this.skuList.length; i++) { for (var i = 0; i < this.skuList.length; i++) {
this.$set(this.skuList[i], 'image', response.data.projectSkuInfos[i].image); this.$set(this.skuList[i], 'image', response.data.projectSkuInfos[i].image);

View File

@ -0,0 +1,392 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="登录人的id" prop="uiserId">
<el-input
v-model="queryParams.uiserId"
placeholder="请输入登录人的id"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="商品id" prop="projectId">
<el-input
v-model="queryParams.projectId"
placeholder="请输入商品id"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="数量" prop="quantity">
<el-input
v-model="queryParams.quantity"
placeholder="请输入数量"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="价格" prop="price">
<el-input
v-model="queryParams.price"
placeholder="请输入价格"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="创建时间" prop="createdAt">
<el-date-picker clearable
v-model="queryParams.createdAt"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择创建时间">
</el-date-picker>
</el-form-item>
<el-form-item label="修改时间" prop="updatedAt">
<el-date-picker clearable
v-model="queryParams.updatedAt"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择修改时间">
</el-date-picker>
</el-form-item>
<el-form-item label="是否选中" prop="selected">
<el-input
v-model="queryParams.selected"
placeholder="请输入是否选中"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="商品属性id" prop="attributeId">
<el-input
v-model="queryParams.attributeId"
placeholder="请输入商品属性id"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="小计金额" prop="subtotal">
<el-input
v-model="queryParams.subtotal"
placeholder="请输入小计金额"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="备注" prop="remarks">
<el-input
v-model="queryParams.remarks"
placeholder="请输入备注"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['product:shoppingcard:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['product:shoppingcard:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['product:shoppingcard:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['product:shoppingcard:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="shoppingcardList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="购物车主键" align="center" prop="id" />
<el-table-column label="登录人的id" align="center" prop="uiserId" />
<el-table-column label="商品id" align="center" prop="projectId" />
<el-table-column label="数量" align="center" prop="quantity" />
<el-table-column label="价格" align="center" prop="price" />
<el-table-column label="创建时间" align="center" prop="createdAt" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createdAt, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="修改时间" align="center" prop="updatedAt" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.updatedAt, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="状态(0,未提交,1已提交)" align="center" prop="status" />
<el-table-column label="是否选中" align="center" prop="selected" />
<el-table-column label="商品属性id" align="center" prop="attributeId" />
<el-table-column label="小计金额" align="center" prop="subtotal" />
<el-table-column label="备注" align="center" prop="remarks" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['product:shoppingcard:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['product:shoppingcard:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改请填写功能名称对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="登录人的id" prop="uiserId">
<el-input v-model="form.uiserId" placeholder="请输入登录人的id" />
</el-form-item>
<el-form-item label="商品id" prop="projectId">
<el-input v-model="form.projectId" placeholder="请输入商品id" />
</el-form-item>
<el-form-item label="数量" prop="quantity">
<el-input v-model="form.quantity" placeholder="请输入数量" />
</el-form-item>
<el-form-item label="价格" prop="price">
<el-input v-model="form.price" placeholder="请输入价格" />
</el-form-item>
<el-form-item label="创建时间" prop="createdAt">
<el-date-picker clearable
v-model="form.createdAt"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择创建时间">
</el-date-picker>
</el-form-item>
<el-form-item label="修改时间" prop="updatedAt">
<el-date-picker clearable
v-model="form.updatedAt"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择修改时间">
</el-date-picker>
</el-form-item>
<el-form-item label="是否选中" prop="selected">
<el-input v-model="form.selected" placeholder="请输入是否选中" />
</el-form-item>
<el-form-item label="商品属性id" prop="attributeId">
<el-input v-model="form.attributeId" placeholder="请输入商品属性id" />
</el-form-item>
<el-form-item label="小计金额" prop="subtotal">
<el-input v-model="form.subtotal" placeholder="请输入小计金额" />
</el-form-item>
<el-form-item label="备注" prop="remarks">
<el-input v-model="form.remarks" placeholder="请输入备注" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listShoppingcard, getShoppingcard, delShoppingcard, addShoppingcard, updateShoppingcard } from "@/api/product/shoppingcard";
export default {
name: "Shoppingcard",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
shoppingcardList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
uiserId: null,
projectId: null,
quantity: null,
price: null,
createdAt: null,
updatedAt: null,
status: null,
selected: null,
attributeId: null,
subtotal: null,
remarks: null
},
//
form: {},
//
rules: {
}
};
},
created() {
this.getList();
},
methods: {
/** 查询【请填写功能名称】列表 */
getList() {
this.loading = true;
listShoppingcard(this.queryParams).then(response => {
this.shoppingcardList = response.data.rows;
this.total = response.data.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
uiserId: null,
projectId: null,
quantity: null,
price: null,
createdAt: null,
updatedAt: null,
status: null,
selected: null,
attributeId: null,
subtotal: null,
remarks: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加【请填写功能名称】";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getShoppingcard(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改【请填写功能名称】";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateShoppingcard(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addShoppingcard(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除【请填写功能名称】编号为"' + ids + '"的数据项?').then(function() {
return delShoppingcard(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('product/shoppingcard/export', {
...this.queryParams
}, `shoppingcard_${new Date().getTime()}.xlsx`)
}
}
};
</script>

View File

@ -0,0 +1,331 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="商品" prop="projectId">
<el-input
v-model="queryParams.projectId"
placeholder="请输入商品"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="sku" prop="projectSku">
<el-input
v-model="queryParams.projectSku"
placeholder="请输入sku"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="用户" prop="userId">
<el-input
v-model="queryParams.userId"
placeholder="请输入用户"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="数量" prop="num">
<el-input
v-model="queryParams.num"
placeholder="请输入数量"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="是否选中" prop="isSelected">
<el-input
v-model="queryParams.isSelected"
placeholder="请输入是否选中"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['shopCart:info:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['shopCart:info:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['shopCart:info:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['shopCart:info:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="infoList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键" align="center" prop="id" />
<el-table-column label="商品" align="center" prop="projectId" />
<el-table-column label="sku" align="center" prop="projectSku" />
<el-table-column label="用户" align="center" prop="userId" />
<el-table-column label="数量" align="center" prop="num" />
<el-table-column label="是否选中" align="center" prop="isSelected" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['shopCart:info:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['shopCart:info:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改购物车对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="商品" prop="projectId">
<el-input v-model="form.projectId" placeholder="请输入商品" />
</el-form-item>
<el-form-item label="sku" prop="projectSku">
<el-input v-model="form.projectSku" placeholder="请输入sku" />
</el-form-item>
<el-form-item label="用户" prop="userId">
<el-input v-model="form.userId" placeholder="请输入用户" />
</el-form-item>
<el-form-item label="数量" prop="num">
<el-input v-model="form.num" placeholder="请输入数量" />
</el-form-item>
<el-form-item label="是否选中" prop="isSelected">
<el-input v-model="form.isSelected" placeholder="请输入是否选中" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listInfo, getInfo, delInfo, addInfo, updateInfo } from "@/api/shopCart/info";
export default {
name: "Info",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
infoList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
projectId: null,
projectSku: null,
userId: null,
num: null,
isSelected: null,
},
//
form: {},
//
rules: {
projectId: [
{ required: true, message: "商品不能为空", trigger: "blur" }
],
projectSku: [
{ required: true, message: "sku不能为空", trigger: "blur" }
],
userId: [
{ required: true, message: "用户不能为空", trigger: "blur" }
],
num: [
{ required: true, message: "数量不能为空", trigger: "blur" }
],
isSelected: [
{ required: true, message: "是否选中不能为空", trigger: "blur" }
],
createBy: [
{ required: true, message: "创建人不能为空", trigger: "blur" }
],
createTime: [
{ required: true, message: "创建时间不能为空", trigger: "blur" }
],
}
};
},
created() {
this.getList();
},
methods: {
/** 查询购物车列表 */
getList() {
this.loading = true;
listInfo(this.queryParams).then(response => {
this.infoList = response.data.rows;
this.total = response.data.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
projectId: null,
projectSku: null,
userId: null,
num: null,
isSelected: null,
remark: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加购物车";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getInfo(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改购物车";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateInfo(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addInfo(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除购物车编号为"' + ids + '"的数据项?').then(function() {
return delInfo(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('shopCart/info/export', {
...this.queryParams
}, `info_${new Date().getTime()}.xlsx`)
}
}
};
</script>