|
@@ -248,7 +248,7 @@
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
import { listTemplate, getTemplate, addTemplate, updateTemplate, delTemplate } from "@/api/monitor/jobTemplate";
|
|
import { listTemplate, getTemplate, addTemplate, updateTemplate, delTemplate } from "@/api/monitor/jobTemplate";
|
|
|
-import { getTenantJobConfig, updateTenantJobStatus, syncTenantJob, syncAllTenantJob, saveTenantJobConfig, listTenantJobConfig } from "@/api/monitor/tenantJob";
|
|
|
|
|
|
|
+import { getTenantJobConfig, updateTenantJobStatus, syncTenantJob, syncAllTenantJob, saveTenantJobConfig, listTenantJobConfig, assignTemplateTenants } from "@/api/monitor/tenantJob";
|
|
|
import { tenantList } from "@/api/tenant/tenant";
|
|
import { tenantList } from "@/api/tenant/tenant";
|
|
|
import Crontab from '@/components/Crontab'
|
|
import Crontab from '@/components/Crontab'
|
|
|
|
|
|
|
@@ -423,29 +423,11 @@ export default {
|
|
|
},
|
|
},
|
|
|
submitAssignTenant() {
|
|
submitAssignTenant() {
|
|
|
this.assignTenantSaving = true
|
|
this.assignTenantSaving = true
|
|
|
- // 只处理选择状态发生变化的租户,避免覆盖其他模板的分配
|
|
|
|
|
- const promises = []
|
|
|
|
|
- const prevIds = this.previousSelectedTenantIds || []
|
|
|
|
|
- this.allTenants.forEach(t => {
|
|
|
|
|
- const isSelected = this.selectedTenantIds.includes(t.id)
|
|
|
|
|
- const wasSelected = prevIds.includes(t.id)
|
|
|
|
|
- if (isSelected === wasSelected) return // 无变化,跳过
|
|
|
|
|
- const p = getTenantJobConfig(t.id).then(res => {
|
|
|
|
|
- const currentIds = (res.data || []).map(c => c.templateId)
|
|
|
|
|
- const newIds = isSelected
|
|
|
|
|
- ? [...new Set([...currentIds, this.assignTemplate.templateId])]
|
|
|
|
|
- : currentIds.filter(id => id !== this.assignTemplate.templateId)
|
|
|
|
|
- return saveTenantJobConfig({ tenantId: t.id, templateIds: newIds, status: '0' })
|
|
|
|
|
- })
|
|
|
|
|
- promises.push(p)
|
|
|
|
|
- })
|
|
|
|
|
- if (promises.length === 0) {
|
|
|
|
|
- this.assignTenantSaving = false
|
|
|
|
|
- this.openAssignTenant = false
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- Promise.all(promises).then(() => {
|
|
|
|
|
|
|
+ const templateId = this.assignTemplate.templateId
|
|
|
|
|
+ const tenantIds = (this.selectedTenantIds || []).map(id => Number(id))
|
|
|
|
|
+ assignTemplateTenants(templateId, tenantIds).then(() => {
|
|
|
this.msgSuccess('分配成功')
|
|
this.msgSuccess('分配成功')
|
|
|
|
|
+ this.previousSelectedTenantIds = [...tenantIds]
|
|
|
this.assignTenantSaving = false
|
|
this.assignTenantSaving = false
|
|
|
this.openAssignTenant = false
|
|
this.openAssignTenant = false
|
|
|
}).catch(() => { this.assignTenantSaving = false })
|
|
}).catch(() => { this.assignTenantSaving = false })
|