Browse Source

电子签名日期交互

TonyKang 5 years ago
parent
commit
80ea8a453b

+ 56 - 3
app/public/report/js/rpt_signature.js

@@ -161,7 +161,8 @@ let rptSignatureHelper = {
                 elementsStrArr.push('<li class="list-group-item">');
                 if (sCell.path || sCell.pic) {
                     let hasPic = false;
-                    for (const role_rel of ROLE_REL_LIST) {
+                    for (let idx = 0; idx < ROLE_REL_LIST.length; idx++) {
+                        const role_rel = ROLE_REL_LIST[idx];
                         if (role_rel.signature_name === sCell.signature_name) {
                             if (role_rel.type === '用户') {
                                 rptSignatureHelper.pushDomElementByUser(elementsStrArr, role_rel.user_name, role_rel.role);
@@ -169,6 +170,8 @@ let rptSignatureHelper = {
                                 //角色
                                 rptSignatureHelper.pushDomElementByRole(elementsStrArr, role_rel.role_name, role_rel.user_name);
                             }
+                            const idSuffixStr = 'dtp_' + idx;
+                            /*
                             elementsStrArr.push('<div class="dropdown">');
                             if (role_rel.sign_date !== '') {
                                 //elementsStrArr.push('<a href="" data-toggle="dropdown">' + (new Date(role_rel.sign_date)).Format('yyyy-M-d') + '</a>');
@@ -181,9 +184,9 @@ let rptSignatureHelper = {
                             elementsStrArr.push('<label for="exampleDropdownFormEmail2">签名日期</label>');
                             if (role_rel.sign_date !== '') {
                                 //elementsStrArr.push('<input class="datepicker-here form-control form-control-sm mt-0" placeholder="选择签名日期" data-language="zh" type="text" value="' + (new Date(role_rel.sign_date)).Format('yyyy-M-d') + '">');
-                                elementsStrArr.push('<input class="datepicker-here form-control form-control-sm mt-0" placeholder="选择签名日期" data-language="zh" type="text">');
+                                elementsStrArr.push('<input id="' + idSuffixStr + '" class="datepicker-here form-control form-control-sm mt-0" placeholder="选择签名日期" data-language="zh" type="text">');
                             } else {
-                                elementsStrArr.push('<input class="datepicker-here form-control form-control-sm mt-0" placeholder="选择签名日期" data-language="zh" type="text">');
+                                elementsStrArr.push('<input id="' + idSuffixStr + '" class="datepicker-here form-control form-control-sm mt-0" placeholder="选择签名日期" data-language="zh" type="text">');
                             }
                             elementsStrArr.push('</div>');
                             if (role_rel.sign_date !== '') {
@@ -194,6 +197,19 @@ let rptSignatureHelper = {
                             }
                             elementsStrArr.push('</form>');
                             elementsStrArr.push('</div>');
+                            /*/
+                            elementsStrArr.push('<div class="">');
+                            if (role_rel.sign_date !== '') {
+                                const dt = new Date(role_rel.sign_date);
+                                const dtVal = dt.Format('yyyy-M-dd');
+                                //elementsStrArr.push('<input class="datepicker-here form-control form-control-sm mt-0" placeholder="选择签名日期" data-language="zh" type="text" value="' + (new Date(role_rel.sign_date)).Format('yyyy-M-d') + '">');
+                                elementsStrArr.push('<input id="' + idSuffixStr + '" class="datepicker-here form-control form-control-sm mt-0" placeholder="选择签名日期" data-language="zh" type="text" readonly="true" value="' + dtVal + '"');
+                            } else {
+                                elementsStrArr.push('<input id="' + idSuffixStr + '" class="datepicker-here form-control form-control-sm mt-0" placeholder="选择签名日期" data-language="zh" type="text" readonly="true"');
+                            }
+                            elementsStrArr.push('</div>');
+                            //*/
+
                             hasPic = true;
                             break;
                         }
@@ -257,7 +273,44 @@ let rptSignatureHelper = {
         ROLE_REL_LIST = ROLE_REL_LIST.concat(rptSignatureHelper.originalRoleRelList);
         zTreeOprObj.showPage(zTreeOprObj.currentPage, zTreeOprObj.canvas);
     },
+    resetSignDate: function() {
+        for (let idx = 0; idx < ROLE_REL_LIST.length; idx++) {
+            const role_rel = ROLE_REL_LIST[idx];
+            const idSuffixStr = 'dtp_' + idx;
+            let dtDom = $('#' + idSuffixStr);
+            if (dtDom.length === 1) {
+                const dtStr = dtDom[0].value;
+                if (dtStr && dtStr !== '' && dtStr.length === 10) {
+                    const year = parseInt(dtStr.slice(0, 4));
+                    const month = parseInt(dtStr.slice(5, 7)) - 1;
+                    const dt = parseInt(dtStr.slice(8, 10));
+                    role_rel.sign_date = new Date(year, month, dt);
+                } else {
+                    role_rel.sign_date = '';
+                }
+                // 要处理相关签名Cell属性(默认跟普通cell一样,就多了个signature_name)
+                for (const page of zTreeOprObj.currentRptPageRst.items) {
+                    if (page.signature_date_cells) {
+                        for (const sCell of page.signature_date_cells) {
+                            if (sCell.signature_name === role_rel.signature_name + '_签字日期') {
+                                if (role_rel.sign_date !== '') {
+                                    sCell.Value = role_rel.sign_date.Format(role_rel.sign_date_format);
+                                } else {
+                                    sCell.Value = '';
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        // 还有ROLE_REL_LIST
+        // rptSignatureHelper.cleanOldSignature(accTxtName);
+
+    },
     setupAfterSelectSignature: function () {
+        //0. 签名日期
+        rptSignatureHelper.resetSignDate();
         //1. 重刷page
         for (const page of zTreeOprObj.currentRptPageRst.items) {
             if (page.signature_cells) {

+ 1 - 0
app/reports/rpt_component/helper/jpc_helper_discrete.js

@@ -42,6 +42,7 @@ const JpcDiscreteHelper = {
                                 if (Array.isArray(signatureDateRst)) {
                                     const param = JE.P(df[JV.PROP_PARAM_ID], $CURRENT_RPT);
                                     const signatureDateItem = JpcCommonOutputHelper.createCommonOutputWithoutDecorate(df, param[JV.PROP_DFT_VALUE], true);
+                                    signatureDateItem.signature_name = param[JV.PROP_NAME];
                                     signatureDateRst.push(signatureDateItem);
                                 }
                             } else {