feat(plugin-schedule): support group dropdown selector for whitelist and single target
This commit is contained in:
@@ -87,10 +87,34 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="editForm.target_scope === 'group_whitelist'" label="群ID列表">
|
||||
<el-input v-model="editForm.group_ids_text" placeholder="群ID逗号分隔"></el-input>
|
||||
<el-select
|
||||
v-model="editForm.selected_group_ids"
|
||||
multiple
|
||||
filterable
|
||||
collapse-tags
|
||||
placeholder="请选择群(可多选)"
|
||||
style="width: 100%;">
|
||||
<el-option
|
||||
v-for="group in groupOptions"
|
||||
:key="group.wxid"
|
||||
:label="group.name"
|
||||
:value="group.wxid">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="editForm.target_scope === 'single_group'" label="群ID">
|
||||
<el-input v-model="editForm.single_group_id"></el-input>
|
||||
<el-select
|
||||
v-model="editForm.selected_single_group_id"
|
||||
filterable
|
||||
placeholder="请选择群"
|
||||
style="width: 100%;">
|
||||
<el-option
|
||||
v-for="group in groupOptions"
|
||||
:key="group.wxid"
|
||||
:label="group.name"
|
||||
:value="group.wxid">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="Payload(JSON)">
|
||||
<el-input type="textarea" :rows="4" v-model="editForm.payload_text"></el-input>
|
||||
@@ -126,6 +150,7 @@ new Vue({
|
||||
return {
|
||||
loading: false,
|
||||
schedules: [],
|
||||
groupOptions: [],
|
||||
editDialogVisible: false,
|
||||
logsDialogVisible: false,
|
||||
logs: [],
|
||||
@@ -142,11 +167,14 @@ new Vue({
|
||||
target_scope: 'all_enabled_groups',
|
||||
group_ids_text: '',
|
||||
single_group_id: '',
|
||||
selected_group_ids: [],
|
||||
selected_single_group_id: '',
|
||||
payload_text: '{}'
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.loadGroupOptions()
|
||||
this.loadSchedules()
|
||||
},
|
||||
methods: {
|
||||
@@ -165,6 +193,20 @@ new Vue({
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
async loadGroupOptions() {
|
||||
try {
|
||||
const resp = await axios.get('/contacts/api/groups')
|
||||
if (resp.data && resp.data.success) {
|
||||
const groups = (resp.data.data && resp.data.data.groups) || {}
|
||||
this.groupOptions = Object.entries(groups).map(([wxid, name]) => ({
|
||||
wxid: String(wxid),
|
||||
name: String(name || wxid)
|
||||
}))
|
||||
}
|
||||
} catch (e) {
|
||||
this.groupOptions = []
|
||||
}
|
||||
},
|
||||
openEdit(row) {
|
||||
this.currentId = row.id
|
||||
const trigger = row.trigger_config || {}
|
||||
@@ -180,6 +222,8 @@ new Vue({
|
||||
this.editForm.target_scope = row.target_scope || 'all_enabled_groups'
|
||||
this.editForm.group_ids_text = (target.group_ids || []).join(',')
|
||||
this.editForm.single_group_id = target.group_id || ''
|
||||
this.editForm.selected_group_ids = Array.isArray(target.group_ids) ? target.group_ids.map(x => String(x)) : []
|
||||
this.editForm.selected_single_group_id = target.group_id ? String(target.group_id) : ''
|
||||
this.editForm.payload_text = JSON.stringify(row.payload || {}, null, 2)
|
||||
this.editDialogVisible = true
|
||||
},
|
||||
@@ -199,9 +243,14 @@ new Vue({
|
||||
},
|
||||
buildTargetConfig() {
|
||||
if (this.editForm.target_scope === 'single_group') {
|
||||
return { group_id: String(this.editForm.single_group_id || '').trim() }
|
||||
const groupId = String(this.editForm.selected_single_group_id || this.editForm.single_group_id || '').trim()
|
||||
return { group_id: groupId }
|
||||
}
|
||||
if (this.editForm.target_scope === 'group_whitelist') {
|
||||
const ids = (this.editForm.selected_group_ids || []).map(x => String(x).trim()).filter(Boolean)
|
||||
if (ids.length > 0) {
|
||||
return { group_ids: ids }
|
||||
}
|
||||
return {
|
||||
group_ids: String(this.editForm.group_ids_text || '').split(',').map(x => x.trim()).filter(Boolean)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user