Browse Source

表头过滤函数和修改未关联该系统的设备查询问题

zhangyu 5 years ago
parent
commit
0bb8186fdc

+ 1 - 1
config/dev.env.js

@@ -4,7 +4,7 @@ const prodEnv = require('./prod.env')
 
 module.exports = merge(prodEnv, {
     NODE_ENV: '"development"',
-    BASE_URL: '"http://172.16.0.239"', //测试iframe地址
+    BASE_URL: '"http://192.168.20.215"', //测试iframe地址
     SSO_SERVER: '"http://192.168.20.101:8004"' //测试环境
     // SSO_SERVER: '"http://sso.sagacloud.cn"'  //正式环境
 })

+ 1 - 1
config/prod.env.js

@@ -1,7 +1,7 @@
 'use strict'
 module.exports = {
     NODE_ENV: '"production"',
-    BASE_URL: '"http://172.16.0.239"', //测试iframe地址
+    BASE_URL: '"http://192.168.20.215"', //测试iframe地址
     SSO_SERVER: '"http://192.168.20.101:8004"' //测试环境
     // BASE_URL: '"http://mbi.sagacloud.cn"', //线上iframe地址
     // SSO_SERVER: '"http://sso.sagacloud.cn"'  //正式环境

+ 12 - 12
src/components/ledger/handsontables/system.vue

@@ -105,24 +105,24 @@ import handsonUtils from "@/utils/scan/hasontableUtils"
 import showTools from "@/utils/handsontable/notShow"
 
 
-import qrcode from "@/components/business_space/lib/qrcode";
-import firm from "@/components/business_space/dialogs/list/firm";
-import supplyDialog from "@/components/business_space/dialogs/list/supplyDialog";
-import supplierDialog from "@/components/business_space/dialogs/list/supplierDialog";
-import maintainerDialog from "@/components/business_space/dialogs/list/maintainerDialog";
-import insurerDialog from "@/components/business_space/dialogs/list/insurerDialog";
-import guaranteeDialog from "@/components/business_space/dialogs/list/guaranteeDialog";
-import uploadFilesDialog from "@/components/business_space/dialogs/list/filesDialog";
-import uploadImgDialog from "@/components/business_space/dialogs/list/uploadImgDialog";
+import qrcode from "@/components/business_space/lib/qrcode"
+import firm from "@/components/business_space/dialogs/list/firm"
+import supplyDialog from "@/components/business_space/dialogs/list/supplyDialog"
+import supplierDialog from "@/components/business_space/dialogs/list/supplierDialog"
+import maintainerDialog from "@/components/business_space/dialogs/list/maintainerDialog"
+import insurerDialog from "@/components/business_space/dialogs/list/insurerDialog"
+import guaranteeDialog from "@/components/business_space/dialogs/list/guaranteeDialog"
+import uploadFilesDialog from "@/components/business_space/dialogs/list/filesDialog"
+import uploadImgDialog from "@/components/business_space/dialogs/list/uploadImgDialog"
 import picDialog from "@/components/business_space/dialogs/list/picDialog"
-import myPagination from "@/components/common/myPagination";
-import dialogAssets from "@/components/ledger/addDialog/dialogSystem";
+import myPagination from "@/components/common/myPagination"
+import dialogAssets from "@/components/ledger/addDialog/dialogSystem"
 import detailsDialog from "@/components/business_space/lib/detailsDia"
 import systemRelevance from "@/components/ledger/tableTransfers"
 
 import Handsontable from "handsontable-pro"
 import 'handsontable-pro/dist/handsontable.full.css'
-import zhCN from 'handsontable-pro/languages/zh-CN';
+import zhCN from 'handsontable-pro/languages/zh-CN'
 
 import {
     mapGetters,

+ 4 - 3
src/components/ledger/tableTransfers.vue

@@ -264,9 +264,6 @@ export default {
             "skip": this.pages1.size * (this.pages1.currentPage - 1),  // 跳过多少数据
             "count": this.pages1.size   // 查询跳过300条数据之后的50条 (默认按照创建时间从大-->小排序)
           },
-          filter: {
-            EquipLocalName: this.search.filter
-          },
           id: "",
           excludeSystemId: this.id,
           type: [this.search.category == "all" ? "Eq" : this.search.category]
@@ -274,6 +271,10 @@ export default {
         secret: this.secret,
         ProjId: this.projectId
       }
+      if (this.search.filter) {
+        param.data.filter = {}
+        param.data.filter.EquipLocalName = this.search.filter == ""
+      }
       if (this.search.build == "all") {
         param.data.id = this.projectId
       } else if (this.search.floor && this.search.floor != "all") {

+ 2 - 4
src/utils/handsontable/fillterField.js

@@ -1,8 +1,6 @@
 const data = {
   equipment: {
-    read: {
-      show: [],
-      hidden: []
-    }
+    onlyRead: [],
+    edit: []
   }
 }

+ 250 - 2
src/utils/handsontable/notShow.js

@@ -1,6 +1,7 @@
 // 不显示的信息点数组
 import text from "@/utils/handsontable/mainText"
 import tools from "@/utils/scan/tools"
+import fieldData from "@/utils/handsontable/fillterField"
 let InputModeArr = ["A1", "A2", "B1", "C5", "D1", "D2", "E1", "L", "L1", "L2", "F1", "F2", "M", "Own"]
 //在编辑模式下并且勾选隐藏自动填充的信息点不显示的字段
 let noShowArr = [
@@ -676,8 +677,6 @@ const showTools = {
                             readOnly: onlyRead,
                             numericFormat: {
                                 pattern: "0,0.00"
-                                    // culture: 'de-DE' // use this for EUR (German),
-                                    // more cultures available on http://numbrojs.com/languages.html
                             }
                         };
                     } else if (item.InputMode == "C5") {
@@ -868,6 +867,255 @@ const showTools = {
         }).filter(item => item);
         return data
     },
+    /**
+     * 
+     * @param {*} arr 原始表头数组
+     * @param {*} type 对应表格的模块类型
+     * @param {*} onlyRead 是否只读
+     * @param {*} showType 查看类型(全部;只看要采集的信息;隐藏部分信息)
+     * @param {*} taizhang 是否是台账类型
+     * @param {*} falg 是否要过滤动态参数
+     * 
+     */
+    headerTextFilter (arr, type, onlyRead, showType, taizhang = false, falg = false) {
+        if (taizhang && !onlyRead) {
+            arr = showTools.arrToArr(arr)
+        }
+        let data = arr.map(item => {
+            if (onlyRead) { //只读模式
+                if (showType == "Visible" && item.Visible) { //只看要采集的信息
+                    return tools.isUnit(item)
+                } else if (showType == "all") { //显示全部
+                    return tools.isUnit(item)
+                } else {
+                    return undefined
+                }
+            } else { //编辑模式
+                if (!showTools.filterUnshow(onlyRead, type, item.InfoPointCode)) { //过滤固定不显示字段
+                    return undefined
+                }
+                if (showType == "Visible" && item.Visible) { //只看要采集的信息
+                    return tools.isUnit(item)
+                } else if (showType == "all") { //显示全部
+                    return tools.isUnit(item)
+                } else if (showType == "partInfo" && showTools.isShow(item.InfoPointCode)) { //隐藏部分厂家信息(***需维护不显示列表***)
+                    if (falg) { //控制过滤动态参数
+                        if (item.FirstName == "控制参数" || item.FirstName == "设定参数" || item.FirstName == "运行参数") {
+                            return undefined
+                        } else {
+                            return tools.isUnit(item)
+                        }
+                    }
+                } else {
+                    return undefined
+                }
+
+            }
+        }).filter(d => d)
+        return data
+    },
+    headerTypeFilter (arr, type, onlyRead, showType, taizhang = false, falg = false) {
+        if (taizhang && !onlyRead) {
+            arr = showTools.arrToArr(arr)
+        }
+        let data = arr.map(item => {
+            if (onlyRead) { //只读模式
+                if (showType == "Visible" && item.Visible) { //只看要采集的信息
+                    return tools.textFormat(item, onlyRead)
+                } else if (showType == "all") { //显示全部
+                    return tools.textFormat(item, onlyRead)
+                } else {
+                    return undefined
+                }
+            } else { //编辑模式
+                if (!showTools.filterUnshow(onlyRead, type, item.InfoPointCode)) { //过滤固定不显示字段
+                    return undefined
+                }
+                if (showType == "Visible" && item.Visible) { //只看要采集的信息
+                    return tools.inputModeFilter(item)
+                } else if (showType == "all") { //显示全部
+                    return tools.inputModeFilter(item)
+                } else if (showType == "partInfo" && showTools.isShow(item.InfoPointCode)) { //隐藏部分厂家信息(***需维护不显示列表***)
+                    if (falg) { //控制过滤动态参数
+                        if (item.FirstName == "控制参数" || item.FirstName == "设定参数" || item.FirstName == "运行参数") {
+                            return undefined
+                        } else {
+                            return tools.inputModeFilter(item)
+                        }
+                    }
+                } else {
+                    return undefined
+                }
+
+            }
+        }).filter(d => d)
+        return data
+    },
+    isUnit (item) {
+        if (!item.Unit || item.Unit == "") {
+            return item.InfoPointName;
+        } else {
+            return item.InfoPointName + "(" + item.Unit + ")";
+        }
+    },
+    textFormat (item, onlyRead) {
+        if (item.InfoPointCode == "EquipQRCode") {
+            return {
+                data: item.Path,
+                renderer: text.lookQRCode,
+                readOnly: onlyRead
+            }
+        }
+
+        //图片类型
+        if (
+            item.InfoPointCode == "InstallPic" ||
+            item.InfoPointCode == "InstallDrawing" ||
+            item.InfoPointCode == "Nameplate" ||
+            item.InfoPointCode == "Pic" ||
+            item.InfoPointCode == "Drawing"
+        ) {
+            return {
+                data: item.Path,
+                renderer: text.picType,
+                readOnly: onlyRead
+            }
+        }
+
+        //文件类型
+        if (item.InfoPointCode == "InsuranceFile" ||
+            item.InfoPointCode == "Archive" ||
+            item.InfoPointCode == "CheckReport") {
+            return {
+                data: item.Path,
+                renderer: text.fileType,
+                readOnly: onlyRead
+            }
+        }
+
+        return {
+            data: item.Path,
+            readOnly: onlyRead
+        }
+    },
+    inputModeFilter (item) {
+        if (item.InfoPointCode == "EquipQRCode") {
+            return {
+                data: item.Path,
+                renderer: text.lookQRCode,
+                readOnly: !item.Editable
+            }
+        }
+
+        //图片类型
+        if (
+            item.InfoPointCode == "InstallPic" ||
+            item.InfoPointCode == "InstallDrawing" ||
+            item.InfoPointCode == "Nameplate" ||
+            item.InfoPointCode == "Pic" ||
+            item.InfoPointCode == "Drawing"
+        ) {
+            return {
+                data: item.Path,
+                renderer: text.picType,
+                readOnly: !item.Editable
+            }
+        }
+
+        //文件类型
+        if (item.InfoPointCode == "InsuranceFile" ||
+            item.InfoPointCode == "Archive" ||
+            item.InfoPointCode == "CheckReport") {
+            return {
+                data: item.Path,
+                renderer: text.fileType,
+                readOnly: !item.Editable
+            }
+        }
+
+        if (item.InputMode == "D1" || item.InputMode == "E1") { //单选输入
+            return {
+                data: item.Path,
+                renderer: tools.customDropdownRenderer,
+                editor: "chosen",
+                readOnly: !item.Editable,
+                chosenOptions: {
+                    data: item.DataSource ? tools.formatDataSource(item.DataSource) : ""
+                }
+            };
+        } else if (item.InputMode == "D2" || item.InputMode == "E2") { //多选输入
+            return {
+                data: item.Path,
+                renderer: tools.customDropdownRenderer,
+                editor: "chosen",
+                readOnly: !item.Editable,
+                chosenOptions: {
+                    multiple: true, //多选
+                    data: item.DataSource ? tools.formatDataSource(item.DataSource) : ""
+                }
+            };
+        } else if (item.InputMode == "A1" || item.InputMode == "A2") { //数字输入
+            return {
+                data: item.Path,
+                type: "numeric",
+                readOnly: !item.Editable,
+                numericFormat: {
+                    pattern: "0,0.00"
+                }
+            };
+        } else if (item.InputMode == "C5") { //日期输入
+            return {
+                data: item.Path,
+                type: "date",
+                dateFormat: "YYYY-MM-DD",
+                readOnly: !item.Editable,
+                correctFormat: true
+            };
+        } else if ( item.InputMode == "A3" ||
+                    item.InputMode == "A4" ||
+                    item.InputMode == "B1" || 
+                    item.InputMode == "B2" ||
+                    item.InputMode == "F1" ||
+                    item.InputMode == "F2" ||
+                    item.InputMode == "L1" ||
+                    item.InputMode == "L2" ||
+                    item.InputMode == "L" ||
+                    item.InputMode == "M" ) { //文本输入
+            return {
+                data: item.Path,
+                readOnly: !item.Editable
+            }
+        } else if (item.InputMode == "Own") { //四大厂商
+            return {
+                data: item.Path,
+                renderer: text.idType,
+                readOnly: !item.Editable
+            }
+        } else { //不支持输入(暂定后台控制是否可编辑)
+            return {
+                data: item.Path,
+                readOnly: !item.Editable
+            }
+        }
+    },
+    filterUnshow: (onlyRead, type, code) => {
+        let falg = true, data = fieldData[type]
+        if (onlyRead) {
+            data.onlyRead.map(item => {
+                if (item == code) {
+                    falg = false
+                }
+            })
+            return falg
+        } else {
+            data.onlyRead.map(item => {
+                if (item == code) {
+                    falg = false
+                }
+            })
+            return falg
+        }
+    }
 }
 
 export default showTools