Przeglądaj źródła

Merge branch 'master' of http://47.92.104.23:3000/LiuYing/tengda

zqy 2 miesięcy temu
rodzic
commit
008007f881

+ 584 - 0
js/addon/customer/configinfo/css/ContarctTable.css

@@ -0,0 +1,584 @@
+/* 弹窗相关样式 */
+.popup-overlay {
+
+    position: fixed;
+    top: 0;
+    left: 0;
+    right: 0;
+    bottom: 0;
+    background-color: rgba(0, 0, 0, 0.5);
+    display: none;
+    justify-content: center;
+    align-items: center;
+    z-index: 1000;
+    padding: 20px;
+}
+
+/* 全局样式变量定义 */
+:root {
+    --primary-color: #165dff;
+    --primary-dark: #0040c9;
+    --primary-light: rgba(22, 93, 255, 0.1);
+    --success-color: #00b42a;
+    --success-dark: #00a127;
+    --success-light: rgba(0, 180, 42, 0.1);
+    --warning-color: #ff7d00;
+    --warning-dark: #e06c00;
+    --purple-color: #722ed1;
+    --purple-dark: #6224c5;
+    --gray-light: #f5f5f5;
+    --gray: #e5e6eb;
+    --gray-dark: #d0d3d9;
+    --text-primary: #333;
+    --text-secondary: #666;
+    --text-tertiary: #999;
+    --border-radius: 6px;
+    --border-radius-lg: 8px;
+    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
+    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
+    --transition: all 0.2s ease;
+}
+
+/* 容器样式 */
+.container {
+    max-width: 1000px;
+    margin: 0 auto 20px;
+    background-color: white;
+    border-radius: var(--border-radius-lg);
+    padding: 24px;
+    box-shadow: var(--shadow);
+}
+
+/* 整体弹窗内容容器 */
+.main-content {
+    background-color: white;
+    border-radius: var(--border-radius-lg);
+    width: 100%;
+    display: flex;
+    flex-direction: column;
+    box-shadow: var(--shadow-lg);
+}
+
+/* 内容区块样式 */
+.content-section {
+    padding: 20px;
+    border-bottom: 1px solid var(--gray);
+}
+
+.content-section:last-child {
+    border-bottom: none;
+}
+
+/* 标题样式 */
+.title {
+    font-size: 20px;
+    font-weight: 600;
+    color: var(--text-primary);
+    display: flex;
+    align-items: center;
+    gap: 8px;
+}
+
+.title1 {
+    font-size: 20px;
+    font-weight: 600;
+    color: var(--text-primary);
+    display: flex;
+    align-items: center;
+    gap: 8px;
+}
+
+.title::before {
+    content: "";
+    font-size: 22px;
+}
+
+.table-title {
+    font-size: 18px;
+    font-weight: 600;
+    margin-bottom: 15px;
+    color: var(--text-primary);
+    padding-bottom: 8px;
+    border-bottom: 2px solid var(--primary-color);
+    display: flex;
+    align-items: center;
+    gap: 15px;
+}
+
+.popup-title {
+    font-size: 18px;
+    font-weight: 600;
+    color: var(--text-primary);
+}
+
+/* 按钮样式统一 */
+.btn,
+.close-btn,
+.preview-btn,
+.global-confirm-btn,
+.open-popup-btn {
+    padding: 9px 18px;
+    border-radius: var(--border-radius);
+    font-size: 14px;
+    font-weight: 500;
+    cursor: pointer;
+    border: none;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    gap: 6px;
+    transition: var(--transition);
+    outline: none;
+}
+
+.btn:hover,
+.close-btn:hover,
+.preview-btn:hover,
+.global-confirm-btn:hover,
+.open-popup-btn:hover {
+    transform: translateY(-1px);
+    box-shadow: var(--shadow);
+}
+
+.btn:active,
+.close-btn:active,
+.preview-btn:active,
+.global-confirm-btn:active,
+.open-popup-btn:active {
+    transform: translateY(0);
+}
+
+.btn-success,
+.global-confirm-btn {
+    background-color: var(--success-color);
+    color: white;
+}
+
+.btn-success:hover,
+.global-confirm-btn:hover {
+    background-color: var(--success-dark);
+    box-shadow: 0 2px 8px rgba(0, 180, 42, 0.2);
+}
+
+.btn-primary,
+.open-popup-btn {
+    background-color: var(--primary-color);
+    color: white;
+}
+
+.btn-primary:hover,
+.open-popup-btn:hover {
+    background-color: var(--primary-dark);
+    box-shadow: 0 2px 8px rgba(22, 93, 255, 0.2);
+}
+
+.preview-btn {
+    background-color: #6c757d;
+    color: white;
+}
+
+.preview-btn:hover {
+    background-color: #5a6268;
+}
+
+.close-btn {
+    background: none;
+    font-size: 20px;
+    color: var(--text-secondary);
+    padding: 0 5px;
+}
+
+.close-btn:hover {
+    color: var(--text-primary);
+    background-color: var(--gray-light);
+}
+
+/* 布局组件 */
+.header {
+    display: flex;
+    flex-wrap: wrap;
+    justify-content: space-between;
+    align-items: center;
+    margin-bottom: 24px;
+    gap: 16px;
+    padding-bottom: 16px;
+    border-bottom: 1px solid var(--gray);
+}
+
+.actions {
+    display: flex;
+    gap: 12px;
+}
+
+/* 签署方卡片样式 */
+.signers-container {
+    display: flex;
+    flex-direction: column;
+    gap: 16px;
+}
+
+.signer-card {
+    background-color: white;
+    border-radius: var(--border-radius-lg);
+    border: 1px solid var(--gray);
+    padding: 20px;
+    transition: var(--transition);
+}
+
+.signer-card:hover {
+    box-shadow: var(--shadow-lg);
+    border-color: var(--gray-dark);
+}
+
+.card-header {
+    display: flex;
+    flex-wrap: wrap;
+    justify-content: space-between;
+    align-items: center;
+    margin-bottom: 18px;
+    gap: 12px;
+}
+
+.card-info {
+    display: flex;
+    align-items: center;
+    gap: 12px;
+    flex-wrap: wrap;
+}
+
+.card-actions {
+    display: flex;
+    gap: 16px;
+}
+
+/* 选择框样式 */
+.type-select {
+    padding: 5px 12px;
+    border-radius: 20px;
+    border: none;
+    color: white;
+    font-size: 12px;
+    font-weight: 500;
+    cursor: pointer;
+    outline: none;
+    transition: var(--transition);
+}
+
+.type-select:hover {
+    transform: scale(1.05);
+}
+
+.type-personal {
+    background-color: var(--purple-color);
+}
+
+.type-personal:hover {
+    background-color: var(--purple-dark);
+}
+
+.type-company {
+    background-color: var(--warning-color);
+}
+
+.type-company:hover {
+    background-color: var(--warning-dark);
+}
+
+.type-copy {
+    background-color: var(--primary-color);
+}
+
+.type-copy:hover {
+    background-color: var(--primary-dark);
+}
+
+/* 文本和标签样式 */
+.signer-name {
+    font-size: 15px;
+    color: var(--text-primary);
+    font-weight: 500;
+}
+
+.signer-role {
+    font-size: 12px;
+    color: var(--text-tertiary);
+    padding: 2px 8px;
+    background-color: var(--gray-light);
+    border-radius: 4px;
+    display: none;
+}
+
+.action-link {
+    font-size: 13px;
+    color: var(--primary-color);
+    cursor: pointer;
+    transition: var(--transition);
+    display: flex;
+    align-items: center;
+    gap: 4px;
+    padding: 4px 6px;
+    border-radius: 4px;
+}
+
+.action-link:hover {
+    color: var(--primary-dark);
+    background-color: var(--primary-light);
+}
+
+.icon {
+    display: inline-block;
+    width: 14px;
+    height: 14px;
+    text-align: center;
+}
+
+/* 表单样式 */
+.form-grid {
+    display: grid;
+    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
+    gap: 18px;
+}
+
+.form-group {
+    width: 100%;
+}
+
+.input-field,
+.order-input,
+.data-table input[type="text"],
+.data-table input[type="date"],
+.data-table input[type="datetime-local"] {
+    width: 100%;
+    padding: 10px 14px;
+    border: 1px solid var(--gray-dark);
+    border-radius: var(--border-radius);
+    font-size: 14px;
+    transition: var(--transition);
+    color: var(--text-primary);
+}
+
+.order-input {
+    width: 50px;
+    padding: 5px 8px;
+    display: none;
+}
+
+.input-field:focus,
+.order-input:focus,
+.data-table input[type="text"]:focus,
+.data-table input[type="date"]:focus,
+.data-table input[type="datetime-local"]:focus {
+    outline: none;
+    border-color: var(--primary-color);
+    box-shadow: 0 0 0 2px rgba(22, 93, 255, 0.2);
+}
+
+.input-field::placeholder,
+.data-table input[type="text"]::placeholder {
+    color: #c9c9c9;
+}
+
+/* 表格样式 */
+.table-container {
+    margin-bottom: 30px;
+    background-color: white;
+    border-radius: var(--border-radius-lg);
+    box-shadow: var(--shadow);
+    padding: 20px;
+    overflow-x: auto;
+}
+
+.data-table {
+    width: 100%;
+    border-collapse: separate;
+    border-spacing: 0;
+    min-width: 600px;
+}
+
+.data-table th,
+.data-table td {
+    border: 1px solid var(--gray);
+    padding: 12px 15px;
+    text-align: left;
+    white-space: nowrap;
+    min-width: 120px;
+}
+
+.data-table thead {
+    position: sticky;
+    top: 0;
+    z-index: 2;
+}
+
+.data-table th {
+    background-color: var(--primary-color);
+    color: white;
+    font-weight: 500;
+    border-right: 1px solid var(--gray);
+}
+
+.data-table tr td:first-child {
+    /* background-color: var(--primary-light); */
+    font-weight: 500;
+}
+
+.data-table tr:nth-child(even) {
+    background-color: #f8f9fa;
+}
+
+.data-table tr:hover {
+    background-color: var(--primary-light);
+}
+
+.data-table input[type="text"] {
+    max-width: 200px;
+}
+
+/* 弹窗样式 */
+.popup-overlay {
+    position: fixed;
+    top: 0;
+    left: 0;
+    right: 0;
+    bottom: 0;
+    background-color: rgba(0, 0, 0, 0.5);
+    display: none;
+    justify-content: center;
+    align-items: center;
+    z-index: 1000;
+    padding: 20px;
+}
+
+.popup-inner {
+    width: 100%;
+    max-width: 1200px;
+    max-height: 90vh;
+    overflow-y: auto;
+}
+
+/* .popup-header {
+    padding: 15px 20px;
+    border-bottom: 1px solid var(--gray);
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+} */
+.popup-header{
+    padding: 15px 20px;
+    border-bottom: 1px solid var(--gray);
+    display: flex;
+    justify-content: space-between;
+    align-items: stretch;
+    position: sticky;
+    top: 0;
+    background-color: white;
+    z-index: 100;
+}
+.popup-body {
+    flex: 1;
+    overflow-y: auto;
+}
+
+.popup-footer {
+    padding: 15px 20px;
+    border-top: 1px solid var(--gray);
+    display: flex;
+    justify-content: flex-end;
+    gap: 10px;
+    background-color: white;
+    z-index: 100;
+    position: sticky;
+    bottom: 0;
+}
+
+/* 结果和输出区域 */
+.result-area {
+    margin-top: 20px;
+    padding: 15px;
+    background-color: var(--gray-light);
+    border-radius: var(--border-radius-lg);
+    font-family: monospace;
+    overflow-x: auto;
+    display: none;
+}
+
+.console-output {
+    margin-top: 20px;
+    padding: 15px;
+    background-color: #f8f9fa;
+    border: 1px solid var(--gray);
+    border-radius: var(--border-radius);
+    font-family: "Consolas", monospace;
+    white-space: pre-wrap;
+    max-height: 200px;
+    overflow-y: auto;
+    font-size: 13px;
+}
+
+/* 动画效果 */
+@keyframes fadeOut {
+    from {
+        opacity: 1;
+        transform: translateX(0);
+    }
+
+    to {
+        opacity: 0;
+        transform: translateX(20px);
+    }
+}
+
+.fade-out {
+    animation: fadeOut 0.3s forwards;
+}
+
+/* 标识样式 */
+.input-marker {
+    display: inline-flex;
+    align-items: center;
+    justify-content: center;
+    width: 20px;
+    height: 20px;
+    border-radius: 50%;
+    background-color: var(--primary-light);
+    color: var(--primary-color);
+    font-size: 12px;
+    font-weight: bold;
+    margin-left: 8px;
+    cursor: pointer;
+    transition: var(--transition);
+}
+
+.input-marker:hover {
+    background-color: var(--primary-color);
+    color: white;
+}
+
+/* 标识弹窗样式 */
+.marker-popup {
+    position: absolute;
+    z-index: 100;
+    max-width: 200px;
+    padding: 12px;
+    background-color: white;
+    border-radius: var(--border-radius);
+    box-shadow: var(--shadow-lg);
+    font-size: 13px;
+    color: var(--text-secondary);
+    border: 1px solid var(--gray);
+    display: none;
+}
+
+.marker-popup::after {
+    content: '';
+    position: absolute;
+    top: 50%;
+    left: -6px;
+    transform: translateY(-50%);
+    border-width: 6px 6px 6px 0;
+    border-style: solid;
+    border-color: transparent white transparent transparent;
+}
+select:disabled {
+    color: initial; /* 保持文字颜色 */
+}

+ 7 - 29
js/addon/customer/configinfo/css/configCss.css

@@ -1,8 +1,4 @@
 .container {
-    position: absolute;
-    z-index: 100;
-    top: -5%;
-    left: 25%;
     max-width: 800px;
     margin: 0 auto;
     background: white;
@@ -10,6 +6,7 @@
     box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
     overflow: hidden;
 }
+
 .header {
     padding: 15px;
     border-bottom: 1px solid #e8e8e8;
@@ -62,7 +59,6 @@
     display: flex;
     align-items: center;
     transition: background-color 0.2s;
-    position: relative; /* 添加相对定位 */
 }
 
 .tree-node:hover {
@@ -122,9 +118,7 @@
 }
 
 .children.expanded {
-    max-height: 300px; /* 限制子节点容器高度 */
-    overflow-y: auto; /* 子节点内容过多时显示滚动条 */
-    padding-right: 10px; /* 避免滚动条与内容重叠 */
+    max-height: 1000px; /* 足够大的值以容纳所有内容 */
 }
 
 .footer {
@@ -178,9 +172,10 @@
     padding: 0 15px;
 }
 
