Commit afb7fb8b by xinla

商品管理

1 parent 9554d9a7
import request from '@/utils/request'
const service = window.CONFIG.services.system + '/product'
const service = window.CONFIG.services.system + window.CONFIG.services.wecom + '/product'
/**
* 商品列表
......
<template>
<div class="preview">
<div class="title">{{ name }}</div>
<div class="content">
<div class="preview-title">{{ title }}</div>
<div class="preview-content">
<slot />
</div>
</div>
......@@ -10,7 +10,7 @@
export default {
components: {},
props: {
name: {
title: {
type: String,
default: '小微',
},
......@@ -27,6 +27,7 @@ export default {
<style lang="scss" scoped>
.preview {
margin: 0 auto;
padding: 0 10px;
position: relative;
width: 300px;
height: 640px;
......@@ -34,7 +35,7 @@ export default {
background-repeat: no-repeat;
background-size: 100% 100%;
.title {
.preview-title {
position: absolute;
top: 37px;
left: 50%;
......@@ -45,17 +46,15 @@ export default {
color: #333333;
}
.content {
position: absolute;
.preview-content {
position: relative;
height: 545px;
width: 280px;
overflow-y: auto;
top: 70px;
left: 50%;
transform: translateX(-50%);
// left: 50%;
// transform: translateX(-50%);
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
padding: 20px;
}
}
</style>
......@@ -4,7 +4,7 @@ import Router from 'vue-router'
Vue.use(Router)
const originalPush = Router.prototype.push
Router.prototype.push = function push (location) {
Router.prototype.push = function push(location) {
return originalPush.call(this, location).catch((err) => err)
}
......@@ -33,6 +33,37 @@ import visitor from '@/layout/visitor'
// 公共路由
export const constantRoutes = [
{
path: '/commodityCenter',
component: Layout,
hidden: true,
meta: {
title: '商品中心',
},
children: [
{
path: 'commodityManage',
name: 'group-code-analyse',
component: (resolve) => require(['@/views/commodityCenter/commodityManage/list'], resolve),
meta: {
title: '商品管理',
activeMenu: '/commodityCenter/commodityManage',
breadcrumb: true,
},
},
{
path: 'detail',
name: 'group-code-analyse',
component: (resolve) =>
require(['@/views/commodityCenter/commodityManage/detail'], resolve),
meta: {
title: '商品管理',
activeMenu: '/commodityCenter/commodityManage',
breadcrumb: true,
},
},
],
},
{
path: '/drainageCode/qrCode',
component: Layout,
hidden: true,
......
<script>
import * as api from '@/api/commodityCenter/commodityManage'
const defaultForm = {
picture: '',
price: 1,
describe: '',
attachments: [],
}
export default {
components: {},
props: {},
......@@ -13,12 +20,10 @@ export default {
},
// 遮罩层
loading: false,
submitLoading: false,
dialogVisible: false,
// 表单参数
form: {
groupName: '',
weTags: [],
},
form: JSON.parse(JSON.stringify(defaultForm)),
// 添加标签输入框
newInput: '',
// 添加标签显隐
......@@ -26,8 +31,8 @@ export default {
// 表单验证规则
rules: Object.freeze({
picture: [{ required: true, message: '必填项', trigger: 'change' }],
groupName: [{ required: true, message: '必填项', trigger: 'blur' }],
groupName: [{ required: true, message: '必填项', trigger: 'blur' }],
price: [{ required: true, message: '必填项', trigger: 'change' }],
describe: [{ required: true, message: '必填项', trigger: 'blur' }],
}),
// 选中数组
ids: [],
......@@ -61,13 +66,11 @@ export default {
this.loading = false
})
},
edit(data, type) {
this.form = JSON.parse(
JSON.stringify(Object.assign({ groupTagType: this.type, weTags: [] }, data || {}))
)
edit(data = {}, type) {
this.form = JSON.parse(JSON.stringify(Object.assign(defaultForm, data)))
this.dialogVisible = true
},
syncTag() {
sync() {
const loading = this.$loading({
lock: true,
text: 'Loading',
......@@ -85,6 +88,21 @@ export default {
loading.close()
})
},
submit() {
this.$refs['form'].validate((valid) => {
let form = JSON.parse(JSON.stringify(this.form))
form.price = form.price.toFixed(2)
this.submitLoading = true
api[form.id ? 'update' : 'add'](form)
.then(() => {
this.msgSuccess('操作成功')
this.dialogVisible = false
})
.finally(() => {
this.submitLoading = false
})
})
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.groupId)
......@@ -104,6 +122,14 @@ export default {
this.msgSuccess('删除成功')
})
},
goRoute(row) {
this.$router.push({
path: './detail',
query: {
id: row.id,
},
})
},
},
}
</script>
......@@ -148,9 +174,9 @@ export default {
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="{ row, index }">
<!-- v-hasPermi="['customerManage:tag:edit']" -->
<el-button type="text" @click="goRoute(row, index)">详情</el-button>
<el-button type="text" @click="goRoute(row)">详情</el-button>
<el-button type="text" @click="edit(row, index)">编辑</el-button>
<el-button @click="remove(row.groupId)" type="text">删除</el-button>
<el-button type="text" @click="remove(row.id)">删除</el-button>
<!-- v-hasPermi="['customerManage:tag:remove']" -->
</template>
</el-table-column>
......@@ -168,15 +194,15 @@ export default {
<el-dialog
:title="form.id ? '修改' : '新建'"
:visible.sync="dialogVisible"
width="600px"
width="800px"
:close-on-click-modal="false"
>
<el-row>
<el-col :span="12">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="商品封面" prop="picture">
<upload :fileUrl.sync="form.picture" type="0">
<div slot="tip">支持jpg/jpeg/png格式,图片大小不超过20M</div>
<div slot="tip" class="tip">支持jpg/jpeg/png格式,图片大小不超过20M</div>
</upload>
</el-form-item>
<el-form-item label="商品单价(元)" prop="price">
......@@ -195,39 +221,60 @@ export default {
type="textarea"
:maxlength="300"
show-word-limit
:autosize="{ minRows: 2, maxRows: 50 }"
:autosize="{ minRows: 4, maxRows: 50 }"
placeholder="请输入"
></el-input>
</el-form-item>
<el-form-item label="商品详情">
<upload :fileUrl.sync="form.attachments" type="0">
<div slot="tip">
最多添加八张详情,支持JPG,PNG格式,图片大小不超过2M,建议上传宽高1:1的图片
</div>
<div slot="tip" class="tip">最多添加八张详情</div>
</upload>
</el-form-item>
<div slot="footer" class="dialog-footer">
<el-button type="primary" v-loading="submitLoading" @click="submit">确 定</el-button>
<el-button @click="dialogVisible = false">取 消</el-button>
</div>
</el-form>
</el-col>
<el-col :span="12">
<PhoneTemplate>
<el-image style="width: 100%; height: 50px" :src="form.picture"></el-image>
<div class="price">¥{{ form.picture }}</div>
<div class="content">{{ form.describe }}</div>
<el-image
v-for="(item, index) of form.attachments"
style="width: 100%; height: 50px"
:src="item.picURL"
:key="index"
></el-image>
<div class="phone-content">
<el-image
class="commodity-img commodity-thumb"
style="width: 100%; height: 50px"
:src="form.picture"
></el-image>
<div class="price">¥{{ form.price.toFixed(2) }}</div>
<div class="content">{{ form.describe }}</div>
<el-image
v-for="(item, index) of form.attachments"
class="commodity-img"
:src="item.picURL"
:key="index"
></el-image>
</div>
</PhoneTemplate>
</el-col>
</el-row>
<div slot="footer" class="dialog-footer ar">
<el-button type="primary" v-loading="submitLoading" @click="submit">确 定</el-button>
<el-button @click="dialogVisible = false">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<style lang="scss" scoped></style>
<style lang="scss" scoped>
.tip {
color: #aaa;
font-size: 12px;
line-height: 20px;
}
.phone-content {
padding: 10px;
}
.price {
font-weight: 500;
font-size: 20px;
margin: 10px 0;
}
.commodity-img {
width: 100%;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!