浏览代码

feat: 建筑和公路的数据后台,新增标准清单库,可排序。

zhangweicheng 1 月之前
父节点
当前提交
be13810c92
共有 3 个文件被更改,包括 124 次插入0 次删除
  1. 93 0
      web/users/js/compilation.js
  2. 1 0
      web/users/views/compilation/engineering.html
  3. 30 0
      web/users/views/compilation/modal.html

+ 93 - 0
web/users/js/compilation.js

@@ -192,6 +192,25 @@ $(document).ready(function () {
     $("select[name='ration_lib']").html(html);
   });
 
+  $("#addRatioBtn").click(function () {
+    let rationLibData = rationList === undefined ? [] : JSON.parse(rationList);
+    let unSelectLibs = [];
+    for (let lib of rationLibData) {
+      if (
+        $("input:hidden[name=ration_lib][data-id = " + lib.id + "]").length > 0
+      ) {
+        continue;
+      }
+      unSelectLibs.push(lib);
+    }
+    let html = "";
+    for (let tmp of unSelectLibs) {
+      let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + "</option>";
+      html += tmpHtml;
+    }
+    $("select[name='ration_lib']").html(html);
+  });
+
   $("#ration_lib-search-box").on("input", function () {
     var keyword = $(this).val().toLowerCase().trim(); // 获取输入的关键字并转为小写
     // 遍历所有option元素
@@ -367,6 +386,57 @@ $(document).ready(function () {
     }
   });
 
+  // 排序点击
+  $("#openBillSort").click(function () {
+    let html = "";
+    const libs = $("input:hidden[name='bill_lib']");
+    for (let libEle of libs) {
+      let lib = JSON.parse($(libEle).val());
+
+      html += `
+      <p class="form-control-static billLibItem">
+      <a class="pull-right "  title="上移" id="list_${lib.id}" onclick="libUp(${
+        lib.id
+      })">
+          <span class="glyphicon glyphicon-arrow-up"></span>
+          <input type="hidden" class="sort_temp_value"  value='${JSON.stringify(
+            { id: lib.id, name: lib.name }
+          )}'>
+      </a>
+      <a class="pull-right stdBillUp"  title="下移" onclick="libDown(${
+        lib.id
+      })">
+          <span class="glyphicon glyphicon-arrow-down"></span>
+      </a>
+      ${lib.name}
+     </p> `;
+    }
+    $("#stdBillList").html(html);
+    $("#stdBillSort").modal("show");
+  });
+
+  $("#billSortConfirm").click(function () {
+    let html = "";
+    const libs = $(".sort_temp_value");
+    libs.each(function (index) {
+      const lib = JSON.parse($(this).val());
+      html += `
+      <p class="form-control-static">
+        <a class="pull-right text-danger remove-lib" data-model="bill" title="移除">
+          <span class="glyphicon glyphicon-remove"></span>
+        </a>
+        <input type="hidden" name="bill_lib" data-id="${
+          lib.id
+        }" value='${JSON.stringify({ id: lib.id, name: lib.name })}'>
+        ${index === 0 ? '<i class="glyphicon glyphicon-flag"></i>&nbsp;' : ""}${
+        lib.name
+      }
+      </p>`;
+    });
+    $(".bill-list").html(html);
+    $("#stdBillSort").modal("hide");
+  });
+
   // 添加
   $(".add-compilation").click(function () {
     model = $(this).data("model");
@@ -754,6 +824,29 @@ $(document).ready(function () {
   });
 });
 
+function libUp(id) {
+  const $item = $(`#list_${id}`).closest(".billLibItem");
+  const $prevItem = $item.prev();
+
+  if ($prevItem.length) {
+    $item.fadeOut(200, function () {
+      $prevItem.before($item);
+      $item.fadeIn(200);
+    });
+  }
+}
+
+function libDown(id) {
+  const $item = $(`#list_${id}`).closest(".billLibItem");
+  const $nextItem = $item.next();
+  if ($nextItem.length) {
+    $item.fadeOut(200, function () {
+      $nextItem.after($item);
+      $item.fadeIn(200);
+    });
+  }
+}
+
 /**
  * 初始化
  *

+ 1 - 0
web/users/views/compilation/engineering.html

@@ -35,6 +35,7 @@
                                     <% } %>
                                 </div>
                                 <a class="btn btn-link btn-sm add-compilation" href="javascript:void(0)" data-model="bill">添加</a>
+                                <a class="btn btn-link btn-sm" href="javascript:void(0)"  id="openBillSort">排序</a>
                             </div>
                             <div class="form-group col-md-3">
                                 <label>人材机库</label>

+ 30 - 0
web/users/views/compilation/modal.html

@@ -110,6 +110,36 @@
     </div>
 </div>
 
+
+<!-- 弹窗标准清单排序 -->
+<div class="modal fade" id="stdBillSort" tabindex="-1" role="dialog">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+                <h4 class="modal-title" id="myModalLabel">标准清单排序</h4>
+            </div>
+            <div class="modal-body"> 
+                <div class="form-group" id="stdBillList">
+                        <p class="form-control-static">
+                            <a class="pull-right stdBillUp"  title="上移">
+                                <span class="glyphicon glyphicon-arrow-up"></span>
+                            </a>
+                            <a class="pull-right"  title="下移">
+                                <span class="glyphicon glyphicon-arrow-down"></span>
+                            </a>
+                            你好
+                        </p> 
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
+                <button type="button" class="btn btn-primary" id="billSortConfirm">确定</button>
+            </div>
+        </div>
+    </div>
+</div>
+
 <!-- 弹窗新增计价 -->
 <div class="modal fade" id="valuation-dialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
     <div class="modal-dialog" role="document">