diff --git a/src/mixins/JeroListMixin.js b/src/mixins/JeroListMixin.js index 57a2a2b..45bc72d 100644 --- a/src/mixins/JeroListMixin.js +++ b/src/mixins/JeroListMixin.js @@ -4,7 +4,7 @@ * data中url定义 list为查询列表 delete为删除单条记录 deleteBatch为批量删除 */ import {filterObj} from '@/utils/util' -import { deleteAction, downloadFile, getAction, getFileAccessHttpUrl, postAction } from '@/api/manage' +import { downloadFile, getAction, getFileAccessHttpUrl, postAction } from '@/api/manage' import Vue from 'vue' import {ACCESS_TOKEN, TENANT_ID} from '@/store/mutation-types' import store from '@/store' @@ -22,7 +22,6 @@ export const JeroListMixin = { dataSource:[], // 做一步转换,方便会员系统使用自己内部的方法 getAction, - deleteAction, getFileAccessHttpUrl, /* 分页参数 */ ipagination:{ diff --git a/src/mixins/StandardListMixin.js b/src/mixins/StandardListMixin.js new file mode 100644 index 0000000..37a179a --- /dev/null +++ b/src/mixins/StandardListMixin.js @@ -0,0 +1,81 @@ +/** + * 新增修改完成调用 modalFormOk方法 编辑弹框组件ref定义为modalForm + * 高级查询按钮调用 superQuery方法 高级查询组件ref定义为superQueryModal + * data中url定义 list为查询列表 delete为删除单条记录 deleteBatch为批量删除 + */ +import { deleteAction } from '@/api/memberManage' +// 会员系统的混入方法,增加delete的方法 +export const StandardListMixin = { + methods: { + // 批量删除 + batchDel: function() { + if (!this.url.deleteBatch) { + this.$message.error('请设置url.deleteBatch属性!') + return + } + if (this.selectedRowKeys.length <= 0) { + this.$message.warning('请选择一条记录!') + return + } else { + let ids = '' + for (let a = 0; a < this.selectedRowKeys.length; a++) { + ids += this.selectedRowKeys[a] + ',' + } + const that = this + this.$confirm({ + title: '确认删除', + content: '是否删除选中数据?', + onOk: function() { + that.loading = true + deleteAction(that.url.deleteBatch, { ids: ids }).then((res) => { + if (res.success) { + that.$message.success(res.message) + // 判断当前删除的数据是否是最后一页的全部数据,如果是的话页码减一 + if (that.ipagination.current > 1 && (that.ipagination.current === Math.ceil(that.ipagination.total / that.ipagination.pageSize)) && + that.selectedRowKeys.length === that.dataSource.length + ) { + that.ipagination.current -= 1 + } + that.loadData() + that.onClearSelected() + } else { + that.$message.warning(res.message) + } + }).finally(() => { + that.loading = false + }) + } + }) + } + }, + // 删除 + handleDelete: function(id) { + if (!this.url.delete) { + this.$message.error('请设置url.delete属性!') + return + } + let that = this + this.$confirm({ + title: '确认删除', + content: '确定要删除此条数据吗?', + onOk: function() { + that.loading = true + deleteAction(that.url.delete, {id: id}).then((res) => { + if (res.success) { + that.$message.success(res.message) + // 判断当前删除的数据是否是最后一页的最后一条数据,如果是的话页码减一 + if (that.ipagination.current > 1 && ((that.ipagination.current - 1) * that.ipagination.pageSize) + 1 === that.ipagination.total) { + that.ipagination.current -= 1 + } + that.loadData() + } else { + that.$message.warning(res.message) + } + }).finally(() => { + that.loading = false + }) + } + }) + } + } +} diff --git a/src/views/standardsAssociation/CertificateManagement.vue b/src/views/standardsAssociation/CertificateManagement.vue index ba8fdca..f52a984 100644 --- a/src/views/standardsAssociation/CertificateManagement.vue +++ b/src/views/standardsAssociation/CertificateManagement.vue @@ -173,6 +173,7 @@ import '@/assets/less/TableExpand.less' import { mixinDevice } from '@/utils/mixin' import { JeroListMixin } from '@/mixins/JeroListMixin' +import { StandardListMixin } from '@/mixins/StandardListMixin' import VinCertificateModal from './memberManagementModule/VinCertificateModal' import JDate from '../../components/tools/JDate' import Vue from 'vue' @@ -181,11 +182,11 @@ import JMultiSelectTag from '@comp/standardsAssociation/JMultiSelectTag' import { RangeDateMixin } from '@/mixins/RangeDateMixin' import JDictSelectTag from '../../components/standardsAssociation/JDictSelectTag' // eslint-disable-next-line no-unused-vars -import { deleteAction, downloadFile, getAction, getFileAccessHttpUrl } from '@/api/memberManage' +import { downloadFile, getAction, getFileAccessHttpUrl } from '@/api/memberManage' export default { name: 'CertificateManagement', - mixins: [JeroListMixin, mixinDevice, RangeDateMixin], + mixins: [JeroListMixin, mixinDevice, RangeDateMixin, StandardListMixin], components: { JMultiSelectTag, JDate, @@ -194,7 +195,6 @@ export default { }, data() { return { - deleteAction, getAction, getFileAccessHttpUrl, // 时间范围查询显示的类型 diff --git a/src/views/standardsAssociation/PaymentInfo/MemberInfo.vue b/src/views/standardsAssociation/PaymentInfo/MemberInfo.vue index 8dc8f0f..cee5199 100644 --- a/src/views/standardsAssociation/PaymentInfo/MemberInfo.vue +++ b/src/views/standardsAssociation/PaymentInfo/MemberInfo.vue @@ -129,17 +129,18 @@ import '@/assets/less/TableExpand.less' import { mixinDevice } from '@/utils/mixin' import { JeroListMixin } from '@/mixins/JeroListMixin' +import { StandardListMixin } from '@/mixins/StandardListMixin' import PaymentInfoModal from './modules/PaymentInfoModal' import JDictSelectTag from '@/components/standardsAssociation/JDictSelectTag.vue' import JDate from '@/components/tools/JDate.vue' import { getMemberInfoById } from '@/api/standardsAssociationApi' import { RangeDateMixin } from '@/mixins/RangeDateMixin' -import { deleteAction, getAction, getFileAccessHttpUrl } from '@/api/memberManage' +import { getAction, getFileAccessHttpUrl } from '@/api/memberManage' export default { name: 'MemberInfo', - mixins: [JeroListMixin, mixinDevice, RangeDateMixin], + mixins: [JeroListMixin, mixinDevice, RangeDateMixin, StandardListMixin], components: { JDictSelectTag, JDate, @@ -147,7 +148,6 @@ export default { }, data() { return { - deleteAction, getAction, getFileAccessHttpUrl, // 时间范围查询显示的类型