Commit 5f24d8bf by 前端

Merge branch 'v3.5.0' into 'master'

V3.5.0

See merge request !13
2 parents f3f13764 dbfda7b4
This diff could not be displayed because it is too large.
import { other_http } from '@/main'
const url = 'rop-scrm-coupon/router'
const defaultPath = 'scrm.api.coupon.'
/**商品分页查询*/
const getCouponsList = params => {
params.method = `${defaultPath}equity.list.merchant`
return other_http({
url,
data: params
})
}
const createCoupons = params => {
params.method = `${defaultPath}equity.batch.create`
return other_http({
url,
data: params
})
}
const getExportApi = params => {
params.method = `${defaultPath}equity.list.merchant.export`
return other_http({
url,
data: params,
sign: true
})
}
//领取记录列表
const getListReceiveRecordApi = params => {
params.method = `${defaultPath}listReceiveRecordByCouponId`
return other_http({
url,
method: 'GET',
data: params,
sign: true
})
}
//查看优惠券
const getCouponDetailApi = params => {
params.method = `${defaultPath}detail`
return other_http({
url,
method: 'GET',
data: params,
sign: true
})
}
//删除
const deleteCouponApi = params => {
params.method = `${defaultPath}delete`
return other_http({
url,
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
// 优惠券-作废
const couponUserCancelApi = params => {
params.method = `${defaultPath}user.cancel`
return other_http({
url,
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
const detailExportApi = params => {
params.method = `${defaultPath}equity.exportReceiveRecord`
return other_http({
url,
data: params,
sign: true
})
}
//生效/失效
const effectiveCouponApi = params => {
params.method = `${defaultPath}effective`
return other_http({
url,
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
export default {
getCouponsList,
createCoupons,
getExportApi,
getListReceiveRecordApi,
getCouponDetailApi,
deleteCouponApi,
couponUserCancelApi,
detailExportApi,
effectiveCouponApi
}
.equity-wrap .contain { .equity-wrap .contain {
background: #FFFFFF; background: #ffffff;
// margin: 0 0 20px 0; // margin: 0 0 20px 0;
padding: 20px 15px; padding: 20px 15px;
// box-shadow: 0 1px 5px 0 rgba(38, 38, 38, 0.10); // box-shadow: 0 1px 5px 0 rgba(38, 38, 38, 0.10);
} }
.equity-wrap .contain .el-table__empty-text{ .equity-wrap .contain .el-table__empty-text {
display: inline-block; display: inline-block;
width: 64px; width: 64px;
height: 41px; height: 41px;
} }
.fr-mr0 { .fr-mr0 {
float: right; float: right;
margin-right: 0px!important; margin-right: 0px !important;
} }
// 单行省略 // 单行省略
.ellipsis-1 { .ellipsis-1 {
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
-o-text-overflow: ellipsis; -o-text-overflow: ellipsis;
/* for Opera */ /* for Opera */
} }
.mb10{ .mb10 {
margin-bottom: 10px; margin-bottom: 10px;
} }
// 我这里以两行为例,该方法基本兼容市场上面所有主流浏览器。 // 我这里以两行为例,该方法基本兼容市场上面所有主流浏览器。
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
} }
.ellipsis-2-text:after { .ellipsis-2-text:after {
content: "..."; content: '...';
position: absolute; position: absolute;
bottom: 0; bottom: 0;
right: 15px; right: 15px;
...@@ -48,13 +48,13 @@ ...@@ -48,13 +48,13 @@
background: -moz-linear-gradient(left, transparent, #fff 55%); background: -moz-linear-gradient(left, transparent, #fff 55%);
background: linear-gradient(to right, transparent, #fff 55%); background: linear-gradient(to right, transparent, #fff 55%);
} }
.el-scrollbar__bar.is-horizontal{ .el-scrollbar__bar.is-horizontal {
height: 10px !important; height: 10px !important;
left: 10px; left: 10px;
} }
.base-container-right .el-main-scroll .el-scrollbar__thumb { .base-container-right .el-main-scroll .el-scrollbar__thumb {
background-color: rgba(144, 147, 153, 0.5) !important; background-color: rgba(144, 147, 153, 0.5) !important;
} }
.equity-wrap .el-table .cell { .equity-wrap .el-table .cell {
...@@ -63,8 +63,8 @@ ...@@ -63,8 +63,8 @@
.equity-wrap .table-btns .el-button { .equity-wrap .table-btns .el-button {
padding: 0 0 0 5px; padding: 0 0 0 5px;
margin-left: 5px; margin-left: 5px;
border-left: 1px solid #DCDFE6; border-left: 1px solid #dcdfe6;
border-radius: 0; border-radius: 0;
} }
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
height: 64px; height: 64px;
text-align: center; text-align: center;
line-height: 64px; line-height: 64px;
background: #FFFFFF; background: #ffffff;
z-index: 999; z-index: 999;
} }
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
height: 48px; height: 48px;
line-height: 48px; line-height: 48px;
// color: #0947C6; // color: #0947C6;
border-bottom: 1px solid #E7EAEC; border-bottom: 1px solid #e7eaec;
// padding-left: 20px; // padding-left: 20px;
margin: 0 0; margin: 0 0;
} }
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
width: 4px; width: 4px;
top: 2px; top: 2px;
left: 0; left: 0;
background-color: #0947C6; background-color: #0947c6;
} }
.equity-wrap .edit-sub-title { .equity-wrap .edit-sub-title {
...@@ -128,7 +128,7 @@ ...@@ -128,7 +128,7 @@
margin: 0 0 30px 0; margin: 0 0 30px 0;
padding-left: 8px; padding-left: 8px;
} }
.find_wrap{ .find_wrap {
background: #ffffff; background: #ffffff;
padding: 20px 15px; padding: 20px 15px;
// padding: 20px 20px 0px 20px; // padding: 20px 20px 0px 20px;
...@@ -140,7 +140,7 @@ ...@@ -140,7 +140,7 @@
margin-bottom: 10px; margin-bottom: 10px;
margin-right: 2px; margin-right: 2px;
} }
.pannel{ .pannel {
padding: 0 15px; padding: 0 15px;
} }
.table_wrap { .table_wrap {
...@@ -153,33 +153,33 @@ ...@@ -153,33 +153,33 @@
width: 100%; width: 100%;
} }
} }
.flex_sc{ .flex_sc {
display: flex; display: flex;
align-items: center; align-items: center;
} }
.flex_cc{ .flex_cc {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
.flex_scb{ .flex_scb {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
} }
.table_point{ .table_point {
width: 6px; width: 6px;
height: 6px; height: 6px;
border-radius: 50%; border-radius: 50%;
margin-right: 8px; margin-right: 8px;
} }
.loadingClass{ .loadingClass {
.el-icon-loading{ .el-icon-loading {
font-size: 22px; font-size: 22px;
} }
.el-icon-loading, .el-icon-loading,
.el-loading-text{ .el-loading-text {
color: #fff!important; color: #fff !important;
} }
} }
// .equity-wrap table { // .equity-wrap table {
...@@ -208,4 +208,24 @@ ...@@ -208,4 +208,24 @@
// .equity-wrap table td { // .equity-wrap table td {
// min-width: 50px; // min-width: 50px;
// }
\ No newline at end of file \ No newline at end of file
// }
.operate_wrap {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
.table_title {
height: 32px;
font-family: PingFangSC-Medium;
font-weight: 600;
font-size: 16px;
color: #333333;
line-height: 32px;
}
.operate_btn {
.export_btn {
margin-left: 8px;
}
}
}
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
{{ item.label ? ':' : '' }} {{ item.label ? ':' : '' }}
</span> </span>
<slot v-if="item.addHtml" :name="item.addHtml" :scope="item"></slot> <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'"> <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)"> <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> <span v-if="item.prepend" slot="prepend">{{ item.prepend }}</span>
...@@ -168,9 +169,9 @@ export default { ...@@ -168,9 +169,9 @@ export default {
type: Object, type: Object,
default: () => {} default: () => {}
}, },
isInline:{ isInline: {
type:Boolean, type: Boolean,
default:true default: true
} }
}, },
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
*/ */
// 根据环境引入不同配置 process.env.VUE_APP_ENV // 根据环境引入不同配置 process.env.VUE_APP_ENV
// let request = require('@/http/request.js') // let request = require('@/http/request.js')
import {Http } from 'glsx-common' import { Http } from 'glsx-common'
let cfg = require('./conf.js') let cfg = require('./conf.js')
export const fetchConfig = function(isEnv = true) { export const fetchConfig = function(isEnv = true) {
// if (isEnv) { // if (isEnv) {
......
...@@ -21,7 +21,5 @@ start() ...@@ -21,7 +21,5 @@ start()
export { bootstrap, mount, unmount } from '@/setup' export { bootstrap, mount, unmount } from '@/setup'
export const http = params => Vue.prototype.$http(params) export const http = params => Vue.prototype.$http(params)
export const new_http = params => Vue.prototype.$new_http(params) export const new_http = params => Vue.prototype.$new_http(params)
export const other_http = params => Vue.prototype.$other_http(params)
import './utils/util.js' import './utils/util.js'
...@@ -25,7 +25,7 @@ VueRouter.prototype.push = function push(location) { ...@@ -25,7 +25,7 @@ VueRouter.prototype.push = function push(location) {
// } // }
function getRoutes(routesData) { function getRoutes(routesData) {
return routesData.reduce((routes, route) => { return routesData.reduce((routes, route) => {
routes.push({ ...route, component: () => import('@/views' + route.path + '.vue') }) routes.push({ ...route, component: () => import('@/views' + route.compath + '.vue') })
return routes return routes
}, []) }, [])
} }
......
...@@ -11,31 +11,36 @@ const staticRoutes = Object.freeze([ ...@@ -11,31 +11,36 @@ const staticRoutes = Object.freeze([
component: resolve => require([`@/views/about/index.vue`], resolve), component: resolve => require([`@/views/about/index.vue`], resolve),
meta: {} meta: {}
}, },
{//领用管理 {
//领用管理
name: 'Collection', name: 'Collection',
path: '/collection/index', path: '/collection/index',
component: resolve => require([`@/views/collection/index.vue`], resolve), component: resolve => require([`@/views/collection/index.vue`], resolve),
meta: {} meta: {}
}, },
{//e代驾订单 {
//e代驾订单
name: 'EManagement', name: 'EManagement',
path: '/eManagement/index', path: '/eManagement/index',
component: resolve => require([`@/views/eManagement/index.vue`], resolve), component: resolve => require([`@/views/eManagement/index.vue`], resolve),
meta: {} meta: {}
}, },
{//财务管理 {
//财务管理
name: 'Financial', name: 'Financial',
path: '/financial/index', path: '/financial/index',
component: resolve => require([`@/views/financial/index.vue`], resolve), component: resolve => require([`@/views/financial/index.vue`], resolve),
meta: {} meta: {}
}, },
{//加油订单 {
//加油订单
name: 'Gas', name: 'Gas',
path: '/gas/index', path: '/gas/index',
component: resolve => require([`@/views/gas/index.vue`], resolve), component: resolve => require([`@/views/gas/index.vue`], resolve),
meta: {} meta: {}
}, },
{//商品管理 {
//商品管理
name: 'Goods', name: 'Goods',
path: '/goods/index', path: '/goods/index',
component: resolve => require([`@/views/goods/index.vue`], resolve), component: resolve => require([`@/views/goods/index.vue`], resolve),
...@@ -47,7 +52,8 @@ const staticRoutes = Object.freeze([ ...@@ -47,7 +52,8 @@ const staticRoutes = Object.freeze([
component: resolve => require([`@/views/goods/addGoods.vue`], resolve), component: resolve => require([`@/views/goods/addGoods.vue`], resolve),
meta: {} meta: {}
}, },
{//权益列表管理 {
//权益列表管理
name: 'List', name: 'List',
path: '/list/index', path: '/list/index',
component: resolve => require([`@/views/list/index.vue`], resolve), component: resolve => require([`@/views/list/index.vue`], resolve),
...@@ -59,13 +65,15 @@ const staticRoutes = Object.freeze([ ...@@ -59,13 +65,15 @@ const staticRoutes = Object.freeze([
component: resolve => require([`@/views/order/detail.vue`], resolve), component: resolve => require([`@/views/order/detail.vue`], resolve),
meta: {} meta: {}
}, },
{//订单管理 {
//订单管理
name: 'Order', name: 'Order',
path: '/order/index', path: '/order/index',
component: resolve => require([`@/views/order/index.vue`], resolve), component: resolve => require([`@/views/order/index.vue`], resolve),
meta: {} meta: {}
}, },
{//权益卡管理 {
//权益卡管理
name: 'RightsCard', name: 'RightsCard',
path: '/rightsCard/index', path: '/rightsCard/index',
component: resolve => require([`@/views/rightsCard/index.vue`], resolve), component: resolve => require([`@/views/rightsCard/index.vue`], resolve),
...@@ -77,17 +85,40 @@ const staticRoutes = Object.freeze([ ...@@ -77,17 +85,40 @@ const staticRoutes = Object.freeze([
component: resolve => require([`@/views/sale/detail.vue`], resolve), component: resolve => require([`@/views/sale/detail.vue`], resolve),
meta: {} meta: {}
}, },
{//售后管理 {
//售后管理
name: 'Sale', name: 'Sale',
path: '/sale/index', path: '/sale/index',
component: resolve => require([`@/views/sale/index.vue`], resolve), component: resolve => require([`@/views/sale/index.vue`], resolve),
meta: {} meta: {}
}, },
{//小程序短链 {
//小程序短链
name: 'ShortLink', name: 'ShortLink',
path: '/shortLink/index', path: '/shortLink/index',
component: resolve => require([`@/views/shortLink/index.vue`], resolve), component: resolve => require([`@/views/shortLink/index.vue`], resolve),
meta: {} meta: {}
}, },
{
//商品优惠券
name: 'goodsCoupon',
path: '/goodsCoupon/index',
component: resolve => require([`@/views/goodsCoupon/index.vue`], resolve),
meta: {}
},
{
//增加商品优惠券
name: 'addCoupon',
path: '/goodsCoupon/addCoupon',
component: resolve => require([`@/views/goodsCoupon/addCoupon.vue`], resolve),
meta: {}
},
{
//商品优惠券领取详情页
name: 'receivedDetail',
path: '/goodsCoupon/receivedDetail',
component: resolve => require([`@/views/goodsCoupon/receivedDetail.vue`], resolve),
meta: {}
}
]) ])
export default staticRoutes export default staticRoutes
import Vue from 'vue' import Vue from 'vue'
import ElementUI from 'element-ui' import ElementUI from 'element-ui'
import { message,messageBox } from '@/plugins/element.js' import { message, messageBox } from '@/plugins/element.js'
import { fetchConfig } from '@/config' import { fetchConfig } from '@/config'
import { GLButton,GLTable, GLCombiForm, GLTableButton,GLDialog } from 'glsx-components' //权限按钮 (根据权限动态创建) import { GLButton, GLTable, GLCombiForm, GLTableButton, GLDialog } from 'glsx-components' //权限按钮 (根据权限动态创建)
import { getRoutes } from '@/router' import { getRoutes } from '@/router'
import render from './render' import render from './render'
import 'glsx-components/dist/glsx-components.css' import 'glsx-components/dist/glsx-components.css'
...@@ -17,10 +17,10 @@ Vue.use(GLCombiForm) ...@@ -17,10 +17,10 @@ Vue.use(GLCombiForm)
Vue.use(GLTableButton) Vue.use(GLTableButton)
Vue.use(GLDialog) Vue.use(GLDialog)
export async function bootstrap({history, common, messenger, globalState,routerBase }) { export async function bootstrap({ history, common, messenger, globalState, routerBase }) {
const { response, request, sign, secret } = await fetchConfig(globalState.configSwitch) const { response, request, other_request, sign, secret } = await fetchConfig(globalState.configSwitch)
let newrequest = Object.assign({},request) let newrequest = Object.assign({}, request)
newrequest.baseURL = juedeDomain(request.baseURL) newrequest.baseURL = juedeDomain(request.baseURL)
Vue.prototype.$history = history Vue.prototype.$history = history
Vue.prototype.$messenger = messenger Vue.prototype.$messenger = messenger
Vue.prototype.$globalState = globalState Vue.prototype.$globalState = globalState
...@@ -28,14 +28,15 @@ export async function bootstrap({history, common, messenger, globalState,routerB ...@@ -28,14 +28,15 @@ export async function bootstrap({history, common, messenger, globalState,routerB
Vue.prototype.$message = message Vue.prototype.$message = message
Vue.prototype.$messageBox = messageBox Vue.prototype.$messageBox = messageBox
Vue.prototype.$http = new common.Http({ response, request, sign, secret, alert: message.error, headers: { token: globalState.session.token } }) Vue.prototype.$http = new common.Http({ response, request, sign, secret, alert: message.error, headers: { token: globalState.session.token } })
Vue.prototype.$new_http = new common.Http({ response, request:newrequest, sign, secret, alert: message.error, headers: { token: globalState.session.token } }) Vue.prototype.$other_http = new common.Http({ response, request: other_request, sign, secret, alert: message.error, headers: { token: globalState.session.token } })
Vue.prototype.$new_http = new common.Http({ response, request: newrequest, sign, secret, alert: message.error, headers: { token: globalState.session.token } })
// Vue.prototype.$setGlobalState = globalState.actions.setGlobalState // Vue.prototype.$setGlobalState = globalState.actions.setGlobalState
// Vue.use(GLButton,GLTable, { permissions: globalState.permissions || ['1-1-1-1', '2-1-1-1', '3-1-1-1'] }) // Vue.use(GLButton,GLTable, { permissions: globalState.permissions || ['1-1-1-1', '2-1-1-1', '3-1-1-1'] })
const routesData = common.utils.deepClone(globalState.routers) const routesData = common.utils.deepClone(globalState.routers)
// routes = getRoutes({ name, id, routesData }) // routes = getRoutes({ name, id, routesData })
routes = getRoutes(routesData) routes = getRoutes(routesData)
subscribe({ messenger }) subscribe({ messenger })
Vue.use(GLButton, { routes, routerBase}) Vue.use(GLButton, { routes, routerBase })
} }
export async function mount(props) { export async function mount(props) {
const insts = render(props.routerBase, routes) const insts = render(props.routerBase, routes)
...@@ -55,35 +56,35 @@ function subscribe({ messenger }) { ...@@ -55,35 +56,35 @@ function subscribe({ messenger }) {
console.log(`监听到子应用${v.from}发来消息:`, v) console.log(`监听到子应用${v.from}发来消息:`, v)
}) })
} }
function juedeDomain(url){ function juedeDomain(url) {
const val = { const val = {
environment:'test', environment: 'test',
channel:1, channel: 1,
envVersion:'trial'//要打开的小程序版本。正式版为:release,体验版为:trial,开发版为:develop,仅在微信外打开时生效 envVersion: 'trial' //要打开的小程序版本。正式版为:release,体验版为:trial,开发版为:develop,仅在微信外打开时生效
} }
const TEST = url.indexOf('scrm.test.glsx')>-1 const TEST = url.indexOf('scrm.test.glsx') > -1
const GL_PRODUCT = url.indexOf('scrm.glsx.com')>-1 const GL_PRODUCT = url.indexOf('scrm.glsx.com') > -1
const GH_PRODUCT = url.indexOf('scrm.cgacar')>-1 const GH_PRODUCT = url.indexOf('scrm.cgacar') > -1
const DEV = url.indexOf('scrm.dev.glsx')>-1 const DEV = url.indexOf('scrm.dev.glsx') > -1
const BETA = url.indexOf('scrm.beta.glsx')>-1 const BETA = url.indexOf('scrm.beta.glsx') > -1
if(TEST){ if (TEST) {
val.environment = 'test' val.environment = 'test'
}else if(GL_PRODUCT){ } else if (GL_PRODUCT) {
val.environment = 'product' val.environment = 'product'
val.envVersion = 'release' val.envVersion = 'release'
val.channel = 1 val.channel = 1
}else if(GH_PRODUCT){ } else if (GH_PRODUCT) {
val.environment = 'product' val.environment = 'product'
val.envVersion = 'release' val.envVersion = 'release'
val.channel = 2 val.channel = 2
}else if(DEV){ } else if (DEV) {
val.environment = 'dev' val.environment = 'dev'
val.envVersion = 'develop' val.envVersion = 'develop'
}else if(BETA){ } else if (BETA) {
val.environment = 'beta' val.environment = 'beta'
val.channel = 1 val.channel = 1
} }
Vue.prototype.$custom_env = val Vue.prototype.$custom_env = val
let baseURL = url.match(/(\S*)\/rop/)[1]; let baseURL = url.match(/(\S*)\/rop/)[1]
return baseURL return baseURL
} }
...@@ -2,23 +2,23 @@ ...@@ -2,23 +2,23 @@
* 日期格式化 * 日期格式化
* let time = new Date().format('yyyy-MM-dd hh:mm:ss') * let time = new Date().format('yyyy-MM-dd hh:mm:ss')
*/ */
Date.prototype.format = function (fmt) { Date.prototype.format = function(fmt) {
let o = { let o = {
'M+': this.getMonth() + 1, //月份 'M+': this.getMonth() + 1, //月份
'd+': this.getDate(), //日 'd+': this.getDate(), //日
'h+': this.getHours(), //小时 'h+': this.getHours(), //小时
'm+': this.getMinutes(), //分 'm+': this.getMinutes(), //分
's+': this.getSeconds(), //秒 's+': this.getSeconds(), //秒
//季度 //季度
'q+': Math.floor((this.getMonth() + 3) / 3), 'q+': Math.floor((this.getMonth() + 3) / 3),
'S': this.getMilliseconds() //毫秒 S: this.getMilliseconds() //毫秒
}; }
if (/(y+)/.test(fmt)) { if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
} }
for (let k in o) { for (let k in o) {
if (new RegExp(`(${k})`).test(fmt)) { 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 return fmt
...@@ -41,16 +41,16 @@ const decimal = (num, fixed) => { ...@@ -41,16 +41,16 @@ const decimal = (num, fixed) => {
let pow = Math.pow(10, fixed) let pow = Math.pow(10, fixed)
return Math.round(num * pow) / pow return Math.round(num * pow) / pow
} }
const getHttpsImgUrl = (url) => { const getHttpsImgUrl = url => {
if (!url) { if (!url) {
return '' return ''
} }
var flag = url.startsWith("http:") var flag = url.startsWith('http:')
if (flag) { if (flag) {
var newurl = url.replace("http:", "https:") var newurl = url.replace('http:', 'https:')
//去掉http自动带的端口 :7060,https不能有 //去掉http自动带的端口 :7060,https不能有
var startPos = newurl.lastIndexOf(":") var startPos = newurl.lastIndexOf(':')
var endPos = newurl.indexOf("/", startPos) var endPos = newurl.indexOf('/', startPos)
var preStr = newurl.substring(0, startPos) var preStr = newurl.substring(0, startPos)
var afterStr = newurl.substring(endPos) var afterStr = newurl.substring(endPos)
var finalStr = preStr + afterStr var finalStr = preStr + afterStr
...@@ -59,12 +59,78 @@ const getHttpsImgUrl = (url) => { ...@@ -59,12 +59,78 @@ const getHttpsImgUrl = (url) => {
} }
return 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)
}
})
}
const dateFormat = function(dateTime, format = 'YYYY-MM-DD') {
const date = new Date(dateTime)
const config = {
YYYY: date.getFullYear(),
MM: appendZero(date.getMonth() + 1), //getMonth() 方法根据本地时间返回指定日期的月份(从 0 到 11)
DD: appendZero(date.getDate()),
HH: appendZero(date.getHours()),
mm: appendZero(date.getMinutes()),
ss: appendZero(date.getSeconds())
}
for (const key in config) {
format = format.replace(key, config[key])
}
return format
}
function appendZero(int) {
if (int < 10) {
return '0' + `${int}`
} else {
return int
}
}
import Vue from 'vue' import Vue from 'vue'
const utils = { const utils = {
dateFormat,
getParams, getParams,
decimal, decimal,
getHttpsImgUrl getHttpsImgUrl,
getExplorer,
exportFn
} }
Object.keys(utils).map(key => { Object.keys(utils).map(key => {
Vue.prototype[key] = utils[key] Vue.prototype[key] = utils[key]
})
\ No newline at end of file \ No newline at end of file
})
<template>
<div class="container">
<glsx-combi-form :isInline="false" ref="couponRef" labelWidth="154px" defaultWidth="432px" :formObj.sync="couponFormObj" :formData="couponFormData" :formRules="couponRule">
<div slot="selectGoods">
<el-button icon="el-icon-plus" size="small" @click="openCouponDialog">选择商品</el-button>
<GLTable v-if="couponFormObj.selectedGoodsList.length" class="selected_table" :hasPage="false" ref="selectedRef" :tableParams="selectedtableParams" :tableData="couponFormObj.selectedGoodsList">
<div class="good_name" slot="goodName" slot-scope="scope">
<img v-if="scope.scope.appearance == 1" src="@/assets/coupon.png" alt="" />
<img v-else src="@/assets/directCharge.png" alt="" />
{{ scope.scope.appearance == 2 ? scope.scope.productName + (scope.scope.denomination || '') : scope.scope.productName }}
</div>
<div class="coupon_cost" slot="couponCost" slot-scope="scope">
<el-input :class="{ lowerZero: Number(scope.scope.newCost) <= 0 || Number(scope.scope.newCost) >= Number(scope.scope.lineationPrice) }" v-model="scope.scope.newCost" @input="formatNum(scope.scope.id, scope.scope.newCost)" />
</div>
<div slot="auth-button" slot-scope="scope">
<GLTableButton :buttonList="buttonList" :buttonItem="scope" :buttonNum="3"></GLTableButton>
</div>
</GLTable>
</div>
<div slot="validityDate">
<el-input class="date_input" v-model.number="couponFormObj.effectiveDays" oninput="value=value.replace(/^0/g,'').replace(/[^\d]/g,'')" type="text" />
</div>
</glsx-combi-form>
<gooods-dialog @confirmDialog="confirmDialog" @closeDialog="closeDialog" :selectedGoodsList="couponFormObj.selectedGoodsList" v-if="isVisible" :isVisible="isVisible"></gooods-dialog>
<div class="btn">
<el-button type="primary" @click="commit()">创建优惠券</el-button>
</div>
<GLDialog class="error_ctnr" title="提示" mode="small" :hasFooter="false" :visible.sync="errorVisible" :show-close="true" :before-close="closeErrorDialog" :close-on-click-modal="true">
<div>
<div class="title">
<i class="el-icon-warning icon"></i>
<div class="tip">以下品牌商品优惠券面额已存在,请修改面额或删除</div>
</div>
<div class="error_coupon">
<div class="coupon_item" v-for="(item, index) in errorCouponList" :key="index">
<img v-if="item.appearance == 1" src="@/assets/coupon.png" alt="" />
<img v-else src="@/assets/directCharge.png" alt="" />
<span class="info">【{{ item.brandName }}{{ item.productName }}{{ item.appearance == 2 ? item.denomination : '' }}】{{ item.newCost }}元</span>
</div>
</div>
</div>
</GLDialog>
</div>
</template>
<script>
import gooodsDialog from './goodsDialog.vue'
export default {
name: 'index',
components: {
gooodsDialog
},
data() {
return {
isVisible: false,
errorVisible: false,
errorCouponList: [],
couponFormData: [
{
label: '选择产品',
name: 'selectedGoodsList',
addHtml: 'selectGoods'
},
{
label: '有效期/天',
name: 'effectiveDays',
addHtml: 'validityDate'
}
],
couponFormObj: {
selectedGoodsList: [],
effectiveDays: ''
},
couponRule: {
selectedGoodsList: [{ required: true, message: '请选择商品', trigger: 'change' }],
effectiveDays: [{ required: true, message: '请输入有效期', trigger: 'change' }]
},
buttonList: [
{
type: 'el-button',
name: row => {
return '删除'
},
attrs: {
type: 'text',
fn: '删除'
},
listeners: {
click: row => this.delSelectedGoods(row.scope)
}
}
],
selectedtableParams: {
listName: 'list',
tableOption: false,
tableColumns: [
{
label: '品牌',
width: 120,
prop: 'brandName'
},
{
label: '商品名称',
addHtml: 'goodName'
},
{
label: '券面额',
addHtml: 'couponCost',
width: 110
},
{
label: '官方价/元',
width: 110,
align: 'right',
prop: 'lineationPrice'
},
{
label: '成本价/元',
width: 110,
align: 'right',
prop: 'costPrice'
},
{
label: '会员价/元',
width: 110,
align: 'right',
prop: 'salesPrice'
},
{
label: '操作',
width: 110,
addHtml: 'auth-button'
}
]
}
}
},
created() {},
methods: {
formatNum(id, val) {
let temp = val
if (temp < 0) {
temp = ''
}
if (temp.length > 1 && temp.slice(0, 1) == '0' && temp.slice(1, 2) != '.') {
temp = '0'
}
temp = temp.replace(/[^\d.]/g, '') //清除"数字"和"."以外的字符
temp = temp.replace(/^\./g, '') //验证第一个字符是数字
temp = temp.replace(/\.{2,}/g, '') //只保留第一个, 清除多余的
temp = temp
.replace('.', '$#$')
.replace(/\./g, '')
.replace('$#$', '.')
temp = temp.replace(/^(-)*(\d+)\.(\d).*$/, '$1$2.$3') //只能输入1个小数
this.$nextTick(() => {
const target = this.couponFormObj.selectedGoodsList.find(item => item.id == id)
target.newCost = temp
})
},
delSelectedGoods(row) {
const idx = this.couponFormObj.selectedGoodsList.findIndex(item => item.id == row.id)
this.couponFormObj.selectedGoodsList.splice(idx, 1)
this.validateGoods()
},
validateGoods() {
this.$refs.couponRef.$refs.formRef.validateField('selectedGoodsList')
},
closeDialog() {
this.isVisible = false
},
confirmDialog(e) {
this.couponFormObj.selectedGoodsList = e || []
this.validateGoods()
},
openCouponDialog() {
this.isVisible = true
},
closeErrorDialog() {
this.errorVisible = false
},
commit() {
this.$refs.couponRef.$refs.formRef.validate(valid => {
if (!valid) return
let { selectedGoodsList, effectiveDays } = this.couponFormObj
const target = selectedGoodsList.find(item => Number(item.newCost) <= 0 || Number(item.newCost) >= Number(item.lineationPrice))
console.log(target)
if (target) return this.$message.error('请填写大于0,小于官方价的券面额')
let equityCouponRequestList = selectedGoodsList.map(item => {
let { brandName, id: goodId, productName: goodsName, appearance, denomination: rechargeDenomination, newCost } = item
return { brandName, goodId, goodsName, appearance, denomination: parseInt(Number(newCost) * 100), rechargeDenomination }
})
const params = {
effectiveDays,
equityCouponRequestList
}
this.$apis.goodsCouponApi.createCoupons(params).then(res => {
if (res && res.length === 0) {
this.$message.success('创建成功')
this.$router.push({ path: '/goodsCoupon/index' })
} else if (res && res.length > 0) {
this.errorCouponList = selectedGoodsList.filter(item => res.indexOf(item.id) > -1)
this.errorVisible = true
}
})
})
}
}
}
</script>
<style lang="scss" scoped>
.container {
background-color: #fff;
padding: 32px 30px;
min-height: calc(100vh - 150px);
position: relative;
/deep/ .glsx-combi-form {
padding-bottom: 30px;
}
.good_name {
img {
width: 40px;
height: 20px;
vertical-align: text-bottom;
}
}
.selected_table {
margin-top: 10px;
width: 100%;
max-width: 1100px;
.coupon_cost {
/deep/ .el-input__inner {
width: 80px;
color: #2cca74;
}
}
.lowerZero {
/deep/ .el-input__inner {
color: #eb4e4e;
}
}
/deep/ .el-table__body-wrapper {
max-height: 500px;
overflow-y: auto;
}
}
.date_input {
width: 432px;
}
.btn {
padding: 0 20px;
position: absolute;
bottom: 10px;
left: 50%;
transform: translateX(-50%);
}
.error_ctnr {
/deep/ .el-dialog__body {
height: 255px;
}
.title {
text-align: center;
.icon {
font-size: 48px;
color: #5851fe;
}
.tip {
height: 20px;
line-height: 20px;
margin-top: 8px;
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: 16px;
color: #333333;
}
}
.error_coupon {
margin: 20px 0 0 74px;
height: 124px;
overflow-y: auto;
.coupon_item {
margin-bottom: 8px;
img {
width: 40px;
height: 20px;
vertical-align: text-bottom;
}
.info {
height: 14px;
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: 14px;
color: #666666;
line-height: 14px;
}
}
}
}
}
</style>
<template>
<GLDialog bigTitle="选择商品优惠券" mode="big" :visible.sync="isVisible" :show-close="true" :before-close="handleClose" :close-on-click-modal="false" @onOk="onOk" @onCancel="onCancel">
<div class="dialog_body">
<GLCombiForm :rowNumber="1" class="dialog_search" ref="searchRef" :formObj="dialogSearchForm" :formData="dialogFormData" @handleOk="handleOk" @handleRest="handleRest"></GLCombiForm>
<div class="coupon_type">
<span :class="['type', { active_type: curType == '1' }]" @click="changeCouponType(1)">卡券</span>
<span :class="['type', { active_type: curType == '2' }]" @click="changeCouponType(2)">直充</span>
</div>
<div class="dialog_table">
<GLTable v-if="showTable" :pageSizes="pageSizes" ref="tableRef" :pageConf="pageConf" @setTableFinishFun="setTableFinishFun" :searchForm="dialogSearchForm" :tableParams="tableParams" :getListApi="getListApi">
<div class="good_name" slot="goodName" slot-scope="scope">
<img v-if="scope.scope.appearance == 1" src="@/assets/coupon.png" alt="" />
<img v-else src="@/assets/directCharge.png" alt="" />
<!-- {{ scope.scope.appearance == 2 ? scope.scope.productName + (scope.scope.denomination || '') : scope.scope.productName }} -->
{{ scope.scope.productName }}
</div>
<div slot="spreadPrice" slot-scope="scope">
<span :style="{ color: Number(scope.scope.lineationPrice - scope.scope.costPrice) <= 0 ? '#eb4e4e' : '#666666' }">{{ Number(Number(scope.scope.lineationPrice - scope.scope.costPrice).toFixed(1)) }}</span>
</div>
</GLTable>
</div>
</div>
</GLDialog>
</template>
<script>
const dialogColumns = [
{
label: '品牌',
width: 150,
prop: 'brandName'
},
{
label: '商品名称',
minWidth: 220,
addHtml: 'goodName'
},
{
label: '差价/元',
width: 110,
align: 'right',
addHtml: 'spreadPrice'
// renderHeader: h => {
// return h('div', { class: 'table-header specHeader' }, [
// h('span', '差价/元'),
// h('table-tooltip', {
// props: { content: '差价=官方价-成本价' }
// })
// ])
// }
},
{
label: '官方价/元',
width: 110,
align: 'right',
prop: 'lineationPrice'
},
{
label: '成本价/元',
width: 110,
align: 'right',
prop: 'costPrice'
},
{
label: '会员价/元',
width: 110,
align: 'right',
prop: 'salesPrice'
}
]
const dialogColumns1 = [
{
label: '品牌',
width: 150,
prop: 'brandName'
},
{
label: '商品名称',
minWidth: 220,
addHtml: 'goodName'
},
{
label: '直充面额',
width: 110,
prop: 'denomination'
},
{
label: '差价/元',
width: 110,
align: 'right',
// renderHeader: h => {
// return h('div', { class: 'table-header specHeader' }, [
// h('span', '差价/元'),
// h('table-tooltip', {
// props: { content: '差价=官方价-成本价' }
// })
// ])
// },
addHtml: 'spreadPrice'
},
{
label: '官方价/元',
width: 110,
align: 'right',
prop: 'lineationPrice'
},
{
label: '成本价/元',
width: 110,
align: 'right',
prop: 'costPrice'
},
{
label: '会员价/元',
width: 110,
align: 'right',
prop: 'salesPrice'
}
]
export default {
name: 'index',
props: ['isVisible', 'selectedGoodsList'],
data() {
return {
curType: 1,
showTable: true,
copyList: [],
couponList: [],
directChargeList: [],
pageSizes: [5, 10, 20, 30, 40],
dialogSearchForm: {
brandName: '',
productName: '',
appearance: 1,
status: 1
},
dialogFormData: [
{
label: '商品品牌',
name: 'brandName',
type: 'select',
optionList: [],
optionId: 'brandName',
optionLabel: 'brandName',
isClear: true
},
{
label: '商品名称',
name: 'productName',
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: dialogColumns
}
}
},
created() {
this.getAllBrandList()
},
methods: {
getAllBrandList() {
this.$apis.orderApi.getAllBrandList().then(res => {
const item = this.dialogFormData.find(item => item.name === 'brandName')
item.optionList = [...res.data]
})
},
handleOk() {
this.$refs.tableRef.refreshTable()
},
resetParam(type) {
let { appearance } = this.dialogSearchForm
this.dialogSearchForm = {
brandName: '',
productName: '',
appearance: type || appearance,
status: 1
}
},
handleRest(type) {
this.resetParam(type)
this.handleOk()
},
changeCouponType(type) {
if (this.curType == type) return
this.getBeforeChangeList(type)
this.showTable = false
this.curType = type
this.$nextTick()
.then(() => {
this.tableParams['tableColumns'] = type == 2 ? [...dialogColumns1] : [...dialogColumns]
})
.then(() => {
this.resetParam(type)
this.showTable = true
})
},
getBeforeChangeList(type = 1) {
let list = this.$refs.tableRef.mutiSelectArr[this.tableParams.mutiSelectName] || []
this[type == 2 ? 'couponList' : 'directChargeList'] = [...list]
},
onOk() {
let selectedList = this.curType == 2 ? this.couponList : this.directChargeList
let list = this.$refs.tableRef.mutiSelectArr[this.tableParams.mutiSelectName] || []
list = [...selectedList, ...list]
for (let i = 0; i < this.selectedGoodsList.length; i++) {
let idx = list.findIndex(item => item.id == this.selectedGoodsList[i].id)
if (idx > -1) {
list.splice(idx, 1)
}
}
list.map(item => this.$set(item, 'newCost', Number((item.lineationPrice - item.costPrice).toFixed(1))))
this.$emit('confirmDialog', [...list, ...this.selectedGoodsList])
this.handleClose()
},
onCancel() {
this.handleClose()
},
handleClose() {
this.$emit('closeDialog')
},
setTableFinishFun() {
this.copyList = [...this.selectedGoodsList, ...this[this.curType == 1 ? 'couponList' : 'directChargeList']]
this.copyList.forEach(row => {
this.$nextTick(() => {
let idx = this.$refs.tableRef.$refs[this.tableParams.mutiSelectName + 'MutiTable'].data.findIndex(item => item.id == row.id)
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)
}
}
})
})
}
}
}
</script>
<style lang="scss" scoped>
.container {
/deep/ .table-header {
display: inline-flex !important;
align-items: center;
justify-content: center;
padding: 0 !important;
.el-button {
min-width: 0;
}
}
.good_name {
img {
width: 40px;
height: 20px;
vertical-align: text-bottom;
}
}
.dialog_body {
border: 1px solid #e5e5e5;
.dialog_search {
padding: 20px 20px 0;
/deep/ .el-form-item {
width: 312px;
}
}
.coupon_type {
width: 100%;
display: inline-block;
border-bottom: 1px solid #eee;
.type {
display: inline-block;
height: 40px;
width: 70px;
line-height: 40px;
font-weight: 500;
text-align: center;
font-size: 16px;
cursor: pointer;
}
.active_type {
color: #5850ff;
border-bottom: 2px solid #5850ff;
}
}
.dialog_table {
padding: 20px;
}
}
}
</style>
<template>
<div class="container">
<GLCombiForm ref="searchRef" :formObj="searchForm" :formData="searchFormData" @handleOk="handleOk" @handleRest="handleRest"></GLCombiForm>
<div class="operate_wrap">
<span class="table_title">商品优惠券列表</span>
<div class="operate_btn">
<GLButton fn="新增商品优惠券" plain size="small" @click="addCoupon">创建优惠券</GLButton>
<el-button class="export_btn" size="small" @click="handleExport">导出</el-button>
</div>
</div>
<GLTable ref="tableRef" :pageConf="pageConf" :searchForm="searchForm" :tableParams="tableParams" :getListApi="getListApi">
<div class="good_name" slot="goodsName" slot-scope="scope">
<img class="coupon_type" v-if="scope.scope.appearance == 1" src="@/assets/coupon.png" alt="" />
<img class="coupon_type" v-else src="@/assets/directCharge.png" alt="" />
{{ scope.scope.appearance == 2 ? scope.scope.goodsName + (scope.scope.rechargeDenomination || '') : scope.scope.goodsName }}
</div>
<div class="good_status" slot="goodStatus" slot-scope="scope">
<span class="circle" :style="{ 'background-color': scope.scope.status == 2 ? '#5850FF' : '#999999' }"></span>
<span>
{{ scope.scope.status == 2 ? '生效中' : '已失效' }}
</span>
</div>
<div slot="auth-button" slot-scope="scope">
<GLTableButton :buttonList="buttonList" :buttonItem="scope" :buttonNum="3"></GLTableButton>
</div>
</GLTable>
</div>
</template>
<script>
export default {
name: 'index',
data() {
return {
getListApi: this.$apis.goodsCouponApi.getCouponsList,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
searchForm: {
brandName: '',
goodsName: '',
appearance: '',
status: ''
},
buttonList: [
{
type: 'el-button',
name: row => {
return '生效'
},
attrs: {
type: 'text',
fn: '生效'
},
condition: row => {
return row.scope.status != 2
},
listeners: {
click: row => this.takeEffect(row.scope, 2)
}
},
{
type: 'el-button',
name: row => {
return '失效'
},
attrs: {
type: 'text',
fn: '失效'
},
condition: row => {
return row.scope.status == 2
},
listeners: {
click: row => this.takeEffect(row.scope, 3)
}
},
{
type: 'el-button',
name: '删除',
attrs: {
type: 'text',
fn: '删除'
},
condition: row => {
return row.scope.status == 3
},
listeners: {
click: row => this.del(row.scope)
}
},
{
type: 'GLButton',
name: row => {
return '领取详情'
},
attrs: {
type: 'text',
fn: '领取详情'
},
listeners: {
click: row => this.goDetailPage(row)
}
}
],
tableParams: {
listName: 'list',
tableOption: true,
tableColumns: [
{
label: '品牌',
width: 150,
prop: 'brandName'
},
{
label: '商品名称',
minWidth: 280,
line: 1,
addHtml: 'goodsName'
},
{
label: '券面额/元',
width: 110,
align: 'right',
formatter: cell => {
return cell.denomination ? Number((Number(cell.denomination) / 100).toFixed(2)) : 0
}
},
{
label: '有效期/天',
width: 110,
prop: 'effectiveDays'
},
{
label: '状态',
width: 110,
addHtml: 'goodStatus'
},
{
label: '已领取',
width: 110,
prop: 'getAmount'
},
{
label: '已使用',
width: 110,
prop: 'usedAmount'
},
{
label: '创建日期',
width: 180,
prop: 'createdDate',
formatter: cell => {
return cell.createdDate ? this.dateFormat(cell.createdDate, 'YYYY-MM-DD HH:mm:ss') : '--'
}
}
]
},
searchFormData: [
{
label: '商品品牌',
name: 'brandName',
type: 'select',
optionList: [],
optionId: 'brandName',
optionLabel: 'brandName',
isClear: true
},
{
label: '商品名称',
name: 'goodsName',
type: 'input',
isClear: true
},
{
label: '商品形态',
name: 'appearance',
type: 'select',
optionList: [
{
id: '',
label: '全部'
},
{
id: '1',
label: '卡券'
},
{
id: '2',
label: '直充'
}
],
optionId: 'id',
optionLabel: 'label',
isClear: true
},
{
label: '状态',
name: 'status',
type: 'select',
optionList: [
{
id: '',
label: '全部'
},
{
id: '2',
label: '生效中'
},
{
id: '3',
label: '已失效'
}
],
optionId: 'id',
optionLabel: 'label',
isClear: true
}
]
}
},
created() {
this.getAllBrandList()
},
methods: {
handleOk() {
this.$refs.tableRef.refreshTable()
},
getAllBrandList() {
this.$apis.orderApi.getAllBrandList().then(res => {
const item = this.searchFormData.find(item => item.name === 'brandName')
item.optionList = [...res.data]
})
},
//删除
del(row) {
const params = {
couponId: row.id
}
this.secondConfirm('删除', '确定删除此优惠券?', 'goodsCouponApi', 'deleteCouponApi', params)
},
takeEffect(row, key) {
const params = {
couponId: row.id,
status: key
}
const title = key == 2 ? '生效' : '失效'
this.secondConfirm(title, `确定要${title}该优惠券?`, 'goodsCouponApi', 'effectiveCouponApi', params)
},
secondConfirm(title, txt, apiModule, apiName, apiParams, fn) {
this.$confirm(txt, title, {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
callback: action => {
if (action == 'confirm') {
this.$apis[apiModule][apiName](apiParams).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
fn && fn()
this.handleOk()
}
})
}
}
})
},
handleRest() {
this.searchForm = {
brandName: '',
goodsName: '',
appearance: '',
status: ''
}
this.handleOk()
},
// 导出
handleExport() {
var params = { ...this.searchForm }
this.$apis.goodsCouponApi.getExportApi(params).then(res => {
let tempaa = this.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(row) {
this.$router.push({ path: '/goodsCoupon/receivedDetail', query: { id: row.scope.id } })
},
changeStatus() {},
addCoupon() {
this.$router.push('/goodsCoupon/addCoupon')
}
}
}
</script>
<style lang="scss" scoped>
.container {
background-color: #fff;
padding: 20px;
height: calc(100vh - 120px);
.good_name {
.coupon_type {
width: 40px;
height: 20px;
vertical-align: text-bottom;
}
}
.good_status {
.circle {
display: inline-block;
width: 6px;
height: 6px;
border-radius: 50%;
vertical-align: middle;
margin-right: 4px;
}
}
}
</style>
<template>
<div class="container">
<div class="info_ctnr">
<glsx-combi-form :isInline="true" ref="couponInfoRef" labelWidth="154px" defaultWidth="432px" :formObj.sync="couponInfoFormObj" :formData="couponInfoFormData" :formRules="couponInfoRule">
<div slot="goodsName" class="txt">
{{ couponInfoFormObj.appearance == 2 ? couponInfoFormObj.goodsName + (couponInfoFormObj.goodsName || '') : couponInfoFormObj.goodsName }}
</div>
<div slot="appearance" class="txt">
{{ couponInfoFormObj.appearance == 1 ? '卡券' : '直充' }}
</div>
</glsx-combi-form>
</div>
<div class="table_ctnr">
<GLCombiForm ref="searchRef" :formObj="searchForm" :formData="searchFormData" @handleOk="handleOk" @handleRest="handleRest"></GLCombiForm>
<div class="operate_wrap">
<span class="table_title">领取详情列表</span>
<div class="operate_btn">
<el-button plain size="small" @click="handleExport">导出</el-button>
</div>
</div>
<GLTable :pageSizes="pageSizes" ref="tableRef" :pageConf="pageConf" :searchForm="searchForm" :tableParams="tableParams" :getListApi="getListApi" :beforeSearchFn="beforeSearchFn">
<div slot="userStatus" slot-scope="scope">
<span class="circle" :style="{ 'background-color': scope.scope.userStatus == 1 ? '#2cca74' : scope.scope.userStatus == 2 ? '#eb4e4e' : '#999999' }"></span>
<span>
{{ statusList.find(item => item.id == scope.scope.userStatus).label }}
</span>
<p v-if="scope.scope.userStatus == 4">{{ scope.scope.cancelReason || '' }}</p>
</div>
<div class="table-btns" slot="auth-button" slot-scope="scope">
<GLTableButton :buttonList="tableButtonList" :buttonItem="scope.scope" :buttonNum="3"></GLTableButton>
</div>
</GLTable>
</div>
<!-- 作废 -->
<GLDialog title="作废确认" mode="small" :visible.sync="isCancelVisible" :before-close="handleCancelClose" @onOk="handleCancelConfirm" @onCancel="handleCancelClose">
<div class="small-content">
<p style="margin-bottom: 20px">请先可客户沟通再确认,避免引起客诉,作废后客户将不可使用该优惠券</p>
<el-form ref="cancelRef" label-width="80px" :rules="cancelRules" :model="cancelForm">
<el-form-item label="作废原因" prop="cancelReason" class="m-t-20">
<el-input style="width: 410px;" size="small" type="textarea" v-model.trim="cancelForm.cancelReason" placeholder="请输入作废原因" maxlength="50" rows="3" show-word-limit></el-input>
</el-form-item>
</el-form>
</div>
</GLDialog>
</div>
</template>
<script>
const statusList = [
{
id: '',
label: '全部'
},
{
id: '1',
label: '已领取'
},
{
id: '2',
label: '已使用'
},
{
id: '3',
label: '已过期'
},
{
id: '4',
label: '已作废'
}
]
export default {
name: 'index',
data() {
return {
isCancelVisible: false,
cancelForm: {
userCouponId: '',
cancelReason: ''
},
cancelRules: {
cancelReason: [{ required: true, message: '请输入作废原因', trigger: 'change' }]
},
couponInfoFormObj: {
brandName: '',
goodsName: '',
appearance: '',
denomination: '',
effectiveTxt: '',
getAmount: '',
usedAmount: ''
},
statusList,
pageSizes: [5, 10, 20, 30, 40],
tableButtonList: [
{
type: 'el-button',
name: '作废',
attrs: {
type: 'text',
disabled: (row, condition) => {
var isDisabled = [2, 3, 4].includes(row.userStatus)
return isDisabled
}
},
listeners: {
click: this.handleCancel
}
}
],
couponInfoFormData: [
{
label: '品牌',
name: 'brandName',
type: 'showTxt'
},
{
label: '商品名称',
name: 'goodsName',
addHtml: 'goodsName'
},
{
label: '商品形态',
name: 'appearance',
addHtml: 'appearance'
},
{
label: '券面额/元',
name: 'denomination',
type: 'showTxt'
},
{
label: '有效期',
name: 'effectiveTxt',
type: 'showTxt'
},
{
label: '已领取',
name: 'getAmount',
type: 'showTxt'
},
{
label: '已使用',
name: 'usedAmount',
type: 'showTxt'
}
],
couponInfoRule: {},
getListApi: this.$apis.goodsCouponApi.getListReceiveRecordApi,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
tableParams: {
listName: 'list',
tableOption: true,
tableColumns: [
{
label: '客户信息',
prop: 'phone'
},
{
label: '使用状态',
addHtml: 'userStatus'
},
{
label: '所属商户',
prop: 'userCouponMerchantName'
},
{
label: '领取日期',
formatter: cell => {
return cell.receiveTime ? this.dateFormat(cell.receiveTime, 'YYYY-MM-DD HH:mm:ss') : '--'
}
},
{
label: '使用日期',
formatter: cell => {
return cell.verificationTime ? this.dateFormat(cell.verificationTime, 'YYYY-MM-DD HH:mm:ss') : '--'
}
}
]
},
searchForm: {
phone: '',
userStatus: '',
userCouponMerchantName: '',
daterange: ''
},
searchFormData: [
{
label: '用户信息',
name: 'phone',
type: 'input',
maxLength: 11,
isClear: true
},
{
label: '使用状态',
name: 'userStatus',
type: 'select',
optionList: statusList,
optionId: 'id',
optionLabel: 'label',
isClear: true
},
{
label: '所属商户',
name: 'userCouponMerchantName',
type: 'input',
isClear: true
},
{
label: '领取日期',
name: 'daterange',
type: 'datePicker',
isClear: true,
pickerOptions: 'beforeRangePickerOptions'
}
]
}
},
mounted() {
let id = this.$route.query.id
this.getInfo(id)
},
methods: {
handleOk() {
this.$refs.tableRef.refreshTable()
},
handleRest() {
this.searchForm = {
phone: '',
userStatus: '',
userCouponMerchantName: '',
daterange: ''
}
this.handleOk()
},
getParams() {
let params = JSON.parse(JSON.stringify(this.searchForm))
params.couponId = this.$route.query.id
if (params.daterange) {
params.receiveTimeBegin = new Date(this.searchForm.daterange[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
params.receiveTimeEnd = new Date(this.searchForm.daterange[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
}
// delete params.daterange
return params
},
beforeSearchFn() {
return new Promise(resolve => {
this.searchForm = this.getParams()
resolve()
})
},
getInfo(couponId) {
var params = {}
params.couponId = couponId
this.$apis.goodsCouponApi.getCouponDetailApi(params).then(res => {
this.couponInfoFormObj = res
//有效期
if (res.effectiveType == 1) {
this.couponInfoFormObj.effectiveTxt = res.effectiveDays + '天'
} else if (res.effectiveType == 2) {
//时间段
this.couponInfoFormObj.effectiveTxt = res.effectiveStartTime + ' - ' + res.effectiveEndTime
} else if (res.effectiveType == 3) {
//永久有效
this.couponInfoFormObj.effectiveTxt = '永久有效'
}
})
},
// 导出
handleExport() {
let params = this.getParams()
this.$apis.goodsCouponApi.detailExportApi(params).then(res => {
let tempaa = this.getExplorer()
if (tempaa == 'QQ') {
window.open(res)
} else {
let iframe = document.createElement('iframe')
iframe.style.display = 'none'
iframe.src = res
document.body.appendChild(iframe)
}
})
},
handleCancel(row) {
this.cancelForm.userCouponId = row.id
this.cancelVisibleChange()
},
cancelVisibleChange() {
this.$refs.cancelRef && this.$refs.cancelRef.clearValidate()
this.isCancelVisible = !this.isCancelVisible
},
handleCancelClose() {
this.cancelVisibleChange()
this.cancelForm = {
userCouponId: '',
cancelReason: ''
}
},
handleCancelConfirm() {
this.$refs.cancelRef.validate(valid => {
if (valid) {
this.$apis.goodsCouponApi.couponUserCancelApi(this.cancelForm).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
this.handleCancelClose()
this.handleOk()
}
})
}
})
}
}
}
</script>
<style lang="scss" scoped>
.container {
.info_ctnr {
background-color: #fff;
padding: 20px;
margin-bottom: 20px;
}
.table_ctnr {
padding: 20px;
background-color: #fff;
}
/deep/ .showTxt,
.txt {
width: 200px;
}
.circle {
display: inline-block;
width: 6px;
height: 6px;
border-radius: 50%;
vertical-align: middle;
margin-right: 4px;
}
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!