Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
addcpm-json
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Александр Чаплыгин
addcpm-json
Commits
671ec348
Commit
671ec348
authored
Jan 31, 2019
by
Александр Чаплыгин
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Правки по коду для сортировки
parent
8eb49388
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
35 deletions
+24
-35
styles-feeds-stat.css
src/public/css/styles-feeds-stat.css
+5
-0
script-feeds-stat-table.js
src/public/js/script-feeds-stat-table.js
+17
-31
script-feeds-stat.js
src/public/js/script-feeds-stat.js
+2
-4
No files found.
src/public/css/styles-feeds-stat.css
View file @
671ec348
...
@@ -276,6 +276,11 @@ input[type="checkbox"]
...
@@ -276,6 +276,11 @@ input[type="checkbox"]
font-size
:
13px
;
font-size
:
13px
;
}
}
.table.table-striped.admin.common
tbody
tr
.total
{
font-weight
:
bold
;
}
.b-basket-content
.b-basket-content
...
...
src/public/js/script-feeds-stat-table.js
View file @
671ec348
...
@@ -6,14 +6,12 @@ $(document).ready(function(){
...
@@ -6,14 +6,12 @@ $(document).ready(function(){
$tableBody
=
$table
.
find
(
'tbody'
).
first
(),
$tableBody
=
$table
.
find
(
'tbody'
).
first
(),
activeLines
=
[],
activeLines
=
[],
currentActiveLine
,
currentActiveLine
,
dataTable
,
currencyFields
=
[
'admoney'
,
'salemoney'
,
'usdollarmoney'
,
'localmoney'
,
'AdMoney'
,
'OrderSum'
,
'Price'
],
currencyFields
=
[
'admoney'
,
'salemoney'
,
'usdollarmoney'
,
'localmoney'
,
'AdMoney'
,
'OrderSum'
,
'Price'
],
notFormatFields
=
[
'Timestamp'
,
'Basket'
],
notFormatFields
=
[
'Timestamp'
,
'Basket'
],
dateTimeFields
=
[
'Timestamp'
,
'period'
];
dateTimeFields
=
[
'Timestamp'
,
'period'
];
// Шаблон содержимого ячейки Basket
// Шаблон содержимого ячейки Basket
var
templateBasketContent
=
_
.
template
(
'
\
n'
+
var
templateBasketContent
=
_
.
template
(
'
\
n'
+
' <div class="b-basket-content">
\
n'
+
' <div class="b-basket-content">
\
n'
+
' <table>
\
n'
+
' <table>
\
n'
+
' <tbody>
\
n'
+
' <tbody>
\
n'
+
...
@@ -27,17 +25,15 @@ $(document).ready(function(){
...
@@ -27,17 +25,15 @@ $(document).ready(function(){
' </tbody>
\
n'
+
' </tbody>
\
n'
+
' </table>
\
n'
+
' </table>
\
n'
+
' </div>
\
n'
+
' </div>
\
n'
+
''
);
''
);
// Шаблон ячейки Время-Дата
var
templateTimestampContent
=
_
.
template
(
'
\
n'
+
var
templateTimestampContent
=
_
.
template
(
'
\
n'
+
' <b><%=data.time %></b><br />
\
n'
+
' <b><%=data.time %></b><br />
\
n'
+
' <span><%=data.date %></span><br />
\
n'
+
' <span><%=data.date %></span><br />
\
n'
+
''
);
''
);
function
valueFormat
(
value
)
function
valueFormat
(
value
)
{
{
var
var
...
@@ -58,30 +54,26 @@ $(document).ready(function(){
...
@@ -58,30 +54,26 @@ $(document).ready(function(){
function
RenderInterval
(
dataLineChartStat
)
function
RenderInterval
(
dataLineChartStat
)
{
{
var
dataPeriod
=
dataLineChartStat
[
'period'
];
var
dataTable
=
dataLineChartStat
,
dataPeriod
=
dataLineChartStat
[
'period'
],
dataTableForSort
=
[],
$selectedField
=
$
(
'thead th b.selected'
,
$table
),
sortField
=
false
,
isDesc
=
true
;
dataTable
=
dataLineChartStat
;
/*
/*
dataTable = {};
dataTable = {};
for (var key in dataLineChartStat) {
for (var key in dataLineChartStat) {
dataTable[key] = dataLineChartStat[key];
dataTable[key] = dataLineChartStat[key];
}
}
console.log('AAA dataTable = ', dataLineChartStat.report);
*/
*/
// Сортировка строк в таблице:
// Определение поля для сортировки строк в таблице:
var
$selectedField
=
$
(
'#table-line thead th b.selected'
),
sortField
=
false
,
isDesc
=
true
;
if
(
$selectedField
.
length
>
0
)
{
if
(
$selectedField
.
length
>
0
)
{
sortField
=
$selectedField
.
attr
(
'id'
);
sortField
=
$selectedField
.
attr
(
'id'
);
isDesc
=
$selectedField
.
hasClass
(
'desc'
);
isDesc
=
$selectedField
.
hasClass
(
'desc'
);
}
}
//console.log('AAA sortField = ', sortField, ' isDesc = ', isDesc);
if
(
!
sortField
)
{
if
(
!
sortField
)
{
switch
(
dataLineChartStat
.
report
)
{
switch
(
dataLineChartStat
.
report
)
{
case
'common'
:
case
'common'
:
...
@@ -98,10 +90,10 @@ $(document).ready(function(){
...
@@ -98,10 +90,10 @@ $(document).ready(function(){
break
;
break
;
}
}
}
}
//console.log('AAA sortField = ', sortField, ' isDesc = ', isDesc);
var
dataTableForSort
=
[];
// Подготовка данных для сортировки:
dataPeriod
.
forEach
(
function
(
dataTableItem
,
ind
){
dataTable
.
period
.
forEach
(
function
(
dataTableItem
,
ind
){
var
dataTableSortItem
=
{};
var
dataTableSortItem
=
{};
dataTableSortItem
[
'period'
]
=
dataTableItem
;
dataTableSortItem
[
'period'
]
=
dataTableItem
;
activeLines
.
forEach
(
function
(
activeLine
){
activeLines
.
forEach
(
function
(
activeLine
){
...
@@ -110,6 +102,7 @@ $(document).ready(function(){
...
@@ -110,6 +102,7 @@ $(document).ready(function(){
dataTableForSort
.
push
(
dataTableSortItem
);
dataTableForSort
.
push
(
dataTableSortItem
);
});
});
// Сортировка данных для таблицы:
dataTableForSort
.
sort
(
function
(
a
,
b
){
dataTableForSort
.
sort
(
function
(
a
,
b
){
if
(
dateTimeFields
.
indexOf
(
sortField
)
>
-
1
)
{
if
(
dateTimeFields
.
indexOf
(
sortField
)
>
-
1
)
{
var
var
...
@@ -123,6 +116,7 @@ $(document).ready(function(){
...
@@ -123,6 +116,7 @@ $(document).ready(function(){
});
});
//console.log('AAA dataTableForSort = ', dataTableForSort);
//console.log('AAA dataTableForSort = ', dataTableForSort);
// Отрисовка таблицы:
dataTableForSort
.
forEach
(
function
(
item
){
dataTableForSort
.
forEach
(
function
(
item
){
$row
=
$
(
'<tr>'
);
$row
=
$
(
'<tr>'
);
$row
.
append
(
$
(
'<td>'
).
html
(
item
[
'period'
]));
$row
.
append
(
$
(
'<td>'
).
html
(
item
[
'period'
]));
...
@@ -150,15 +144,14 @@ $(document).ready(function(){
...
@@ -150,15 +144,14 @@ $(document).ready(function(){
$row
.
appendTo
(
$tableContent
);
$row
.
appendTo
(
$tableContent
);
});
});
// Добавляем строку "Итого" для отчета 'common':
// Добавляем строку "Итого" для отчета 'common':
if
(
dataLineChartStat
.
report
==
'common'
)
{
if
(
dataLineChartStat
.
report
==
'common'
)
{
$row
=
$
(
'<tr
style="font-weight: bold;
">'
);
$row
=
$
(
'<tr
class="total
">'
);
$row
.
append
(
$
(
'<td>'
).
html
(
"Итого"
));
$row
.
append
(
$
(
'<td>'
).
html
(
"Итого"
));
activeLines
.
forEach
(
function
(
item
){
activeLines
.
forEach
(
function
(
item
){
currentActiveLine
=
item
;
currentActiveLine
=
item
;
var
isNotSumValue
=
notFormatFields
.
indexOf
(
currentActiveLine
)
>
-
1
;
var
isNotSumValue
=
notFormatFields
.
indexOf
(
currentActiveLine
)
>
-
1
;
if
(
!
isNotSumValue
)
{
if
(
!
isNotSumValue
)
{
...
@@ -173,18 +166,16 @@ $(document).ready(function(){
...
@@ -173,18 +166,16 @@ $(document).ready(function(){
$row
.
append
(
$
(
'<td>'
).
html
(
valueFormat
(
totalValue
)));
$row
.
append
(
$
(
'<td>'
).
html
(
valueFormat
(
totalValue
)));
});
});
$row
.
appendTo
(
$tableContent
);
$row
.
appendTo
(
$tableContent
);
}
}
// Добавляем строку "Всего заказов" для отчета 'transaction':
// Добавляем строку "Всего заказов" для отчета 'transaction':
if
(
dataLineChartStat
.
report
==
'transaction'
)
{
if
(
dataLineChartStat
.
report
==
'transaction'
)
{
$row
=
$
(
'<tr class="total-orders"
style=""
>'
);
$row
=
$
(
'<tr class="total-orders">'
);
$row
.
append
(
$
(
'<td>'
).
html
(
"Всего заказов: "
+
dataPeriod
.
length
));
$row
.
append
(
$
(
'<td>'
).
html
(
"Всего заказов: "
+
dataPeriod
.
length
));
activeLines
.
forEach
(
function
(
item
){
activeLines
.
forEach
(
function
(
item
){
currentActiveLine
=
item
;
currentActiveLine
=
item
;
var
isNotSumValue
=
notFormatFields
.
indexOf
(
currentActiveLine
)
>
-
1
;
var
isNotSumValue
=
notFormatFields
.
indexOf
(
currentActiveLine
)
>
-
1
;
if
(
!
isNotSumValue
)
{
if
(
!
isNotSumValue
)
{
...
@@ -199,7 +190,6 @@ $(document).ready(function(){
...
@@ -199,7 +190,6 @@ $(document).ready(function(){
$row
.
append
(
$
(
'<td class="'
+
item
+
'">'
).
html
(
valueFormat
(
totalValue
)));
$row
.
append
(
$
(
'<td class="'
+
item
+
'">'
).
html
(
valueFormat
(
totalValue
)));
});
});
$row
.
appendTo
(
$tableContent
);
$row
.
appendTo
(
$tableContent
);
}
}
}
}
...
@@ -217,10 +207,6 @@ $(document).ready(function(){
...
@@ -217,10 +207,6 @@ $(document).ready(function(){
//console.log('AAA TableStat render: ', dataLineChartStat);
//console.log('AAA TableStat render: ', dataLineChartStat);
//console.log('AAA activeLines: ', activeLines);
//console.log('AAA activeLines: ', activeLines);
dataTable
=
{};
activeLines
.
forEach
(
function
(
item
){
dataTable
[
item
]
=
[];
});
if
(
dataLineChartStat
.
type
==
'interval'
)
{
if
(
dataLineChartStat
.
type
==
'interval'
)
{
RenderInterval
(
dataLineChartStat
);
RenderInterval
(
dataLineChartStat
);
...
...
src/public/js/script-feeds-stat.js
View file @
671ec348
...
@@ -142,11 +142,9 @@ $(document).ready(function(){
...
@@ -142,11 +142,9 @@ $(document).ready(function(){
var
$tableHeadCols
=
$
(
'#table-line thead.metric.sortable th b'
);
var
$tableHeadCols
=
$
(
'#table-line thead.metric.sortable th b'
);
$tableHeadCols
.
on
(
'click'
,
function
(){
$tableHeadCols
.
on
(
'click'
,
function
(){
var
var
$this
=
$
(
this
),
$this
=
$
(
this
);
$parent
=
$this
.
parent
(),
categoryName
=
$parent
.
data
(
'id'
);
if
(
[
'period'
,
'Basket'
].
indexOf
(
categoryName
)
>-
1
)
{
if
(
$this
.
hasClass
(
'not-sorted'
)
)
{
return
false
;
return
false
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment