|
@@ -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');
|