浏览代码

前端文件

liuling 1 月之前
父节点
当前提交
b8c281db29
共有 2 个文件被更改,包括 822 次插入0 次删除
  1. 279 0
      js/addon/customer/configinfo/css/configCss.css
  2. 543 0
      js/addon/customer/configinfo/js/configInfoEdit.js

+ 279 - 0
js/addon/customer/configinfo/css/configCss.css

@@ -0,0 +1,279 @@
+.container {
+    position: absolute;
+    z-index: 100;
+    top: -5%;
+    left: 25%;
+    max-width: 800px;
+    margin: 0 auto;
+    background: white;
+    border-radius: 4px;
+    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
+    overflow: hidden;
+}
+.header {
+    padding: 15px;
+    border-bottom: 1px solid #e8e8e8;
+    background-color: #fafafa;
+}
+
+.header h2 {
+    font-size: 16px;
+    font-weight: normal;
+    margin-bottom: 15px;
+    color: #333;
+}
+
+.search-box {
+    display: flex;
+    align-items: center;
+    gap: 10px;
+    margin-bottom: 10px;
+}
+
+.search-input {
+    flex: 1;
+    padding: 8px 12px;
+    border: 1px solid #d9d9d9;
+    border-radius: 4px;
+    font-size: 14px;
+}
+
+.checkbox-label {
+    display: flex;
+    align-items: center;
+    font-size: 14px;
+    color: #666;
+    white-space: nowrap;
+}
+
+.checkbox-label input {
+    margin-right: 5px;
+}
+
+.field-list {
+    height: 400px;
+    overflow-y: auto;
+    padding: 10px 0;
+}
+
+.tree-node {
+    padding: 5px 15px;
+    cursor: pointer;
+    display: flex;
+    align-items: center;
+    transition: background-color 0.2s;
+    position: relative; /* 添加相对定位 */
+}
+
+.tree-node:hover {
+    background-color: #f0f7ff;
+}
+
+.tree-node.selected {
+    background-color: #e6f7ff;
+}
+
+.tree-node-content {
+    display: flex;
+    align-items: center;
+    flex: 1;
+}
+
+.expand-icon {
+    width: 16px;
+    height: 16px;
+    margin-right: 5px;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    cursor: pointer;
+    color: #666;
+    font-size: 12px;
+    transition: transform 0.2s ease;
+}
+
+.expand-icon.expanded {
+    transform: rotate(90deg);
+}
+
+.node-checkbox {
+    margin-right: 8px;
+}
+
+.node-text {
+    font-size: 14px;
+    color: #333;
+}
+
+.node-type {
+    margin-left: 8px;
+    font-size: 12px;
+    color: #999;
+    background: #f0f0f0;
+    padding: 1px 5px;
+    border-radius: 3px;
+}
+
+.children {
+    margin-left: 20px;
+    max-height: 0;
+    overflow: hidden;
+    transition: max-height 0.3s ease;
+}
+
+.children.expanded {
+    max-height: 300px; /* 限制子节点容器高度 */
+    overflow-y: auto; /* 子节点内容过多时显示滚动条 */
+    padding-right: 10px; /* 避免滚动条与内容重叠 */
+}
+
+.footer {
+    padding: 15px;
+    border-top: 1px solid #e8e8e8;
+    display: flex;
+    justify-content: space-between;
+    gap: 10px;
+    background-color: #fafafa;
+}
+
+.footer-left {
+    display: flex;
+    gap: 10px;
+}
+
+.btn {
+    padding: 6px 16px;
+    border: 1px solid #d9d9d9;
+    border-radius: 4px;
+    background-color: white;
+    cursor: pointer;
+    font-size: 14px;
+    transition: all 0.3s;
+}
+
+.btn-primary {
+    background-color: #1890ff;
+    color: white;
+    border-color: #1890ff;
+}
+
+.btn-primary:hover {
+    background-color: #40a9ff;
+}
+
+.btn:hover {
+    border-color: #40a9ff;
+}
+
+.empty-state {
+    text-align: center;
+    padding: 40px 20px;
+    color: #999;
+}
+
+.info-text {
+    font-size: 12px;
+    color: #999;
+    margin-top: 10px;
+    padding: 0 15px;
+}
+
+/* 层级缩进线优化 */
+.tree-node[data-level="1"] {
+    padding-left: 35px;
+}
+
+.tree-node[data-level="1"]::before {
+    content: "";
+    position: absolute;
+    left: 25px;
+    top: 0;
+    bottom: 0;
+    width: 1px;
+    background-color: #e8e8e8;
+}
+
+.tree-node[data-level="2"] {
+    padding-left: 55px;
+}
+
+.tree-node[data-level="2"]::before {
+    content: "";
+    position: absolute;
+    left: 45px;
+    top: 0;
+    bottom: 0;
+    width: 1px;
+    background-color: #e8e8e8;
+}
+
+.tree-node[data-level="3"] {
+    padding-left: 75px;
+}
+
+.tree-node[data-level="3"]::before {
+    content: "";
+    position: absolute;
+    left: 65px;
+    top: 0;
+    bottom: 0;
+    width: 1px;
+    background-color: #e8e8e8;
+}
+
+/* 连接线优化 */
+.tree-node:not(:last-child)::after {
+    content: "";
+    position: absolute;
+    left: 15px;
+    top: 50%;
+    width: 10px;
+    height: 1px;
+    background-color: #e8e8e8;
+}
+
+.tree-node[data-level="1"]::after {
+    left: 35px;
+}
+
+.tree-node[data-level="2"]::after {
+    left: 55px;
+}
+
+.tree-node[data-level="3"]::after {
+    left: 75px;
+}
+
+.select-field-input {
+    padding: 8px 12px;
+    border: 1px solid #d9d9d9;
+    border-radius: 4px;
+    font-size: 14px;
+    width: 200px;
+}
+
+.status-bar {
+    display: flex;
+    align-items: center;
+    font-size: 12px;
+    color: #666;
+}
+
+/* 添加子节点滚动条样式优化 */
+.children::-webkit-scrollbar {
+    width: 6px;
+}
+
+.children::-webkit-scrollbar-track {
+    background: #f1f1f1;
+    border-radius: 3px;
+}
+
+.children::-webkit-scrollbar-thumb {
+    background: #ccc;
+    border-radius: 3px;
+}
+
+.children::-webkit-scrollbar-thumb:hover {
+    background: #aaa;
+}

