Commit ce248f7b by wuwx

修改定向礼包需求

1 parent dd7fb649
......@@ -32,7 +32,7 @@
<!-- radio -->
<div v-else-if="item.type === 'radio'">
<el-radio-group v-model="formObj[item.name]" v-bind="item.attrs ? item.attrs : {}" v-on="item.listeners ? item.listeners : {}" :disabled="item.isDisabled" @change="item.handleRadioChange">
<el-radio v-for="subItem in item.optionList" :key="subItem[item.optionId]" :disabled="subItem.isDisabled" :label="subItem[item.optionId]">{{ subItem[item.optionLabel] }}</el-radio>
<el-radio v-for="subItem in item.optionList" :key="subItem[item.optionId]" :disabled="subItem.isDisabled" :label="subItem[item.optionId]">{{ subItem[item.optionLabel] }} <slot :name="subItem.suffixSonSlot" :scope="subItem"></slot></el-radio>
</el-radio-group>
<slot :name="item.suffixSlot" :scope="item"></slot>
</div>
......
No preview for this file type
<!-- 编辑礼包 -->
<template>
<div class="edit-gift marketing edit-box">
<div class="edit-gift marketing p-t-20 edit-box">
<!-- <div v-if="routeInfo.addOrEdit != 'add'" class="container approval-container">
<p class="edit-title">审批信息</p>
<div class="approval-info">
......@@ -52,16 +52,17 @@
<el-radio :disabled="routeInfo.receivedStock" v-model="editForm.approveFlag" :label="2">无需审批</el-radio>
<p class="approval-tip">无需审批,可直接赠送给客户</p>
</div>
<div v-if="editForm.receiveRule === 1" class="telArea" slot="configSlot">
<label class="receiving" for="">领取条件:</label>
<el-radio-group @change="resetTextArea" v-model="receiveWay">
<div v-if="editForm.receiveRule === 1 || editForm.receiveRule === 4" class="telArea" slot="configSlot">
<label class="receiving" for="" v-show="editForm.receiveRule !== 4">领取条件:</label>
<label class="receiving" for="" v-show="editForm.receiveRule === 4">用户手机号:</label>
<el-radio-group v-if="editForm.receiveRule !== 4" @change="resetTextArea" v-model="receiveWay">
<el-radio :label="1">指定手机号</el-radio>
<el-radio :label="2">指定车架号后6位</el-radio>
</el-radio-group>
<div style="margin-left:70px;width: calc(100% - 70px);">
<el-input @blur="formatPhone" type="textarea" v-model="phone" :placeholder="placeholder"></el-input>
<span class="approval-tip" style="margin-left:0;">客户需准确输入该{{ receiveWay == 1 ? '手机号码' : '车架号后6位' }}才能成功领取</span>
<div>
<el-input :style="editForm.receiveRule === 4?'margin-top: -22px;margin-left: 8px;':''" @blur="formatPhone" type="textarea" v-model="phone" :placeholder="placeholder"></el-input>
<span v-if="editForm.receiveRule !== 4" class="approval-tip" style="margin-left:0;">客户需准确输入该{{ receiveWay == 1 ? '手机号码' : '车架号后6位' }}才能成功领取</span>
<div :style="editForm.receiveRule === 4?'margin-left: 7px;':''">
<div :class="['tel-item', !item.valid ? 'valid-tel': receiveWay == 1?'realTel':'realNum']" v-for="(item, index) in phoneList" :key="index">
{{ item.tel }}
<i style="cursor:pointer" class="el-icon-close" @click="delPhone(item.tel)"></i>
......@@ -69,9 +70,29 @@
</div>
</div>
</div>
<span slot="bubble">
<el-popover placement="top-start" width="200" trigger="hover" content="创建礼包时指定好领取条件,客户需正确输入领取条件方可成功领取">
<i slot="reference" class="el-icon-question" style="color: #C6C6C6;"></i>
</el-popover>
</span>
<span slot="giveAway">
<el-popover placement="top-start" width="200" trigger="hover" content="员工在每次发送礼包给客户之前,需设置好领取条件,客户需正确输入领取条件方可成功领取">
<i slot="reference" class="el-icon-question" style="color: #C6C6C6;"></i>
</el-popover>
</span>
<span slot="receives">
<el-popover placement="top-start" width="200" trigger="hover" content="客户无需输入任何领取条件,即可直接领取礼包">
<i slot="reference" class="el-icon-question" style="color: #C6C6C6;"></i>
</el-popover>
</span>
<span slot="cardHolder">
<el-popover placement="top-start" width="200" trigger="hover" content="将根据手机号直接发送至小程序客户的卡包当中,客户无需领取">
<i slot="reference" class="el-icon-question" style="color: #C6C6C6;"></i>
</el-popover>
</span>
<!-- <div slot="receiveDetails" class="edit-tips m-t-8">客户需要输入该{{ editForm.receiveWay == '1' ? '手机号' : '车架号后6位' }}才能成功领取</div> -->
<el-button slot="selectStaffBtn" :disabled="routeInfo.receivedStock" class="el-icon-plus" @click="handleSelectStaff">选择员工</el-button>
<div slot="staffListBlock" class="sale-select" :style="{ 'margin-left': labelWidth }" v-show="editForm.staffList && editForm.staffList.length != 0 && editForm.grantType == 1">
<div slot="staffListBlock" class="sale-select" :style="{ 'margin-left': labelWidth }" v-show="editForm.staffList && editForm.staffList.length != 0 && editForm.receiveRule !== 4">
<div :key="key" class="el-input-tag input-tag-wrapper">
<el-tag effect="plain" type="info" v-for="(tag, idx) in editForm.staffList" :key="idx" :closable="!routeInfo.receivedStock" :disable-transitions="false" @close="handleStaffRemove(tag, idx)">
<i class="el-icon-user-solid"></i>
......@@ -79,14 +100,6 @@
</el-tag>
</div>
</div>
<div class="approval" slot="grantType">
<el-radio :disabled="routeInfo.addOrEdit == 'edit'" v-model="editForm.grantType" :label="1">否</el-radio>
<el-radio :disabled="routeInfo.addOrEdit == 'edit'" v-model="editForm.grantType" :label="2">是</el-radio>
<p class="grantType-tip">(根据手机号将礼包中的优惠券直接发放到小程序对应账户的卡包中)</p>
</div>
<div class="approval" slot="receiveDetails">
<phoneArea :phones="phones" :phoneLists="phoneLists" ref="phoneArea" @changePhoneList="changePhoneList" placeholder="请输入领取手机号,多个手机号以换行隔开" />
</div>
</glsx-combi-form>
<div v-if="routeInfo.addOrEdit != 'add'" class="approval_note_container">
<div class="line"></div>
......@@ -102,28 +115,23 @@
</div>
</div>
</div>
<GLFooter>
<el-button @click="handleCancel" size="medium">取消</el-button>
<el-button type="primary" @click="handleConfirm" size="medium" :loading="loading">提交</el-button>
</GLFooter>
<div class="footer" :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }">
<el-button type="default" @click="handleCancel">取消</el-button>
<el-button type="primary" @click="handleConfirm">提交</el-button>
</div>
<select-gift-dialog v-if="isSelectGiftVisible" :isSelectGiftVisible="isSelectGiftVisible" :selectedGiftList="selectedGiftList" @handleGiftConfirm="handleGiftConfirm" @handleGiftClose="handleGiftClose"></select-gift-dialog>
<select-staff-dialog v-if="isMutiSelectVisible" :isMutiSelectVisible="isMutiSelectVisible" :searchForm="searchStaffForm" :selectedStaffList="selectedStaffList" @handleMutiSelectConfirm="handleMutiSelectConfirm" @handleMutiSelectClose="handleMutiSelectClose"></select-staff-dialog>
</div>
</template>
<script>
import selectStaffDialog from './selectStaffDialog.vue'
import selectGiftDialog from './selectGiftDialog.vue'
import * as dayjs from 'dayjs'
import phoneArea from './components/phone-area'
export default {
name: 'editGift',
data() {
return {
phones:'',
phoneLists:[],
phone: '',
arr:[],
isLoaded: true,
loading:false,
phoneList: [],
......@@ -133,6 +141,8 @@ export default {
add: '新增礼包',
edit: '编辑礼包'
},
footerLeft: '0',
footerWidth: '0',
// 选择员工弹窗
isMutiSelectVisible: false,
searchStaffForm: {},
......@@ -160,8 +170,7 @@ export default {
couponList: [],
stock: 1,
approveFlag: 1,
receiveRule: 1,
grantType: 1,
receiveRule: 1
},
totalEstimatedCost: '',
orderShow: ['service', 'cash', 'discount', 'exchange'],
......@@ -219,17 +228,7 @@ export default {
}
],
approveFlag: [{ required: true, message: '请选择审批要求', trigger: 'change' }],
receiveRule: [{ required: true, message: '请选择领取规则设置', trigger: 'change' }],
grantType: [{ required: true, message: '', trigger: 'change' }],
receiveDetails: [
{
required: true,
validator: (rule, value, callback) => {
return this.$refs.phoneArea.phones ? callback() : callback(new Error('请输入用户手机号'))
},
trigger: 'change'
}
]
receiveRule: [{ required: true, message: '请选择领取规则设置', trigger: 'change' }]
// receiveDetails: [
// { required: true, message: '请输入领取条件', trigger: 'change' },
// {
......@@ -280,16 +279,10 @@ export default {
addHtml: 'couponListBlock'
},
{
label: '立即发至卡包',
name: 'grantType',
isDisabled: false,
addHtml: 'grantType'
},
{
label: '库存数量',
name: 'stock',
addHtml: 'stockNumInput',
isDisabled: false,
isHide: false,
},
{
label: '审批要求',
......@@ -304,23 +297,33 @@ export default {
optionId: 'confId',
optionLabel: 'confName',
isDisabled: false,
isHide: false,
optionList: [
{
confId: 1,
confName: '创建时指定'
confName: '创建时指定',
suffixSonSlot: 'bubble'
},
{
confId: 2,
confName: '员工赠送时指定',
suffixSonSlot: 'giveAway'
},
{
confId: 3,
confName: '直接领取'
confName: '直接领取',
suffixSonSlot: 'receives'
},
{
confId: 4,
confName: '直接发送到小程序卡包',
suffixSonSlot: 'cardHolder'
}
],
suffixSlot: 'configSlot',
handleRadioChange: () => {
handleRadioChange: (e) => {
if(e==4){
this.receiveWay = 1
}
this.resetTextArea()
}
},
......@@ -367,12 +370,6 @@ export default {
addHtml: 'staffListBlock'
},
{
label: '用户手机号',
name: 'receiveDetails',
addHtml: 'receiveDetails',
isHide: true
},
{
label: '赠送原因',
name: 'giveReason',
type: 'input',
......@@ -394,10 +391,8 @@ export default {
},
components: {
selectStaffDialog,
selectGiftDialog,
phoneArea
selectGiftDialog
},
watch: {
editForm: {
handler(val) {
......@@ -415,17 +410,13 @@ export default {
this.isChangePeople = this.judgeAddOrDel(val, this.currentPeople, 'staffUUID')
}
},
'editForm.grantType'(newValue) {
let idx = this.editFormData.findIndex(item => item.name == 'staffList')
let idxx = this.editFormData.findIndex(item => item.name == 'approveFlag')
let idxxx = this.editFormData.findIndex(item => item.name == 'receiveRule')
let idxxxx = this.editFormData.findIndex(item => item.name == 'receiveDetails')
let idxxxxx = this.editFormData.findIndex(item => item.name == 'stock')
this.editFormData[idx].isHide = newValue == 2
this.editFormData[idxx].isHide = newValue == 2
this.editFormData[idxxx].isHide = newValue == 2
this.editFormData[idxxxxx].isHide = newValue == 2
this.editFormData[idxxxx].isHide = newValue == 1
'editForm.receiveRule'(newValue) {
let idx = this.editFormData.findIndex(item => item.name == 'staffList')
let idxx = this.editFormData.findIndex(item => item.name == 'approveFlag')
let idxxx = this.editFormData.findIndex(item => item.name == 'stock')
this.editFormData[idx].isHide = newValue == 4
this.editFormData[idxx].isHide = newValue == 4
this.editFormData[idxxx].isHide = newValue == 4
},
},
computed: {
......@@ -433,9 +424,9 @@ export default {
return `请输入领取${this.receiveWay == 1 ? '手机号' : '车架号后6位'},多个${this.receiveWay == 1 ? '手机号' : '车架号'}以换行符隔开`
}
},
mounted() {
this.setMinHeight()
this.footerLeft = document.querySelector('.base-container-right').offsetLeft
this.footerWidth = document.documentElement.clientWidth - this.footerLeft
this.routeInfo = this.$route.query
if (this.routeInfo.receivedStock) this.routeInfo.receivedStock = +this.routeInfo.receivedStock
this.title = this.titleObj[this.routeInfo.addOrEdit]
......@@ -451,12 +442,7 @@ export default {
})
}
},
methods: {
changePhoneList(val,v){
this.phoneLists = val
this.phones = v
},
resetTextArea() {
this.phone = ''
this.phoneList = []
......@@ -507,18 +493,11 @@ export default {
this.approvalStatus = res.data.approveStatus - 1
this.editForm = res.data
this.curStock = res.data.stock
this.editForm.grantType = res.data.grantType || 1
this.receiveWay = res.data.receiveWay || 1
if (res.data && res.data.receiveDetails && res.data.grantType == 1) {
if (res.data && res.data.receiveDetails) {
this.phone = res.data.receiveDetails.replaceAll(',', '\n')
this.formatPhone()
}
if(res.data.receiveDetails && res.data.grantType == 2) {
this.phones = res.data.receiveDetails.replaceAll(',','\n')
setTimeout(() => {
this.$refs.phoneArea.formatPhone()
},50)
}
this.recoveryCoupon()
this.recoveryTotalPrice()
this.hasStaffBlock(false)
......@@ -531,7 +510,6 @@ export default {
this.isLoaded = true
})
},
recoveryCoupon() {
this.orderShow.forEach(item => {
this.couponObj[item].list = []
......@@ -544,7 +522,6 @@ export default {
this.currentPeople = this.$common.utils.deepClone(this.editForm.staffList)
this.hasCouponBlock(false)
},
// 用来判断券和发放员工是否有增删 type: id为礼券 staffUUID为发放员工
judgeAddOrDel(newArr, oldArr, type = 'id') {
let id1 = [],
......@@ -558,13 +535,11 @@ export default {
let flag = id1.length === id2.length && id1.sort().toString() === id2.sort().toString()
return flag
},
receiveWayChange(val) {
var receiveDetailsIdx = this.editFormData.findIndex(item => item.name == 'receiveDetails')
this.editFormData[receiveDetailsIdx].placeholder = val == '1' ? '请输入领取手机号' : '请输入领取车架号后6位'
this.editFormData[receiveDetailsIdx].maxlength = val == '1' ? 11 : 6
},
// 计算预估成本
recoveryTotalPrice() {
this.totalEstimatedCost = 0
......@@ -578,13 +553,11 @@ export default {
})
this.totalEstimatedCost = (this.totalEstimatedCost / 100).toFixed(2)
},
hasCouponBlock(isValidate = true) {
var idx = this.editFormData.findIndex(item => item.name == 'couponListBlock')
this.editFormData[idx].isHide = !this.editForm.couponList.length
isValidate && this.$refs.editFormRef.$refs[this.editChildRef].validateField('couponList')
},
// 礼包
recoveryGiftList() {
this.editForm.couponList = []
......@@ -595,51 +568,43 @@ export default {
})
this.hasCouponBlock()
},
handleGiftAdd() {
// console.log(this.couponObj, '')
this.selectedGiftList = JSON.parse(JSON.stringify(this.couponObj))
this.handleGiftClose()
},
handleGiftConfirm(selectedData) {
this.handleGiftClose()
this.couponObj = selectedData
this.recoveryTotalPrice()
this.recoveryGiftList()
},
handleGiftClose() {
this.isSelectGiftVisible = !this.isSelectGiftVisible
},
handleGiftDelete(attr, idx) {
if (this.routeInfo.receivedStock) return
this.couponObj[attr].list.splice(idx, 1)
this.recoveryTotalPrice()
this.recoveryGiftList()
},
handleStaffRemove(val, idx) {
this.editForm.staffList.splice(idx, 1)
this.hasStaffBlock()
this.key = new Date()
},
hasStaffBlock(isValidate = true) {
var idx = this.editFormData.findIndex(item => item.name == 'staffListBlock')
this.editFormData[idx].isHide = !this.editForm.staffList.length
isValidate && this.$refs.editFormRef.$refs[this.editChildRef].validateField('staffList')
},
handleSelectStaff() {
this.selectedStaffList = JSON.parse(JSON.stringify(this.editForm.staffList))
this.handleMutiSelectClose()
},
handleMutiSelectClose() {
this.isMutiSelectVisible = !this.isMutiSelectVisible
},
handleMutiSelectConfirm(selectedData) {
this.editForm.staffList = []
selectedData.forEach(item => {
......@@ -651,18 +616,11 @@ export default {
this.hasStaffBlock()
this.handleMutiSelectClose()
},
handleConfirm() {
let validItem = this.phoneList.find(item => !item.valid)
if (validItem && validItem.tel && this.editForm.grantType == 1) {
if (validItem && validItem.tel) {
return this.$message.error(`${this.receiveWay == 1 ? '手机号' : '车架号'}${validItem.tel}格式错误,请修改!`)
}
if(this.editForm.grantType == 2){
let validItems = this.$refs.phoneArea.phoneLists.find(item => !item.valid)
if (validItems && validItems.tel) {
return this.$message.error(`手机号格式错误,请修改!`)
}
}
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
if (valid) {
var params = this.$common.utils.deepClone(this.editForm)
......@@ -671,7 +629,7 @@ export default {
params.couponCreateRequests.forEach(item => {
item.couponId = item.id
})
if (this.editForm.receiveRule == 1 && this.editForm.grantType == 1) {
if (this.editForm.receiveRule == 1 || this.editForm.receiveRule == 4) {
params.receiveDetailList = this.phoneList.map(item => item.tel)
let maxLength = 500
if(params.receiveDetailList && params.receiveDetailList.length > maxLength){
......@@ -683,17 +641,12 @@ export default {
delete params.couponList
if (this.routeInfo.addOrEdit == 'edit') {
params.id = this.routeInfo.id
if (this.editForm.receiveRule == 2 && this.editForm.grantType == 1) {
if (this.editForm.receiveRule == 2) {
let telArr = []
this.editForm.receiveDetails && (telArr = this.editForm.receiveDetails.split(','))
params.receiveDetailList = [...telArr]
}
}
if(this.editForm.grantType == 2) {
let phoneLists = this.$refs.phoneArea.phoneLists
params.receiveDetailList = phoneLists.map(item => item.tel)
params.receiveWay = this.receiveWay
}
params.requestSource = 1
// 插入判断是否存在审批模板
// const { session } = this.$globalState
......@@ -1002,10 +955,4 @@ export default {
}
}
}
.grantType-tip {
display: inline;
font-size: 12px;
color: #999;
margin-left: -27px;
}
</style>
</style>
\ No newline at end of file
......@@ -42,15 +42,11 @@
{{ editForm.approveFlag == 1 ? '赠送前需审批' : '无需审批' }}
</div>
<div slot="receiveDetails">
<span v-if="editForm.receiveRule != 1">{{ editForm.receiveRule == 2 ? '员工赠送时指定' : '直接领取' }}</span>
<span v-if="editForm.receiveRule != 1 && editForm.receiveRule != 4">{{ editForm.receiveRule == 2 ? '员工赠送时指定' : '直接领取' }}</span>
<span v-if="editForm.receiveRule == 2 && editForm.receiveWay && editForm.receiveDetails">{{ `${editForm.receiveWay == '1' ? '手机号:' : '车架号后6位:'}${editForm.receiveDetails}` }}</span>
<span v-if="editForm.receiveRule == 1">{{ editForm.receiveWay == '1' ? '指定手机号' : '指定车架号后6位' }}:</span>
<div v-if="editForm.receiveRule == 1" class="phone-wrap">
<span :class="['phone', editForm.receiveWay == 1 ? 'realTel' : 'realNum']" v-for="(item, id) in receiveDetailList" :key="id">{{ item }}</span>
</div>
</div>
<div slot="phones">
<div v-if="receiveDetailList" class="phone-wrap">
<span v-if="editForm.receiveRule == 4">用户手机号:</span>
<div v-if="editForm.receiveRule == 1 || editForm.receiveRule == 4" class="phone-wrap">
<span :class="['phone', editForm.receiveWay == 1 ? 'realTel' : 'realNum']" v-for="(item, id) in receiveDetailList" :key="id">{{ item }}</span>
</div>
</div>
......@@ -153,7 +149,6 @@ export default {
staffList: [{ required: true, message: '请选择发放员工', trigger: 'change' }],
approveFlag: [{ required: true, message: '请选择审批要求', trigger: 'change' }],
stock: [{ required: true, message: '请选择库存数量', trigger: 'change' }],
phones: [{ required: true, message: '请选择用户手机号', trigger: 'change' }]
},
isEdit: true,
editFormData: [
......@@ -187,8 +182,7 @@ export default {
{
label: '领取规则',
name: 'receiveWay',
addHtml: 'receiveDetails',
isHide: false
addHtml: 'receiveDetails'
},
{
label: '发放员工',
......@@ -196,12 +190,6 @@ export default {
addHtml: 'staffListBlock'
},
{
label: '用户手机号',
name: 'phones',
addHtml: 'phones',
isHide: true
},
{
label: '赠送原因',
name: 'giveReason',
type: 'showTxt'
......@@ -229,15 +217,11 @@ export default {
res.data.createdDate = dayjs(res.data.createdDate).format('YYYY-MM-DD HH:mm:ss')
res.data.updatedDate = dayjs(res.data.updatedDate).format('YYYY-MM-DD HH:mm:ss')
this.editForm = res.data
if(res?.data?.grantType==2){
if(res?.data?.receiveRule==4){
let target = this.editFormData.find(item => item.name == 'stock')
let targets = this.editFormData.find(item => item.name == 'approveFlag')
let targetss = this.editFormData.find(item => item.name == 'receiveWay')
let targetsss = this.editFormData.find(item => item.name == 'phones')
target.isHide = true
targets.isHide = true
targetss.isHide = true
targetsss.isHide = false
}
let arr = []
res.data.receiveDetails && (arr = res.data.receiveDetails.split(','))
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!