描述:优惠券新增和编辑

This commit is contained in:
SelfRidicule 2024-03-26 10:33:30 +08:00
parent ee077bc38a
commit fa1409fbe5

View File

@ -111,9 +111,11 @@
size='default' size='default'
ref='table' ref='table'
style='width: 100%; padding: 0 20px;' style='width: 100%; padding: 0 20px;'
:data-source='loadData' :data-source='selectEnterpriseDataList'
rowKey='id' rowKey='id'>
:rowSelection='{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}'>
<!-- :rowSelection='{selectedRowKeys: selectEnterpriseIdList, 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>
@ -137,9 +139,9 @@
size='default' size='default'
ref='table' ref='table'
rowKey='id' rowKey='id'
:rowSelection='{ selectedRowKeys: selectedCustomerRowKeys, onChange: onCustomerSelectChange }' :rowSelection='{ selectedRowKeys: notSelectEnterpriseIdList, onChange: onCustomerSelectChange }'
:columns='customerColumns' :columns='customerColumns'
:data-source='data' :data-source='notSelectEnterpriseDataList'
> >
</a-table> </a-table>
</a-modal> </a-modal>
@ -188,9 +190,9 @@ export default {
}, },
ticketId: null, ticketId: null,
ticketNum: 0, ticketNum: 0,
selectedRowKeys: [], selectEnterpriseIdList: [],
selectedRows: [], selectedRows: [],
selectedCustomerRowKeys: [], notSelectEnterpriseIdList: [],
selectedCustomerRows: [], selectedCustomerRows: [],
columns: [ columns: [
{ {
@ -227,22 +229,16 @@ export default {
}, },
{ {
title: '企业负责人', title: '企业负责人',
dataIndex: 'user.nickname', dataIndex: 'contacts',
key: 'age'
}, },
{ {
title: '联系电话', title: '联系电话',
dataIndex: 'user.mobile' dataIndex: 'phone'
}, },
{
title: '操作',
dataIndex: 'action',
scopedSlots: { customRender: 'action' }
}
], ],
CompanyList: [], CompanyList: [],
data: [], notSelectEnterpriseDataList: [],
loadData: [], selectEnterpriseDataList: [],
// loadData: parameter => { // loadData: parameter => {
// return getTicketByCompany(Object.assign(parameter, this.queryParam)) // return getTicketByCompany(Object.assign(parameter, this.queryParam))
// }, // },
@ -262,7 +258,7 @@ export default {
clickNumber(value) { clickNumber(value) {
this.mdl.num = value this.mdl.num = value
// //
this.loadData.forEach(item => { this.selectEnterpriseDataList.forEach(item => {
if (!item.moreNum) { if (!item.moreNum) {
item.moreNum = 0 item.moreNum = 0
} }
@ -278,7 +274,7 @@ export default {
// //
handleNumSubmit() { handleNumSubmit() {
this.numVisible = false this.numVisible = false
this.loadData = this.loadData.map(item => { this.selectEnterpriseDataList = this.selectEnterpriseDataList.map(item => {
if (item.id == this.ticketId) { if (item.id == this.ticketId) {
console.log('this.ticketNum ', this.ticketNum) console.log('this.ticketNum ', this.ticketNum)
console.log('this.mdl.num ', this.mdl.num) console.log('this.mdl.num ', this.mdl.num)
@ -291,25 +287,25 @@ export default {
customerHandleOk() { 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.notSelectEnterpriseDataList = this.notSelectEnterpriseDataList.filter(item => item.id != record.id)
this.loadData.push(record) this.selectEnterpriseDataList.push(record)
}) })
this.customerVisible = false this.customerVisible = false
}, },
deleteRecord(record) { deleteRecord(record) {
this.loadData = this.loadData.filter(item => item.id != record.id) this.selectEnterpriseDataList = this.selectEnterpriseDataList.filter(item => item.id != record.id)
this.data.push(record) this.notSelectEnterpriseDataList.push(record)
}, },
onSelectChange(selectedRowKeys, selectedRows) { onSelectChange(selectedRowKeys, selectedRows) {
console.log(selectedRowKeys, selectedRows) console.log(selectedRowKeys, selectedRows)
this.selectedRowKeys = selectedRowKeys this.selectEnterpriseIdList = selectedRowKeys
this.selectedRows = selectedRows this.selectedRows = selectedRows
}, },
onCustomerSelectChange(selectedRowKeys, selectedRows) { onCustomerSelectChange(selectedRowKeys, selectedRows) {
this.selectedCustomerRowKeys = selectedRowKeys this.notSelectEnterpriseIdList = selectedRowKeys
this.selectedCustomerRows = selectedRows this.selectedCustomerRows = selectedRows
}, },
getCustomer() { getCustomer() {
@ -327,16 +323,29 @@ export default {
}, },
add() { add() {
this.form.resetFields() this.form.resetFields()
this.selectedCustomerRowKeys = [] this.notSelectEnterpriseIdList = []
this.edit({ id: 0 }) this.edit({ id: 0 })
}, },
edit(record) { edit(record) {
this.mdl = Object.assign(record) this.mdl = Object.assign(record)
this.visible = true this.visible = true
if (record.id > 0) {
get(record.id).then(res => {
//
this.selectEnterpriseDataList = res.selectCustomerList
// this.selectEnterpriseIdList = res.selectCustomerList.map(item => item.id)
//
this.notSelectEnterpriseDataList = res.notSelectCustomerList
// this.notSelectEnterpriseIdList = res.notSelectCustomerList.map(item => item.id)
})
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'))
})
} else {
// //
getTicketByCompany().then(res => { getTicketByCompany().then(res => {
console.log('getTicketByCompany', res) console.log('getTicketByCompany', res)
this.loadData = res.rows.map(item => { this.selectEnterpriseDataList = res.rows.map(item => {
if (!item.moreNum) { if (!item.moreNum) {
item.moreNum = 0 item.moreNum = 0
} }
@ -346,12 +355,7 @@ export default {
return item return item
}) })
}) })
get(record.id).then(res => { }
this.selectedRowKeys = res.enterpriseIds
})
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'))
})
}, },
handleSubmit(e) { handleSubmit(e) {
e.preventDefault() e.preventDefault()
@ -359,7 +363,7 @@ export default {
if (!err) { if (!err) {
console.log('Received values of form: ', values) console.log('Received values of form: ', values)
// //
values.ticketCustomerVo = this.loadData values.ticketCustomerVo = this.selectEnterpriseDataList
this.confirmLoading = true this.confirmLoading = true
saveTicket(values).then(res => { saveTicket(values).then(res => {
if (res.code === 0) { if (res.code === 0) {