|
|
@@ -39,7 +39,10 @@ angular.module('app.business')
|
|
39
|
39
|
$scope.loadData();
|
|
40
|
40
|
}
|
|
41
|
41
|
|
|
42
|
|
- //新增、查看、修改
|
|
|
42
|
+ /**
|
|
|
43
|
+ * 新增、查看、修改
|
|
|
44
|
+ * jslx: 0是入库,1是出库
|
|
|
45
|
+ */
|
|
43
|
46
|
$scope.edit = function(id, butType) {
|
|
44
|
47
|
$state.go('app.business.rkjslist.edit',{id:id, butType:butType, jslx: $stateParams.jslx});
|
|
45
|
48
|
}
|
|
|
@@ -57,12 +60,13 @@ angular.module('app.business')
|
|
57
|
60
|
}
|
|
58
|
61
|
|
|
59
|
62
|
})
|
|
60
|
|
-.controller("jsglEditCtrl", function($scope, $http, $filter, $state, $rootScope, $stateParams, APP_CONFIG, jsglService, warehouseService) {
|
|
|
63
|
+.controller("jsglEditCtrl", function($scope, $http, $filter, $state, $rootScope, $stateParams, $uibModal, APP_CONFIG, jsglService, warehouseService, customerService ) {
|
|
61
|
64
|
var id = $stateParams.id;
|
|
62
|
65
|
var butType = $stateParams.butType;
|
|
63
|
66
|
$scope.jslx = $stateParams.jslx;
|
|
64
|
67
|
if ($scope.jslx == "0") {
|
|
65
|
68
|
$scope.top_title = "入库结算详情";
|
|
|
69
|
+
|
|
66
|
70
|
} else if ($scope.jslx == "1") {
|
|
67
|
71
|
$scope.top_title = "出库结算详情";
|
|
68
|
72
|
}
|
|
|
@@ -102,6 +106,147 @@ angular.module('app.business')
|
|
102
|
106
|
} else {
|
|
103
|
107
|
$scope.jsgl.bcjssj = $filter('date')(new Date(), "yyyy-MM-dd HH:mm:ss");
|
|
104
|
108
|
$scope.jsgl.fkdw = $rootScope.orgInfo.orgName;
|
|
|
109
|
+ $scope.jsgl.orgId = $rootScope.orgInfo.orgId;
|
|
|
110
|
+ $scope.jsgl.jslx = $scope.jslx;
|
|
|
111
|
+ $scope.jsgl.fpzt = "1"; //发票状态默认1正常
|
|
|
112
|
+ $scope.jsgl.bcjsfs = "1"; //付款方式默认1转账
|
|
|
113
|
+ }
|
|
|
114
|
+
|
|
|
115
|
+ $scope.getReceiveContract = function() {
|
|
|
116
|
+ var params = [];
|
|
|
117
|
+ if ($scope.jslx == "0") {//入库
|
|
|
118
|
+ params.htlx = "0";
|
|
|
119
|
+ } else if ($scope.jslx == "1") {//出库
|
|
|
120
|
+ params.htlx = "1";
|
|
|
121
|
+ } else {
|
|
|
122
|
+ alert("系统异常,请联系管理员!");
|
|
|
123
|
+ return;
|
|
|
124
|
+ }
|
|
|
125
|
+ var uibModalInstance = $uibModal.open({
|
|
|
126
|
+ size:'lg',
|
|
|
127
|
+ templateUrl: 'app/business/deliveryStorageNotice/views/receiveContract-list-modal.html',
|
|
|
128
|
+ controller: 'receiveContractListModalCtrl',
|
|
|
129
|
+ resolve: {
|
|
|
130
|
+ // items是一个回调函数
|
|
|
131
|
+ items: function () {
|
|
|
132
|
+ // 这个值会被模态框的控制器获取到
|
|
|
133
|
+ return params;
|
|
|
134
|
+ }
|
|
|
135
|
+ }
|
|
|
136
|
+ });
|
|
|
137
|
+ uibModalInstance.result.then(function (result) {
|
|
|
138
|
+ if (result != null) {
|
|
|
139
|
+ // 获取明细信息.
|
|
|
140
|
+ $scope.jsgl.htid = result.id;
|
|
|
141
|
+ $scope.jsgl.htbh = result.htbh;
|
|
|
142
|
+ $scope.jsgl.htzsl = result.htzsl;
|
|
|
143
|
+ $scope.jsgl.yjssl = result.yjssl;
|
|
|
144
|
+ $scope.jsgl.houseId = result.houseId;
|
|
|
145
|
+ $scope.jsgl.warehouseId = result.warehouseId;
|
|
|
146
|
+ if (result.warehouseId != null) {
|
|
|
147
|
+ $scope.loadWare(result.houseId);
|
|
|
148
|
+ }
|
|
|
149
|
+ $scope.jsgl.lypz = result.lypz;
|
|
|
150
|
+ $scope.jsgl.mxpz = result.mxpz;
|
|
|
151
|
+ $scope.jsgl.lyxz = result.lyxz;
|
|
|
152
|
+ $scope.jsgl.bcjsdj = result.htdj;
|
|
|
153
|
+ $scope.getCustomer(result.khid);
|
|
|
154
|
+ }
|
|
|
155
|
+ }, function (reason) {
|
|
|
156
|
+ console.log(reason);
|
|
|
157
|
+ });
|
|
|
158
|
+ }
|
|
|
159
|
+
|
|
|
160
|
+ /**
|
|
|
161
|
+ * 获取客户信息
|
|
|
162
|
+ * @param khid 客户ID
|
|
|
163
|
+ */
|
|
|
164
|
+ $scope.getCustomer = function(khid) {
|
|
|
165
|
+ customerService.loadDataById(khid).then(function(data){
|
|
|
166
|
+ $scope.jsgl.customerId = data.id;
|
|
|
167
|
+ // 收付款人赋值客户姓名.
|
|
|
168
|
+ $scope.jsgl.sfkr = data.name;
|
|
|
169
|
+ //开户行名称
|
|
|
170
|
+ $scope.jsgl.khhmc = data.bankName;
|
|
|
171
|
+ //开户行号
|
|
|
172
|
+ $scope.jsgl.khhh = data.khhh;
|
|
|
173
|
+ //银行账号
|
|
|
174
|
+ $scope.jsgl.yhzh = data.accountNumber;
|
|
|
175
|
+ //收付款人身份证号赋值社会信用代码
|
|
|
176
|
+ $scope.jsgl.skrsfzh = data.socialCreditCode;
|
|
|
177
|
+ //付款单位
|
|
|
178
|
+ $scope.jsgl.fkdw = $rootScope.orgInfo.orgName;
|
|
|
179
|
+ }, function (data) {
|
|
|
180
|
+ console.log(data);
|
|
|
181
|
+ });
|
|
|
182
|
+ }
|
|
|
183
|
+
|
|
|
184
|
+ /**
|
|
|
185
|
+ * 计算本次结算金额 = 本次结算数量 * 本次结算单价
|
|
|
186
|
+ * 保留两位小数
|
|
|
187
|
+ */
|
|
|
188
|
+ $scope.calculate = function() {
|
|
|
189
|
+ var bcjssl = $scope.jsgl.bcjssl;
|
|
|
190
|
+ var bcjsdj = $scope.jsgl.bcjsdj;
|
|
|
191
|
+ var re = /^([0-9]+.[0-9]{3})[0-9]*/;
|
|
|
192
|
+ if(bcjssl !== undefined && bcjssl !== "" && bcjssl != null) {
|
|
|
193
|
+ bcjssl = bcjssl.toString().replace(re,"$1");
|
|
|
194
|
+ bcjssl = parseFloat(bcjssl);
|
|
|
195
|
+ $scope.jsgl.bcjssl = bcjssl;
|
|
|
196
|
+ } else {
|
|
|
197
|
+ return;
|
|
|
198
|
+ }
|
|
|
199
|
+ if(bcjsdj !== undefined && bcjsdj !== "" && bcjsdj != null) {
|
|
|
200
|
+ bcjsdj = bcjsdj.toString().replace(re,"$1");
|
|
|
201
|
+ bcjsdj = parseFloat(bcjsdj);
|
|
|
202
|
+ $scope.jsgl.bcjsdj = bcjsdj;
|
|
|
203
|
+ } else {
|
|
|
204
|
+ return;
|
|
|
205
|
+ }
|
|
|
206
|
+
|
|
|
207
|
+ /**
|
|
|
208
|
+ *
|
|
|
209
|
+ */
|
|
|
210
|
+ var bcjsje = $scope.jsgl.bcjssl * 1000 * $scope.jsgl.bcjsdj * 1000 / 1000000;
|
|
|
211
|
+ $scope.jsgl.bcjsje = $scope.getMath(bcjsje, 2);
|
|
|
212
|
+ }
|
|
|
213
|
+
|
|
|
214
|
+ //将v四舍五入,且保留n位小数
|
|
|
215
|
+ $scope.getMath = function(v, n) {
|
|
|
216
|
+ if (isNaN(v) || v == "") {
|
|
|
217
|
+ if (isNaN(n) || v == "") {
|
|
|
218
|
+ v = "0.00";
|
|
|
219
|
+ } else if (n == 0) {
|
|
|
220
|
+ v = "0";
|
|
|
221
|
+ } else {
|
|
|
222
|
+ v = "";
|
|
|
223
|
+ for (var i = 1; i <= n; i++) {
|
|
|
224
|
+ if (i == 1) {
|
|
|
225
|
+ v = "0.0";
|
|
|
226
|
+ } else {
|
|
|
227
|
+ v = v+"0";
|
|
|
228
|
+ }
|
|
|
229
|
+ }
|
|
|
230
|
+ }
|
|
|
231
|
+ } else {
|
|
|
232
|
+ v = Math.round(v*100)/100;
|
|
|
233
|
+ v = v.toString();
|
|
|
234
|
+ var rs = v.indexOf('.');
|
|
|
235
|
+ if (rs < 0) {
|
|
|
236
|
+ if (n > 0) {
|
|
|
237
|
+ for (var i = 1; i <= n; i++) {
|
|
|
238
|
+ if (i == 1) {
|
|
|
239
|
+ v = v+".0";
|
|
|
240
|
+ } else {
|
|
|
241
|
+ v = v+"0";
|
|
|
242
|
+ }
|
|
|
243
|
+ }
|
|
|
244
|
+ }
|
|
|
245
|
+ }else{
|
|
|
246
|
+ while(v.length <= rs + n){v += '0';}
|
|
|
247
|
+ }
|
|
|
248
|
+ }
|
|
|
249
|
+ return v;
|
|
105
|
250
|
}
|
|
106
|
251
|
|
|
107
|
252
|
// 返回.
|
|
|
@@ -117,22 +262,26 @@ angular.module('app.business')
|
|
117
|
262
|
}
|
|
118
|
263
|
}
|
|
119
|
264
|
|
|
|
265
|
+ var validator = $("#jsgl-form").validate();
|
|
|
266
|
+
|
|
120
|
267
|
//保存(0:保存,1:提交)
|
|
121
|
268
|
$scope.save = function(czlx) {
|
|
122
|
269
|
$scope.jsgl.dataStatus = czlx;
|
|
123
|
|
- jsglService.saveData($scope.jsgl).then(function(data){
|
|
124
|
|
- if (data.status == "200") {
|
|
125
|
|
- alert("操作成功!");
|
|
126
|
|
- } else {
|
|
127
|
|
- alert("操作失败!");
|
|
128
|
|
- }
|
|
129
|
|
- if ($scope.jslx=="0") {
|
|
130
|
|
- $state.go('app.business.rkjslist');
|
|
131
|
|
- } else if ($scope.jslx=="1") {
|
|
132
|
|
- $state.go('app.business.ckjslist');
|
|
133
|
|
- }
|
|
134
|
|
- },function(data){
|
|
135
|
|
- console.log(data);
|
|
136
|
|
- });
|
|
|
270
|
+ if (validator.form()) {
|
|
|
271
|
+ jsglService.saveData($scope.jsgl).then(function(data){
|
|
|
272
|
+ if (data.status == "200") {
|
|
|
273
|
+ alert("操作成功!");
|
|
|
274
|
+ } else {
|
|
|
275
|
+ alert("操作失败!");
|
|
|
276
|
+ }
|
|
|
277
|
+ if ($scope.jslx=="0") {
|
|
|
278
|
+ $state.go('app.business.rkjslist');
|
|
|
279
|
+ } else if ($scope.jslx=="1") {
|
|
|
280
|
+ $state.go('app.business.ckjslist');
|
|
|
281
|
+ }
|
|
|
282
|
+ },function(data){
|
|
|
283
|
+ console.log(data);
|
|
|
284
|
+ });
|
|
|
285
|
+ }
|
|
137
|
286
|
}
|
|
138
|
287
|
})
|