add campaign-quota
This commit is contained in:
parent
58b460e122
commit
dd72ef1e08
@ -1,9 +1,14 @@
|
||||
package com.pudonghot.yo.cms.controller;
|
||||
|
||||
import com.wacai.tigon.form.FormList;
|
||||
import lombok.val;
|
||||
import com.wacai.tigon.model.ViewModel;
|
||||
import com.wacai.tigon.web.controller.ArgQuery;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import com.pudonghot.yo.model.domain.CampaignQuota;
|
||||
import com.pudonghot.yo.cms.service.CampaignService;
|
||||
import com.pudonghot.yo.cms.form.FormListCampaignQuota;
|
||||
import com.wacai.tigon.web.controller.BaseCrudController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import com.pudonghot.yo.cms.form.create.FormCreateCampaignQuota;
|
||||
import com.pudonghot.yo.cms.form.update.FormUpdateCampaignQuota;
|
||||
@ -13,11 +18,48 @@ import com.pudonghot.yo.cms.form.update.FormUpdateCampaignQuota;
|
||||
* @date Oct 14, 2021 14:24:45
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/campaign-quota")
|
||||
@RequestMapping("/cms/api/campaign-quota")
|
||||
public class CampaignQuotaController
|
||||
extends BaseCrudController<Integer,
|
||||
CampaignQuota,
|
||||
FormList,
|
||||
FormListCampaignQuota,
|
||||
FormCreateCampaignQuota,
|
||||
FormUpdateCampaignQuota> {
|
||||
|
||||
@Autowired
|
||||
private CampaignService campaignService;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void before(final ArgQuery<?> arg) {
|
||||
super.before(arg);
|
||||
|
||||
if (arg.getType() == ArgQuery.Type.LIST) {
|
||||
val form = (FormListCampaignQuota) arg.getArg();
|
||||
arg.getSearch()
|
||||
.eq(CampaignQuota.CAMPAIGN_ID,
|
||||
form.getCampaignId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void after(final ArgQuery<?> arg) {
|
||||
super.after(arg);
|
||||
|
||||
val vm = (ViewModel<?>) arg.getResult();
|
||||
final Integer campaignId;
|
||||
if (arg.getType() == ArgQuery.Type.LIST) {
|
||||
val form = (FormListCampaignQuota) arg.getArg();
|
||||
campaignId = form.getCampaignId();
|
||||
}
|
||||
else {
|
||||
campaignId = ((CampaignQuota) vm.getData()).getCampaignId();
|
||||
}
|
||||
vm.attr("campaign", campaignService.find(campaignId));
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.pudonghot.yo.cms.form;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import com.wacai.tigon.form.FormList;
|
||||
|
||||
/**
|
||||
* @author Donghuang
|
||||
* @date Oct 18, 2021 23:52:22
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class FormListCampaignQuota extends FormList {
|
||||
private Integer campaignId;
|
||||
}
|
@ -162,6 +162,12 @@ Router.map(function() {
|
||||
this.route('agent-daily-idle-detail', function() {
|
||||
this.route('list');
|
||||
});
|
||||
|
||||
this.route('campaign-quota', function() {
|
||||
this.route('list');
|
||||
this.route('create');
|
||||
this.route('edit', {path: '/:id/edit'});
|
||||
});
|
||||
});
|
||||
|
||||
export default Router;
|
||||
|
33
web/cms/app/routes/campaign-quota/create.js
Normal file
33
web/cms/app/routes/campaign-quota/create.js
Normal file
@ -0,0 +1,33 @@
|
||||
import BaseRoute from '../base';
|
||||
import RSVP from 'rsvp';
|
||||
|
||||
export default BaseRoute.extend({
|
||||
perm: 'PERM_VIEW_CAMPAIGN_QUOTA_CREATE',
|
||||
queryParams: {
|
||||
campaignId: {
|
||||
refreshModel: true
|
||||
}
|
||||
},
|
||||
model(params) {
|
||||
const me = this;
|
||||
return RSVP.hash({
|
||||
campaignId: params.campaignId,
|
||||
campaign: me.get('store').ajaxGet('campaign/find', {id: params.campaignId}),
|
||||
active: true
|
||||
});
|
||||
},
|
||||
afterModel(model) {
|
||||
const me = this;
|
||||
me._super(...arguments);
|
||||
|
||||
me.set('breadcrumbs', [{
|
||||
route: 'campaign.list', text: '呼叫活动列表'
|
||||
}, {
|
||||
route: 'campaign-quota.list',
|
||||
text: '呼叫活动[' + model.campaign.name + ']配额列表',
|
||||
queryParams: {campaignId: model.campaign.id}
|
||||
}, {
|
||||
text: '创建呼叫活动配额'
|
||||
}]);
|
||||
}
|
||||
});
|
12
web/cms/app/routes/campaign-quota/edit.js
Normal file
12
web/cms/app/routes/campaign-quota/edit.js
Normal file
@ -0,0 +1,12 @@
|
||||
import BaseEditRoute from '../base-edit';
|
||||
|
||||
export default BaseEditRoute.extend({
|
||||
perm: 'PERM_VIEW_CAMPAIGN_QUOTA_EDIT',
|
||||
afterModel(model) {
|
||||
this.set('breadcrumbs',
|
||||
[{route: 'campaign-quota.list',
|
||||
text: '呼叫活动[' + model.campaign.name + ']配额列表',
|
||||
queryParams: {campaignId: model.campaign.id}},
|
||||
{text: '编辑呼叫活动配额'}]);
|
||||
}
|
||||
});
|
20
web/cms/app/routes/campaign-quota/list.js
Normal file
20
web/cms/app/routes/campaign-quota/list.js
Normal file
@ -0,0 +1,20 @@
|
||||
import BaseListRoute from '../base-list';
|
||||
|
||||
export default BaseListRoute.extend({
|
||||
perm: 'PERM_VIEW_CAMPAIGN_QUOTA_LIST',
|
||||
queryParams: {
|
||||
campaignId: {
|
||||
refreshModel: true
|
||||
}
|
||||
},
|
||||
afterModel(model) {
|
||||
const me = this;
|
||||
me._super(...arguments);
|
||||
|
||||
me.set('breadcrumbs', [{
|
||||
route: 'campaign.list', text: '呼叫活动列表'
|
||||
}, {
|
||||
text: '呼叫活动[' + model.campaign.name + ']配额列表'
|
||||
}]);
|
||||
}
|
||||
});
|
26
web/cms/app/services/campaign-quota/service.js
Normal file
26
web/cms/app/services/campaign-quota/service.js
Normal file
@ -0,0 +1,26 @@
|
||||
import Service from '../service';
|
||||
|
||||
export default Service.extend({
|
||||
modelName: 'CampaignQuota',
|
||||
constraints: {
|
||||
dailyFrom: {
|
||||
presence: true,
|
||||
format: {
|
||||
pattern: '^([01]?[0-9]|2[0-3]):([0-5]?[0-9])(:[0-5]?[0-9])?$'
|
||||
}
|
||||
},
|
||||
dailyTo: {
|
||||
presence: true,
|
||||
format: {
|
||||
pattern: '^([01]?[0-9]|2[0-3]):([0-5]?[0-9])(:[0-5]?[0-9])?$'
|
||||
}
|
||||
},
|
||||
quota: {
|
||||
presence: true,
|
||||
numericality: {
|
||||
onlyInteger: true,
|
||||
greaterThan: 0
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
18
web/cms/app/templates/campaign-quota/create.hbs
Normal file
18
web/cms/app/templates/campaign-quota/create.hbs
Normal file
@ -0,0 +1,18 @@
|
||||
{{#form-content}}
|
||||
<hr />
|
||||
{{form-input type='hidden' name='campaignId'}}
|
||||
|
||||
{{form-input name='dailyFrom' label='开始时间'}}
|
||||
{{form-input name='dailyTo' label='结束时间'}}
|
||||
{{form-input name='quota' label='配额'}}
|
||||
|
||||
{{form-input-enabled}}
|
||||
{{form-input name='note' label='备注'}}
|
||||
|
||||
<hr />
|
||||
{{form-footer-buttons type='create'
|
||||
back-route='campaign-quota.list'
|
||||
back-route-query-params=(hash campaignId=campaignId)
|
||||
}}
|
||||
{{/form-content}}
|
||||
{{outlet}}
|
17
web/cms/app/templates/campaign-quota/edit.hbs
Normal file
17
web/cms/app/templates/campaign-quota/edit.hbs
Normal file
@ -0,0 +1,17 @@
|
||||
{{#form-content}}
|
||||
{{form-input type='hidden' name='id'}}
|
||||
|
||||
{{form-input name='dailyFrom' label='开始时间'}}
|
||||
{{form-input name='dailyTo' label='结束时间'}}
|
||||
{{form-input name='quota' label='配额'}}
|
||||
|
||||
{{form-input-enabled}}
|
||||
{{form-input name='note' label='备注'}}
|
||||
|
||||
<hr />
|
||||
{{form-footer-buttons type='update'
|
||||
back-route='campaign-quota.list'
|
||||
back-route-query-params=(hash campaignId=model.campaignId)
|
||||
}}
|
||||
{{/form-content}}
|
||||
{{outlet}}
|
86
web/cms/app/templates/campaign-quota/list.hbs
Normal file
86
web/cms/app/templates/campaign-quota/list.hbs
Normal file
@ -0,0 +1,86 @@
|
||||
<div class="widget-box transparent" style="padding-top: 2px; border: 1px solid #ddd;">
|
||||
{{#grid-header}}
|
||||
{{#has-perm 'PERM_VIEW_CAMPAIGN_QUOTA_CREATE'}}
|
||||
<li>
|
||||
{{#link-to 'campaign-quota.create' (query-params campaignId=campaignId)}}
|
||||
<i class="ace-icon fa fa-plus-circle bigger-110 green"></i>
|
||||
新建呼叫活动配额
|
||||
{{/link-to}}
|
||||
</li>
|
||||
{{/has-perm}}
|
||||
{{/grid-header}}
|
||||
|
||||
<div class="widget-body">
|
||||
<!-- #section:custom/scrollbar -->
|
||||
<div class="widget-main no-padding">
|
||||
<table class="table table-striped table-bordered table-hover dataTable">
|
||||
<thead class="thin-border-bottom">
|
||||
<tr>
|
||||
<th>
|
||||
开始时间
|
||||
</th>
|
||||
<th>
|
||||
结束时间
|
||||
</th>
|
||||
<th>
|
||||
限额
|
||||
</th>
|
||||
<th>
|
||||
<i class="ace-icon fa fa-sticky-note-o bigger-110"></i>
|
||||
备注
|
||||
</th>
|
||||
<th>
|
||||
<i class="ace-icon fa fa-exchange bigger-110 hidden-480"></i>
|
||||
{{th-filter name='active'
|
||||
text='状态'
|
||||
dialog-title='状态'
|
||||
options=(array (hash value=true text='启用')
|
||||
(hash value=false text='禁用'))
|
||||
}}
|
||||
</th>
|
||||
<th>
|
||||
<i class="ace-icon fa fa-cogs bigger-110 hidden-480"></i>
|
||||
管理
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each model.data as |it|}}
|
||||
<tr>
|
||||
<td>
|
||||
{{it.dailyFrom}}
|
||||
</td>
|
||||
<td>
|
||||
{{it.dailyTo}}
|
||||
</td>
|
||||
<td>
|
||||
{{it.quota}}
|
||||
</td>
|
||||
<td>
|
||||
{{editable-cell model=it field='note'}}
|
||||
</td>
|
||||
<td>
|
||||
{{status-cell model=it}}
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
{{#has-perm 'PERM_VIEW_CAMPAIGN_QUOTA_EDIT'}}
|
||||
{{status-toggle-button model=it}}
|
||||
{{edit-btn route-name='campaign-quota.edit' model-id=it.id perm='PERM_VIEW_CAMPAIGN_QUOTA_EDIT'}}
|
||||
{{/has-perm}}
|
||||
{{#has-perm 'PERM_VIEW_CAMPAIGN_QUOTA_DELETE'}}
|
||||
{{#unless it.active}}
|
||||
{{delete-button model=it}}
|
||||
{{/unless}}
|
||||
{{/has-perm}}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{pagination-bar}}
|
||||
</div>
|
||||
</div>
|
||||
{{outlet}}
|
@ -22,6 +22,7 @@
|
||||
<th>
|
||||
Key
|
||||
</th>
|
||||
{{!--
|
||||
<th>
|
||||
{{th-filter name='type'
|
||||
text='类型'
|
||||
@ -34,6 +35,7 @@
|
||||
options=model.targetTypesList
|
||||
}}
|
||||
</th>
|
||||
--}}
|
||||
<th>
|
||||
转接目标
|
||||
</th>
|
||||
@ -99,12 +101,14 @@
|
||||
<td>
|
||||
{{it.campaignKey}}
|
||||
</td>
|
||||
{{!--
|
||||
<td>
|
||||
{{it.type}}
|
||||
</td>
|
||||
<td>
|
||||
{{it.targetType}}
|
||||
</td>
|
||||
--}}
|
||||
<td>
|
||||
{{option-text model.queuesList it.targetId 'id' 'name'}}
|
||||
</td>
|
||||
@ -152,6 +156,15 @@
|
||||
<i class="ace-icon fa fa-sliders bigger-120"></i>
|
||||
{{/link-to}}
|
||||
{{/has-perm}}
|
||||
{{#has-perm 'PERM_VIEW_CAMPAIGN_QUOTA_LIST'}}
|
||||
{{#link-to 'campaign-quota.list'
|
||||
(query-params campaignId=it.id)
|
||||
class='btn btn-xs btn-info2'
|
||||
data-rel='tooltip'
|
||||
title='呼叫活动配额管理'}}
|
||||
<i class="ace-icon fa fa-sort-numeric-asc bigger-120"></i>
|
||||
{{/link-to}}
|
||||
{{/has-perm}}
|
||||
{{#has-perm 'PERM_VIEW_CAMPAIGN_EDIT'}}
|
||||
{{status-toggle-button model=it}}
|
||||
{{edit-btn route-name='campaign.edit' model-id=it.id perm='PERM_VIEW_CAMPAIGN_EDIT'}}
|
||||
|
11
web/cms/tests/unit/routes/campaign-quota/create-test.js
Normal file
11
web/cms/tests/unit/routes/campaign-quota/create-test.js
Normal file
@ -0,0 +1,11 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | campaign-quota/create', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:campaign-quota/create');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
11
web/cms/tests/unit/routes/campaign-quota/edit-test.js
Normal file
11
web/cms/tests/unit/routes/campaign-quota/edit-test.js
Normal file
@ -0,0 +1,11 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | campaign-quota/edit', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:campaign-quota/edit');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
11
web/cms/tests/unit/routes/campaign-quota/list-test.js
Normal file
11
web/cms/tests/unit/routes/campaign-quota/list-test.js
Normal file
@ -0,0 +1,11 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | campaign-quota/list', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:campaign-quota/list');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
12
web/cms/tests/unit/services/campaign-quota/service-test.js
Normal file
12
web/cms/tests/unit/services/campaign-quota/service-test.js
Normal file
@ -0,0 +1,12 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Service | campaign-quota/service', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let service = this.owner.lookup('service:campaign-quota/service');
|
||||
assert.ok(service);
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user