educode_sales 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/educode_sales/businesses_controller.rb +1 -1
  3. data/app/controllers/educode_sales/invoices_controller.rb +219 -0
  4. data/app/controllers/educode_sales/money_plan_records_controller.rb +13 -0
  5. data/app/controllers/educode_sales/sale_trends_controller.rb +2 -2
  6. data/app/models/educode_sales/business.rb +4 -0
  7. data/app/models/educode_sales/invoice.rb +5 -0
  8. data/app/models/educode_sales/invoice_apply.rb +12 -0
  9. data/app/models/educode_sales/invoice_detail.rb +10 -0
  10. data/app/models/educode_sales/staff.rb +2 -0
  11. data/app/views/educode_sales/contracts/_list.html.erb +1 -1
  12. data/app/views/educode_sales/invoices/_apply_records.html.erb +276 -0
  13. data/app/views/educode_sales/invoices/apply.html.erb +443 -0
  14. data/app/views/educode_sales/invoices/apply_records.js.erb +1 -0
  15. data/app/views/educode_sales/invoices/apply_records.json.jbuilder +20 -0
  16. data/app/views/educode_sales/invoices/details.json.jbuilder +17 -0
  17. data/app/views/educode_sales/invoices/list.json.jbuilder +14 -0
  18. data/app/views/educode_sales/invoices/new.html.erb +177 -0
  19. data/app/views/educode_sales/invoices/sales_details.html.erb +88 -0
  20. data/app/views/educode_sales/invoices/sales_details.json.jbuilder +14 -0
  21. data/app/views/educode_sales/money_plan_records/_index.html.erb +35 -8
  22. data/app/views/educode_sales/money_plans/_index.html.erb +138 -169
  23. data/app/views/educode_sales/money_plans/list.html.erb +2 -1
  24. data/app/views/layouts/educode_sales/application.html.erb +245 -236
  25. data/config/routes.rb +16 -0
  26. data/db/migrate/20230531144834_create_educode_sales_invoice_applies.rb +25 -0
  27. data/db/migrate/20230601011835_create_educode_sales_invoices.rb +14 -0
  28. data/db/migrate/20230601011943_create_educode_sales_invoice_details.rb +20 -0
  29. data/lib/educode_sales/version.rb +1 -1
  30. metadata +19 -3
