|
|
@@ -328,1054 +328,8 @@
|
|
|
</basic-container>
|
|
|
</template>
|
|
|
|
|
|
-<script>
|
|
|
-import {
|
|
|
- getList,
|
|
|
- getDetail,
|
|
|
- update,
|
|
|
- approveWithSmartRecord,
|
|
|
- getApprovalRecords,
|
|
|
- getApprovalRecordDetail,
|
|
|
- addApprovalRecord,
|
|
|
- updateApprovalRecord,
|
|
|
- saveApprovalRecord,
|
|
|
- getActivityAttachments
|
|
|
-} from '@/api/order/marketing-activity'
|
|
|
-import { formatFileSize } from '@/util/util'
|
|
|
-import { mapGetters } from 'vuex'
|
|
|
+<script src="./index.js">
|
|
|
|
|
|
-/**
|
|
|
- * 营销活动记录类型定义
|
|
|
- * @typedef {Object} MarketingActivityRecord
|
|
|
- * @property {string} id - 活动ID
|
|
|
- * @property {string} activityCode - 活动编码
|
|
|
- * @property {number} applicantType - 申请人类型
|
|
|
- * @property {number} customerId - 客户ID
|
|
|
- * @property {string} customerCode - 客户编码
|
|
|
- * @property {string} customerName - 客户名称
|
|
|
- * @property {string} contactName - 联系人姓名
|
|
|
- * @property {string} contactPhone - 联系人电话
|
|
|
- * @property {string} title - 活动标题
|
|
|
- * @property {string} startTime - 开始时间
|
|
|
- * @property {string} endTime - 结束时间
|
|
|
- * @property {string} activityType - 活动类型
|
|
|
- * @property {string} promotionPrice - 促销价格
|
|
|
- * @property {string} description - 活动描述
|
|
|
- * @property {number} approvalStatus - 审批状态
|
|
|
- * @property {string} approvalRemark - 审批备注
|
|
|
- * @property {number} approverId - 审批人ID
|
|
|
- * @property {string} approverName - 审批人姓名
|
|
|
- * @property {string} approvalTime - 审批时间
|
|
|
- * @property {string} createTime - 创建时间
|
|
|
- * @property {string} updateTime - 更新时间
|
|
|
- */
|
|
|
-
|
|
|
-/**
|
|
|
- * 营销活动查询参数类型定义
|
|
|
- * @typedef {Object} MarketingActivityQueryParams
|
|
|
- * @property {string} [activityCode] - 活动编码
|
|
|
- * @property {string} [customerName] - 客户名称
|
|
|
- * @property {string} [title] - 活动标题
|
|
|
- * @property {string} [activityType] - 活动类型
|
|
|
- * @property {number} [approvalStatus] - 审批状态
|
|
|
- */
|
|
|
-
|
|
|
-export default {
|
|
|
- data() {
|
|
|
- return {
|
|
|
-
|
|
|
- /**
|
|
|
- * 详情加载状态
|
|
|
- * @type {boolean}
|
|
|
- */
|
|
|
- detailLoading: false,
|
|
|
-
|
|
|
- /**
|
|
|
- * 图片预览弹窗配置
|
|
|
- * @type {Object}
|
|
|
- */
|
|
|
- imagePreviewDialog: {
|
|
|
- visible: false,
|
|
|
- imageUrl: '',
|
|
|
- fileName: '',
|
|
|
- currentAttachment: null
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 查看弹窗显示状态
|
|
|
- * @type {boolean}
|
|
|
- */
|
|
|
- viewDialogVisible: false,
|
|
|
-
|
|
|
- /**
|
|
|
- * 当前查看的活动详情
|
|
|
- * @type {MarketingActivityItem|null}
|
|
|
- */
|
|
|
- currentViewActivity: null,
|
|
|
-
|
|
|
- /**
|
|
|
- * 附件列表数据
|
|
|
- * @type {ActivityAttachmentItem[]}
|
|
|
- */
|
|
|
- attachmentsList: [],
|
|
|
-
|
|
|
- /**
|
|
|
- * 附件加载状态
|
|
|
- * @type {boolean}
|
|
|
- */
|
|
|
- attachmentsLoading: false,
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 审批记录对话框配置
|
|
|
- * @type {Object}
|
|
|
- */
|
|
|
- approvalRecordsDialog: {
|
|
|
- visible: false,
|
|
|
- loading: false,
|
|
|
- activityId: '',
|
|
|
- activityCode: '',
|
|
|
- activityTitle: '',
|
|
|
- data: [],
|
|
|
- page: {
|
|
|
- current: 1,
|
|
|
- size: 10,
|
|
|
- total: 0
|
|
|
- }
|
|
|
- },
|
|
|
- /**
|
|
|
- * 表格数据
|
|
|
- * @type {MarketingActivityRecord[]}
|
|
|
- */
|
|
|
- data: [],
|
|
|
-
|
|
|
- /**
|
|
|
- * 查询参数
|
|
|
- * @type {MarketingActivityQueryParams}
|
|
|
- */
|
|
|
- query: {},
|
|
|
-
|
|
|
- /**
|
|
|
- * 表单数据
|
|
|
- * @type {MarketingActivityRecord}
|
|
|
- */
|
|
|
- form: {},
|
|
|
-
|
|
|
- /**
|
|
|
- * 选中的数据列表
|
|
|
- * @type {MarketingActivityRecord[]}
|
|
|
- */
|
|
|
- selectionList: [],
|
|
|
-
|
|
|
- /**
|
|
|
- * 表格加载状态
|
|
|
- * @type {boolean}
|
|
|
- */
|
|
|
- loading: true,
|
|
|
-
|
|
|
- /**
|
|
|
- * 分页配置
|
|
|
- * @type {Object}
|
|
|
- */
|
|
|
- page: {
|
|
|
- pageSize: 10,
|
|
|
- currentPage: 1,
|
|
|
- total: 0
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 审批对话框配置
|
|
|
- * @type {Object}
|
|
|
- */
|
|
|
- approvalDialog: {
|
|
|
- visible: false,
|
|
|
- loading: false,
|
|
|
- title: ''
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 审批表单数据
|
|
|
- * @type {Object}
|
|
|
- */
|
|
|
- approvalForm: {
|
|
|
- id: '',
|
|
|
- title: '',
|
|
|
- customerName: '',
|
|
|
- approvalStatus: 1,
|
|
|
- approvalRemark: ''
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 审批表单验证规则
|
|
|
- * @type {Object}
|
|
|
- */
|
|
|
- approvalRules: {
|
|
|
- approvalRemark: [
|
|
|
- { required: true, message: '请输入审批意见', trigger: 'blur' },
|
|
|
- { min: 5, message: '审批意见至少5个字符', trigger: 'blur' },
|
|
|
- { max: 500, message: '审批意见不能超过500个字符', trigger: 'blur' }
|
|
|
- ]
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 表格配置
|
|
|
- * @type {Object}
|
|
|
- */
|
|
|
- option: {
|
|
|
- height: 'auto',
|
|
|
- calcHeight: 30,
|
|
|
- tip: false,
|
|
|
- searchShow: true,
|
|
|
- searchMenuSpan: 6,
|
|
|
- border: true,
|
|
|
- index: true,
|
|
|
- viewBtn: true,
|
|
|
- editBtn: false,
|
|
|
- delBtn: false,
|
|
|
- addBtn: false,
|
|
|
- column: [
|
|
|
- {
|
|
|
- label: '活动编码',
|
|
|
- prop: 'activityCode',
|
|
|
- minWidth: 120,
|
|
|
- search: true,
|
|
|
- fixed: true
|
|
|
- },
|
|
|
- {
|
|
|
- label: '活动标题',
|
|
|
- prop: 'title',
|
|
|
- minWidth: 200,
|
|
|
- search: true,
|
|
|
- overHidden: true
|
|
|
- },
|
|
|
- {
|
|
|
- label: '客户名称',
|
|
|
- prop: 'customerName',
|
|
|
- minWidth: 150,
|
|
|
- search: true,
|
|
|
- overHidden: true
|
|
|
- },
|
|
|
- {
|
|
|
- label: '联系人',
|
|
|
- prop: 'contactName',
|
|
|
- minWidth: 100,
|
|
|
- overHidden: true
|
|
|
- },
|
|
|
- {
|
|
|
- label: '联系电话',
|
|
|
- prop: 'contactPhone',
|
|
|
- minWidth: 120,
|
|
|
- overHidden: true
|
|
|
- },
|
|
|
- {
|
|
|
- label: '活动类型',
|
|
|
- prop: 'activityType',
|
|
|
- minWidth: 100,
|
|
|
- search: true,
|
|
|
- type: 'select',
|
|
|
- dicData: [
|
|
|
- { label: '促销', value: '促销' },
|
|
|
- { label: '折扣', value: '折扣' },
|
|
|
- { label: '满减', value: '满减' },
|
|
|
- { label: '买赠', value: '买赠' },
|
|
|
- { label: '其他', value: '其他' }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- label: '活动时间',
|
|
|
- prop: 'activityPeriod',
|
|
|
- minWidth: 180,
|
|
|
- slot: true,
|
|
|
- sortable: false,
|
|
|
- search: false
|
|
|
- },
|
|
|
- {
|
|
|
- label: '促销价格',
|
|
|
- prop: 'promotionPrice',
|
|
|
- minWidth: 120,
|
|
|
- slot: true,
|
|
|
- sortable: true
|
|
|
- },
|
|
|
- {
|
|
|
- label: '审批状态',
|
|
|
- prop: 'approvalStatus',
|
|
|
- minWidth: 100,
|
|
|
- slot: true,
|
|
|
- search: true,
|
|
|
- type: 'select',
|
|
|
- dicData: [
|
|
|
- { label: '待审批', value: 1 },
|
|
|
- { label: '审批通过', value: 2 },
|
|
|
- { label: '审批拒绝', value: 3 }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- label: '审批人',
|
|
|
- prop: 'approverName',
|
|
|
- minWidth: 100,
|
|
|
- overHidden: true
|
|
|
- },
|
|
|
- {
|
|
|
- label: '审批时间',
|
|
|
- prop: 'approvalTime',
|
|
|
- minWidth: 150,
|
|
|
- type: 'datetime',
|
|
|
- format: 'yyyy-MM-dd HH:mm:ss',
|
|
|
- valueFormat: 'yyyy-MM-dd HH:mm:ss'
|
|
|
- },
|
|
|
- {
|
|
|
- label: '创建时间',
|
|
|
- prop: 'createTime',
|
|
|
- minWidth: 150,
|
|
|
- type: 'datetime',
|
|
|
- format: 'yyyy-MM-dd HH:mm:ss',
|
|
|
- valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
|
|
- addDisplay: false,
|
|
|
- editDisplay: false,
|
|
|
- viewDisplay: true
|
|
|
- },
|
|
|
- {
|
|
|
- label: '更新时间',
|
|
|
- prop: 'updateTime',
|
|
|
- minWidth: 150,
|
|
|
- type: 'datetime',
|
|
|
- format: 'yyyy-MM-dd HH:mm:ss',
|
|
|
- valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
|
|
- addDisplay: false,
|
|
|
- editDisplay: false,
|
|
|
- viewDisplay: true
|
|
|
- },
|
|
|
- {
|
|
|
- label: '活动描述',
|
|
|
- prop: 'description',
|
|
|
- minWidth: 200,
|
|
|
- type: 'textarea',
|
|
|
- overHidden: true,
|
|
|
- span: 24,
|
|
|
- addDisplay: false,
|
|
|
- editDisplay: false,
|
|
|
- viewDisplay: true
|
|
|
- },
|
|
|
- {
|
|
|
- label: '审批备注',
|
|
|
- prop: 'approvalRemark',
|
|
|
- minWidth: 200,
|
|
|
- type: 'textarea',
|
|
|
- overHidden: true,
|
|
|
- span: 24,
|
|
|
- addDisplay: false,
|
|
|
- editDisplay: false,
|
|
|
- viewDisplay: true
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 权限列表
|
|
|
- * @type {Object}
|
|
|
- */
|
|
|
- permissionList: {
|
|
|
- addBtn: false,
|
|
|
- viewBtn: false,
|
|
|
- delBtn: false,
|
|
|
- editBtn: false
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- computed: {
|
|
|
- ...mapGetters(['permission', 'userInfo']),
|
|
|
-
|
|
|
- /**
|
|
|
- * 选中的ID列表
|
|
|
- * @returns {string} 逗号分隔的ID字符串
|
|
|
- */
|
|
|
- ids() {
|
|
|
- const ids = []
|
|
|
- this.selectionList.forEach(ele => {
|
|
|
- ids.push(ele.id)
|
|
|
- })
|
|
|
- return ids.join(',')
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- methods: {
|
|
|
-
|
|
|
- /**
|
|
|
- * 判断是否为图片文件
|
|
|
- * @param {string} fileType - 文件类型
|
|
|
- * @returns {boolean} 是否为图片文件
|
|
|
- */
|
|
|
- isImageFile(fileType) {
|
|
|
- if (!fileType) return false
|
|
|
- const imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg']
|
|
|
- return imageTypes.includes(fileType.toLowerCase())
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 预览图片
|
|
|
- * @param {ActivityAttachmentItem} attachment - 附件信息
|
|
|
- * @returns {void}
|
|
|
- */
|
|
|
- handlePreviewImage(attachment) {
|
|
|
- if (!this.isImageFile(attachment.fileType)) {
|
|
|
- this.$message.warning('该文件不是图片格式,无法预览')
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- if (!attachment.fileUrl) {
|
|
|
- this.$message.warning('图片链接不存在')
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- this.imagePreviewDialog = {
|
|
|
- visible: true,
|
|
|
- imageUrl: attachment.fileUrl.trim(),
|
|
|
- fileName: attachment.fileName,
|
|
|
- currentAttachment: attachment
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 关闭图片预览弹窗
|
|
|
- * @returns {void}
|
|
|
- */
|
|
|
- handleCloseImagePreview() {
|
|
|
- this.imagePreviewDialog = {
|
|
|
- visible: false,
|
|
|
- imageUrl: '',
|
|
|
- fileName: '',
|
|
|
- currentAttachment: null
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 处理缩略图加载错误
|
|
|
- * @param {Event} event - 错误事件
|
|
|
- * @returns {void}
|
|
|
- */
|
|
|
- handleImageError(event) {
|
|
|
- event.target.style.display = 'none'
|
|
|
- const parent = event.target.parentNode
|
|
|
- if (parent && !parent.querySelector('.error-icon')) {
|
|
|
- const errorIcon = document.createElement('i')
|
|
|
- errorIcon.className = 'el-icon-picture-outline error-icon'
|
|
|
- errorIcon.style.fontSize = '24px'
|
|
|
- errorIcon.style.color = '#ccc'
|
|
|
- parent.appendChild(errorIcon)
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 处理预览图片加载错误
|
|
|
- * @param {Event} event - 错误事件
|
|
|
- * @returns {void}
|
|
|
- */
|
|
|
- handlePreviewImageError(event) {
|
|
|
- this.$message.error('图片加载失败')
|
|
|
- event.target.style.display = 'none'
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 关闭查看弹窗
|
|
|
- * @returns {void}
|
|
|
- */
|
|
|
- handleCloseViewDialog() {
|
|
|
- this.viewDialogVisible = false
|
|
|
- this.currentViewActivity = null
|
|
|
- this.attachmentsList = []
|
|
|
- // 同时关闭图片预览弹窗
|
|
|
- this.handleCloseImagePreview()
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 加载活动附件列表
|
|
|
- * @param {string|number} activityId - 活动ID
|
|
|
- * @returns {Promise<void>}
|
|
|
- */
|
|
|
- async loadActivityAttachments(activityId) {
|
|
|
- if (!activityId) return
|
|
|
-
|
|
|
- this.attachmentsLoading = true
|
|
|
- try {
|
|
|
- const response = await getActivityAttachments(1, 100, activityId)
|
|
|
- if (response.data.success) {
|
|
|
- this.attachmentsList = response.data.data.records || []
|
|
|
- } else {
|
|
|
- this.$message.error('获取附件列表失败')
|
|
|
- this.attachmentsList = []
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.error('获取附件列表失败:', error)
|
|
|
- this.$message.error('获取附件列表失败')
|
|
|
- this.attachmentsList = []
|
|
|
- } finally {
|
|
|
- this.attachmentsLoading = false
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 预览附件
|
|
|
- * @param {ActivityAttachmentItem} attachment - 附件信息
|
|
|
- * @returns {void}
|
|
|
- */
|
|
|
- handleViewAttachment(attachment) {
|
|
|
- if (attachment.fileUrl) {
|
|
|
- window.open(attachment.fileUrl.trim(), '_blank')
|
|
|
- } else {
|
|
|
- this.$message.warning('文件链接不存在')
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 下载附件
|
|
|
- * @param {ActivityAttachmentItem} attachment - 附件信息
|
|
|
- * @returns {void}
|
|
|
- */
|
|
|
- handleDownloadAttachment(attachment) {
|
|
|
- if (attachment.fileUrl) {
|
|
|
- const link = document.createElement('a')
|
|
|
- link.href = attachment.fileUrl.trim()
|
|
|
- link.download = attachment.fileName
|
|
|
- link.target = '_blank'
|
|
|
- document.body.appendChild(link)
|
|
|
- link.click()
|
|
|
- document.body.removeChild(link)
|
|
|
- } else {
|
|
|
- this.$message.warning('文件链接不存在')
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- formatFileSize,
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取文件类型图标
|
|
|
- * @param {string} fileType - 文件类型
|
|
|
- * @returns {string} 图标类名
|
|
|
- */
|
|
|
- getFileTypeIcon(fileType) {
|
|
|
- if (!fileType) return 'el-icon-document'
|
|
|
-
|
|
|
- const type = fileType.toLowerCase()
|
|
|
- const iconMap = {
|
|
|
- pdf: 'el-icon-document',
|
|
|
- doc: 'el-icon-document',
|
|
|
- docx: 'el-icon-document',
|
|
|
- xls: 'el-icon-s-grid',
|
|
|
- xlsx: 'el-icon-s-grid',
|
|
|
- ppt: 'el-icon-present',
|
|
|
- pptx: 'el-icon-present',
|
|
|
- jpg: 'el-icon-picture',
|
|
|
- jpeg: 'el-icon-picture',
|
|
|
- png: 'el-icon-picture',
|
|
|
- gif: 'el-icon-picture',
|
|
|
- bmp: 'el-icon-picture',
|
|
|
- txt: 'el-icon-document',
|
|
|
- zip: 'el-icon-folder-opened',
|
|
|
- rar: 'el-icon-folder-opened',
|
|
|
- '7z': 'el-icon-folder-opened'
|
|
|
- }
|
|
|
-
|
|
|
- return iconMap[type] || 'el-icon-document'
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取审批状态文本
|
|
|
- * @param {number} status - 审批状态
|
|
|
- * @returns {string} 状态文本
|
|
|
- */
|
|
|
- getApprovalStatusText(status) {
|
|
|
- const statusMap = {
|
|
|
- 1: '待审批',
|
|
|
- 2: '审批通过',
|
|
|
- 3: '审批拒绝'
|
|
|
- }
|
|
|
- return statusMap[status] || '未知状态'
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取审批状态类型
|
|
|
- * @param {number} status - 审批状态
|
|
|
- * @returns {string} 状态类型
|
|
|
- */
|
|
|
- getApprovalStatusType(status) {
|
|
|
- const typeMap = {
|
|
|
- 1: 'warning',
|
|
|
- 2: 'success',
|
|
|
- 3: 'danger'
|
|
|
- }
|
|
|
- return typeMap[status] || 'info'
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 查看审批记录
|
|
|
- * @param {MarketingActivityRecord} row - 营销活动记录
|
|
|
- */
|
|
|
- async handleViewApprovalRecords(row) {
|
|
|
- this.approvalRecordsDialog.visible = true
|
|
|
- this.approvalRecordsDialog.activityId = row.id
|
|
|
- this.approvalRecordsDialog.activityCode = row.activityCode
|
|
|
- this.approvalRecordsDialog.activityTitle = row.title
|
|
|
- this.approvalRecordsDialog.page.current = 1
|
|
|
- this.approvalRecordsDialog.page.size = 10
|
|
|
-
|
|
|
- await this.loadApprovalRecords()
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 加载审批记录数据
|
|
|
- */
|
|
|
- async loadApprovalRecords() {
|
|
|
- try {
|
|
|
- this.approvalRecordsDialog.loading = true
|
|
|
-
|
|
|
- const response = await getApprovalRecords(
|
|
|
- this.approvalRecordsDialog.page.current,
|
|
|
- this.approvalRecordsDialog.page.size,
|
|
|
- this.approvalRecordsDialog.activityId
|
|
|
- )
|
|
|
-
|
|
|
- if (response.data.success) {
|
|
|
- const { records, total, current, size } = response.data.data
|
|
|
- this.approvalRecordsDialog.data = records || []
|
|
|
- this.approvalRecordsDialog.page.total = total || 0
|
|
|
- this.approvalRecordsDialog.page.current = current || 1
|
|
|
- this.approvalRecordsDialog.page.size = size || 10
|
|
|
- } else {
|
|
|
- this.$message.error(response.data.msg || '获取审批记录失败')
|
|
|
- this.approvalRecordsDialog.data = []
|
|
|
- this.approvalRecordsDialog.page.total = 0
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.error('获取审批记录失败:', error)
|
|
|
- this.$message.error('获取审批记录失败,请稍后重试')
|
|
|
- this.approvalRecordsDialog.data = []
|
|
|
- this.approvalRecordsDialog.page.total = 0
|
|
|
- } finally {
|
|
|
- this.approvalRecordsDialog.loading = false
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 审批记录分页大小变化
|
|
|
- * @param {number} size - 新的分页大小
|
|
|
- */
|
|
|
- async handleApprovalRecordsSizeChange(size) {
|
|
|
- this.approvalRecordsDialog.page.size = size
|
|
|
- this.approvalRecordsDialog.page.current = 1
|
|
|
- await this.loadApprovalRecords()
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 审批记录当前页变化
|
|
|
- * @param {number} current - 新的当前页
|
|
|
- */
|
|
|
- async handleApprovalRecordsCurrentChange(current) {
|
|
|
- this.approvalRecordsDialog.page.current = current
|
|
|
- await this.loadApprovalRecords()
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 重置审批记录对话框
|
|
|
- */
|
|
|
- resetApprovalRecordsDialog() {
|
|
|
- this.approvalRecordsDialog.visible = false
|
|
|
- this.approvalRecordsDialog.loading = false
|
|
|
- this.approvalRecordsDialog.activityId = ''
|
|
|
- this.approvalRecordsDialog.activityCode = ''
|
|
|
- this.approvalRecordsDialog.activityTitle = ''
|
|
|
- this.approvalRecordsDialog.data = []
|
|
|
- this.approvalRecordsDialog.page = {
|
|
|
- current: 1,
|
|
|
- size: 10,
|
|
|
- total: 0
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取审批状态文本
|
|
|
- * @param {number} status - 审批状态
|
|
|
- * @returns {string} 状态文本
|
|
|
- */
|
|
|
- // getApprovalStatusText(status) {
|
|
|
- // const statusMap = {
|
|
|
- // 1: '待审批',
|
|
|
- // 2: '审批通过',
|
|
|
- // 3: '审批拒绝'
|
|
|
- // }
|
|
|
- // return statusMap[status] || '未知状态'
|
|
|
- // },
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取审批状态标签类型
|
|
|
- * @param {number} status - 审批状态
|
|
|
- * @returns {string} 标签类型
|
|
|
- */
|
|
|
- // getApprovalStatusType(status) {
|
|
|
- // const typeMap = {
|
|
|
- // 1: 'warning',
|
|
|
- // 2: 'success',
|
|
|
- // 3: 'danger'
|
|
|
- // }
|
|
|
- // return typeMap[status] || 'info'
|
|
|
- // },
|
|
|
-
|
|
|
- /**
|
|
|
- * 查看详情
|
|
|
- * @param {MarketingActivityRecord} row - 行数据
|
|
|
- * @returns {Promise<void>}
|
|
|
- */
|
|
|
- async handleView(row) {
|
|
|
- this.viewDialogVisible = true
|
|
|
- this.currentViewActivity = null
|
|
|
- this.attachmentsList = []
|
|
|
- this.detailLoading = true
|
|
|
-
|
|
|
- try {
|
|
|
- // 获取活动详情
|
|
|
- const detailRes = await getDetail(row.id)
|
|
|
- if (detailRes.data.success) {
|
|
|
- this.currentViewActivity = detailRes.data.data
|
|
|
-
|
|
|
- // 同时加载附件数据
|
|
|
- await this.loadActivityAttachments(row.id)
|
|
|
- } else {
|
|
|
- this.$message.error('获取活动详情失败')
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.error('获取活动详情失败:', error)
|
|
|
- this.$message.error('获取活动详情失败')
|
|
|
- } finally {
|
|
|
- this.detailLoading = false
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 处理审批操作
|
|
|
- * @param {MarketingActivityRecord} row - 行数据
|
|
|
- * @param {number} approvalStatus - 审批状态 2-通过 3-拒绝
|
|
|
- * @returns {void}
|
|
|
- */
|
|
|
- handleApprove(row, approvalStatus) {
|
|
|
- this.approvalForm = {
|
|
|
- id: row.id,
|
|
|
- title: row.title,
|
|
|
- customerName: row.customerName,
|
|
|
- approvalStatus,
|
|
|
- approvalRemark: ''
|
|
|
- }
|
|
|
-
|
|
|
- this.approvalDialog.title = approvalStatus === 2 ? '审批通过' : '审批拒绝'
|
|
|
- this.approvalDialog.visible = true
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 提交审批(智能审批记录管理)
|
|
|
- */
|
|
|
- async submitApproval() {
|
|
|
- try {
|
|
|
- // 表单验证
|
|
|
- const valid = await this.$refs.approvalForm.validate()
|
|
|
- if (!valid) {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- this.approvalDialog.loading = true
|
|
|
-
|
|
|
- // 构建审批参数
|
|
|
- const approvalParams = {
|
|
|
- id: this.approvalForm.id,
|
|
|
- approvalStatus: this.approvalForm.approvalStatus,
|
|
|
- approvalRemark: this.approvalForm.approvalRemark
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前用户信息
|
|
|
- const currentUserInfo = {
|
|
|
- userId: this.userInfo.user_id || this.userInfo.userId,
|
|
|
- userName: this.userInfo.user_name || this.userInfo.userName || this.userInfo.name
|
|
|
- }
|
|
|
-
|
|
|
- // 执行智能审批操作(包含智能审批记录管理)
|
|
|
- const response = await approveWithSmartRecord(approvalParams, currentUserInfo)
|
|
|
-
|
|
|
- if (response.data.success) {
|
|
|
- this.$message.success('审批操作成功')
|
|
|
- this.approvalDialog.visible = false
|
|
|
- this.resetApprovalDialog()
|
|
|
-
|
|
|
- // 刷新列表数据
|
|
|
- await this.onLoad(this.page)
|
|
|
- } else {
|
|
|
- this.$message.error(response.data.msg || '审批操作失败')
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.error('审批操作失败:', error)
|
|
|
- this.$message.error('审批操作失败,请稍后重试')
|
|
|
- } finally {
|
|
|
- this.approvalDialog.loading = false
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 重置审批对话框
|
|
|
- * @returns {void}
|
|
|
- */
|
|
|
- resetApprovalDialog() {
|
|
|
- this.approvalForm = {
|
|
|
- id: '',
|
|
|
- title: '',
|
|
|
- customerName: '',
|
|
|
- approvalStatus: 1,
|
|
|
- approvalRemark: ''
|
|
|
- }
|
|
|
-
|
|
|
- if (this.$refs.approvalForm) {
|
|
|
- this.$refs.approvalForm.resetFields()
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增、编辑、查看前的回调
|
|
|
- * @param {Function} done - 完成回调
|
|
|
- * @param {string} type - 操作类型
|
|
|
- * @returns {Promise<void>}
|
|
|
- */
|
|
|
- async beforeOpen(done, type) {
|
|
|
- if (['edit', 'view'].includes(type)) {
|
|
|
- try {
|
|
|
- const res = await getDetail(this.form.id)
|
|
|
- this.form = res.data.data
|
|
|
- } catch (error) {
|
|
|
- console.error('获取详情失败:', error)
|
|
|
- this.$message.error('获取详情失败')
|
|
|
- }
|
|
|
- }
|
|
|
- done()
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除操作
|
|
|
- * @param {MarketingActivityRecord} row - 行数据
|
|
|
- * @returns {Promise<void>}
|
|
|
- */
|
|
|
- async rowDel(row) {
|
|
|
- try {
|
|
|
- await this.$confirm('确定将选择数据删除?', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
- })
|
|
|
- // 注意:根据接口文档,没有删除接口,这里可能需要调用状态更新
|
|
|
- this.$message.warning('删除功能暂未开放')
|
|
|
- } catch (error) {
|
|
|
- console.error('删除失败:', error)
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 批量删除
|
|
|
- * @returns {Promise<void>}
|
|
|
- */
|
|
|
- async handleDelete() {
|
|
|
- if (this.selectionList.length === 0) {
|
|
|
- this.$message.warning('请选择至少一条数据')
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- await this.$confirm('确定将选择数据删除?', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
- })
|
|
|
- // 注意:根据接口文档,没有删除接口,这里可能需要调用状态更新
|
|
|
- this.$message.warning('删除功能暂未开放')
|
|
|
- } catch (error) {
|
|
|
- console.error('批量删除失败:', error)
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 更新操作
|
|
|
- * @param {MarketingActivityRecord} row - 行数据
|
|
|
- * @param {number} index - 行索引
|
|
|
- * @param {Function} done - 完成回调
|
|
|
- * @param {Function} loading - 加载状态回调
|
|
|
- * @returns {Promise<void>}
|
|
|
- */
|
|
|
- async rowUpdate(row, index, done, loading) {
|
|
|
- try {
|
|
|
- loading()
|
|
|
- await update(row)
|
|
|
- done()
|
|
|
- this.$message.success('操作成功')
|
|
|
- await this.onLoad(this.page)
|
|
|
- } catch (error) {
|
|
|
- loading()
|
|
|
- console.error('更新失败:', error)
|
|
|
- this.$message.error('操作失败')
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增操作
|
|
|
- * @param {MarketingActivityRecord} row - 行数据
|
|
|
- * @param {Function} done - 完成回调
|
|
|
- * @param {Function} loading - 加载状态回调
|
|
|
- * @returns {Promise<void>}
|
|
|
- */
|
|
|
- async rowSave(row, done, loading) {
|
|
|
- // 根据接口文档,没有新增接口,这里暂不实现
|
|
|
- loading()
|
|
|
- this.$message.warning('新增功能暂未开放')
|
|
|
- done()
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 搜索回调
|
|
|
- * @param {MarketingActivityQueryParams} params - 搜索参数
|
|
|
- * @param {Function} done - 完成回调
|
|
|
- * @returns {void}
|
|
|
- */
|
|
|
- searchChange(params, done) {
|
|
|
- this.query = params
|
|
|
- this.page.currentPage = 1
|
|
|
- this.onLoad(this.page)
|
|
|
- done()
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 搜索重置回调
|
|
|
- * @returns {void}
|
|
|
- */
|
|
|
- searchReset() {
|
|
|
- this.query = {}
|
|
|
- this.page.currentPage = 1
|
|
|
- this.onLoad(this.page)
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 选择改变回调
|
|
|
- * @param {MarketingActivityRecord[]} list - 选中的数据列表
|
|
|
- * @returns {void}
|
|
|
- */
|
|
|
- selectionChange(list) {
|
|
|
- this.selectionList = list
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 清空选择回调
|
|
|
- * @returns {void}
|
|
|
- */
|
|
|
- selectionClear() {
|
|
|
- this.selectionList = []
|
|
|
- this.$refs.crud.toggleSelection()
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 当前页改变回调
|
|
|
- * @param {number} currentPage - 当前页码
|
|
|
- * @returns {void}
|
|
|
- */
|
|
|
- currentChange(currentPage) {
|
|
|
- this.page.currentPage = currentPage
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 页大小改变回调
|
|
|
- * @param {number} pageSize - 页大小
|
|
|
- * @returns {void}
|
|
|
- */
|
|
|
- sizeChange(pageSize) {
|
|
|
- this.page.pageSize = pageSize
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 刷新回调
|
|
|
- * @returns {void}
|
|
|
- */
|
|
|
- refreshChange() {
|
|
|
- this.onLoad(this.page)
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 数据加载
|
|
|
- * @param {Object} page - 分页参数
|
|
|
- * @param {Object} [params] - 查询参数
|
|
|
- * @returns {Promise<void>}
|
|
|
- */
|
|
|
- async onLoad(page, params) {
|
|
|
- this.loading = true
|
|
|
- try {
|
|
|
- const response = await getList(
|
|
|
- page.currentPage || 1,
|
|
|
- page.pageSize || 10,
|
|
|
- Object.assign(params || {}, this.query)
|
|
|
- )
|
|
|
-
|
|
|
- if (response.data && response.data.success) {
|
|
|
- const data = response.data.data
|
|
|
- this.data = data.records || []
|
|
|
- this.page.total = data.total || 0
|
|
|
- } else {
|
|
|
- this.data = []
|
|
|
- this.page.total = 0
|
|
|
- this.$message.warning('获取数据失败')
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- this.data = []
|
|
|
- this.page.total = 0
|
|
|
- console.error('加载数据失败:', error)
|
|
|
- this.$message.error('加载数据失败,请稍后重试')
|
|
|
- } finally {
|
|
|
- this.loading = false
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 手动保存审批记录(用于特殊场景)
|
|
|
- * @param {string|number} activityId - 活动ID
|
|
|
- * @param {Object} approvalData - 审批数据
|
|
|
- */
|
|
|
- async handleSaveApprovalRecord(activityId, approvalData) {
|
|
|
- try {
|
|
|
- // 获取当前用户信息
|
|
|
- const currentUserInfo = {
|
|
|
- userId: this.userInfo.user_id || this.userInfo.userId,
|
|
|
- userName: this.userInfo.user_name || this.userInfo.userName || this.userInfo.name
|
|
|
- }
|
|
|
-
|
|
|
- const response = await saveApprovalRecord(
|
|
|
- activityId,
|
|
|
- currentUserInfo.userId,
|
|
|
- approvalData
|
|
|
- )
|
|
|
-
|
|
|
- if (response.data.success) {
|
|
|
- this.$message.success('审批记录保存成功')
|
|
|
- // 如果审批记录弹窗是打开的,刷新审批记录列表
|
|
|
- if (this.approvalRecordsDialog.visible) {
|
|
|
- await this.loadApprovalRecords()
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.$message.error(response.data.msg || '审批记录保存失败')
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.error('保存审批记录失败:', error)
|
|
|
- this.$message.error('保存审批记录失败,请稍后重试')
|
|
|
- }
|
|
|
- },
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 组件挂载后初始化
|
|
|
- * @returns {void}
|
|
|
- */
|
|
|
- mounted() {
|
|
|
- this.onLoad(this.page)
|
|
|
- }
|
|
|
-}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped >
|