mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-14 12:20:27 +08:00
实现基础的通知媒介管理
This commit is contained in:
29
web/public/js/components/admins/admin-selector.js
Normal file
29
web/public/js/components/admins/admin-selector.js
Normal file
@@ -0,0 +1,29 @@
|
||||
// TODO 支持关键词搜索
|
||||
// TODO 改成弹窗选择
|
||||
Vue.component("admin-selector", {
|
||||
props: ["v-admin-id"],
|
||||
mounted: function () {
|
||||
let that = this
|
||||
Tea.action("/admins/options")
|
||||
.post()
|
||||
.success(function (resp) {
|
||||
that.admins = resp.data.admins
|
||||
})
|
||||
},
|
||||
data: function () {
|
||||
let adminId = this.vAdminId
|
||||
if (adminId == null) {
|
||||
adminId = 0
|
||||
}
|
||||
return {
|
||||
admins: [],
|
||||
adminId: adminId
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
<select class="ui dropdown auto-width" name="adminId" v-model="adminId">
|
||||
<option value="0">[选择系统用户]</option>
|
||||
<option v-for="admin in admins" :value="admin.id">{{admin.name}}({{admin.username}})</option>
|
||||
</select>
|
||||
</div>`
|
||||
})
|
||||
@@ -0,0 +1,58 @@
|
||||
Vue.component("message-media-instance-selector", {
|
||||
props: ["v-instance-id"],
|
||||
mounted: function () {
|
||||
let that = this
|
||||
Tea.action("/admins/recipients/instances/options")
|
||||
.post()
|
||||
.success(function (resp) {
|
||||
that.instances = resp.data.instances
|
||||
|
||||
// 初始化简介
|
||||
if (that.instanceId > 0) {
|
||||
let instance = that.instances.$find(function (_, instance) {
|
||||
return instance.id == that.instanceId
|
||||
})
|
||||
if (instance != null) {
|
||||
that.description = instance.description
|
||||
that.update(instance.id)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
data: function () {
|
||||
let instanceId = this.vInstanceId
|
||||
if (instanceId == null) {
|
||||
instanceId = 0
|
||||
}
|
||||
return {
|
||||
instances: [],
|
||||
description: "",
|
||||
instanceId: instanceId
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
instanceId: function (v) {
|
||||
this.update(v)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
update: function (v) {
|
||||
let instance = this.instances.$find(function (_, instance) {
|
||||
return instance.id == v
|
||||
})
|
||||
if (instance == null) {
|
||||
this.description = ""
|
||||
} else {
|
||||
this.description = instance.description
|
||||
}
|
||||
this.$emit("change", instance)
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
<select class="ui dropdown auto-width" name="instanceId" v-model="instanceId">
|
||||
<option value="0">[选择媒介]</option>
|
||||
<option v-for="instance in instances" :value="instance.id">{{instance.name}} ({{instance.media.name}})</option>
|
||||
</select>
|
||||
<p class="comment" v-html="description"></p>
|
||||
</div>`
|
||||
})
|
||||
52
web/public/js/components/messages/message-media-selector.js
Normal file
52
web/public/js/components/messages/message-media-selector.js
Normal file
@@ -0,0 +1,52 @@
|
||||
Vue.component("message-media-selector", {
|
||||
props: ["v-media-type"],
|
||||
mounted: function () {
|
||||
let that = this
|
||||
Tea.action("/admins/recipients/mediaOptions")
|
||||
.post()
|
||||
.success(function (resp) {
|
||||
that.medias = resp.data.medias
|
||||
|
||||
// 初始化简介
|
||||
if (that.mediaType.length > 0) {
|
||||
let media = that.medias.$find(function (_, media) {
|
||||
return media.type == that.mediaType
|
||||
})
|
||||
if (media != null) {
|
||||
that.description = media.description
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
data: function () {
|
||||
let mediaType = this.vMediaType
|
||||
if (mediaType == null) {
|
||||
mediaType = ""
|
||||
}
|
||||
return {
|
||||
medias: [],
|
||||
description: "",
|
||||
mediaType: mediaType
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
mediaType: function (v) {
|
||||
let media = this.medias.$find(function (_, media) {
|
||||
return media.type == v
|
||||
})
|
||||
if (media == null) {
|
||||
this.description = ""
|
||||
} else {
|
||||
this.description = media.description
|
||||
}
|
||||
this.$emit("change", media)
|
||||
},
|
||||
},
|
||||
template: `<div>
|
||||
<select class="ui dropdown auto-width" name="mediaType" v-model="mediaType">
|
||||
<option value="">[选择媒介类型]</option>
|
||||
<option v-for="media in medias" :value="media.type">{{media.name}}</option>
|
||||
</select>
|
||||
<p class="comment" v-html="description"></p>
|
||||
</div>`
|
||||
})
|
||||
@@ -0,0 +1,56 @@
|
||||
Vue.component("message-recipient-group-selector", {
|
||||
props: ["v-groups"],
|
||||
data: function () {
|
||||
let groups = this.vGroups
|
||||
if (groups == null) {
|
||||
groups = []
|
||||
}
|
||||
let groupIds = []
|
||||
if (groups.length > 0) {
|
||||
groupIds = groups.map(function (v) {
|
||||
return v.id.toString()
|
||||
}).join(",")
|
||||
}
|
||||
|
||||
return {
|
||||
groups: groups,
|
||||
groupIds: groupIds
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
addGroup: function () {
|
||||
let that = this
|
||||
teaweb.popup("/admins/recipients/groups/selectPopup?groupIds=" + this.groupIds, {
|
||||
callback: function (resp) {
|
||||
that.groups.push(resp.data.group)
|
||||
that.update()
|
||||
}
|
||||
})
|
||||
},
|
||||
removeGroup: function (index) {
|
||||
this.groups.$remove(index)
|
||||
this.update()
|
||||
},
|
||||
update: function () {
|
||||
let groupIds = []
|
||||
if (this.groups.length > 0) {
|
||||
this.groups.forEach(function (v) {
|
||||
groupIds.push(v.id)
|
||||
})
|
||||
}
|
||||
this.groupIds = groupIds.join(",")
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
<input type="hidden" name="groupIds" :value="groupIds"/>
|
||||
<div v-if="groups.length > 0">
|
||||
<div>
|
||||
<div v-for="(group, index) in groups" class="ui label small basic">
|
||||
{{group.name}} <a href="" title="删除" @click.prevent="removeGroup(index)"><i class="icon remove"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui divider"></div>
|
||||
</div>
|
||||
<button class="ui button tiny" type="button" @click.prevent="addGroup()">+</button>
|
||||
</div>`
|
||||
})
|
||||
Reference in New Issue
Block a user