123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- 'use strict';
- /**
- * 变更令详细页js
- *
- * @author EllisRan.
- * @date 2018/11/22
- * @version
- */
- $.event.special.valuechange = {
- teardown: function (namespaces) {
- $(this).unbind('.valuechange');
- },
- handler: function (e) {
- $.event.special.valuechange.triggerChanged($(this));
- },
- add: function (obj) {
- $(this).on('keyup.valuechange cut.valuechange paste.valuechange input.valuechange', obj.selector, $.event.special.valuechange.handler)
- },
- triggerChanged: function (element) {
- var current = element[0].contentEditable === 'true' ? element.html() : element.val()
- , previous = typeof element.data('previous') === 'undefined' ? element[0].defaultValue : element.data('previous');
- if (current !== previous) {
- element.trigger('valuechange', [element.data('previous')]);
- element.data('previous', current);
- }
- }
- };
- $(document).ready(() => {
- // tab切换
- $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
- const tab = $(this).attr('aria-controls');
- $('.show_title').hide();
- $('#'+ tab +'_title').show();
- if (tab === 'bills' && $('#bills').hasClass('first-bill-pane')) {
- table = $('#tablelist').removeAttr('width').DataTable({
- columnDefs: [
- { className: 'allwidth1', width: 100, targets: 0 },
- { className: 'allwidth2', width: 150, targets: [1,2] },
- { className: 'allwidth4', width: 40, targets: 9 },
- { className: 'allwidth5', width: 60, targets: 3 },
- { className: 'allwidth3',width: 80, targets: '_all' }
- ],
- fixedColumns: {
- leftColumns: 5
- }
- });
- $('#bills').removeClass('first-bill-pane');
- }
- });
- // 上传附件
- $('#upload-file-btn').click(function () {
- const file = $('#upload-file')[0];
- if (file.files[0] === undefined) {
- toastr.error('未选择上传文件!');
- return false;
- }
- const filesize = file.files[0].size;
- if (filesize > 30 * 1024 * 1024) {
- toastr.error('文件大小过大!');
- return false;
- }
- const fileext = '.' + file.files[0].name.toLowerCase().split('.').splice(-1)[0];
- if (whiteList.indexOf(fileext) === -1) {
- toastr.error('只能上传指定格式的附件!');
- return false;
- }
- const formData = new FormData();
- formData.append('cid', $('#changeId').val());
- formData.append('tid', $('#tenderId').val());
- formData.append('size', filesize);
- formData.append('file', file.files[0]);
- postDataWithFile('/change/upload/file', formData, function (data) {
- $('#addfujian').modal('hide');
- console.log(data);
- const fileInfo = data;
- let index = $('#attList tr').length;
- let html = '<tr> ' +
- '<td>' + (index+1) + '</td> ' +
- '<td><a href="/change/download/file/' + fileInfo.id + '">' + fileInfo.filename + fileInfo.fileext + '</a></td> ' +
- '<td>' + fileInfo.filesize + '</td> ' +
- '<td>' + fileInfo.in_time + '</td> ' +
- '<td> <a class="btn btn-light btn-sm delete-file" data-attid="' + fileInfo.id + '" title="删除附件"><span class="fa fa-trash text-danger"></span></a> </td> ' +
- '</tr>';
- $('#attList').append(html);
- }, function () {
- });
- $('#upload-file').val('');
- });
- // 删除附件
- $('body').on('click', '.delete-file', function () {
- let attid = $(this).data('attid');
- console.log(attid);
- let self = $(this);
- const data = {id: attid};
- postData('/change/delete/file', data, function (result) {
- self.parents('tr').remove();
- // 重新排序
- let newsort = 1;
- $('#attList tr').each(function(){
- $(this).children('td').eq(0).text(newsort);
- newsort++;
- });
- });
- });
- // 变更详情展示和隐藏
- $('.change-detail-checkbox').on('click', function (e) {
- if($(e.target).is('label')){
- return;
- }
- let column = table.column(2);
- column.visible(!column.visible());
- })
- });
|