SystemGeneral.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. //通用JS
  2. var DropdownListSelectValueList;
  3. var DropdownListSelectValue;
  4. $.SystemGeneral = (function () {
  5. //获取url中的参数
  6. var getUrlParam = function (name) {
  7. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
  8. var r = window.location.search.substr(1).match(reg); //匹配目标参数
  9. if (r != null)
  10. return unescape(r[2]);
  11. return null; //返回参数值
  12. }
  13. return { 'getUrlParam': getUrlParam };
  14. })();
  15. $(function () {
  16. $("#liquery").find(".divquery").css("display", "none");
  17. });
  18. var ScoreFormulaFunction = {
  19. ScoreFormulaChangeHidden: function (record) {
  20. $('[name="' + $(this).attr("id") + '"]').val(eval("("+record.Value+")").ScoreFormulaID);
  21. },
  22. GradePointFormularChangeHidden: function (record) {
  23. $('[name="' + $(this).attr("id") + '"]').val(eval("(" + record.Value + ")").GradePointFormulaID);
  24. },
  25. CreditFormularChangeHidden: function (record) {
  26. $('[name="' + $(this).attr("id") + '"]').val(eval("(" + record.Value + ")").CreditFormulaID);
  27. }
  28. };
  29. //通用JS
  30. var SystemBatchModifyControl = {
  31. BatchModifyControl: function (data) {
  32. var batch = eval('(' + data.Value + ')');
  33. var hidcolumn = $("#PL_hiddenBatchModifycolumnName").val();
  34. var str = new Array();
  35. str = hidcolumn.split(',');
  36. for (var i = 0; i < str.length; i++) {
  37. var controltdiv = batch.Value + batch.ControlType + "_div";
  38. if (str[i] == controltdiv) {
  39. if (batch.ControlType == "TextBox")
  40. $("#" + batch.Value + "_TextBox").val("");
  41. else if (batch.ControlType == "DropdownList")
  42. $("#" + batch.Value + "_DropdownList").combobox("setValue", "请选择");
  43. else if (batch.ControlType == "DictionaryDropDownList")
  44. $("#" + batch.Value + "_DictionaryDropDownList").combobox("setValue", "请选择");
  45. else if (batch.ControlType == "CheckBox") {
  46. $("#" + batch.Value + "_CheckBox").removeAttr("checked");
  47. $("#" + batch.Value + "_CheckBox").val("false");
  48. }
  49. else if (batch.ControlType == "ComboGrid") {
  50. $("#" + batch.Value + "_ComboGrid").combogridX("setValue", "");
  51. }
  52. else if (batch.ControlType == "TextBoxDate")
  53. $("#" + batch.Value + "_TextBoxDate").val("");
  54. else if (batch.ControlType == "TextBoxDateTime")
  55. $("#" + batch.Value + "_TextBoxDateTime").val("");
  56. else if (batch.ControlType == "NumberBox")
  57. $("#" + batch.Value + "_NumberBox").val("");
  58. $("#" + controltdiv).css("display", "inline-block");
  59. } else {
  60. $("#" + str[i]).css("display", "none");
  61. }
  62. }
  63. $(".batchUpdateCheckbox").click(function () {
  64. if ($(this).attr("checked")) {
  65. $(this).val(true);
  66. } else {
  67. $(this).val(false);
  68. }
  69. });
  70. },
  71. showBatchModifydiv: function () {
  72. $("#li_div").find(".divbatchmodify").css("display", "none");
  73. $("#li_div").find(".divbatchmodify").first().css("display", "inline-block");
  74. $("#BatchModifydiv").css("display", "inline-block");
  75. //获取选中要修改的
  76. DropdownListSelectValue = $("[name='DropdownBatchModify']").val();
  77. var value = DropdownListSelectValue;
  78. if (value != "" && value != null) {
  79. //$("[name='DropdownBatchModify']").attr("value", value);
  80. var valuelist = value.split(",");
  81. var batchModifyName = valuelist[2]; //获取修改列
  82. var batchModifyValue = valuelist[3]; //获取修改列对应的控件
  83. var name = batchModifyName.split(":");
  84. var namestr = name[1].replace("\"", "").replace("\"", "");
  85. var value = batchModifyValue.split(":");
  86. var valuestr = value[1].replace("\"", "").replace("\"", "");
  87. var inid = namestr + valuestr + "_div";
  88. $(".divbatchmodify").css("display", "none");
  89. $("#" + inid).css("display", "inline-block");
  90. }
  91. },
  92. closeBatchModifydiv: function () {
  93. $("#BatchModifydiv").css("display", "none");
  94. },
  95. SelectFunction: null,
  96. OnSubmit: null,
  97. OnComplete: null,
  98. BatchModifysubmit: function () {
  99. if (SystemBatchModifyControl.OnSubmit) {
  100. var isCancel = SystemBatchModifyControl.OnSubmit.call(null);
  101. if (typeof (isCancel) == "boolean" && !isCancel) return;
  102. }
  103. if (SystemBatchModifyControl.SelectFunction == null)
  104. SystemBatchModifyControl.SelectFunction = validChoose;
  105. var batch = SystemBatchModifyControl.SelectFunction.call(null);
  106. //先清空
  107. $("#PL_hiddenBatchModify").val("");
  108. if ($("input[name='DropdownBatchModify']").val() == "-1") {
  109. $.messager.alert("系统提示", "请选择您要批量修改的字段。");
  110. return;
  111. }
  112. //重新赋值
  113. $("#PL_hiddenBatchModify").val(batch.join(','));
  114. if ($("#PL_hiddenBatchModify").val() == "") {
  115. $.messager.alert("系统提示", "请选择您要批量修改的信息。");
  116. return;
  117. }
  118. $.messager.confirm("系统提示", "您确定要批量修改选择的信息吗?", function (r) {
  119. if (r) {
  120. var formValue = $("#formBatchModify").getJsonFormParams();
  121. var batchModifyValue = eval('('+$("#DropdownBatchModify").combobox("getValue")+')');
  122. var columnName = batchModifyValue.Value;
  123. var modifyValue = $("[name='" + columnName + "_" + batchModifyValue.ControlType + "']").val();
  124. var url = $("#formBatchModify").attr("action");
  125. if (SystemBatchModifyControl.OnComplete) {
  126. $.postWithLoading(url, formValue, function (data) {
  127. if (data.IsSuccess) {
  128. SystemBatchModifyControl.OnComplete.call(data, columnName, modifyValue, batch);
  129. }
  130. EMISFunction.FormSuccess(data);
  131. }, 'json');
  132. } else {
  133. $.postWithLoading(url, formValue, EMISFunction.FormSuccess, 'json');
  134. }
  135. $("#BatchModifydiv").css("display", "none");
  136. }
  137. });
  138. }
  139. };
  140. var SystemQueryControl = function () { };
  141. SystemQueryControl.ControlCache = {};
  142. SystemQueryControl.QueryControl = function (data) {
  143. var batch = eval('(' + data.Value + ')'),
  144. dic = SystemQueryControl.ControlCache,
  145. $parent = $(this).parent().next().next(),
  146. template = "<div></div>";
  147. for (var item in dic) {
  148. dic[item].$wrapper.hide();
  149. //SetDefaultValue(dic[item].$control, dic[item].ControlType);
  150. }
  151. if (batch.ControlType == "TextBox") {
  152. var controlName = batch.Value + "_QueryTextBox",
  153. $control,
  154. $wrapper = $(template);
  155. if (!dic[controlName]) {
  156. $control = $("<input name=\"" + controlName + "\" data-condition=\"" + batch.listControl + "\" type=\"text\" value=\"\" />");
  157. AddControlAndCache($wrapper, $control, controlName, batch.ControlType);
  158. } else {
  159. ShowControl(controlName);
  160. }
  161. } else if (batch.ControlType == "TextBoxDate") {
  162. var controlName = batch.Value + "_QueryTextBoxDate",
  163. $control,
  164. $wrapper = $(template);
  165. if (!dic[controlName]) {
  166. $control = $("<input name=\"" + controlName + "\" data-condition=\"" + batch.listControl + "\" onfocus=\"WdatePicker({autoUpdateOnChanged:true,dateFmt:'yyyy-MM-dd'})\" type=\"text\" value=\"\" />");
  167. AddControlAndCache($wrapper, $control, controlName, batch.ControlType);
  168. } else {
  169. ShowControl(controlName);
  170. }
  171. } else if (batch.ControlType == "DropdownList" || batch.ControlType == "DictionaryDropDownList") {
  172. var controlName = batch.Value + (batch.ControlType == "DropdownList" ? "_QueryDropdownList" : "_QueryDictionaryDropDownList"),
  173. $control,
  174. $wrapper = $(template);
  175. if (!dic[controlName]) {
  176. $control = $("<input name=\"" + controlName + "\" data-condition=\"" + batch.listControl + "\" class=\"easyui-combobox combobox-f combo-f\" isonload=\"0\" />");
  177. AddControlAndCache($wrapper, $control, controlName, batch.ControlType);
  178. $control.combobox({
  179. url: batch.PostUrl,
  180. textField: batch.ControlTextFiled,
  181. valueField: batch.ControlValueFiled,
  182. onSelect: function (record) {
  183. BowinFunction.Combobox.OnSelect.call(this, record, null);
  184. },
  185. onUnselect: function (record) {
  186. BowinFunction.Combobox.OnUnselect.call(this, record, null);
  187. },
  188. onLoadSuccess: function () {
  189. BowinFunction.Combobox.OnLoadSuccess.call(this, null);
  190. },
  191. panelHeight: 'auto',
  192. editable: false,
  193. multiple: false
  194. });
  195. }
  196. else {
  197. ShowControl(controlName);
  198. }
  199. } else if (batch.ControlType == "ComboGrid") {
  200. var controlName = batch.Value + "_QueryComboGrid",
  201. $control,
  202. $wrapper = $(template);
  203. if (!dic[controlName]) {
  204. $.post(CMS_SystemConfig.VirtualDirectoryPath + '/Common/GetPositionConditionComboGrid', {
  205. controlName: controlName,
  206. dataCondition: batch.listControl,
  207. textField: batch.ControlTextFiled,
  208. valueFiled: batch.ControlValueFiled,
  209. url: batch.PostUrl,
  210. configuretermsExpandJson: JSON.stringify(batch.Sys_ConfiguretermsExpand)
  211. }, function (htmlString) {
  212. $control = $(htmlString);
  213. AddControlAndCache($wrapper, $control, controlName, batch.ControlType);
  214. $control.combogridX();
  215. $control.find('.easyui-cmsXDataTable').cmsXDataTable();
  216. });
  217. } else {
  218. ShowControl(controlName);
  219. }
  220. }
  221. function ShowControl(controlName) {
  222. dic[controlName].$wrapper.show();
  223. }
  224. function AddControlAndCache($wrapper, $control, controlName, controlType) {
  225. $parent.append($wrapper.append($control));
  226. dic[controlName] = { $wrapper: $wrapper, $control: $control, ControlType: controlType };
  227. };
  228. function SetDefaultValue($control, controlType) {
  229. if (controlType == "TextBox" || controlType == "TextBoxDate") {
  230. $control.val('');
  231. } else if (controlType == "DropdownList" || controlType == "DictionaryDropDownList") {
  232. $control.combobox("setValue", "-1");
  233. } else if (controlType == "ComboGrid") {
  234. $control.combogridX("setValue", "");
  235. }
  236. };
  237. };
  238. SystemQueryControl.FormatOperator = function (operator) {
  239. var result = '';
  240. switch (operator) {
  241. case '左':
  242. result = " like '%{0}'";
  243. break;
  244. case '中':
  245. result = " like '%{0}%'";
  246. break;
  247. case '右':
  248. result = " like '{0}%'";
  249. break;
  250. default:
  251. result = operator + "'{0}'";
  252. break;
  253. }
  254. return result;
  255. };
  256. SystemQueryControl.GetValue = function () {
  257. var attributeControl = $('[name="Attribute"]');
  258. var attributeObj = eval('(' + attributeControl.val() + ')');
  259. if (attributeObj.ControlType == "TextBox")
  260. return $("[name='" + attributeObj.Value + "_QueryTextBox']").val();
  261. else if (attributeObj.ControlType == "DropdownList")
  262. return $("[name='" + attributeObj.Value + "_QueryDropdownList']").combobox("getValue");
  263. else if (attributeObj.ControlType == "DictionaryDropDownList")
  264. return $("#" + attributeObj.Value + "_QueryDictionaryDropDownList").combobox("getValue");
  265. else if (attributeObj.ControlType == "ComboGrid") {
  266. return $("#" + attributeObj.Value + "_QueryComboGrid").combogridX("getValue");
  267. }
  268. else if (attributeObj.ControlType == "TextBoxDate")
  269. return $("#" + attributeObj.Value + "_QueryTextBoxDate").val();
  270. };
  271. //var SystemQueryControl = {
  272. // QueryControl: function (data) {
  273. // var batch = eval('(' + data.Value + ')');
  274. // var hidcolumn = $("#QuerycolumnName").val();
  275. // var str = new Array();
  276. // str = hidcolumn.split(',');
  277. // for (var i = 0; i < str.length; i++) {
  278. // var controlName = batch.Value.replace('.', '');
  279. // var controltdiv = controlName + "Query" + batch.ControlType + "_div";
  280. // if (str[i] == controltdiv) {
  281. // if (batch.ControlType == "TextBox")
  282. // $("#" + controlName + "_QueryTextBox").val("");
  283. // else if (batch.ControlType == "DropdownList")
  284. // $("#" + controlName + "_QueryDropdownList").combobox("setValue", "全部");
  285. // else if (batch.ControlType == "DictionaryDropDownList")
  286. // $("#" + controlName + "_QueryDictionaryDropDownList").combobox("setValue", "全部");
  287. // else if (batch.ControlType == "CheckBox")
  288. // $("#" + controlName + "_QueryCheckBox").removeAttr("checked");
  289. // else if (batch.ControlType == "ComboGrid") {
  290. // $("#" + controlName + "_QueryComboGrid").combogridX("setValue", "");
  291. // }
  292. // else if (batch.ControlType == "TextBoxDate")
  293. // $("#" + controlName + "_QueryTextBoxDate").val("");
  294. // $("#" + controltdiv).css("display", "block");
  295. // } else {
  296. // $("#" + str[i]).css("display", "none");
  297. // }
  298. // }
  299. // }
  300. //};
  301. var EMISFunction = {
  302. ReportingServices: $(CMS_SystemConfig.GetConfig()).find("configuration>reportServer").attr("url"),
  303. UserRole: {
  304. Popup: function (userID) {
  305. $.popupTopWindow('用户类型', CMS_SystemConfig.VirtualDirectoryPath + '/Common/UserRole?UserID=' + userID + '&MNU=' + $.SystemGeneral.getUrlParam("MNU"), 800, 600);
  306. }
  307. },
  308. ApproveStatus: {
  309. Popup: function (tableName, formID) {
  310. $.popupTopWindow('审核历史', CMS_SystemConfig.VirtualDirectoryPath + '/Common/ApproveStatus?tableName=' + tableName + '&formID=' + formID, 800, 280);
  311. }
  312. },
  313. FormSubmit: function (formID) {
  314. $('a').attr('disabled', 'disabled');
  315. $.each($('a'), function () {
  316. if ($.data(this, "linkbutton")) {
  317. $(this).linkbutton('disable');
  318. }
  319. });
  320. $('#loading').show();
  321. },
  322. FormComplete: function () {
  323. $.each($('a'), function () {
  324. if ($.data(this, "linkbutton")) {
  325. $(this).linkbutton('enable');
  326. }
  327. });
  328. $('a').removeAttr('disabled', 'disabled');
  329. $('#loading').hide();
  330. },
  331. FormSuccess: function (data) {
  332. $('a').removeAttr('disabled', 'disabled');
  333. $('#loading').hide();
  334. $.messager.alert('系统信息', data.Message, null, function () {
  335. if (data.IsSuccess) {
  336. var dialogId = $.SystemGeneral.getUrlParam('WindowID');
  337. dialogId = (dialogId == null || dialogId == '') ? 'sysWindow' : dialogId;
  338. try {
  339. top.$('#' + dialogId).window('close');
  340. } catch (e) {
  341. }
  342. var tab = top.$('#index_center_tabs').tabs('getSelected');
  343. var $iframe = tab.panel('body').find("iframe");
  344. if ($iframe[0].contentWindow.reload)
  345. $iframe[0].contentWindow.reload();
  346. }
  347. });
  348. },
  349. FormSuccessNoClose: function (data) {
  350. $('a').removeAttr('disabled', 'disabled');
  351. $('#loading').hide();
  352. $.messager.alert('系统信息', data.Message, null, function () {
  353. if (data.IsSuccess) {
  354. }
  355. });
  356. },
  357. LoadContextMenuBar: function (id, formClass, mnu) {
  358. $.post(CMS_SystemConfig.VirtualDirectoryPath + '/Common/GetContextMenuList', { FormClass: formClass, Mnu: mnu }, function (data) {
  359. var $id = $('#' + id);
  360. for (var i = 0; i < data.length; i++) {
  361. var $sb = $("<a class=\"easyui-linkbutton\" name=\"" + data[i].Name + "\" href=\"javascript:" + data[i].OnClick + "\" data-options=\"iconCls:'" + data[i].Icon + "',plain:'true'\" onfocus=\"this.blur()\" >" + data[i].Text + "</a>");
  362. $id.append($sb);
  363. $sb.linkbutton();
  364. }
  365. }, 'json');
  366. },
  367. LoadPositionCondition: function (id, menuClass, mnu, url) {
  368. $.post(url, { MenuClass: menuClass, Mnu: mnu }, function (data) {
  369. var $id = $('#' + id);
  370. var $control1 = $("<input name=\"Attribute\" class=\"easyui-combobox combobox-f combo-f\" data-condition=\"" + data.Condition + "\" isonload=\"0\" />");
  371. var $control2 = $("<input name=\"Condition\" data-condition=\"" + data.Condition + "\" class=\"easyui-combobox combobox-f combo-f\" data-options=\"textField:'Text',valueField:'Value',onSelect:function(record){ BowinFunction.Combobox.OnSelect.call(this,record,null); },onUnselect:function(record){ BowinFunction.Combobox.OnUnselect.call(this,record,null); },onLoadSuccess:function(){ BowinFunction.Combobox.OnLoadSuccess.call(this,null); },panelHeight:'auto',data:[{ Text:'=',Value:'=' },{ Text:'>=',Value:'>=' },{ Text:'>',Value:'>' },{ Text:'<=',Value:'<=' },{ Text:'<',Value:'<' },{ Text:'<>',Value:'<>' },{ Text:'左',Value:'左' },{ Text:'右',Value:'右' },{ Text:'中',Value:'中' }],value:'左',editable:false,multiple:false\" isonload=\"0\" />");
  372. $id.children("li:nth-child(2)").append($control1);
  373. $id.children("li:nth-child(3)").append($control2);
  374. $control1.combobox({
  375. url: data.Url,
  376. textField: data.TextField,
  377. valueField: data.ValueField,
  378. onSelect: function (record) {
  379. if ($(this).attr("isOnload") == 1)
  380. BowinFunction.Combobox.OnSelect.call(this, record, SystemQueryControl.QueryControl);
  381. BowinFunction.Combobox.OnSelect.call(this, record, SystemQueryControl.QueryControl);
  382. },
  383. onUnselect: function (record) {
  384. BowinFunction.Combobox.OnUnselect.call(this, record, null);
  385. },
  386. onLoadSuccess: function () {
  387. BowinFunction.Combobox.OnLoadSuccess.call(this, function (data) { if (data.length > 0) $(this).combo("setValue", data[0].Value) });
  388. },
  389. panelHeight: 'auto',
  390. editable: false,
  391. multiple: false
  392. });
  393. $control2.combobox({
  394. width: 50
  395. });
  396. }, 'json');
  397. }
  398. };
  399. function initGlobalStyle() {
  400. $("label").parent().addClass("labelClass");
  401. $("label").parents(".search_list").addClass("popupWindowContent");
  402. $(".popupWindowContent td").not(":has(label)").addClass("formTdClass");
  403. $(".popupWindowContent").prev('.p_title').find('div').css("color", "#f0f0f0");
  404. var windowID = $.SystemGeneral.getUrlParam("WindowID");
  405. if (windowID) {
  406. if (windowID != "") {
  407. $("body").addClass("popupWindowBody");
  408. }
  409. }
  410. }
  411. $(function () {
  412. SystemBatchModifyControl.closeBatchModifydiv();
  413. //全局设置样式
  414. initGlobalStyle();
  415. });