-/* 层级缩进线优化 */
+/* 添加层级缩进线 */
 .tree-node[data-level="1"] {
     padding-left: 35px;
+    position: relative;
 }
 
 .tree-node[data-level="1"]::before {
@@ -195,6 +190,7 @@
 
 .tree-node[data-level="2"] {
     padding-left: 55px;
+    position: relative;
 }
 
 .tree-node[data-level="2"]::before {
@@ -209,6 +205,7 @@
 
 .tree-node[data-level="3"] {
     padding-left: 75px;
+    position: relative;
 }
 
 .tree-node[data-level="3"]::before {
@@ -221,7 +218,7 @@
     background-color: #e8e8e8;
 }
 
-/* 连接线优化 */
+/* 添加连接线 */
 .tree-node:not(:last-child)::after {
     content: "";
     position: absolute;
@@ -258,22 +255,3 @@
     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;
-}

+ 1020 - 0
js/addon/customer/configinfo/js/Econtarct.js

@@ -0,0 +1,1020 @@
+shr.defineClass("shr.ats.Econtarct", shr.empContract.EmpContractCompsitQueryList, {
+    protocolData: {},
+    signerCount: 1,
+    contractName: "",
+    selectedRowsData: {},
+    initalizeDOM: function () {
+        shr.ats.Econtarct.superClass.initalizeDOM.call(this);
+        this.changeEntrys();
+    },
+    sendSignAction: function () {
+        $('#field').shrPromptBox("setFilter", "eSignFile.state = 1");
+        $("#field").shrPromptBox("open");
+    },
+    changeEntrys: function () {
+        var _this = this;
+
+        // 绑定签署方类型切换事件(使用事件委托)
+        $(document).on('change', '.type-select', function () {
+            _this.changeSignerType(this);
+        });
+
+        // 绑定签署顺序验证事件(使用事件委托)
+        $(document).on('input', '.order-input', function () {
+            _this.validateOrder(this);
+        });
+
+        let lastCheckedRadio = null;
+
+        $(document).on('click', '[name="signer-radio-orgname"]', function (a, e) {
+            const $this = $(this);
+            // 判断当前点击的元素是否是上一次选中的元素
+            if ($this[0] === lastCheckedRadio) {
+                // 取消选中
+                $this.prop('checked', false);
+                lastCheckedRadio = null; // 清空记录
+            } else {
+                // 原生已自动选中当前元素,只需更新记录(同组其他项已被原生取消)
+                lastCheckedRadio = $this[0];
+            }
+            if ($('[name="signer-radio-orgname"').size() > 1) {
+                $('[name="signer-radio-orgname"').prop('checked', false)
+                lastCheckedRadio = null;
+                shr.showWarning({
+                    'message': "多个公司签署不允许使用电子签"
+                });
+            }
+        });
+
+
+        $('#field').shrPromptBox('option', {
+            afterOnSelectRowHandler: function (a, b) {
+                var l = $("#grid").jqGrid("getSelectedRowsData");
+                if (l.length !== 1) {
+                    shr.showWarning({
+                        'message': "请选择一条元数据!!注意:只能选择一条数据!"
+                    });
+                    return
+                }
+                var number = b.value.number;
+                _this.contractName = b.value.name;
+                if (number) {
+                    _this.selectedRowsData = $("#grid").jqGrid("getSelectedRowsData")[0];
+                    var id = _this.selectedRowsData ? _this.selectedRowsData.id : '';
+                    shr.callHandler({
+                        action: "getTableData",
+                        param: { "number": number, "id": id },
+                        type: "POST",
+                        success: function (res) {
+                            _this.protocolData = _this.sortFieldsBySeq(res.data);
+                            var eSignTemplateId;
+                            for (var key in _this.protocolData) {
+                                _this.protocolData[key];
+                                if (_this.protocolData[key]) {
+                                    eSignTemplateId = _this.protocolData[key].eSignTemplateNum
+                                    break;
+                                }
+
+                            }
+                            _this.renderAllTablesByColumns();
+                            _this.resetSigners(eSignTemplateId);
+                            $('#popup-overlay').css('display', 'flex');
+                        }
+                    });
+                } else {
+                    shr.showWarning({
+                        'message': "未获取到e签宝映射编码!!!"
+                    });
+                    return
+                }
+            }
+        });
+
+        // 弹窗控制
+        $('#open-popup').click(function () {
+            $('#popup-overlay').css('display', 'flex');
+        });
+
+        $('#close-popup').click(function () {
+            $('#popup-overlay').hide();
+        });
+
+        // $('#popup-overlay').click(function (e) {
+        //     if (e.target === this) {
+        //         $(this).hide();
+        //     }
+        // });
+
+        $('#addSigner').click(function () {
+            _this.signerCount++;
+
+            // 创建新签署方卡片
+            var newSigner = '<div class="signer-card" data-id="' + _this.signerCount + '">' +
+                '<div class="card-header">' +
+                '<div class="card-info">' +
+                '<select class="type-select type-personal" id="signer-' + _this.signerCount + '-type" name="signer-' + _this.signerCount + '-type" disabled>' +
+                '<option value="personal" >个人</option>' +
+                '<option value="company">企业</option>' +
+                '<option value="copy" selected>抄送</option>' +
+                '</select>' +
+                '<span class="signer-name" id="signername_index' + _this.signerCount + '" ">签署方' + _this.signerCount + '</span>' +
+                '<span class="signer-role">签署</span>' +
+                '<input type="number" min="1" max="255" value="' + _this.signerCount + '" class="order-input" id="signer-' + _this.signerCount + '-order" name="signer-' + _this.signerCount + '-order">' +
+                '</div>' +
+                '<div class="card-actions">' +
+                '<span class="action-link delete-signer"><span class="icon"></span>删除</span>' +
+                '</div>' +
+                '</div>' +
+                '<div class="form-grid signer-fields">' +
+                '<div class="form-group">' +
+                '<input type="text" placeholder="真实姓名" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name">' +
+                '<span class="input-marker" id="name-tip-' + _this.signerCount + '">ⓘ</span>' +
+                '<input type="hidden" id="signer-' + _this.signerCount + '-person-f7" name="signer-' + _this.signerCount + '-person-f7">' +
+                '</div>' +
+                '<div class="form-group">' +
+                '<input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account">' +
+                '</div>' +
+                '</div>' +
+                '</div>';
+
+            // 添加到容器
+            $('#signersContainer').append(newSigner);
+            // 初始化F7选择器
+            _this.initPersonF7(_this.signerCount);
+            $('#signer-' + _this.signerCount + '-type').val('copy').trigger('change');
+
+        });
+
+        // 删除签署方
+        $(document).on('click', '.delete-signer', function () {
+            var card = $(this).closest('.signer-card');
+            card.addClass('fade-out');
+
+            setTimeout(function () {
+                card.remove();
+                // 更新序号
+                _this.updateSignerNumbers();
+            }, 300);
+        });
+
+
+        $('#getData').click(function () {
+            var data = _this.getSignerData();
+            console.log(data);
+        });
+
+
+        // 确认按钮事件
+        $('#global-confirm').click(function () {
+            $.block.show({
+                text: '正在发送合同,请稍等...'
+            });
+            var data = _this.collectAllTableData();
+            var data1 = _this.getSignerData();
+            var signFlowTitle = $("#popup_title").attr("value");
+            var sourceId = _this.selectedRowsData ? _this.selectedRowsData.id : '';
+            var personId = _this.selectedRowsData['employee.id'];
+            var d = {};
+            d.signInfo = data1;
+            d.templateInfo = data;
+            d.signFlowTitle = signFlowTitle;
+            d.sourceId = "劳动合同" + "_" + sourceId;
+            d.personId = personId
+            console.log(d);
+            var param = {}
+            param.data = d;
+            //param.mack="preview";
+            // 调用服务获取字段数据
+            window.setTimeout(function () {
+                shr.callService({
+                    serviceName: 'create_by_fileOSF',
+                    param: param,
+                    success: function (data) {
+                        console.log("========调用合同返回参数=========")
+                        console.log(data)
+                        if (data.code === 0) {
+                            $('#popup-overlay').hide();
+                            shr.showInfo({
+                                'message': "发送成功!!!"
+                            });
+                        } else {
+                            shr.showError({
+                                'message': data.message
+                            });
+                        }
+                        $.block.hide();
+                    },
+                    error: function (e) {
+                        shr.showError({
+                            'message': e
+                        });
+                        $.block.hide();
+                    }
+                });
+            }, 300)
+        });
+    },
+    /**
+ * 处理字段排序:按seq升序排列(从小到大)
+ * @param {Object} data - 原始文档数据
+ * @returns {Object} 排序后的文档数据
+ */
+    sortFieldsBySeq: function (data) {
+        const sortedData = {};
+        // 遍历每个文档
+        Object.entries(data).forEach(([docId, docInfo]) => {
+            // 深拷贝文档信息,避免修改原对象
+            const newDocInfo = JSON.parse(JSON.stringify(docInfo));
+            // 提取fields的键值对数组,并按seq升序排序
+            const fieldsArr = Object.entries(newDocInfo.fields);
+            const sortedFieldsArr = fieldsArr.sort((a, b) => {
+                // a[1] 和 b[1] 是字段对象,取seq属性比较
+                return a[1].seq - b[1].seq; // 升序(从小到大);降序则改为 b[1].seq - a[1].seq
+            });
+            // 将排序后的数组转回对象(ES6+ 保留顺序)
+            newDocInfo.fields = Object.fromEntries(sortedFieldsArr);
+            // 存入排序后的数据对象
+            sortedData[docId] = newDocInfo;
+        });
+        return sortedData;
+    },
+
+    renderAllTablesByColumns: function () {
+        var _this = this;
+        if (_this.contractName !== "") {
+            $("#popup_title").attr("value", _this.contractName);
+        }
+        var wrapper = $('#tables-wrapper');
+        wrapper.empty();
+
+        $.each(_this.protocolData, function (protocolKey, protocolInfo) {
+            var tableContainer = $('<div>').addClass('table-container');
+            // 表格标题和预览按钮
+            var tableTitle = $('<div>').addClass('table-title');
+            tableTitle.append($('<span>').text(protocolInfo.name || '未命名模板'));
+            var previewBtn = $('<button>').addClass('preview-btn').text('预览');
+            previewBtn.click(function () {
+                _this.previewTableData(protocolKey);
+            });
+            tableTitle.append(previewBtn);
+
+            var table = $('<table>').addClass('data-table').attr('id', 'table-' + protocolKey);
+
+            var fieldNames = [];
+            var fieldValues = [];
+            $.each(protocolInfo.fields || {}, function (fieldKey, fieldInfo) {
+                if (fieldInfo.dataType !== "签署区" && fieldInfo.dataType !== "骑缝签署区" && fieldInfo.dataType !== "签署日期") {
+                    fieldNames.push(fieldInfo.name || '未命名字段');
+                    fieldValues.push({
+                        fieldKey: fieldKey,
+                        value: fieldInfo.value === null ? '' : fieldInfo.value,
+                        dataType: fieldInfo.dataType || '单行文本',
+                        dataFormat: fieldInfo.dataFormat,
+                        isRequired: fieldInfo.isRequired
+                    });
+                }
+            });
+
+            // 表头渲染
+            var thead = $('<thead>');
+            var headerTr = $('<tr>');
+            $.each(fieldNames, function (index, name) {
+                headerTr.append($('<th>').text(name));
+            });
+            thead.append(headerTr);
+            table.append(thead);
+
+            // 内容渲染
+            var tbody = $('<tbody>');
+            var dataTr = $('<tr>');
+            $.each(fieldValues, function (index, fieldData) {
+                var inputHtml;
+
+                // 处理日期类型
+                if (fieldData.dataType === "日期") {
+                    var inputType = _this.getInputType(fieldData.dataFormat);
+                    var formattedValue = _this.formatDateForInput(fieldData.value, fieldData.dataFormat);
+                    if (fieldData.isRequired) {
+                        inputHtml = '<input style="background-color: #D9EDF7;" type="' + inputType + '" value="' + formattedValue + '" placeholder="请输入值">';
+                    } else {
+                        inputHtml = '<input type="' + inputType + '" value="' + formattedValue + '" placeholder="请输入值">';
+                    }
+
+                } else if (fieldData.dataType === "勾选框") {
+                    if (fieldData.value == 1 || fieldData.value == "1") {
+                        inputHtml = '<input type="Checkbox" checked>';
+                    } else {
+                        inputHtml = '<input type="Checkbox">';
+                    }
+
+                } else {
+                    // 非日期类型使用普通文本输入
+
+                    if (fieldData.isRequired) {
+                        inputHtml = '<input style="background-color: #D9EDF7;" type="text" value="' + fieldData.value + '" placeholder="请输入值">';
+                    } else {
+                        inputHtml = '<input type="text" value="' + fieldData.value + '" placeholder="请输入值">';
+                    }
+                }
+                if (fieldData.dataType !== "签署区" && fieldData.dataType !== "骑缝签署区" && fieldData.dataType !== "签署日期") {
+                    dataTr.append($(
+                        '<td data-field-key="' + fieldData.fieldKey + '" ' +
+                        'data-data-type="' + fieldData.dataType + '"' +
+                        'data-data-format="' + fieldData.dataFormat + '">' +
+                        inputHtml +
+                        '</td>'
+                    ));
+                }
+            });
+            tbody.append(dataTr);
+            table.append(tbody);
+
+            tableContainer.append(tableTitle).append(table);
+            wrapper.append(tableContainer);
+        });
+    },
+    formatDateForInput: function (value, dataFormat) {
+        if (!value) return '';
+
+        // 补零工具函数:保证数字为两位(兼容ES5及以上)
+        function padZero(num) {
+            return num < 10 ? '0' + num : num;
+        }
+
+        // 尝试解析各种可能的日期格式
+        var date;
+        if (value instanceof Date) {
+            date = value;
+        } else {
+            // 替换常见分隔符(包括中文年、月、日),统一为 '-' 和 'T'(兼容ISO格式)
+            var normalizedValue = value
+                .replace(/[./年]/g, '-')    // 将 . / 年 替换为 -
+                .replace(/月/g, '-')        // 将 月 替换为 -
+                .replace(/日/g, '')         // 移除 日
+                .replace(/\s+/, 'T')        // 空格替换为T(衔接时分秒)
+                .replace(/:/g, ':');        // 保留冒号(时分秒分隔符)
+
+            date = new Date(normalizedValue);
+
+            // 如果解析失败,尝试其他格式
+            if (isNaN(date.getTime())) {
+                // 处理类似 "2025-11" 这样的年月格式
+                if (value.match(/^\d{4}-\d{2}$/)) {
+                    date = new Date(value + '-01');
+                } else {
+                    console.warn('无法解析日期: ' + value);
+                    return value; // 解析失败时返回原始值
+                }
+            }
+        }
+
+        // 根据dataFormat返回对应格式
+        if (dataFormat.indexOf('yyyy-MM-dd HH:mm:ss') !== -1) {
+            return date.toISOString().slice(0, 19).replace('T', ' '); // 注意:原代码slice(0,19)是"2025-11-12T13:45:30",这里替换T为空格更符合常规
+        } else if (dataFormat.indexOf('yyyy-MM-dd HH:mm') !== -1) {
+            return date.toISOString().slice(0, 16).replace('T', ' ');
+        } else if (dataFormat.indexOf('yyyy-MM-dd') !== -1) {
+            return date.toISOString().slice(0, 10);
+        } else if (dataFormat.indexOf('yyyy年MM月dd日') !== -1) {
+            // 基础中文日期格式:yyyy年MM月dd日
+            const year = date.getFullYear();
+            const month = padZero(date.getMonth() + 1); // 月份是0-based(0-11),需+1
+            const day = padZero(date.getDate());
+            let result = `${year}年${month}月${day}日`;
+
+            // 扩展:处理时分秒
+            if (dataFormat.indexOf('HH:mm:ss') !== -1) {
+                const hour = padZero(date.getHours());
+                const minute = padZero(date.getMinutes());
+                const second = padZero(date.getSeconds());
+                result += ` ${hour}:${minute}:${second}`;
+            } else if (dataFormat.indexOf('HH:mm') !== -1) {
+                const hour = padZero(date.getHours());
+                const minute = padZero(date.getMinutes());
+                result += ` ${hour}:${minute}`;
+            }
+            return result;
+        }
+
+        // 未知格式,返回原始值
+        return value;
+    },
+    getInputType: function (dataFormat) {
+        // 添加对dataFormat的检查,无值时默认使用"yyyy-MM-dd"
+        if (!dataFormat) {
+            dataFormat = "yyyy-MM-dd";
+        }
+
+        // 处理中文日期格式:yyyy年MM月dd日(包括扩展格式)
+        if (dataFormat.indexOf('yyyy年MM月dd日') !== -1) {
+            return 'text';
+        }
+
+        // 简化原有逻辑:合并HH:mm:ss和HH:mm的判断
+        if (dataFormat.indexOf('HH:mm') !== -1) { // 同时匹配HH:mm和HH:mm:ss
+            return 'datetime-local';
+        } else if (dataFormat.indexOf('yyyy-MM-dd') !== -1) {
+            return 'date';
+        }
+
+        // 未知格式返回text
+        return 'text';
+    },
+
+    // 预览单个表格数据
+    previewTableData: function (protocolKey) {
+        var _this = this;
+        var protocolInfo = _this.protocolData[protocolKey] || {};
+        var tableData = {};
+        tableData[protocolKey] = {
+            "name": protocolInfo.name || protocolKey,
+            "id": protocolInfo.id || protocolKey,
+            "fields": {}
+        };
+
+        $('#table-' + protocolKey + ' tbody tr td').each(function (index) {
+            var fieldKey = $(this).data('field-key');
+            var fieldName = $('#table-' + protocolKey + ' thead th:eq(' + index + ')').text() || '字段' + (index + 1);
+            var value = $(this).find('input').val() || null;
+
+            var dataType = "单行文本";
+            if (protocolInfo.fields && protocolInfo.fields[fieldKey]) {
+                dataType = protocolInfo.fields[fieldKey].dataType || "单行文本";
+            }
+            if (dataType === "勾选框") {
+                value = "" + $(this).find('input').is(':checked') + ""
+            }
+
+            tableData[protocolKey].fields[fieldKey] = {
+                name: fieldName,
+                dataType: dataType,
+                value: value
+            };
+        });
+        var param = {}
+        param.data = tableData;
+        param.mack = "preview";
+        $.block.show({
+            text: '正在获取预览地址,请稍等...'
+        });
+        window.setTimeout(function () {
+            // 调用服务获取字段数据
+            shr.callService({
+                serviceName: 'create_by_fileOSF',
+                param: param,
+                success: function (data) {
+                    console.log("========调用合同返回参数=========")
+                    console.log(data)
+                    if (data.code !== 0) {
+                        shr.showError({
+                            'message': data.message
+                        });
+                    } else {
+                        window.open(data.data.fileDownloadUrl, '_blank');
+                    }
+                    $.block.hide();
+                },
+                error: function (e) {
+                    shr.showError({
+                        'message': e
+                    });
+                    $.block.hide();
+                }
+            });
+        }, 300)
+
+    },
+    // 收集所有表格数据
+    collectAllTableData: function () {
+        var allData = {};
+        var _this = this;
+        $.each(_this.protocolData, function (protocolKey, protocolInfo) {
+            // var tableData = {
+            //     tableName: protocolInfo.name,
+            //     tableId: protocolInfo.id,
+            //     fields: protocolInfo.fields
+            // };
+            var tableData = protocolInfo
+            $('#table-' + protocolKey + ' tbody tr td').each(function (index) {
+                var fieldKey = $(this).data('field-key');
+                var fieldName = $('#table-' + protocolKey + ' thead th:eq(' + index + ')').text();
+                var dataType = $(this).data('data-type');
+                var dataFormat = $(this).data('data-format');
+                tableData.fields[fieldKey].name = fieldName;
+                tableData.fields[fieldKey].dataType = dataType;
+                tableData.fields[fieldKey].dataFormat = dataFormat;
+                var value = ""
+                if (dataType == "勾选框") {
+                    value = "" + $(this).find('input').is(':checked') + ""
+                } else {
+                    value = $(this).find('input').val() || null;
+                }
+                tableData.fields[fieldKey].value = value;
+                // tableData.fields[fieldKey] = {
+                //     name: fieldName,
+                //     dataType: dataType,
+                //     dataFormat: dataFormat,
+                //     value: value
+                // };
+            });
+
+            allData[protocolKey] = tableData;
+        });
+        console.log('===== 所有表格数据 =====');
+        console.log(JSON.stringify(allData, null, 2));
+        return allData;
+    },
+    // 验证签署顺序输入值
+    validateOrder: function (input) {
+        var value = parseInt(input.value);
+        if (isNaN(value) || value < 1) {
+            input.value = 1;
+        } else if (value > 255) {
+            input.value = 255;
+        }
+    },
+
+    // 切换签署方类型
+    changeSignerType: function (selectElement) {
+        var type = selectElement.value;
+        var card = $(selectElement).closest('.signer-card');
+        var cardId = card.attr('data-id');
+        var fieldsContainer = card.find('.signer-fields');
+        var orderInput = card.find('.order-input');
+        var roleElement = card.find('.signer-role');
+
+        var nameElement = card.find('.signer-name');
+
+        // 更新选择框样式和颜色
+        if (type === 'personal') {
+            $(selectElement).removeClass('type-company type-copy').addClass('type-personal');
+            // 显示个人字段和签署顺序
+            fieldsContainer.html(
+                '<div class="form-group">' +
+                '<input type="text" placeholder="真实姓名" class="input-field" id="signer-' + cardId + '-name" name="signer-' + cardId + '-name">' +
+                '<span class="input-marker" id="name-tip-' + cardId + '">ⓘ</span>' +
+                '<input type="hidden" id="signer-' + cardId + '-person-f7" name="signer-' + cardId + '-person-f7">' +
+                '</div>' +
+                '<div class="form-group">' +
+                '<input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + cardId + '-account" name="signer-' + cardId + '-account">' +
+                '</div>'
+            );
+            nameElement.text('签署方' + cardId)
+            roleElement.text('签署');
+            $('#span-' + cardId + '').remove();
+            orderInput.show();
+            // 初始化F7选择器
+            this.initPersonF7(cardId);
+        } else if (type === 'company') {
+            $(selectElement).removeClass('type-personal type-copy').addClass('type-company');
+            $('#signer-' + cardId + '-order').after('<span id="span-' + cardId + '" style="display: none;"> 自动签 <input type="radio" placeholder="" class="" id="signer-' + cardId + '-radio" name="signer-radio-orgname"></span>');
+            // 显示企业字段和签署顺序
+            fieldsContainer.html(
+                '<div class="form-group">' +
+                '<input type="text" placeholder="请输入企业完整名称" class="input-field" id="signer-' + cardId + '-orgname" name="signer-' + cardId + '-orgname">' +
+                '</div>' +
+                '<div class="form-group">' +
+                '<input readonly type="text" placeholder="企业章" class="input-field" id="signer-' + cardId + '-orgnId" name="signer-' + cardId + '-orgnId">' +
+                '<span class="input-marker" id="name-orgId-' + cardId + '">ⓘ</span>' +
+                '<input type="hidden" id="signer-' + cardId + '-orgnId-f7" name="signer-' + cardId + '-orgnId-f7">' +
+                '</div>' +
+                '<div class="form-group">' +
+                '<input type="text" placeholder="真实姓名" class="input-field" id="signer-' + cardId + '-name" name="signer-' + cardId + '-name">' +
+                '<span class="input-marker" id="name-tip-' + cardId + '">ⓘ</span>' +
+                '<input type="hidden" id="signer-' + cardId + '-person-f7" name="signer-' + cardId + '-person-f7">' +
+                '</div>' +
+                '<div class="form-group">' +
+                '<input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + cardId + '-account" name="signer-' + cardId + '-account">' +
+                '</div>'
+            );
+            nameElement.text('签署方' + cardId)
+            roleElement.text('签署');
+            orderInput.show();
+            // 初始化F7选择器
+            this.initPersonF7(cardId);
+        } else if (type === 'copy') {
+            // 处理抄送类型
+            $(selectElement).removeClass('type-personal type-company').addClass('type-copy');
+            $('#span-' + cardId + '').remove();
+            // 显示抄送字段,隐藏签署顺序
+            fieldsContainer.html(
+                '<div class="form-group">' +
+                '<input type="text" placeholder="真实姓名" class="input-field" id="signer-' + cardId + '-name" name="signer-' + cardId + '-name">' +
+                '<span class="input-marker" id="name-tip-' + cardId + '">ⓘ</span>' +
+                '<input type="hidden" id="signer-' + cardId + '-person-f7" name="signer-' + cardId + '-person-f7">' +
+                '</div>' +
+                '<div class="form-group">' +
+                '<input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + cardId + '-account" name="signer-' + cardId + '-account">' +
+                '</div>'
+            );
+            nameElement.text('抄送方' + cardId)
+            roleElement.text('抄送');
+            orderInput.hide(); // 隐藏签署顺序
+            // 初始化F7选择器
+            this.initPersonF7(cardId);
+        }
+    },
+
+    // 初始化人员选择F7
+    initPersonF7: function (cardId) {
+        var grid_f7_json = {
+            id: 'signer-' + cardId + '-person-f7',
+            name: 'signer-' + cardId + '-person-f7'
+        };
+        grid_f7_json.subWidgetName = 'shrPromptGrid';
+        grid_f7_json.subWidgetOptions = {
+            title: "员工",
+            uipk: "com.kingdee.eas.custom.entryconfig.app.person.F7",
+            query: "",
+            filter: "",
+            domain: "",
+            multiselect: false,
+            treeFilterConfig: '',
+            permItemId: "",
+            isHasMultileDialog: false,
+            isTree: false,
+            treeUrl: "",
+            isContainLowerOrg: false,
+            isAdminOrg: false,
+            pgSizes: true,
+            f7SearchConfig: { "displayField": [], "filterFields": "" },
+            dataShowMode: "layout"
+        };
+        grid_f7_json.readonly = '';
+        grid_f7_json.validate = '{required:false}';
+        grid_f7_json.value = { 'id': "", 'name': "" };
+        grid_f7_json.isHROrg = "false";
+        grid_f7_json.isAdminOrg = "false";
+        grid_f7_json.searchLikePattern = "any";
+
+        // 初始化F7选择器
+        $('#signer-' + cardId + '-person-f7').shrPromptBox(grid_f7_json);
+
+        // 绑定选择事件,将选择的姓名回填到真实姓名输入框
+        $('#signer-' + cardId + '-person-f7').shrPromptBox('option', {
+            afterOnSelectRowHandler: function (a, data) {
+                $('#signer-' + cardId + '-name').val(data.value.name);
+                $('#signer-' + cardId + '-account').val(data.value.cell);
+                console.log(data);
+            }
+        });
+        $('#name-tip-' + cardId).click(function () {
+            $('#signer-' + cardId + '-person-f7').shrPromptBox("open");
+        });
+        $('#signer-' + cardId + '-person-f7').parent().parent().parent().hide();
+
+
+
+
+        id = "signer-' + cardId + '-orgnId-f7"
+
+
+        var grid_f7_json = {
+            id: 'signer-' + cardId + '-orgnId-f7',
+            name: 'signer-' + cardId + '-orgnId-f7'
+        };
+        grid_f7_json.subWidgetName = 'shrPromptGrid';
+        grid_f7_json.subWidgetOptions = {
+            title: "印章",
+            uipk: "com.kingdee.eas.custom.esign.app.Seal.list",
+            query: "",
+            filter: "",
+            domain: "",
+            multiselect: false,
+            treeFilterConfig: '',
+            permItemId: "",
+            isHasMultileDialog: false,
+            isTree: false,
+            treeUrl: "",
+            isContainLowerOrg: false,
+            isAdminOrg: false,
+            pgSizes: true,
+            f7SearchConfig: { "displayField": [], "filterFields": "" },
+            dataShowMode: "layout"
+        };
+        grid_f7_json.readonly = '';
+        grid_f7_json.validate = '{required:false}';
+        grid_f7_json.value = { 'id': "", 'name': "" };
+        grid_f7_json.isHROrg = "false";
+        grid_f7_json.isAdminOrg = "false";
+        grid_f7_json.searchLikePattern = "any";
+
+        // 初始化F7选择器
+        $('#signer-' + cardId + '-orgnId-f7').shrPromptBox(grid_f7_json);
+
+        $('#signer-' + cardId + '-orgnId-f7').shrPromptBox('option', {
+            afterOnSelectRowHandler: function (a, data) {
+                $('#signer-' + cardId + '-orgnId').val(data.value.sealId);
+                console.log(data);
+            }
+        });
+        $('#name-orgId-' + cardId).click(function () {
+            $('#signer-' + cardId + '-orgnId-f7').shrPromptBox("open");
+        });
+
+        $('#signer-' + cardId + '-orgnId-f7').parent().parent().parent().hide();
+    },
+
+    // 更新签署方序号
+    updateSignerNumbers: function () {
+        var _this = this;
+        $('.signer-card').each(function (index, element) {
+            var newNumber = index + 1;
+            var oldId = $(element).attr('data-id');
+
+            // 更新卡片ID
+            $(element).attr('data-id', newNumber);
+
+            // 更新显示名称
+            $(element).find('.signer-name').text('签署方' + newNumber);
+
+            // 更新所有相关元素的ID和name属性
+            $(element).find('[id^="signer-' + oldId + '-"]').each(function () {
+                var field = $(this).attr('id').split('-').pop();
+                $(this).attr('id', 'signer-' + newNumber + '-' + field);
+                var name = $(this).attr('name');
+                if (name !== "signer-radio-orgname") {
+                    $(this).attr('name', 'signer-' + newNumber + '-' + field);
+                }
+            });
+
+            // 重新初始化F7组件(因为ID发生了变化)
+            _this.initPersonF7(newNumber);
+
+            // 如果没有设置过顺序值,自动填充序号(只对非抄送类型生效)
+            var orderInput = $(element).find('.order-input');
+            var typeSelect = $(element).find('.type-select');
+
+            if (typeSelect.val() !== 'copy' && (!orderInput.val() || orderInput.val() < 1)) {
+                orderInput.val(newNumber);
+            }
+        });
+        _this.signerCount = $('.signer-card').length;
+    },
+
+    // 获取数据方法
+    getSignerData: function () {
+        var result = {
+            signers: [],
+            copiers: []
+        };
+
+        // 遍历所有签署方卡片
+        $('.signer-card').each(function () {
+            var cardId = $(this).attr('data-id');
+            var type = $(this).find('#signer-' + cardId + '-type').val();
+            // 获取F7选择的完整数据
+            var f7Data = $('#signer-' + cardId + '-person-f7').shrPromptBox('getValue') || {};
+
+            if (type === 'personal') {
+                // 个人签署方
+                result.signers.push({
+                    psnSignerInfo: {
+                        psnAccount: $(this).find('#signer-' + cardId + '-account').val() || '',
+                        psnName: $(this).find('#signer-' + cardId + '-name').val() || '',
+                        signOrder: $(this).find('#signer-' + cardId + '-order').val() || '1',
+                        f7Data: f7Data, // 包含F7选择的完整数据
+                        signName: $(this).find('#signername_index' + cardId).text() || '',
+                    }
+                });
+            } else if (type === 'company') {
+                // 企业签署方
+                result.signers.push({
+                    orgSignerInfo: {
+                        orgName: $(this).find('#signer-' + cardId + '-orgname').val() || '',
+                        psnName: $(this).find('#signer-' + cardId + '-name').val() || '',
+                        psnAccount: $(this).find('#signer-' + cardId + '-account').val() || '',
+                        signOrder: $(this).find('#signer-' + cardId + '-order').val() || '1',
+                        f7Data: f7Data, // 包含F7选择的完整数据
+                        sealId: $(this).find('#signer-' + cardId + '-orgnId').val() || '',
+                        isRadio: $('#signer-' + cardId + '-radio').is(":checked"),
+                        signName: $(this).find('#signername_index' + cardId).text() || '',
+                    }
+                });
+            } else if (type === 'copy') {
+                // 抄送方
+                result.copiers.push({
+                    psnAccount: $(this).find('#signer-' + cardId + '-account').val() || '',
+                    psnName: $(this).find('#signer-' + cardId + '-name').val() || '',
+                    f7Data: f7Data, // 包含F7选择的完整数据
+                    signName: $(this).find('#signername_index' + cardId).text() || '',
+                });
+            }
+        });
+
+        return result;
+    },
+    // 重置参与方设置
+    resetSigners: function (eSignTemplateId) {
+        var _this = this;
+        // 清空现有签署方卡片
+        $('#signersContainer').empty();
+        // 重置签署方计数
+        this.signerCount = 1;
+        // 隐藏结果区域
+        $('#resultArea').hide();
+        var param = {}
+        param.mack = "getTemplate";
+        param.eSignTemplateNum = eSignTemplateId
+        shr.callService({
+            serviceName: 'create_by_fileOSF',
+            param: param,
+            success: function (data) {
+                console.log("========签署信息=========")
+                console.log(data)
+                if (data.data.length <= 0) {
+                    shr.showWarning({
+                        'message': "未获取到设置签署信息请自行设置签署人!注:需要和e签宝保持一致。"
+                    });
+                }
+                var d = data.data
+                for (let i = 0; i < d.length; i++) {
+                    var entry = d[i];
+                    //签署类型 1 公司签署 2 个人签署 3 抄送人
+                    var type = entry.participantType;
+
+                    var defaultSigner = "";
+
+                    if (type == 1 || type == "1") {
+                        var participantFlag = entry.participantFlag;
+                        var orgParticipant = entry.orgParticipant
+                        var participantSetMode = entry.participantSetMode
+                        if (participantSetMode == 2 ) {
+                            continue;
+                        }
+                        defaultSigner = '<div class="signer-card" data-id="' + _this.signerCount + '">' +
+                            '<div class="card-header">' +
+                            '<div class="card-info"><select class="type-select type-company" id="signer-' + _this.signerCount + '-type" name="signer-' + _this.signerCount + '-type" disabled>' +
+                            '<option value="personal" >个人</option>' +
+                            '<option value="company" selected >企业</option>' +
+                            '<option value="copy">抄送</option>' +
+                            '</select>' +
+                            '<span class="signer-name" id="signername_index' + _this.signerCount + '">' + participantFlag + '</span><span class="signer-role">签署</span>' +
+                            '<input type="number" min="1" max="255" value="' + _this.signerCount + '" class="order-input"id="signer-' + _this.signerCount + '-order" name="signer-' + _this.signerCount + '-order" style="">' +
+                            '<span id="span-' + _this.signerCount + '" style="display: none;"> 自动签 <input type="radio"placeholder="" class="" id="signer-' + _this.signerCount + '-radio" name="signer-radio-orgname"></span>' +
+                            '</div>' +
+                            '<!--div class="card-actions"><span class="action-link delete-signer"><span class="icon"></span>删除</span></div-->' +
+                            '</div>' +
+                            '<div class="form-grid signer-fields">'
+                        if (orgParticipant != null) {
+                            var orgName = orgParticipant.orgName;
+                            //disabled
+                            if (orgName != null && orgName != undefined && orgName != "") {
+                                defaultSigner += '<div class="form-group"><input type="text" placeholder="请输入企业完整名称" value="' + orgParticipant.orgName + '" class="input-field" id="signer-' + _this.signerCount + '-orgname"name="signer-' + _this.signerCount + '-orgname"></div>'
+                            } else {
+                                defaultSigner += '<div class="form-group"><input type="text" placeholder="请输入企业完整名称" value="' + orgParticipant.orgName + '" class="input-field" id="signer-' + _this.signerCount + '-orgname"name="signer-' + _this.signerCount + '-orgname" disabled ></div>'
+                            }
+                        } else {
+                            defaultSigner += '<div class="form-group"><input type="text" placeholder="请输入企业完整名称" value="" class="input-field" id="signer-' + _this.signerCount + '-orgname"name="signer-' + _this.signerCount + '-orgname"></div>'
+                        }
+
+                        defaultSigner += '<div class="form-group"><input readonly="" type="text" placeholder="企业章" class="input-field"id="signer-' + _this.signerCount + '-orgnId" name="signer-' + _this.signerCount + '-orgnId"><span class="input-marker" id="name-orgId-' + _this.signerCount + '">ⓘ</span>' +
+                            '<div class="ui-promptBox-frame" style="display: none;">' +
+                            '<div class="ui-promptBox-layout">' +
+                            '<div class="ui-promptBox-inputframe"><input type="hidden" id="signer-' + _this.signerCount + '-orgnId-f7_el" name="hidd_name_signer-' + _this.signerCount + '-orgnId-f7" value=""><input type="hidden" id="signer-' + _this.signerCount + '-orgnId-f7"name="signer-' + _this.signerCount + '-orgnId-f7" ctrlrole="promptBox" autocomplete="off" value="" title=""></div>' +
+                            '<div class="ui-promptBox-icon"><img style="cursor:pointer;" src="/shr/styles/images/seniorf7.png">' +
+                            '</div>' +
+                            '</div>' +
+                            '</div>' +
+                            '</div>';
+                        if (orgParticipant != null) {
+                            var transactor = orgParticipant.transactor;
+                            if (transactor != null && transactor != undefined) {
+                                defaultSigner += '<div class="form-group"><input type="text" placeholder="真实姓名" value="' + transactor.transactorName + '" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name"><span class="input-marker" id="name-tip-' + _this.signerCount + '">ⓘ</span>'
+                            } else {
+                                defaultSigner += '<div class="form-group"><input type="text" placeholder="真实姓名" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name"><span class="input-marker" id="name-tip-' + _this.signerCount + '">ⓘ</span>'
+
+                            }
+
+                        } else {
+                            defaultSigner += '<div class="form-group"><input type="text" placeholder="真实姓名" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name"><span class="input-marker" id="name-tip-' + _this.signerCount + '">ⓘ</span>'
+                        }
+                        defaultSigner += '<div class="ui-promptBox-frame" style="display: none;">' +
+                            '<div class="ui-promptBox-layout">' +
+                            '<div class="ui-promptBox-inputframe"><input type="hidden" id="signer-' + _this.signerCount + '-person-f7_el" name="hidd_name_signer-' + _this.signerCount + '-person-f7" value=""><input type="hidden" id="signer-' + _this.signerCount + '-person-f7"' +
+                            ' name="signer-' + _this.signerCount + '-person-f7" ctrlrole="promptBox" autocomplete="off" value="" title=""></div>' +
+                            '<div class="ui-promptBox-icon"><img style="cursor:pointer;" src="/shr/styles/images/seniorf7.png">' +
+                            '</div>' +
+                            '</div>' +
+                            '</div>' +
+                            '</div>';
+                        if (orgParticipant != null) {
+                            var transactor = orgParticipant.transactor;
+                            if (transactor != null && transactor != undefined) {
+                                defaultSigner += '<div class="form-group"><input type="text" placeholder="请输入手机号/邮箱" value="' + transactor.transactorPsnAccount + '" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account"></div>';
+                            } else {
+                                defaultSigner += '<div class="form-group"><input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account"></div>';
+
+                            }
+
+                        } else {
+                            defaultSigner += '<div class="form-group"><input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account"></div>';
+                        }
+                        defaultSigner += '</div>' +
+                            '</div>';
+                    } else if (type == 2 || type == "2") {
+                        var participantFlag = entry.participantFlag;
+                        var psnParticipant = entry.psnParticipant
+                        var participantSetMode = entry.participantSetMode
+                        if (participantSetMode == 2 ) {
+                            continue;
+                        }
+                        // 添加默认的第一个签署方卡片 默认个人
+                        defaultSigner = '<div class="signer-card" data-id="' + _this.signerCount + '">' +
+                            '<div class="card-header">' +
+                            '<div class="card-info">' +
+                            '<select class="type-select type-personal" id="signer-' + _this.signerCount + '-type" name="signer-' + _this.signerCount + '-type" disabled>' +
+                            '<option value="personal" selected >个人</option>' +
+                            '<option value="company" >企业</option>' +
+                            '<option value="copy">抄送</option>' +
+                            '</select>' +
+                            '<span class="signer-name" id = "signername_index' + _this.signerCount + '">' + participantFlag + '</span>' +
+                            '<span class="signer-role">签署</span>' +
+                            '<input type="number" min="1" max="255" value="' + _this.signerCount + '" class="order-input" id="signer-' + _this.signerCount + '-order" name="signer-' + _this.signerCount + '-order">' +
+                            '</div>' +
+                            '<!--div class="card-actions">' +
+                            '<span class="action-link delete-signer"><span class="icon"></span>删除</span>' +
+                            '</div-->' +
+                            '</div>' +
+                            '<div class="form-grid signer-fields">' +
+                            '<div class="form-group">';
+                        if (psnParticipant != null && psnParticipant != undefined) {
+                            defaultSigner += '<input type="text" placeholder="真实姓名" value="' + psnParticipant.psnName + '" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name">';
+                        } else {
+                            defaultSigner += '<input type="text" placeholder="真实姓名" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name">';
+                        }
+                        defaultSigner += '<span class="input-marker" id="name-tip-' + _this.signerCount + '">ⓘ</span>' +
+                            '<input type="hidden" id="signer-' + _this.signerCount + '-person-f7" name="signer-' + _this.signerCount + '-person-f7">' +
+                            '</div>' +
+                            '<div class="form-group">';
+                        if (psnParticipant != null && psnParticipant != undefined) {
+                            defaultSigner += '<input type="text" placeholder="请输入手机号/邮箱" value="' + psnParticipant.psnAccount + '" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account">';
+                        } else {
+                            defaultSigner += '<input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account">';
+                        }
+                        defaultSigner += '</div>' +
+                            '</div>' +
+                            '</div>';
+                    } else if (type == 3 || type == "3") {
+                        var copierPsnInfo = entry.copierPsnInfo;
+                        defaultSigner = '<div class="signer-card" data-id="' + _this.signerCount + '">' +
+                            '<div class="card-header">' +
+                            '<div class="card-info"><select class="type-select type-copy" id="signer-' + _this.signerCount + '-type" name="signer-' + _this.signerCount + '-type" disabled>' +
+                            '<option value="personal">个人</option>' +
+                            '<option value="company">企业</option>' +
+                            '<option value="copy" selected >抄送</option>' +
+                            '</select>' +
+                            '<span class="signer-name" id="signername_index' + _this.signerCount + '" > 抄送方' + _this.signerCount + '</span><span class="signer-role">抄送</span>' +
+                            '<input type="number" min="1" max="255" value="' + _this.signerCount + '" class="order-input" id="signer-' + _this.signerCount + '-order" name="signer-' + _this.signerCount + '-order" style="display: none;"></div>' +
+                            '<!--div class="card-actions"><span class="action-link delete-signer"><span class="icon"></span>删除</span></div-->' +
+                            '</div>' +
+                            '<div class="form-grid signer-fields">' +
+                            '<div class="form-group">';
+                        if (copierPsnInfo != null && copierPsnInfo != undefined) {
+                            defaultSigner += '<input type="text" placeholder="真实姓名" value="' + copierPsnInfo.psnName + '" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name">';
+
+                        } else {
+                            defaultSigner += '<input type="text" placeholder="真实姓名" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name">';
+                        }
+                        defaultSigner += '<span class="input-marker" id="name-tip-' + _this.signerCount + '">ⓘ</span>' +
+                            '<div class="ui-promptBox-frame" style="display: none;">' +
+                            '<div class="ui-promptBox-layout">' +
+                            '<div class="ui-promptBox-inputframe">' +
+                            '<input type="hidden" id="signer-' + _this.signerCount + '-person-f7_el" name="hidd_name_signer-' + _this.signerCount + '-person-f7" value="">' +
+                            '<input type="hidden" id="signer-' + _this.signerCount + '-person-f7" name="signer-' + _this.signerCount + '-person-f7" ctrlrole="promptBox" autocomplete="off" value="" title="">' +
+                            '</div>' +
+                            '<div class="ui-promptBox-icon"><img style="cursor:pointer;" src="/shr/styles/images/seniorf7.png">' +
+                            '</div>' +
+                            '</div>' +
+                            '</div>' +
+                            '</div>' +
+                            '<div class="form-group">';
+                        if (copierPsnInfo != null && copierPsnInfo != undefined) {
+                            defaultSigner += '<input type="text" placeholder="请输入手机号/邮箱" value="' + copierPsnInfo.psnAccount + '" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account">';
+
+                        } else {
+                            defaultSigner += '<input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account">';
+                        }
+                        defaultSigner += '</div>' +
+                            '</div>' +
+                            '</div>';
+
+                    } else {
+                        shr.showWarning({
+                            'message': "获取到设置签署信息失败!请自行设置签署人!注:需要和e签宝保持一致。"
+                        });
+                    }
+                    $('#signersContainer').append(defaultSigner);
+                    _this.initPersonF7(_this.signerCount);
+                    _this.signerCount++
+                }
+
+            },
+            error: function (e) {
+                shr.showError({
+                    'message': e
+                });
+            }
+        });
+    }
+});

+ 1013 - 0
js/addon/customer/configinfo/js/EcontarctEx.js

@@ -0,0 +1,1013 @@
+shr.defineClass("shr.ats.Econtarct", shr.framework.List, {
+    protocolData: {},
+    signerCount: 1,
+    contractName: "",
+    selectedRowsData: {},
+    initalizeDOM: function () {
+        shr.ats.Econtarct.superClass.initalizeDOM.call(this);
+        this.changeEntrys();
+    },
+    sendSignAction: function () {
+        var _this = this;
+        var l = $("#grid").jqGrid("getSelectedRowsData");
+        if (l.length !== 1) {
+            shr.showWarning({
+                'message': "请选择一条元数据!!注意:只能选择一条数据!"
+            });
+            return
+        }
+        var id = l[0]["person.id"];
+        var number = l[0]["eSignMapping.number"];
+        _this.contractName = l[0]["eSignMapping.name"]
+        if (number) {
+            shr.callHandler({
+                action: "getTableData",
+                param: { "number": number, "id": id },
+                type: "POST",
+                success: function (res) {
+                    _this.protocolData = _this.sortFieldsBySeq(res.data);
+                    _this.renderAllTablesByColumns();
+                    var eSignTemplateId;
+                    for (var key in _this.protocolData) {
+                        _this.protocolData[key];
+                        if (_this.protocolData[key]) {
+                            eSignTemplateId = _this.protocolData[key].eSignTemplateNum
+                            break;
+                        }
+
+                    }
+                    _this.resetSigners(eSignTemplateId);
+                    $('#popup-overlay').css('display', 'flex');
+                }
+            });
+        } else {
+            shr.showWarning({
+                'message': "未获取到e签宝映射!!"
+            });
+            return
+        }
+
+    },
+    changeEntrys: function () {
+        var _this = this;
+        // 绑定签署方类型切换事件(使用事件委托)
+        $(document).on('change', '.type-select', function () {
+            _this.changeSignerType(this);
+        });
+
+        // 绑定签署顺序验证事件(使用事件委托)
+        $(document).on('input', '.order-input', function () {
+            _this.validateOrder(this);
+        });
+
+        // 弹窗控制
+        $('#open-popup').click(function () {
+            $('#popup-overlay').css('display', 'flex');
+        });
+
+        $('#close-popup').click(function () {
+            $('#popup-overlay').hide();
+        });
+
+        // $('#popup-overlay').click(function (e) {
+        //     if (e.target === this) {
+        //         $(this).hide();
+        //     }
+        // });
+
+        let lastCheckedRadio = null;
+
+        $(document).on('click', '[name="signer-radio-orgname"]', function (a, e) {
+            const $this = $(this);
+            // 判断当前点击的元素是否是上一次选中的元素
+            if ($this[0] === lastCheckedRadio) {
+                // 取消选中
+                $this.prop('checked', false);
+                lastCheckedRadio = null; // 清空记录
+            } else {
+                // 原生已自动选中当前元素,只需更新记录(同组其他项已被原生取消)
+                lastCheckedRadio = $this[0];
+            }
+            if ($('[name="signer-radio-orgname"').size() > 1) {
+                $('[name="signer-radio-orgname"').prop('checked', false)
+                lastCheckedRadio = null;
+                shr.showWarning({
+                    'message': "多个公司签署不允许使用电子签"
+                });
+            }
+        });
+
+
+        $('#addSigner').click(function () {
+            _this.signerCount++;
+
+            // 创建新签署方卡片
+            var newSigner = '<div class="signer-card" data-id="' + _this.signerCount + '">' +
+                '<div class="card-header">' +
+                '<div class="card-info">' +
+                '<select class="type-select type-personal" id="signer-' + _this.signerCount + '-type" name="signer-' + _this.signerCount + '-type" disabled>' +
+                '<option value="personal" >个人</option>' +
+                '<option value="company">企业</option>' +
+                '<option value="copy" selected>抄送</option>' +
+                '</select>' +
+                '<span class="signer-name" id="signername_index' + _this.signerCount + '" ">签署方' + _this.signerCount + '</span>' +
+                '<span class="signer-role">签署</span>' +
+                '<input type="number" min="1" max="255" value="' + _this.signerCount + '" class="order-input" id="signer-' + _this.signerCount + '-order" name="signer-' + _this.signerCount + '-order">' +
+                '</div>' +
+                '<div class="card-actions">' +
+                '<span class="action-link delete-signer"><span class="icon"></span>删除</span>' +
+                '</div>' +
+                '</div>' +
+                '<div class="form-grid signer-fields">' +
+                '<div class="form-group">' +
+                '<input type="text" placeholder="真实姓名" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name">' +
+                '<span class="input-marker" id="name-tip-' + _this.signerCount + '">ⓘ</span>' +
+                '<input type="hidden" id="signer-' + _this.signerCount + '-person-f7" name="signer-' + _this.signerCount + '-person-f7">' +
+                '</div>' +
+                '<div class="form-group">' +
+                '<input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account">' +
+                '</div>' +
+                '</div>' +
+                '</div>';
+
+            // 添加到容器
+            $('#signersContainer').append(newSigner);
+            // 初始化F7选择器
+            _this.initPersonF7(_this.signerCount);
+            $('#signer-' + _this.signerCount + '-type').val('copy').trigger('change');
+        });
+
+        // 删除签署方
+        $(document).on('click', '.delete-signer', function () {
+            var card = $(this).closest('.signer-card');
+            card.addClass('fade-out');
+
+            setTimeout(function () {
+                card.remove();
+                // 更新序号
+                _this.updateSignerNumbers();
+            }, 300);
+        });
+
+
+        $('#getData').click(function () {
+            var data = _this.getSignerData();
+            console.log(data);
+        });
+
+
+        // 确认按钮事件
+        $('#global-confirm').click(function () {
+            $.block.show({
+                text: '正在发送合同,请稍等...'
+            });
+            var data = _this.collectAllTableData();
+            var data1 = _this.getSignerData();
+            var signFlowTitle = $("#popup_title").attr("value");
+            var sourceId = $("#grid").jqGrid("getSelectedRowsData")[0] ? $("#grid").jqGrid("getSelectedRowsData")[0].id : '';
+            var personId = $("#grid").jqGrid("getSelectedRowsData")[0]['person.id'];
+            var d = {};
+            d.signInfo = data1;
+            d.templateInfo = data;
+            d.signFlowTitle = signFlowTitle;
+            d.sourceId = "通用电子签署申请单" + "_" + sourceId;
+            d.personId = personId
+            console.log(d);
+            var param = {}
+            param.data = d;
+            //param.mack="preview";
+            // 调用服务获取字段数据
+            window.setTimeout(function () {
+                shr.callService({
+                    serviceName: 'create_by_fileOSF',
+                    param: param,
+                    success: function (data) {
+                        console.log("========调用合同返回参数=========")
+                        console.log(data)
+                        if (data.code === 0) {
+                            $('#popup-overlay').hide();
+                            shr.showInfo({
+                                'message': "发送成功!!!"
+                            });
+                        } else {
+                            shr.showError({
+                                'message': data.message
+                            });
+                        }
+                        $.block.hide();
+                    },
+                    error: function (e) {
+                        shr.showError({
+                            'message': e
+                        });
+                        $.block.hide();
+                    }
+                });
+            }, 300)
+        });
+    },
+    /**
+* 处理字段排序:按seq升序排列(从小到大)
+* @param {Object} data - 原始文档数据
+* @returns {Object} 排序后的文档数据
+*/
+    sortFieldsBySeq: function (data) {
+        const sortedData = {};
+        // 遍历每个文档
+        Object.entries(data).forEach(([docId, docInfo]) => {
+            // 深拷贝文档信息,避免修改原对象
+            const newDocInfo = JSON.parse(JSON.stringify(docInfo));
+            // 提取fields的键值对数组,并按seq升序排序
+            const fieldsArr = Object.entries(newDocInfo.fields);
+            const sortedFieldsArr = fieldsArr.sort((a, b) => {
+                // a[1] 和 b[1] 是字段对象,取seq属性比较
+                return a[1].seq - b[1].seq; // 升序(从小到大);降序则改为 b[1].seq - a[1].seq
+            });
+            // 将排序后的数组转回对象(ES6+ 保留顺序)
+            newDocInfo.fields = Object.fromEntries(sortedFieldsArr);
+            // 存入排序后的数据对象
+            sortedData[docId] = newDocInfo;
+        });
+        return sortedData;
+    },
+
+    renderAllTablesByColumns: function () {
+        var _this = this;
+        if (_this.contractName !== "") {
+            $("#popup_title").attr("value", _this.contractName);
+        }
+        var wrapper = $('#tables-wrapper');
+        wrapper.empty();
+
+        $.each(_this.protocolData, function (protocolKey, protocolInfo) {
+            var tableContainer = $('<div>').addClass('table-container');
+            // 表格标题和预览按钮
+            var tableTitle = $('<div>').addClass('table-title');
+            tableTitle.append($('<span>').text(protocolInfo.name || '未命名模板'));
+            var previewBtn = $('<button>').addClass('preview-btn').text('预览');
+            previewBtn.click(function () {
+                _this.previewTableData(protocolKey);
+            });
+            tableTitle.append(previewBtn);
+
+            var table = $('<table>').addClass('data-table').attr('id', 'table-' + protocolKey);
+
+            var fieldNames = [];
+            var fieldValues = [];
+            $.each(protocolInfo.fields || {}, function (fieldKey, fieldInfo) {
+                if (fieldInfo.dataType !== "签署区" && fieldInfo.dataType !== "骑缝签署区" && fieldInfo.dataType !== "签署日期") {
+                    fieldNames.push(fieldInfo.name || '未命名字段');
+                    fieldValues.push({
+                        fieldKey: fieldKey,
+                        value: fieldInfo.value === null ? '' : fieldInfo.value,
+                        dataType: fieldInfo.dataType || '单行文本',
+                        dataFormat: fieldInfo.dataFormat,
+                        isRequired: fieldInfo.isRequired
+                    });
+                }
+            });
+
+            // 表头渲染
+            var thead = $('<thead>');
+            var headerTr = $('<tr>');
+            $.each(fieldNames, function (index, name) {
+                headerTr.append($('<th>').text(name));
+            });
+            thead.append(headerTr);
+            table.append(thead);
+
+            // 内容渲染
+            var tbody = $('<tbody>');
+            var dataTr = $('<tr>');
+            $.each(fieldValues, function (index, fieldData) {
+                var inputHtml;
+
+                // 处理日期类型
+                if (fieldData.dataType === "日期") {
+                    var inputType = _this.getInputType(fieldData.dataFormat);
+                    var formattedValue = _this.formatDateForInput(fieldData.value, fieldData.dataFormat);
+                    if (fieldData.isRequired) {
+                        inputHtml = '<input style="background-color: #D9EDF7;" type="' + inputType + '" value="' + formattedValue + '" placeholder="请输入值">';
+                    } else {
+                        inputHtml = '<input type="' + inputType + '" value="' + formattedValue + '" placeholder="请输入值">';
+                    }
+
+                } else if(fieldData.dataType === "勾选框"){
+                    if(fieldData.value==1||fieldData.value=="1"){
+                        inputHtml = '<input type="Checkbox" checked>';
+                    }else {
+                        inputHtml = '<input type="Checkbox">';
+                    }
+                    
+                }else {
+                    // 非日期类型使用普通文本输入
+
+                    if (fieldData.isRequired) {
+                        inputHtml = '<input style="background-color: #D9EDF7;" type="text" value="' + fieldData.value + '" placeholder="请输入值">';
+                    } else {
+                        inputHtml = '<input type="text" value="' + fieldData.value + '" placeholder="请输入值">';
+                    }
+                }
+                if (fieldData.dataType !== "签署区" && fieldData.dataType !== "骑缝签署区" && fieldData.dataType !== "签署日期") {
+                    dataTr.append($(
+                        '<td data-field-key="' + fieldData.fieldKey + '" ' +
+                        'data-data-type="' + fieldData.dataType + '"' +
+                        'data-data-format="' + fieldData.dataFormat + '">' +
+                        inputHtml +
+                        '</td>'
+                    ));
+                }
+            });
+            tbody.append(dataTr);
+            table.append(tbody);
+
+            tableContainer.append(tableTitle).append(table);
+            wrapper.append(tableContainer);
+        });
+    },
+    formatDateForInput: function (value, dataFormat) {
+        if (!value) return '';
+
+        // 补零工具函数:保证数字为两位(兼容ES5及以上)
+        function padZero(num) {
+            return num < 10 ? '0' + num : num;
+        }
+
+        // 尝试解析各种可能的日期格式
+        var date;
+        if (value instanceof Date) {
+            date = value;
+        } else {
+            // 替换常见分隔符(包括中文年、月、日),统一为 '-' 和 'T'(兼容ISO格式)
+            var normalizedValue = value
+                .replace(/[./年]/g, '-')    // 将 . / 年 替换为 -
+                .replace(/月/g, '-')        // 将 月 替换为 -
+                .replace(/日/g, '')         // 移除 日
+                .replace(/\s+/, 'T')        // 空格替换为T(衔接时分秒)
+                .replace(/:/g, ':');        // 保留冒号(时分秒分隔符)
+
+            date = new Date(normalizedValue);
+
+            // 如果解析失败,尝试其他格式
+            if (isNaN(date.getTime())) {
+                // 处理类似 "2025-11" 这样的年月格式
+                if (value.match(/^\d{4}-\d{2}$/)) {
+                    date = new Date(value + '-01');
+                } else {
+                    console.warn('无法解析日期: ' + value);
+                    return value; // 解析失败时返回原始值
+                }
+            }
+        }
+
+        // 根据dataFormat返回对应格式
+        if (dataFormat.indexOf('yyyy-MM-dd HH:mm:ss') !== -1) {
+            return date.toISOString().slice(0, 19).replace('T', ' '); // 注意:原代码slice(0,19)是"2025-11-12T13:45:30",这里替换T为空格更符合常规
+        } else if (dataFormat.indexOf('yyyy-MM-dd HH:mm') !== -1) {
+            return date.toISOString().slice(0, 16).replace('T', ' ');
+        } else if (dataFormat.indexOf('yyyy-MM-dd') !== -1) {
+            return date.toISOString().slice(0, 10);
+        } else if (dataFormat.indexOf('yyyy年MM月dd日') !== -1) {
+            // 基础中文日期格式:yyyy年MM月dd日
+            const year = date.getFullYear();
+            const month = padZero(date.getMonth() + 1); // 月份是0-based(0-11),需+1
+            const day = padZero(date.getDate());
+            let result = `${year}年${month}月${day}日`;
+
+            // 扩展:处理时分秒
+            if (dataFormat.indexOf('HH:mm:ss') !== -1) {
+                const hour = padZero(date.getHours());
+                const minute = padZero(date.getMinutes());
+                const second = padZero(date.getSeconds());
+                result += ` ${hour}:${minute}:${second}`;
+            } else if (dataFormat.indexOf('HH:mm') !== -1) {
+                const hour = padZero(date.getHours());
+                const minute = padZero(date.getMinutes());
+                result += ` ${hour}:${minute}`;
+            }
+            return result;
+        }
+
+        // 未知格式,返回原始值
+        return value;
+    },
+    getInputType: function (dataFormat) {
+        // 添加对dataFormat的检查,无值时默认使用"yyyy-MM-dd"
+        if (!dataFormat) {
+            dataFormat = "yyyy-MM-dd";
+        }
+
+        // 处理中文日期格式:yyyy年MM月dd日(包括扩展格式)
+        if (dataFormat.indexOf('yyyy年MM月dd日') !== -1) {
+            return 'text';
+        }
+
+        // 简化原有逻辑:合并HH:mm:ss和HH:mm的判断
+        if (dataFormat.indexOf('HH:mm') !== -1) { // 同时匹配HH:mm和HH:mm:ss
+            return 'datetime-local';
+        } else if (dataFormat.indexOf('yyyy-MM-dd') !== -1) {
+            return 'date';
+        }
+
+        // 未知格式返回text
+        return 'text';
+    },
+
+    // 预览单个表格数据
+    previewTableData: function (protocolKey) {
+        var _this = this;
+        var protocolInfo = _this.protocolData[protocolKey] || {};
+        var tableData = {};
+        tableData[protocolKey] = {
+            "name": protocolInfo.name || protocolKey,
+            "id": protocolInfo.id || protocolKey,
+            "fields": {}
+        };
+
+        $('#table-' + protocolKey + ' tbody tr td').each(function (index) {
+            var fieldKey = $(this).data('field-key');
+            var fieldName = $('#table-' + protocolKey + ' thead th:eq(' + index + ')').text() || '字段' + (index + 1);
+            var value = $(this).find('input').val() || null;
+
+            var dataType = "单行文本";
+            if (protocolInfo.fields && protocolInfo.fields[fieldKey]) {
+                dataType = protocolInfo.fields[fieldKey].dataType || "单行文本";
+            }
+            if(dataType==="勾选框"){
+                value  = ""+$(this).find('input').is(':checked')+""
+            }
+
+            tableData[protocolKey].fields[fieldKey] = {
+                name: fieldName,
+                dataType: dataType,
+                value: value
+            };
+        });
+        var param = {}
+        param.data = tableData;
+        param.mack = "preview";
+        $.block.show({
+            text: '正在获取预览地址,请稍等...'
+        });
+        window.setTimeout(function () {
+            // 调用服务获取字段数据
+            shr.callService({
+                serviceName: 'create_by_fileOSF',
+                param: param,
+                success: function (data) {
+                    console.log("========调用合同返回参数=========")
+                    console.log(data)
+                    if (data.code !== 0) {
+                        shr.showError({
+                            'message': data.message
+                        });
+                    } else {
+                        window.open(data.data.fileDownloadUrl, '_blank');
+                    }
+                    $.block.hide();
+                },
+                error: function (e) {
+                    shr.showError({
+                        'message': e
+                    });
+                    $.block.hide();
+                }
+            });
+        }, 300)
+
+    },
+    // 收集所有表格数据
+    collectAllTableData: function () {
+        var allData = {};
+        var _this = this;
+        $.each(_this.protocolData, function (protocolKey, protocolInfo) {
+            // var tableData = {
+            //     tableName: protocolInfo.name,
+            //     tableId: protocolInfo.id,
+            //     fields: protocolInfo.fields
+            // };
+            var tableData = protocolInfo
+            $('#table-' + protocolKey + ' tbody tr td').each(function (index) {
+                var fieldKey = $(this).data('field-key');
+                var fieldName = $('#table-' + protocolKey + ' thead th:eq(' + index + ')').text();
+                var dataType = $(this).data('data-type');
+                var dataFormat = $(this).data('data-format');
+                tableData.fields[fieldKey].name = fieldName;
+                tableData.fields[fieldKey].dataType = dataType;
+                tableData.fields[fieldKey].dataFormat = dataFormat;
+                var value=""
+                if(dataType=="勾选框"){
+                    value = ""+$(this).find('input').is(':checked')+""
+                }else {
+                    value = $(this).find('input').val() || null;
+                }
+                tableData.fields[fieldKey].value = value;
+                // tableData.fields[fieldKey] = {
+                //     name: fieldName,
+                //     dataType: dataType,
+                //     dataFormat: dataFormat,
+                //     value: value
+                // };
+            });
+
+            allData[protocolKey] = tableData;
+        });
+        console.log('===== 所有表格数据 =====');
+        console.log(JSON.stringify(allData, null, 2));
+        return allData;
+    },
+    // 验证签署顺序输入值
+    validateOrder: function (input) {
+        var value = parseInt(input.value);
+        if (isNaN(value) || value < 1) {
+            input.value = 1;
+        } else if (value > 255) {
+            input.value = 255;
+        }
+    },
+
+    // 切换签署方类型
+    changeSignerType: function (selectElement) {
+        var type = selectElement.value;
+        var card = $(selectElement).closest('.signer-card');
+        var cardId = card.attr('data-id');
+        var fieldsContainer = card.find('.signer-fields');
+        var orderInput = card.find('.order-input');
+        var roleElement = card.find('.signer-role');
+
+        var nameElement = card.find('.signer-name');
+
+        // 更新选择框样式和颜色
+        if (type === 'personal') {
+            $(selectElement).removeClass('type-company type-copy').addClass('type-personal');
+            // 显示个人字段和签署顺序
+            fieldsContainer.html(
+                '<div class="form-group">' +
+                '<input type="text" placeholder="真实姓名" class="input-field" id="signer-' + cardId + '-name" name="signer-' + cardId + '-name">' +
+                '<span class="input-marker" id="name-tip-' + cardId + '">ⓘ</span>' +
+                '<input type="hidden" id="signer-' + cardId + '-person-f7" name="signer-' + cardId + '-person-f7">' +
+                '</div>' +
+                '<div class="form-group">' +
+                '<input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + cardId + '-account" name="signer-' + cardId + '-account">' +
+                '</div>'
+            );
+            nameElement.text('签署方' + cardId)
+            roleElement.text('签署');
+            $('#span-' + cardId + '').remove();
+            orderInput.show();
+            // 初始化F7选择器
+            this.initPersonF7(cardId);
+        } else if (type === 'company') {
+            $(selectElement).removeClass('type-personal type-copy').addClass('type-company');
+            $('#signer-' + cardId + '-order').after('<span id="span-' + cardId + '" style="display: none;"> 自动签 <input type="radio" placeholder="" class="" id="signer-' + cardId + '-radio" name="signer-radio-orgname"></span>');
+            // 显示企业字段和签署顺序
+            fieldsContainer.html(
+                '<div class="form-group">' +
+                '<input type="text" placeholder="请输入企业完整名称" class="input-field" id="signer-' + cardId + '-orgname" name="signer-' + cardId + '-orgname">' +
+                '</div>' +
+                '<div class="form-group">' +
+                '<input readonly type="text" placeholder="企业章" class="input-field" id="signer-' + cardId + '-orgnId" name="signer-' + cardId + '-orgnId">' +
+                '<span class="input-marker" id="name-orgId-' + cardId + '">ⓘ</span>' +
+                '<input type="hidden" id="signer-' + cardId + '-orgnId-f7" name="signer-' + cardId + '-orgnId-f7">' +
+                '</div>' +
+                '<div class="form-group">' +
+                '<input type="text" placeholder="真实姓名" class="input-field" id="signer-' + cardId + '-name" name="signer-' + cardId + '-name">' +
+                '<span class="input-marker" id="name-tip-' + cardId + '">ⓘ</span>' +
+                '<input type="hidden" id="signer-' + cardId + '-person-f7" name="signer-' + cardId + '-person-f7">' +
+                '</div>' +
+                '<div class="form-group">' +
+                '<input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + cardId + '-account" name="signer-' + cardId + '-account">' +
+                '</div>'
+            );
+            nameElement.text('签署方' + cardId)
+            roleElement.text('签署');
+            orderInput.show();
+            // 初始化F7选择器
+            this.initPersonF7(cardId);
+        } else if (type === 'copy') {
+            // 处理抄送类型
+            $(selectElement).removeClass('type-personal type-company').addClass('type-copy');
+            $('#span-' + cardId + '').remove();
+            // 显示抄送字段,隐藏签署顺序
+            fieldsContainer.html(
+                '<div class="form-group">' +
+                '<input type="text" placeholder="真实姓名" class="input-field" id="signer-' + cardId + '-name" name="signer-' + cardId + '-name">' +
+                '<span class="input-marker" id="name-tip-' + cardId + '">ⓘ</span>' +
+                '<input type="hidden" id="signer-' + cardId + '-person-f7" name="signer-' + cardId + '-person-f7">' +
+                '</div>' +
+                '<div class="form-group">' +
+                '<input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + cardId + '-account" name="signer-' + cardId + '-account">' +
+                '</div>'
+            );
+            nameElement.text('抄送方' + cardId)
+            roleElement.text('抄送');
+            orderInput.hide(); // 隐藏签署顺序
+            // 初始化F7选择器
+            this.initPersonF7(cardId);
+        }
+    },
+
+    // 初始化人员选择F7
+    initPersonF7: function (cardId) {
+        var grid_f7_json = {
+            id: 'signer-' + cardId + '-person-f7',
+            name: 'signer-' + cardId + '-person-f7'
+        };
+        grid_f7_json.subWidgetName = 'shrPromptGrid';
+        grid_f7_json.subWidgetOptions = {
+            title: "员工",
+            uipk: "com.kingdee.eas.custom.entryconfig.app.person.F7",
+            query: "",
+            filter: "",
+            domain: "",
+            multiselect: false,
+            treeFilterConfig: '',
+            permItemId: "",
+            isHasMultileDialog: false,
+            isTree: false,
+            treeUrl: "",
+            isContainLowerOrg: false,
+            isAdminOrg: false,
+            pgSizes: true,
+            f7SearchConfig: { "displayField": [], "filterFields": "" },
+            dataShowMode: "layout"
+        };
+        grid_f7_json.readonly = '';
+        grid_f7_json.validate = '{required:false}';
+        grid_f7_json.value = { 'id': "", 'name': "" };
+        grid_f7_json.isHROrg = "false";
+        grid_f7_json.isAdminOrg = "false";
+        grid_f7_json.searchLikePattern = "any";
+
+        // 初始化F7选择器
+        $('#signer-' + cardId + '-person-f7').shrPromptBox(grid_f7_json);
+
+        // 绑定选择事件,将选择的姓名回填到真实姓名输入框
+        $('#signer-' + cardId + '-person-f7').shrPromptBox('option', {
+            afterOnSelectRowHandler: function (a, data) {
+                $('#signer-' + cardId + '-name').val(data.value.name);
+                $('#signer-' + cardId + '-account').val(data.value.cell);
+                console.log(data);
+            }
+        });
+        $('#name-tip-' + cardId).click(function () {
+            $('#signer-' + cardId + '-person-f7').shrPromptBox("open");
+        });
+        $('#signer-' + cardId + '-person-f7').parent().parent().parent().hide();
+
+
+
+
+        id = "signer-' + cardId + '-orgnId-f7"
+
+
+        var grid_f7_json = {
+            id: 'signer-' + cardId + '-orgnId-f7',
+            name: 'signer-' + cardId + '-orgnId-f7'
+        };
+        grid_f7_json.subWidgetName = 'shrPromptGrid';
+        grid_f7_json.subWidgetOptions = {
+            title: "印章",
+            uipk: "com.kingdee.eas.custom.esign.app.Seal.list",
+            query: "",
+            filter: "",
+            domain: "",
+            multiselect: false,
+            treeFilterConfig: '',
+            permItemId: "",
+            isHasMultileDialog: false,
+            isTree: false,
+            treeUrl: "",
+            isContainLowerOrg: false,
+            isAdminOrg: false,
+            pgSizes: true,
+            f7SearchConfig: { "displayField": [], "filterFields": "" },
+            dataShowMode: "layout"
+        };
+        grid_f7_json.readonly = '';
+        grid_f7_json.validate = '{required:false}';
+        grid_f7_json.value = { 'id': "", 'name': "" };
+        grid_f7_json.isHROrg = "false";
+        grid_f7_json.isAdminOrg = "false";
+        grid_f7_json.searchLikePattern = "any";
+
+        // 初始化F7选择器
+        $('#signer-' + cardId + '-orgnId-f7').shrPromptBox(grid_f7_json);
+
+        $('#signer-' + cardId + '-orgnId-f7').shrPromptBox('option', {
+            afterOnSelectRowHandler: function (a, data) {
+                $('#signer-' + cardId + '-orgnId').val(data.value.sealId);
+                console.log(data);
+            }
+        });
+        $('#name-orgId-' + cardId).click(function () {
+            $('#signer-' + cardId + '-orgnId-f7').shrPromptBox("open");
+        });
+
+        $('#signer-' + cardId + '-orgnId-f7').parent().parent().parent().hide();
+    },
+
+    // 更新签署方序号
+    updateSignerNumbers: function () {
+        var _this = this;
+        $('.signer-card').each(function (index, element) {
+            var newNumber = index + 1;
+            var oldId = $(element).attr('data-id');
+
+            // 更新卡片ID
+            $(element).attr('data-id', newNumber);
+
+            // 更新显示名称
+            $(element).find('.signer-name').text('签署方' + newNumber);
+
+            // 更新所有相关元素的ID和name属性
+            $(element).find('[id^="signer-' + oldId + '-"]').each(function () {
+                var field = $(this).attr('id').split('-').pop();
+                $(this).attr('id', 'signer-' + newNumber + '-' + field);
+                var name = $(this).attr('name');
+                if (name !== "signer-radio-orgname") {
+                    $(this).attr('name', 'signer-' + newNumber + '-' + field);
+                }
+            });
+
+            // 重新初始化F7组件(因为ID发生了变化)
+            _this.initPersonF7(newNumber);
+
+            // 如果没有设置过顺序值,自动填充序号(只对非抄送类型生效)
+            var orderInput = $(element).find('.order-input');
+            var typeSelect = $(element).find('.type-select');
+
+            if (typeSelect.val() !== 'copy' && (!orderInput.val() || orderInput.val() < 1)) {
+                orderInput.val(newNumber);
+            }
+        });
+        _this.signerCount = $('.signer-card').length;
+    },
+
+    // 获取数据方法
+    getSignerData: function () {
+        var result = {
+            signers: [],
+            copiers: []
+        };
+
+        // 遍历所有签署方卡片
+        $('.signer-card').each(function () {
+            var cardId = $(this).attr('data-id');
+            var type = $(this).find('#signer-' + cardId + '-type').val();
+            // 获取F7选择的完整数据
+            var f7Data = $('#signer-' + cardId + '-person-f7').shrPromptBox('getValue') || {};
+
+            if (type === 'personal') {
+                // 个人签署方
+                result.signers.push({
+                    psnSignerInfo: {
+                        psnAccount: $(this).find('#signer-' + cardId + '-account').val() || '',
+                        psnName: $(this).find('#signer-' + cardId + '-name').val() || '',
+                        signOrder: $(this).find('#signer-' + cardId + '-order').val() || '1',
+                        f7Data: f7Data, // 包含F7选择的完整数据
+                        signName: $(this).find('#signername_index' + cardId).text() || '',
+                    }
+                });
+            } else if (type === 'company') {
+                // 企业签署方
+                result.signers.push({
+                    orgSignerInfo: {
+                        orgName: $(this).find('#signer-' + cardId + '-orgname').val() || '',
+                        psnName: $(this).find('#signer-' + cardId + '-name').val() || '',
+                        psnAccount: $(this).find('#signer-' + cardId + '-account').val() || '',
+                        signOrder: $(this).find('#signer-' + cardId + '-order').val() || '1',
+                        f7Data: f7Data, // 包含F7选择的完整数据
+                        sealId: $(this).find('#signer-' + cardId + '-orgnId').val() || '',
+                        isRadio: $('#signer-' + cardId + '-radio').is(":checked"),
+                        signName: $(this).find('#signername_index' + cardId).text() || '',
+                    }
+                });
+            } else if (type === 'copy') {
+                // 抄送方
+                result.copiers.push({
+                    psnAccount: $(this).find('#signer-' + cardId + '-account').val() || '',
+                    psnName: $(this).find('#signer-' + cardId + '-name').val() || '',
+                    f7Data: f7Data, // 包含F7选择的完整数据
+                    signName: $(this).find('#signername_index' + cardId).text() || '',
+                });
+            }
+        });
+
+        return result;
+    },
+    // 重置参与方设置
+    resetSigners: function (eSignTemplateId) {
+        var _this = this;
+        // 清空现有签署方卡片
+        $('#signersContainer').empty();
+        // 重置签署方计数
+        this.signerCount = 1;
+        // 隐藏结果区域
+        $('#resultArea').hide();
+        var param = {}
+        param.mack = "getTemplate";
+        param.eSignTemplateNum = eSignTemplateId
+        shr.callService({
+            serviceName: 'create_by_fileOSF',
+            param: param,
+            success: function (data) {
+                console.log("========签署信息=========")
+                console.log(data)
+                if (data.data.length <= 0) {
+                    shr.showWarning({
+                        'message': "未获取到设置签署信息请自行设置签署人!注:需要和e签宝保持一致。"
+                    });
+                }
+                var d = data.data
+                for (let i = 0; i < d.length; i++) {
+                    var entry = d[i];
+                    //签署类型 1 公司签署 2 个人签署 3 抄送人
+                    var type = entry.participantType;
+
+                    var defaultSigner = "";
+
+                    if (type == 1 || type == "1") {
+                        var participantFlag = entry.participantFlag;
+                        var orgParticipant = entry.orgParticipant
+                        var participantSetMode = entry.participantSetMode
+                        if (participantSetMode == 2 ) {
+                            continue;
+                        }
+                        defaultSigner = '<div class="signer-card" data-id="' + _this.signerCount + '">' +
+                            '<div class="card-header">' +
+                            '<div class="card-info"><select class="type-select type-company" id="signer-' + _this.signerCount + '-type" name="signer-' + _this.signerCount + '-type" disabled>' +
+                            '<option value="personal" >个人</option>' +
+                            '<option value="company" selected >企业</option>' +
+                            '<option value="copy">抄送</option>' +
+                            '</select>' +
+                            '<span class="signer-name" id="signername_index' + _this.signerCount + '">' + participantFlag + '</span><span class="signer-role">签署</span>' +
+                            '<input type="number" min="1" max="255" value="' + _this.signerCount + '" class="order-input"id="signer-' + _this.signerCount + '-order" name="signer-' + _this.signerCount + '-order" style="">' +
+                            '<span id="span-' + _this.signerCount + '" style="display: none;"> 自动签 <input type="radio"placeholder="" class="" id="signer-' + _this.signerCount + '-radio" name="signer-radio-orgname"></span>' +
+                            '</div>' +
+                            '<!--div class="card-actions"><span class="action-link delete-signer"><span class="icon"></span>删除</span></div-->' +
+                            '</div>' +
+                            '<div class="form-grid signer-fields">'
+                        if (orgParticipant != null) {
+                            var orgName = orgParticipant.orgName;
+                            //disabled
+                            if (orgName != null && orgName != undefined && orgName != "") {
+                                defaultSigner += '<div class="form-group"><input type="text" placeholder="请输入企业完整名称" value="' + orgParticipant.orgName + '" class="input-field" id="signer-' + _this.signerCount + '-orgname"name="signer-' + _this.signerCount + '-orgname"></div>'
+                            } else {
+                                defaultSigner += '<div class="form-group"><input type="text" placeholder="请输入企业完整名称" value="' + orgParticipant.orgName + '" class="input-field" id="signer-' + _this.signerCount + '-orgname"name="signer-' + _this.signerCount + '-orgname" disabled ></div>'
+                            }
+                        } else {
+                            defaultSigner += '<div class="form-group"><input type="text" placeholder="请输入企业完整名称" value="" class="input-field" id="signer-' + _this.signerCount + '-orgname"name="signer-' + _this.signerCount + '-orgname"></div>'
+                        }
+
+                        defaultSigner += '<div class="form-group"><input readonly="" type="text" placeholder="企业章" class="input-field"id="signer-' + _this.signerCount + '-orgnId" name="signer-' + _this.signerCount + '-orgnId"><span class="input-marker" id="name-orgId-' + _this.signerCount + '">ⓘ</span>' +
+                            '<div class="ui-promptBox-frame" style="display: none;">' +
+                            '<div class="ui-promptBox-layout">' +
+                            '<div class="ui-promptBox-inputframe"><input type="hidden" id="signer-' + _this.signerCount + '-orgnId-f7_el" name="hidd_name_signer-' + _this.signerCount + '-orgnId-f7" value=""><input type="hidden" id="signer-' + _this.signerCount + '-orgnId-f7"name="signer-' + _this.signerCount + '-orgnId-f7" ctrlrole="promptBox" autocomplete="off" value="" title=""></div>' +
+                            '<div class="ui-promptBox-icon"><img style="cursor:pointer;" src="/shr/styles/images/seniorf7.png">' +
+                            '</div>' +
+                            '</div>' +
+                            '</div>' +
+                            '</div>';
+                        if (orgParticipant != null) {
+                            var transactor = orgParticipant.transactor;
+                            if (transactor != null && transactor != undefined) {
+                                defaultSigner += '<div class="form-group"><input type="text" placeholder="真实姓名" value="' + transactor.transactorName + '" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name"><span class="input-marker" id="name-tip-' + _this.signerCount + '">ⓘ</span>'
+                            } else {
+                                defaultSigner += '<div class="form-group"><input type="text" placeholder="真实姓名" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name"><span class="input-marker" id="name-tip-' + _this.signerCount + '">ⓘ</span>'
+
+                            }
+
+                        } else {
+                            defaultSigner += '<div class="form-group"><input type="text" placeholder="真实姓名" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name"><span class="input-marker" id="name-tip-' + _this.signerCount + '">ⓘ</span>'
+                        }
+                        defaultSigner += '<div class="ui-promptBox-frame" style="display: none;">' +
+                            '<div class="ui-promptBox-layout">' +
+                            '<div class="ui-promptBox-inputframe"><input type="hidden" id="signer-' + _this.signerCount + '-person-f7_el" name="hidd_name_signer-' + _this.signerCount + '-person-f7" value=""><input type="hidden" id="signer-' + _this.signerCount + '-person-f7"' +
+                            ' name="signer-' + _this.signerCount + '-person-f7" ctrlrole="promptBox" autocomplete="off" value="" title=""></div>' +
+                            '<div class="ui-promptBox-icon"><img style="cursor:pointer;" src="/shr/styles/images/seniorf7.png">' +
+                            '</div>' +
+                            '</div>' +
+                            '</div>' +
+                            '</div>';
+                        if (orgParticipant != null) {
+                            var transactor = orgParticipant.transactor;
+                            if (transactor != null && transactor != undefined) {
+                                defaultSigner += '<div class="form-group"><input type="text" placeholder="请输入手机号/邮箱" value="' + transactor.transactorPsnAccount + '" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account"></div>';
+                            } else {
+                                defaultSigner += '<div class="form-group"><input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account"></div>';
+
+                            }
+
+                        } else {
+                            defaultSigner += '<div class="form-group"><input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account"></div>';
+                        }
+                        defaultSigner += '</div>' +
+                            '</div>';
+                    } else if (type == 2 || type == "2") {
+                        var participantFlag = entry.participantFlag;
+                        var psnParticipant = entry.psnParticipant
+                        var participantSetMode = entry.participantSetMode
+                        if (participantSetMode == 2 ) {
+                            continue;
+                        }
+                        // 添加默认的第一个签署方卡片 默认个人
+                        defaultSigner = '<div class="signer-card" data-id="' + _this.signerCount + '">' +
+                            '<div class="card-header">' +
+                            '<div class="card-info">' +
+                            '<select class="type-select type-personal" id="signer-' + _this.signerCount + '-type" name="signer-' + _this.signerCount + '-type" disabled>' +
+                            '<option value="personal" selected >个人</option>' +
+                            '<option value="company" >企业</option>' +
+                            '<option value="copy">抄送</option>' +
+                            '</select>' +
+                            '<span class="signer-name" id = "signername_index' + _this.signerCount + '">' + participantFlag + '</span>' +
+                            '<span class="signer-role">签署</span>' +
+                            '<input type="number" min="1" max="255" value="' + _this.signerCount + '" class="order-input" id="signer-' + _this.signerCount + '-order" name="signer-' + _this.signerCount + '-order">' +
+                            '</div>' +
+                            '<!--div class="card-actions">' +
+                            '<span class="action-link delete-signer"><span class="icon"></span>删除</span>' +
+                            '</div-->' +
+                            '</div>' +
+                            '<div class="form-grid signer-fields">' +
+                            '<div class="form-group">';
+                        if (psnParticipant != null && psnParticipant != undefined) {
+                            defaultSigner += '<input type="text" placeholder="真实姓名" value="' + psnParticipant.psnName + '" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name">';
+                        } else {
+                            defaultSigner += '<input type="text" placeholder="真实姓名" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name">';
+                        }
+                        defaultSigner += '<span class="input-marker" id="name-tip-' + _this.signerCount + '">ⓘ</span>' +
+                            '<input type="hidden" id="signer-' + _this.signerCount + '-person-f7" name="signer-' + _this.signerCount + '-person-f7">' +
+                            '</div>' +
+                            '<div class="form-group">';
+                        if (psnParticipant != null && psnParticipant != undefined) {
+                            defaultSigner += '<input type="text" placeholder="请输入手机号/邮箱" value="' + psnParticipant.psnAccount + '" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account">';
+                        } else {
+                            defaultSigner += '<input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account">';
+                        }
+                        defaultSigner += '</div>' +
+                            '</div>' +
+                            '</div>';
+                    } else if (type == 3 || type == "3") {
+                        var copierPsnInfo = entry.copierPsnInfo;
+                        defaultSigner = '<div class="signer-card" data-id="' + _this.signerCount + '">' +
+                            '<div class="card-header">' +
+                            '<div class="card-info"><select class="type-select type-copy" id="signer-' + _this.signerCount + '-type" name="signer-' + _this.signerCount + '-type" disabled>' +
+                            '<option value="personal">个人</option>' +
+                            '<option value="company">企业</option>' +
+                            '<option value="copy" selected >抄送</option>' +
+                            '</select>' +
+                            '<span class="signer-name" id="signername_index' + _this.signerCount + '" > 抄送方' + _this.signerCount + '</span><span class="signer-role">抄送</span>' +
+                            '<input type="number" min="1" max="255" value="' + _this.signerCount + '" class="order-input" id="signer-' + _this.signerCount + '-order" name="signer-' + _this.signerCount + '-order" style="display: none;"></div>' +
+                            '<!--div class="card-actions"><span class="action-link delete-signer"><span class="icon"></span>删除</span></div-->' +
+                            '</div>' +
+                            '<div class="form-grid signer-fields">' +
+                            '<div class="form-group">';
+                        if (copierPsnInfo != null && copierPsnInfo != undefined) {
+                            defaultSigner += '<input type="text" placeholder="真实姓名" value="' + copierPsnInfo.psnName + '" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name">';
+
+                        } else {
+                            defaultSigner += '<input type="text" placeholder="真实姓名" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name">';
+                        }
+                        defaultSigner += '<span class="input-marker" id="name-tip-' + _this.signerCount + '">ⓘ</span>' +
+                            '<div class="ui-promptBox-frame" style="display: none;">' +
+                            '<div class="ui-promptBox-layout">' +
+                            '<div class="ui-promptBox-inputframe">' +
+                            '<input type="hidden" id="signer-' + _this.signerCount + '-person-f7_el" name="hidd_name_signer-' + _this.signerCount + '-person-f7" value="">' +
+                            '<input type="hidden" id="signer-' + _this.signerCount + '-person-f7" name="signer-' + _this.signerCount + '-person-f7" ctrlrole="promptBox" autocomplete="off" value="" title="">' +
+                            '</div>' +
+                            '<div class="ui-promptBox-icon"><img style="cursor:pointer;" src="/shr/styles/images/seniorf7.png">' +
+                            '</div>' +
+                            '</div>' +
+                            '</div>' +
+                            '</div>' +
+                            '<div class="form-group">';
+                        if (copierPsnInfo != null && copierPsnInfo != undefined) {
+                            defaultSigner += '<input type="text" placeholder="请输入手机号/邮箱" value="' + copierPsnInfo.psnAccount + '" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account">';
+
+                        } else {
+                            defaultSigner += '<input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account">';
+                        }
+                        defaultSigner += '</div>' +
+                            '</div>' +
+                            '</div>';
+
+                    } else {
+                        shr.showWarning({
+                            'message': "获取到设置签署信息失败!请自行设置签署人!注:需要和e签宝保持一致。"
+                        });
+                    }
+                    $('#signersContainer').append(defaultSigner);
+                    _this.initPersonF7(_this.signerCount);
+                    _this.signerCount++
+                }
+
+            },
+            error: function (e) {
+                shr.showError({
+                    'message': e
+                });
+            }
+        });
+    }
+
+});

+ 35 - 0
js/addon/customer/configinfo/js/GeneralESignBillEdit.js

@@ -0,0 +1,35 @@
+
+shr.defineClass("shr.custom.GeneralESignBillEntry",shr.framework.Edit, {
+    initalizeDOM: function () {
+        shr.custom.GeneralESignBillEntry.superClass.initalizeDOM.call(this);
+		this.personChange()
+    },
+   
+	personChange:function(){
+		var _this = this
+		$("#person").shrPromptBox("option", {
+			onchange : function(e, value) {
+				var personF7Id = value.current.id;
+				if(personF7Id!=null&&personF7Id!=""&&personF7Id!=undefined){
+					shr.callService({
+						serviceName : "getPersonPosOrgInfo",
+						param :{
+							personID: personF7Id,
+							uiClass : _this._uiClass
+						},
+						async : true,
+						success : function (data) {
+							console.log(data)
+							if(data.length>0){
+								var d = data[0]
+								$('#adminOrg').shrPromptBox("setValue",d.adminOrg);
+								$('#position').shrPromptBox("setValue",d.position);
+								
+							}
+						}
+					})
+				}
+			}
+		})
+	}
+})

+ 146 - 0
js/addon/customer/configinfo/js/MappingFieldEdit.js

@@ -0,0 +1,146 @@
+
+shr.defineClass("shr.ats.mappingFieldEdit", shr.framework.Edit, {
+    data: [],
+    initalizeDOM: function () {
+        shr.ats.mappingFieldEdit.superClass.initalizeDOM.call(this);
+        var _this = this
+        this.data = $("#entrys").jqGrid("getAllRowData");
+        var method = shr.getUrlRequestParam("method", window.location.href);
+        if (method === "edit" || method === "addNew") {
+            var dataSource = $('#dataSource').shrPromptBox("getValue");
+            if (dataSource.id == null || dataSource.id == "" || dataSource.id == undefined) {
+                shr.execByFieldIdAndMethod('dataInterface', 'addRules', { 'required': true });
+                $('#dataInterface').shrTextField('enable');
+
+            } else {
+                shr.execByFieldIdAndMethod('dataInterface', 'addRules', { 'required': false });
+                $('#dataInterface').shrTextField('disable');
+            }
+            $("[class='editGrid-toolbar']").append('<button id="addAllEntry" type="button" name="addAllEntry" style="display:Initial" class=" shrbtn" data-isenableexcelpwd="false">批量新增</button>')
+
+            $(document).on('click', '#addAllEntry', function () {
+                var eSignFile = $('#eSignFile').shrPromptBox("getValue");
+                var filter = "Parent1.Parent.id = '" + eSignFile.id + "'"
+                $('#eField').shrPromptBox("setFilter", filter);
+                _this.data = $("#entrys").jqGrid("getAllRowData");
+
+                var thisData = [];
+                for (let i = 0; i < _this.data.length; i++) {
+                    thisData.push(_this.data[i].eField)
+                }
+                $('#eField').shrPromptBox("setValue", thisData);
+                $("#eField").shrPromptBox("open");
+            });
+            $('#eField').shrPromptBox('option', {
+                onchange: function (a, b) {
+                    var lodData = [];
+                    var d = $("#entrys").jqGrid("getAllRowData")
+                    for (let i = 0; i < d.length; i++) {
+                        lodData.push(d[i].eField)
+                    }
+                    var cData = b.current
+                    for (let i = 0; i < cData.length; i++) {
+                        var isOut = true;
+                        for (let j = 0; j < lodData.length; j++) {
+                            if (cData[i].id === lodData[j].id) {
+                                isOut = false
+                                continue;
+                            }
+                        }
+                        if (isOut) {
+                            console.log(cData[i])
+                            var rowData = {};
+                            rowData.eFieldMark = cData[i].templateFieldId
+                            rowData.eFieldName = cData[i].templateFieldName
+                            rowData.eField = cData[i]
+                            $('#entrys').jqGrid('addRowData', null, rowData, 'last', null)
+                        }
+                    }
+                }
+
+            })
+        }
+        this.changeEntrys()
+
+
+    },
+    changeEntrys: function () {
+        var _this = this
+        $('#entrys').jqGrid('option', {
+            afterSaveCell: function (rowid, cellname, value, iRow, iCol) {
+                // 这里可以检查单元格的值是否改变,并执行相应的操作
+                if (cellname === "eField") {
+                    $('#entrys').jqGrid('setCell', rowid, "eFieldMark", value.templateFieldId);
+                    $('#entrys').jqGrid('setCell', rowid, "eFieldName", value.templateFieldName);
+                    $('#entrys').jqGrid('saveRow', rowid, false, 'clientArray');
+                }
+            },
+            afterEditCell: function (rowid, cellname, value, iRow, iCol) {
+                // 这里可以检查单元格的值是否改变,并执行相应的操作
+                if (cellname === "eField") {
+                    var eSignFile = $('#eSignFile').shrPromptBox("getValue");
+                    var filter = "Parent1.Parent.id = '" + eSignFile.id + "'"
+                    var eFieldMark = ""
+                    for (let i = 0; i < _this.data.length; i++) {
+                        var temp = _this.data[i].eFieldMark;
+                        if (temp != null && temp != undefined && temp != "") {
+                            eFieldMark += "'" + temp + "',"
+                        }
+                    }
+                    if (eFieldMark.length > 0) {
+                        eFieldMark = eFieldMark.substring(0, eFieldMark.length - 1)
+                        eFieldMark = "(" + eFieldMark + ")"
+                        filter += " and templateFieldId not in " + eFieldMark
+                    }
+                    $('#' + iRow + '_eField').shrPromptBox("setFilter", filter);
+                    console.log(value)
+
+                } else if (cellname === "dataSourceField") {
+                    var dataSource = $('#dataSource').shrPromptBox("getValue");
+                    $('#' + iRow + '_dataSourceField').shrPromptBox("setFilter", "Parent.id = '" + dataSource.id + "'");
+                }
+            }
+        })
+        var method = shr.getUrlRequestParam("method", window.location.href);
+        if (method === "edit" || method === "addNew") {
+            $('#dataSource').shrPromptBox('option', {
+                onchange: function (a, b) {
+                    // 这里可以检查单元格的值是否改变,并执行相应的操作
+                    if (b.current == null) {
+                        shr.execByFieldIdAndMethod('dataInterface', 'addRules', { 'required': true });
+                        $('#dataInterface').shrTextField('enable');
+
+                    } else {
+                        shr.execByFieldIdAndMethod('dataInterface', 'addRules', { 'required': false });
+                        $('#dataInterface').shrTextField('disable');
+                    }
+                }
+            })
+        }
+
+    },
+    addRowAction: function (event) {
+        this.data = $("#entrys").jqGrid("getAllRowData");
+        var source = event.currentTarget,
+            $editGrid = this.getEditGrid(source);
+
+        var data = this.createNewEntryModel();
+        if (typeof data === 'undefined') {
+            data = {};
+        }
+
+        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);
+    }
+
+})

+ 1019 - 0
js/addon/customer/configinfo/js/PersonEcontarct.js

@@ -0,0 +1,1019 @@
+shr.defineClass("shr.ats.Econtarct", shr.custom.EmployeeDynListEx, {
+    protocolData: {},
+    signerCount: 1,
+    contractName: "",
+    selectedRowsData: {},
+    initalizeDOM: function () {
+        shr.ats.Econtarct.superClass.initalizeDOM.call(this);
+        this.changeEntrys();
+    },
+    sendSignAction: function () {
+        $('#field').shrPromptBox("setFilter", "eSignFile.state = 1");
+        $("#field").shrPromptBox("open");
+    },
+    changeEntrys: function () {
+        var _this = this;
+
+        // 绑定签署方类型切换事件(使用事件委托)
+        $(document).on('change', '.type-select', function () {
+            _this.changeSignerType(this);
+        });
+
+        // 绑定签署顺序验证事件(使用事件委托)
+        $(document).on('input', '.order-input', function () {
+            _this.validateOrder(this);
+        });
+
+        let lastCheckedRadio = null;
+
+        $(document).on('click', '[name="signer-radio-orgname"]', function (a, e) {
+            const $this = $(this);
+            // 判断当前点击的元素是否是上一次选中的元素
+            if ($this[0] === lastCheckedRadio) {
+                // 取消选中
+                $this.prop('checked', false);
+                lastCheckedRadio = null; // 清空记录
+            } else {
+                // 原生已自动选中当前元素,只需更新记录(同组其他项已被原生取消)
+                lastCheckedRadio = $this[0];
+            }
+            if ($('[name="signer-radio-orgname"').size() > 1) {
+                $('[name="signer-radio-orgname"').prop('checked', false)
+                lastCheckedRadio = null;
+                shr.showWarning({
+                    'message': "多个公司签署不允许使用电子签"
+                });
+            }
+        });
+
+
+        $('#field').shrPromptBox('option', {
+            afterOnSelectRowHandler: function (a, b) {
+                var l = $("#grid").jqGrid("getSelectedRowsData");
+                if (l.length !== 1) {
+                    shr.showWarning({
+                        'message': "请选择一条元数据!!注意:只能选择一条数据!"
+                    });
+                    return
+                }
+                var number = b.value.number;
+                _this.contractName = b.value.name;
+                if (number) {
+                    _this.selectedRowsData = $("#grid").jqGrid("getSelectedRowsData")[0];
+                    var id = _this.selectedRowsData ? _this.selectedRowsData["person.id"] : '';
+                    shr.callHandler({
+                        action: "getTableData",
+                        param: { "number": number, "id": id },
+                        type: "POST",
+                        success: function (res) {
+                            _this.protocolData = _this.sortFieldsBySeq(res.data);
+                            _this.renderAllTablesByColumns();
+                            var eSignTemplateId;
+                            for (var key in _this.protocolData) {
+                                _this.protocolData[key];
+                                if (_this.protocolData[key]) {
+                                    eSignTemplateId = _this.protocolData[key].eSignTemplateNum
+                                    break;
+                                }
+
+                            }
+                            _this.resetSigners(eSignTemplateId);
+                            $('#popup-overlay').css('display', 'flex');
+                        }
+                    });
+                } else {
+                    shr.showWarning({
+                        'message': "未获取到e签宝映射编码!!!"
+                    });
+                    return
+                }
+            }
+        });
+
+        // 弹窗控制
+        $('#open-popup').click(function () {
+            $('#popup-overlay').css('display', 'flex');
+        });
+
+        $('#close-popup').click(function () {
+            $('#popup-overlay').hide();
+        });
+
+        // $('#popup-overlay').click(function (e) {
+        //     if (e.target === this) {
+        //         $(this).hide();
+        //     }
+        // });
+
+        $('#addSigner').click(function () {
+            _this.signerCount++;
+
+            // 创建新签署方卡片
+            var newSigner = '<div class="signer-card" data-id="' + _this.signerCount + '">' +
+                '<div class="card-header">' +
+                '<div class="card-info">' +
+                '<select class="type-select type-personal" id="signer-' + _this.signerCount + '-type" name="signer-' + _this.signerCount + '-type" disabled>' +
+                '<option value="personal" >个人</option>' +
+                '<option value="company">企业</option>' +
+                '<option value="copy" selected>抄送</option>' +
+                '</select>' +
+                '<span class="signer-name" id="signername_index' + _this.signerCount + '" ">签署方' + _this.signerCount + '</span>' +
+                '<span class="signer-role">签署</span>' +
+                '<input type="number" min="1" max="255" value="' + _this.signerCount + '" class="order-input" id="signer-' + _this.signerCount + '-order" name="signer-' + _this.signerCount + '-order">' +
+                '</div>' +
+                '<div class="card-actions">' +
+                '<span class="action-link delete-signer"><span class="icon"></span>删除</span>' +
+                '</div>' +
+                '</div>' +
+                '<div class="form-grid signer-fields">' +
+                '<div class="form-group">' +
+                '<input type="text" placeholder="真实姓名" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name">' +
+                '<span class="input-marker" id="name-tip-' + _this.signerCount + '">ⓘ</span>' +
+                '<input type="hidden" id="signer-' + _this.signerCount + '-person-f7" name="signer-' + _this.signerCount + '-person-f7">' +
+                '</div>' +
+                '<div class="form-group">' +
+                '<input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account">' +
+                '</div>' +
+                '</div>' +
+                '</div>';
+
+            // 添加到容器
+            $('#signersContainer').append(newSigner);
+            // 初始化F7选择器
+            _this.initPersonF7(_this.signerCount);
+            $('#signer-' + _this.signerCount + '-type').val('copy').trigger('change');
+        });
+
+        // 删除签署方
+        $(document).on('click', '.delete-signer', function () {
+            var card = $(this).closest('.signer-card');
+            card.addClass('fade-out');
+
+            setTimeout(function () {
+                card.remove();
+                // 更新序号
+                _this.updateSignerNumbers();
+            }, 300);
+        });
+
+
+        $('#getData').click(function () {
+            var data = _this.getSignerData();
+            console.log(data);
+        });
+
+
+        // 确认按钮事件
+        $('#global-confirm').click(function () {
+            $.block.show({
+                text: '正在发送合同,请稍等...'
+            });
+            var data = _this.collectAllTableData();
+            var data1 = _this.getSignerData();
+            var signFlowTitle = $("#popup_title").attr("value");
+            var sourceId = _this.selectedRowsData ? _this.selectedRowsData["person.id"] : '';
+            var personId = _this.selectedRowsData['person.id'];
+            var d = {};
+            d.signInfo = data1;
+            d.templateInfo = data;
+            d.signFlowTitle = signFlowTitle;
+            d.sourceId = "员工信息" + "_" + sourceId;
+            d.personId = personId
+            console.log(d);
+            var param = {}
+            param.data = d;
+            //param.mack="preview";
+            // 调用服务获取字段数据
+            window.setTimeout(function () {
+                shr.callService({
+                    serviceName: 'create_by_fileOSF',
+                    param: param,
+                    success: function (data) {
+                        console.log("========调用合同返回参数=========")
+                        console.log(data)
+                        if (data.code === 0) {
+                            $('#popup-overlay').hide();
+                            shr.showInfo({
+                                'message': "发送成功!!!"
+                            });
+                        } else {
+                            shr.showError({
+                                'message': data.message
+                            });
+                        }
+                        $.block.hide();
+                    },
+                    error: function (e) {
+                        shr.showError({
+                            'message': e
+                        });
+                        $.block.hide();
+                    }
+                });
+            }, 300)
+        });
+    },
+    /**
+* 处理字段排序:按seq升序排列(从小到大)
+* @param {Object} data - 原始文档数据
+* @returns {Object} 排序后的文档数据
+*/
+    sortFieldsBySeq: function (data) {
+        const sortedData = {};
+        // 遍历每个文档
+        Object.entries(data).forEach(([docId, docInfo]) => {
+            // 深拷贝文档信息,避免修改原对象
+            const newDocInfo = JSON.parse(JSON.stringify(docInfo));
+            // 提取fields的键值对数组,并按seq升序排序
+            const fieldsArr = Object.entries(newDocInfo.fields);
+            const sortedFieldsArr = fieldsArr.sort((a, b) => {
+                // a[1] 和 b[1] 是字段对象,取seq属性比较
+                return a[1].seq - b[1].seq; // 升序(从小到大);降序则改为 b[1].seq - a[1].seq
+            });
+            // 将排序后的数组转回对象(ES6+ 保留顺序)
+            newDocInfo.fields = Object.fromEntries(sortedFieldsArr);
+            // 存入排序后的数据对象
+            sortedData[docId] = newDocInfo;
+        });
+        return sortedData;
+    },
+
+    renderAllTablesByColumns: function () {
+        var _this = this;
+        if (_this.contractName !== "") {
+            $("#popup_title").attr("value", _this.contractName);
+        }
+        var wrapper = $('#tables-wrapper');
+        wrapper.empty();
+
+        $.each(_this.protocolData, function (protocolKey, protocolInfo) {
+            var tableContainer = $('<div>').addClass('table-container');
+            // 表格标题和预览按钮
+            var tableTitle = $('<div>').addClass('table-title');
+            tableTitle.append($('<span>').text(protocolInfo.name || '未命名模板'));
+            var previewBtn = $('<button>').addClass('preview-btn').text('预览');
+            previewBtn.click(function () {
+                _this.previewTableData(protocolKey);
+            });
+            tableTitle.append(previewBtn);
+
+            var table = $('<table>').addClass('data-table').attr('id', 'table-' + protocolKey);
+
+            var fieldNames = [];
+            var fieldValues = [];
+            $.each(protocolInfo.fields || {}, function (fieldKey, fieldInfo) {
+                if (fieldInfo.dataType !== "签署区" && fieldInfo.dataType !== "骑缝签署区" && fieldInfo.dataType !== "签署日期") {
+                    fieldNames.push(fieldInfo.name || '未命名字段');
+                    fieldValues.push({
+                        fieldKey: fieldKey,
+                        value: fieldInfo.value === null ? '' : fieldInfo.value,
+                        dataType: fieldInfo.dataType || '单行文本',
+                        dataFormat: fieldInfo.dataFormat,
+                        isRequired: fieldInfo.isRequired
+                    });
+                }
+            });
+
+            // 表头渲染
+            var thead = $('<thead>');
+            var headerTr = $('<tr>');
+            $.each(fieldNames, function (index, name) {
+                headerTr.append($('<th>').text(name));
+            });
+            thead.append(headerTr);
+            table.append(thead);
+
+            // 内容渲染
+            var tbody = $('<tbody>');
+            var dataTr = $('<tr>');
+            $.each(fieldValues, function (index, fieldData) {
+                var inputHtml;
+
+                // 处理日期类型
+                if (fieldData.dataType === "日期") {
+                    var inputType = _this.getInputType(fieldData.dataFormat);
+                    var formattedValue = _this.formatDateForInput(fieldData.value, fieldData.dataFormat);
+                    if (fieldData.isRequired) {
+                        inputHtml = '<input style="background-color: #D9EDF7;" type="' + inputType + '" value="' + formattedValue + '" placeholder="请输入值">';
+                    } else {
+                        inputHtml = '<input type="' + inputType + '" value="' + formattedValue + '" placeholder="请输入值">';
+                    }
+
+                } else if(fieldData.dataType === "勾选框"){
+                    if(fieldData.value==1||fieldData.value=="1"){
+                        inputHtml = '<input type="Checkbox" checked>';
+                    }else {
+                        inputHtml = '<input type="Checkbox">';
+                    }
+                    
+                }else {
+                    // 非日期类型使用普通文本输入
+
+                    if (fieldData.isRequired) {
+                        inputHtml = '<input style="background-color: #D9EDF7;" type="text" value="' + fieldData.value + '" placeholder="请输入值">';
+                    } else {
+                        inputHtml = '<input type="text" value="' + fieldData.value + '" placeholder="请输入值">';
+                    }
+                }
+                if (fieldData.dataType !== "签署区" && fieldData.dataType !== "骑缝签署区" && fieldData.dataType !== "签署日期") {
+                    dataTr.append($(
+                        '<td data-field-key="' + fieldData.fieldKey + '" ' +
+                        'data-data-type="' + fieldData.dataType + '"' +
+                        'data-data-format="' + fieldData.dataFormat + '">' +
+                        inputHtml +
+                        '</td>'
+                    ));
+                }
+            });
+            tbody.append(dataTr);
+            table.append(tbody);
+
+            tableContainer.append(tableTitle).append(table);
+            wrapper.append(tableContainer);
+        });
+    },
+    formatDateForInput: function (value, dataFormat) {
+        if (!value) return '';
+
+        // 补零工具函数:保证数字为两位(兼容ES5及以上)
+        function padZero(num) {
+            return num < 10 ? '0' + num : num;
+        }
+
+        // 尝试解析各种可能的日期格式
+        var date;
+        if (value instanceof Date) {
+            date = value;
+        } else {
+            // 替换常见分隔符(包括中文年、月、日),统一为 '-' 和 'T'(兼容ISO格式)
+            var normalizedValue = value
+                .replace(/[./年]/g, '-')    // 将 . / 年 替换为 -
+                .replace(/月/g, '-')        // 将 月 替换为 -
+                .replace(/日/g, '')         // 移除 日
+                .replace(/\s+/, 'T')        // 空格替换为T(衔接时分秒)
+                .replace(/:/g, ':');        // 保留冒号(时分秒分隔符)
+
+            date = new Date(normalizedValue);
+
+            // 如果解析失败,尝试其他格式
+            if (isNaN(date.getTime())) {
+                // 处理类似 "2025-11" 这样的年月格式
+                if (value.match(/^\d{4}-\d{2}$/)) {
+                    date = new Date(value + '-01');
+                } else {
+                    console.warn('无法解析日期: ' + value);
+                    return value; // 解析失败时返回原始值
+                }
+            }
+        }
+
+        // 根据dataFormat返回对应格式
+        if (dataFormat.indexOf('yyyy-MM-dd HH:mm:ss') !== -1) {
+            return date.toISOString().slice(0, 19).replace('T', ' '); // 注意:原代码slice(0,19)是"2025-11-12T13:45:30",这里替换T为空格更符合常规
+        } else if (dataFormat.indexOf('yyyy-MM-dd HH:mm') !== -1) {
+            return date.toISOString().slice(0, 16).replace('T', ' ');
+        } else if (dataFormat.indexOf('yyyy-MM-dd') !== -1) {
+            return date.toISOString().slice(0, 10);
+        } else if (dataFormat.indexOf('yyyy年MM月dd日') !== -1) {
+            // 基础中文日期格式:yyyy年MM月dd日
+            const year = date.getFullYear();
+            const month = padZero(date.getMonth() + 1); // 月份是0-based(0-11),需+1
+            const day = padZero(date.getDate());
+            let result = `${year}年${month}月${day}日`;
+
+            // 扩展:处理时分秒
+            if (dataFormat.indexOf('HH:mm:ss') !== -1) {
+                const hour = padZero(date.getHours());
+                const minute = padZero(date.getMinutes());
+                const second = padZero(date.getSeconds());
+                result += ` ${hour}:${minute}:${second}`;
+            } else if (dataFormat.indexOf('HH:mm') !== -1) {
+                const hour = padZero(date.getHours());
+                const minute = padZero(date.getMinutes());
+                result += ` ${hour}:${minute}`;
+            }
+            return result;
+        }
+
+        // 未知格式,返回原始值
+        return value;
+    },
+    getInputType: function (dataFormat) {
+        // 添加对dataFormat的检查,无值时默认使用"yyyy-MM-dd"
+        if (!dataFormat) {
+            dataFormat = "yyyy-MM-dd";
+        }
+
+        // 处理中文日期格式:yyyy年MM月dd日(包括扩展格式)
+        if (dataFormat.indexOf('yyyy年MM月dd日') !== -1) {
+            return 'text';
+        }
+
+        // 简化原有逻辑:合并HH:mm:ss和HH:mm的判断
+        if (dataFormat.indexOf('HH:mm') !== -1) { // 同时匹配HH:mm和HH:mm:ss
+            return 'datetime-local';
+        } else if (dataFormat.indexOf('yyyy-MM-dd') !== -1) {
+            return 'date';
+        }
+
+        // 未知格式返回text
+        return 'text';
+    },
+
+    // 预览单个表格数据
+    previewTableData: function (protocolKey) {
+        var _this = this;
+        var protocolInfo = _this.protocolData[protocolKey] || {};
+        var tableData = {};
+        tableData[protocolKey] = {
+            "name": protocolInfo.name || protocolKey,
+            "id": protocolInfo.id || protocolKey,
+            "fields": {}
+        };
+
+        $('#table-' + protocolKey + ' tbody tr td').each(function (index) {
+            var fieldKey = $(this).data('field-key');
+            var fieldName = $('#table-' + protocolKey + ' thead th:eq(' + index + ')').text() || '字段' + (index + 1);
+            var value = $(this).find('input').val() || null;
+
+            var dataType = "单行文本";
+            if (protocolInfo.fields && protocolInfo.fields[fieldKey]) {
+                dataType = protocolInfo.fields[fieldKey].dataType || "单行文本";
+            }
+            if(dataType==="勾选框"){
+                value  = ""+$(this).find('input').is(':checked')+""
+            }
+
+            tableData[protocolKey].fields[fieldKey] = {
+                name: fieldName,
+                dataType: dataType,
+                value: value
+            };
+        });
+        var param = {}
+        param.data = tableData;
+        param.mack = "preview";
+        $.block.show({
+            text: '正在获取预览地址,请稍等...'
+        });
+        window.setTimeout(function () {
+            // 调用服务获取字段数据
+            shr.callService({
+                serviceName: 'create_by_fileOSF',
+                param: param,
+                success: function (data) {
+                    console.log("========调用合同返回参数=========")
+                    console.log(data)
+                    if (data.code !== 0) {
+                        shr.showError({
+                            'message': data.message
+                        });
+                    } else {
+                        window.open(data.data.fileDownloadUrl, '_blank');
+                    }
+                    $.block.hide();
+                },
+                error: function (e) {
+                    shr.showError({
+                        'message': e
+                    });
+                    $.block.hide();
+                }
+            });
+        }, 300)
+
+    },
+    // 收集所有表格数据
+    collectAllTableData: function () {
+        var allData = {};
+        var _this = this;
+        $.each(_this.protocolData, function (protocolKey, protocolInfo) {
+            // var tableData = {
+            //     tableName: protocolInfo.name,
+            //     tableId: protocolInfo.id,
+            //     fields: protocolInfo.fields
+            // };
+            var tableData = protocolInfo
+            $('#table-' + protocolKey + ' tbody tr td').each(function (index) {
+                var fieldKey = $(this).data('field-key');
+                var fieldName = $('#table-' + protocolKey + ' thead th:eq(' + index + ')').text();
+                var dataType = $(this).data('data-type');
+                var dataFormat = $(this).data('data-format');
+                tableData.fields[fieldKey].name = fieldName;
+                tableData.fields[fieldKey].dataType = dataType;
+                tableData.fields[fieldKey].dataFormat = dataFormat;
+                var value=""
+                if(dataType=="勾选框"){
+                    value = ""+$(this).find('input').is(':checked')+""
+                }else {
+                    value = $(this).find('input').val() || null;
+                }
+                tableData.fields[fieldKey].value = value;
+                // tableData.fields[fieldKey] = {
+                //     name: fieldName,
+                //     dataType: dataType,
+                //     dataFormat: dataFormat,
+                //     value: value
+                // };
+            });
+
+            allData[protocolKey] = tableData;
+        });
+        console.log('===== 所有表格数据 =====');
+        console.log(JSON.stringify(allData, null, 2));
+        return allData;
+    },
+    // 验证签署顺序输入值
+    validateOrder: function (input) {
+        var value = parseInt(input.value);
+        if (isNaN(value) || value < 1) {
+            input.value = 1;
+        } else if (value > 255) {
+            input.value = 255;
+        }
+    },
+
+    // 切换签署方类型
+    changeSignerType: function (selectElement) {
+        var type = selectElement.value;
+        var card = $(selectElement).closest('.signer-card');
+        var cardId = card.attr('data-id');
+        var fieldsContainer = card.find('.signer-fields');
+        var orderInput = card.find('.order-input');
+        var roleElement = card.find('.signer-role');
+
+        var nameElement = card.find('.signer-name');
+
+        // 更新选择框样式和颜色
+        if (type === 'personal') {
+            $(selectElement).removeClass('type-company type-copy').addClass('type-personal');
+            // 显示个人字段和签署顺序
+            fieldsContainer.html(
+                '<div class="form-group">' +
+                '<input type="text" placeholder="真实姓名" class="input-field" id="signer-' + cardId + '-name" name="signer-' + cardId + '-name">' +
+                '<span class="input-marker" id="name-tip-' + cardId + '">ⓘ</span>' +
+                '<input type="hidden" id="signer-' + cardId + '-person-f7" name="signer-' + cardId + '-person-f7">' +
+                '</div>' +
+                '<div class="form-group">' +
+                '<input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + cardId + '-account" name="signer-' + cardId + '-account">' +
+                '</div>'
+            );
+            nameElement.text('签署方' + cardId)
+            roleElement.text('签署');
+            $('#span-' + cardId + '').remove();
+            orderInput.show();
+            // 初始化F7选择器
+            this.initPersonF7(cardId);
+        } else if (type === 'company') {
+            $(selectElement).removeClass('type-personal type-copy').addClass('type-company');
+            $('#signer-' + cardId + '-order').after('<span id="span-' + cardId + '"> 自动签 <input type="radio" placeholder="" class="" id="signer-' + cardId + '-radio" name="signer-radio-orgname"></span>');
+            // 显示企业字段和签署顺序
+            fieldsContainer.html(
+                '<div class="form-group">' +
+                '<input type="text" placeholder="请输入企业完整名称" class="input-field" id="signer-' + cardId + '-orgname" name="signer-' + cardId + '-orgname">' +
+                '</div>' +
+                '<div class="form-group">' +
+                '<input readonly type="text" placeholder="企业章" class="input-field" id="signer-' + cardId + '-orgnId" name="signer-' + cardId + '-orgnId">' +
+                '<span class="input-marker" id="name-orgId-' + cardId + '">ⓘ</span>' +
+                '<input type="hidden" id="signer-' + cardId + '-orgnId-f7" name="signer-' + cardId + '-orgnId-f7">' +
+                '</div>' +
+                '<div class="form-group">' +
+                '<input type="text" placeholder="真实姓名" class="input-field" id="signer-' + cardId + '-name" name="signer-' + cardId + '-name">' +
+                '<span class="input-marker" id="name-tip-' + cardId + '">ⓘ</span>' +
+                '<input type="hidden" id="signer-' + cardId + '-person-f7" name="signer-' + cardId + '-person-f7">' +
+                '</div>' +
+                '<div class="form-group">' +
+                '<input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + cardId + '-account" name="signer-' + cardId + '-account">' +
+                '</div>'
+            );
+            nameElement.text('签署方' + cardId)
+            roleElement.text('签署');
+            orderInput.show();
+            // 初始化F7选择器
+            this.initPersonF7(cardId);
+        } else if (type === 'copy') {
+            // 处理抄送类型
+            $(selectElement).removeClass('type-personal type-company').addClass('type-copy');
+            $('#span-' + cardId + '').remove();
+            // 显示抄送字段,隐藏签署顺序
+            fieldsContainer.html(
+                '<div class="form-group">' +
+                '<input type="text" placeholder="真实姓名" class="input-field" id="signer-' + cardId + '-name" name="signer-' + cardId + '-name">' +
+                '<span class="input-marker" id="name-tip-' + cardId + '">ⓘ</span>' +
+                '<input type="hidden" id="signer-' + cardId + '-person-f7" name="signer-' + cardId + '-person-f7">' +
+                '</div>' +
+                '<div class="form-group">' +
+                '<input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + cardId + '-account" name="signer-' + cardId + '-account">' +
+                '</div>'
+            );
+            nameElement.text('抄送方' + cardId)
+            roleElement.text('抄送');
+            orderInput.hide(); // 隐藏签署顺序
+            // 初始化F7选择器
+            this.initPersonF7(cardId);
+        }
+    },
+
+    // 初始化人员选择F7
+    initPersonF7: function (cardId) {
+        var grid_f7_json = {
+            id: 'signer-' + cardId + '-person-f7',
+            name: 'signer-' + cardId + '-person-f7'
+        };
+        grid_f7_json.subWidgetName = 'shrPromptGrid';
+        grid_f7_json.subWidgetOptions = {
+            title: "员工",
+            uipk: "com.kingdee.eas.custom.entryconfig.app.person.F7",
+            query: "",
+            filter: "",
+            domain: "",
+            multiselect: false,
+            treeFilterConfig: '',
+            permItemId: "",
+            isHasMultileDialog: false,
+            isTree: false,
+            treeUrl: "",
+            isContainLowerOrg: false,
+            isAdminOrg: false,
+            pgSizes: true,
+            f7SearchConfig: { "displayField": [], "filterFields": "" },
+            dataShowMode: "layout"
+        };
+        grid_f7_json.readonly = '';
+        grid_f7_json.validate = '{required:false}';
+        grid_f7_json.value = { 'id': "", 'name': "" };
+        grid_f7_json.isHROrg = "false";
+        grid_f7_json.isAdminOrg = "false";
+        grid_f7_json.searchLikePattern = "any";
+
+        // 初始化F7选择器
+        $('#signer-' + cardId + '-person-f7').shrPromptBox(grid_f7_json);
+
+        // 绑定选择事件,将选择的姓名回填到真实姓名输入框
+        $('#signer-' + cardId + '-person-f7').shrPromptBox('option', {
+            afterOnSelectRowHandler: function (a, data) {
+                $('#signer-' + cardId + '-name').val(data.value.name);
+                $('#signer-' + cardId + '-account').val(data.value.cell);
+                console.log(data);
+            }
+        });
+        $('#name-tip-' + cardId).click(function () {
+            $('#signer-' + cardId + '-person-f7').shrPromptBox("open");
+        });
+        $('#signer-' + cardId + '-person-f7').parent().parent().parent().hide();
+
+
+
+
+        id = "signer-' + cardId + '-orgnId-f7"
+
+
+        var grid_f7_json = {
+            id: 'signer-' + cardId + '-orgnId-f7',
+            name: 'signer-' + cardId + '-orgnId-f7'
+        };
+        grid_f7_json.subWidgetName = 'shrPromptGrid';
+        grid_f7_json.subWidgetOptions = {
+            title: "印章",
+            uipk: "com.kingdee.eas.custom.esign.app.Seal.list",
+            query: "",
+            filter: "",
+            domain: "",
+            multiselect: false,
+            treeFilterConfig: '',
+            permItemId: "",
+            isHasMultileDialog: false,
+            isTree: false,
+            treeUrl: "",
+            isContainLowerOrg: false,
+            isAdminOrg: false,
+            pgSizes: true,
+            f7SearchConfig: { "displayField": [], "filterFields": "" },
+            dataShowMode: "layout"
+        };
+        grid_f7_json.readonly = '';
+        grid_f7_json.validate = '{required:false}';
+        grid_f7_json.value = { 'id': "", 'name': "" };
+        grid_f7_json.isHROrg = "false";
+        grid_f7_json.isAdminOrg = "false";
+        grid_f7_json.searchLikePattern = "any";
+
+        // 初始化F7选择器
+        $('#signer-' + cardId + '-orgnId-f7').shrPromptBox(grid_f7_json);
+
+        $('#signer-' + cardId + '-orgnId-f7').shrPromptBox('option', {
+            afterOnSelectRowHandler: function (a, data) {
+                $('#signer-' + cardId + '-orgnId').val(data.value.sealId);
+                console.log(data);
+            }
+        });
+        $('#name-orgId-' + cardId).click(function () {
+            $('#signer-' + cardId + '-orgnId-f7').shrPromptBox("open");
+        });
+
+        $('#signer-' + cardId + '-orgnId-f7').parent().parent().parent().hide();
+    },
+
+    // 更新签署方序号
+    updateSignerNumbers: function () {
+        var _this = this;
+        $('.signer-card').each(function (index, element) {
+            var newNumber = index + 1;
+            var oldId = $(element).attr('data-id');
+
+            // 更新卡片ID
+            $(element).attr('data-id', newNumber);
+
+            // 更新显示名称
+            $(element).find('.signer-name').text('签署方' + newNumber);
+
+            // 更新所有相关元素的ID和name属性
+            $(element).find('[id^="signer-' + oldId + '-"]').each(function () {
+                var field = $(this).attr('id').split('-').pop();
+                $(this).attr('id', 'signer-' + newNumber + '-' + field);
+                var name = $(this).attr('name');
+                if (name !== "signer-radio-orgname") {
+                    $(this).attr('name', 'signer-' + newNumber + '-' + field);
+                }
+            });
+
+            // 重新初始化F7组件(因为ID发生了变化)
+            _this.initPersonF7(newNumber);
+
+            // 如果没有设置过顺序值,自动填充序号(只对非抄送类型生效)
+            var orderInput = $(element).find('.order-input');
+            var typeSelect = $(element).find('.type-select');
+
+            if (typeSelect.val() !== 'copy' && (!orderInput.val() || orderInput.val() < 1)) {
+                orderInput.val(newNumber);
+            }
+        });
+        _this.signerCount = $('.signer-card').length;
+    },
+
+    // 获取数据方法
+    getSignerData: function () {
+        var result = {
+            signers: [],
+            copiers: []
+        };
+
+        // 遍历所有签署方卡片
+        $('.signer-card').each(function () {
+            var cardId = $(this).attr('data-id');
+            var type = $(this).find('#signer-' + cardId + '-type').val();
+            // 获取F7选择的完整数据
+            var f7Data = $('#signer-' + cardId + '-person-f7').shrPromptBox('getValue') || {};
+
+            if (type === 'personal') {
+                // 个人签署方
+                result.signers.push({
+                    psnSignerInfo: {
+                        psnAccount: $(this).find('#signer-' + cardId + '-account').val() || '',
+                        psnName: $(this).find('#signer-' + cardId + '-name').val() || '',
+                        signOrder: $(this).find('#signer-' + cardId + '-order').val() || '1',
+                        f7Data: f7Data, // 包含F7选择的完整数据
+                        signName: $(this).find('#signername_index' + cardId).text() || '',
+                    }
+                });
+            } else if (type === 'company') {
+                // 企业签署方
+                result.signers.push({
+                    orgSignerInfo: {
+                        orgName: $(this).find('#signer-' + cardId + '-orgname').val() || '',
+                        psnName: $(this).find('#signer-' + cardId + '-name').val() || '',
+                        psnAccount: $(this).find('#signer-' + cardId + '-account').val() || '',
+                        signOrder: $(this).find('#signer-' + cardId + '-order').val() || '1',
+                        f7Data: f7Data, // 包含F7选择的完整数据
+                        sealId: $(this).find('#signer-' + cardId + '-orgnId').val() || '',
+                        isRadio: $('#signer-' + cardId + '-radio').is(":checked"),
+                        signName: $(this).find('#signername_index' + cardId).text() || '',
+                    }
+                });
+            } else if (type === 'copy') {
+                // 抄送方
+                result.copiers.push({
+                    psnAccount: $(this).find('#signer-' + cardId + '-account').val() || '',
+                    psnName: $(this).find('#signer-' + cardId + '-name').val() || '',
+                    f7Data: f7Data, // 包含F7选择的完整数据
+                    signName: $(this).find('#signername_index' + cardId).text() || '',
+                });
+            }
+        });
+
+        return result;
+    },
+    // 重置参与方设置
+    resetSigners: function (eSignTemplateId) {
+        var _this = this;
+        // 清空现有签署方卡片
+        $('#signersContainer').empty();
+        // 重置签署方计数
+        this.signerCount = 1;
+        // 隐藏结果区域
+        $('#resultArea').hide();
+        var param = {}
+        param.mack = "getTemplate";
+        param.eSignTemplateNum = eSignTemplateId
+        shr.callService({
+            serviceName: 'create_by_fileOSF',
+            param: param,
+            success: function (data) {
+                console.log("========签署信息=========")
+                console.log(data)
+                if (data.data.length <= 0) {
+                    shr.showWarning({
+                        'message': "未获取到设置签署信息请自行设置签署人!注:需要和e签宝保持一致。"
+                    });
+                }
+                var d = data.data
+                for (let i = 0; i < d.length; i++) {
+                    var entry = d[i];
+                    //签署类型 1 公司签署 2 个人签署 3 抄送人
+                    var type = entry.participantType;
+
+                    var defaultSigner = "";
+
+                    if (type == 1 || type == "1") {
+                        var participantFlag = entry.participantFlag;
+                        var orgParticipant = entry.orgParticipant
+                        var participantSetMode = entry.participantSetMode
+                        if (participantSetMode == 2 ) {
+                            continue;
+                        }
+                        defaultSigner = '<div class="signer-card" data-id="' + _this.signerCount + '">' +
+                            '<div class="card-header">' +
+                            '<div class="card-info"><select class="type-select type-company" id="signer-' + _this.signerCount + '-type" name="signer-' + _this.signerCount + '-type" disabled>' +
+                            '<option value="personal" >个人</option>' +
+                            '<option value="company" selected >企业</option>' +
+                            '<option value="copy">抄送</option>' +
+                            '</select>' +
+                            '<span class="signer-name" id="signername_index' + _this.signerCount + '">' + participantFlag + '</span><span class="signer-role">签署</span>' +
+                            '<input type="number" min="1" max="255" value="' + _this.signerCount + '" class="order-input"id="signer-' + _this.signerCount + '-order" name="signer-' + _this.signerCount + '-order" style="">' +
+                            '<span id="span-' + _this.signerCount + '"> 自动签 <input type="radio"placeholder="" class="" id="signer-' + _this.signerCount + '-radio" name="signer-radio-orgname"></span>' +
+                            '</div>' +
+                            '<!--div class="card-actions"><span class="action-link delete-signer"><span class="icon"></span>删除</span></div-->' +
+                            '</div>' +
+                            '<div class="form-grid signer-fields">'
+                        if (orgParticipant != null) {
+                            var orgName = orgParticipant.orgName;
+                            //disabled
+                            if (orgName != null && orgName != undefined && orgName != "") {
+                                defaultSigner += '<div class="form-group"><input type="text" placeholder="请输入企业完整名称" value="' + orgParticipant.orgName + '" class="input-field" id="signer-' + _this.signerCount + '-orgname"name="signer-' + _this.signerCount + '-orgname"></div>'
+                            } else {
+                                defaultSigner += '<div class="form-group"><input type="text" placeholder="请输入企业完整名称" value="' + orgParticipant.orgName + '" class="input-field" id="signer-' + _this.signerCount + '-orgname"name="signer-' + _this.signerCount + '-orgname" disabled ></div>'
+                            }
+                        } else {
+                            defaultSigner += '<div class="form-group"><input type="text" placeholder="请输入企业完整名称" value="" class="input-field" id="signer-' + _this.signerCount + '-orgname"name="signer-' + _this.signerCount + '-orgname"></div>'
+                        }
+
+                        defaultSigner += '<div class="form-group"><input readonly="" type="text" placeholder="企业章" class="input-field"id="signer-' + _this.signerCount + '-orgnId" name="signer-' + _this.signerCount + '-orgnId"><span class="input-marker" id="name-orgId-' + _this.signerCount + '">ⓘ</span>' +
+                            '<div class="ui-promptBox-frame" style="display: none;">' +
+                            '<div class="ui-promptBox-layout">' +
+                            '<div class="ui-promptBox-inputframe"><input type="hidden" id="signer-' + _this.signerCount + '-orgnId-f7_el" name="hidd_name_signer-' + _this.signerCount + '-orgnId-f7" value=""><input type="hidden" id="signer-' + _this.signerCount + '-orgnId-f7"name="signer-' + _this.signerCount + '-orgnId-f7" ctrlrole="promptBox" autocomplete="off" value="" title=""></div>' +
+                            '<div class="ui-promptBox-icon"><img style="cursor:pointer;" src="/shr/styles/images/seniorf7.png">' +
+                            '</div>' +
+                            '</div>' +
+                            '</div>' +
+                            '</div>';
+                        if (orgParticipant != null) {
+                            var transactor = orgParticipant.transactor;
+                            if (transactor != null && transactor != undefined) {
+                                defaultSigner += '<div class="form-group"><input type="text" placeholder="真实姓名" value="' + transactor.transactorName + '" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name"><span class="input-marker" id="name-tip-' + _this.signerCount + '">ⓘ</span>'
+                            } else {
+                                defaultSigner += '<div class="form-group"><input type="text" placeholder="真实姓名" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name"><span class="input-marker" id="name-tip-' + _this.signerCount + '">ⓘ</span>'
+
+                            }
+
+                        } else {
+                            defaultSigner += '<div class="form-group"><input type="text" placeholder="真实姓名" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name"><span class="input-marker" id="name-tip-' + _this.signerCount + '">ⓘ</span>'
+                        }
+                        defaultSigner += '<div class="ui-promptBox-frame" style="display: none;">' +
+                            '<div class="ui-promptBox-layout">' +
+                            '<div class="ui-promptBox-inputframe"><input type="hidden" id="signer-' + _this.signerCount + '-person-f7_el" name="hidd_name_signer-' + _this.signerCount + '-person-f7" value=""><input type="hidden" id="signer-' + _this.signerCount + '-person-f7"' +
+                            ' name="signer-' + _this.signerCount + '-person-f7" ctrlrole="promptBox" autocomplete="off" value="" title=""></div>' +
+                            '<div class="ui-promptBox-icon"><img style="cursor:pointer;" src="/shr/styles/images/seniorf7.png">' +
+                            '</div>' +
+                            '</div>' +
+                            '</div>' +
+                            '</div>';
+                        if (orgParticipant != null) {
+                            var transactor = orgParticipant.transactor;
+                            if (transactor != null && transactor != undefined) {
+                                defaultSigner += '<div class="form-group"><input type="text" placeholder="请输入手机号/邮箱" value="' + transactor.transactorPsnAccount + '" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account"></div>';
+                            } else {
+                                defaultSigner += '<div class="form-group"><input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account"></div>';
+
+                            }
+
+                        } else {
+                            defaultSigner += '<div class="form-group"><input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account"></div>';
+                        }
+                        defaultSigner += '</div>' +
+                            '</div>';
+                    } else if (type == 2 || type == "2") {
+                        var participantFlag = entry.participantFlag;
+                        var psnParticipant = entry.psnParticipant
+                        var participantSetMode = entry.participantSetMode
+                        if (participantSetMode == 2 ) {
+                            continue;
+                        }
+                        // 添加默认的第一个签署方卡片 默认个人
+                        defaultSigner = '<div class="signer-card" data-id="' + _this.signerCount + '">' +
+                            '<div class="card-header">' +
+                            '<div class="card-info">' +
+                            '<select class="type-select type-personal" id="signer-' + _this.signerCount + '-type" name="signer-' + _this.signerCount + '-type" disabled>' +
+                            '<option value="personal" selected >个人</option>' +
+                            '<option value="company" >企业</option>' +
+                            '<option value="copy">抄送</option>' +
+                            '</select>' +
+                            '<span class="signer-name" id = "signername_index' + _this.signerCount + '">' + participantFlag + '</span>' +
+                            '<span class="signer-role">签署</span>' +
+                            '<input type="number" min="1" max="255" value="' + _this.signerCount + '" class="order-input" id="signer-' + _this.signerCount + '-order" name="signer-' + _this.signerCount + '-order">' +
+                            '</div>' +
+                            '<!--div class="card-actions">' +
+                            '<span class="action-link delete-signer"><span class="icon"></span>删除</span>' +
+                            '</div-->' +
+                            '</div>' +
+                            '<div class="form-grid signer-fields">' +
+                            '<div class="form-group">';
+                        if (psnParticipant != null && psnParticipant != undefined) {
+                            defaultSigner += '<input type="text" placeholder="真实姓名" value="' + psnParticipant.psnName + '" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name">';
+                        } else {
+                            defaultSigner += '<input type="text" placeholder="真实姓名" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name">';
+                        }
+                        defaultSigner += '<span class="input-marker" id="name-tip-' + _this.signerCount + '">ⓘ</span>' +
+                            '<input type="hidden" id="signer-' + _this.signerCount + '-person-f7" name="signer-' + _this.signerCount + '-person-f7">' +
+                            '</div>' +
+                            '<div class="form-group">';
+                        if (psnParticipant != null && psnParticipant != undefined) {
+                            defaultSigner += '<input type="text" placeholder="请输入手机号/邮箱" value="' + psnParticipant.psnAccount + '" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account">';
+                        } else {
+                            defaultSigner += '<input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account">';
+                        }
+                        defaultSigner += '</div>' +
+                            '</div>' +
+                            '</div>';
+                    } else if (type == 3 || type == "3") {
+                        var copierPsnInfo = entry.copierPsnInfo;
+                        defaultSigner = '<div class="signer-card" data-id="' + _this.signerCount + '">' +
+                            '<div class="card-header">' +
+                            '<div class="card-info"><select class="type-select type-copy" id="signer-' + _this.signerCount + '-type" name="signer-' + _this.signerCount + '-type" disabled>' +
+                            '<option value="personal">个人</option>' +
+                            '<option value="company">企业</option>' +
+                            '<option value="copy" selected >抄送</option>' +
+                            '</select>' +
+                            '<span class="signer-name" id="signername_index' + _this.signerCount + '" > 抄送方' + _this.signerCount + '</span><span class="signer-role">抄送</span>' +
+                            '<input type="number" min="1" max="255" value="' + _this.signerCount + '" class="order-input" id="signer-' + _this.signerCount + '-order" name="signer-' + _this.signerCount + '-order" style="display: none;"></div>' +
+                            '<!--div class="card-actions"><span class="action-link delete-signer"><span class="icon"></span>删除</span></div-->' +
+                            '</div>' +
+                            '<div class="form-grid signer-fields">' +
+                            '<div class="form-group">';
+                        if (copierPsnInfo != null && copierPsnInfo != undefined) {
+                            defaultSigner += '<input type="text" placeholder="真实姓名" value="' + copierPsnInfo.psnName + '" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name">';
+
+                        } else {
+                            defaultSigner += '<input type="text" placeholder="真实姓名" class="input-field" id="signer-' + _this.signerCount + '-name" name="signer-' + _this.signerCount + '-name">';
+                        }
+                        defaultSigner += '<span class="input-marker" id="name-tip-' + _this.signerCount + '">ⓘ</span>' +
+                            '<div class="ui-promptBox-frame" style="display: none;">' +
+                            '<div class="ui-promptBox-layout">' +
+                            '<div class="ui-promptBox-inputframe">' +
+                            '<input type="hidden" id="signer-' + _this.signerCount + '-person-f7_el" name="hidd_name_signer-' + _this.signerCount + '-person-f7" value="">' +
+                            '<input type="hidden" id="signer-' + _this.signerCount + '-person-f7" name="signer-' + _this.signerCount + '-person-f7" ctrlrole="promptBox" autocomplete="off" value="" title="">' +
+                            '</div>' +
+                            '<div class="ui-promptBox-icon"><img style="cursor:pointer;" src="/shr/styles/images/seniorf7.png">' +
+                            '</div>' +
+                            '</div>' +
+                            '</div>' +
+                            '</div>' +
+                            '<div class="form-group">';
+                        if (copierPsnInfo != null && copierPsnInfo != undefined) {
+                            defaultSigner += '<input type="text" placeholder="请输入手机号/邮箱" value="' + copierPsnInfo.psnAccount + '" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account">';
+
+                        } else {
+                            defaultSigner += '<input type="text" placeholder="请输入手机号/邮箱" class="input-field" id="signer-' + _this.signerCount + '-account" name="signer-' + _this.signerCount + '-account">';
+                        }
+                        defaultSigner += '</div>' +
+                            '</div>' +
+                            '</div>';
+
+                    } else {
+                        shr.showWarning({
+                            'message': "获取到设置签署信息失败!请自行设置签署人!注:需要和e签宝保持一致。"
+                        });
+                    }
+                    $('#signersContainer').append(defaultSigner);
+                    _this.initPersonF7(_this.signerCount);
+                    _this.signerCount++
+                }
+
+            },
+            error: function (e) {
+                shr.showError({
+                    'message': e
+                });
+            }
+        });
+    }
+});

+ 370 - 510
js/addon/customer/configinfo/js/configInfoEdit.js

@@ -1,543 +1,403 @@
-// 定义配置信息编辑类,继承自框架的Edit类
-shr.defineClass("shr.ats.configInfoEdit", shr.framework.Edit, {
-    fieldData: "", // 存储字段数据
-    selectedFields: [], // 存储当前选中的字段
-    isSelected: [], // 存储已选中的字段标识(用于回显)
-    selectEntry: "", // 当前选中的条目
 
-    // 初始化DOM元素及事件绑定
+shr.defineClass("shr.ats.configInfoEdit", shr.framework.Edit, {
     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()
     },
+    addRowAction: function () {
+        var params = {}
+        params.entityName = "com.kingdee.eas.basedata.person.app.Person"
+        entityName.isQuery = "false"
+        shr.callService({
+            serviceName: 'getEntityInfoService',
+            param: params,
+            success: function (data) {
 
-    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 })
-                                }
-                            }
-                        });
+                if (waf.modelObjectData.className == 'waf.framework.dynamic.element.EditGrid') {
+                    //编辑表格只能勾选分录下面的数据
+                    var editGridName = waf.modelObjectData.getProp('name').value;
+                    waf.editGridData = [];
+                    data = getEditGridData(data, editGridName);
+                };
+                $('.fieldEditContainerLoading').remove();
+                $('#fieldEditContainer').css('visibility', 'visible');
+                $('.ui-dialog-titlebar .ui-icon-closethick').css('visibility', 'visible');
+                $('.ui-dialog-buttonset').css('visibility', 'visible');
+                waf.fieldData = [];
+                $.each(configPage.allComponentChildren, function (i, v) {
+                    var classNameList = ['waf.framework.dynamic.element.EditColumn', 'waf.framework.dynamic.element.Field', 'waf.framework.dynamic.element.Column',
+                        'waf.framework.dynamic.element.SearchColumn', 'waf.framework.dynamic.element.F7Column'];
+                    if (classNameList.indexOf(v.className) > -1) {
+                        waf.fieldData.push(v);
                     }
+                });
+                doFieldData(data);
+                addTreeFieldLocationListener();
+                addEditGridNameTips();
+                //阻止鼠标滚动穿透
+                var eventType = 'wheel';
+                //兼容火狐浏览器
+                if (document.mozHidden !== undefined) {
+                    eventType = 'DOMMouseScroll';
                 }
-            }
-        })
-    },
-
-
-    // 根据数据类型别名获取对应枚举值
-    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;
-                        }
+                $('#gridZtree').on(eventType, function (e) {
+                    var scrollTop = this.scrollTop,
+                        scrollHeight = this.scrollHeight,
+                        height = this.clientHeight;
+                    var delta = (e.originalEvent.wheelDelta) ? e.originalEvent.wheelDelta : -(e.originalEvent.detail || 0);
+                    if ((delta > 0 && scrollTop <= delta) || (delta < 0 && scrollHeight - height - scrollTop <= -1 * delta)) {
+                        this.scrollTop = delta > 0 ? 0 : scrollHeight;
+                        e.preventDefault();
                     }
-                }
-            },
-            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
-            }
+        // var source = event.currentTarget,
+        // 	$editGrid = this.getEditGrid(source);
 
