卡片添加操作按钮

This commit is contained in:
ngfchl
2022-12-04 19:51:21 +08:00
parent 1d75576d04
commit fdea1e5564

View File

@@ -109,7 +109,13 @@
</div> </div>
<div class="text item" style="font-size: 13px;text-align: right;"> <div class="text item" style="font-size: 13px;text-align: right;">
<div> <div>
<el-button type="success" size="mini" @click="showHistoryList(site.id)">历史数据 <el-button type="primary" size="mini" @click="signIn(site.id)">签到
</el-button>
<el-button type="info" size="mini" @click="updateSite(site.id)">更新
</el-button>
<el-button type="danger" size="mini" @click="editSite(site.id)">编辑
</el-button>
<el-button type="success" size="mini" @click="showHistoryList(site.id)">历史 c
</el-button> </el-button>
</div> </div>
<hr> <hr>
@@ -231,26 +237,26 @@
} }
const vm = new Vue({ const vm = new Vue({
el: '#status', el: '#status',
data() { data() {
return { return {
chart: null, chart: null,
ptData: {}, ptData: {},
option: {}, option: {},
showList: false, showList: false,
showSiteChart: false, showSiteChart: false,
begInvite: false, begInvite: false,
showLogo: true, showLogo: true,
showLegend: true, showLegend: true,
shuffle: false, shuffle: false,
} }
}, },
beforeMount() { beforeMount() {
}, },
mounted() { mounted() {
{#this.chart = this.$refs.charts.chart#} {#this.chart = this.$refs.charts.chart#}
this.getData() this.getData()
}, },
watch: { watch: {
@@ -263,34 +269,43 @@
deep: true, deep: true,
} }
}, },
methods: { methods: {
showHistoryList(id) { signIn(id) {
axios.get( alert(id)
"{% url 'site_data_api' %}" + '?id=' + id },
).then(res => { updateSite(id) {
console.log('获取数据列表成功', res.data) alert(id)
let data = res.data },
if ((typeof res.data) == "string") { editSite(id) {
data = JSON.parse(data) alert(id)
} },
{#console.log(typeof res.data.data)#} showHistoryList(id) {
if (res.data.code === 0) { axios.get(
{#this.ptData = res.data.data#} "{% url 'site_data_api' %}" + '?id=' + id
{#this.ptData = res.data.data#} ).then(res => {
{#this.setPie()#} console.log('获取数据列表成功', res.data)
{#this.setCard()#} let data = res.data
if ((typeof res.data) == "string") {
data = JSON.parse(data)
}
{#console.log(typeof res.data.data)#}
if (res.data.code === 0) {
{#this.ptData = res.data.data#}
{#this.ptData = res.data.data#}
{#this.setPie()#}
{#this.setCard()#}
this.setLine(data.data) this.setLine(data.data)
} else { } else {
this.loading = false this.loading = false
this.$message({ this.$message({
type: 'warning', type: 'warning',
message: '获取数据列表失败!' message: '获取数据列表失败!'
}); });
} }
}) })
//.catch(res => { //.catch(res => {
//console.log('获取数据列表失败', res) //console.log('获取数据列表失败', res)
// this.$message({ // this.$message({
// type: 'warning', // type: 'warning',
// message: '获取数据列表失败!' + res // message: '获取数据列表失败!' + res
@@ -311,28 +326,28 @@
this.showLogo = !this.showLogo this.showLogo = !this.showLogo
this.setPie() this.setPie()
} }
, ,
showLegendMode() { showLegendMode() {
this.showLegend = !this.showLegend this.showLegend = !this.showLegend
this.setPie() this.setPie()
}
,
setChartOption(option) {
{#this.option = option#}
if (this.chart) {
this.chart.clear()
} }
this.chart.setOption(option) ,
window.addEventListener("resize", () => { setChartOption(option) {
this.chart.resize() {#this.option = option#}
}) if (this.chart) {
//this.$nextTick(() => {//自适应宽度 this.chart.clear()
// this.chart.resize(); }
//}) this.chart.setOption(option)
} window.addEventListener("resize", () => {
, this.chart.resize()
shuffleList() { })
this.shuffle = true //this.$nextTick(() => {//自适应宽度
// this.chart.resize();
//})
}
,
shuffleList() {
this.shuffle = true
this.ptData.status_list.sort(() => { this.ptData.status_list.sort(() => {
return Math.random() > 0.5 ? -1 : 1 return Math.random() > 0.5 ? -1 : 1
}) })
@@ -494,15 +509,15 @@
this.setChartOption(option) this.setChartOption(option)
}, 50) }, 50)
}, },
setTree() { setTree() {
let ptData = this.ptData let ptData = this.ptData
let begInvite = !this.begInvite let begInvite = !this.begInvite
let uploadedList = [] let uploadedList = []
let downloadedList = [] let downloadedList = []
ptData.status_list.forEach((site, index) => { ptData.status_list.forEach((site, index) => {
uploadedList.push({ uploadedList.push({
'value': site.uploaded, 'value': site.uploaded,
'path': 'uploaded/' + site.name, 'path': 'uploaded/' + site.name,
'name': `${site.name}\t${renderSize(site.uploaded)}` 'name': `${site.name}\t${renderSize(site.uploaded)}`
}) })
downloadedList.push({ downloadedList.push({
@@ -779,9 +794,9 @@
}, },
getData() { getData() {
axios.get( axios.get(
"{% url "site_status_api" %}" "{% url "site_status_api" %}"
).then(res => { ).then(res => {
console.log('获取数据列表成功', res.data) console.log('获取数据列表成功', res.data)
if (res.data.code === 0) { if (res.data.code === 0) {
@@ -797,9 +812,9 @@
message: '获取数据列表失败!' message: '获取数据列表失败!'
}); });
} }
}).catch(res => { }).catch(res => {
console.log('获取数据列表失败', res) console.log('获取数据列表失败', res)
this.$message({ this.$message({
type: 'warning', type: 'warning',
message: '获取数据列表失败!' + res message: '获取数据列表失败!' + res
}); });