mirror of
https://github.com/ngfchl/ptools
synced 2023-07-10 13:41:22 +08:00
任务状态调整为前端过滤
This commit is contained in:
@@ -141,7 +141,7 @@ def get_downloading(request):
|
||||
'day,', '天'
|
||||
).replace(':', '小时', 1).replace(':', '分', 1).split('.')[0] + '秒'
|
||||
# 大小与速度处理
|
||||
torrent['state'] = TorrentBaseInfo.download_state.get(torrent.get('state'))
|
||||
# torrent['state'] = TorrentBaseInfo.download_state.get(torrent.get('state'))
|
||||
torrent['ratio'] = '%.4f' % torrent.get('ratio') if torrent['ratio'] >= 0.0001 else 0
|
||||
torrent['progress'] = '%.4f' % torrent.get('progress') if float(torrent['progress']) < 1 else 1
|
||||
torrent['uploaded'] = '' if torrent['uploaded'] == 0 else torrent['uploaded']
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
</div>
|
||||
<hr/>
|
||||
<u-table
|
||||
ref="plTable"
|
||||
ref="plxTable"
|
||||
row-height="55"
|
||||
use-virtual
|
||||
showBodyOverflow="title"
|
||||
@@ -72,7 +72,10 @@
|
||||
size="mini"
|
||||
border
|
||||
stripe
|
||||
beautify-table
|
||||
highlight-current-row
|
||||
{# pagination-show="true"#}
|
||||
{# total="true"#}
|
||||
{# show-summary#}
|
||||
style="width: 100%">
|
||||
<u-table-column
|
||||
@@ -148,7 +151,13 @@
|
||||
{# label="做种时间"></u-table-column>#}
|
||||
<u-table-column prop="state"
|
||||
sortable
|
||||
width="75"
|
||||
width="85"
|
||||
:formatter="handleState"
|
||||
column-key="state"
|
||||
:filter-method="filterStateMethod"
|
||||
{# :filters="[{text: '做种中', value: 'stalledUP'}, {text: '上传中', value: 'uploading'}, {text: '下载中', value: 'downloading'}]"#}
|
||||
:filters="stateFilters"
|
||||
:filter-multiple="false"
|
||||
label="状态"></u-table-column>
|
||||
<u-table-column prop="last_activity"
|
||||
sortable
|
||||
@@ -233,6 +242,28 @@
|
||||
|
||||
<script src="{% static 'admin/simpleui-x/js/axios.min.js' %}"></script>
|
||||
<script>
|
||||
const download_state = {
|
||||
'allocating': '分配',
|
||||
'checkingDL': '校验中',
|
||||
'checkingResumeData': '校验恢复数据',
|
||||
'checkingUP': '',
|
||||
'downloading': '下载中',
|
||||
'error': '错误',
|
||||
'forcedDL': '强制下载',
|
||||
'forcedMetaDL': '强制下载元数据',
|
||||
'forcedUP': '强制上传',
|
||||
'metaDL': '下载元数据',
|
||||
'missingFiles': '文件丢失',
|
||||
'moving': '移动中',
|
||||
'pausedDL': '暂停下载',
|
||||
'pausedUP': '完成',
|
||||
'queuedDL': '下载队列中',
|
||||
'queuedUP': '下载队列中',
|
||||
'stalledDL': '等待下载',
|
||||
'stalledUP': '做种',
|
||||
'unknown': '未知',
|
||||
'uploading': '上传中',
|
||||
}
|
||||
const vm = new Vue({
|
||||
// 配置选项(option)
|
||||
// element: 指定用vue来管理页面中的哪个标签区域
|
||||
@@ -273,9 +304,19 @@
|
||||
beforeMount() {
|
||||
},
|
||||
mounted() {
|
||||
|
||||
// 任务状态过滤器数据
|
||||
let data = []
|
||||
for (let x in download_state) {
|
||||
{#console.log(download_state[x])#}
|
||||
data.push({
|
||||
'text': download_state[x],
|
||||
'value': x
|
||||
})
|
||||
}
|
||||
this.stateFilters = data
|
||||
console.log(this.stateFilters)
|
||||
this.get_downloader()
|
||||
console.log("下载器:", this.downloaders)
|
||||
console.log("下载器:", this.downloaders.length)
|
||||
|
||||
},
|
||||
// 清除定时器,不然页面会卡死
|
||||
@@ -351,8 +392,13 @@
|
||||
// 执行格式化文件大小
|
||||
handleSize(row, column, cellValue, index) {
|
||||
return this.renderSize(cellValue)
|
||||
}
|
||||
,
|
||||
},
|
||||
// 执行格式化文件大小
|
||||
handleState(row, column, cellValue, index) {
|
||||
{#('state'))#}
|
||||
|
||||
return download_state[cellValue]
|
||||
},
|
||||
// 格式化文件大小
|
||||
renderSize(value) {
|
||||
if (null == value || value == '') {
|
||||
@@ -365,18 +411,15 @@
|
||||
var size = srcsize / Math.pow(1024, index);
|
||||
size = size.toFixed(2);//保留的小数位数
|
||||
return size + unitArr[index];
|
||||
}
|
||||
,
|
||||
},
|
||||
// 格式化进度
|
||||
handlePercent(row, column, cellValue, index) {
|
||||
return (cellValue * 100).toFixed(2) + '%'
|
||||
}
|
||||
,
|
||||
},
|
||||
// 格式化分享率
|
||||
handleRatio(row, column, cellValue, index) {
|
||||
return cellValue.toFixed(4)
|
||||
}
|
||||
,
|
||||
},
|
||||
// 双击任务事件
|
||||
handleRow(row, column, event) {
|
||||
console.log(row)
|
||||
@@ -386,14 +429,12 @@
|
||||
console.log(row.name)
|
||||
console.log(column)
|
||||
console.log(event)
|
||||
}
|
||||
,
|
||||
},
|
||||
// 阻止默认右键菜单弹出
|
||||
rtClick(row, column, event) {
|
||||
// 阻止默认右键菜单弹出
|
||||
event.preventDefault()
|
||||
}
|
||||
,
|
||||
},
|
||||
handleRefresh(command) {
|
||||
console.log(this.refresh)
|
||||
this.refresh = true
|
||||
@@ -406,8 +447,7 @@
|
||||
this.get_downloading(this.downloader_id)
|
||||
}, this.interval)
|
||||
|
||||
}
|
||||
,
|
||||
},
|
||||
clearTimer() {
|
||||
this.refresh = false
|
||||
console.log(this.refresh)
|
||||
@@ -417,7 +457,11 @@
|
||||
});
|
||||
window.clearInterval(this.timer)
|
||||
this.timer = null
|
||||
}
|
||||
},
|
||||
filterStateMethod(value, row, column) {
|
||||
const property = column['property'];
|
||||
return row[property] === value;
|
||||
},
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user