@@ -0,0 +1,443 @@
1
+ <div style="padding:10px">
2
+ <div class="layui-form layuimini-form" lay-filter="searchform">
3
+ <div class="layui-form-item">
4
+ <div class="layui-inline">
5
+ <label class="layui-form-label required" style="width: 80px !important;">合同名称:</label>
6
+ <div class="layui-inline">
7
+ <div id="business_app" style="width:500px;"></div>
8
+ </div>
9
+ </div>
10
+ <div class="layui-inline">
11
+ <label class="layui-form-label" style="width:150px;">合同金额:</label>
12
+ <div class="layui-inline" style="line-height: 38px;" id="total_amount">
13
+ <%= @invoice_apply ? @invoice_apply.business.actual_amount : 0 %>
14
+ </div>
15
+ </div>
16
+ </div>
17
+ <div class="layui-form-item">
18
+ <div class="layui-inline">
19
+ <label class="layui-form-label" style="width:150px;">已开票金额:</label>
20
+ <div class="layui-input-inline" style="line-height: 38px;" id="pass_amount">
21
+ <%= @invoice_apply ? @invoice_apply.invoice_details.passed.sum(:amount) : 0 %>
22
+ </div>
23
+ </div>
24
+ <div class="layui-inline">
25
+ <label class="layui-form-label" style="width:150px;">本次开票金额:</label>
26
+ <div class="layui-input-inline" style="line-height: 38px;" id="current_amount">
27
+ </div>
28
+ </div>
29
+ <div class="layui-inline">
30
+ <label class="layui-form-label" style="width:150px;">剩余可开票金额:</label>
31
+ <div class="layui-input-inline" style="line-height: 38px;" id="residuea_mount">
32
+ </div>
33
+ </div>
34
+ </div>
35
+ <div class="layui-form-item">
36
+ <div class="layui-inline">
37
+ <label class="layui-form-label required">发票类型:</label>
38
+ <div class="layui-input-inline">
39
+ <%= select_tag "invoice_category", options_for_select(EducodeSales::InvoiceApply.categories.keys), { 'lay-filter': 'category', 'lay-verify': "required", include_blank: true, "lay-search": "" } %>
40
+ </div>
41
+ </div>
42
+ <div class="layui-inline">
43
+ <label class="layui-form-label required" style="width:150px;">是否退税产品:</label>
44
+ <div class="layui-input-inline">
45
+ <div class="layui-input-inline">
46
+ <%= select_tag "is_tax_rebate", options_for_select([['是', true], ['否', false]], @invoice_apply&.is_tax_rebate), { 'lay-filter': 'category', 'lay-verify': "required", include_blank: true, "lay-search": "" } %>
47
+ </div>
48
+ </div>
49
+ </div>
50
+ <div class="layui-inline">
51
+ <label class="layui-form-label required" style="width:150px;">出票需求时间:</label>
52
+ <div class="layui-input-inline">
53
+ <div class="layui-input-inline">
54
+ <input type="text" name="ticket_at" value="<%= @invoice_apply&.ticket_at %>" class="layui-input" lay-verify="required" id="ticket_at">
55
+ </div>
56
+ </div>
57
+ </div>
58
+ </div>
59
+ <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
60
+ <legend>开票信息</legend>
61
+ </fieldset>
62
+
63
+ <div class="layui-form-item">
64
+ <div class="layui-inline">
65
+ <label class="layui-form-label required" style="width:150px;">名称:</label>
66
+ <div class="layui-input-inline" style="line-height: 38px;">
67
+ <input type="text" name="name" class="layui-input">
68
+ </div>
69
+ </div>
70
+ <div class="layui-inline">
71
+ <label class="layui-form-label required" style="width:150px;">纳税人识别号:</label>
72
+ <div class="layui-input-inline" style="line-height: 38px;">
73
+ <input type="text" name="taxpaper_number" class="layui-input">
74
+ </div>
75
+ </div>
76
+ <div class="layui-inline">
77
+ <label class="layui-form-label required" style="width:150px;">地址:</label>
78
+ <div class="layui-input-inline" style="line-height: 38px;">
79
+ <input type="text" name="address" class="layui-input">
80
+ </div>
81
+ </div>
82
+ <div class="layui-inline">
83
+ <label class="layui-form-label required" style="width:150px;">电话:</label>
84
+ <div class="layui-input-inline" style="line-height: 38px;">
85
+ <input type="text" name="phone" class="layui-input">
86
+ </div>
87
+ </div>
88
+ <div class="layui-inline">
89
+ <label class="layui-form-label required" style="width:150px;">开户行:</label>
90
+ <div class="layui-input-inline" style="line-height: 38px;">
91
+ <input type="text" name="bank" class="layui-input">
92
+ </div>
93
+ </div>
94
+ <div class="layui-inline">
95
+ <label class="layui-form-label required" style="width:150px;">开户行账号:</label>
96
+ <div class="layui-input-inline" style="line-height: 38px;">
97
+ <input type="text" name="bank_number" class="layui-input">
98
+ </div>
99
+ </div>
100
+ </div>
101
+
102
+ <div id="invoices_passed">
103
+ <table class="layui-hide" id="invoices_details_pass_table" lay-filter="invoices_details_pass_table"></table>
104
+ </div>
105
+
106
+ <div id="invoices_details">
107
+ <table class="layui-hide" id="invoices_details_table" lay-filter="invoices_details_table"></table>
108
+ </div>
109
+ <div class="layui-form-item">
110
+ <div class="layui-input-block">
111
+ <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveInvoiceApply">保存</button>
112
+ </div>
113
+ </div>
114
+ </div>
115
+ </div>
116
+ <script type="text/html" id="toolbar_invoices_apply">
117
+ <div class="layui-btn-container">
118
+ <span class="table-label">已开票记录</span>
119
+ </div>
120
+ </script>
121
+ <script type="text/html" id="toolbar_invoices_apply_detail">
122
+ <div class="layui-btn-container">
123
+ <span class="table-label">开票明细</span>
124
+ <a class="layui-btn layui-btn-normal layui-btn-sm" style="margin-left: 20px;" lay-event="add_detail">添加明细</a>
125
+ </div>
126
+ </script>
127
+ <script type="text/html" id="select_category_temp" >
128
+ <select name="category" lay-filter="select_category" data-value={{d.category}} >
129
+ <option value=""></option>
130
+ <option value="软件" selected="{{d.category == '软件'}}">软件</option>
131
+ <option value="技术服务" selected="{{d.category == '技术服务'}}">技术服务</option>
132
+ <option value="硬件" selected="{{d.category == '硬件'}}">硬件</option>
133
+ <option value="装修服务" selected="{{d.category == '装修服务'}}">装修服务</option>
134
+ <option value="咨询服务" selected="{{d.category == '咨询服务'}}">咨询服务</option>
135
+ <option value="会议服务" selected="{{d.category == '会议服务'}}">会议服务</option>
136
+ </select>
137
+ </script>
138
+ <script>
139
+
140
+ layui.use(['form', 'table', 'upload', 'laytpl', 'request', 'laydate', 'selectInput'], function() {
141
+ var form = layui.form,
142
+ layer = layui.layer,
143
+ table = layui.table,
144
+ laydate = layui.laydate,
145
+ laytpl = layui.laytpl,
146
+ request = layui.request,
147
+ selectInput = layui.selectInput,
148
+ $ = layui.$;
149
+ form.render();
150
+
151
+
152
+ laydate.render({
153
+ elem: '#ticket_at',
154
+ });
155
+
156
+
157
+ var invoices_details_pass_table = table.render({
158
+ elem: '#invoices_details_pass_table',
159
+ // url: '/missions/invoices/details',
160
+ autoSort: false,
161
+ defaultToolbar: [],
162
+ title: '已开票记录',
163
+ data: [],
164
+ totalRow: true,
165
+ cols: [
166
+ [{
167
+ field: 'category',
168
+ width: 100,
169
+ title: '类别',
170
+ totalRowText: '合计'
171
+ },
172
+ {
173
+ field: 'name',
174
+ width: 200,
175
+ title: '货物或应税劳务名称',
176
+ },
177
+ {
178
+ field: 'specification',
179
+ width: 120,
180
+ title: '规格型号',
181
+ },
182
+ {
183
+ field: 'unit',
184
+ width: 150,
185
+ title: '单位',
186
+ },
187
+ {
188
+ field: 'num',
189
+ width: 150,
190
+ title: '数量',
191
+ },
192
+ {
193
+ field: 'amount',
194
+ width: 150,
195
+ title: '开票金额',
196
+ totalRow: true,
197
+ },
198
+ {
199
+ field: 'state',
200
+ width: 150,
201
+ title: '开票状态',
202
+ }]
203
+ ],
204
+ toolbar: '#toolbar_invoices_apply',
205
+ page: false,
206
+ skin: 'line'
207
+ });
208
+
209
+ var invoices_details_table = table.render({
210
+ elem: '#invoices_details_table',
211
+ autoSort: false,
212
+ data: [],
213
+ height: 400,
214
+ defaultToolbar: [],
215
+ title: '开票明细',
216
+ totalRow: true,
217
+ cols: [
218
+ [{
219
+ field: 'category',
220
+ width: 180,
221
+ title: '类别',
222
+ templet: '#select_category_temp',
223
+ totalRowText: '合计'
224
+ },
225
+ {
226
+ field: 'name',
227
+ width: 200,
228
+ edit: true,
229
+ title: '货物或应税劳务名称',
230
+ },
231
+ {
232
+ field: 'specification',
233
+ width: 120,
234
+ edit: true,
235
+ title: '规格型号',
236
+ },
237
+ {
238
+ field: 'unit',
239
+ width: 120,
240
+ edit: true,
241
+ title: '单位',
242
+ },
243
+ {
244
+ field: 'num',
245
+ width: 150,
246
+ edit: true,
247
+ title: '数量',
248
+ },
249
+ {
250
+ field: 'price',
251
+ width: 150,
252
+ edit: true,
253
+ title: '单价',
254
+ },
255
+ {
256
+ field: 'amount',
257
+ width: 150,
258
+ edit: true,
259
+ title: '开票金额',
260
+ totalRow: true,
261
+ }]
262
+ ],
263
+ toolbar: '#toolbar_invoices_apply_detail',
264
+ page: false,
265
+ skin: 'line',
266
+ done: function (res, curr, count) {
267
+ res.data.forEach(function (item, index) {//根据已有的值回填下拉框
268
+ layui.each($("select[name='category']", ""), function (index, item) {
269
+ var elem = $(item);
270
+ elem.next().children().children()[0].defaultValue = elem.data('value');
271
+ //elem.val(elem.data('value'));
272
+ });
273
+ })
274
+ table.render('select');
275
+ }
276
+ });
277
+
278
+ form.on('select(select_category)', function(data){
279
+ var elem = data.othis.parents('tr');
280
+ var dataindex = elem.attr("data-index");
281
+ var tabledata = table.cache["invoices_details_table"];
282
+ $.each(tabledata,function(index,value){
283
+ if(value.LAY_TABLE_INDEX==dataindex){
284
+ tabledata[index]["category"] = data.value;
285
+ // table.reload("invoices_details_table", {
286
+ // data: tabledata,
287
+ // })
288
+ }
289
+ });
290
+ });
291
+
292
+ if (parent.business_id) {
293
+ loadData();
294
+ business_id = parent.business_id;
295
+ } else {
296
+ business_id = "";
297
+ }
298
+
299
+
300
+ business_select = selectInput.render({
301
+ elem: '#business_app',
302
+ name: 'bussiness_name', // 渲染的input的name值
303
+ layFilter: 'test', //同layui form参数lay-filter
304
+ layVerType: 'tips', // 同layui form参数lay-verType
305
+ layReqText: '请填写文本', //同layui form参数lay-ReqText
306
+ hasSelectIcon: false,
307
+ initValue: parent.business_id ? parent.business_id : '',
308
+ data: parent.business ? parent.business : [],
309
+ placeholder: '请输入合同名称', // 渲染的inputplaceholder值
310
+ remoteSearch: true, // 是否启用远程搜索 默认是false,和远程搜索回调保存同步
311
+ remoteMethod: function (value, cb) { // 远程搜索的回调函数
312
+ if (!value) {
313
+ business_id = "";
314
+ return cb([]);
315
+ }
316
+ request.get('missions/search_contracts?q=' + value, {}, function (res) {
317
+ if (res.data.length == 0) {
318
+ business_select.emptyValue();
319
+ return cb([])
320
+ }
321
+ return cb(res)
322
+ })
323
+ },
324
+
325
+ });
326
+
327
+
328
+ business_select.on('itemSelect(business_app)', function (obj) {
329
+ business_id = obj.data;
330
+ loadData();
331
+ });
332
+
333
+ function loadData() {
334
+ request.get("missions/invoices/invoice_amount?id="+ business_id, {}, function(res) {
335
+ total_amount.innerText = res.actual_amount;
336
+ $("#pass_amount")[0].innerText = res.invoice_pass;
337
+ residuea_mount = parseFloat(total_amount.innerText) - parseFloat($("#pass_amount")[0].innerText) - parseFloat(current_amount.innerText || 0)
338
+ form.val('searchform', res)
339
+ })
340
+
341
+ table.reload("invoices_details_pass_table", {
342
+ url: '/missions/invoices/details?id=' + business_id,
343
+ })
344
+
345
+ }
346
+
347
+ table.on('edit(invoices_details_table)', function(obj){
348
+ if (['num','price'].includes(obj.field)) {
349
+ obj.data.amount = (parseFloat(obj.data.num) * parseFloat(obj.data.price)).toFixed(2)
350
+ }
351
+ obj.update(obj.data)
352
+ calAmount()
353
+ })
354
+
355
+ table.on('toolbar(invoices_details_table)', function(obj) {
356
+ if (business_id == '') {
357
+ layer.msg('请选择合同')
358
+ return false;
359
+ }
360
+ if (obj.event === 'add_detail') { // 监听添加操作
361
+ var content = miniPage.getHrefContent('/missions/invoices/' + business_id + "/sales_details")
362
+ var openWH = miniPage.getOpenWidthHeight();
363
+ deteilIndex = layer.open({
364
+ title: '添加开票明细',
365
+ type: 1,
366
+ shade: 0.2,
367
+ maxmin: true,
368
+ shadeClose: true,
369
+ area: [openWH[0] + 'px', openWH[1] + 'px'],
370
+ offset: [openWH[2] + 'px', openWH[3] + 'px'],
371
+ content: content
372
+ });
373
+ $(window).on("resize", function() {
374
+ layer.full(deteilIndex);
375
+ });
376
+ }
377
+ });
378
+
379
+ calAmount = function() {
380
+ var amount = 0
381
+ table.getData('invoices_details_table').forEach(function(d) {
382
+ amount += parseFloat(d.amount || 0)
383
+ })
384
+ current_amount.innerText = amount;
385
+ residuea_mount.innerText = parseFloat(total_amount.innerText) - parseFloat(pass_amount) - parseFloat(current_amount.innerText)
386
+ }
387
+
388
+
389
+ form.on('submit(saveInvoiceApply)', function(data) {
390
+ data.field.business_id = business_select.getValue() || business_id;
391
+ data.field.category = data.field.invoice_category;
392
+ if (data.field.business_id == '') {
393
+ layer.msg('请选择合同')
394
+ return false;
395
+ }
396
+ var is_valid = true;
397
+ table.getData('invoices_details_table').forEach(function(d) {
398
+
399
+ if (d.category == "") {
400
+ is_valid = false;
401
+ layer.msg('类别不能为空')
402
+ return false;
403
+ } else if (d.specification == "" || d.unit == "" || d.num == "" || d.price == "" || d.amount == "") {
404
+ layer.msg('明细内容不能为空')
405
+ is_valid = false;
406
+ return false;
407
+ }
408
+ })
409
+ if (is_valid) {
410
+ data.field.details = table.getData('invoices_details_table');
411
+
412
+ request.post("missions/invoices/create_apply", data.field, function(res) {
413
+ layer.close(parent.sindex)
414
+ parent.table.reload('apply_invoice_table')
415
+ })
416
+ }
417
+
418
+
419
+ return false;
420
+ });
421
+ });
422
+ </script>
423
+
424
+ <style>
425
+ .layui-table-cell {
426
+ overflow: visible;
427
+ }
428
+
429
+ .layui-table-box {
430
+ overflow: visible;
431
+ }
432
+
433
+ .layui-table-body {
434
+ overflow: visible;
435
+ }
436
+ /* 设置下拉框的高度与表格单元相同 */
437
+
438
+ td .layui-form-select {
439
+ margin-top: -10px;
440
+ margin-left: -15px;
441
+ margin-right: -15px;
442
+ }
443
+ </style>
@@ -0,0 +1 @@
1
+ $("#invoice_wraper").html("<%= j render 'apply_records' %>");
@@ -0,0 +1,20 @@
1
+ json.data do
2
+ json.array! @data do |d|
3
+ json.id d.id
4
+ json.number d.number
5
+ json.business_name d.business.name
6
+ json.business_number d.business.number
7
+ json.created_at d.created_at.to_s(:date)
8
+ json.take_ticket d.take_ticket&.name || ''
9
+ json.business_id d.business_id
10
+ json.school d.business.school&.name
11
+ json.staff d.staff.name
12
+ json.state d.state
13
+ json.delivery d.delivery
14
+ json.amount d.invoice_details.sum(:amount)
15
+ json.invoices_count d.invoices_count || 0
16
+ end
17
+ end
18
+
19
+ json.code 0
20
+ json.count @data.total_count
@@ -0,0 +1,17 @@
1
+ json.data do
2
+ json.array! @data do |d|
3
+ json.id d.id
4
+ json.category d.category
5
+ json.name d.name
6
+ json.specification d.specification
7
+ json.num d.num
8
+ json.amount d.amount
9
+ json.unit d.unit
10
+ json.price d.price
11
+ json.date d.state
12
+ json.state d.state
13
+ end
14
+ end
15
+
16
+ json.code 0
17
+ json.count @data.total_count
@@ -0,0 +1,14 @@
1
+ json.data do
2
+ json.array! @data do |d|
3
+ json.id d.id
4
+ json.number d.number
5
+ json.no_tax_amount d.no_tax_amount
6
+ json.taxt_amount d.taxt_amount
7
+ json.amount d.amount
8
+ json.date_at d.date_at.to_s(:date)
9
+ json.created_at d.created_at.to_s(:date)
10
+ end
11
+ end
12
+
13
+ json.code 0
14
+ json.count @data.total_count
@@ -0,0 +1,177 @@
1
+ <div class="layuimini-main edit-table" >
2
+ <div class="layui-form layuimini-form" lay-filter="add_invoice_form">
3
+ <fieldset class="table-search-fieldset">
4
+ <legend>添加发票信息</legend>
5
+ <div class="layui-form-item">
6
+ <div class="layui-input-inline" style="width: 300px;">
7
+ <label class="layui-form-label required">发票号码</label>
8
+ <div class="layui-input-block">
9
+ <input type="text" name="number" autocomplete="off" placeholder="请输入发票号码" class="layui-input" lay-verify="required">
10
+ </div>
11
+ </div>
12
+ <div class="layui-input-inline" style="width: 300px;" id="professional_title_div">
13
+ <label class="layui-form-label required">未税金额</label>
14
+ <div class="layui-input-block">
15
+ <input type="text" name="no_tax_amount" autocomplete="off" placeholder="请输入未税金额" class="layui-input" lay-verify="required">
16
+ </div>
17
+ </div>
18
+ </div>
19
+ <div class="layui-form-item">
20
+ <div class="layui-input-inline" style="width: 300px;">
21
+ <label class="layui-form-label required">税额</label>
22
+ <div class="layui-input-block">
23
+ <input type="text" name="taxt_amount" autocomplete="off" placeholder="请输入税额" class="layui-input" lay-verify="required">
24
+ </div>
25
+ </div>
26
+ <div class="layui-input-inline" style="width: 300px;">
27
+ <label class="layui-form-label required">发票金额</label>
28
+ <div class="layui-input-block">
29
+ <input type="text" name="amount" autocomplete="off" placeholder="请输入发票金额" class="layui-input" lay-verify="required">
30
+ </div>
31
+ </div>
32
+ </div>
33
+ <div class="layui-form-item">
34
+ <div class="layui-input-inline" style="width: 300px;">
35
+ <label class="layui-form-label required">开票日期</label>
36
+ <div class="layui-input-block" style="width: 190px;">
37
+ <input type="text" class="layui-input" name="date_at" autocomplete="off" lay-verify="required" id="date_at" placeholder="请选择开票日期">
38
+ </div>
39
+ </div>
40
+ </div>
41
+ <div class="layui-form-item">
42
+ <div class="layui-input-block">
43
+ <button class="layui-btn layui-btn-normal" lay-submit lay-filter="add_invoice_btn">提交</button>
44
+ </div>
45
+ </div>
46
+ </fieldset>
47
+ </div>
48
+ <h4 class="m-t-10">发票信息列表</h4>
49
+ <table class="layui-hide" id="invoice_table" style="min-height: 300px;" lay-filter="invoice_table"></table>
50
+ </div>
51
+
52
+ <script type="text/html" id="invoice_toolbar">
53
+ <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">保存</a>
54
+ <a class="layui-btn layui-btn-danger layui-btn-xs data-count-edit" lay-event="delete">删除</a>
55
+ </script>
56
+ <script>
57
+ layui.use(['form', 'table', 'upload', 'laytpl', 'request', 'laydate', 'selectInput'], function () {
58
+ var form = layui.form,
59
+ layer = layui.layer,
60
+ table = layui.table,
61
+ laytpl = layui.laytpl,
62
+ laydate = layui.laydate,
63
+ miniPage = layui.miniPage,
64
+ request = layui.request,
65
+ selectInput = layui.selectInput,
66
+ $ = layui.$;
67
+
68
+ form.render();
69
+ laydate.render({
70
+ elem: '#date_at'
71
+ })
72
+
73
+ var invoice_apply_id = parent.invoice_apply_id;
74
+ form.on('submit(add_invoice_btn)', function (data) {
75
+ data.field.invoice_apply_id = invoice_apply_id;
76
+ request.authPost("missions/invoices", data.field, function (res) {
77
+ if (res.success == false) {
78
+ layer.alert(res.msg)
79
+ } else {
80
+ table.reload("invoice_table");
81
+ parent.table.reload('apply_invoice_table');
82
+ layer.alert('添加成功')
83
+ form.val('add_invoice_form', {
84
+ 'number': '',
85
+ 'no_tax_amount': '',
86
+ 'taxt_amount': '',
87
+ 'amount': '',
88
+ 'date_at': '',
89
+ })
90
+ }
91
+ })
92
+ return false;
93
+ });
94
+
95
+ table.render({
96
+ elem: '#invoice_table',
97
+ url: '/missions/invoices/list?id=' + invoice_apply_id,
98
+ cols: [
99
+ [{
100
+ field: 'id',
101
+ width: 80,
102
+ title:'序号',type: 'numbers',
103
+ sort: true
104
+ }, {
105
+ field: 'number',
106
+ width: 150,
107
+ title: '发票号码',
108
+ edit: true
109
+ }, {
110
+ field: 'no_tax_amount',
111
+ width: 150,
112
+ title: '未税金额',
113
+ edit: true
114
+ }, {
115
+ field: 'taxt_amount',
116
+ width: 150,
117
+ title: '税额',
118
+ edit: true
119
+ }, {
120
+ field: 'amount',
121
+ width: 150,
122
+ title: '发票金额',
123
+ edit: true
124
+ }, {
125
+ field: 'date_at',
126
+ width: 190,
127
+ title: '开票日期',
128
+ templet:function (d) {
129
+ return '<input type="text" class="layui-input layui-input-date" value="'+ (d.date_at || '') +'" autocomplete="off">'
130
+ }
131
+ }, {
132
+ title: '操作',
133
+ minWidth: 170,
134
+ toolbar: '#invoice_toolbar'
135
+ }]
136
+ ],
137
+ page: true,
138
+ done: function (res) {
139
+ $(".layui-input-date").each(function (i) {
140
+ layui.laydate.render({
141
+ elem: this,
142
+ format: "yyyy-MM-dd",
143
+ done: function (value, date) {
144
+ if (res && res.data[i]) {
145
+ $.extend(res.data[i], {'date_at': value || ''})
146
+ }
147
+ }
148
+ })
149
+ })
150
+ }
151
+ });
152
+
153
+ table.on('tool(invoice_table)', function (obj) {
154
+ var data = obj.data;
155
+ if (obj.event === 'edit') {
156
+ request.authPut('missions/invoices/' + data.id, data,
157
+ function (res) {
158
+ if (res.success) {
159
+ table.reload('invoice_table')
160
+ } else {
161
+ layer.alert(res.msg)
162
+ }
163
+
164
+ })
165
+ } else if (obj.event == 'delete') {
166
+ layer.confirm('确定删除发票号码' + data.number, function (index) {
167
+ request.delete('missions/invoices/'+ data.id, {}, function(res) {
168
+ layer.close(index);
169
+ table.reload("invoice_table")
170
+ table.reload("apply_invoice_table")
171
+ })
172
+ });
173
+ }
174
+ });
175
+
176
+ });
177
+ </script>