cmsAdd.ss.jsp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <title></title>
  5. <style>
  6. .progressbar {
  7. height: 100%;
  8. width: 100%;
  9. }
  10. .progressvalue {
  11. position: absolute;
  12. z-index: 100;
  13. left: 53%;
  14. font-size: 14px;
  15. transform: translateX(-50%);
  16. }
  17. </style>
  18. </head>
  19. <body>
  20. <div class='content-div' ssFith="true">
  21. <table class='form'>
  22. <tr> <%-- 去掉,style="display:none;",可以改名称。Lin --%>
  23. <th width="110px">名称</th>
  24. <td>
  25. <input type="text" name="name" id="fileName" width="310px" />
  26. <growh.ss name="fileName" maxHeight="80px" mode="edit"/>
  27. </td>
  28. </tr>
  29. <form id="wjuploadform" action="<serv.ss name='ulByHttp'/>" method="post" enctype="multipart/form-data">
  30. <tr id="hidden" class="type1">
  31. <th width="110px">文件</th>
  32. <td>
  33. <span type="text" id='dataBaseName' class="wjName" style="float: left;"></span>
  34. <input type='hidden' name='width' value="${width}">
  35. <input type='hidden' name='height' value="${height}">
  36. <%-- ='wwj'。改为传输 upload.js 设置的 "Test图片.png",原为 "D:/pms/_ul/ea0e0e2f6724477dbb840ac08bd87d1a",UUID 是上传文件。Lin --%>
  37. <%-- 再改回 wj。sltwj。Lin
  38. 下同
  39. <in@put type='hidden' name='dataBaseName'> --%>
  40. <input type='hidden' name='datawj'>
  41. <%-- 增加,传输 upload.js 设置的 "D:/pms/_ul/ea0e0e2f6724477dbb840ac08bd87d1a",UUID 是上传文件。Lin --%>
  42. <%-- 再改为 xxxBaseName("Test图片.png"),改用 UUID 了。Lin
  43. 下同
  44. <in@put type='hidden' name='dataFileName'> --%>
  45. <input type='hidden' name='dataBaseName'>
  46. <input type="button" multiple="multiple" id="dataEdit" class="content-button" value="上传" style="float: left;"> <%-- 去掉 name="wEdit"。Lin --%>
  47. <ul.ss name="data" width="${empty width?'null':width}" height="${empty height?'null':height}" run="callback"/>
  48. </td>
  49. </tr>
  50. </form>
  51. <%-- "这里上传有问题,先注释掉"。先放出来看看。Lin --%>
  52. <form id="imageuploadform1" action="<serv.ss name='ulByHttp'/>" method="post" enctype="multipart/form-data">
  53. <tr class="type1"> <%-- 去掉 style="display:none;"。Lin --%>
  54. <th>缩略图</th>
  55. <td>
  56. <span id='thnBaseName' class="imageName" style="float: left;"></span> <%-- id='imageName'。Lin --%>
  57. <input type='hidden' name='thnwj'> <%-- name='imagewj'。原 upload.js 里 name='imagewj' 和 id='imagepath' 赋值相同。Lin --%>
  58. <input type="button" id="thnEdit" class="content-button" value="上传" style="float: left;"> <%-- 去掉 name="imageEdit"。Lin --%>
  59. <ul.ss name="thn"/> <%-- 去掉 value="",用到在弄。Lin --%>
  60. <%-- 加载upload模块,实际上是直接加载 --%>
  61. </td>
  62. </tr>
  63. </form>
  64. <%-- "这里上传有问题,先注释掉"。先放出来看看。Lin --%>
  65. <form id="iconuploadform1" action="<serv.ss name='ulByHttp'/>" method="post" enctype="multipart/form-data">
  66. <tr class="type1"> <%-- 去掉 style="display:none;"。Lin --%>
  67. <th width="108px">图标</th>
  68. <td>
  69. <span id='iconBaseName' class="iconName" style="float: left;"></span> <%-- id='iconName'。Lin --%>
  70. <input type='hidden' name='iconwj'> <%-- name='iconwj'。原 upload.js 里 name='iconwj' 和 id='iconpath' 赋值相同。Lin --%>
  71. <input type="button" multiple id="iconEdit" class="content-button" value="上传" style="float: left;"> <%-- 去掉 name="iconEdit"。Lin --%>
  72. <ul.ss name="icon"/> <%-- 去掉 value="",用到在弄。Lin --%>
  73. <%-- 加载upload模块,实际上是直接加载 --%>
  74. </td>
  75. </tr>
  76. </form>
  77. <tr class="type2" style="display: none;">
  78. <th>引用内容</th>
  79. <td>
  80. <select id="referenceSelection"></select>
  81. </td>
  82. </tr>
  83. <tr class="type3" style="display: none;">
  84. <th>引用对象</th>
  85. <td>
  86. <select id="objectSelection"></select>
  87. </td>
  88. </tr>
  89. <tr style="display:none;">
  90. <th>类别</th>
  91. <td>
  92. <span id="s1"><input type="radio" name="identity" value="1" checked="checked" />新建内容</span>
  93. <span id="s2" style="display: none;"><input type="radio" name="identity" value="2" />引用内容</span>
  94. <span id="s3" style="display: none;"><input type="radio" name="identity" value="3" />引用对象</span>
  95. </td>
  96. </tr>
  97. </table>
  98. </div>
  99. <div class="bottom-div">
  100. <div class="bottom-down-div border-top">
  101. <input type="button" class="bottom-button" onclick="checkAndCommit();" value="确认" />
  102. </div>
  103. </div>
  104. <script>
  105. function getFileType(fileName) {//获取单个文件类型
  106. var type = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
  107. if (type == "xls" || type == "xlsx") {
  108. return "1110";
  109. } else if (type == "jpg" || type == "jpeg") {
  110. return "310";
  111. } else if (type == "png") {
  112. return "320";
  113. } else if (type == "gif") {
  114. return "330";
  115. } else if (type == "bmp") {
  116. return "340";
  117. } else if (type == "mp3") {
  118. return "410";
  119. } else if (type == "h264") {
  120. return "510";
  121. } else if (type == "mp4") {
  122. return "520";
  123. } else if (type == "html" || type == "htm"|| type == "txt") {
  124. return "610";
  125. } else if (type == "swf") {
  126. return "710";
  127. } else if (type == "ppt" || type == "pptx") {
  128. return "810";
  129. } else if (type == "doc" || type == "docx") {
  130. return "910";
  131. } else if (type == "pdf") {
  132. return "1010";
  133. } else if (type == "zip") {
  134. return "5010";
  135. } else if (type == "rar") {
  136. return "5011";
  137. } else if (type=="tif"){
  138. return "150";
  139. } else {
  140. return "9910";
  141. }
  142. }
  143. function getFileTypes(fileName) {//获取文件类型
  144. var fileNames="";
  145. var str=fileName.split(";")
  146. for(var i = 0; i <str.length; i++){
  147. fileNames +=getFileType(str[i]);
  148. if(i<str.length-1){
  149. fileNames+=";";
  150. }
  151. }
  152. return fileNames;
  153. }
  154. function checkAndCommit() {
  155. //文件名
  156. //var fileName = document.getElementById("fileName");
  157. var fileName = document.querySelector("textarea[name=fileName]");
  158. //文件路径
  159. var wj = document.querySelector("input[name=dataBaseName]"); // =wwj]。"Test图片.png"。改用 xxxBaseName,改用 UUID 了。Lin
  160. var radioVal = $('input[name="identity"]:checked').val();
  161. if (fileName.value == null || "" == (fileName.value.trim())) { // 没有添加文件上传,直接关闭对话框就好,无需返回新增失败页面
  162. //window.location = "@service{dest:'xzsb'}@";
  163. wd.display.getwdDialogOpener().loadItem();
  164. wd.display.closeDialog();
  165. } else if ('1' == radioVal) { //新增内容
  166. $.ajax({
  167. type: "POST",
  168. /* 改。Lin
  169. url: "@service{name:xznr}@",
  170. */ url: "<serv.ss name='saveCms'/>",
  171. async: true,
  172. dataType: "json",
  173. data: {
  174. nrid: "${nrid}",
  175. prevNrid: "${prevNrid}",
  176. name: $("textarea[name=fileName]").val(),
  177. /// 改,在 upload.js 里把 wwj 的值改为 "Test图片.png" -- 原值为 "D:/pms/_ul/ea0e0e2f6724477dbb840ac08bd87d1a",UUID 是上传文件。Lin
  178. type: getFileTypes(wj.value), // ($("input[name=wwj]").val()),。Lin
  179. ///
  180. /// 增加,filepath > ulFileName 值为 "D:/pms/_ul/ea0e0e2f6724477dbb840ac08bd87d1a" 了 -- UUID 是上传文件。Lin
  181. ulBaseName: wj.value, // "Test图片.png"。Lin
  182. ///
  183. /* 改,改为用 wpath 的值为 "D:/pms/_ul/ea0e0e2f6724477dbb840ac08bd87d1a" -- UUID 是上传文件。Lin
  184. * 原 wwj 改为 "Test图片.png" 了
  185. filepath: $("input[name=wwj]").val(),
  186. */
  187. /* 再改回 xxxwj -- sltwj。Lin
  188. ulFileName: $("input[name=dataFileName]").val(),
  189. */ ulFileName: $("input[name=datawj]").val(),
  190. /* 改。Lin
  191. imgpath: $("input[name=imagewj]").val(),
  192. */
  193. /* 再改回 xxxwj -- sltwj。Lin
  194. ulThnFileName: $("input[name=thnFileName]").val(),
  195. */ ulThnFileName: $("input[name=thnwj]").val(),
  196. //icon
  197. /* 改。Lin
  198. iconPath: $("input[name=iconwj]").val() // iconpath:。Lin
  199. */
  200. /* 再改回 xxxwj -- sltwj。Lin
  201. ulIconFileName: $("input[name=iconFileName]").val() // iconpath:。Lin
  202. */ ulIconFileName: $("input[name=iconwj]").val() // iconpath:。Lin
  203. },
  204. success: function(data) {
  205. if (data.result) {
  206. wd.display.alert("增加成功")
  207. } else {
  208. wd.display.alert("增加失败")
  209. }
  210. wd.display.getwdDialogOpener().loadItem();
  211. wd.display.closeDialog();
  212. },
  213. error: function() {
  214. alert('增加失败');
  215. }
  216. });
  217. } else if ('2' == radioVal) { //新增引用内容
  218. $.ajax({
  219. type: "POST",
  220. url: "@service{name:addReference}@",
  221. async: true,
  222. dataType: "json",
  223. data: {
  224. nrid: "${nrid}",
  225. prevNrid: "${prevNrid}",
  226. name: $('textarea[name=fileName]').val(),
  227. referenceId: $("#referenceSelection").val(),
  228. },
  229. success: function(data) {
  230. if (data.result) {
  231. wd.display.alert("新建成功!")
  232. $("#fileProperty").show();
  233. $("#delete").show();
  234. } else {
  235. wd.display.alert("新建失败!")
  236. }
  237. wd.display.getwdDialogOpener().loadItem();
  238. wd.display.closeDialog();
  239. },
  240. error: function() {
  241. alert('fail');
  242. }
  243. });
  244. } else if ('3' == radioVal) { //新增引用对象
  245. $.ajax({
  246. type: "POST",
  247. url: "@service{name:addObject}@",
  248. async: true,
  249. dataType: "json",
  250. data: {
  251. nrid: "${nrid}",
  252. prevNrid: "${prevNrid}",
  253. name: $('textarea[name=fileName]').val(),
  254. objectId: $("#objectSelection").val(),
  255. objectName: '${objectName}'
  256. },
  257. success: function(data) {
  258. if (data.result) {
  259. wd.display.alert("新建成功!")
  260. } else {
  261. wd.display.alert("新建失败!")
  262. }
  263. wd.display.getwdDialogOpener().loadItem();
  264. wd.display.closeDialog();
  265. },
  266. error: function() {
  267. alert('fail');
  268. }
  269. });
  270. }
  271. }
  272. function callback() {
  273. //var fileName = document.getElementById("fileName");
  274. var fileName = document.querySelector("textarea[name=fileName]");
  275. if (fileName.value == null || fileName.value.trim().length == 0) {
  276. var val = $('#dataBaseName').text(); // = $('#wName').。Lin
  277. var fileNames="";
  278. var str=val.split(";")
  279. for(var i = 0; i <str.length; i++){
  280. fileNames += str[i].substring(0, val.lastIndexOf('.'));
  281. if(i<str.length-1){
  282. fileNames+=";";
  283. }
  284. }
  285. fileName.value = fileNames;
  286. }
  287. }
  288. (function() {
  289. var objectFunction = '${objectFunction}';
  290. if(objectFunction.length > 0 && objectFunction.trim() == 'chooseContent'){
  291. $('#s2').attr('style', '');
  292. }else if(objectFunction.length > 0 && objectFunction.trim() == 'chooseObject'){
  293. $('#s3').attr('style', '');
  294. }
  295. //为radio添加改变事件
  296. $('input:radio[name="identity"]').change(function() {
  297. var objectId = '${objectId}';
  298. var objectName = '${objectName}';
  299. var objectFunction = '${objectFunction}';
  300. var val = $('input[name="identity"]:checked').val();
  301. if ('1' == val) {
  302. $('.type1').attr('style', '');
  303. $('.type2').attr('style', 'display:none');
  304. $('.type3').attr('style', 'display:none');
  305. } else if ('2' == val && objectFunction.length > 0 && objectFunction.trim() == 'chooseContent') {
  306. $('.type1').attr('style', 'display:none');
  307. $('.type2').attr('style', '');
  308. $('.type3').attr('style', 'display:none');
  309. $.ajax({
  310. type: "POST",
  311. url: "@service{name:getObjectFunctionURL}@",
  312. async: true,
  313. data: {
  314. 'objectName': objectName,
  315. 'objectFunction': objectFunction
  316. },
  317. success: function(data) {
  318. $.ajax({
  319. type: "POST",
  320. url: data,
  321. dataType: "json",
  322. async: true,
  323. data: {
  324. 'objectId': objectId
  325. },
  326. success: function(data) {
  327. for (var i = 0; i < data.length; i++) {
  328. $('#referenceSelection').append('<option value="' + data[i].ID + '">' + data[i].name + '</option>');
  329. }
  330. $('textarea[name=fileName]').val(data[0].name);
  331. $('#referenceSelection').on('change', function(e) {
  332. $('textarea[name=fileName]').val($('#referenceSelection').find("option:selected").text());
  333. });
  334. }
  335. });
  336. },
  337. error: function() {
  338. alert('fail');
  339. }
  340. });
  341. } else if ('3' == val && objectFunction.length > 0 && objectFunction.trim() == 'chooseObject') {
  342. $('.type1').attr('style', 'display:none');
  343. $('.type2').attr('style', 'display:none');
  344. $('.type3').attr('style', '');
  345. $.ajax({
  346. type: "POST",
  347. url: "@service{name:getObjectFunctionURL}@",
  348. async: true,
  349. data: {
  350. 'objectName': objectName,
  351. 'objectFunction': objectFunction
  352. },
  353. success: function(data) {
  354. $.ajax({
  355. type: "POST",
  356. url: data,
  357. dataType: "json",
  358. async: true,
  359. success: function(data) {
  360. for (var i = 0; i < data.length; i++) {
  361. $('#objectSelection').append('<option value="' + data[i].ID + '">' + data[i].name + '</option>');
  362. }
  363. $('textarea[name=fileName]').val(data[0].name);
  364. $('#objectSelection').on('change', function(e) {
  365. $('textarea[name=fileName]').val($('#objectSelection').find("option:selected").text());
  366. });
  367. }
  368. });
  369. },
  370. error: function() {
  371. alert('fail');
  372. }
  373. });
  374. }
  375. });
  376. })();
  377. </script>
  378. </body>
  379. </html>