Commit 70fb686f by zhangquan

优惠券基本开发

1 parent 0a732b3c
......@@ -12,6 +12,7 @@
{{ item.label ? ':' : '' }}
</span>
<slot v-if="item.addHtml" :name="item.addHtml" :scope="item"></slot>
<div class="showTxt" v-else-if="item.type === 'showTxt'">{{ formObj[item.name] }}</div>
<div v-else-if="item.type === 'input'">
<el-input :placeholder="item.placeholder || '请输入' + item.label" v-model.trim="formObj[item.name]" :disabled="item.isDisabled" :maxlength="item.maxlength" :clearable="item.isClear || false" :type="item.inputType || 'text'" :rows="item.rows || 2" :style="{ width: item.width || defaultWidth }" :show-word-limit="item.showLimit || false" :show-password="item.showPass || false" @keydown.native="e => handleInputDown(e, item)" @blur="e => handleInputBlur(e, item)">
<span v-if="item.prepend" slot="prepend">{{ item.prepend }}</span>
......@@ -168,9 +169,9 @@ export default {
type: Object,
default: () => {}
},
isInline:{
type:Boolean,
default:true
isInline: {
type: Boolean,
default: true
}
},
......
......@@ -11,31 +11,36 @@ const staticRoutes = Object.freeze([
component: resolve => require([`@/views/about/index.vue`], resolve),
meta: {}
},
{//领用管理
{
//领用管理
name: 'Collection',
path: '/collection/index',
component: resolve => require([`@/views/collection/index.vue`], resolve),
meta: {}
},
{//e代驾订单
{
//e代驾订单
name: 'EManagement',
path: '/eManagement/index',
component: resolve => require([`@/views/eManagement/index.vue`], resolve),
meta: {}
},
{//财务管理
{
//财务管理
name: 'Financial',
path: '/financial/index',
component: resolve => require([`@/views/financial/index.vue`], resolve),
meta: {}
},
{//加油订单
{
//加油订单
name: 'Gas',
path: '/gas/index',
component: resolve => require([`@/views/gas/index.vue`], resolve),
meta: {}
},
{//商品管理
{
//商品管理
name: 'Goods',
path: '/goods/index',
component: resolve => require([`@/views/goods/index.vue`], resolve),
......@@ -47,7 +52,8 @@ const staticRoutes = Object.freeze([
component: resolve => require([`@/views/goods/addGoods.vue`], resolve),
meta: {}
},
{//权益列表管理
{
//权益列表管理
name: 'List',
path: '/list/index',
component: resolve => require([`@/views/list/index.vue`], resolve),
......@@ -59,13 +65,15 @@ const staticRoutes = Object.freeze([
component: resolve => require([`@/views/order/detail.vue`], resolve),
meta: {}
},
{//订单管理
{
//订单管理
name: 'Order',
path: '/order/index',
component: resolve => require([`@/views/order/index.vue`], resolve),
meta: {}
},
{//权益卡管理
{
//权益卡管理
name: 'RightsCard',
path: '/rightsCard/index',
component: resolve => require([`@/views/rightsCard/index.vue`], resolve),
......@@ -77,17 +85,40 @@ const staticRoutes = Object.freeze([
component: resolve => require([`@/views/sale/detail.vue`], resolve),
meta: {}
},
{//售后管理
{
//售后管理
name: 'Sale',
path: '/sale/index',
component: resolve => require([`@/views/sale/index.vue`], resolve),
meta: {}
},
{//小程序短链
{
//小程序短链
name: 'ShortLink',
path: '/shortLink/index',
component: resolve => require([`@/views/shortLink/index.vue`], resolve),
meta: {}
},
{
//商品优惠券
name: 'goodsConpon',
path: '/goodsConpon/index',
component: resolve => require([`@/views/goodsConpon/index.vue`], resolve),
meta: {}
},
{
//增加商品优惠券
name: 'addConpon',
path: '/goodsConpon/addConpon',
component: resolve => require([`@/views/goodsConpon/addConpon.vue`], resolve),
meta: {}
},
{
//商品优惠券领取详情页
name: 'receivedDetail',
path: '/goodsConpon/receivedDetail',
component: resolve => require([`@/views/goodsConpon/receivedDetail.vue`], resolve),
meta: {}
}
])
export default staticRoutes
......@@ -2,23 +2,23 @@
* 日期格式化
* let time = new Date().format('yyyy-MM-dd hh:mm:ss')
*/
Date.prototype.format = function (fmt) {
Date.prototype.format = function(fmt) {
let o = {
'M+': this.getMonth() + 1, //月份
'd+': this.getDate(), //日
'h+': this.getHours(), //小时
'm+': this.getMinutes(), //分
's+': this.getSeconds(), //秒
//季度
'M+': this.getMonth() + 1, //月份
'd+': this.getDate(), //日
'h+': this.getHours(), //小时
'm+': this.getMinutes(), //分
's+': this.getSeconds(), //秒
//季度
'q+': Math.floor((this.getMonth() + 3) / 3),
'S': this.getMilliseconds() //毫秒
};
S: this.getMilliseconds() //毫秒
}
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
}
for (let k in o) {
if (new RegExp(`(${k})`).test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length))
}
}
return fmt
......@@ -41,16 +41,16 @@ const decimal = (num, fixed) => {
let pow = Math.pow(10, fixed)
return Math.round(num * pow) / pow
}
const getHttpsImgUrl = (url) => {
const getHttpsImgUrl = url => {
if (!url) {
return ''
}
var flag = url.startsWith("http:")
var flag = url.startsWith('http:')
if (flag) {
var newurl = url.replace("http:", "https:")
var newurl = url.replace('http:', 'https:')
//去掉http自动带的端口 :7060,https不能有
var startPos = newurl.lastIndexOf(":")
var endPos = newurl.indexOf("/", startPos)
var startPos = newurl.lastIndexOf(':')
var endPos = newurl.indexOf('/', startPos)
var preStr = newurl.substring(0, startPos)
var afterStr = newurl.substring(endPos)
var finalStr = preStr + afterStr
......@@ -59,12 +59,53 @@ const getHttpsImgUrl = (url) => {
}
return url
}
const getExplorer = function() {
var ua = navigator.userAgent.toLocaleLowerCase()
var browserType = null
if (ua.match(/msie/) != null || ua.match(/trident/) != null) {
browserType = 'IE'
} else if (ua.match(/firefox/) != null) {
browserType = '火狐'
} else if (ua.match(/ubrowser/) != null) {
browserType = 'UC'
} else if (ua.match(/opera/) != null) {
browserType = '欧朋'
} else if (ua.match(/bidubrowser/) != null) {
browserType = '百度'
} else if (ua.match(/metasr/) != null) {
browserType = '搜狗'
} else if (ua.match(/tencenttraveler/) != null || ua.match(/qqbrowse/) != null) {
browserType = 'QQ'
} else if (ua.match(/maxthon/) != null) {
browserType = '遨游'
} else {
browserType = '谷歌'
}
return browserType
}
const exportFn = function(api, params) {
api(params).then(res => {
let tempaa = getExplorer()
if (tempaa == 'QQ') {
window.open(res)
} else {
let iframe = document.createElement('iframe')
iframe.style.display = 'none'
iframe.src = res
document.body.appendChild(iframe)
}
})
}
import Vue from 'vue'
const utils = {
getParams,
decimal,
getHttpsImgUrl
getHttpsImgUrl,
getExplorer,
exportFn
}
Object.keys(utils).map(key => {
Vue.prototype[key] = utils[key]
})
\ No newline at end of file
})
<template>
<div class="container">
<glsx-combi-form :isInline="false" ref="couponRef" labelWidth="154px" defaultWidth="432px" :formObj.sync="conponFormObj" :formData="conponFormData" :formRules="conponRule">
<div slot="selectGoods">
<el-button type="primary" @click="openConponDialog">选择商品</el-button>
<div>
<div v-for="(item, index) in selectedGoodsList" :key="item.id">{{ index + 1 }}{{ item.id }}</div>
</div>
</div>
<div slot="validityDate">
<el-input class="date_input" v-model.number="conponFormObj.date" oninput="value=value.replace(/^0/g,'').replace(/[^\d]/g,'')" type="text" />
天
</div>
</glsx-combi-form>
<GLDialog bigTitle="选择商品优惠券" mode="big" v-if="isVisible" :visible.sync="isVisible" :show-close="true" :before-close="handleClose" :close-on-click-modal="false" @onOk="onOk" @onCancel="onCancel">
<GLCombiForm ref="searchRef" :formObj="dialogSearchForm" :formData="dialogFormData" @handleOk="handleOk" @handleRest="handleRest"></GLCombiForm>
<div class="conpon_type">
<span :class="['type', { active_type: curType == '1' }]" @click="changeConponType(1)">直充</span>
<span :class="['type', { active_type: curType == '2' }]" @click="changeConponType(2)">卡券</span>
</div>
<GLTable ref="tableRef" :pageConf="pageConf" @setTableFinishFun="setTableFinishFun" :searchForm="dialogSearchForm" :tableParams="tableParams" :getListApi="getListApi"></GLTable>
</GLDialog>
<div class="btn">
<el-button type="primary" @click="commit()">确定</el-button>
</div>
</div>
</template>
<script>
export default {
name: 'index',
data() {
return {
isVisible: true,
curType: 1,
selectedGoodsList: [],
copyList: [],
conponFormData: [
{
label: '选择产品',
name: 'gooods',
addHtml: 'selectGoods'
},
{
label: '有效期',
name: 'date',
addHtml: 'validityDate'
}
],
conponFormObj: {
gooods: '',
date: ''
},
conponRule: {
gooods: [{ required: true, message: '', trigger: 'change' }],
date: [{ required: true, message: '请输入有效期', trigger: 'change' }]
},
dialogSearchForm: {
brand: '0',
goodsName: ''
},
dialogFormData: [
{
label: '商品品牌',
name: 'brand',
type: 'select',
optionList: [
{
id: '0',
label: '全部'
},
{
id: '1',
label: '益禾堂'
},
{
id: '2',
label: '肯德基'
}
],
optionId: 'id',
optionLabel: 'label',
isClear: true
},
{
label: '商品名称',
name: 'goodsName',
type: 'input',
isClear: true
}
],
getListApi: this.$apis.orderApi.getGoodsList,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
tableParams: {
listName: 'list',
mutiSelectName: 'goodsIndex',
mutiSelectUniqueKey: 'id',
tableOption: false,
tableColumns: [
{
label: '品牌',
width: 150,
formatter: cell => {
return '海威'
}
},
{
label: '商品名称',
minWidth: 150,
formatter: cell => {
let str = cell.appearance == 1 ? `${cell.brandName || ''}${cell.productName || ''}` : `${cell.brandName || ''}${cell.productName || ''}${cell.denomination || ''}`
return str
}
},
{
label: '差价',
width: 110,
align: 'right',
formatter: cell => {
return cell.stock == -1 ? '无限制' : cell.stock
}
},
{
label: '官方价',
width: 110,
align: 'right',
formatter: cell => {
return cell.stock == -1 ? '无限制' : cell.stock
}
},
{
label: '成本价',
width: 110,
align: 'right',
formatter: cell => {
return cell.stock == -1 ? '无限制' : cell.stock
}
},
{
label: '会员价',
width: 110,
align: 'right',
formatter: cell => {
return cell.stock == -1 ? '无限制' : cell.stock
}
}
]
}
}
},
methods: {
handleOk() {
this.$refs.tableRef.refreshTable()
},
handleRest() {
this.searchForm = {
brand: '0',
goodsName: ''
}
this.handleOk()
},
changeConponType(type) {
this.curType = type
// if (type == 2) {
// }
},
onOk() {
console.log(this.$refs.tableRef.mutiSelectArr[this.tableParams.mutiSelectName])
this.selectedGoodsList = this.$refs?.tableRef?.mutiSelectArr?.[this.tableParams?.mutiSelectName]
this.handleClose()
},
onCancel() {},
handleClose() {
this.isVisible = false
},
setTableFinishFun() {
this.copyList.forEach(row => {
this.$nextTick(() => {
let idx = this.$refs.tableRef.$refs[this.tableParams.mutiSelectName + 'MutiTable'].data.findIndex(item => item.id == row.id)
console.log(idx)
if (idx > -1) {
try {
this.$refs.tableRef.$refs[this.tableParams.mutiSelectName + 'MutiTable'].toggleRowSelection(this.$refs.tableRef.$refs[this.tableParams.mutiSelectName + 'MutiTable'].data[idx], true)
let id = this.copyList.findIndex(item => item.id == row.id)
if (id > -1) this.copyList.splice(id, 1)
} catch (err) {
console.log(err)
}
}
})
})
},
openConponDialog() {
console.log(this.selectedGoodsList)
this.copyList = [...this.selectedGoodsList]
this.isVisible = true
},
commit() {}
}
}
</script>
<style lang="scss" scoped>
.container {
background-color: #fff;
padding: 30px;
min-height: 500px;
position: relative;
.date_input {
width: 100px;
}
.btn {
width: 100%;
position: absolute;
bottom: 10px;
text-align: center;
}
.conpon_type {
display: inline-block;
border: 1px solid #eee;
border-radius: 4px;
.type {
display: inline-block;
height: 40px;
width: 60px;
line-height: 40px;
text-align: center;
border-radius: 4px;
cursor: pointer;
}
.active_type {
background-color: #5850ff;
color: #fff;
}
}
}
</style>
<template>
<div class="container">
<GLCombiForm ref="searchRef" :formObj="searchForm" :formData="searchFormData" @handleOk="handleOk" @handleRest="handleRest"></GLCombiForm>
<GLButton fn="新增商品优惠券" plain size="small" style="float:left;margin-bottom:10px;" @click="addConpon">创建商品优惠券</GLButton>
<el-button plain size="small" style="float:right;margin-bottom:10px;" @click="handleExport">导出</el-button>
<GLTable ref="tableRef" :pageConf="pageConf" :searchForm="searchForm" :tableParams="tableParams" :getListApi="getListApi">
<div slot="table-btns" slot-scope="scope">
<GLTableButton :buttonList="buttonList" :buttonItem="scope" :buttonNum="3"></GLTableButton>
</div>
</GLTable>
</div>
</template>
<script>
import utils from '../../utils/util'
export default {
name: 'index',
data() {
return {
getListApi: this.$apis.orderApi.getGoodsList,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
searchForm: {
brand: '0',
goodsName: '',
type: '0',
status: '0'
},
buttonList: [
{
type: 'el-button',
name: row => {
return '生效'
},
attrs: {
type: 'text',
fn: '生效'
},
listeners: {
click: row => this.changeStatus(row.scope)
}
},
{
type: 'el-button',
name: row => {
return '失效'
},
attrs: {
type: 'text',
fn: '失效'
},
condition: row => {
return false
},
listeners: {
click: row => this.changeStatus(row.scope)
}
},
{
type: 'GLButton',
name: row => {
return '领取详情'
},
attrs: {
type: 'text',
fn: '领取详情'
},
listeners: {
click: row => this.goDetailPage(row.scope)
}
}
],
tableParams: {
listName: 'list',
tableOption: false,
tableColumns: [
{
label: '品牌',
width: 150,
formatter: cell => {
return '海威'
}
},
{
label: '商品名称',
minWidth: 150,
formatter: cell => {
let str = cell.appearance == 1 ? `${cell.brandName || ''}${cell.productName || ''}` : `${cell.brandName || ''}${cell.productName || ''}${cell.denomination || ''}`
return str
}
},
{
label: '商品形态',
width: 150,
prop: 'salesPrice',
formatter(cell) {
return parseFloat(cell.salesPrice).toFixed(2)
}
},
{
label: '券面额',
width: 110,
align: 'right',
formatter: cell => {
return cell.stock == -1 ? '无限制' : cell.stock
}
},
{
label: '有效期',
prop: 'salesPrice'
},
{
label: '状态',
prop: 'salesPrice'
},
{
label: '已领取',
prop: 'salesPrice'
},
{
label: '已使用',
prop: 'salesPrice'
},
{
label: '创建日期',
width: 150,
prop: 'salesPrice'
},
{
label: '操作',
width: 170,
fixed: 'right',
addHtml: 'table-btns'
}
]
},
searchFormData: [
{
label: '商品品牌',
name: 'brand',
type: 'select',
optionList: [
{
id: '0',
label: '全部'
},
{
id: '1',
label: '益禾堂'
},
{
id: '2',
label: '肯德基'
}
],
optionId: 'id',
optionLabel: 'label',
isClear: true
},
{
label: '商品名称',
name: 'goodsName',
type: 'input',
isClear: true
},
{
label: '商品形态',
name: 'type',
type: 'select',
optionList: [
{
id: '0',
label: '全部'
},
{
id: '1',
label: '卡券'
},
{
id: '2',
label: '直充'
}
],
optionId: 'id',
optionLabel: 'label',
isClear: true
},
{
label: '状态',
name: 'status',
type: 'select',
optionList: [
{
id: '0',
label: '全部'
},
{
id: '1',
label: '生效中'
},
{
id: '2',
label: '已失效'
}
],
optionId: 'id',
optionLabel: 'label',
isClear: true
}
]
}
},
methods: {
handleOk() {
this.$refs.tableRef.refreshTable()
},
handleRest() {
this.searchForm = {
brand: '0',
goodsName: '',
type: '0',
status: '0'
}
this.handleOk()
},
// 导出
handleExport() {
var params = { ...this.searchForm }
this.$apis.beforeSale.getExportApi(params).then(res => {
let tempaa = utils.getExplorer()
if (tempaa == 'QQ') {
window.open(res)
} else {
let iframe = document.createElement('iframe')
iframe.style.display = 'none'
iframe.src = res
document.body.appendChild(iframe)
}
})
},
goDetailPage() {
this.$router.push('/goodsConpon/receivedDetail')
},
changeStatus() {},
addConpon() {
this.$router.push('/goodsConpon/addConpon')
}
}
}
</script>
<style lang="scss" scoped>
.container {
background-color: #fff;
padding: 30px;
}
</style>
<template>
<div class="container">
<glsx-combi-form :isInline="true" ref="couponInfoRef" labelWidth="154px" defaultWidth="432px" :formObj.sync="conponInfoFormObj" :formData="conponInfoFormData" :formRules="conponInfoRule"></glsx-combi-form>
<GLCombiForm ref="searchRef" :formObj="searchForm" :formData="searchFormData" @handleOk="handleOk" @handleRest="handleRest"></GLCombiForm>
<el-button plain size="small" style="float:right;margin-bottom:10px;" @click="handleExport">导出</el-button>
<GLTable ref="tableRef" :pageConf="pageConf" :searchForm="searchForm" :tableParams="tableParams" :getListApi="getListApi"></GLTable>
</div>
</template>
<script>
import utils from '../../utils/util'
export default {
name: 'index',
data() {
return {
conponInfoFormObj: {
brand: '肯德基',
goodsName: '肯德基优惠券',
status: '直充',
price: '123',
date: '30天',
received: '100',
used: '4'
},
conponInfoFormData: [
{
label: '品牌',
name: 'brand',
type: 'showTxt'
},
{
label: '商品名称',
name: 'goodsName',
type: 'showTxt'
},
{
label: '商品形态',
name: 'status',
type: 'showTxt'
},
{
label: '券面额',
name: 'price',
type: 'showTxt'
},
{
label: '有效期',
name: 'date',
type: 'showTxt'
},
{
label: '已领取',
name: 'received',
type: 'showTxt'
},
{
label: '已使用',
name: 'used',
type: 'showTxt'
}
],
conponInfoRule: {
brand: { required: true, message: '', trigger: 'change' },
goodsName: { required: true, message: '', trigger: 'change' },
status: { required: true, message: '', trigger: 'change' },
price: { required: true, message: '', trigger: 'change' },
date: { required: true, message: '', trigger: 'change' },
received: { required: true, message: '', trigger: 'change' },
used: { required: true, message: '', trigger: 'change' }
},
getListApi: this.$apis.orderApi.getGoodsList,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
tableParams: {
listName: 'list',
tableOption: false,
tableColumns: [
{
label: '客户信息',
formatter: cell => {
return '海威'
}
},
{
label: '使用状态',
formatter: cell => {
let str = cell.appearance == 1 ? `${cell.brandName || ''}${cell.productName || ''}` : `${cell.brandName || ''}${cell.productName || ''}${cell.denomination || ''}`
return str
}
},
{
label: '所属商户',
prop: 'salesPrice',
formatter(cell) {
return parseFloat(cell.salesPrice).toFixed(2)
}
},
{
label: '领取日期',
formatter: cell => {
return cell.stock == -1 ? '无限制' : cell.stock
}
},
{
label: '使用日期',
prop: 'salesPrice'
}
]
},
searchForm: {
userInfo: '',
merchant: '',
status: '0',
receivedDate: ''
},
searchFormData: [
{
label: '用户信息',
name: 'userInfo',
type: 'input',
maxLength: 11,
isClear: true
},
{
label: '使用状态',
name: 'type',
type: 'select',
optionList: [
{
id: '0',
label: '全部'
},
{
id: '1',
label: '已领取'
},
{
id: '2',
label: '已使用'
},
{
id: '3',
label: '已过期'
}
],
optionId: 'id',
optionLabel: 'label',
isClear: true
},
{
label: '所属商户',
name: 'merchant',
type: 'input',
isClear: true
},
{
label: '领取日期',
name: 'successDate',
type: 'datePicker',
isClear: true
}
]
}
},
methods: {
handleOk() {
this.$refs.tableRef.refreshTable()
},
handleRest() {
this.searchForm = {
userInfo: '',
merchant: '',
status: '0',
receivedDate: ''
}
this.handleOk()
},
// 导出
handleExport() {
var params = { ...this.searchForm }
this.$apis.beforeSale.getExportApi(params).then(res => {
let tempaa = utils.getExplorer()
if (tempaa == 'QQ') {
window.open(res)
} else {
let iframe = document.createElement('iframe')
iframe.style.display = 'none'
iframe.src = res
document.body.appendChild(iframe)
}
})
}
}
}
</script>
<style lang="scss" scoped>
.container {
background-color: #fff;
padding: 30px;
/deep/ .showTxt {
width: 200px;
}
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!