+        // var data = this.createNewEntryModel();
+        // if (typeof data === 'undefined') {
+        // 	data = {};
+        // }
 
-            // 若选中条目变更,重新获取字段数据并初始化树
-            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
+        // var editGridCont = this._getEditGridCont(source);
+        // if (editGridCont.data('editType') == 'inline') {
+        // 	// 表格内编辑
+        // 	$editGrid.jqGrid('addRow', { data: data	});
+        // } else {
+        // 	$editGrid.wafGrid('addForm');
+        // }
 
-                // 调用服务获取字段数据
-                shr.callService({
-                    serviceName: 'getSelectFieldService',
-                    param: params,
-                    success: function (data) {
-                        _this.fieldData = data
-                        _this.selectedFields = []
-                        // 初始化树形结构
-                        _this.initTree(_this.fieldData);
-                        // 显示容器
-                        $("#container").attr("style", "")
-                    }
-                });
+        // var event = document.createEvent('HTMLEvents');
+        //     event.initEvent("editComplete_"+$editGrid.attr("id"), true, true);
+        //     event.eventType = 'message';
+        //     document.dispatchEvent(event);
+    }
+})
+//获取编辑表格数据
+function getEditGridData(data, editGridName) {
+    if (data && data.length > 0) {
+        $.each(data, function (i, v) {
+            if (v.field === editGridName) {
+                waf.editGridData = v;
+                return false;
             } else {
-                _this.initTree(_this.fieldData);
-                // 条目未变更,直接显示容器
-                $("#container").attr("style", "")
-            }
-            // 根据已选中字段回显选择状态
-            _this.selectFieldsByField(_this.isSelected);
-
+                getEditGridData(v.children, editGridName);
+            };
+        });
+    };
+    return waf.editGridData;
+};
+function doFieldData(data) {
+    var isClass = '';
+    //兼容IE
+    var Ua = navigator.userAgent;
+    if (Ua.indexOf('MSIE') > -1 || Ua.indexOf('rv:11.0') > -1 || Ua.indexOf('Edge') > -1) {
+        isClass = 'accruateSwitchIE';
+    } else {
+        isClass = 'accruateSwitch';
+    }
 
-        } else {
-            // 其他添加行逻辑(表格内编辑或表单添加)
-            var editGridCont = _this._getEditGridCont(source);
-            if (editGridCont.data('editType') == 'inline') {
-                $editGrid.jqGrid('addRow', { data: data });
-            } else {
-                $editGrid.wafGrid('addForm');
+    $('#fieldEditContainer').html(
+        "<div class='treeSearch-con'>" +
+        "<div class='search-container'>" +
+        "<img src='/shr/styles/images/set_field_location_search.png' class='search-icon'/>" +
+        "<input type='text' placeholder='请输入字段标题、类型、名称' id='searchTree'/>" +
+        "<div style='float:left;'><button id='tree-searchBtn' >搜索</button></div>" +
+        "<div class='accurateTitle'>精确搜索</div>" +
+        "<div class='accruate-container'>" +
+        "<input type='checkbox' class='" + isClass + " switch-anim'>" +
+        "</div>" +
+        "</div>" +
+        "<div class='showNumber'>" +
+        "<label id='treeSearchCount' style='display:none'>" + '共查到' + '&nbsp;0&nbsp;' + "条信息</label>" +
+        '<span id="treePrevSearchTarget" style="display:none;" >上一条</span>' +
+        '<span id="treeNextSearchTarget" style="display:none;" >下一条</span>' +
+        '</div>' +
+        "</div>" +
+        "<ul id='gridZtree' class='ztree'></ul>"
+    );
+    var $zTree = $('#gridZtree.ztree');
+    waf.removeFields = [];
+    //zTree配置
+    var zTreeSettings = {
+        view: {
+            showIcon: false,
+            showLine: false,
+            dblClickExpand: false,
+            addDiyDom: addDiyDom
+        },
+        check: {
+            enable: true,
+            chkboxType: { 'Y': '', 'N': '' },
+            autoCheckTrigger: true,
+            chkStyle: "checkbox"
+        },
+        callback: {
+            onCheck: function (event, treeId, treeNode) {
+                //勾选复选框后,列表字段相应修改逻辑  
+                var containerId = $('#fieldEditContainer').attr('containerId');
+                if (!treeNode.checked) {
+                    //先进先出原则
+                    var removeField = {};
+                    removeField.containerId = containerId;
+                    removeField.fieldId = treeNode.field;
+                    if (!treeNode.field && treeNode.children.length > 0) {
+                        $.each(treeNode.children, function (index, item) {
+                            removeField = $.extend(true, {}, removeField);
+                            removeField.fieldId = item.field;
+                            waf.removeFields.push(removeField);
+                        });
+                    } else {
+                        waf.removeFields.push(removeField);
+                    };
+
+                } else {
+                    for (var i = waf.removeFields.length - 1; i >= 0; i--) {
+                        value = waf.removeFields[i];
+                        if (value.containerId == containerId && value.fieldId == treeNode.field) {
+                            waf.removeFields.remove(value);
+                        };
+                    };
+                };
+            },
+            onNodeCreated: function (event, treeId, treeNode) {
+                var className = waf.modelObjectData.className;
+                if (treeNode && treeNode.level == 0 && className == 'waf.framework.dynamic.element.EditGrid') {
+                    //分录数据默认展开第二级树节点	
+                    window.gridZtree.getZTreeObj(treeId).expandNode(treeNode, true);
+                };
             }
-
-            // 触发编辑完成事件
-            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>';
+    };
+    // $.fn.zTree.init($zTree, zTreeSettings, data);
+    window.gridZtree.init($zTree, zTreeSettings, data);
+    //字段配置数据来源提示信息
+    var dataSourceTips = $('#fieldEditContainer').attr('dataSourceTips');
+    if (dataSourceTips) {
+        var dataSourceHtml = "<div style='float:left;width:540px;margin:-3px 0 0 5px;color:red;word-break:break-all;line-height:20px;'>" + dataSourceTips + "</div>";
+        $('.ui-dialog-buttonpane.ui-widget-content').prepend(dataSourceHtml);
+    };
+    $('#fieldEditContainer').dialog('open');
+    $('#waf-mask img').remove();
+    var model = waf.modelObjectData;
+    //将字段配置容器的modelId挂载到fieldEditContainer的containerId自定义属性中
+    $('#fieldEditContainer').attr('containerId', model.modelId);
+    var modelChildrenObjects;
+    if (model.className == 'waf.framework.dynamic.element.Section' || model.className == 'waf.framework.dynamic.page.ConfigPageCanvas') {
+        modelChildrenObjects = configPage.allComponentChildren.filter(function (v, i) {
+            return v.className == 'waf.framework.dynamic.element.Field';
+        });
+    } else {
+        modelChildrenObjects = model.childrenObjects;
+    };
+    $.each(modelChildrenObjects, function (index, value) {
+        var treeId = 'gridZtree';
+        var tree = window.gridZtree.getZTreeObj(treeId);
+        var treeNode;
+        var fieldId = value.fieldName;
+        if (value.className == 'waf.framework.dynamic.element.EditColumn') {
+            if (!fieldId.startsWith(editName)) {
+                fieldId = editName + '.' + fieldId;
+            };
+        };
+        //根据field选择出节点名字
+        treeNode = tree.getNodeByParam('field', fieldId);
+
+        if (treeNode) {
+            tree.checkNode(treeNode, true, false);
+            //如果为扩展视图,标准产品预置出厂字段不允许删除,故将其勾选状态设置为不可编辑
+            if (waf.isStandardFieldList.indexOf(value.modelId) > -1 && uiViewInfo.isProductionMode) {
+                tree.setChkDisabled(treeNode, true);
+            };
+        }
+    });
+
+};
+
+function addEditGridNameTips() {
+    var className = waf.modelObjectData.className;
+    if (className == 'waf.framework.dynamic.element.EditGrid') {
+        var editGridName = waf.modelObjectData.getProp('name').value;
+        if (editGridName === '') {
+            $('#fieldEditContainer').html('<div style="font-size:14px;margin-top:100px;">编辑表格editGrid的name值为空,请先填写编辑表格的name值!</div>');
+        } else if (waf.editGridData.length == 0) {
+            $('#fieldEditContainer').html('<div style="font-size:14px;margin-top:100px;">请检查编辑表格的name值是否正确!</div>');
+        };
+    };
+};
+
+
+//树的字段添加定位监听
+function addTreeFieldLocationListener() {
+    var _self = this;
+    $('#tree-searchBtn').unbind('click').bind('click', function (event) {
+        event.preventDefault();
+        searchTree();
+        return false;
+    });
+    $('#searchTree').unbind('keydown').bind('keydown', function (event) {
+        if (event.keyCode == 13) {
+            searchTree();
+            event.stopPropagation();
+            return false;
+        }
+    });
+    //每次加载时先解除绑定,在重新绑定方法,避免多次绑定
+    $('#treePrevSearchTarget').unbind('click').bind('click', function () {
+        var targetDom = _self.targetTreeNodeDom;
+        if (_self.index == 0) return;
+        targetDom[_self.index].css('background-color', '#EDF7FF');
+        targetDom[_self.index].focus();
+        _self.index--;
+        targetDom[_self.index].css('background-color', '#D8E6FF');
+        var leng = targetDom[_self.index][0].offsetTop - 240;
+        $('#gridZtree').animate({ scrollTop: leng }, 0);
+    });
+    //每次加载时先解除绑定,在重新绑定方法,避免多次绑定
+    $('#treeNextSearchTarget').unbind('click').bind('click', function () {
+        var targetDom = _self.targetTreeNodeDom;
+        if (_self.index + 1 == targetDom.length || targetDom.length == 0) {
             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);
+        targetDom[_self.index].css('background-color', '#EDF7FF');
+        _self.index++;
+        targetDom[_self.index].css('background-color', '#D8E6FF');
+        var leng = targetDom[_self.index][0].offsetTop - 240;
+        $('#gridZtree').animate({ scrollTop: leng }, 0);
+    });
+};
+//树结构定位、回车时,搜索出目标字段
+function searchTree() {
+    var _self = this;
+    var treeId = 'gridZtree';
+    //window.gridZtree.getZTreeObj,$.fn.zTree.getZTreeObj()
+    var tree = window.gridZtree.getZTreeObj(treeId);
+    var content = $('#searchTree').val();//目标字段
+    var targetCount = 0;
+    _self.targetTreeNodeDom = [];
+    _self.treeDom = [];
+    _self.index = 0;//定位到第几项
+    tree.expandAll(true);
+    //模糊匹配id以 gridZtree_开头的span标签,[id^=gridZtree_]
+    $('ul#gridZtree li a span').each(function () {
+        var parentLiDom = $(this).closest('li');
+        // if(parentLiDom.find('ul').length > 0) return true;
+        if (content == '') {
+            parentLiDom.css('background-color', '');
+            return true;
         }
-
-        // 节点文本
-        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));
+        var str = $(this).text();
+        //用户输入类型和名称对应值也要搜索出来,过滤【类型:F7; 名称:entrys.employerUnit】
+        var arr = str.split(';');
+        if (arr.length > 1) {
+            str = '';
+            $.each(arr, function (index, item) {
+                var items = item.split(':');
+                items[1] = items[1].indexOf('】') > -1 ? items[1].substring(0, items[1].length - 1) : items[1];
+                str += items[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');
+        content = content.toLowerCase();
+        str = str.toLowerCase();
+        var target = new RegExp(content);
+        //判断是否是精确搜索,若是精确搜索不能使用test()匹配,非精确搜索使用test()匹配
+        if ($('.switch-anim').prop('checked')) {
+            var str1 = str.split(',');
+            if (str1.length > 1) {
+                str = str1[1];
             } else {
-                childrenContainer.classList.add('expanded');
-                iconElement.classList.add('expanded');
+                str = str
             }
         }
-    },
-
-    // 切换节点选择状态
-    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;
+        var targetValue = $('.switch-anim').prop('checked') ? (content == str) : target.test(str);
+        if (targetValue) {
+            if (parentLiDom.find('ul').length > 0) {
+                parentLiDom.children('a').css('background-color', '#EDF7FF');
+                //用一个数组判断插入的dom节点是否重复
+                if (_self.treeDom.indexOf(parentLiDom.children('a')[0]) == -1) {
+                    _self.treeDom.push(parentLiDom.children('a')[0]);
+                    _self.targetTreeNodeDom.push(parentLiDom.children('a'));
+                    targetCount++;
                 }
-            }
-
-            // 不匹配且无子节点匹配,返回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);
+            } else {
+                parentLiDom.children('a').css('background-color', '');
+                parentLiDom.css('background-color', '#EDF7FF');
+                //用一个数组判断插入的dom节点是否重复
+                if (_self.treeDom.indexOf(parentLiDom[0]) == -1) {
+                    _self.treeDom.push(parentLiDom[0]);
+                    _self.targetTreeNodeDom.push(parentLiDom);
+                    targetCount++;
                 }
             }
-        });
-
-        // 更新选择状态
-        //_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;
-            }
+        } else {
+            parentLiDom.children('a').css('background-color', '');
+            parentLiDom.css('background-color', '');
         }
-        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;
+    });
+
+    if (targetCount > 0) {
+        $('#treeSearchCount').css('display', '');
+        $('#treePrevSearchTarget').css('display', '');
+        $('#treeNextSearchTarget').css('display', '');
+    } else {
+        tree.expandAll(false);
+        _self.targetTreeNodeDom = [];
+        _self.treeDom = [];
+        $('#treeSearchCount').css('display', '');
+        $('#treePrevSearchTarget').css('display', '');
+        $('#treeNextSearchTarget').css('display', '');
+    }
+    if (_self.targetTreeNodeDom.length > 0) {
+        _self.targetTreeNodeDom[0].css('background-color', '#D8E6FF');
+        //查询到结果,定位到第一条,获取第一条数据的offsetTop时,树结构全部展开后,再设置滚动条的位置
+        setTimeout(function () {
+            var leng = _self.targetTreeNodeDom[0][0].offsetTop - 240;
+            $('#gridZtree').animate({ scrollTop: leng }, 0);
+        }, 200);
+    } else {
+        $('#gridZtree').animate({ scrollTop: 0 });
+    }
+    $('#treeSearchCount').text('共查到 ' + targetCount + ' 条信息');
+};
+//树的字段添加定位监听
+function addTreeFieldLocationListener() {
+    var _self = this;
+    $('#tree-searchBtn').unbind('click').bind('click', function (event) {
+        event.preventDefault();
+        searchTree();
+        return false;
+    });
+    $('#searchTree').unbind('keydown').bind('keydown', function (event) {
+        if (event.keyCode == 13) {
+            searchTree();
+            event.stopPropagation();
+            return false;
         }
-    },
-
-    // 全选所有节点
-    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");		
+    });
+    //每次加载时先解除绑定,在重新绑定方法,避免多次绑定
+    $('#treePrevSearchTarget').unbind('click').bind('click', function () {
+        var targetDom = _self.targetTreeNodeDom;
+        if (_self.index == 0) return;
+        targetDom[_self.index].css('background-color', '#EDF7FF');
+        targetDom[_self.index].focus();
+        _self.index--;
+        targetDom[_self.index].css('background-color', '#D8E6FF');
+        var leng = targetDom[_self.index][0].offsetTop - 240;
+        $('#gridZtree').animate({ scrollTop: leng }, 0);
+    });
+    //每次加载时先解除绑定,在重新绑定方法,避免多次绑定
+    $('#treeNextSearchTarget').unbind('click').bind('click', function () {
+        var targetDom = _self.targetTreeNodeDom;
+        if (_self.index + 1 == targetDom.length || targetDom.length == 0) {
+            return;
         }
-        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();
-    }
-})
+        targetDom[_self.index].css('background-color', '#EDF7FF');
+        _self.index++;
+        targetDom[_self.index].css('background-color', '#D8E6FF');
+        var leng = targetDom[_self.index][0].offsetTop - 240;
+        $('#gridZtree').animate({ scrollTop: leng }, 0);
+    });
+};

