util.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. function addOption(sText, sValue) {
  2. var def = false;
  3. var sel = false;
  4. var hasValue = false;
  5. for (var i = 0; i < document.addAuth.authList.options.length; i++) {
  6. if (document.addAuth.authList.options[i].value == sValue) {
  7. hasValue = true;
  8. alert("�����Ѿ����");
  9. break;
  10. }
  11. }
  12. if (!hasValue) {
  13. var ilength = document.addAuth.authList.length;
  14. var optionName = new Option(sText, sValue, def, sel);
  15. document.addAuth.authList.options[ilength] = optionName;
  16. document.addAuth.authList.options[ilength].selected = false;
  17. }
  18. }
  19. function addToOption(td1Text, td2Text, td3Text, sValue) {
  20. if (checkIfExist(sValue)) {
  21. alert("�����Ѿ����");
  22. return;
  23. }
  24. var al = document.getElementById("authLists");
  25. var newLine = al.insertRow();
  26. al.className = 'listrow';
  27. var cb = '<input type=Checkbox name=infoid value=' + sValue + ' checked>';
  28. addNewCell(newLine, cb);
  29. addNewCell(newLine, '');
  30. addNewCell(newLine, td1Text);
  31. addNewCell(newLine, '');
  32. addNewCell(newLine, td2Text);
  33. addNewCell(newLine, '');
  34. addNewCell(newLine, td3Text);
  35. var newLine2 = al.insertRow();
  36. addLineCell(newLine2);
  37. }
  38. function checkIfExist(cname) {
  39. for (i = 0; i < document.addAuth.elements.length; i++) {
  40. if (document.addAuth.elements[i].value == cname) {
  41. return true;
  42. }
  43. }
  44. return false;
  45. }
  46. function addNewCell(trLine, tdText) {
  47. var newCell = trLine.insertCell();
  48. newCell.innerHTML = tdText;
  49. }
  50. function addLineCell(trLine, tdText) {
  51. var newCell = trLine.insertCell();
  52. newCell.className = 'listline';
  53. newCell.height = 1;
  54. newCell.colSpan = 7;
  55. }
  56. function addNodeToOption() {
  57. var sText = document.addAuth.city.value
  58. + getSpace(document.addAuth.city.value, 20) + "����"
  59. + getSpace("����", 23) + "����";
  60. // addOption(sText,document.addAuth.cityCode.value + '*ALL*ALL');
  61. addToOption(document.addAuth.city.value, '����', '����',
  62. document.addAuth.cityCode.value + '*ALL*ALL');
  63. }
  64. function addResTypeToOption(resTypeCode, resTypeName) {
  65. if (document.addAuth.city.value != null
  66. && document.addAuth.city.value != "") {
  67. var sText = document.addAuth.city.value
  68. + getSpace(document.addAuth.city.value, 20)
  69. + replaceToSpace(resTypeName) + getSpace(resTypeName, 23)
  70. + "����";
  71. // addOption(sText,document.addAuth.cityCode.value + '*' + resTypeCode +
  72. // '*ALL');
  73. addToOption(document.addAuth.city.value, replaceToSpace(resTypeName),
  74. '����', document.addAuth.cityCode.value + '*' + resTypeCode
  75. + '*ALL');
  76. } else
  77. alert("��ѡ��ڵ�");
  78. }
  79. function addResInstToOption(resInstID, resInstName) {
  80. for (var i = 0; i < document.addAuth.resSubType.options.length; i++) {
  81. if (document.addAuth.resSubType.options[i].selected) {
  82. var tempText = document.addAuth.resSubType.options[i].text;
  83. break;
  84. }
  85. }
  86. var sText = document.addAuth.city.value
  87. + getSpace(document.addAuth.city.value, 20) + tempText
  88. + getSpace(document.addAuth.resSubType.value, 21)
  89. + replaceToSpace(resInstName);
  90. // addOption(sText,document.addAuth.cityCode.value + '*' +
  91. // document.addAuth.resSubType.value + '*' + resInstID);
  92. addToOption(document.addAuth.city.value, tempText,
  93. replaceToSpace(resInstName), document.addAuth.cityCode.value + '*'
  94. + document.addAuth.resSubType.value + '*' + resInstID);
  95. }
  96. function replaceToSpace(str) {
  97. while (str.indexOf('$') != -1) {
  98. str = str.replace('$', " ");
  99. }
  100. return str;
  101. }
  102. function addViewPreCheckToAuthList(nodeName, resType, resInst, auth) {
  103. var sText = nodeName + getSpace(nodeName, 20) + resType
  104. + getSpace(resType, 23) + resInst;
  105. // addOption(sText,auth);
  106. addToOption(nodeName, resType, resInst, auth);
  107. }
  108. function addToAuthList(nodeName, fatherNodeName, isLeaf, nodeCode) {
  109. if (document.addAuth.city.value == '-1') {
  110. isLeaf = isLeaf == 1 ? '��' : '��';
  111. addToOption(nodeName, fatherNodeName, isLeaf, nodeCode);
  112. } else {
  113. if (isLeaf == '1') {
  114. resInst.innerHTML = '<a href=javascript:changeToResInst()>��������Դ����</a>';
  115. if (document.addAuth.city.value != nodeName) {
  116. resList.innerHTML = '';
  117. document.addAuth.resType.options[0].selected = true;
  118. document.addAuth.resSubType.options[0].selected = true;
  119. }
  120. } else {
  121. resInst.innerHTML = '';
  122. changeToResType();
  123. }
  124. city.innerHTML = '<a href="javascript:addNodeToOption()" >' + nodeName
  125. + '</a>';
  126. document.addAuth.city.value = nodeName;
  127. document.addAuth.cityCode.value = nodeCode;
  128. }
  129. }
  130. function addPreCheckToAuthList(nodeName, resType, resInst, auth) {
  131. var sText = nodeName + getSpace(nodeName, 10) + resType
  132. + getSpace(resType, 10) + resInst;
  133. // addOption(sText,auth);
  134. addToOption(nodeName, resType, resInst, auth);
  135. }
  136. function getSpace(firstWord, distance) {
  137. var spaceStr = "";
  138. var singleCharacters = 0;
  139. var doubleCharacters = 0;
  140. for (var i = 0; i < firstWord.length; i++) {
  141. var temp = firstWord.charAt(i);
  142. if ((temp > "0" && temp < "9") || (temp > "a" && temp < "z")
  143. || (temp > "A" && temp < "Z") || (temp == "_")) {
  144. singleCharacters++;
  145. spaceStr += " ";
  146. }
  147. if (temp == " ")
  148. spaceStr += " ";
  149. }
  150. for (var i = 0; i < distance - firstWord.length - singleCharacters; i++) {
  151. spaceStr += " ";
  152. }
  153. if (firstWord.length > 6 && singleCharacters <= 4)
  154. spaceStr += " ";
  155. // if(doubleCharacters.length >= 6 || singleCharacters > 8)
  156. // spaceStr += " ";
  157. return spaceStr;
  158. }
  159. function deleteOptions() {
  160. for (var i = 0; i < document.addAuth.authList.options.length; i++) {
  161. if (document.addAuth.authList.options[i].selected) {
  162. document.addAuth.authList.options[i] = null;
  163. i--;
  164. }
  165. }
  166. }
  167. function setUser(usr) {
  168. document.write("<input type=hidden name=usr value = " + usr + ">")
  169. }
  170. function doubleSelectItem(resClassName, resClassCode, resTypeName, resTypeCode) {
  171. this.resClassName = resClassName;
  172. this.resClassCode = resClassCode;
  173. this.resTypeName = resTypeName;
  174. this.resTypeCode = resTypeCode;
  175. }
  176. function selectChanged() {
  177. with (document.addAuth.resType) {
  178. var resClassSelected = options[selectedIndex].text;
  179. }
  180. for (i = 0; i < resTypeList.length; i++) {
  181. if (resTypeList[i].resClassName == resClassSelected) {
  182. resTypeNames = (resTypeList[i].resTypeName).split("|");
  183. resTypeCodes = (resTypeList[i].resTypeCode).split("|");
  184. for (j = 0; j < resTypeNames.length; j++) {
  185. with (document.addAuth.resSubType) {
  186. length = resTypeNames.length;
  187. options[j].text = resTypeNames[j];
  188. options[j].value = resTypeCodes[j];
  189. }
  190. }
  191. break;
  192. }
  193. }
  194. document.addAuth.resSubType.options[0].selected = true;
  195. }
  196. function loadResDetail() {
  197. with (document.addAuth.resType) {
  198. var resClassSelected = options[selectedIndex].value;
  199. }
  200. // if (this.res.style.display != 'block'){
  201. // this.res.style.display = "block";
  202. document.frames["hiddenframe"].location.replace(resClassSelected
  203. + "List.jsp?nodeCode=" + document.addAuth.cityCode.value
  204. + "&resSubType=" + document.addAuth.resSubType.value);
  205. // }
  206. }
  207. function addAll() {
  208. // for (i=0; i<document.addAuth.authList.options.length; i++) {
  209. // document.addAuth.authList.options[i].selected=true;
  210. // }
  211. addAuth.submit();
  212. }
  213. function checkall() {
  214. var flag = document.getElementById("checkFlag");
  215. var temp = document.getElementById("checkText");
  216. for (var i = 0; i < document.addAuth.length; i++) {
  217. e = document.addAuth.item(i);
  218. if (e.name == "infoid") {
  219. if (flag.checked == true) {
  220. temp.innerText = "ѡ������";
  221. e.checked = true;
  222. } else {
  223. temp.innerText = "ѡ������";
  224. e.checked = false;
  225. }
  226. }
  227. }
  228. }