|
@@ -4356,11 +4356,12 @@ $(document).ready(() => {
|
|
|
$('#shoufang-flie-list').html(html);
|
|
|
postData(window.location.pathname + '/shoufang/file', { sfid: id }, function (result) {
|
|
|
for (const att of result) {
|
|
|
- html += `<tr><td>${att.filename}${att.fileext}</td><td>${moment(att.in_time).format('YYYY-MM-DD HH:mm')}</td><td>` +
|
|
|
+ html += `<tr><td>${att.filename}${att.fileext} ` + makeEditHtml(att.id, att.filename, att.fileext, att.extra_upload) +
|
|
|
+ `<td>${moment(att.in_time).format('YYYY-MM-DD HH:mm')}</td><td>` +
|
|
|
`<a href="${att.filepath}" target="_blank"><i class="fa fa-download"></i></a>` + makeDelHtml(att.id, att.extra_upload) +`</td></tr>`;
|
|
|
}
|
|
|
$('#shoufang-flie-list').html(html);
|
|
|
- $('[data-toggle="tooltip"]').tooltip();
|
|
|
+ $('[data-toggle="tooltip"]').tooltip()
|
|
|
});
|
|
|
|
|
|
function makeDelHtml(fid, extra_upload) {
|
|
@@ -4370,6 +4371,65 @@ $(document).ready(() => {
|
|
|
'<i data-toggle="tooltip" data-placement="left" data-original-title="删除" class="fa fa-remove"></i></a>' : '';
|
|
|
}
|
|
|
});
|
|
|
+ function makeEditHtml(fid, filename, fileext, extra_upload) {
|
|
|
+ return sfAttDelPower &&
|
|
|
+ (stage.status !== auditConst.status.checked || (stage.status === auditConst.status.checked && extra_upload)) ?
|
|
|
+ '<a href="javascript:void(0)" data-filename="' + filename + '" data-fileext="'+ fileext +'" data-id="'+ fid +'" class="edit-shoufang-att ml-1">' +
|
|
|
+ '<i data-toggle="tooltip" data-placement="left" data-original-title="修改文件名" class="fa fa-pencil"></i></a></td>' : ''
|
|
|
+ }
|
|
|
+ // 修改收方单附件文件名
|
|
|
+ $('body').on('click', '.edit-shoufang-att', function () {
|
|
|
+ $(this).children('i').tooltip('hide');
|
|
|
+ const fid = $(this).data('id');
|
|
|
+ const filename = $(this).data('filename');
|
|
|
+ const fileext = $(this).data('fileext');
|
|
|
+ const html = `<div class="input-group input-group-sm">
|
|
|
+ <input type="text" class="form-control" value="${filename}" placeholder="输入文件名" aria-describedby="button-${fid}" style="width:50px">
|
|
|
+ <div class="input-group-append" id="button-${fid}">
|
|
|
+ <button class="btn btn-outline-primary shoufang-att-confirm-btn" data-filename="${filename}" data-fileext="${fileext}" data-fid="${fid}" type="button">确认</button>
|
|
|
+ <button class="btn btn-outline-secondary shoufang-att-cancel-btn" data-filename="${filename}" data-fileext="${fileext}" data-fid="${fid}" type="button">取消</button>
|
|
|
+ </div>
|
|
|
+ </div>`;
|
|
|
+ $(this).parents('td').html(html);
|
|
|
+ });
|
|
|
+ // 确认修改文件名
|
|
|
+ $('body').on('click', '.shoufang-att-confirm-btn', function () {
|
|
|
+ const validText = $.trim($(this).parents('td').find('input').val());
|
|
|
+ const orgValue = $.trim($(this).data('filename'));
|
|
|
+ const fileext = $(this).data('fileext');
|
|
|
+ const fid = $(this).data('fid');
|
|
|
+ if (!validText) {
|
|
|
+ toastr.error('文件名不能为空');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // const reg = /^[0-9a-zA-Z\-_\u4e00-\u9fa5]+$/;
|
|
|
+ if(validText.indexOf('.') !== -1 || validText.indexOf(' ') !== -1) {
|
|
|
+ toastr.error('文件名中不能包含.字符和空格');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(validText == orgValue) {
|
|
|
+ const html = `${orgValue}${fileext} ` + makeEditHtml(fid, orgValue, fileext, 1);
|
|
|
+ $(this).parents('td').html(html);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const data = {
|
|
|
+ id: fid,
|
|
|
+ filename: validText,
|
|
|
+ };
|
|
|
+ const _self = $(this);
|
|
|
+ postData('/wap/shoufang/editfile', data, function (result) {
|
|
|
+ const html = `${validText}${fileext} ` + makeEditHtml(fid, validText, fileext, 1);
|
|
|
+ _self.parents('td').html(html);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ // 取消修改文件名
|
|
|
+ $('body').on('click', '.shoufang-att-cancel-btn', function () {
|
|
|
+ const fid = $(this).data('fid');
|
|
|
+ const filename = $(this).data('filename');
|
|
|
+ const fileext = $(this).data('fileext');
|
|
|
+ const html = `${filename}${fileext} ` + makeEditHtml(fid, filename, fileext, 1);
|
|
|
+ $(this).parents('td').html(html);
|
|
|
+ });
|
|
|
// 删除收方单附件
|
|
|
$('body').on('click', '.del-shoufang-att', function () {
|
|
|
const id = $(this).data('id');
|