Explorar o código

1. 报表,审批人选择,审批流程变更时,提示用户
2. 报表,审批人选择,未选择审批人时,提示用户

MaiXinRong %!s(int64=5) %!d(string=hai) anos
pai
achega
1fa82bca8b
Modificáronse 2 ficheiros con 36 adicións e 7 borrados
  1. 34 7
      app/public/report/js/rpt_custom.js
  2. 2 0
      app/view/report/rpt_all_popup.ejs

+ 34 - 7
app/public/report/js/rpt_custom.js

@@ -9,20 +9,33 @@
  */
 
 const rptCustomObj = (function () {
-
     const sAuditSelect = 'audit_select';
     let stageFlow = [];
 
-    const getStageFlowSelectHtml = function (select) {
+    const getStageFlowSelectHtml = function (select, id) {
         const html = [];
-        html.push('<select style="width: 80%">');
+        html.push('<select style="width: 80%" id="' + id + '" sf-title="' + select.title + '">');
         for (const sf of stageFlow) {
-            html.push('<option' + (select && sf.order === select.order ? ' selected' : '') + '>' + sf.name + '-' + sf.role +'</option>');
+            html.push('<option>' + sf.name + '-' + sf.role +'</option>');
         }
         html.push('</select>');
         return html.join('');
     };
 
+    const checkAsSelectValid = function (validFlow, asSelect) {
+        for (const s of asSelect) {
+            const f = validFlow.find(function (x) {
+                return x.aid === s.aid && x.order === s.order;
+            });
+            if (!f) {
+                $('#audit-select-hint').html('本期审批流程发生变动,原审批人选择不适配,需重新选择').show();
+                return false;
+            }
+        }
+        $('#audit-select-hint').hide();
+        return true;
+    };
+
     const initAuditSelect = function (asSetting, asSelect) {
         const setting = JSON.parse(asSetting), select = asSelect;
         $('#audit-select-title').html(setting.title);
@@ -30,11 +43,19 @@ const rptCustomObj = (function () {
         for (const [i, s] of setting.select.entries()) {
             html.push('<tr>');
             html.push('<td>', s.title, '</td>');
-            html.push('<td>', getStageFlowSelectHtml(select[i]), '</td>');
+            html.push('<td>', getStageFlowSelectHtml(s, 'sf-' + i), '</td>');
             html.push('</tr>');
         }
         $('#audit-select-list').html(html.join(''));
-        if (asSelect.length === 0) {
+        for (const [i, s] of setting.select.entries()) {
+            const obj = $('#sf-' + i);
+            const s = select[i];
+            const sf = s ? stageFlow.find(function (x) {
+                return x.order === s.order && x.aid === s.aid;
+            }) : null;
+            obj[0].selectedIndex = sf ? sf.order : -1;
+        }
+        if (asSelect.length === 0 || !checkAsSelectValid(stageFlow, asSelect)) {
             $('#audit-select').modal('show');
         }
     };
@@ -121,8 +142,14 @@ const rptCustomObj = (function () {
         data.stage_order = getStageOrder();
         data.stage_times = getStageTimes();
         for (const s of selObj) {
-            data.audit_select.push(stageFlow[s.selectedIndex]);
+            const sf = stageFlow[s.selectedIndex];
+            if (!sf) {
+                $('#audit-select-hint').html('未选择' + s.attributes['sf-title'].value).show();
+                return;
+            }
+            data.audit_select.push(sf);
         }
+        $('#audit-select-hint').hide();
         postData('/report/cDefine', data, function (result) {
             reloadReportData(result);
             $('#audit-select').modal('hide');

+ 2 - 0
app/view/report/rpt_all_popup.ejs

@@ -259,6 +259,8 @@
                     <tbody id="audit-select-list">
                     </tbody>
                 </table>
+                <div id="audit-select-hint" class="text-danger">
+                </div>
             </div>
             <div class="modal-footer">
                 <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>