2020-09-06 16:19:34 +08:00
|
|
|
|
Vue.component("grant-selector", {
|
|
|
|
|
|
props: ["vGrant"],
|
|
|
|
|
|
data: function () {
|
|
|
|
|
|
return {
|
|
|
|
|
|
grantId: (this.vGrant == null) ? 0 : this.vGrant.id,
|
|
|
|
|
|
grant: this.vGrant
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
// 选择授权
|
|
|
|
|
|
select: function () {
|
|
|
|
|
|
let that = this;
|
2020-10-25 21:27:28 +08:00
|
|
|
|
teaweb.popup("/clusters/grants/selectPopup", {
|
2020-09-06 16:19:34 +08:00
|
|
|
|
callback: (resp) => {
|
|
|
|
|
|
that.grantId = resp.data.grant.id;
|
|
|
|
|
|
if (that.grantId > 0) {
|
|
|
|
|
|
that.grant = resp.data.grant;
|
|
|
|
|
|
}
|
2021-08-14 18:06:24 +08:00
|
|
|
|
that.notifyUpdate()
|
2020-09-06 16:19:34 +08:00
|
|
|
|
}
|
2021-08-14 18:06:24 +08:00
|
|
|
|
})
|
2020-09-06 16:19:34 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 创建授权
|
|
|
|
|
|
create: function () {
|
2021-08-14 18:06:24 +08:00
|
|
|
|
let that = this
|
2020-10-25 21:27:28 +08:00
|
|
|
|
teaweb.popup("/clusters/grants/createPopup", {
|
2021-08-02 14:51:15 +08:00
|
|
|
|
height: "26em",
|
2020-09-06 16:19:34 +08:00
|
|
|
|
callback: (resp) => {
|
2021-08-14 18:06:24 +08:00
|
|
|
|
that.grantId = resp.data.grant.id;
|
|
|
|
|
|
if (that.grantId > 0) {
|
|
|
|
|
|
that.grant = resp.data.grant;
|
2020-09-06 16:19:34 +08:00
|
|
|
|
}
|
2021-08-14 18:06:24 +08:00
|
|
|
|
that.notifyUpdate()
|
2020-09-06 16:19:34 +08:00
|
|
|
|
}
|
2021-08-14 18:06:24 +08:00
|
|
|
|
})
|
2020-09-06 16:19:34 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 修改授权
|
|
|
|
|
|
update: function () {
|
|
|
|
|
|
if (this.grant == null) {
|
|
|
|
|
|
window.location.reload();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2021-08-14 18:06:24 +08:00
|
|
|
|
let that = this
|
2020-10-25 21:27:28 +08:00
|
|
|
|
teaweb.popup("/clusters/grants/updatePopup?grantId=" + this.grant.id, {
|
2021-08-02 14:51:15 +08:00
|
|
|
|
height: "26em",
|
2020-09-06 16:19:34 +08:00
|
|
|
|
callback: (resp) => {
|
2021-08-14 18:06:24 +08:00
|
|
|
|
that.grant = resp.data.grant
|
|
|
|
|
|
that.notifyUpdate()
|
2020-09-06 16:19:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 删除已选择授权
|
|
|
|
|
|
remove: function () {
|
2021-08-14 18:06:24 +08:00
|
|
|
|
this.grant = null
|
|
|
|
|
|
this.grantId = 0
|
|
|
|
|
|
this.notifyUpdate()
|
|
|
|
|
|
},
|
|
|
|
|
|
notifyUpdate: function () {
|
|
|
|
|
|
this.$emit("change", this.grant)
|
2020-09-06 16:19:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
template: `<div>
|
|
|
|
|
|
<input type="hidden" name="grantId" :value="grantId"/>
|
2020-11-21 15:53:04 +08:00
|
|
|
|
<div class="ui label small basic" v-if="grant != null">{{grant.name}}<span class="small">({{grant.methodName}})</span> <a href="" title="修改" @click.prevent="update()"><i class="icon pencil small"></i></a> <a href="" title="删除" @click.prevent="remove()"><i class="icon remove"></i></a> </div>
|
2020-09-06 16:19:34 +08:00
|
|
|
|
<div v-if="grant == null">
|
|
|
|
|
|
<a href="" @click.prevent="select()">[选择已有认证]</a> <a href="" @click.prevent="create()">[添加新认证]</a>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>`
|
|
|
|
|
|
})
|