| | |
| | | :value="item.value" |
| | | :key="item.id" |
| | | > |
| | | {{ item.value }} |
| | | {{ item.label }} |
| | | </Option> |
| | | </Select> |
| | | </FormItem> |
| | |
| | | <template slot-scope="{ row }" slot="url"> |
| | | <div class="media-container"> |
| | | <!-- 图片类型 --> |
| | | <template v-if="row.coverType === '图片'"> |
| | | <template v-if="row.coverType === 'image'"> |
| | | <img |
| | | :src="row.url" |
| | | alt="活动封面" |
| | |
| | | > |
| | | </template> |
| | | <!-- 视频类型 --> |
| | | <template v-else-if="row.coverType === '视频'"> |
| | | <template v-else-if="row.coverType === 'video'"> |
| | | <video |
| | | :src="row.url" |
| | | class="video-player" |
| | |
| | | <Button |
| | | type="primary" |
| | | size="small" |
| | | @click="changeStatus(row, row.status === '已发布' ? '下架' : '发布')" |
| | | @click="changeStatus(row, row.publish ? '下架' : '发布')" |
| | | :loading="row.statusLoading" |
| | | > |
| | | {{ row.status === '已发布' ? '下架' : '发布' }} |
| | | {{ row.publish ? '下架' : '发布' }} |
| | | </Button> |
| | | <Button |
| | | type="info" |
| | |
| | | </FormItem> |
| | | </Col> |
| | | <Col span="12"> |
| | | <FormItem label="活动类型" prop="activityType"> |
| | | <FormItem label="活动类型" prop="activityType" :label-width="100"> |
| | | <Select |
| | | v-model="activityFrom.activityType" |
| | | placeholder="请选择活动类型" |
| | |
| | | :value="item.value" |
| | | :key="item.id" |
| | | > |
| | | {{ item.value }} |
| | | {{ item.label }} |
| | | </Option> |
| | | </Select> |
| | | </FormItem> |
| | |
| | | ></DatePicker> |
| | | </FormItem> |
| | | </Col> |
| | | <Col span="24"> |
| | | <FormItem label="封面类型" prop="coverType"> |
| | | <Col span="12"> |
| | | <FormItem label="封面类型" prop="coverType" :labelWidth="100"> |
| | | <Select |
| | | v-model="coverType" |
| | | placeholder="请选择封面类型" |
| | | clearable |
| | | @on-change="handleCoverTypeChange" |
| | | > |
| | | <Option |
| | |
| | | accept="image/*,video/*" |
| | | > |
| | | <Button icon="ios-cloud-upload-outline">上传封面文件</Button> |
| | | |
| | | <div class="upload-tip">支持图片或视频文件,最大20MB</div> |
| | | </Upload> |
| | | <div v-if="file" class="upload-file-info">c |
| | | <div v-if="file" class="upload-file-info"> |
| | | 已选文件: {{ file.name }} |
| | | <Button type="text" @click="handleRemove">删除</Button> |
| | | </div> |
| | | </FormItem> |
| | | </Col> |
| | | <!-- 这两个表单项在同一Row内,会显示在同一行 --> |
| | | <Col span="12"> |
| | | <FormItem label="人数限制" prop="limitUserNum"> |
| | | <InputNumber |
| | |
| | | </FormItem> |
| | | </Col> |
| | | <Col span="24"> |
| | | <Form :model="videoDownForm" :rules="videoDownRule" ref="videoDownForm"> |
| | | <!-- <FormItem label="下架原因:" :labelWidth="100" prop="activityContent">--> |
| | | <!-- <editor ref="editor" @input="getReason" />--> |
| | | <!-- </FormItem>--> |
| | | </Form> |
| | | <FormItem label="活动内容" prop="activityContent"> |
| | | <Input |
| | | v-model="activityFrom.activityContent" |
| | | type="textarea" |
| | | :rows="4" |
| | | placeholder="请输入活动详细内容" |
| | | /> |
| | | <FormItem label="活动内容:" prop="activityContent"> |
| | | <editor ref="editor" @input="getReason" /> |
| | | </FormItem> |
| | | </Col> |
| | | </Row> |
| | |
| | | components: {Editor}, |
| | | data() { |
| | | return { |
| | | videoDownForm :{ |
| | | id: '', |
| | | reason: '' |
| | | }, |
| | | videoDownRule: { |
| | | reason: [ |
| | | { |
| | | require: true, |
| | | message: '请输入活动内容', |
| | | trigger: 'blur', |
| | | validator: (rule, value, callback) => { |
| | | if (value === null || value === '') { |
| | | callback(new Error('请输入活动内容')); |
| | | } else { |
| | | callback(); |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | }, |
| | | |
| | | loading: false, |
| | | membersLoading: false, |
| | | submitLoading: false, |
| | |
| | | |
| | | // 活动类型选项 |
| | | typeSelect: [ |
| | | { id: 1, value: '线上' }, |
| | | { id: 2, value: '线下' } |
| | | { id: 1, value: 'online',label:'线上' }, |
| | | { id: 2, value: 'offline',label:'线下' } |
| | | ], |
| | | |
| | | // 封面类型选项 |
| | |
| | | endTime: '', |
| | | recommend: false, |
| | | limitUserNum: 0, |
| | | activityLocation: '' |
| | | activityLocation: '', |
| | | }, |
| | | |
| | | // 表单验证规则 |
| | |
| | | ], |
| | | cover: [ |
| | | { required: true, message: '请输入封面内容', trigger: 'blur' } |
| | | ], |
| | | coverType: [ |
| | | { required: true, message: '请选择封面类型', trigger: 'blur' } |
| | | ], |
| | | limitUserNum: [ |
| | | { required: true, type: 'number', message: '请输入人数限制', trigger: 'blur' }, |
| | |
| | | title: '活动类型', |
| | | key: 'activityType', |
| | | width: 100, |
| | | align: 'center' |
| | | align: 'center', |
| | | render: (h, params) => { |
| | | return h('Tag', { |
| | | }, params.row.activityType === 'online' ? '线上' : '线下') |
| | | } |
| | | }, |
| | | { |
| | | title: '推荐', |
| | |
| | | } |
| | | }, |
| | | { |
| | | title: '状态', |
| | | key: 'status', |
| | | title: '发布', |
| | | key: 'publish', |
| | | width: 100, |
| | | align: 'center', |
| | | render: (h, params) => { |
| | | return h('Tag', { |
| | | props: { |
| | | color: params.row.status === '已发布' ? 'blue' : 'orange' |
| | | color: params.row.publish ? 'green' : 'default' |
| | | } |
| | | }, params.row.status) |
| | | }, params.row.publish ? '已发布' : '未发布') |
| | | } |
| | | }, |
| | | { |
| | | title: '报名时间段', |
| | | key: 'reportTimeRange', |
| | | width: 300, |
| | | title: '状态', |
| | | key: 'status', |
| | | width: 100, |
| | | align: 'center', |
| | | render: (h, params) => { |
| | | return h('div', [ |
| | | h('div', `开始: ${this.formatDate(params.row.reportStartTime)}`), |
| | | h('div', `结束: ${this.formatDate(params.row.reportEndTime)}`) |
| | | ]) |
| | | const status = params.row.status; |
| | | const statusMap = { |
| | | 'noStart': { text: '未开始', color: 'default' }, |
| | | 'report': { text: '报名中', color: 'green' }, |
| | | 'inProgress':{ text:'进行中',color:'cyan'}, |
| | | 'end': { text: '已结束', color: 'red' } |
| | | }; |
| | | const currentStatus = statusMap[status] || { text: status, color: 'default' }; |
| | | return h('Tag', { |
| | | props: { |
| | | color: currentStatus.color |
| | | } |
| | | }, currentStatus.text); |
| | | } |
| | | }, |
| | | { |
| | |
| | | title: '封面类型', |
| | | key: 'coverType', |
| | | width: 100, |
| | | align: 'center' |
| | | align: 'center', |
| | | render: (h, params) => { |
| | | const typeMap = { |
| | | text: '文本', |
| | | video: '视频', |
| | | image: '图片' |
| | | }; |
| | | const text = typeMap[params.row.coverType] || params.row.coverType; |
| | | return h('span', text); |
| | | } |
| | | }, |
| | | { |
| | | title: '人数限制', |
| | |
| | | methods: { |
| | | // 获取富文本编辑器的内容 |
| | | getReason(content) { |
| | | this.videoDownForm.reason = content |
| | | console.log(content) |
| | | this.activityFrom.activityContent = content |
| | | }, |
| | | // 初始化数据 |
| | | init() { |
| | |
| | | statusLoading: false |
| | | })) |
| | | this.total = res.total |
| | | } else { |
| | | this.$Message.error(res.msg || '获取活动列表失败') |
| | | } |
| | | }).catch(() => { |
| | | this.loading = false |
| | |
| | | openAdd() { |
| | | this.modelTitle = '新增活动' |
| | | this.modelShow = true |
| | | this.coverType = '' |
| | | this.coverType = '输入文字封面' |
| | | this.file = null |
| | | this.$refs.form.resetFields() |
| | | this.activityFrom.id = '' |
| | |
| | | this.modelShow = true |
| | | this.$nextTick(() => { |
| | | this.$refs.form.resetFields() |
| | | |
| | | // 填充表单数据 |
| | | this.activityFrom = { |
| | | id: row.id, |
| | |
| | | limitUserNum: row.limitUserNum, |
| | | activityLocation: row.activityLocation |
| | | } |
| | | |
| | | this.$refs.editor.setContent(this.activityFrom.activityLocation) |
| | | // 设置封面类型 |
| | | this.coverType = row.coverType === '文字' ? '输入文字封面' : '选择文件封面' |
| | | this.coverType = row.coverType === 'text' ? '输入文字封面' : '选择文件封面' |
| | | }) |
| | | }, |
| | | |
| | |
| | | this.modelShow = false |
| | | this.file = null |
| | | this.submitLoading = false |
| | | this.handleRemove(); |
| | | this.$refs.form.resetFields() |
| | | }, |
| | | |
| | | // 保存或更新活动 |
| | | saveOrUpdate() { |
| | | // 设置封面类型 |
| | | this.activityFrom.coverType = this.coverType === '输入文字封面' ? '文字' : |
| | | this.file ? this.getFileCategory(this.file.type) : |
| | | this.activityFrom.coverType |
| | | this.$refs.form.validate(valid => { |
| | | if (valid) { |
| | | this.submitLoading = true |
| | |
| | | this.activityFrom.endTime = this.formatDate(this.activityFrom.time[1], 'YYYY-MM-DD HH:mm:ss') |
| | | } |
| | | |
| | | // 设置封面类型 |
| | | this.activityFrom.coverType = this.coverType === '输入文字封面' ? '文字' : |
| | | this.file ? this.getFileCategory(this.file.type) : |
| | | this.activityFrom.coverType |
| | | |
| | | const api = this.activityFrom.id ? editActivity : addActivity |
| | | api(this.activityFrom).then(res => { |
| | | this.submitLoading = false |
| | |
| | | this.$Message.success(res.msg) |
| | | this.modelClose() |
| | | this.getActivityList() |
| | | } else { |
| | | this.$Message.error(res.msg || '操作失败') |
| | | } |
| | | }).catch(() => { |
| | | this.submitLoading = false |
| | |
| | | if (res.code === 200) { |
| | | this.$Message.success(res.msg) |
| | | this.getActivityList() |
| | | } else { |
| | | this.$Message.error(res.msg || '删除失败') |
| | | } |
| | | }) |
| | | } |
| | |
| | | if (res.code === 200) { |
| | | this.$Message.success(res.msg) |
| | | row.recommend = recommend |
| | | } else { |
| | | this.$Message.error(res.msg || '操作失败') |
| | | } |
| | | }).catch(() => { |
| | | row.recommendLoading = false |
| | |
| | | // 改变活动状态 |
| | | changeStatus(row, action) { |
| | | row.statusLoading = true |
| | | const status = action === '发布' ? '已发布' : '已下架' |
| | | const publish = action === '发布' |
| | | |
| | | activityChangeStatus({ |
| | | id: row.id, |
| | | status: status |
| | | publish: publish |
| | | }).then(res => { |
| | | row.statusLoading = false |
| | | if (res.code === 200) { |
| | | this.$Message.success(res.msg) |
| | | row.status = status |
| | | } else { |
| | | this.$Message.error(res.msg || '操作失败') |
| | | row.publish = publish |
| | | } |
| | | }).catch(() => { |
| | | row.statusLoading = false |
| | |
| | | if (res.code === 200) { |
| | | this.membersList = res.data |
| | | this.memberTotal = res.total |
| | | } else { |
| | | this.$Message.error(res.msg || '获取报名人员失败') |
| | | } |
| | | }).catch(() => { |
| | | this.membersLoading = false |
| | |
| | | if (res.code === 200) { |
| | | this.activityFrom.cover = res.data.fileKey |
| | | this.$Message.success('上传成功') |
| | | } else { |
| | | this.$Message.error(res.msg || '上传失败') |
| | | } |
| | | }).catch(() => { |
| | | this.submitLoading = false |
| | |
| | | |
| | | // 删除文件 |
| | | handleRemove() { |
| | | //点击关闭窗口时确保文件已被清除 |
| | | if(this.file === null){ |
| | | return; |
| | | } |
| | | if (!this.activityFrom.cover) { |
| | | this.file = null |
| | | return |
| | | } |
| | | |
| | | this.$Modal.confirm({ |
| | | title: '确认删除', |
| | | content: '确定要删除已上传的文件吗?', |
| | | onOk: () => { |
| | | delByKey(this.activityFrom.cover).then(res => { |
| | | if (res.code === 200) { |
| | | this.$Message.success(res.msg) |
| | | this.file = null |
| | | this.activityFrom.cover = '' |
| | | } else { |
| | | this.$Message.error(res.msg || '删除失败') |
| | | } |
| | | }) |
| | | delByKey(this.activityFrom.cover).then(res => { |
| | | if (res.code === 200) { |
| | | this.file = null |
| | | this.activityFrom.cover = '' |
| | | } |
| | | }) |
| | | }, |
| | |
| | | // 获取文件分类 |
| | | getFileCategory(mimeType) { |
| | | const typeMap = { |
| | | 'image': '图片', |
| | | 'video': '视频', |
| | | 'audio': '音频', |
| | | 'application': '文档' |
| | | 'image': 'image', |
| | | 'video': 'video', |
| | | 'audio': 'audio', |
| | | 'application': 'application' |
| | | } |
| | | |
| | | const typePrefix = mimeType.split('/')[0] |
| | | return typeMap[typePrefix] || '未知' |
| | | return typeMap[typePrefix] || 'unknown' |
| | | }, |
| | | |
| | | // 格式化日期 |