فهرست منبع

feat: 人材机库增加右键修改编号

vian 2 ماه پیش
والد
کامیت
8c9e6c16b5
2فایلهای تغییر یافته به همراه93 افزوده شده و 13 حذف شده
  1. 29 1
      web/maintain/std_glj_lib/html/gongliao.html
  2. 64 12
      web/maintain/std_glj_lib/js/glj.js

+ 29 - 1
web/maintain/std_glj_lib/html/gongliao.html

@@ -257,6 +257,34 @@
         </div>
     </div>
 
+    <div class="modal fade" id="edit-code" data-backdrop="static" style="display: none;" aria-hidden="true">
+        <div class="modal-dialog" role="document">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <h5 class="modal-title">修改编号</h5>
+                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                        <span aria-hidden="true">×</span>
+                    </button>
+                </div>
+                <div class="modal-body">
+
+                    <form>
+                        <div class="form-group row" style="margin-left: 0px;">
+                            <label class="col-auto col-form-label" id="edit-label" style="line-height: 26px;">编号</label>
+                            <div class="col">
+                                <input id="edit-code-text" class="form-control" placeholder="请输入编号" type="text" value="">
+                            </div>
+                        </div>
+                    </form>
+                </div>
+                <div class="modal-footer">
+                    <a id="edit-code-confirm" href="javascript: void(0);" class="btn btn-primary">确定</a>
+                    <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                </div>
+            </div>
+        </div>
+    </div>
+
     <!-- JS. -->
     <script src="/lib/jquery/jquery.min.js"></script>
     <script src="/lib/jquery-contextmenu/jquery.contextMenu.min.js"></script>
@@ -393,4 +421,4 @@
     autoFlashHeight();
 </script>
 
-</html>
+</html>

+ 64 - 12
web/maintain/std_glj_lib/js/glj.js

@@ -475,7 +475,7 @@ let repositoryGljObj = {
             me.rationLibs = result.data[0].rationLibs;
             $(".navbar-text").append(
               "<a href='/stdGljRepository/main'>人材机库</a><i class='fa fa-angle-right fa-fw'></i>" +
-                result.data[0].dispName
+              result.data[0].dispName
             );
             pageOprObj.gljLibName = result.data[0].dispName;
           }
@@ -849,6 +849,7 @@ let repositoryGljObj = {
     if (row < me.currentCache.length) {
       //标记当前工料机
       me.currentGlj = me.currentCache[row];
+      console.log(me.currentGlj);
       if (allowComponent.includes(me.currentCache[row].gljType)) {
         //展示数据
         if (me.currentGlj.component.length > 0) {
@@ -1434,6 +1435,33 @@ let repositoryGljObj = {
         false
       );
   },
+  editCode: async function () {
+    const sheet = this.workBook.getSheet(0);
+    const row = sheet.getActiveRowIndex();
+    const glj = this.currentCache[row];
+    if (!glj) {
+      alert('请选中工料机!');
+      $('#edit-code').modal('hide');
+      return;
+    }
+    const newCode = $('#edit-code-text').val();
+    if (!newCode) {
+      alert('编号不可为空!');
+      $('#edit-code-text').focus();
+      return;
+    }
+    if (this.gljList.some(item => item.ID !== glj.ID && item.code === newCode)) {
+      alert('编号已存在!');
+      $('#edit-code-text').focus();
+      return;
+    }
+    if (newCode === glj.code) {
+      $('#edit-code').modal('hide');
+      return;
+    }
+    this.mixUpdateRequest([{ ...glj, code: newCode }], [], []);
+    $('#edit-code').modal('hide');
+  },
   onContextmenuOpr: function () {
     let me = repositoryGljObj;
     $.contextMenu({
@@ -1468,8 +1496,23 @@ let repositoryGljObj = {
             sheet.setActiveCell(target.row, target.col);
           }
           return {
-            callback: function () {},
+            callback: function () { },
             items: {
+              edit: {
+                name: "修改编号",
+                disabled: function () {
+                  return (
+                    locked || !(me.currentCache && me.currentCache[target.row])
+                  );
+                },
+                icon: "fa-edit",
+                callback: function (key, opt) {
+                  if (me.currentCache[target.row]) {
+                    $('#edit-code').modal('show');
+                    $('#edit-code-text').val(me.currentCache[target.row].code || '');
+                  }
+                },
+              },
               delete: {
                 name: "删除",
                 disabled: function () {
@@ -1813,8 +1856,8 @@ let repositoryGljObj = {
     if (!priceProperties || priceProperties.length === 0) {
       pasteObj.basePrice =
         !isNaN(parseFloat(pasteObj.basePrice)) &&
-        pasteObj.basePrice &&
-        typeof pasteObj.basePrice !== "undefined"
+          pasteObj.basePrice &&
+          typeof pasteObj.basePrice !== "undefined"
           ? parseFloat(pasteObj.basePrice)
           : 0;
     } else {
@@ -1933,7 +1976,7 @@ let repositoryGljObj = {
         info.cellRange.colCount >= 5 &&
         info.cellRange.colCount <= me.setting.header.length &&
         info.cellRange.col + info.cellRange.colCount - 1 >=
-          me.colMapping.fieldToCol["gljType"]
+        me.colMapping.fieldToCol["gljType"]
       ) {
         for (let i = 0; i < items.length; i++) {
           if (me.isValidObj(items[i])) {
@@ -2320,7 +2363,7 @@ let gljTypeTreeOprObj = {
           pNode.isParent = false;
         }
       },
-      error: function () {},
+      error: function () { },
     });
     return true;
   },
@@ -2358,7 +2401,7 @@ let gljTypeTreeOprObj = {
         success: function (result, textStatus, status) {
           console.log(status + " : " + result);
         },
-        error: function () {},
+        error: function () { },
       });
     }
   },
@@ -2429,10 +2472,10 @@ let gljTypeTreeOprObj = {
         btn.bind("click", function () {
           treeNode.doing = true;
           let rawNode = {
-              ParentID: treeNode.ID,
-              NextSiblingID: -1,
-              Name: "新增子节点",
-            },
+            ParentID: treeNode.ID,
+            NextSiblingID: -1,
+            Name: "新增子节点",
+          },
             lastNodeId = -1;
           if (treeNode.items.length > 0) {
             lastNodeId = treeNode.items[treeNode.items.length - 1].ID;
@@ -2535,7 +2578,7 @@ $(document).ready(function () {
     },
     function () {
       let resizeRate =
-          (SlideResize.resizeWidth * 100) / $("#midContent").width(),
+        (SlideResize.resizeWidth * 100) / $("#midContent").width(),
         sheetRate = 100 - resizeRate;
       $("#slideResizeLeft").css("width", `${resizeRate}%`);
       $("#GLJListSheet").css("width", `${sheetRate}%`);
@@ -2572,4 +2615,13 @@ $(document).ready(function () {
     repositoryGljObj.mixUpdateRequest(updateArr, [], []);
     $("#moveTo").modal("hide");
   });
+
+  // 修改编号弹窗
+  $('#edit-code').on('shown.bs.modal', function () {
+    $('#edit-code-text').focus();
+  });
+
+  $('#edit-code-confirm').click(async () => {
+    await repositoryGljObj.editCode();
+  });
 });