SystemGeneral.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. //通用JS
  2. $(function () {
  3. $("#liquery").find(".divquery").css("display", "none");
  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. });
  16. //通用JS
  17. var SystemBatchModifyControl = {
  18. BatchModifyControl: function (data) {
  19. var batch = eval('(' + data.Value + ')');
  20. var hidcolumn = $("#PL_hiddenBatchModifycolumnName").val();
  21. var str = new Array();
  22. str = hidcolumn.split(',');
  23. for (var i = 0; i < str.length; i++) {
  24. var controltdiv = batch.Value + batch.ControlType + "_div";
  25. if (str[i] == controltdiv) {
  26. if (batch.ControlType == "TextBox")
  27. $("#" + batch.Value + "_TextBox").val("");
  28. else if (batch.ControlType == "DropdownList")
  29. $("#" + batch.Value + "_DropdownList").combobox("setValue", "请选择");
  30. else if (batch.ControlType == "DictionaryDropDownList")
  31. $("#" + batch.Value + "_DictionaryDropDownList").combobox("setValue", "请选择");
  32. else if (batch.ControlType == "CheckBox")
  33. $("#" + batch.Value + "_CheckBox").removeAttr("checked");
  34. else if (batch.ControlType == "ComboGrid") {
  35. $("#" + batch.Value + "_ComboGrid").combogridX("setValue", "");
  36. }
  37. else if (batch.ControlType == "TextBoxDate")
  38. $("#" + batch.Value + "_TextBoxDate").val("");
  39. else if (batch.ControlType == "TextBoxDateTime")
  40. $("#" + batch.Value + "_TextBoxDateTime").val("");
  41. else if (batch.ControlType == "NumberBox")
  42. $("#" + batch.Value + "_NumberBox").val("");
  43. $("#" + controltdiv).css("display", "inline-block");
  44. } else {
  45. $("#" + str[i]).css("display", "none");
  46. }
  47. }
  48. },
  49. showBatchModifydiv: function () {
  50. $("#li_div").find(".divbatchmodify").css("display", "none");
  51. $("#li_div").find(".divbatchmodify").first().css("display", "inline-block");
  52. $("#BatchModifydiv").css("display", "inline-block");
  53. },
  54. closeBatchModifydiv: function () {
  55. $("#BatchModifydiv").css("display", "none");
  56. },
  57. OnSubmit: null,
  58. BatchModifysubmit: function () {
  59. if (SystemBatchModifyControl.OnSubmit) {
  60. var isCancel = SystemBatchModifyControl.OnSubmit.call(null);
  61. if (typeof (isCancel) == "boolean" && !isCancel) return;
  62. }
  63. if (isCancel) return;
  64. var batch = validChoose().join(',');
  65. //先清空
  66. $("#PL_hiddenBatchModify").val("");
  67. if ($("input[name='DropdownBatchModify']").val() == "-1") {
  68. $.messager.alert("系统提示", "请选择您要批量修改的字段!!");
  69. return;
  70. }
  71. //重新赋值
  72. $("#PL_hiddenBatchModify").val(batch);
  73. if ($("#PL_hiddenBatchModify").val() == "") {
  74. $.messager.alert("系统提示", "请选择您要批量修改的数据!!");
  75. return;
  76. }
  77. $.messager.confirm("系统提示", "您确定要批量修改选择的数据吗?", function (r) {
  78. if (r) {
  79. $("#formBatchModify").submit();
  80. }
  81. });
  82. }
  83. };
  84. var SystemQueryControl = function () { };
  85. SystemQueryControl.ControlCache = {};
  86. SystemQueryControl.QueryControl = function (data) {
  87. var batch = eval('(' + data.Value + ')'),
  88. dic = SystemQueryControl.ControlCache,
  89. $parent = $(this).parent().next().next(),
  90. template = "<div></div>";
  91. for (var item in dic) {
  92. dic[item].$wrapper.hide();
  93. //SetDefaultValue(dic[item].$control, dic[item].ControlType);
  94. }
  95. if (batch.ControlType == "TextBox") {
  96. var controlName = batch.Value + "_QueryTextBox",
  97. $control,
  98. $wrapper = $(template);
  99. if (!dic[controlName]) {
  100. $control = $("<input name=\"" + controlName + "\" data-condition=\"" + batch.listControl + "\" type=\"text\" value=\"\" />");
  101. AddControlAndCache($wrapper, $control, controlName, batch.ControlType);
  102. } else {
  103. ShowControl(controlName);
  104. }
  105. } else if (batch.ControlType == "TextBoxDate") {
  106. var controlName = batch.Value + "_QueryTextBoxDate",
  107. $control,
  108. $wrapper = $(template);
  109. if (!dic[controlName]) {
  110. $control = $("<input name=\"" + controlName + "\" data-condition=\"" + batch.listControl + "\" onfocus=\"WdatePicker({autoUpdateOnChanged:true,dateFmt:'yyyy-MM-dd'})\" type=\"text\" value=\"\" />");
  111. AddControlAndCache($wrapper, $control, controlName, batch.ControlType);
  112. } else {
  113. ShowControl(controlName);
  114. }
  115. } else if (batch.ControlType == "DropdownList" || batch.ControlType == "DictionaryDropDownList") {
  116. var controlName = batch.Value + (batch.ControlType == "DropdownList" ? "_QueryDropdownList" : "_QueryDictionaryDropDownList"),
  117. $control,
  118. $wrapper = $(template);
  119. if (!dic[controlName]) {
  120. $control = $("<input name=\"" + controlName + "\" data-condition=\"" + batch.listControl + "\" class=\"easyui-combobox combobox-f combo-f\" isonload=\"0\" />");
  121. AddControlAndCache($wrapper, $control, controlName, batch.ControlType);
  122. $control.combobox({
  123. url: batch.PostUrl,
  124. textField: batch.ControlTextFiled,
  125. valueField: batch.ControlValueFiled,
  126. onSelect: function (record) {
  127. BowinFunction.Combobox.OnSelect.call(this, record, null);
  128. },
  129. onUnselect: function (record) {
  130. BowinFunction.Combobox.OnUnselect.call(this, record, null);
  131. },
  132. onLoadSuccess: function () {
  133. BowinFunction.Combobox.OnLoadSuccess.call(this, null);
  134. },
  135. panelHeight: 'auto',
  136. editable: false,
  137. multiple: false
  138. });
  139. }
  140. else {
  141. ShowControl(controlName);
  142. }
  143. } else if (batch.ControlType == "ComboGrid") {
  144. var controlName = batch.Value + "_QueryComboGrid",
  145. $control,
  146. $wrapper = $(template);
  147. if (!dic[controlName]) {
  148. var sb = "<span class=\"easyui-combogridX \" comboname=\"" + controlName + "\" data-condition=\"" + batch.listControl + "\"";
  149. sb = sb + " data-options=\"textField:'" + batch.ControlTextFiled + "',valueField:'" + batch.ControlValueFiled + "',value:'-1'\"";
  150. sb = sb + " id=\"" + controlName + "\">";
  151. sb = sb + " <input class=\"combo-text\" type=\"text\" /><span><span class=\"combo-arrow combogridX-arrow\"></span></span><input";
  152. sb = sb + " class=\"combogridX-value\" name=\"" + controlName + "\" type=\"hidden\" /><div class=\"easyui-panel combogridX-expander\">";
  153. sb = sb + " <div class=\"easyui-cmsXDataTable xDataTablePanel \" data-options=\"pagerType:1,singleSelect:false,checkOnSelect:true,isPostBack:false,rownumbers:true,url:'" + batch.PostUrl + "',striped:'True',fitColumns:true,nowrap:false,onLoadSuccess:function (data) { CMSFunction.DataTable.OnLoadSuccessFunction.call(this, data, null) },pagination:true,pageSize:10\"";
  154. sb = sb + " id=\"" + controlName + "_gridX\">";
  155. sb = sb + " <div class=\"xpanel_head\">";
  156. sb = sb + " <div class=\"xpanel_head_title\">";
  157. sb = sb + " <span></span>";
  158. sb = sb + " </div>";
  159. sb = sb + " </div>";
  160. sb = sb + " <div class='xDataTable_bodyPanel'>";
  161. sb = sb + " <input id=\"" + controlName + "_gridX_datajson\" name=\"" + controlName + "_gridX_datajson\"";
  162. sb = sb + " type=\"hidden\" />";
  163. sb = sb + " <table class=\"xDataTable\" cellpadding=\"0\" cellspacing=\"0\">";
  164. sb = sb + " <tr class=\"header\">";
  165. for (var i = 0; i < batch.Sys_ConfiguretermsExpand.length; i++) {
  166. sb = sb + " <th columnname=\"\" width=\"10.00%\" data-options=\"width:$(this).width() * 0.1,align:'center',hidden:false,field:'" + batch.Sys_ConfiguretermsExpand[i].ColumnValue + "',formatter:function(value,row,index){ return CMSFunction.DataTable.ColumnFormatterFunction.call(this,value,row,index,0,null,null); }\">";
  167. sb = sb + " <div style='width: 100%'>";
  168. sb = sb + batch.Sys_ConfiguretermsExpand[i].ColumnName;
  169. sb = sb + " </div>";
  170. sb = sb + " </th>";
  171. }
  172. sb = sb + " </tr>";
  173. sb = sb + " </table>";
  174. sb = sb + " </div>";
  175. sb = sb + " <div class=\"xDataTablePanel_pager\">";
  176. sb = sb + " <div class=\"xDataTablePanel_pager_Simp\">";
  177. sb = sb + " </div>";
  178. sb = sb + " </div>";
  179. sb = sb + " </div>";
  180. sb = sb + " </div>";
  181. sb = sb + "</span>";
  182. $control = $(sb);
  183. AddControlAndCache($wrapper, $control, controlName, batch.ControlType);
  184. $control.combogridX();
  185. $control.find('.easyui-cmsXDataTable').cmsXDataTable();
  186. } else {
  187. ShowControl(controlName);
  188. }
  189. }
  190. function ShowControl(controlName) {
  191. dic[controlName].$wrapper.show();
  192. }
  193. function AddControlAndCache($wrapper, $control, controlName, controlType) {
  194. $parent.append($wrapper.append($control));
  195. dic[controlName] = { $wrapper: $wrapper, $control: $control, ControlType: controlType };
  196. };
  197. function SetDefaultValue($control, controlType) {
  198. if (controlType == "TextBox" || controlType == "TextBoxDate") {
  199. $control.val('');
  200. } else if (controlType == "DropdownList" || controlType == "DictionaryDropDownList") {
  201. $control.combobox("setValue", "-1");
  202. } else if (controlType == "ComboGrid") {
  203. $control.combogridX("setValue", "");
  204. }
  205. };
  206. };
  207. //var SystemQueryControl = {
  208. // QueryControl: function (data) {
  209. // var batch = eval('(' + data.Value + ')');
  210. // var hidcolumn = $("#QuerycolumnName").val();
  211. // var str = new Array();
  212. // str = hidcolumn.split(',');
  213. // for (var i = 0; i < str.length; i++) {
  214. // var controlName = batch.Value.replace('.', '');
  215. // var controltdiv = controlName + "Query" + batch.ControlType + "_div";
  216. // if (str[i] == controltdiv) {
  217. // if (batch.ControlType == "TextBox")
  218. // $("#" + controlName + "_QueryTextBox").val("");
  219. // else if (batch.ControlType == "DropdownList")
  220. // $("#" + controlName + "_QueryDropdownList").combobox("setValue", "全部");
  221. // else if (batch.ControlType == "DictionaryDropDownList")
  222. // $("#" + controlName + "_QueryDictionaryDropDownList").combobox("setValue", "全部");
  223. // else if (batch.ControlType == "CheckBox")
  224. // $("#" + controlName + "_QueryCheckBox").removeAttr("checked");
  225. // else if (batch.ControlType == "ComboGrid") {
  226. // $("#" + controlName + "_QueryComboGrid").combogridX("setValue", "");
  227. // }
  228. // else if (batch.ControlType == "TextBoxDate")
  229. // $("#" + controlName + "_QueryTextBoxDate").val("");
  230. // $("#" + controltdiv).css("display", "block");
  231. // } else {
  232. // $("#" + str[i]).css("display", "none");
  233. // }
  234. // }
  235. // }
  236. //};
  237. var EMISFunction = {
  238. ReportingServices: $(CMS_SystemConfig.GetConfig()).find("configuration>reportServer").attr("url"),
  239. UserRole: {
  240. Popup: function (userID) {
  241. top.$('#sysWindow').dialog({
  242. title: '用户类型',
  243. width: 800,
  244. height: 600,
  245. content: '<iframe id="iframeUserRoleControl" frameborder="0" scrolling="no" src="' + CMS_SystemConfig.VirtualDirectoryPath + '/Common/UserRole?UserID=' + userID + '&MNU=' + $.SystemGeneral.getUrlParam("MNU") + '"></iframe>',
  246. modal: true
  247. });
  248. }
  249. },
  250. ApproveStatus: {
  251. Popup: function (tableName, formID) {
  252. top.$('#sysWindow').dialog({
  253. title: '审核历史',
  254. width: 800,
  255. height: 280,
  256. content: '<iframe id="iframeApproveStatusControl" frameborder="0" scrolling="no" src="' + CMS_SystemConfig.VirtualDirectoryPath + '/Common/ApproveStatus?tableName=' + tableName + '&formID=' + formID + '"></iframe>',
  257. modal: true
  258. });
  259. }
  260. },
  261. FormSubmit: function (formID) {
  262. $('a').attr('disabled', 'disabled');
  263. $.each($('a'), function () {
  264. if ($.data(this, "linkbutton")) {
  265. $(this).linkbutton('disable');
  266. }
  267. });
  268. $('#loading').show();
  269. },
  270. FormComplete: function () {
  271. $.each($('a'), function () {
  272. if ($.data(this, "linkbutton")) {
  273. $(this).linkbutton('enable');
  274. }
  275. });
  276. $('a').removeAttr('disabled', 'disabled');
  277. $('#loading').hide();
  278. },
  279. FormSuccess: function (data) {
  280. $('a').removeAttr('disabled', 'disabled');
  281. $('#loading').hide();
  282. $.messager.alert('系统信息', data.Message, null, function () {
  283. if (data.IsSuccess) {
  284. if (data.RedictUrl != null && data.RedictUrl != "") {
  285. window.location.href = data.RedictUrl;
  286. }
  287. var dialogId = $.SystemGeneral.getUrlParam('WindowID');
  288. dialogId = (dialogId == null || dialogId == '') ? 'sysWindow' : dialogId;
  289. top.$('#' + dialogId).window('close');
  290. var $iframe = top.$("#centerIframe");
  291. if ($iframe[0].contentWindow.location.reload)
  292. $iframe[0].contentWindow.location.reload();
  293. }
  294. });
  295. },
  296. LoadContextMenuBar: function (id, formClass, mnu) {
  297. $.post(CMS_SystemConfig.VirtualDirectoryPath + '/Common/GetContextMenuList', { FormClass: formClass, Mnu: mnu }, function (data) {
  298. var $id = $('#' + id);
  299. for (var i = 0; i < data.length; i++) {
  300. 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>");
  301. $id.append($sb);
  302. $sb.linkbutton();
  303. }
  304. }, 'json');
  305. },
  306. LoadPositionCondition: function (id, menuClass, mnu, url) {
  307. $.post(url, { MenuClass: menuClass, Mnu: mnu }, function (data) {
  308. var $id = $('#' + id);
  309. var $control1 = $("<input name=\"Attribute\" class=\"easyui-combobox combobox-f combo-f\" data-condition=\"" + data.Condition + "\" isonload=\"0\" />");
  310. 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\" />");
  311. $id.children("li:nth-child(2)").append($control1);
  312. $id.children("li:nth-child(3)").append($control2);
  313. $control1.combobox({
  314. url: data.Url,
  315. textField: data.TextField,
  316. valueField: data.ValueField,
  317. onSelect: function (record) {
  318. if ($(this).attr("isOnload") == 1)
  319. BowinFunction.Combobox.OnSelect.call(this, record, SystemQueryControl.QueryControl);
  320. BowinFunction.Combobox.OnSelect.call(this, record, SystemQueryControl.QueryControl);
  321. },
  322. onUnselect: function (record) {
  323. BowinFunction.Combobox.OnUnselect.call(this, record, null);
  324. },
  325. onLoadSuccess: function () {
  326. BowinFunction.Combobox.OnLoadSuccess.call(this, function (data) { if (data.length > 0) $(this).combo("setValue", data[0].Value) });
  327. },
  328. panelHeight: 'auto',
  329. editable: false,
  330. multiple: false
  331. });
  332. $control2.combobox({
  333. width: 50
  334. });
  335. }, 'json');
  336. }
  337. };
  338. function initGlobalStyle() {
  339. $("label").parent().addClass("labelClass");
  340. $("label").parents(".search_list").addClass("popupWindowContent");
  341. $(".popupWindowContent td").not(":has(label)").addClass("formTdClass");
  342. $(".popupWindowContent").prev('.p_title').find('div').css("color", "#333");
  343. }
  344. $(function () {
  345. SystemBatchModifyControl.closeBatchModifydiv();
  346. //全局设置样式
  347. initGlobalStyle();
  348. });