+ 543 - 0
js/addon/customer/configinfo/js/configInfoEdit.js

@@ -0,0 +1,543 @@
+// 定义配置信息编辑类,继承自框架的Edit类
+shr.defineClass("shr.ats.configInfoEdit", shr.framework.Edit, {
+    fieldData: "", // 存储字段数据
+    selectedFields: [], // 存储当前选中的字段
+    isSelected: [], // 存储已选中的字段标识(用于回显)
+    selectEntry: "", // 当前选中的条目
+
+    // 初始化DOM元素及事件绑定
+    initalizeDOM: function () {
+        var _this = this;
+        // 调用父类的初始化DOM方法
+        shr.ats.configInfoEdit.superClass.initalizeDOM.call(this);
+        // 更新已选中字段状态
+        _this.updateIsSelected();
+
+        // 精确搜索复选框变更事件,触发搜索
+        $('#exactSearch').on('change', function () {
+            _this.performSearch()
+        });
+        // 搜索输入框输入事件,触发搜索
+        $('#searchInput').on('input', function () {
+            _this.performSearch()
+        });
+
+        // 全选按钮点击事件绑定
+        $('#selectAllBtn').on('click', _this.selectAll());
+
+        // 清空选择按钮点击事件绑定
+        $('#clearSelectionBtn').on('click', _this.clearSelection());
+
+        // 确定按钮点击事件:处理选中字段并添加到表格
+        $('#confirmBtn').on('click', function () {
+            console.log('选中的字段:', _this.selectedFields);
+            // 隐藏容器
+            $("#container").css("display", "none");
+            var fields = _this.selectedFields
+
+            // 遍历选中字段,构造行数据并添加到表格
+            for (let i = 0; i < fields.length; i++) {
+                var data = fields[i];
+                var rowData = {}
+                rowData.fieldKey = data.field
+                rowData.databaseName = data.mappingField
+                rowData.mappingKey = data.asMappingField
+                rowData.fieldName = data.name
+                rowData.dataEntry = data.enumSource
+                rowData.dataType = _this.updateselect(data.dataType); // 转换数据类型
+                console.log(rowData)
+                // 向表格添加行数据
+                $('#SelectFieldEntry').jqGrid('addRowData', null, rowData, 'last', null)
+            }
+            _this.updateIsSelected();
+        });
+
+        // 取消按钮点击事件:清空选择并隐藏容器
+        $('#cancelBtn').on('click', function () {
+            _this.clearSelection();
+            $("#container").css("display", "none");
+        });
+        _this.changeEntrys()
+    },
+
+    changeEntrys: function () {
+        $('#entrys').jqGrid('option', {
+            afterSaveCell: function (rowid, cellname, value, iRow, iCol) {
+                // 这里可以检查单元格的值是否改变,并执行相应的操作
+                if (cellname === "entryFull") {
+                    // 调用服务获取字段数据
+                    shr.callService({
+                        serviceName: 'getEntityInfoService',
+                        param: { "entryFull": value },
+                        success: function (data) {
+                            if (data.code != 200) {
+                                $('#entrys').jqGrid("setRowData", rowid, { "entryFull": "" })
+                                shr.showWarning({
+                                    'message': "元数据不存在"
+                                });
+                            }
+                        }
+                    });
+                } else if (cellname === "relationFeild") {
+                    {
+                        shr.callService({
+                            serviceName: 'verifySqlService',
+                            param: { "relationField": value },
+                            success: function (data) {
+                                if (data.code != 200) {
+                                    $('#entrys').jqGrid("setRowData", rowid, { "relationFeild": "" })
+                                    shr.showError({
+                                        'message': "条件不合法!!!"
+                                    });
+                                } else {
+                                    $('#entrys').jqGrid("setRowData", rowid, { "relationFeild": data.info })
+                                }
+                            }
+                        });
+                    }
+                }
+            }
+        })
+    },
+
+
+    // 根据数据类型别名获取对应枚举值
+    updateselect: function (value) {
+        // 请求枚举数据的URL
+        var url = "selectEnum.do?method=getSelectEnumData&enumSource=com.kingdee.eas.custom.entryconfig.enumlist.DataTypeEnum"
+        var rd = ""
+        // 同步AJAX请求
+        $.ajax({
+            type: "get",
+            url: url,
+            async: false,
+            success: function (data) {
+                console.log(data);
+                if (data.result == "success") {
+                    var d = data.data;
+                    // 遍历枚举数据,匹配别名对应的枚举值
+                    for (let i = 0; i < d.length; i++) {
+                        if (d[i].alias == value) {
+                            rd = d[i].value
+                            break;
+                        }
+                    }
+                }
+            },
+            dataType: "json"
+        });
+        return rd
+    },
+
+    // 更新已选中字段列表(从表格中获取)
+    updateIsSelected: function () {
+        // 获取表格所有行数据
+        var data = $("#SelectFieldEntry").jqGrid("getAllRowData");
+        var a = []
+        // 提取每行的fieldKey存入数组
+        for (let i = 0; i < data.length; i++) {
+            a.push(data[i].fieldKey)
+        }
+        this.isSelected = a;
+    },
+
+    // 处理添加行动作
+    addRowAction: function (event) {
+        var _this = this;
+        var source = event.currentTarget,
+            $editGrid = _this.getEditGrid(source);
+
+        var data = _this.createNewEntryModel();
+        if (typeof data === 'undefined') {
+            data = {};
+        }
+
+        // 当点击特定添加行按钮时
+        if (event.currentTarget.id == "addRow_SelectFieldEntry") {
+
+            // 获取选中的条目数据
+            var data = $("#entrys").jqGrid("getSelectedRowsData");
+            // 确保只选中一条数据
+            if (data.length != 1) {
+                shr.showWarning({
+                    'message': "请选择一条元数据!!注意:只能选择一条数据!"
+                });
+                return
+            }
+
+
+            // 若选中条目变更,重新获取字段数据并初始化树
+            if (_this.selectEntry == "" || _this.selectEntry != data[0].entryFull) {
+                _this.selectEntry = data[0].entryFull
+                var params = {}
+                params.entryFull1 = data[0].entryFull
+                params.alias = data[0].alias
+
+                // 调用服务获取字段数据
+                shr.callService({
+                    serviceName: 'getSelectFieldService',
+                    param: params,
+                    success: function (data) {
+                        _this.fieldData = data
+                        _this.selectedFields = []
+                        // 初始化树形结构
+                        _this.initTree(_this.fieldData);
+                        // 显示容器
+                        $("#container").attr("style", "")
+                    }
+                });
+            } else {
+                _this.initTree(_this.fieldData);
+                // 条目未变更,直接显示容器
+                $("#container").attr("style", "")
+            }
+            // 根据已选中字段回显选择状态
+            _this.selectFieldsByField(_this.isSelected);
+
+
+        } else {
+            // 其他添加行逻辑(表格内编辑或表单添加)
+            var editGridCont = _this._getEditGridCont(source);
+            if (editGridCont.data('editType') == 'inline') {
+                $editGrid.jqGrid('addRow', { data: data });
+            } else {
+                $editGrid.wafGrid('addForm');
+            }
+
+            // 触发编辑完成事件
+            var event = document.createEvent('HTMLEvents');
+            event.initEvent("editComplete_" + $editGrid.attr("id"), true, true);
+            event.eventType = 'message';
+            document.dispatchEvent(event);
+        }
+    },
+
+    // 初始化树形结构
+    initTree: function (data) {
+        var _this = this;
+        const fieldList = document.getElementById('fieldList');
+        // 清空容器
+        fieldList.innerHTML = '';
+
+        // 无数据时显示空状态
+        if (data.length === 0) {
+            fieldList.innerHTML = '<div class="empty-state">没有找到匹配的字段</div>';
+            return;
+        }
+
+        // 遍历数据创建树节点
+        data.forEach(item => {
+            fieldList.appendChild(_this.createTreeNode(item));
+        });
+    },
+
+    // 创建树节点(递归)
+    createTreeNode: function (node, level = 0) {
+        var _this = this;
+        const nodeElement = document.createElement('div');
+        nodeElement.className = 'tree-node';
+        nodeElement.dataset.level = level; // 存储层级信息
+        nodeElement.dataset.field = node.field; // 存储字段标识
+
+        const nodeContent = document.createElement('div');
+        nodeContent.className = 'tree-node-content';
+
+        // 创建复选框
+        const checkbox = document.createElement('input');
+        checkbox.type = 'checkbox';
+        checkbox.className = 'node-checkbox';
+        // 复选框变更事件:切换选择状态
+        checkbox.addEventListener('change', function (e) {
+            e.stopPropagation();
+            _this.toggleSelection(nodeElement, node, this.checked);
+        });
+        nodeContent.appendChild(checkbox);
+
+        // 展开/折叠图标(有子节点时)
+        if (node.children && node.children.length > 0) {
+            const expandIcon = document.createElement('div');
+            expandIcon.className = 'expand-icon';
+            expandIcon.innerHTML = '▶';
+            // 点击事件:切换节点展开状态
+            expandIcon.addEventListener('click', function (e) {
+                e.stopPropagation();
+                _this.toggleNode(this);
+            });
+            nodeContent.appendChild(expandIcon);
+        } else {
+            // 无子节点时显示占位图标(隐藏)
+            const placeholder = document.createElement('div');
+            placeholder.className = 'expand-icon';
+            placeholder.style.visibility = 'hidden';
+            nodeContent.appendChild(placeholder);
+        }
+
+        // 节点文本
+        const nodeText = document.createElement('div');
+        nodeText.className = 'node-text';
+        nodeText.textContent = node.name;
+
+        // 类型标签
+        const typeLabel = document.createElement('span');
+        typeLabel.className = 'node-type';
+        typeLabel.textContent = `类型:${node.dataType}`;
+
+        nodeText.appendChild(typeLabel);
+        nodeContent.appendChild(nodeText);
+
+        // 节点内容点击事件:切换复选框状态
+        nodeContent.addEventListener('click', function (e) {
+            if (e.target !== checkbox && !e.target.classList.contains('expand-icon')) {
+                checkbox.checked = !checkbox.checked;
+                _this.toggleSelection(nodeElement, node, checkbox.checked);
+            }
+        });
+
+        nodeElement.appendChild(nodeContent);
+
+        // 子节点容器(有子节点时)
+        if (node.children && node.children.length > 0) {
+            const childrenContainer = document.createElement('div');
+            childrenContainer.className = 'children';
+
+            // 递归创建子节点
+            node.children.forEach(child => {
+                childrenContainer.appendChild(_this.createTreeNode(child, level + 1));
+            });
+
+            nodeElement.appendChild(childrenContainer);
+        }
+
+        return nodeElement;
+    },
+
+    // 切换节点展开/折叠状态
+    toggleNode: function (iconElement) {
+        const nodeElement = iconElement.closest('.tree-node');
+        const childrenContainer = nodeElement.querySelector('.children');
+
+        if (childrenContainer) {
+            // 切换展开/折叠状态
+            if (childrenContainer.classList.contains('expanded')) {
+                childrenContainer.classList.remove('expanded');
+                iconElement.classList.remove('expanded');
+            } else {
+                childrenContainer.classList.add('expanded');
+                iconElement.classList.add('expanded');
+            }
+        }
+    },
+
+    // 切换节点选择状态
+    toggleSelection: function (nodeElement, node, isChecked) {
+        if (isChecked) {
+            // 选中状态:添加选中样式并加入选中列表
+            nodeElement.classList.add('selected');
+            if (!this.selectedFields.some(field => field.field === node.field)) {
+                this.selectedFields.push(node);
+            }
+        } else {
+            // 未选中状态:移除选中样式并从选中列表移除
+            nodeElement.classList.remove('selected');
+            this.selectedFields = this.selectedFields.filter(field => field.field !== node.field);
+        }
+    },
+
+    // 执行搜索功能
+    performSearch: function () {
+        var _this = this
+        // 获取搜索关键词和精确匹配状态
+        const searchTerm = document.getElementById('searchInput').value.toLowerCase();
+        const exactMatch = document.getElementById('exactSearch').checked;
+
+        // 无搜索词时显示全部数据
+        if (!searchTerm) {
+            _this.initTree(_this.fieldData);
+            return;
+        }
+
+        // 过滤数据并重新初始化树
+        const filteredData = this.filterData(_this.fieldData, searchTerm, exactMatch);
+        _this.initTree(filteredData);
+    },
+
+    // 过滤数据(递归)
+    filterData: function (data, searchTerm, exactMatch) {
+        var _this = this;
+        // 对每个节点创建副本,避免修改原始数据
+        return data.map(item => {
+            const itemCopy = { ...item };
+            // 检查当前节点是否匹配(名称、字段名、类型)
+            const nameMatch = exactMatch ?
+                item.name.toLowerCase() === searchTerm :
+                item.name.toLowerCase().includes(searchTerm);
+
+            const fieldMatch = exactMatch ?
+                item.field.toLowerCase() === searchTerm :
+                item.field.toLowerCase().includes(searchTerm);
+
+            const typeMatch = exactMatch ?
+                item.dataType.toLowerCase() === searchTerm :
+                item.dataType.toLowerCase().includes(searchTerm);
+
+            // 节点匹配时,保留节点及所有子节点
+            if (nameMatch || fieldMatch || typeMatch) {
+                itemCopy.children = item.children ? [...item.children] : [];
+                return itemCopy;
+            }
+
+            // 节点不匹配时,检查子节点
+            if (item.children && item.children.length > 0) {
+                const filteredChildren = _this.filterData(item.children, searchTerm, exactMatch);
+                if (filteredChildren.length > 0) {
+                    // 子节点有匹配时,保留节点及过滤后的子节点
+                    itemCopy.children = filteredChildren;
+                    return itemCopy;
+                }
+            }
+
+            // 不匹配且无子节点匹配,返回null(后续过滤)
+            return null;
+        }).filter(Boolean) // 过滤掉null值
+    },
+
+    // 根据字段标识选择对应节点
+    selectFieldsByField: function (fields) {
+        var _this = this
+        // 确保字段列表为数组
+        const fieldArray = Array.isArray(fields) ? fields : [fields];
+
+        // 清空当前选择
+        _this.clearSelection();
+
+        // 遍历字段列表,选中对应节点
+        fieldArray.forEach(field => {
+            const nodeElement = document.querySelector(`.tree-node[data-field="${field}"]`);
+            if (nodeElement) {
+                const checkbox = nodeElement.querySelector('.node-checkbox');
+                if (checkbox) {
+                    checkbox.checked = true;
+                    // 查找对应节点数据
+                    const node = _this.findNodeByField(_this.fieldData, field);
+                    if (node) {
+                        _this.toggleSelection(nodeElement, node, true);
+                        // 去重处理
+                        _this.selectedFields = _this.selectedFields.filter(field => field.field !== node.field);
+                    }
+
+                    // 展开所有父节点,确保选中节点可见
+                    _this.expandParentNodes(nodeElement);
+                }
+            }
+        });
+
+        // 更新选择状态
+        //_this.updateStatus();
+    },
+
+    // 根据字段标识查找节点数据(递归)
+    findNodeByField: function (data, field) {
+        var _this = this
+        for (let item of data) {
+            if (item.field === field) {
+                return item;
+            }
+            // 递归查找子节点
+            if (item.children && item.children.length > 0) {
+                const found = _this.findNodeByField(item.children, field);
+                if (found) return found;
+            }
+        }
+        return null;
+    },
+
+    // 展开节点的所有父节点
+    expandParentNodes: function (nodeElement) {
+        let current = nodeElement.parentElement;
+        // 向上遍历父节点,直到找到根容器
+        while (current && !current.classList.contains('field-list')) {
+            if (current.classList.contains('children')) {
+                const parentNode = current.parentElement;
+                const expandIcon = parentNode.querySelector('.expand-icon');
+                // 展开父节点
+                if (expandIcon && !expandIcon.classList.contains('expanded')) {
+                    expandIcon.classList.add('expanded');
+                    current.classList.add('expanded');
+                }
+            }
+            current = current.parentElement;
+        }
+    },
+
+    // 全选所有节点
+    selectAll: function () {
+        var _this = this
+        const checkboxes = document.querySelectorAll('.node-checkbox');
+        checkboxes.forEach(checkbox => {
+            checkbox.checked = true;
+            const nodeElement = checkbox.closest('.tree-node');
+            const field = nodeElement.dataset.field;
+            const node = findNodeByField(fieldData, field);
+            if (node) {
+                toggleSelection(nodeElement, node, true);
+            }
+        });
+        // _this.updateStatus();
+    },
+
+    // 清空所有选择
+    clearSelection: function () {
+        var _this = this
+        this.selectedFields = [];
+        // 取消所有复选框勾选
+        const checkboxes = document.querySelectorAll('.node-checkbox');
+        checkboxes.forEach(checkbox => {
+            checkbox.checked = false;
+        });
+        // 移除所有选中样式
+        document.querySelectorAll('.tree-node.selected').forEach(node => {
+            node.classList.remove('selected');
+        });
+        //_this.updateStatus();
+    },
+
+    // 更新选择状态显示(控制台日志)
+    // updateStatus: function () {
+    //     console.log(`当前已选择 ${this.selectedFields.length} 个字段`);
+    // },
+    dataConfigJYAction: function () {
+        $.block.show({
+            text: $.shrI18n.common.loadingText.runningPlsWait
+        });
+        var method = shr.getUrlRequestParam("method", window.location.href);
+        var number = "";
+        if(method=="view"){
+            number  = $('#number').text();		
+        }else {
+            number  = $('#number').shrTextField("getValue");		
+        }
+        var options = {
+            type: "get",
+            action: "dataConfigJY",
+            handler:
+                "com.kingdee.eas.custom.dataconfig.handler.DataConfigEditHandler",
+            param: {
+                "number": number
+            },
+            success: function (response) {
+                console.log(response.sql)
+                if(response.code==200){
+                    shr.showInfo({
+                        'message': "校验通过!!"+"</br>"+response.sql
+                    });
+                }else {
+                    shr.showError({
+                        'message': response.error
+                    });
+                }
+            }
+        };
+        shr.callHandler(options);
+        $.block.hide();
+    }
+})