+ 12 - 1
websrc/com/kingdee/eas/custom/esign/contract/ContractCompositionQueryHandlerEx.java

@@ -3,6 +3,8 @@ package com.kingdee.eas.custom.esign.contract;
 import com.alibaba.fastjson.JSONObject;
 import com.kingdee.bos.BOSException;
 import com.kingdee.bos.Context;
+import com.kingdee.bos.util.BOSObjectType;
+import com.kingdee.bos.util.BOSUuid;
 import com.kingdee.eas.common.EASBizException;
 import com.kingdee.shr.base.syssetting.MSFServiceFacadeFactory;
 import com.kingdee.shr.base.syssetting.context.SHRContext;
@@ -24,7 +26,16 @@ public class ContractCompositionQueryHandlerEx extends ContractCompositionQueryH
         try {
             Map<String,Object> getSqlServiceMap = new HashMap<String,Object>();
             getSqlServiceMap.put("number",number);
-            getSqlServiceMap.put("filter","  where \"employeeContract\".FID = '"+id+"'");
+            BOSUuid read = BOSUuid.read(id);
+            BOSObjectType type = read.getType();
+            System.out.println(type.toString());
+            if (type.toString().equals("7BD37592")){//id类型为合同
+                getSqlServiceMap.put("filter","  where \"employeeContract\".FID = '"+id+"'");
+            }else  if (type.toString().equals("80EF7DED")){//id类型为员工
+                getSqlServiceMap.put("filter","  where \"person\".FID = '"+id+"'");
+            }else {
+                throw new RuntimeException("传入id非合同id和员工ID");
+            }
             JSONObject jsonObject = new JSONObject();
             jsonObject.put("id",id);
             getSqlServiceMap.put("otherParameters",jsonObject);

+ 12 - 1
websrc/com/kingdee/eas/custom/esign/handler/EmployeeListHandlerESignEx.java

@@ -3,6 +3,8 @@ package com.kingdee.eas.custom.esign.handler;
 import com.alibaba.fastjson.JSONObject;
 import com.kingdee.bos.BOSException;
 import com.kingdee.bos.Context;
+import com.kingdee.bos.util.BOSObjectType;
+import com.kingdee.bos.util.BOSUuid;
 import com.kingdee.eas.common.EASBizException;
 import com.kingdee.eas.custom.beisen.syncperson.handler.EmployeeListHandlerEx;
 import com.kingdee.shr.base.syssetting.MSFServiceFacadeFactory;
@@ -24,7 +26,16 @@ public class EmployeeListHandlerESignEx extends EmployeeListHandlerEx {
         try {
             Map<String,Object> getSqlServiceMap = new HashMap<String,Object>();
             getSqlServiceMap.put("number",number);
-            getSqlServiceMap.put("filter","  where \"employeeemployeeContract\".FID = '"+id+"'");
+            BOSUuid read = BOSUuid.read(id);
+            BOSObjectType type = read.getType();
+            System.out.println(type.toString());
+            if (type.toString().equals("7BD37592")){//id类型为合同
+                getSqlServiceMap.put("filter","  where \"employeeContract\".FID = '"+id+"'");
+            }else  if (type.toString().equals("80EF7DED")){//id类型为员工
+                getSqlServiceMap.put("filter","  where \"person\".FID = '"+id+"'");
+            }else {
+                throw new RuntimeException("传入id非合同id和员工ID");
+            }
             JSONObject jsonObject = new JSONObject();
             jsonObject.put("id",id);
             getSqlServiceMap.put("otherParameters",jsonObject);

+ 13 - 1
websrc/com/kingdee/eas/custom/esign/handler/GeneralESignBillHandler.java

@@ -3,6 +3,8 @@ package com.kingdee.eas.custom.esign.handler;
 import com.alibaba.fastjson.JSONObject;
 import com.kingdee.bos.BOSException;
 import com.kingdee.bos.Context;
+import com.kingdee.bos.util.BOSObjectType;
+import com.kingdee.bos.util.BOSUuid;
 import com.kingdee.eas.common.EASBizException;
 import com.kingdee.shr.base.syssetting.MSFServiceFacadeFactory;
 import com.kingdee.shr.base.syssetting.context.SHRContext;
@@ -24,7 +26,17 @@ public class GeneralESignBillHandler extends ListHandler {
         try {
             Map<String,Object> getSqlServiceMap = new HashMap<String,Object>();
             getSqlServiceMap.put("number",number);
-            getSqlServiceMap.put("filter","  where \"employeeemployeeContract\".FID = '"+id+"'");
+
+            BOSUuid read = BOSUuid.read(id);
+            BOSObjectType type = read.getType();
+            System.out.println(type.toString());
+            if (type.toString().equals("7BD37592")){//id类型为合同
+                getSqlServiceMap.put("filter","  where \"employeeContract\".FID = '"+id+"'");
+            }else  if (type.toString().equals("80EF7DED")){//id类型为员工
+                getSqlServiceMap.put("filter","  where \"person\".FID = '"+id+"'");
+            }else {
+                throw new RuntimeException("传入id非合同id和员工ID");
+            }
             JSONObject jsonObject = new JSONObject();
             jsonObject.put("id",id);
             getSqlServiceMap.put("otherParameters",jsonObject);

+ 22 - 6
websrc/com/kingdee/eas/custom/esign/service/GetESignConfigDataService.java

@@ -22,6 +22,7 @@ import com.kingdee.eas.custom.esign.bizEnum.ComponentTypeEnum;
 import com.kingdee.eas.custom.esign.utils.ESignFieldMappingUtils;
 import com.kingdee.eas.fi.arap.util.DBUtil;
 import com.kingdee.jdbc.rowset.IRowSet;
+import com.kingdee.util.enums.Enum;
 
 import java.sql.SQLException;
 import java.text.SimpleDateFormat;
@@ -91,8 +92,9 @@ public class GetESignConfigDataService implements IHRMsfService {
             String number1 = dataSource.getNumber();
             // 获取当前字段映射信息对应的电子签模板信息
             ESignTemplateInfo eSignFile = fieldMappingInfo.getESignFile();
+            String eSignTemplateNum = eSignFile.getESignTemplateNum();
             if(sqlField.toString().equals("")){
-                JSONObject jsonObject = this.reassembleData(eSignFile, context);
+                JSONObject jsonObject = this.reassembleData(eSignFile, eSignTemplateNum,context);
                 return jsonObject;
             }
             // 通过工具类根据数据源编号和上下文获取电子签基础查询SQL
@@ -102,9 +104,9 @@ public class GetESignConfigDataService implements IHRMsfService {
             // 在SQL末尾添加过滤条件(换行分隔,便于阅读)
             eSignSql += "\n"+filter;
             // 执行SQL查询并将结果封装为JSON对象(包含字段映射关系)
-            JSONObject data = this.getData(eSignSql, context, entrys);
+            JSONObject data = this.getData(eSignSql, context, entrys,eSignTemplateNum);
             // 重新组装电子签模板数据为JSON对象
-            JSONObject jsonObject = this.reassembleData(eSignFile, context);
+            JSONObject jsonObject = this.reassembleData(eSignFile, eSignTemplateNum ,context);
             // 合并查询数据与模板数据,返回合并后的JSON对象
             JSONObject newJSONObject = utils.mergeAgreements(data, jsonObject);
             return newJSONObject;
@@ -112,8 +114,9 @@ public class GetESignConfigDataService implements IHRMsfService {
         }else {
             // 若数据源无效,直接获取电子签模板信息
             ESignTemplateInfo eSignFile = fieldMappingInfo.getESignFile();
+            String eSignTemplateNum = eSignFile.getESignTemplateNum();
             // 重新组装模板数据并返回
-            JSONObject jsonObject = this.reassembleData(eSignFile, context);
+            JSONObject jsonObject = this.reassembleData(eSignFile,eSignTemplateNum, context);
             return jsonObject;
         }
 
@@ -128,7 +131,7 @@ public class GetESignConfigDataService implements IHRMsfService {
      * @param entrys 字段映射明细集合
      * @return 封装后的JSON对象,包含电子签模板各字段信息
      */
-    public JSONObject getData(String sql,Context context,FieldMappingEntryCollection entrys){
+    public JSONObject getData(String sql,Context context,FieldMappingEntryCollection entrys,String eSignTemplateNum){
         // 创建JSON对象用于存储最终封装的数据
         JSONObject jsonObject = new JSONObject();
         try {
@@ -159,6 +162,7 @@ public class GetESignConfigDataService implements IHRMsfService {
                         templateJSON = new JSONObject();
                         templateJSON.put("id",eSignTemplateId); // 设置模板ID
                         templateJSON.put("name",template.getName()); // 设置模板名称
+                        templateJSON.put("eSignTemplateNum",eSignTemplateNum);
                         jsonObject.put(eSignTemplateId,templateJSON); // 将模板信息存入主JSON对象
                     }
                     // 从模板子JSON对象中获取字段信息对应的子JSON对象
@@ -194,6 +198,17 @@ public class GetESignConfigDataService implements IHRMsfService {
                                 value.put("value",simpleDateFormat.format(iRowSet1.getDate(name)));
                             }
                             value.put("dataFormat", eField.getDataFormat());
+                        }else if(dataSourceField.getDataType().getAlias().equals("Enum")){
+                            String dataEntry = dataSourceField.getDataEntry();
+                            if (dataEntry!=null&&!dataEntry.equals("")){
+                                Object enumByValue = com.kingdee.shr.base.syssetting.app.util.MetaDataUtil
+                                        .findEnumByValue(dataEntry, iRowSet1.getObject(name));
+                                if (enumByValue instanceof Enum){
+                                    Enum e =  (Enum) enumByValue;
+                                    value.put("value", e.getAlias());
+                                }
+
+                            }
                         }
                     }
                     if (eField.getComponentType().getValue()==6||eField.getComponentType().getValue()==106){
@@ -253,7 +268,7 @@ public class GetESignConfigDataService implements IHRMsfService {
      * @param context 上下文对象
      * @return 重新组装后的JSON对象(数据可能为null)
      */
-    public JSONObject reassembleData(ESignTemplateInfo eSignFile,Context context){
+    public JSONObject reassembleData(ESignTemplateInfo eSignFile,String eSignTemplateNum,Context context){
         // 获取电子签模板的ID
         BOSUuid id = eSignFile.getId();
         // 声明用于存储组装后数据的JSON对象
@@ -298,6 +313,7 @@ public class GetESignConfigDataService implements IHRMsfService {
                     signTemplate = new JSONObject();
                     signTemplate.put("name",name); // 设置模板名称
                     signTemplate.put("id",eSignTemplateId); // 设置模板ID
+                    signTemplate.put("eSignTemplateNum",eSignTemplateNum);
                     JSONObject fields = new JSONObject(); // 创建字段信息JSON对象
                     signTemplate.put("fields",fields); // 将字段信息存入模板JSON
                     dataJSON.put(eSignTemplateId,signTemplate);

+ 117 - 20
websrc/com/kingdee/eas/custom/esign/service/OnboardingSalaryDataService.java

@@ -1,7 +1,8 @@
 package com.kingdee.eas.custom.esign.service;
 
- 
 
+import com.kingdee.bos.util.BOSObjectType;
+import com.kingdee.bos.util.BOSUuid;
 
 
 /**
@@ -10,11 +11,6 @@ package com.kingdee.eas.custom.esign.service;
  * 202602
  */
 public class OnboardingSalaryDataService extends OtherESignConfigDataService {
-    
-
-    
-    
-    
 	public String getSql(String id) {
     	StringBuilder sql = new StringBuilder();
     	
@@ -35,9 +31,9 @@ public class OnboardingSalaryDataService extends OtherESignConfigDataService {
     	// 4. 试用期绩效奖金(税前)= 试用期标准绩效奖金
     	sql.append("    ISNULL(SUM(CASE WHEN sitem.FNUMBER = 'TD74' THEN fas.FMoney ELSE 0 END), 0) AS prob_perf_bonus ,\n");
     	// 5. 国内餐补 = 餐补补贴
-    	sql.append("    ISNULL(SUM(CASE WHEN sitem.FNUMBER = 'T025' THEN fas.FMoney ELSE 0 END), 0) AS domestic_meal_subsidy ,\n");
+    	sql.append("    ISNULL(SUM(CASE WHEN sitem.FNUMBER = 'T014' THEN fas.FMoney ELSE 0 END), 0) AS domestic_meal_subsidy ,\n");
     	// 6. 艰苦补贴 = 艰苦补贴
-    	sql.append("    ISNULL(SUM(CASE WHEN sitem.FNUMBER = 'T038' THEN fas.FMoney ELSE 0 END), 0) AS hardship_subsidy ,\n");
+    	sql.append("    ISNULL(SUM(CASE WHEN sitem.FNUMBER = 'TD05' THEN fas.FMoney ELSE 0 END), 0) AS hardship_subsidy ,\n");
     	// 7. 社保公积金补贴 = 社保公积金补贴
     	sql.append("    ISNULL(SUM(CASE WHEN sitem.FNUMBER = 'TD101' THEN fas.FMoney ELSE 0 END), 0) AS social_fund \n");
     	
@@ -56,19 +52,18 @@ public class OnboardingSalaryDataService extends OtherESignConfigDataService {
     	sql.append("LEFT JOIN T_HR_EmployeeContract econtract on econtract.FEmployeeID = person.FID\n");
     	sql.append("LEFT JOIN T_HR_LabContractFirstParty firstParty on econtract.FContFirstPartyID = firstParty.FID \n");
     	
-    	// -------------------------- WHERE子句 --------------------------
-    	// 过滤条件:
-    	// 1. 薪资项目编码仅包含指定项(固定工资、绩效、补贴等)
-    	// 2. 薪资生效日期为2199-12-31(永久生效)
-    	// 3. 可选条件:按人员ID过滤(启用时删除注释,注意数据库注释用--)
+ 
     	sql.append("WHERE \n");
-    	sql.append("    sitem.FNUMBER IN ('TD01', 'T012', 'T013', 'TD02', 'TD04', 'TD74', 'T025', 'T038', 'TD101') \n");
+    	sql.append("    sitem.FNUMBER IN ('TD01', 'T012', 'T013', 'TD02', 'TD04', 'TD74', 'T014', 'TD05', 'TD101') \n");
     	sql.append("    and fas.FLeffectDay = '2199-12-31 00:00:00' \n");
-    	// 数据库兼容的注释:-- 开头,嵌入SQL内不会报错(如需启用可删除前面的//)
-    	// sql.append("    -- and person.fid = 'X+0AAACrsleA733t' \n");
-    	sql.append("and  person.fid  in (select FEmployeeID from T_HR_EmployeeContract where fid = '"+id+"')  ") ;
-    	// -------------------------- GROUP BY子句 --------------------------
-    	// 分组逻辑:按人员唯一标识+基础信息分组,保证聚合函数(SUM)结果正确
+        
+        BOSUuid read = BOSUuid.read(id);
+        BOSObjectType type = read.getType();
+    	 if (type.toString().equals("7BD37592")){//id类型为合同
+         	sql.append("and  person.fid  in (select FEmployeeID from T_HR_EmployeeContract where fid = '"+id+"')" ) ;
+         }else  if (type.toString().equals("80EF7DED")){//id类型为员工felse
+         	sql.append("and person.fid = '"+id+"'");
+         }
     	sql.append("GROUP BY \n");
     	sql.append("    person.FID, person.FNAME_L2 , elation.FEnterDate , person.FIDCardNO , firstParty.FName_l2 \n");
     	
@@ -80,7 +75,109 @@ public class OnboardingSalaryDataService extends OtherESignConfigDataService {
     	System.out.print("osfsql"+sql.toString());
     	return sql.toString();
     }
- 
+//	/**
+//     * 执行SQL查询并将结果封装为JSON对象
+//     *
+//     * @param sql     要执行的查询SQL
+//     * @param context 上下文对象
+//     * @param entrys  字段映射明细集合
+//     * @return 封装后的JSON对象,包含电子签模板各字段信息
+//     */
+//    public JSONObject getData(String sql, Context context, FieldMappingEntryCollection entrys) {
+//        // 创建JSON对象用于存储最终封装的数据
+//        JSONObject jsonObject = new JSONObject();
+//        try {
+//            // 执行SQL查询,获取结果集
+//            IRowSet iRowSet1 = DBUtil.executeQuery(context, sql);
+//            // 遍历结果集中的每一行数据
+//				while (iRowSet1.next()) {
+//				    // 遍历每个字段映射明细项
+//				    for (int i = 0; i < entrys.size(); i++) {
+//				        // 获取当前索引对应的字段映射明细信息
+//				        FieldMappingEntryInfo fieldMappingEntryInfo = entrys.get(i);
+//				        // 获取明细项中关联的电子签模板字段信息
+//				        ESignTemplateFileEntryFieldInfo eField = fieldMappingEntryInfo.getEField();
+//				        // 判断该字段是否无效(已废弃)
+//				        boolean invalid = eField.isInvalid();
+//				        // 若字段无效,跳过当前循环(不处理)
+//				        if (invalid) {
+//				            continue;
+//				        }
+//				        // 获取明细项中关联的电子签模板明细信息
+//				        ESignTemplateFileEntryInfo template = fieldMappingEntryInfo.getTemplate();
+//				        // 获取电子签模板的ID
+//				        String eSignTemplateId = template.getESignTemplateId();
+//				        // 从JSON对象中获取该模板ID对应的子JSON对象
+//				        JSONObject templateJSON = jsonObject.getJSONObject(eSignTemplateId);
+//				        // 若模板对应的子JSON对象不存在,则创建并初始化(设置ID和名称)
+//				        if (templateJSON == null) {
+//				            templateJSON = new JSONObject();
+//				            templateJSON.put("id", eSignTemplateId); // 设置模板ID
+//				            templateJSON.put("name", template.getName()); // 设置模板名称
+//				            jsonObject.put(eSignTemplateId, templateJSON); // 将模板信息存入主JSON对象
+//				        }
+//				        // 从模板子JSON对象中获取字段信息对应的子JSON对象
+//				        JSONObject fields = templateJSON.getJSONObject("fields");
+//				        // 若字段信息子JSON对象不存在,则创建并添加到模板子JSON中
+//				        if (fields == null) {
+//				            fields = new JSONObject();
+//				            templateJSON.put("fields", fields);
+//				        }
+//				        // 获取电子签模板字段的ID
+//				        String templateFieldId = eField.getTemplateFieldId();
+//				        // 创建用于存储字段值信息的JSON对象
+//				        JSONObject value = new JSONObject();
+//				        value.put("name", eField.getTemplateFieldName()); // 设置字段名称
+//				        // 获取明细项中关联的数据源字段信息
+//				        //DataConfigSelectFieldEntryInfo dataSourceField = fieldMappingEntryInfo.getDataSourceField();
+////                    if (dataSourceField==null){
+////                        value.put("value","");
+////                        value.put("dataFormat", eField.getDataFormat());
+////                    }else {
+//				        // 获取数据源字段的映射键(对应数据库列名)
+//				        String name = fieldMappingEntryInfo.getEFieldMark();
+//				        // 去除映射键中的双引号(处理可能的格式问题)
+//				        //name = name.replace("\"", "");
+//				        // 从结果集中获取该字段对应的值,并存入字段值JSON对象
+//				        if (name != null && !name.equals("")) {
+//				            try {
+//								value.put("value", iRowSet1.getObject(name));
+//							} catch (SQLException e) {
+//								e.printStackTrace();
+//							}
+//				        }
+//				        // 设置字段的数据类型(取自数据源字段的类型别名)
+//				        //value.put("dataType", dataSourceField.getDataType().getAlias());
+////                    if (dataSourceField.getDataType().getAlias().equals("Date")) {
+////                        Object object = iRowSet1.getObject(name);
+////                        if (object != null) {
+////                            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日");
+////                            value.put("value", simpleDateFormat.format(iRowSet1.getDate(name)));
+////                        }
+////                        value.put("dataFormat", eField.getDataFormat());
+////                    }
+//				        //}
+//				        if (eField.getComponentType().getValue() == 6 || eField.getComponentType().getValue() == 106) {
+//				            value.put("positionX", eField.getPositionX());
+//				            value.put("positionY", eField.getPositionY());
+//				            value.put("pageNum", eField.getPageNum());
+//				        }
+//				        // 将字段值信息存入字段信息子JSON对象(以模板字段ID为键)
+//				        fields.put(templateFieldId, value);
+//				    }
+//				}
+//
+//
+//        } catch (BOSException e) {
+//            // BOS异常时,封装为运行时异常抛出
+//            throw new RuntimeException(e);
+//        } catch (SQLException e) {
+//            // SQL异常时,封装为运行时异常抛出
+//            throw new RuntimeException(e);
+//        }
+//        // 返回封装好的JSON对象
+//        return jsonObject;
+//    }
 
      
 }

+ 84 - 76
websrc/com/kingdee/eas/custom/esign/service/OtherESignConfigDataService.java

@@ -10,6 +10,7 @@ import com.kingdee.bos.metadata.entity.FilterItemInfo;
 import com.kingdee.bos.metadata.entity.SelectorItemCollection;
 import com.kingdee.bos.metadata.query.util.CompareType;
 import com.kingdee.bos.sql.ParserException;
+import com.kingdee.bos.util.BOSObjectType;
 import com.kingdee.bos.util.BOSUuid;
 import com.kingdee.eas.common.EASBizException;
 import com.kingdee.eas.custom.dataconfig.utils.SqlUtils;
@@ -26,12 +27,7 @@ import java.sql.SQLException;
 import java.text.SimpleDateFormat;
 import java.util.Map;
 
-import org.apache.log4j.Logger;
-
 public class OtherESignConfigDataService implements IHRMsfService {
-	
-	private static Logger logger = Logger.getLogger(OtherESignConfigDataService.class);
-	
     @Override
     public Object process(Context context, Map map) throws EASBizException, BOSException {
         // 从参数映射中获取"number"参数值,用于定位配置信息
@@ -93,9 +89,10 @@ public class OtherESignConfigDataService implements IHRMsfService {
         // 在SQL末尾添加过滤条件(换行分隔,便于阅读)
         //eSignSql += "\n"+filter;
         // 执行SQL查询并将结果封装为JSON对象(包含字段映射关系)
-        JSONObject data = this.getData(getSql(filter), context, entrys);
+        String eSignTemplateNum = eSignFile.getESignTemplateNum();
+        JSONObject data = this.getData(getSql(filter), context, entrys,eSignTemplateNum);
         // 重新组装电子签模板数据为JSON对象
-        JSONObject jsonObject = this.reassembleData(eSignFile, context);
+        JSONObject jsonObject = this.reassembleData(eSignFile,eSignTemplateNum, context);
         // 合并查询数据与模板数据,返回合并后的JSON对象
         JSONObject newJSONObject = utils.mergeAgreements(data, jsonObject);
         return newJSONObject;
@@ -139,7 +136,14 @@ public class OtherESignConfigDataService implements IHRMsfService {
         sql.append("T_HR_SCmpItem sitem ON fas.FCmpItemID = sitem.FID").append("\n");
         sql.append("WHERE").append("\n");
         sql.append("sitem.FNUMBER IN ('TD01', 'T012', 'T013', 'TD02', 'TD04', 'TD74', 'T025', 'T038', 'TD101')").append("\n");
-        sql.append("and  person.fid  in (select FEmployeeID from T_HR_EmployeeContract where fid = '"+id+"')").append("\n");
+        BOSUuid read = BOSUuid.read(id);
+        BOSObjectType type = read.getType();
+        System.out.println(type.toString());
+        if (type.toString().equals("7BD37592")){//id类型为合同
+            sql.append("and  person.fid  in (select FEmployeeID from T_HR_EmployeeContract where fid = '"+id+"')").append("\n");
+        }else  if (type.toString().equals("80EF7DED")){//id类型为员工
+            sql.append("and  person.fid  = '"+id+"'").append("\n");
+        }
         sql.append(" GROUP BY").append("\n");
         sql.append("person.FID, person.FNAME_L2  , elation.FEnterDate").append("\n");
         sql.append("ORDER BY").append("\n");
@@ -155,71 +159,75 @@ public class OtherESignConfigDataService implements IHRMsfService {
      * @param entrys  字段映射明细集合
      * @return 封装后的JSON对象,包含电子签模板各字段信息
      */
-    public JSONObject getData(String sql, Context context, FieldMappingEntryCollection entrys) {
+    public JSONObject getData(String sql, Context context, FieldMappingEntryCollection entrys,String eSignTemplateNum) {
         // 创建JSON对象用于存储最终封装的数据
         JSONObject jsonObject = new JSONObject();
         try {
             // 执行SQL查询,获取结果集
             IRowSet iRowSet1 = DBUtil.executeQuery(context, sql);
             // 遍历结果集中的每一行数据
-				while (iRowSet1.next()) {
-				    // 遍历每个字段映射明细项
-				    for (int i = 0; i < entrys.size(); i++) {
-				        // 获取当前索引对应的字段映射明细信息
-				        FieldMappingEntryInfo fieldMappingEntryInfo = entrys.get(i);
-				        // 获取明细项中关联的电子签模板字段信息
-				        ESignTemplateFileEntryFieldInfo eField = fieldMappingEntryInfo.getEField();
-				        // 判断该字段是否无效(已废弃)
-				        boolean invalid = eField.isInvalid();
-				        // 若字段无效,跳过当前循环(不处理)
-				        if (invalid) {
-				            continue;
-				        }
-				        // 获取明细项中关联的电子签模板明细信息
-				        ESignTemplateFileEntryInfo template = fieldMappingEntryInfo.getTemplate();
-				        // 获取电子签模板的ID
-				        String eSignTemplateId = template.getESignTemplateId();
-				        // 从JSON对象中获取该模板ID对应的子JSON对象
-				        JSONObject templateJSON = jsonObject.getJSONObject(eSignTemplateId);
-				        // 若模板对应的子JSON对象不存在,则创建并初始化(设置ID和名称)
-				        if (templateJSON == null) {
-				            templateJSON = new JSONObject();
-				            templateJSON.put("id", eSignTemplateId); // 设置模板ID
-				            templateJSON.put("name", template.getName()); // 设置模板名称
-				            jsonObject.put(eSignTemplateId, templateJSON); // 将模板信息存入主JSON对象
-				        }
-				        // 从模板子JSON对象中获取字段信息对应的子JSON对象
-				        JSONObject fields = templateJSON.getJSONObject("fields");
-				        // 若字段信息子JSON对象不存在,则创建并添加到模板子JSON中
-				        if (fields == null) {
-				            fields = new JSONObject();
-				            templateJSON.put("fields", fields);
-				        }
-				        // 获取电子签模板字段的ID
-				        String templateFieldId = eField.getTemplateFieldId();
-				        // 创建用于存储字段值信息的JSON对象
-				        JSONObject value = new JSONObject();
-				        value.put("name", eField.getTemplateFieldName()); // 设置字段名称
-				        // 获取明细项中关联的数据源字段信息
-				        //DataConfigSelectFieldEntryInfo dataSourceField = fieldMappingEntryInfo.getDataSourceField();
+            while (iRowSet1.next()) {
+                // 遍历每个字段映射明细项
+                for (int i = 0; i < entrys.size(); i++) {
+                    // 获取当前索引对应的字段映射明细信息
+                    FieldMappingEntryInfo fieldMappingEntryInfo = entrys.get(i);
+                    // 获取明细项中关联的电子签模板字段信息
+                    ESignTemplateFileEntryFieldInfo eField = fieldMappingEntryInfo.getEField();
+                    // 判断该字段是否无效(已废弃)
+                    boolean invalid = eField.isInvalid();
+                    // 若字段无效,跳过当前循环(不处理)
+                    if (invalid) {
+                        continue;
+                    }
+                    // 获取明细项中关联的电子签模板明细信息
+                    ESignTemplateFileEntryInfo template = fieldMappingEntryInfo.getTemplate();
+                    // 获取电子签模板的ID
+                    String eSignTemplateId = template.getESignTemplateId();
+                    // 从JSON对象中获取该模板ID对应的子JSON对象
+                    JSONObject templateJSON = jsonObject.getJSONObject(eSignTemplateId);
+                    // 若模板对应的子JSON对象不存在,则创建并初始化(设置ID和名称)
+                    if (templateJSON == null) {
+                        templateJSON = new JSONObject();
+                        templateJSON.put("id", eSignTemplateId); // 设置模板ID
+                        templateJSON.put("name", template.getName()); // 设置模板名称
+                        templateJSON.put("eSignTemplateNum",eSignTemplateNum);
+                        jsonObject.put(eSignTemplateId, templateJSON); // 将模板信息存入主JSON对象
+                    }
+                    // 从模板子JSON对象中获取字段信息对应的子JSON对象
+                    JSONObject fields = templateJSON.getJSONObject("fields");
+                    // 若字段信息子JSON对象不存在,则创建并添加到模板子JSON中
+                    if (fields == null) {
+                        fields = new JSONObject();
+                        templateJSON.put("fields", fields);
+                    }
+                    // 获取电子签模板字段的ID
+                    String templateFieldId = eField.getTemplateFieldId();
+                    // 创建用于存储字段值信息的JSON对象
+                    JSONObject value = new JSONObject();
+                    value.put("name", eField.getTemplateFieldName()); // 设置字段名称
+                    // 获取明细项中关联的数据源字段信息
+                    //DataConfigSelectFieldEntryInfo dataSourceField = fieldMappingEntryInfo.getDataSourceField();
 //                    if (dataSourceField==null){
 //                        value.put("value","");
 //                        value.put("dataFormat", eField.getDataFormat());
 //                    }else {
-				        // 获取数据源字段的映射键(对应数据库列名)
-				        String name = fieldMappingEntryInfo.getEFieldMark();
-				        // 去除映射键中的双引号(处理可能的格式问题)
-				        //name = name.replace("\"", "");
-				        // 从结果集中获取该字段对应的值,并存入字段值JSON对象
-				        if (name != null && !name.equals("")) {
-				            try {
-								value.put("value", iRowSet1.getObject(name));
-							} catch (SQLException e) {
-								e.printStackTrace();
-							}
-				        }
-				        // 设置字段的数据类型(取自数据源字段的类型别名)
-				        //value.put("dataType", dataSourceField.getDataType().getAlias());
+                    // 获取数据源字段的映射键(对应数据库列名)
+                    String name = fieldMappingEntryInfo.getEFieldMark();
+                    // 去除映射键中的双引号(处理可能的格式问题)
+                    //name = name.replace("\"", "");
+                    // 从结果集中获取该字段对应的值,并存入字段值JSON对象
+                    if (name != null && !name.equals("")) {
+                        Object object = null;
+                        try {
+                            object= iRowSet1.getObject(name);
+                        }catch (Exception e){
+                            object= null;
+                        }
+
+                        value.put("value",object);
+                    }
+                    // 设置字段的数据类型(取自数据源字段的类型别名)
+                    //value.put("dataType", dataSourceField.getDataType().getAlias());
 //                    if (dataSourceField.getDataType().getAlias().equals("Date")) {
 //                        Object object = iRowSet1.getObject(name);
 //                        if (object != null) {
@@ -228,17 +236,16 @@ public class OtherESignConfigDataService implements IHRMsfService {
 //                        }
 //                        value.put("dataFormat", eField.getDataFormat());
 //                    }
-				        //}
-				        if (eField.getComponentType().getValue() == 6 || eField.getComponentType().getValue() == 106) {
-				            value.put("positionX", eField.getPositionX());
-				            value.put("positionY", eField.getPositionY());
-				            value.put("pageNum", eField.getPageNum());
-				        }
-				        // 将字段值信息存入字段信息子JSON对象(以模板字段ID为键)
-				        fields.put(templateFieldId, value);
-				    }
-				}
-		 
+                    //}
+                    if (eField.getComponentType().getValue() == 6 || eField.getComponentType().getValue() == 106) {
+                        value.put("positionX", eField.getPositionX());
+                        value.put("positionY", eField.getPositionY());
+                        value.put("pageNum", eField.getPageNum());
+                    }
+                    // 将字段值信息存入字段信息子JSON对象(以模板字段ID为键)
+                    fields.put(templateFieldId, value);
+                }
+            }
 
         } catch (BOSException e) {
             // BOS异常时,封装为运行时异常抛出
@@ -246,7 +253,7 @@ public class OtherESignConfigDataService implements IHRMsfService {
         } catch (SQLException e) {
             // SQL异常时,封装为运行时异常抛出
             throw new RuntimeException(e);
-        }  
+        }
         // 返回封装好的JSON对象
         return jsonObject;
     }
@@ -289,7 +296,7 @@ public class OtherESignConfigDataService implements IHRMsfService {
      * @param context   上下文对象
      * @return 重新组装后的JSON对象(数据可能为null)
      */
-    public JSONObject reassembleData(ESignTemplateInfo eSignFile, Context context) {
+    public JSONObject reassembleData(ESignTemplateInfo eSignFile,String eSignTemplateNum, Context context) {
         // 获取电子签模板的ID
         BOSUuid id = eSignFile.getId();
         // 声明用于存储组装后数据的JSON对象
@@ -334,6 +341,7 @@ public class OtherESignConfigDataService implements IHRMsfService {
                     signTemplate = new JSONObject();
                     signTemplate.put("name", name); // 设置模板名称
                     signTemplate.put("id", eSignTemplateId); // 设置模板ID
+                    signTemplate.put("eSignTemplateNum",eSignTemplateNum);
                     JSONObject fields = new JSONObject(); // 创建字段信息JSON对象
                     signTemplate.put("fields", fields); // 将字段信息存入模板JSON
                     dataJSON.put(eSignTemplateId, signTemplate);