Commit 6c990531 by 张权

bug:代码优化,以及企微sdk兼容性问题

1 parent a2590559
export const setApproveParam = res =>{
const {approveTemplateId, approveNo, name, remarkName, anticipatedCost, coupons, giveReason} = res
let couponStr = ''
coupons.forEach(item => {
couponStr = couponStr + `${item.couponName}x${item.couponAmount}, 预估成本${(item.couponAnticipatedCost*item.couponAmount/100).toFixed(2)}元\n`
})
const param = {
"oaType": "10001",
"templateId": approveTemplateId,
"thirdNo": approveNo,
"extData": {
'fieldList': [
{
'title': '礼包名称',
'type': 'text',
'value': name,
},
{
'title': '备注名称',
'type': 'text',
'value': remarkName,
},
{
'title': '预估成本',
'type': 'text',
'value': (anticipatedCost/100).toFixed(2) + '元',
},
{
'title': '礼包明细',
'type': 'text',
'value': couponStr,
},
{
'title': '赠送原因',
'type': 'text',
'value': giveReason==null ? '': giveReason ,
},
]
}
}
console.log(param,'param')
return param;
}
\ No newline at end of file \ No newline at end of file
...@@ -133,6 +133,7 @@ ...@@ -133,6 +133,7 @@
import GiftModal from './GiftModal.vue' import GiftModal from './GiftModal.vue'
import { giftApi, wxConfig} from '@/api' import { giftApi, wxConfig} from '@/api'
import { discountTypeMixin } from '@/mixins' import { discountTypeMixin } from '@/mixins'
import { setApproveParam } from '@/mixins/giftMixin'
export default { export default {
name: '', name: '',
components: { GiftModal }, components: { GiftModal },
...@@ -292,49 +293,11 @@ export default { ...@@ -292,49 +293,11 @@ export default {
giftApi.createOrupdataGift(params).then(res => { giftApi.createOrupdataGift(params).then(res => {
this.hideLoading() this.hideLoading()
if(res.approveFlag ===2){ if(res.approveFlag ===2){
const {approveTemplateId, approveNo, name, remarkName, anticipatedCost, coupons, giveReason, directionalGiftId} = res wxConfig.thirdPartyOpenPage(wxConfig.thirdPartyOpenPage(setApproveParam(res)))
let couponStr = ''
coupons.forEach(item => {
couponStr = couponStr + `${item.couponName}x${item.couponAmount}, 预估成本${(item.couponAnticipatedCost*item.couponAmount/100).toFixed(2)}元\n`
})
wxConfig.thirdPartyOpenPage({
"oaType": "10001",
"templateId": approveTemplateId,
"thirdNo": approveNo,
"extData": {
'fieldList': [
{
'title': '礼包名称',
'type': 'text',
'value': name,
},
{
'title': '备注名称',
'type': 'text',
'value': remarkName,
},
{
'title': '预估成本',
'type': 'text',
'value': (anticipatedCost/100).toFixed(2) + '元',
},
{
'title': '礼包明细',
'type': 'text',
'value': couponStr,
},
{
'title': '赠送原因',
'type': 'text',
'value': giveReason,
},
]
}
})
.then((resp) => { .then((resp) => {
console.log(resp,'已发起审批') console.log(resp,'已发起审批')
setTimeout(()=>{ setTimeout(()=>{
this.$router.replace({ name: 'gift.detail', query: {id:directionalGiftId,approveStatus:999}}) this.$router.replace({ name: 'gift.detail', query: {id:res.directionalGiftId,approveStatus:999}})
},500) },500)
}) })
}else{ }else{
......
...@@ -150,6 +150,7 @@ function appendZero(int) { ...@@ -150,6 +150,7 @@ function appendZero(int) {
} }
import { giftApi,wxConfig } from '@/api' import { giftApi,wxConfig } from '@/api'
import { discountTypeMixin } from '@/mixins' import { discountTypeMixin } from '@/mixins'
import { setApproveParam } from '@/mixins/giftMixin'
export default { export default {
name: '', name: '',
mixins: [discountTypeMixin], mixins: [discountTypeMixin],
...@@ -253,45 +254,7 @@ export default { ...@@ -253,45 +254,7 @@ export default {
let { id } = this.getQuery() let { id } = this.getQuery()
giftApi.toApproveById({id}).then(res => { giftApi.toApproveById({id}).then(res => {
if(res.approveFlag ===2){ if(res.approveFlag ===2){
const {approveTemplateId, approveNo, name, remarkName, anticipatedCost, coupons, giveReason} = res wxConfig.thirdPartyOpenPage(setApproveParam(res))
let couponStr = ''
coupons.forEach(item => {
couponStr = couponStr + `${item.couponName}x${item.couponAmount}, 预估成本${(item.couponAnticipatedCost*item.couponAmount/100).toFixed(2)}元\n`
})
wxConfig.thirdPartyOpenPage({
"oaType": "10001",
"templateId": approveTemplateId,
"thirdNo": approveNo,
"extData": {
'fieldList': [
{
'title': '礼包名称',
'type': 'text',
'value': name,
},
{
'title': '备注名称',
'type': 'text',
'value': remarkName,
},
{
'title': '预估成本',
'type': 'text',
'value': (anticipatedCost/100).toFixed(2) + '元',
},
{
'title': '礼包明细',
'type': 'text',
'value': couponStr,
},
{
'title': '赠送原因',
'type': 'text',
'value': giveReason,
},
]
}
})
.then((resp) => { .then((resp) => {
console.log(resp,'已发起审批') console.log(resp,'已发起审批')
}) })
......
...@@ -138,6 +138,7 @@ ...@@ -138,6 +138,7 @@
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
import { giftApi, wxConfig } from '@/api' import { giftApi, wxConfig } from '@/api'
import { setApproveParam } from '@/mixins/giftMixin'
export default { export default {
name: '', name: '',
data () { data () {
...@@ -179,45 +180,7 @@ export default { ...@@ -179,45 +180,7 @@ export default {
toAppprove({id}){ toAppprove({id}){
giftApi.toApproveById({id}).then(res => { giftApi.toApproveById({id}).then(res => {
if(res.approveFlag ===2){ if(res.approveFlag ===2){
const {approveTemplateId, approveNo, name, remarkName, anticipatedCost, coupons, giveReason} = res wxConfig.thirdPartyOpenPage(wxConfig.thirdPartyOpenPage(setApproveParam(res)))
let couponStr = ''
coupons.forEach(item => {
couponStr = couponStr + `${item.couponName}x${item.couponAmount}, 预估成本${(item.couponAnticipatedCost*item.couponAmount/100).toFixed(2)}元\n`
})
wxConfig.thirdPartyOpenPage({
"oaType": "10001",
"templateId": approveTemplateId,
"thirdNo": approveNo,
"extData": {
'fieldList': [
{
'title': '礼包名称',
'type': 'text',
'value': name,
},
{
'title': '备注名称',
'type': 'text',
'value': remarkName,
},
{
'title': '预估成本',
'type': 'text',
'value': (anticipatedCost/100).toFixed(2) + '元',
},
{
'title': '礼包明细',
'type': 'text',
'value': couponStr,
},
{
'title': '赠送原因',
'type': 'text',
'value': giveReason,
},
]
}
})
.then((resp) => { .then((resp) => {
console.log(resp,'已发起审批') console.log(resp,'已发起审批')
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!