add expand years
This commit is contained in:
parent
532e3148b2
commit
09befa7c9c
@ -6,20 +6,17 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import me.chyxion.tigon.mybatis.Search;
|
import me.chyxion.tigon.mybatis.Search;
|
||||||
import me.chyxion.tigon.model.ViewModel;
|
import me.chyxion.tigon.model.ViewModel;
|
||||||
import org.apache.commons.csv.CSVRecord;
|
import org.apache.commons.csv.CSVRecord;
|
||||||
|
import com.pudonghot.ambition.crm.model.*;
|
||||||
import me.chyxion.tigon.model.ListResult;
|
import me.chyxion.tigon.model.ListResult;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import com.pudonghot.ambition.crm.model.User;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.pudonghot.ambition.crm.util.CSVUtils;
|
import com.pudonghot.ambition.crm.util.CSVUtils;
|
||||||
import com.pudonghot.ambition.crm.model.Customer;
|
|
||||||
import com.pudonghot.ambition.crm.common.Constants;
|
import com.pudonghot.ambition.crm.common.Constants;
|
||||||
import com.pudonghot.ambition.crm.service.UserService;
|
import com.pudonghot.ambition.crm.service.UserService;
|
||||||
import com.pudonghot.ambition.crm.mapper.CustomerMapper;
|
import com.pudonghot.ambition.crm.mapper.CustomerMapper;
|
||||||
import com.pudonghot.ambition.crm.service.CustomerService;
|
import com.pudonghot.ambition.crm.service.CustomerService;
|
||||||
import com.pudonghot.ambition.crm.model.CustomerPermission;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import com.pudonghot.ambition.crm.service.CustomerIssueService;
|
import com.pudonghot.ambition.crm.service.CustomerIssueService;
|
||||||
import com.pudonghot.ambition.crm.model.CustomerYearToDateSale;
|
|
||||||
import com.pudonghot.ambition.crm.mapper.CustomerPermissionMapper;
|
import com.pudonghot.ambition.crm.mapper.CustomerPermissionMapper;
|
||||||
import com.pudonghot.ambition.crm.form.create.CustomerFormForCreate;
|
import com.pudonghot.ambition.crm.form.create.CustomerFormForCreate;
|
||||||
import com.pudonghot.ambition.crm.form.update.CustomerFormForUpdate;
|
import com.pudonghot.ambition.crm.form.update.CustomerFormForUpdate;
|
||||||
@ -66,7 +63,9 @@ public class CustomerServiceSupport
|
|||||||
viewModel.setAttr("users", userService.listByCustomerId(id));
|
viewModel.setAttr("users", userService.listByCustomerId(id));
|
||||||
viewModel.setAttr("issues", customerIssueService.listViewModels(
|
viewModel.setAttr("issues", customerIssueService.listViewModels(
|
||||||
new Search(CustomerYearToDateSale.CUSTOMER_ID, id)
|
new Search(CustomerYearToDateSale.CUSTOMER_ID, id)
|
||||||
.eq(CustomerYearToDateSale.ENABLED, true)));
|
.eq(CustomerYearToDateSale.ENABLED, true)
|
||||||
|
.desc(CustomerYearToDateSale.DATE_CREATED)
|
||||||
|
.desc(CustomerYearToDateSale.DATE_UPDATED)));
|
||||||
}
|
}
|
||||||
return viewModel;
|
return viewModel;
|
||||||
}
|
}
|
||||||
@ -88,17 +87,39 @@ public class CustomerServiceSupport
|
|||||||
protected void processViewModel(ViewModel<Customer> viewModel, Customer model) {
|
protected void processViewModel(ViewModel<Customer> viewModel, Customer model) {
|
||||||
super.processViewModel(viewModel, model);
|
super.processViewModel(viewModel, model);
|
||||||
|
|
||||||
// List<Map<String, Object>> ytdSales;0wi
|
List<Map<String, Object>> ytdSales = null;
|
||||||
|
|
||||||
final String strYears = model.getYears();
|
final String strYears = model.getYears();
|
||||||
final String strYtdSales = model.getYtdSales();
|
final String strYtdSales = model.getYtdSales();
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(strYears) &&
|
if (StringUtils.isNotBlank(strYears) &&
|
||||||
StringUtils.isNotBlank(strYtdSales)) {
|
StringUtils.isNotBlank(strYtdSales)) {
|
||||||
String[] years = strYears.split("\\s*,\\s*");
|
final String[] years = strYears.split("\\s*,\\s*");
|
||||||
String[] ytdSales = strYtdSales.split("\\s*,\\s*");
|
final String[] sales = strYtdSales.split("\\s*,\\s*");
|
||||||
|
ytdSales = new ArrayList<>(years.length);
|
||||||
|
int i = 0;
|
||||||
|
for (final String year : years) {
|
||||||
|
final Map<String, Object> ytdSale = new HashMap<>();
|
||||||
|
ytdSale.put("year", year);
|
||||||
|
ytdSale.put("sale", Long.parseLong(sales[i++]));
|
||||||
|
ytdSales.add(ytdSale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
viewModel.setAttr("ytdSales", ytdSales != null ?
|
||||||
|
ytdSales : Collections.emptyList());
|
||||||
|
List<ViewModel<CustomerIssue>> recentIssues = customerIssueService.listViewModels(
|
||||||
|
new Search(CustomerYearToDateSale.CUSTOMER_ID, model.getId())
|
||||||
|
.eq(CustomerYearToDateSale.ENABLED, true)
|
||||||
|
.desc(CustomerYearToDateSale.DATE_CREATED)
|
||||||
|
.desc(CustomerYearToDateSale.DATE_UPDATED)
|
||||||
|
.limit(3));
|
||||||
|
if (!recentIssues.isEmpty()) {
|
||||||
|
int i = 0;
|
||||||
|
final Iterator<ViewModel<CustomerIssue>> it = recentIssues.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
viewModel.setAttr("issue" + (++i), it.next());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// viewModel.setAttr("ytdSales", ytdSales);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,4 +20,4 @@ echo "Script Path [$prg_path]"
|
|||||||
PROJECT_HOME=$(dirname $prg_path)
|
PROJECT_HOME=$(dirname $prg_path)
|
||||||
echo "Project Home [$PROJECT_HOME]"
|
echo "Project Home [$PROJECT_HOME]"
|
||||||
cd "$PROJECT_HOME"
|
cd "$PROJECT_HOME"
|
||||||
mvn clean package -pl crm -am -DskipTests -Ptest
|
mvn clean package -o -pl crm -am -DskipTests -Ptest
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
tagName: 'span'
|
tagName: 'span',
|
||||||
|
value: Ember.computed.alias('model'),
|
||||||
|
format: 'YYYY-MM-DD H:mm:ss'
|
||||||
});
|
});
|
||||||
|
@ -3,6 +3,7 @@ import BaseListRoute from './../base-list';
|
|||||||
|
|
||||||
const cols = ['showId',
|
const cols = ['showId',
|
||||||
'showName',
|
'showName',
|
||||||
|
'showDateAdded',
|
||||||
'showYear',
|
'showYear',
|
||||||
'showYtdSale',
|
'showYtdSale',
|
||||||
'showCountryCode',
|
'showCountryCode',
|
||||||
@ -12,6 +13,9 @@ const cols = ['showId',
|
|||||||
'showRegion',
|
'showRegion',
|
||||||
'showSalesperson',
|
'showSalesperson',
|
||||||
'showStatus',
|
'showStatus',
|
||||||
|
'showIssue1',
|
||||||
|
'showIssue2',
|
||||||
|
'showIssue3',
|
||||||
];
|
];
|
||||||
const config = {
|
const config = {
|
||||||
showAll: true,
|
showAll: true,
|
||||||
@ -27,19 +31,24 @@ const config = {
|
|||||||
colChanged: Ember.observer(...cols.concat(function() {
|
colChanged: Ember.observer(...cols.concat(function() {
|
||||||
let me = this;
|
let me = this;
|
||||||
me.set('lock', true);
|
me.set('lock', true);
|
||||||
me.set('showAll',
|
me.set('showAll', cols.map(col => {
|
||||||
cols.map(col => {
|
|
||||||
return me[col];
|
return me[col];
|
||||||
}).reduce((val, prevVal) => {
|
}).reduce((val, prevVal) => {
|
||||||
return val && prevVal;
|
return val && prevVal;
|
||||||
}, true));
|
}, true));
|
||||||
me.set('lock', false);
|
me.set('lock', false);
|
||||||
|
me.set('countOfShowing', cols.filter(col => {
|
||||||
|
return me[col];
|
||||||
|
}).length);
|
||||||
}))
|
}))
|
||||||
};
|
};
|
||||||
|
|
||||||
cols.forEach((col) => {
|
cols.forEach((col) => {
|
||||||
config[col] = !['showCountryCode', 'showState', 'showCity'].contains(col);
|
config[col] = !['showYear', 'showCountryCode', 'showState', 'showCity'].includes(col);
|
||||||
});
|
});
|
||||||
|
config.countOfShowing = cols.filter(col => {
|
||||||
|
return config[col];
|
||||||
|
}).length;
|
||||||
|
|
||||||
const TableOptions = Ember.Object.extend(config);
|
const TableOptions = Ember.Object.extend(config);
|
||||||
|
|
||||||
@ -50,9 +59,18 @@ export default BaseListRoute.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
breadcrumbs: [{text: 'Customers'}],
|
breadcrumbs: [{text: 'Customers'}],
|
||||||
|
tableOptions: TableOptions.create(),
|
||||||
setupController(controller) {
|
setupController(controller) {
|
||||||
let me = this;
|
let me = this;
|
||||||
me._super(...arguments);
|
me._super(...arguments);
|
||||||
controller.set('tableOptions', TableOptions.create());
|
controller.set('tableOptions', me.get('tableOptions'));
|
||||||
},
|
},
|
||||||
|
actions: {
|
||||||
|
expandYtdSales(row) {
|
||||||
|
Ember.set(row, 'expand', true);
|
||||||
|
},
|
||||||
|
collapseYtdSales(row) {
|
||||||
|
Ember.set(row, 'expand', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
@ -28,6 +28,7 @@ export default Ember.Route.extend({
|
|||||||
statusList: parentController.get('model.statusList'),
|
statusList: parentController.get('model.statusList'),
|
||||||
criteria: criteria,
|
criteria: criteria,
|
||||||
cols: [{col: 'name', name: 'Name'},
|
cols: [{col: 'name', name: 'Name'},
|
||||||
|
{col: 'dateAdded', name: 'Date Added'},
|
||||||
{col: 'year', name: 'Year'},
|
{col: 'year', name: 'Year'},
|
||||||
{col: 'ytdSale', name: 'YTD Sales'},
|
{col: 'ytdSale', name: 'YTD Sales'},
|
||||||
{col: 'countryCode', name: 'Country'},
|
{col: 'countryCode', name: 'Country'},
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
{{#if model}}
|
{{#if value}}
|
||||||
{{moment-format model 'YYYY-MM-DD H:mm:ss'}}
|
{{moment-format value format}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
@ -35,11 +35,14 @@
|
|||||||
{{#if tableOptions.showName}}
|
{{#if tableOptions.showName}}
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{#if tableOptions.showDateAdded}}
|
||||||
|
<th>Added</th>
|
||||||
|
{{/if}}
|
||||||
{{#if tableOptions.showYear}}
|
{{#if tableOptions.showYear}}
|
||||||
<th>Years</th>
|
<th>Years</th>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if tableOptions.showYtdSale}}
|
{{#if tableOptions.showYtdSale}}
|
||||||
{{sortable-th name='sumYtdSales' text='Sum YTD Sales'}}
|
{{sortable-th name='sumYtdSales' text='Sales'}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if tableOptions.showCountryCode}}
|
{{#if tableOptions.showCountryCode}}
|
||||||
<th class="hidden-480">Country</th>
|
<th class="hidden-480">Country</th>
|
||||||
@ -62,6 +65,15 @@
|
|||||||
{{#if tableOptions.showStatus}}
|
{{#if tableOptions.showStatus}}
|
||||||
<th class="hidden-480">Status</th>
|
<th class="hidden-480">Status</th>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{#if tableOptions.showIssue1}}
|
||||||
|
<th class="hidden-480">Issue 1</th>
|
||||||
|
{{/if}}
|
||||||
|
{{#if tableOptions.showIssue2}}
|
||||||
|
<th class="hidden-480">Issue 2</th>
|
||||||
|
{{/if}}
|
||||||
|
{{#if tableOptions.showIssue3}}
|
||||||
|
<th class="hidden-480">Issue 3</th>
|
||||||
|
{{/if}}
|
||||||
<th>
|
<th>
|
||||||
<i class="ace-icon fa fa-cogs bigger-110 hidden-480"></i>
|
<i class="ace-icon fa fa-cogs bigger-110 hidden-480"></i>
|
||||||
Settings
|
Settings
|
||||||
@ -84,6 +96,11 @@
|
|||||||
{{it.name}}
|
{{it.name}}
|
||||||
</td>
|
</td>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{#if tableOptions.showDateAdded}}
|
||||||
|
<td>
|
||||||
|
{{date-cell value=it.dateAdded format='D/M/YYYY'}}
|
||||||
|
</td>
|
||||||
|
{{/if}}
|
||||||
{{#if tableOptions.showYear}}
|
{{#if tableOptions.showYear}}
|
||||||
<td>
|
<td>
|
||||||
{{it.years}}
|
{{it.years}}
|
||||||
@ -91,6 +108,19 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if tableOptions.showYtdSale}}
|
{{#if tableOptions.showYtdSale}}
|
||||||
<td>
|
<td>
|
||||||
|
{{#if it.sumYtdSales}}
|
||||||
|
{{#if it.expand}}
|
||||||
|
<a style="cursor: pointer;" {{action (route-action 'collapseYtdSales' it)}}>
|
||||||
|
<span class="ui-icon ace-icon fa fa-minus center bigger-110 blue">
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
{{else}}
|
||||||
|
<a style="cursor: pointer;" {{action (route-action 'expandYtdSales' it)}}>
|
||||||
|
<span class="ui-icon ace-icon fa fa-plus center bigger-110 blue">
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
{{number-us it.sumYtdSales}}
|
{{number-us it.sumYtdSales}}
|
||||||
</td>
|
</td>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
@ -129,6 +159,36 @@
|
|||||||
{{it.statusText}}
|
{{it.statusText}}
|
||||||
</td>
|
</td>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{#if tableOptions.showIssue1}}
|
||||||
|
<td style="max-width: 32px">
|
||||||
|
{{#if it.issue1}}
|
||||||
|
{{it.issue1.issue}}
|
||||||
|
{{#link-to 'customer-issue.edit' it.issue1.id class="blue" title="Edit"}}
|
||||||
|
<i class="ace-icon fa fa-pencil bigger-60"></i>
|
||||||
|
{{/link-to}}
|
||||||
|
{{/if}}
|
||||||
|
</td>
|
||||||
|
{{/if}}
|
||||||
|
{{#if tableOptions.showIssue2}}
|
||||||
|
<td style="max-width: 32px">
|
||||||
|
{{#if it.issue2}}
|
||||||
|
{{it.issue2.issue}}
|
||||||
|
{{#link-to 'customer-issue.edit' it.issue2.id class="blue" title="Edit"}}
|
||||||
|
<i class="ace-icon fa fa-pencil bigger-60"></i>
|
||||||
|
{{/link-to}}
|
||||||
|
{{/if}}
|
||||||
|
</td>
|
||||||
|
{{/if}}
|
||||||
|
{{#if tableOptions.showIssue3}}
|
||||||
|
<td style="max-width: 32px">
|
||||||
|
{{#if it.issue3}}
|
||||||
|
{{it.issue3.issue}}
|
||||||
|
{{#link-to 'customer-issue.edit' it.issue3.id class="blue" title="Edit"}}
|
||||||
|
<i class="ace-icon fa fa-pencil bigger-60"></i>
|
||||||
|
{{/link-to}}
|
||||||
|
{{/if}}
|
||||||
|
</td>
|
||||||
|
{{/if}}
|
||||||
<td>
|
<td>
|
||||||
<div class="hidden-sm hidden-xs btn-group">
|
<div class="hidden-sm hidden-xs btn-group">
|
||||||
{{#link-to 'customer-issue.create' it.id class='btn btn-xs btn-success' title='创建注记'}}
|
{{#link-to 'customer-issue.create' it.id class='btn btn-xs btn-success' title='创建注记'}}
|
||||||
@ -149,7 +209,7 @@
|
|||||||
|
|
||||||
<ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
|
<ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
|
||||||
<li>
|
<li>
|
||||||
{{#link-to 'customer-issue.create' it.id class='tooltip-info' data-rel='tooltip' title='创建注记'}}
|
{{#link-to 'customer-issue.create' it.id class='tooltip-info' data-rel='tooltip' title='Create Issue'}}
|
||||||
<span class="green">
|
<span class="green">
|
||||||
<i class="ace-icon fa fa-tags bigger-120"></i>
|
<i class="ace-icon fa fa-tags bigger-120"></i>
|
||||||
</span>
|
</span>
|
||||||
@ -157,7 +217,7 @@
|
|||||||
</li>
|
</li>
|
||||||
{{#if ajax.user.admin}}
|
{{#if ajax.user.admin}}
|
||||||
<li>
|
<li>
|
||||||
{{#link-to 'customer.edit' it.id class='tooltip-info' data-rel='tooltip' title='编辑'}}
|
{{#link-to 'customer.edit' it.id class='tooltip-info' data-rel='tooltip' title='Edit'}}
|
||||||
<span class="blue">
|
<span class="blue">
|
||||||
<i class="ace-icon fa fa-pencil-square-o bigger-120"></i>
|
<i class="ace-icon fa fa-pencil-square-o bigger-120"></i>
|
||||||
</span>
|
</span>
|
||||||
@ -169,6 +229,32 @@
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{{#if it.expand}}
|
||||||
|
<tr>
|
||||||
|
<td colspan="{{tableOptions.countOfShowing}}">
|
||||||
|
<table class="table table-striped table-hover dataTable table-bordered" style="border: 1px solid #ddd;">
|
||||||
|
<thead class="thin-border-bottom">
|
||||||
|
<tr>
|
||||||
|
<th>Year</th>
|
||||||
|
<th>Sale</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{#each it.ytdSales as |yearSale|}}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{{yearSale.year}}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{number-us yearSale.sale}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{/each}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{/if}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
{{ace-checkbox label='ID' value=model.tableOptions.showId}}
|
{{ace-checkbox label='ID' value=model.tableOptions.showId}}
|
||||||
{{ace-checkbox label='Name' value=model.tableOptions.showName}}
|
{{ace-checkbox label='Name' value=model.tableOptions.showName}}
|
||||||
{{ace-checkbox label='Year' value=model.tableOptions.showYear}}
|
{{ace-checkbox label='Date Added' value=model.tableOptions.showDateAdded}}
|
||||||
{{ace-checkbox label='YTD Sales' value=model.tableOptions.showYtdSale}}
|
{{ace-checkbox label='YTD Sales' value=model.tableOptions.showYtdSale}}
|
||||||
{{ace-checkbox label='Country' value=model.tableOptions.showCountryCode}}
|
{{ace-checkbox label='Country' value=model.tableOptions.showCountryCode}}
|
||||||
{{ace-checkbox label='State' value=model.tableOptions.showState}}
|
{{ace-checkbox label='State' value=model.tableOptions.showState}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user