| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- function changeModule($target, type = 'single')
- {
- const name = $target.attr('name');
- if($target.prop('checked'))
- {
- $("input[type=hidden][name='" + name + "']").val('1').attr('disabled');
- if(type == 'single') checkRelated(name, 'open');
- }
- else
- {
- $("input[type=hidden][name='" + name + "']").val('1').attr('disabled');
- $("input[type=hidden][name='" + name + "']").val('0').removeAttr('disabled');
- if(type == 'single') checkRelated(name, 'close');
- }
- };
- function checkModule(event)
- {
- changeModule($(event.target));
- }
- function checkGroup()
- {
- const checked = $(this).prop('checked');
- $(this).closest('tr').find("div:not(.hidden) > input[type=checkbox][name^='module']").each(function()
- {
- const name = $(this).attr('name');
- $(this).prop('checked', checked);
- $(`input[type=hidden][name='${name}']`).val(checked ? '1' : '0');
- });
- };
- function checkAll()
- {
- const checked = $(this).prop('checked');
- $('input[type=checkbox][name^=allChecker]').prop('checked', checked);
- $(this).closest('table').find("div:not(.hidden) > input[type=checkbox][name^='module']").each(function()
- {
- $(this).prop('checked', checked);
- changeModule($(this), 'all');
- });
- };
- window.submitForm = function()
- {
- const isCheckedUR = $('[name="module[productUR]"]').prop('checked');
- const isCheckedER = $('[name="module[productER]"]').prop('checked');
- let message = confirmDisableStoryType;
- let storyType = '';
- if(edition != 'ipd' && URAndSR && !isCheckedUR)
- {
- storyType += URCommon;
- }
- if(enableER && !isCheckedER)
- {
- if(storyType) storyType += ',';
- storyType += ERCommon;
- }
- if(storyType)
- {
- zui.Modal.confirm(
- {
- message: message.replace(/{type}/g, storyType),
- icon: 'icon-exclamation-sign',
- iconClass: 'warning-pale rounded-full icon-2x'
- }).then((res) =>
- {
- if(res)
- {
- realSubmitForm();
- return false;
- }
- setModuleState('productUR', true);
- setModuleState('productER', true);
- });
- return false;
- }
- realSubmitForm();
- return false;
- }
- window.realSubmitForm = function()
- {
- const formData = new FormData($('#setModuleForm form')[0]);
- const url = $.createLink('admin', 'setmodule');
- $.ajaxSubmit({url: url, data: formData});
- }
- /**
- * 设置模块的checkbox和hidden input状态
- * @param {string} moduleName - 模块名称(如 'productUR', 'productER')
- * @param {boolean} checked - 是否选中
- */
- function setModuleState(moduleName, checked)
- {
- const checkboxSelector = `[name="module[${moduleName}]"]`;
- const hiddenSelector = `#module${moduleName}[type=hidden]`;
- $(checkboxSelector).prop('checked', checked);
- $(hiddenSelector).val(checked ? '1' : '0');
- }
- /**
- * 检查模块是否已启用
- * @param {string} moduleName - 模块名称
- * @returns {boolean} 是否已启用
- */
- function isModuleEnabled(moduleName)
- {
- return $('[name="module[' + moduleName + ']"]').prop('checked');
- }
- /**
- * 显示依赖关系确认对话框
- * @param {string} message - 确认消息
- * @param {Function} onConfirm - 确认回调
- * @param {Function} onCancel - 取消回调
- */
- function showDependencyConfirm(message, onConfirm, onCancel)
- {
- zui.Modal.confirm(
- {
- message: message,
- icon: 'icon-exclamation-sign',
- iconClass: 'warning-pale rounded-full icon-2x'
- }).then((res) =>
- {
- if(res)
- {
- if(onConfirm) onConfirm();
- return false;
- }
- if(onCancel) onCancel();
- });
- }
- window.checkRelated = function(name, type)
- {
- if(type === 'open')
- {
- // 开启 业务需求 时,需要确保 用户需求 已开启
- if(name.includes('productER') && edition !== 'ipd')
- {
- if(!isModuleEnabled('productUR'))
- {
- const message = openDependFeature.replace('{source}', ERCommon).replace('{target}', URCommon);
- showDependencyConfirm(
- message,
- () => setModuleState('productUR', true),
- () => setModuleState('productER', false)
- );
- return false;
- }
- }
- // 开启 项目变更 时,需要确保 交付物 已开启
- else if(name.includes('projectCm'))
- {
- if(!isModuleEnabled('projectDeliverable'))
- {
- const message = openDependFeature.replace('{source}', cmLang).replace('{target}', deliverableLang);
- showDependencyConfirm(
- message,
- () => setModuleState('projectDeliverable', true),
- () => setModuleState('projectCm', false)
- );
- return false;
- }
- }
- // 开启 项目变更 时,需要确保 交付物 和 基线 都已开启
- else if(name.includes('projectChange'))
- {
- const deliverableEnabled = isModuleEnabled('projectDeliverable');
- const cmEnabled = isModuleEnabled('projectCm');
- if(!deliverableEnabled || !cmEnabled)
- {
- let message = openDependFeature.replace('{source}', changeLang);
- const missingLangs = [];
- if(!deliverableEnabled) missingLangs.push(deliverableLang);
- if(!cmEnabled) missingLangs.push(cmLang);
- message = message.replace('{target}', missingLangs.join(','));
- showDependencyConfirm(
- message,
- () =>
- {
- if(!deliverableEnabled) setModuleState('projectDeliverable', true);
- if(!cmEnabled) setModuleState('projectCm', true);
- },
- () => setModuleState('projectChange', false)
- );
- return false;
- }
- }
- }
- else
- {
- // 关闭 用户需求 时,如果 业务需求 已开启,需要提示关闭 业务需求
- if(name.includes('productUR') && edition !== 'ipd')
- {
- if(isModuleEnabled('productER'))
- {
- const message = closeDependFeature.replace('{source}', URCommon).replace('{target}', ERCommon);
- showDependencyConfirm(
- message,
- () => setModuleState('productER', false),
- () =>
- {
- setModuleState('productUR', true);
- setModuleState('productER', true);
- }
- );
- return false;
- }
- }
- // 关闭 交付物 时,如果 项目变更 或 基线 已开启,需要提示关闭它们
- else if(name.includes('projectDeliverable'))
- {
- const changeEnabled = isModuleEnabled('projectChange');
- const cmEnabled = isModuleEnabled('projectCm');
- if(changeEnabled || cmEnabled)
- {
- let message = closeDependFeature.replace('{source}', deliverableLang);
- const activeLangs = [];
- if(changeEnabled) activeLangs.push(changeLang);
- if(cmEnabled) activeLangs.push(cmLang);
- message = message.replace('{target}', activeLangs.join(','));
- showDependencyConfirm(
- message,
- () =>
- {
- if(changeEnabled) setModuleState('projectChange', false);
- if(cmEnabled) setModuleState('projectCm', false);
- },
- () => setModuleState('projectDeliverable', true)
- );
- }
- }
- // 关闭 基线 时,如果 项目变更 已开启,需要提示关闭 项目变更
- else if(name.includes('projectCm'))
- {
- if(isModuleEnabled('projectChange'))
- {
- const message = closeDependFeature.replace('{source}', cmLang).replace('{target}', changeLang);
- showDependencyConfirm(
- message,
- () => setModuleState('projectChange', false),
- () => setModuleState('projectCm', true)
- );
- }
- }
- }
- }
|