可以打开或关闭源是否为自选源

This commit is contained in:
haiyangcui
2020-10-21 17:26:46 +02:00
parent 2ed47e64c3
commit bd43f06e7d
4 changed files with 72 additions and 27 deletions

View File

@@ -18,6 +18,19 @@
label="资源名"
min-width="200">
</el-table-column>
<el-table-column
prop="isActive"
label="自选源"
width="100">
<template slot-scope="scope">
<el-switch
v-model="scope.row.isActive"
:active-value="1"
:inactive-value="0"
@change='isActiveChangeEvent'>
</el-switch>
</template>
</el-table-column>
<el-table-column
label="操作"
header-align="center"
@@ -215,6 +228,9 @@ export default {
json.forEach(ele => {
if (this.sites.filter(x => x.key === ele.key).length === 0 && this.sites.filter(x => x.name === ele.name && x.url === ele.url).length === 0) {
// 不含该key 同时也不含名字和url一样的
if (ele.isActive === undefined) {
ele.isActive = 1
}
this.sites.push(ele)
}
})
@@ -233,6 +249,9 @@ export default {
this.sites.sort(function (x, y) { return x.key === i.key ? -1 : y.key === i.key ? 1 : 0 })
this.updateDatabase(this.sites)
},
isActiveChangeEvent () {
this.updateDatabase(this.sites)
},
resetId (inArray) {
var id = 1
inArray.forEach(ele => {

View File

@@ -470,7 +470,7 @@ export default {
},
getAllsites () {
sites.all().then(res => {
this.sites = res
this.sites = res.filter(x => x.isActive)
this.site = this.sites[0]
this.siteClick(this.site)
})