|
@@ -2891,11 +2891,67 @@ function bindEvents_file_table(jqS, usedObj, targetBody, type){
|
|
|
let orgDispName = $(jqS + ' div:eq(0)')[0].childNodes[0].textContent;
|
|
|
let postFix = '';
|
|
|
let orgName = orgDispName;
|
|
|
+ let hintText = $(jqS).find('span');
|
|
|
+ let fileDiv = $(jqS + ' div:eq(0)');
|
|
|
+ let renameDiv = $(jqS + ' div:eq(1)');
|
|
|
$(jqS + ' input').val(orgName);
|
|
|
- $(jqS + ' div:eq(0)').hide();
|
|
|
- $(jqS + ' div:eq(1)').show();
|
|
|
+ fileDiv.hide();
|
|
|
+ renameDiv.show();
|
|
|
+ $(jqS).find('input:eq(0)').focus();
|
|
|
+ $(jqS).find('input:eq(0)').blur(function () {
|
|
|
+ fileDiv.show();
|
|
|
+ renameDiv.hide();
|
|
|
+ hintText.hide();
|
|
|
+ });
|
|
|
//确认重命名
|
|
|
- $(jqS + ' .btn-success').on('click', function () {
|
|
|
+ //回车键
|
|
|
+ $(jqS).find('input:eq(0)').keypress(function (e) {
|
|
|
+ if(e.keyCode === 13){
|
|
|
+ let attrId = $(jqS).attr('id');
|
|
|
+ let id = attrId.slice(5, attrId.length);
|
|
|
+ let newName = $(jqS + ' input').val().trim();
|
|
|
+ if(newName !== orgName){
|
|
|
+ if(hasThisFileName(fileObjs, newName)){
|
|
|
+ hintText.show();
|
|
|
+ //$(jqS + ' input').val(orgName);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(newName.trim().length === 0){
|
|
|
+ alert('文件名不可为空!');
|
|
|
+ $(jqS + ' input').val(orgName);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //ajax
|
|
|
+ let updateObj = Object.create(null);
|
|
|
+ updateObj.fileType = type;
|
|
|
+ updateObj.updateType = 'update';
|
|
|
+ updateObj.updateData = Object.create(null);
|
|
|
+ if(type === fileType.unitPriceFile){
|
|
|
+ updateObj.updateData.id = parseInt(id);
|
|
|
+ //updateObj.updateData.id = id;
|
|
|
+ }
|
|
|
+ else if(type === fileType.feeRateFile){
|
|
|
+ updateObj.updateData.ID = id;
|
|
|
+ }
|
|
|
+ updateObj.updateData.name = newName;
|
|
|
+ a_updateFiles([updateObj], function () {
|
|
|
+ let newDispName = newName + postFix;
|
|
|
+ fileDiv[0].childNodes[0].textContent = newDispName;
|
|
|
+ fileDiv.show();
|
|
|
+ renameDiv.hide();
|
|
|
+ //refresh tender
|
|
|
+ refreshTenderFile(getTendersByFile(type, id, projTreeObj.tree.selected), type, newName);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ let newDispName = newName + postFix;
|
|
|
+ fileDiv[0].childNodes[0].textContent = newDispName;
|
|
|
+ fileDiv.show();
|
|
|
+ renameDiv.hide();
|
|
|
+ hintText.hide();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ /*$(jqS + ' .btn-success').on('click', function () {
|
|
|
let attrId = $(jqS).attr('id');
|
|
|
let id = attrId.slice(5, attrId.length);
|
|
|
let newName = $(jqS + ' input').val().trim();
|
|
@@ -2942,7 +2998,7 @@ function bindEvents_file_table(jqS, usedObj, targetBody, type){
|
|
|
$(jqS + ' div:eq(0)').show();
|
|
|
$(jqS + ' div:eq(1)').hide();
|
|
|
$(jqS).find('span:eq(2)').hide();
|
|
|
- });
|
|
|
+ });*/
|
|
|
});
|
|
|
//悬浮框显示使用该文件的单位工程
|
|
|
$($(jqS)[0].nextSibling).popover({
|
|
@@ -2978,12 +3034,7 @@ function set_file_table(target, poj_tenders, fileList, type){
|
|
|
let hoverHtml = '<p style="display: none; height: 14px;"><a class="btn btn-sm" href="javascript:void(0);" data-toggle="modal" data-target="#del-wj">删除</a><a class="btn btn-sm" href="javascript:void(0);">重命名</a></p></div>';
|
|
|
let renHtml = '<div class="input-group" style="display: none;">'
|
|
|
+ '<input class="form-control form-control-sm" value="">'
|
|
|
- + '<span class="input-group-btn">'
|
|
|
- + '<button class="btn btn-success btn-sm" type="button"><i class="fa fa-check"></i></button>'
|
|
|
- + '</span>'
|
|
|
- + '<span class="input-group-btn">'
|
|
|
- + '<button class="btn btn-secondary btn-sm" type="button"><i class="fa fa-remove"></i></button>'
|
|
|
- + '</span>'
|
|
|
+
|
|
|
+ '</div>'
|
|
|
+ '<span class="form-text text-danger" style="display: none">本建设项目已存在该文件名,请重新输入!' +
|
|
|
'</span></td>';
|