Commit 088af47b authored by Davve's avatar Davve

完善推送

parent 4e806b9f
......@@ -42,9 +42,22 @@ class PushUpdateOrCreateView(APIView):
'creator_id': creator_id
}
try:
self.rpc['venus/sun/push/edit'](id=id, data=data).unwrap()
rep = self.rpc['venus/sun/push/edit'](id=id, data=data).unwrap()
except Exception as e:
raise e
return {
"message": '更新成功'
"message": '更新成功',
"id": rep['id']
}
class EffectPushTaskView(APIView):
def get(self, request):
push_task_id = request.GET.get('id')
try:
self.rpc['venus/sun/push/effect_push_task'](id=push_task_id).unwrap()
except Exception as e:
raise e
return {
'message': '操作成功'
}
\ No newline at end of file
......@@ -60,6 +60,7 @@ urlpatterns = [
url(r'push/list$', PushListView.as_view()),
url(r'push/create', PushUpdateOrCreateView.as_view()),
url(r'push/detail', PushUpdateOrCreateView.as_view()),
url(r'push/effect_push', EffectPushTaskView.as_view()),
# pick相关
url(r'pick/list$', PickListView.as_view()),
......
......@@ -32,3 +32,11 @@ export function fetchPushDetail(id) {
params: { id }
})
}
export function EffectPushTask(id) {
return request({
url: '/api/push/effect_push',
method: 'get',
params: { id }
})
}
......@@ -2,7 +2,7 @@
<div :style="{height:height+'px',zIndex:zIndex}">
<div :class="className" :style="{top:stickyTop+'px',zIndex:zIndex,position:position,width:width,height:height+'px'}">
<slot>
<div>sticky</div>
<div></div>
</slot>
</div>
</div>
......
......@@ -21,7 +21,7 @@
<!--</div>-->
<div class="image-preview">
<div v-show="imageUrl.length>1" class="image-preview-wrapper">
<img :src="imageUrl">
<img :src="imageUrl" :disabled="true">
<div class="image-preview-action">
<i class="el-icon-delete" @click="rmImage"/>
</div>
......
......@@ -39,6 +39,7 @@
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page="listQuery.page" :limit="listQuery.limit" style="margin-left: 150px;" @pagination="getList" />
......
......@@ -3,16 +3,16 @@
<el-form ref="postForm" :model="postForm" :rules="rules" class="form-container">
<sticky :class-name="'sub-navbar '+postForm.status">
<el-button v-loading="loading" style="margin-left: 10px;" type="success" @click="submitForm">保存
</el-button>
<el-button v-loading="loading" style="margin-left: 10px;" type="success" @click="effectPush" v-if="isEdit && !is_effect">生效</el-button>
<el-button v-loading="loading" style="margin-left: 10px;" type="success" @click="submitForm" v-if="!is_effect">保存</el-button>
</sticky>
<div class="createPost-main-container">
<el-row>
<Warning v-if="isEdit"/>
<el-col :span="24">
<el-form-item style="margin-bottom: 40px;" prop="title">
<MDinput v-model="postForm.title" :maxlength="100" name="title" required>
<MDinput v-model="postForm.title" :maxlength="100" name="title" required >
推送标题
</MDinput>
</el-form-item>
......@@ -67,14 +67,14 @@
</el-row>
<el-form-item style="margin-bottom: 40px;" label-width="75px" label="推送内容:" prop="content">
<el-input :rows="1" v-model="postForm.content" type="textarea" class="article-textarea" autosize placeholder="请输入内容"/>
<el-input :rows="1" v-model="postForm.content" type="textarea" class="article-textarea" autosize placeholder="请输入内容" />
<span v-show="contentShortLength" class="word-counter">{{ contentShortLength }}</span>
</el-form-item>
<div style="margin-bottom: 20px;">
<el-form-item style="margin-bottom: 40px;" label-width="75px" label="推送头像:" prop="icon">
<el-form-item style="margin-bottom: 40px;" label-width="75px" label="推送头像:" prop="icon" :disabled="is_effect">
<span v-model="uploadType"></span>
<Upload v-model="postForm.icon" :uploadType="uploadType"/>
<Upload v-model="postForm.icon" :uploadType="uploadType" />
</el-form-item>
</div>
</div>
......@@ -87,8 +87,9 @@
import Upload from '@/components/Upload/singleImage3'
import MDinput from '@/components/MDinput'
import Sticky from '@/components/Sticky' // 粘性header组件
import Warning from './Warning'
import { validateURL } from '@/utils/validate'
import { fetchPushDetail, CreatePush } from '@/api/push'
import { fetchPushDetail, CreatePush, EffectPushTask } from '@/api/push'
const defaultForm = {
status: 'draft',
......@@ -97,12 +98,12 @@ const defaultForm = {
icon: '',
push_time: '',
url: '',
creator_name: ''
creator_name: '',
}
export default {
name: 'PushDetail',
components: { MDinput, Upload, Sticky},
components: { MDinput, Upload, Sticky, Warning},
props: {
isEdit: {
type: Boolean,
......@@ -138,7 +139,8 @@ export default {
push_time: [{ validator: validateRequire, trigger: 'blur'}],
},
tempRoute: {},
uploadType: 1 // 图片类型
uploadType: 1, // 图片类型
is_effect: false,
}
},
computed: {
......@@ -160,6 +162,7 @@ export default {
fetchData(id) {
fetchPushDetail(id).then(response => {
this.postForm = response.data.data.data
this.is_effect = Boolean(response.data.data.data.is_effect)
}).catch(err => {
console.log(err)
})
......@@ -197,6 +200,20 @@ export default {
}
})
},
effectPush() {
this.is_effect = Boolean(1);
const id = this.$route.params && this.$route.params.id
EffectPushTask(id).then(response => {
console.log(response.data.data.message)
this.$message({
message: response.data.data.message,
type: 'success'
})
this.$router.go(0)
}).catch(err => {
})
}
}
}
</script>
......
<template>
<p class="warn-content" style="text-align: center">
点击生效以后,页面所有内容不可进行编辑,请谨慎操作!!
</p>
</template>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment