|
@@ -220,6 +220,16 @@ $(document).ready(function() {
|
|
|
parent = parent.getParentNode();
|
|
|
}
|
|
|
}
|
|
|
+ checkFilesExist(files, callback) {
|
|
|
+ const data = [];
|
|
|
+ for (const file of files) {
|
|
|
+ if (file === undefined) return [];
|
|
|
+ data.push(file.name);
|
|
|
+ }
|
|
|
+ postData('file/check', { filing_id: filingObj.curFiling.id, files: data }, function(result) {
|
|
|
+ callback(result);
|
|
|
+ });
|
|
|
+ }
|
|
|
uploadFiles(files, callback) {
|
|
|
const formData = new FormData();
|
|
|
formData.append('filing_id', filingObj.curFiling.id);
|
|
@@ -563,6 +573,25 @@ $(document).ready(function() {
|
|
|
$('#del-filing').modal('hide');
|
|
|
});
|
|
|
});
|
|
|
+ $('#add-file').on('show.bs.modal', function() {
|
|
|
+ $('#upload-file-hint').hide();
|
|
|
+ $('#upload-file')[0].value = '';
|
|
|
+ if ($('#add-file-ok').hasClass('btn-warning')) $('#add-file-ok').removeClass('btn-warning').addClass('btn-primary');
|
|
|
+ });
|
|
|
+ $('#upload-file').change(() => {
|
|
|
+ $('#add-file-ok').attr('disabled', true);
|
|
|
+ const input = $('#upload-file');
|
|
|
+ filingObj.checkFilesExist(input[0].files, function(result) {
|
|
|
+ if (result.length === 0) {
|
|
|
+ $('#upload-file-hint').hide();
|
|
|
+ $('#add-file-ok').removeClass('btn-warning').addClass('btn-primary').attr('disabled', false);
|
|
|
+ } else {
|
|
|
+ const msg = result[0] + (result.length > 1 ? `(等${result.length}个文件)`: '') + '</br>存在同名文件,请确认是否上传重复';
|
|
|
+ $('#upload-file-hint').html(msg).show();
|
|
|
+ $('#add-file-ok').removeClass('btn-primary').addClass('btn-warning').attr('disabled', false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
$('#add-file-ok').click(() => {
|
|
|
const input = $('#upload-file');
|
|
|
filingObj.uploadFiles(input[0].files, function() {
|
|
@@ -570,6 +599,24 @@ $(document).ready(function() {
|
|
|
$('#add-file').modal('hide');
|
|
|
});
|
|
|
});
|
|
|
+ $('#add-big-file').on('show.bs.modal', function() {
|
|
|
+ $('#upload-big-file-hint').hide();
|
|
|
+ $('#upload-big-file')[0].value = '';
|
|
|
+ if ($('#add-big-file-ok').hasClass('btn-warning')) $('#add-big-file-ok').removeClass('btn-warning').addClass('btn-primary');
|
|
|
+ });
|
|
|
+ $('#upload-big-file').change(() => {
|
|
|
+ $('#add-big-file-ok').attr('disabled', true);
|
|
|
+ const input = $('#upload-big-file');
|
|
|
+ filingObj.checkFilesExist(input[0].files, function(result) {
|
|
|
+ if (result.length === 0) {
|
|
|
+ $('#upload-big-file-hint').hide();
|
|
|
+ $('#add-big-file-ok').removeClass('btn-warning').addClass('btn-primary').attr('disabled', false);
|
|
|
+ } else {
|
|
|
+ $('#upload-big-file-hint').html('存在同名文件,请确认是否上传重复').show();
|
|
|
+ $('#add-big-file-ok').removeClass('btn-primary').addClass('btn-warning').attr('disabled', false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
$('#add-big-file-ok').click(() => {
|
|
|
const input = $('#upload-big-file');
|
|
|
filingObj.uploadBigFile(input[0].files[0], function () {
|