This commit is contained in:
SelfRidicule 2024-03-25 17:30:02 +08:00
parent 902769298c
commit 8baf9881ff

View File

@ -22,7 +22,8 @@
<a-row> <a-row>
<a-col :span='11'> <a-col :span='11'>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='优惠卷名称'> <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='优惠卷名称'>
<a-input placeholder='优惠卷名称' v-decorator="['title',{rules: [{ required: true, message: '优惠卷名称'}]}]" /> <a-input placeholder='优惠卷名称'
v-decorator="['title',{rules: [{ required: true, message: '优惠卷名称'}]}]" />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span='11'> <a-col :span='11'>
@ -40,7 +41,8 @@
<a-row> <a-row>
<a-col :span='11'> <a-col :span='11'>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='优惠方式'> <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='优惠方式'>
<a-input placeholder='优惠方式' v-decorator="['content',{rules: [{ required: true, message: '优惠方式'}]}]" /> <a-input placeholder='优惠方式'
v-decorator="['content',{rules: [{ required: true, message: '优惠方式'}]}]" />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span='11'> <a-col :span='11'>
@ -56,13 +58,15 @@
<a-row> <a-row>
<a-col :span='11'> <a-col :span='11'>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='开始时间'> <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='开始时间'>
<a-date-picker @change='onChange' v-decorator="['startTime',{rules: [{ required: true, message: '开始时间'}]}]" <a-date-picker @change='onChange'
v-decorator="['startTime',{rules: [{ required: true, message: '开始时间'}]}]"
placeholder='开始时间' /> placeholder='开始时间' />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span='11'> <a-col :span='11'>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='结束日期'> <a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='结束日期'>
<a-date-picker @change='onChange' v-decorator="['endDate',{rules: [{ required: true, message: '结束日期'}]}]" <a-date-picker @change='onChange'
v-decorator="['endDate',{rules: [{ required: true, message: '结束日期'}]}]"
placeholder='结束日期' /> placeholder='结束日期' />
</a-form-item> </a-form-item>
</a-col> </a-col>
@ -106,15 +110,15 @@
<a-table :columns='columns' <a-table :columns='columns'
size='default' size='default'
ref='table' ref='table'
style='width: 800px;margin-left: 20px' style='width: 100%; padding: 0 20px;'
:data-source='loadData' :data-source='loadData'
rowKey='id' rowKey='id'
:rowSelection='{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}'> :rowSelection='{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}'>
<a slot='name' slot-scope='text'>{{ text }}</a> <a slot='name' slot-scope='text'>{{ text }}</a>
<span slot='action' slot-scope='text, record'> <span slot='action' slot-scope='text, record'>
<a @click='deleteRecord(record)' >删除</a> <a @click='deleteRecord(record)'>删除</a>
<a-divider type='vertical' /> <a-divider type='vertical' />
<a @click='couponTicket(record)'>多发优惠劵</a> <a v-if='value === 2' @click='couponTicket(record)'>多发优惠劵</a>
</span> </span>
</a-table> </a-table>
</a-form> </a-form>
@ -148,7 +152,7 @@
@ok='handleNumSubmit' @ok='handleNumSubmit'
> >
<a-form layout='inline'> <a-form layout='inline'>
<a-form-item label='发放数量' > <a-form-item label='发放数量'>
<a-input-number placeholder='请输入发放数量' v-model='ticketNum' style='width: 200px' /> <a-input-number placeholder='请输入发放数量' v-model='ticketNum' style='width: 200px' />
</a-form-item> </a-form-item>
</a-form> </a-form>
@ -159,7 +163,7 @@
</template> </template>
<script> <script>
import { saveTicket, getTicketByCompany,get } from '@/api/admin/meeting/ticket' import { saveTicket, getTicketByCompany, get } from '@/api/admin/meeting/ticket'
import pick from 'lodash.pick' import pick from 'lodash.pick'
import { STable } from '@/components' import { STable } from '@/components'
@ -182,7 +186,8 @@ export default {
xs: { span: 24 }, xs: { span: 24 },
sm: { span: 16 } sm: { span: 16 }
}, },
ticketNum:0, ticketId: null,
ticketNum: 0,
selectedRowKeys: [], selectedRowKeys: [],
selectedRows: [], selectedRows: [],
selectedCustomerRowKeys: [], selectedCustomerRowKeys: [],
@ -202,8 +207,12 @@ export default {
dataIndex: 'phone' dataIndex: 'phone'
}, },
{ {
title: '优惠劵数量', title: '优惠劵总数量',
dataIndex: 'num' dataIndex: 'sumNum'
},
{
title: '优惠劵多发数量',
dataIndex: 'moreNum'
}, },
{ {
title: '操作', title: '操作',
@ -238,7 +247,7 @@ export default {
// return getTicketByCompany(Object.assign(parameter, this.queryParam)) // return getTicketByCompany(Object.assign(parameter, this.queryParam))
// }, // },
value: 1, value: 1,
numVisible:false, numVisible: false,
confirmLoading: false, confirmLoading: false,
mdl: {}, mdl: {},
queryParam: {}, queryParam: {},
@ -250,28 +259,42 @@ export default {
created() { created() {
}, },
methods: { methods: {
// clickNumber(value) {
couponTicket(){ this.mdl.num = value
this.numVisible =true //
}, this.loadData.forEach(item => {
clickNumber(value){ if (!item.moreNum) {
// item.moreNum = 0
this.loadData.forEach(item =>{ }
item.num = value item.sumNum = value + item.moreNum
}) })
}, },
//
handleNumSubmit(){ couponTicket(record) {
this.numVisible = true
this.ticketId = record.id
this.ticketNum = record.moreNum
}, },
//
customerHandleOk(){ handleNumSubmit() {
this.numVisible = false
this.loadData = this.loadData.map(item => {
if (item.id == this.ticketId) {
console.log('this.ticketNum ', this.ticketNum)
console.log('this.mdl.num ', this.mdl.num)
item.moreNum = this.ticketNum
item.sumNum = item.moreNum + this.mdl.num
}
return item
})
},
customerHandleOk() {
let record = this.selectedCustomerRows let record = this.selectedCustomerRows
record.forEach(record =>{ record.forEach(record => {
this.data = this.data.filter(item => item.id != record.id) this.data = this.data.filter(item => item.id != record.id)
this.loadData.push(record) this.loadData.push(record)
}) })
this.customerVisible =false this.customerVisible = false
}, },
@ -284,16 +307,11 @@ export default {
console.log(selectedRowKeys, selectedRows) console.log(selectedRowKeys, selectedRows)
this.selectedRowKeys = selectedRowKeys this.selectedRowKeys = selectedRowKeys
this.selectedRows = selectedRows this.selectedRows = selectedRows
//
}, },
onCustomerSelectChange(selectedRowKeys, selectedRows) { onCustomerSelectChange(selectedRowKeys, selectedRows) {
this.selectedCustomerRowKeys = selectedRowKeys this.selectedCustomerRowKeys = selectedRowKeys
this.selectedCustomerRows = selectedRows this.selectedCustomerRows = selectedRows
}, },
getCustomer() { getCustomer() {
this.customerVisible = true this.customerVisible = true
}, },
@ -307,7 +325,6 @@ export default {
this.form.startTime = dateString[0] this.form.startTime = dateString[0]
this.form.endDate = dateString[1] this.form.endDate = dateString[1]
}, },
add() { add() {
this.form.resetFields() this.form.resetFields()
this.selectedCustomerRowKeys = [] this.selectedCustomerRowKeys = []
@ -316,22 +333,21 @@ export default {
edit(record) { edit(record) {
this.mdl = Object.assign(record) this.mdl = Object.assign(record)
this.visible = true this.visible = true
//
getTicketByCompany().then(res => { getTicketByCompany().then(res => {
this.loadData = res.rows console.log('getTicketByCompany', res)
this.loadData = res.rows.map(item => {
if (!item.moreNum) {
item.moreNum = 0
}
return item
}) })
//todo
get(record.id).then(res =>{
this.form.setFieldsValue({
type:res.type.toString(),
duration:res.duration,
discount:res.discount,
}) })
this.selectedRowKeys =res.enterpriseIds get(record.id).then(res => {
this.selectedRowKeys = res.enterpriseIds
}) })
this.$nextTick(() => { this.$nextTick(() => {
this.form.setFieldsValue(pick(this.mdl, 'id', 'title', 'content', 'duration', 'type', 'money', 'address', 'isVerification','enterpriseIds', 'isShow', 'startTime', 'endDate', 'remark', 'isDefault', 'version', 'deleteFlag', 'createBy', 'createTime', 'updateBy', 'updateTime')) this.form.setFieldsValue(pick(this.mdl, 'id', 'title', 'content', 'duration', 'type', 'money', 'address', 'isVerification', 'enterpriseIds', 'isShow', 'startTime', 'endDate', 'remark', 'isDefault', 'version', 'deleteFlag', 'createBy', 'createTime', 'updateBy', 'updateTime'))
}) })
}, },
handleSubmit(e) { handleSubmit(e) {
@ -341,10 +357,10 @@ export default {
console.log('Received values of form: ', values) console.log('Received values of form: ', values)
values.count = 1 values.count = 1
let ids = [] let ids = []
this.loadData.forEach(item =>{ this.loadData.forEach(item => {
ids.push(item.id) ids.push(item.id)
}) })
values.enterpriseIds=this.selectedRowKeys>0?this.selectedRowKeys:ids values.enterpriseIds = this.selectedRowKeys > 0 ? this.selectedRowKeys : ids
this.confirmLoading = true this.confirmLoading = true
saveTicket(values).then(res => { saveTicket(values).then(res => {
if (res.code === 0) { if (res.code === 0) {