| 12
 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
 
 | var uploadTaskForm = function (uploadForm) {
 $.ajax({
 url: applicationUtil.gatewayURL + '/pssc-graph/graph/generate-task',
 data: uploadForm,
 type: "post",
 contentType: "application/json",
 dataType: "JSON",
 success: function (data) {
 console.log(data.code);
 
 },
 error: function (data) {
 console.log(data.msg);
 }
 });
 };
 
 var array = new Array();
 var list_view = $('#upload-list');
 var taskForm = {};
 var uploadListIns = upload.render({
 elem: '#upload-svg-btn'
 , url: applicationUtil.gatewayURL + '/pssc-graph/graph/upload/'
 , accept: 'file'
 , exts: 'svg|xml'
 , auto: false
 , multiple: true
 , number: 2
 , bindAction: '#upload'
 , choose: function (obj) {
 
 var files = this.files = obj.pushFile();
 
 obj.preview(function (index, file, result) {
 if ($("#upload").hasClass("layui-btn-disabled")) {
 $("#upload").removeClass("layui-btn-disabled")
 }
 var tr = $(['<tr id="upload-' + index + '">'
 , '<td>' + file.name + '</td>'
 , '<td>' + (file.size / 1024).toFixed(1) + 'kb</td>'
 , '<td>等待上传</td>'
 , '<td>'
 , '<button class="layui-btn layui-btn-min demo-reload layui-hide">重传</button>'
 , '<button class="layui-btn layui-btn-min demo-delete layui-btn-danger">删除</button>'
 , '</td>'
 , '</tr>'].join(''));
 
 tr.find('.demo-reload').on('click', function () {
 obj.upload(index, file);
 });
 
 tr.find('.demo-delete').on('click', function () {
 delete files[index];
 tr.remove();
 uploadListIns.config.elem.next()[0].value = '';
 });
 list_view.append(tr);
 });
 }
 , allDone: function (res) {
 $("#filePath").val(array.toString());
 $("#upload").addClass("layui-btn-disabled");
 
 
 uploadTaskForm(JSON.stringify(taskForm));
 }
 , done: function (res, index, upload) {
 
 
 if (res.data.svgFileName != '-1') {
 taskForm.svgFileName = res.data.svgFileName;
 taskForm.svgFileId = res.data.svgFileId;
 }
 if (res.data.cimFileName != '-1') {
 taskForm.cimFileName = res.data.cimFileName;
 taskForm.cimFileId = res.data.cimFileId;
 }
 if (res.code == 0) {
 array.push(res.filePath);
 var tr = list_view.find('tr#upload-' + index)
 , tds = tr.children();
 tds.eq(2).html('<span style="color:#5FB878;">上传成功</span>');
 
 return delete this.files[index];
 }
 this.error(index, upload);
 }
 , error: function (index, upload) {
 
 var tr = list_view.find('tr#upload-' + index)
 , tds = tr.children();
 tds.eq(2).html('<span style="color:#FF5722;">上传失败</span>');
 tds.eq(3).find('.demo-reload').removeClass('layui-hide');
 }
 });
 
 
 |