Commit 9ce05c29 authored by Davve's avatar Davve

批量更新发帖时间

parent 7c2f2970
......@@ -23,7 +23,7 @@ class AccountList(APIView):
def post(self, request):
ids = json.loads(request.POST.get('ids', '[]'))
updates = json.loads(request.POST.get('update', '{}'))
updates = json.loads(request.POST.get('updates', '{}'))
try:
self.rpc['venus/sun/account/batch/update'](updates=updates, ids=ids).unwrap()
except Exception as e:
......
......@@ -62,7 +62,7 @@ class StarListView(APIView):
def post(self, request):
ids = json.loads(request.POST.get('ids', '[]'))
updates = json.loads(request.POST.get('update', '{}'))
updates = json.loads(request.POST.get('updates', '{}'))
try:
self.rpc['mercury/face/batch/update'](ids=ids, updates=updates).unwrap()
......
......@@ -23,7 +23,7 @@ class PickListView(APIView):
def post(self, request):
ids = json.loads(request.POST.get('ids', '[]'))
updates = json.loads(request.POST.get('update', '{}'))
updates = json.loads(request.POST.get('updates', '{}'))
try:
self.rpc['venus/sun/pick/batch/update'](updates=updates, ids=ids).unwrap()
except Exception as e:
......
......@@ -22,7 +22,7 @@ class CelebrityListView(APIView):
def post(self, request):
ids = json.loads(request.POST.get('ids', '[]'))
updates = json.loads(request.POST.get('update', '{}'))
updates = json.loads(request.POST.get('updates', '{}'))
try:
self.rpc['venus/sun/celebrity/batch/update'](updates=updates, ids=ids).unwrap()
......
......@@ -22,7 +22,7 @@ class TagListView(APIView):
def post(self, request):
ids = json.loads(request.POST.get('ids', '[]'))
updates = json.loads(request.POST.get('update', '{}'))
updates = json.loads(request.POST.get('updates', '{}'))
try:
self.rpc['venus/sun/tag/batch/update'](updates=updates, ids=ids).unwrap()
except Exception as e:
......
......@@ -118,10 +118,11 @@ class ReplyCreate(APIView):
class TopicListBatchUpdate(APIView):
def post(self, request):
ids = json.loads(request.POST.get('ids', '[]'))
updates = json.loads(request.POST.get('update', '{}'))
updates = json.loads(request.POST.get('updates', '{}'))
extra = json.loads(request.POST.get('extra', '{}'))
try:
self.rpc['venus/sun/topic/batch/update'](updates=updates, ids=ids).unwrap()
self.rpc['venus/sun/topic/batch/update'](updates=updates, ids=ids, extra=extra).unwrap()
except Exception as e:
error_logger.error(u'批量更新帖子失败%s', e)
raise
......
......@@ -2,8 +2,8 @@
<div>
<input ref="excel-upload-input" class="excel-upload-input" type="file" accept=".xlsx, .xls" @change="handleClick">
<div class="drop" @drop="handleDrop" @dragover="handleDragover" @dragenter="handleDragover">
Drop excel file here or
<el-button :loading="loading" style="margin-left:16px;" size="mini" type="primary" @click="handleUpload">Browse</el-button>
文件拖至此处
<el-button :loading="loading" style="margin-left:16px;" size="mini" type="primary" @click="handleUpload">点我上传</el-button>
</div>
</div>
</template>
......
......@@ -23,6 +23,7 @@
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleCreate">创建</el-button>
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleOfflineOrOnline('offline')">下线</el-button>
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleOfflineOrOnline('online')">上线</el-button>
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="batchUpdate" >批量上线</el-button>
</div>
<el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%" ref="multipleTable" @selection-change="handleSelectionChange" @sort-change="sortChange">
<el-table-column type="selection" align="center"></el-table-column>
......@@ -87,6 +88,27 @@
<pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :pageSizes="pageSize" :limit.sync="listQuery.limit" style="margin-left: 150px;" @pagination="getList" />
<el-dialog :visible.sync="dialogFormVisible">
<label>发帖时间:&nbsp;&nbsp;</label>
<el-date-picker
v-model="select_start_time "
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="起始时间"
style="width: 230px"
/>&nbsp;&nbsp;----&nbsp;&nbsp;
<el-date-picker
v-model="select_end_time "
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="结束时间"
style="width: 230px"
/>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false">取消</el-button>
<el-button type="primary" @click="updateData()" :disabled="this.is_click">确认</el-button>
</div>
</el-dialog>
</div>
</template>
......@@ -158,6 +180,11 @@ export default {
{'key': 4, 'display_name': '星级四'},
{'key': 5, 'display_name': '星级五'},
],
dialogFormVisible: false,
is_click: false,
dialogStatus: '',
select_start_time: '',
select_end_time: ''
}
},
created() {
......@@ -228,6 +255,44 @@ export default {
this.listQuery.sort.push(...['-id'])
}
this.handleFilter()
},
batchUpdate(){
this.dialogFormVisible = true;
this.reset()
},
updateData(){
const length = this.multipleSelection.length;
var ids = []
var updates = {}
var extra_info = {}
this.del_list = this.del_list.concat(this.multipleSelection);
for (let i = 0; i < length; i++) {
this.multipleSelection[i].is_online = 1
updates['is_online'] = 1
ids.push(this.multipleSelection[i].id)
}
if (!length){
this.$message.error('请先勾选帖子ID,再进行后续操作.....')
}
if (!this.select_start_time || !this.select_end_time){
this.$message.error('起始时间或者结束时间不能为空.....')
}
if (this.select_start_time > this.select_end_time){
this.$message.error('起始时间不能小于结束时间.....')
}
extra_info['start_time'] = this.select_start_time
extra_info['end_time'] = this.select_end_time
OffLineOrOnLine({updates: JSON.stringify(updates), ids: JSON.stringify(ids), extra: JSON.stringify(extra_info)}).then(response => {
this.multipleSelection = [];
this.$message.success(response.data.data.message);
this.$router.go(0)
this.dialogFormVisible = false;
})
},
reset(){
this.select_start_time = ''
this.select_end_time = ''
}
}
}
......
......@@ -28,6 +28,9 @@
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit"
@click="handleOfflineOrOnline('online')">上线
</el-button>
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit"
@click="handleOfflineOrOnline('online')">上线
</el-button>
</div>
<el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%"
ref="multipleTable" @selection-change="handleSelectionChange">
......@@ -90,7 +93,8 @@
<el-table-column align="center" label="是否推荐">
<template slot-scope="scope">
<el-tag :type="scope.row.is_recommend | isOnlineFilter">{{ scope.row.is_recommend==true ? '是' : '否' }}</el-tag>
<el-tag :type="scope.row.is_recommend | isOnlineFilter">{{ scope.row.is_recommend==true ? '是' : '否' }}
</el-tag>
</template>
</el-table-column>
is_recommend
......@@ -107,7 +111,7 @@
import {fetchList, OffLineOrOnLine} from '@/api/user'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
import waves from '@/directive/waves'
import { mapGetters } from 'vuex'
import {mapGetters} from 'vuex'
export default {
name: 'UserList',
......@@ -221,8 +225,8 @@
this.multipleSelection = [];
this.$message.success(response.data.data.message);
setTimeout(() => {
this.$router.go(0)
}, 1500)
this.$router.go(0)
}, 1500)
})
},
handleFilter() {
......
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