Commit 2d61ecc5 by chenwq

发券宝

1 parent 690665ed
import { http } from '@/main'
const path = 'dj.api.'
const path2 = 'dj.smartcarlife.api.'
// const path = 'dj.api.'
// const path2 = 'dj.smartcarlife.api.'
// 查询优惠券列表
const getListApi = params => {
params.method = `scrm.api.shopmall.goods.page.curMerchant`
params.method = `scrm.api.boutiquecoupon.rop.router.twoCityTale`
params.routerMethod = `dj.api.life.merchant.coupon.list`
return http({
url: 'rop-scrm-shopmall/router',
method: 'GET',
url: 'rop-scrm-boutiquecoupon/router',
method: 'POST',
data: params,
sign: true
})
}
// 领用明细 - 查询优惠券列表
const getDetailListApi = params => {
params.method = `scrm.api.boutiquecoupon.rop.router.twoCityTale`
params.routerMethod = `dj.api.life.customer.coupon.list`
return http({
url: 'rop-scrm-boutiquecoupon/router',
method: 'POST',
data: params,
sign: true
})
}
const getTypeList = params => {
params.method = `scrm.api.boutiquecoupon.rop.router.twoCityTale`
params.routerMethod = `dj.api.goods.type.list`
return http({
url: 'rop-scrm-boutiquecoupon/router',
method: 'POST',
data: params,
sign: true
})
}
const addCouponApi = params => {
params.method = `scrm.api.boutiquecoupon.rop.router.twoCityTale`
params.routerMethod = `dj.api.life.coupon.info.add`
return http({
url: 'rop-scrm-boutiquecoupon/router',
method: 'POST',
data: params,
sign: true
})
}
const updateCouponApi = params => {
params.method = `scrm.api.boutiquecoupon.rop.router.twoCityTale`
params.routerMethod = `dj.api.life.merchant.coupon.update`
return http({
url: 'rop-scrm-boutiquecoupon/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
// 分页查找园区店
const commodityAddSeviceMerchant = function(params) {
params.method = `dj.api.servicemerchantref.page`
params.method = `scrm.api.boutiquecoupon.rop.router.twoCityTale`
params.routerMethod = `dj.api.servicemerchantref.page`
return http({
url: 'rop-scrm-shopmall/router',
method: 'GET',
url: 'rop-scrm-boutiquecoupon/router',
method: 'POST',
data: params,
sign: true
})
}
const getSimpleMerchantList = params => {
params.method = 'scrm.api.carlife.merchant.listWithPageSimpleByCurMerchant'
// 获取核销人
const getDistinctColum = function(params) {
params.method = `scrm.api.boutiquecoupon.rop.router.twoCityTale`
params.routerMethod = `dj.api.life.customer.coupon.distinctColum`
return http({
url: 'rop-scrm-carlife/router',
url: 'rop-scrm-boutiquecoupon/router',
method: 'POST',
data: params,
sign: true
})
}
export default { getListApi, commodityAddSeviceMerchant, getSimpleMerchantList }
export default { getListApi, getDetailListApi, getTypeList, addCouponApi, updateCouponApi, commodityAddSeviceMerchant, getDistinctColum }
export function debounce(func, wait = 200) {
let timeout;
return function (event) {
let timeout
return function(event) {
clearTimeout(timeout)
timeout = setTimeout(() => {
func.call(this, event)
......@@ -24,10 +24,41 @@ export function dateFormat(dateTime, format = 'YYYY-MM-DD HH:mm') {
return format
}
/**
* 校验手机号码格式
*/
* 校验手机号码格式
*/
export function checkPhone(mobile) {
const myreg =
/^(13[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9]|14[0-9])[0-9]{8}$/
const myreg = /^(13[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9]|14[0-9])[0-9]{8}$/
return myreg.test(mobile)
}
/**
* 用于glsx-combi-form的select写入options
* formName String FormData的属性名
* hasAll Boolean 是否需要添加“全部”属性
* refreshSigle String 更新特定的属性的options
*/
export function getOptionsList(that, formName, hasAll = true, refreshSigle) {
if (refreshSigle) {
var item = that[formName].find(k => k.name == refreshSigle)
var index = that[formName].findIndex(k => k.name == refreshSigle)
that.$set(that[formName][index], 'optionList', that.$common.utils.deepClone(that.baseData[item.optionsName]))
if (hasAll && that.baseData[item.optionsName].length && that.baseData[item.optionsName][0][that[formName][index].optionLabel] !== '全部') {
const temp = {}
temp[that[formName][index].optionId] = ''
temp[that[formName][index].optionLabel] = '全部'
that[formName][index].optionList.unshift(temp)
}
} else {
that[formName].forEach((item, index) => {
if (item.type === 'select' && that.baseData[item.optionsName]?.length) {
that.$set(that[formName][index], 'optionList', that.$common.utils.deepClone(that.baseData[item.optionsName]))
if (hasAll && that.baseData[item.optionsName].length && that.baseData[item.optionsName][0][that[formName][index].optionLabel] !== '全部') {
const temp = {}
temp[that[formName][index].optionId] = ''
temp[that[formName][index].optionLabel] = '全部'
that[formName][index].optionList.unshift(temp)
}
}
})
}
}
......@@ -79,6 +79,7 @@ export default {
data() {
return {
// userInfo: this.$store.state.d2admin.user.info,
userInfo: this.$globalState.session,
couponsForm: {
couponName: '',
couponType: '',
......@@ -99,8 +100,8 @@ export default {
relateStoreVisible: false,
sourcePage: 'coupons',
storeSelected: [],
// storeApi: this.$apis.coupons.commodityAddSeviceMerchant,
storeApi: this.$apis.coupons.getSimpleMerchantList,
storeApi: this.$apis.coupons.commodityAddSeviceMerchant,
// storeApi: this.$apis.coupons.getSimpleMerchantList,
storeSearchForm: {
yqMerchantName: '',
merchantName: ''
......@@ -147,6 +148,7 @@ export default {
mounted() {
// this.getBaseData()
this.getTypeList()
!this.couponInfo && (this.couponsForm.remark = this.remarkTemp)
},
......@@ -157,6 +159,11 @@ export default {
// async getBaseData() {
// this.baseData.productTypeList = JSON.parse(JSON.stringify((await this.get(BaseData.productType))
// },
getTypeList() {
this.$apis.coupons.getTypeList({}).then(res => {
this.baseData.productTypeList = res
})
},
validateAccount(rule, value, callback) {
value < this.couponInfo.amount ? callback(new Error(`数量不能小于${this.couponInfo.amount}张`)) : callback()
},
......@@ -215,11 +222,12 @@ export default {
},
handleAddConfirm() {
// console.log(this.couponsForm.remark)
console.log(this.userInfo)
this.$refs.couponAddForm.validate(valid => {
if (valid) {
var params = JSON.parse(JSON.stringify(this.couponsForm))
params.couponTypeName = this.baseData.productTypeList.find(item => item.goodsType === this.couponsForm.couponType).goodsTypeName
params.createdBy = this.userInfo.detail[this.userInfo.merchantAccountLevel == 4 ? 'userName' : 'merchantName']
params.createdBy = this.userInfo.accountName
if (this.couponInfo) {
// 编辑
......@@ -240,13 +248,16 @@ export default {
})
})
}
// console.log(params)
// var apiName = this.couponInfo ? 'updateCouponApi' : 'addCouponApi'
// api[apiName](params).then(res => {
// this.notice.okTips()
// this.$emit('couponClose', true)
// this.$refs.couponAddForm && this.$refs.couponAddForm.resetFields()
// })
console.log(params)
var apiName = this.couponInfo ? 'updateCouponApi' : 'addCouponApi'
this.$apis.coupons[apiName](params).then(res => {
this.$notify({
type: 'success',
title: res.message || '操作成功'
})
this.$refs.couponAddForm && this.$refs.couponAddForm.resetFields()
this.$emit('couponClose', true)
})
}
})
}
......
......@@ -11,94 +11,57 @@ const couponsObj = {
name: 'merchantName',
type: 'input',
isClear: true
},
{
label: '类型',
name: 'couponTypeList',
type: 'select',
multiple: true,
optionList: [],
optionId: 'goodsType',
optionLabel: 'goodsTypeName',
optionsName: 'typeList'
},
{
label: '状态',
name: 'enabledFlagList',
type: 'select',
multiple: true,
optionList: [],
optionId: 'confId',
optionLabel: 'confLabel',
optionsName: 'enabledFlagList'
},
{
label: '发券人',
name: 'employeeNameKeyword',
type: 'input',
isClear: true,
isHide: true
},
{
label: '核销状态',
name: 'usedFlagList',
type: 'select',
multiple: true,
isHide: true,
optionList: [],
optionId: 'confId',
optionLabel: 'confLabel',
optionsName: 'usedFlagList'
},
{
label: '核销人',
name: 'sellerNameList',
type: 'select',
multiple: true,
isHide: true,
optionList: [],
optionId: 'confId',
optionLabel: 'confLabel',
optionsName: 'sellerNameList'
}
],
tableParams: {
needUnique: true,
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list',
tableOption: true,
tableColumns: [
{
label: '批次号',
prop: 'merchantCouponCode'
},
{
label: '礼券名称',
parentProp: 'couponInfo',
prop: 'couponName'
},
{
label: '类型',
parentProp: 'couponInfo',
prop: 'couponTypeName',
optionConfig: {
searchItemName: 'couponTypeList',
optionId: 'goodsType',
optionLabel: 'goodsTypeName'
}
// optionList: []
},
{
label: '区域',
parentProp: 'yqMerchantInfo',
prop: 'region',
optionConfig: {
searchItemName: 'regionList',
optionId: 'confKey',
optionLabel: 'confValue'
}
// optionList: []
},
{
label: '门店名称',
prop: 'merchantName',
formatter: cellValue => {
return cellValue.merchantName + ' - ' + cellValue.yqMerchantName
}
},
{
label: '总数',
prop: 'amount',
sortable: 'custom'
},
{
label: '余量',
prop: 'allowance',
sortable: 'custom',
formatter: cellValue => {
return cellValue.amount - cellValue.getAmount
}
},
{
label: '发放量',
prop: 'getAmount',
sortable: 'custom'
},
{
label: '核销量',
prop: 'usedAmount',
sortable: 'custom'
},
{
label: '状态',
prop: 'enabledFlag',
optionConfig: {
searchItemName: 'enabledFlagList',
optionId: 'confId',
optionLabel: 'confLabel'
},
// optionList: [{ confLabel: '启用', confId: 'Y' }, { confLabel: '停用', confId: 'N' }],
formatter: cellValue => {
return {
Y: '启用',
N: '停用'
}[cellValue.enabledFlag]
}
}
]
}
]
}
export default {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!