Quellcode durchsuchen

feat: 工料机的排序应按分类、编号数值排序

zhangweicheng vor 5 Jahren
Ursprung
Commit
92a3c16c42

+ 1 - 1
web/building_saas/main/js/views/glj_view_contextMenu.js

@@ -470,7 +470,7 @@ function getGLJData(actionType, isInitial = true,getLibFunc) {
     $.bootstrapLoading.start();
     if(!getLibFunc)getLibFunc = projectObj.project.ration_glj.getGLJData;
     getLibFunc(url, function (result) {
-        // 目前只有浙江2015需要特殊处理处理
+        // 目前只有浙江2015 湖南 - 山东 需要特殊处理处理
         if (gljOprObj.sortSelectViewGLJ) {
             gljOprObj.sortSelectViewGLJ(result.datas.stdGLJ);
             gljOprObj.sortSelectViewGLJ(result.datas.complementaryGLJs);

+ 107 - 0
web/over_write/js/hunan_2014.js

@@ -350,6 +350,113 @@ function ifTransEqToMateria(){
   return true;
 }
 
+if (typeof gljOprObj !== 'undefined') {
+  // 添加、替换工料机界面工料机排序
+  gljOprObj.sortSelectViewGLJ = function (data) {
+      // 工料机编码:按“-”前的数值排序
+      const reg = /[^-]+/;
+      data.sort((a, b) => {
+          const orgCodeA = a.code;
+          const orgCodeB = b.code;
+          const regCodeA = orgCodeA.match(reg);
+          const regCodeB = orgCodeB.match(reg);
+          const compareCodeA = regCodeA
+              ? +regCodeA[0]
+                  ? +regCodeA[0]
+                  : regCodeA[0]
+              : orgCodeA;
+          const compareCodeB = regCodeB
+              ? +regCodeB[0]
+                  ? +regCodeB[0]
+                  : regCodeB
+              : orgCodeB;
+          return isNaN(compareCodeA) && isNaN(compareCodeB)
+              ? compareCodeA.localeCompare(compareCodeB)
+              : compareCodeA - compareCodeB;
+      });
+      // 工料机类型排序:人工、机上人工、混凝土、砂浆、配合比、普通材料、商品混凝土、商品砂浆、外购砼构件、绿化苗木、机械台班、机械组成物、设备。
+      const TypeMap = {
+          1: 1,
+          303: 2,
+          202: 3,
+          203: 4,
+          204: 5,
+          201: 6,
+          205: 7,
+          206: 8,
+          208: 9,
+          209: 10,
+          301: 11,
+          302: 12,
+          5: 13,
+      };
+      data.sort((a, b) => {
+          const typeA = TypeMap[a.gljType];
+          const typeB = TypeMap[b.gljType];
+          return typeA - typeB;
+      });
+  }
+}
+
+
+//工料机类型排序:人工、机上人工、混凝土、砂浆、配合比、普通材料、商品混凝土、商品砂浆、外购砼构件、绿化苗木、机械台班、机械组成物、设备。
+
+function o_sortRationGLJ(list, std, tm) {
+  let lo_sh = typeof _ !== "undefined" ? _ : require("lodash");
+  const field = std ? "gljType" : "type";
+  let TypeMap = {
+    1: 1,
+    303: 2,
+    202: 3,
+    203: 4,
+    204: 5,
+    201: 6,
+    205: 7,
+    206: 8,
+    208: 9,
+    209: 10,
+    301: 11,
+    302: 12,
+    5: 13,
+  };
+  if (tm) TypeMap = tm;
+  list = lo_sh.sortByAll(list, [
+    function (item) {
+      return TypeMap[item[field]];
+    },
+    function (item) {
+      let arr = item.code.split("-");
+      return arr[0];
+    },
+    "code",
+  ]);
+  return list;
+}
+
+if (typeof gljUtil !== "undefined") {
+  gljUtil.sortRationGLJ = o_sortRationGLJ;
+
+  gljUtil.sortProjectGLJ = function (list) {
+    //人工、机上人工、普通材料、商品混凝土、商品砂浆、外购砼构件、绿化苗木、机械台班、机械组成物、设备、混凝土、砂浆、配合比
+    const TypeMap = {
+      1: 1,
+      303: 2,
+      201: 3,
+      205: 4,
+      206: 5,
+      208: 6,
+      209: 7,
+      301: 8,
+      302: 9,
+      5: 10,
+      202: 11,
+      203: 12,
+      204: 13,
+    };
+    return o_sortRationGLJ(list, false, TypeMap);
+  };
+}
+
 if (typeof module !== 'undefined') {
   module.exports = {
       progression,