Merge branch 'feature/2021' of 118.31.72.164:donghuang/yoqw into feature/2021

This commit is contained in:
Donghuang 2021-10-20 00:49:08 +08:00
commit 2f44766cff
15 changed files with 336 additions and 3 deletions

View File

@ -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));
}
}

View File

@ -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;
}

View File

@ -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;

View 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: '创建呼叫活动配额'
}]);
}
});

View 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: '编辑呼叫活动配额'}]);
}
});

View 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 + ']配额列表'
}]);
}
});

View 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
}
},
}
});

View 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}}

View 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}}

View 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}}

View File

@ -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'}}

View 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);
});
});

View 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);
});
});

View 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);
});
});

View 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);
});
});