Nenhuma Descrição

addApplicationUpdate.html 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <script src="../../Script/Common/huayi.load.js"></script>
  7. <script src="../../Script/Common/huayi.config.js"></script>
  8. <link href="../../js/bootstrap-select/css/bootstrap-select.css" rel="stylesheet" />
  9. <link href="../../css/init.css" rel="stylesheet" />
  10. <link rel="stylesheet" type="text/css" href="../../css/Table/table1.css" />
  11. <title>新增和编辑应用更新</title>
  12. <style>
  13. b.text_require {
  14. color: red;
  15. }
  16. .app_url,
  17. .app_file {
  18. display: none;
  19. }
  20. </style>
  21. </head>
  22. <body class="gray-bg">
  23. <div class="container wrapper-content animated fadeInRight">
  24. <div class="form-horizontal">
  25. <div class="form-group">
  26. <label for="appType" class="col-sm-3 control-label text-right"><b class="text_require">*</b>应用分类</label>
  27. <div class="col-sm-9">
  28. <!--<input id="applicationName" class="form-control" type="text" autocomplete="off" />-->
  29. <select class="form-control selectpicker" id="appType">
  30. <option value="1">Android</option>
  31. <option value="2">IOS</option>
  32. </select>
  33. </div>
  34. </div>
  35. <div class="form-group">
  36. <label for="versionName" class="col-sm-3 control-label text-right"><b class="text_require">*</b>版本名称</label>
  37. <div class="col-sm-9">
  38. <input id="versionName" class="form-control" type="text" autocomplete="off" />
  39. </div>
  40. </div>
  41. <div class="form-group">
  42. <label for="versionCode" class="col-sm-3 control-label text-right"><b class="text_require">*</b>版本号</label>
  43. <div class="col-sm-9">
  44. <input id="versionCode" class="form-control" type="text" autocomplete="off" />
  45. </div>
  46. </div>
  47. <div class="form-group">
  48. <label for="orderNum" class="col-sm-3 control-label text-right"><b class="text_require">*</b>排序</label>
  49. <div class="col-sm-9">
  50. <input id="orderNum" class="form-control" type="text" autocomplete="off" />
  51. </div>
  52. </div>
  53. <div class="form-group app_url">
  54. <label for="httpurl" class="col-sm-3 control-label text-right"><b class="text_require">*</b>链接地址</label>
  55. <div class="col-sm-9">
  56. <input id="httpurl" class="form-control" type="text" autocomplete="off" />
  57. </div>
  58. </div>
  59. <div class="form-group app_file">
  60. <label for="downurl" class="col-sm-3 control-label text-right"><b class="text_require">*</b>下载地址</label>
  61. <div class="col-sm-9">
  62. <span class="fjnr"></span>
  63. <input class="input" type="file" name="upFile" id="upFile" multiple="multiple" style="display: none;">
  64. <input class="input btns" type="button" value="上传" id="scwj" />
  65. <input class="input" type="button" value="删除附件" id="scfj" style="display:none;" />
  66. <input type="hidden" id="file" />
  67. </div>
  68. </div>
  69. <div class="form-group">
  70. <label for="note" class="col-sm-3 control-label text-right">备注</label>
  71. <div class="col-sm-9">
  72. <input id="note" class="form-control" type="text" autocomplete="off" />
  73. </div>
  74. </div>
  75. <div class="form-group">
  76. <div class="col-sm-12" style="text-align: center;">
  77. <input type="button" id="HY_save" class="btn_gray btn" onclick="btn_save()" value="保存" />
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. <script src="../../js/bootstrap-select/js/bootstrap-select.js"></script>
  83. <script src="../../js/bootstrap-select/js/i18n/defaults-zh_CN.js"></script>
  84. <script src="../../js/laydate/laydate.js"></script>
  85. <script>
  86. var ids = helper.request.queryString("ids");
  87. var downurl = '';
  88. $(document).ready(function() {
  89. $('#appType').on('change', function() {
  90. //1,Android 2 IOS
  91. switch($(this).val()) {
  92. case '1':
  93. $('.app_url').hide();
  94. $('.app_file').show();
  95. break;
  96. case '2':
  97. $('.app_url').show();
  98. $('.app_file').hide();
  99. break;
  100. default:
  101. break;
  102. }
  103. });
  104. $('#appType').trigger('change');
  105. //上传安装包
  106. $("#scwj").click(function() {
  107. $("#upFile").trigger("click");
  108. })
  109. $("#upFile").change(function() {
  110. upload();
  111. });
  112. $("#scfj").click(function() {
  113. $(".fjnr").text("");
  114. $("#scfj").hide();
  115. });
  116. if(ids) {
  117. getDetail()
  118. };
  119. })
  120. //获取详情
  121. function getDetail() {
  122. $.ajax({
  123. type: "get",
  124. url: huayi.config.callcenter_url + "messageapi/api/ApplicationsVersion/getdetailes",
  125. async: true,
  126. dataType: 'json',
  127. data: {
  128. id: ids
  129. },
  130. success: function(data) {
  131. if(data.state.toLowerCase() == 'success') {
  132. $('#appType').selectpicker('val', data.data.apptype).trigger('change'); //应用分类
  133. $('#versionName').val(data.data.versionname); //版本名称
  134. $('#versionCode').val(data.data.versioncode); //版本号
  135. $('#orderNum').val(data.data.ordernum); //排序
  136. $('#httpurl').val(data.data.httpurl); //排序
  137. if(data.data.downurl && data.data.downurl.length > 0) {
  138. $('.fjnr').text(data.data.downurl[0].filename);
  139. downurl = data.data.downurl;
  140. };
  141. $('#note').val(data.data.note); //备注
  142. }
  143. }
  144. });
  145. }
  146. //添加应用更新
  147. function btn_save() {
  148. var regVersionCode = /^(?!\.)(?!.*?\.$)[a-zA-Z0-9\.]+$/; //由字母、数字、.组成
  149. if($("#versionName").val() == '') {
  150. layer.confirm('请输入版本名称!', {
  151. btn: ['确定'] //按钮
  152. });
  153. return;
  154. }
  155. if(!regVersionCode.test($.trim($("#versionCode").val()))) {
  156. layer.confirm('版本号只能含有字母、数字、.,且不能以.开头和结尾。', {
  157. btn: ['确定'] //按钮
  158. });
  159. return;
  160. }
  161. if($("#orderNum").val() == '') {
  162. layer.confirm('请输入排序号!', {
  163. btn: ['确定'] //按钮
  164. });
  165. return;
  166. }
  167. if($(".app_url").is(':visible')){
  168. if($("#httpurl").val() == '') {
  169. layer.confirm('请输入链接地址!', {
  170. btn: ['确定'] //按钮
  171. });
  172. return;
  173. }
  174. }
  175. if($(".app_file").is(':visible')){
  176. if(!downurl) {
  177. layer.confirm('请上传下载地址!', {
  178. btn: ['确定'] //按钮
  179. });
  180. return;
  181. }
  182. }
  183. if(ids) {
  184. $.post(huayi.config.callcenter_url + "messageapi/api/ApplicationsVersion/update", {
  185. id: ids,
  186. apptype: $('#appType').val(),
  187. versionname: $('#versionName').val(),
  188. versioncode: $('#versionCode').val(),
  189. ordernum: $('#orderNum').val(),
  190. downurl: downurl,
  191. httpurl: $("#httpurl").val(),
  192. note: $("#note").val()
  193. }, function(data) {
  194. data = JSON.parse(data);
  195. if(data.state == "success") {
  196. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  197. parent.layer.close(index); //再执行关闭
  198. layer.msg(data.message);
  199. parent.$('#table1').bootstrapTable('refresh');
  200. }
  201. });
  202. } else {
  203. $.post(huayi.config.callcenter_url + "messageapi/api/ApplicationsVersion/add", {
  204. apptype: $('#appType').val(),
  205. versionname: $('#versionName').val(),
  206. versioncode: $('#versionCode').val(),
  207. ordernum: $('#orderNum').val(),
  208. httpurl: $('#httpurl').val(),
  209. downurl: downurl,
  210. note: $('#note').val()
  211. }, function(data) {
  212. data = JSON.parse(data);
  213. if(data.state == "success") {
  214. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  215. parent.layer.close(index); //再执行关闭
  216. layer.msg(data.message);
  217. parent.$('#table1').bootstrapTable('refresh');
  218. }
  219. });
  220. }
  221. }
  222. //上传文件
  223. function upload() {
  224. var Files = document.getElementById("upFile").files;
  225. if(Files.length > 0) {
  226. var formData = new FormData();
  227. console.log(formData)
  228. for(var i = 0; i < Files.length; i++) {
  229. formData.append('file' + i, Files[i]);
  230. }
  231. formData.append("uploadtype", 'App');
  232. console.log(formData,Files)
  233. $.ajax({
  234. url: huayi.config.callcenter_url + "fileserverapi/Api/Upload",
  235. type: "POST",
  236. data: formData,
  237. /**
  238. *必须false才会自动加上正确的Content-Type
  239. */
  240. contentType: false,
  241. /**
  242. * 必须false才会避开jQuery对 formdata 的默认处理
  243. * XMLHttpRequest会对 formdata 进行正确的处理
  244. */
  245. processData: false,
  246. success: function(result) {
  247. document.getElementById("upFile").outerHTML = document.getElementById("upFile").outerHTML;
  248. $("#upFile").change(function() {
  249. upload();
  250. });
  251. var r = $.parseJSON(result);
  252. if(r.state.toLowerCase() == "success") {
  253. downurl = r.data;
  254. layer.msg(r.message);
  255. $(r.data).each(function(i, n) {
  256. $('.fjnr').text(n.filename);
  257. })
  258. }
  259. }
  260. });
  261. } else {
  262. layer.confirm('请上传文件!', {
  263. btn: ['确定']
  264. });
  265. }
  266. }
  267. </script>
  268. </body>
  269. </html>