|
|
@@ -8,29 +8,17 @@
|
|
|
>
|
|
|
<div
|
|
|
class="wrap">
|
|
|
- <div v-loading="loading">
|
|
|
- <div class="block-title">
|
|
|
- 票种价格方案
|
|
|
- </div>
|
|
|
- <el-select v-model="plan_id">
|
|
|
- <el-option
|
|
|
- v-for="item in ticketPricePlanList"
|
|
|
- :key="item.id"
|
|
|
- :value="item.id"
|
|
|
- :label="item.name">
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- </div>
|
|
|
- <div v-loading="loading">
|
|
|
+ <el-alert type="warning" :closable="false" title="当前价格优先级:日期段价格 > 周价格 > 日常价格" />
|
|
|
+ <!-- <div v-loading="loading">
|
|
|
<div class="block-title">
|
|
|
基础价格
|
|
|
</div>
|
|
|
<el-input
|
|
|
placeholder="请输入内容"
|
|
|
- v-model="basic_price"
|
|
|
+ v-model="basicPrice"
|
|
|
style="width: 160px">
|
|
|
</el-input>
|
|
|
- </div>
|
|
|
+ </div> -->
|
|
|
<div v-loading="weekLoading">
|
|
|
<div class="block-title">
|
|
|
周价格
|
|
|
@@ -121,9 +109,18 @@
|
|
|
<script>
|
|
|
import moment from 'moment'
|
|
|
|
|
|
-import { getPricePlan, setPricePlan } from '@/api/ticketPricePlan'
|
|
|
+import { getPricePlan, addTicketPricePlan } from '@/api/ticketPricePlan'
|
|
|
|
|
|
const week = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
|
|
|
+const weekMap = {
|
|
|
+ '周日': 1,
|
|
|
+ '周一': 2,
|
|
|
+ '周二': 3,
|
|
|
+ '周三': 4,
|
|
|
+ '周四': 5,
|
|
|
+ '周五': 6,
|
|
|
+ '周六': 7
|
|
|
+}
|
|
|
|
|
|
const stragegiesMap = {
|
|
|
PERIOD: '日期段价格',
|
|
|
@@ -141,73 +138,49 @@ export default {
|
|
|
visible: false,
|
|
|
weekLoading: false,
|
|
|
confirmLoading: false,
|
|
|
- basic_price: '',
|
|
|
+ basicPrice: '',
|
|
|
ticketPricePlanList: [],
|
|
|
priceList: [],
|
|
|
weekDayPriceList: [],
|
|
|
- plan_id: '',
|
|
|
- form: {
|
|
|
- plan_id: 0,
|
|
|
- period_price: {
|
|
|
- price: []
|
|
|
- },
|
|
|
- weekday_price: {
|
|
|
- price: {}
|
|
|
- },
|
|
|
- ticketTypeId: 0
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- watch: {
|
|
|
- plan_id (newName, oldName) {
|
|
|
- this.priceList = []
|
|
|
- this.getPricePlan(newName)
|
|
|
+ ticketInfo: {}
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- moment,
|
|
|
- show (id, ticketPricePlanList) {
|
|
|
- Object.assign(this.$data, this.$options.data())
|
|
|
- this.visible = true
|
|
|
- this.ticketTypeId = id
|
|
|
- this.ticketPricePlanList = ticketPricePlanList
|
|
|
- if (!this.plan_id && ticketPricePlanList.length) {
|
|
|
- this.plan_id = ticketPricePlanList[0].id
|
|
|
- }
|
|
|
+ show (ticket) {
|
|
|
+ this.ticketInfo = ticket
|
|
|
this.weekDayPriceList = week.map((val, index) => {
|
|
|
return {
|
|
|
label: val,
|
|
|
value: null
|
|
|
}
|
|
|
})
|
|
|
- this.getPricePlan()
|
|
|
- },
|
|
|
- getPricePlan (e) {
|
|
|
- let params = {
|
|
|
- 'batch_config_id': 0,
|
|
|
- 'plan_id': e || 1,
|
|
|
- 'seat_area_id': 0,
|
|
|
- 'ticketTypeId': this.ticketTypeId }
|
|
|
- getPricePlan(params).then(res => {
|
|
|
- try {
|
|
|
- this.basic_price = res.basic_price
|
|
|
- let priceList = res.period_price.price
|
|
|
- priceList && priceList.forEach(item => {
|
|
|
- item.dateRange = [new Date(item.start), new Date(item.end)]
|
|
|
+ getPricePlan({
|
|
|
+ ticketTypeId: ticket.id,
|
|
|
+ pageSize: 10,
|
|
|
+ pageNum: -1
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code === '200') {
|
|
|
+ const list = res.data || []
|
|
|
+
|
|
|
+ list.filter(l => l.weekdays).forEach(l => {
|
|
|
+ this.weekDayPriceList.forEach(w => {
|
|
|
+ if (l.weekdays.includes(weekMap[w.label])) {
|
|
|
+ w.value = l.price
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
- this.priceList = priceList || []
|
|
|
|
|
|
- const weekPrice = res.weekday_price.price
|
|
|
- this.weekDayPriceList = week.map((val, index) => {
|
|
|
+ this.priceList = list.filter(l => !l.weekdays).map(l => {
|
|
|
+ const { startDate, endDate, specificDate, price } = l
|
|
|
return {
|
|
|
- label: val,
|
|
|
- value: (weekPrice && weekPrice[index]) || null
|
|
|
+ dateRange: [moment(specificDate || startDate), moment(specificDate || endDate)],
|
|
|
+ price: price
|
|
|
}
|
|
|
- })
|
|
|
- } catch (e) {
|
|
|
- console.log(e)
|
|
|
+ }).reverse()
|
|
|
}
|
|
|
})
|
|
|
+ this.visible = true
|
|
|
+ this.ticketTypeId = ticket.id
|
|
|
},
|
|
|
handleCancel () {
|
|
|
this.visible = false
|
|
|
@@ -243,22 +216,61 @@ export default {
|
|
|
},
|
|
|
handleOk () {
|
|
|
this.confirmLoading = true
|
|
|
- let weekPrice = this.weekDayPriceList.map(i => i.value)
|
|
|
- weekPrice = Object.assign({}, weekPrice)
|
|
|
- let params = {}
|
|
|
- params = JSON.parse(JSON.stringify(this.form))
|
|
|
- params.plan_id = this.plan_id
|
|
|
- params.period_price.price = this.priceList
|
|
|
- params.weekday_price.price = weekPrice
|
|
|
- params.ticketTypeId = this.ticketTypeId
|
|
|
- params.basic_price = this.basic_price
|
|
|
- let plan_list = []
|
|
|
- plan_list.push(params)
|
|
|
- setPricePlan({ plan_list: plan_list }).then(res => {
|
|
|
- this.$message.success('设置成功')
|
|
|
- this.handleCancel()
|
|
|
+ const { id, isSale } = this.ticketInfo
|
|
|
+ const planList = []
|
|
|
+ const weekPriceList = []
|
|
|
+ let priority = 0
|
|
|
+ const wpList = this.weekDayPriceList.filter(wp => wp.value !== null || wp.value !== undefined)
|
|
|
+ wpList.forEach(wp => {
|
|
|
+ const hasPrice = weekPriceList.find(item => wp.value === item.price)
|
|
|
+
|
|
|
+ if (hasPrice) {
|
|
|
+ hasPrice.weekdays += `,${weekMap[wp.label]}`
|
|
|
+ } else {
|
|
|
+ weekPriceList.push({
|
|
|
+ ticketTypeId: id,
|
|
|
+ isSale,
|
|
|
+ priority,
|
|
|
+ price: wp.value,
|
|
|
+ weekdays: weekMap[wp.label]
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ planList.push(...weekPriceList)
|
|
|
+
|
|
|
+ this.priceList.forEach(item => {
|
|
|
+ priority--
|
|
|
+ const { start, end, price } = item
|
|
|
+ const startDate = moment(start).format('YYYY-MM-DD')
|
|
|
+ const endDate = moment(end).format('YYYY-MM-DD')
|
|
|
+
|
|
|
+ if (startDate === endDate) {
|
|
|
+ planList.push({
|
|
|
+ ticketTypeId: id,
|
|
|
+ isSale,
|
|
|
+ priority,
|
|
|
+ price,
|
|
|
+ specificDate: startDate
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ planList.push({
|
|
|
+ ticketTypeId: id,
|
|
|
+ isSale,
|
|
|
+ priority,
|
|
|
+ price,
|
|
|
+ startDate,
|
|
|
+ endDate
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ addTicketPricePlan(planList).then(res => {
|
|
|
+ if (res.code === '200') {
|
|
|
+ this.$message.success('设置成功')
|
|
|
+ this.handleCancel()
|
|
|
+ }
|
|
|
}).finally(() => {
|
|
|
- this.confirmLoadingading = false
|
|
|
+ this.loading = false
|
|
|
})
|
|
|
}
|
|
|
}
|