subtotal.js
4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/**
* Created by DEV005 on 2015/2/26.
* 赵星
*/
angular.module("xn/template/subtotal.html",[]).run(["$templateCache", function($templateCache) {
"use strict";
$templateCache.put("xn/template/calendar/xnReceiptsTotal.html",
"<label class=\"xn-label form-total-title\">{{title}} :</label>"+
"<div class=\"form-total\">"+
"<span>{{receiptsTotal.integer[7] | moneyCharacter}}</span>"+
"<span class=\"fc-yellow-2\">仟</span>"+
"<span>{{receiptsTotal.integer[6] | moneyCharacter}}</span>"+
"<span class=\"fc-yellow-2\">佰</span>"+
"<span>{{receiptsTotal.integer[5] | moneyCharacter}}</span>"+
"<span class=\"fc-yellow-2\">拾</span>"+
"<span>{{receiptsTotal.integer[4] | moneyCharacter}}</span>"+
"<span class=\"fc-yellow-2\">万</span>"+
"<span>{{receiptsTotal.integer[3] | moneyCharacter}}</span>"+
"<span class=\"fc-yellow-2\">仟</span>"+
"<span>{{receiptsTotal.integer[2] | moneyCharacter}}</span>"+
"<span class=\"fc-yellow-2\">佰</span>"+
"<span>{{receiptsTotal.integer[1] | moneyCharacter}}</span>"+
"<span class=\"fc-yellow-2\">拾</span>"+
"<span>{{receiptsTotal.integer[0] | moneyCharacter}}</span>"+
"<span class=\"fc-yellow-2\">元</span>"+
"<span>{{receiptsTotal.decimal[0] | moneyCharacter}}</span>"+
"<span class=\"fc-yellow-2\">角</span>"+
"<span>{{receiptsTotal.decimal[1] | moneyCharacter}}</span>"+
"<span class=\"fc-yellow-2\">分</span>"+
"</div>"+
"<div class=\"total-money xn-text-right\">{{receiptsTotal.total | money}}</div>"
);
}]);
angular.module("xn.directive.subtotal",["xn/template/subtotal.html"])
.filter("moneyCharacter", [
function () {
return function (input) {
var money="";
switch (input)
{
case "0":
money="零";
break;
case "1":
money="壹";
break;
case "2":
money="贰";
break;
case "3":
money="叁";
break;
case "4":
money="肆";
break;
case "5":
money="伍";
break;
case "6":
money="陆";
break;
case "7":
money="柒";
break;
case "8":
money="捌";
break;
case "9":
money="玖";
break;
default :
money="/";
break;
}
return money;
};
}
])
.directive('xnReceiptsTotal',function() {
return {
restrict: "A",
templateUrl: "xn/template/calendar/xnReceiptsTotal.html",
scope: {receiptsTotal:'=ngModel',
title:"@title"},
require: "?ngModel",
link: function (scope, elem, attrs, ngModel) {
if (!ngModel) return;
var receiptsTotal = scope.receiptsTotal={list:[],odd:[],total:{},decimal:{},integer:{}};
attrs.$observe("sumAmount", function (value){
if(!scope.title){
scope.title="合计金额";
}
scope.receiptsTotal.total=angular.copy(value);
scope.receiptsTotal.odd =Number(value).toFixed(2).toString().split("");
scope.receiptsTotal.integer= scope.receiptsTotal.odd.slice(0,-3);
scope.receiptsTotal.decimal= scope.receiptsTotal.odd.slice(-2);
scope.receiptsTotal.integer.reverse();
});
}
}
});