Нет описания

updatingFiles.html 9.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <script src="../Script/Common/huayi.load.js"></script>
  6. <script src="../Script/Common/huayi.config.js"></script>
  7. <link href="../css/layer/need/layer.css" />
  8. <link rel="stylesheet" href="../css/init.css" />
  9. <title>诉求单结案</title>
  10. <style type="text/css">
  11. .isStandard,
  12. .bulletUnit {
  13. display: none;
  14. }
  15. .bulletUnit ul {
  16. list-style: none;
  17. margin: 0;
  18. padding: 0;
  19. }
  20. .bulletUnit ul li {
  21. float: left;
  22. margin-right: 20px;
  23. text-align: center;
  24. padding: 6px 0;
  25. }
  26. .bulletUnit li input {
  27. display: none;
  28. }
  29. .bulletUnit li label {
  30. margin: 0;
  31. font-weight: normal;
  32. display: block;
  33. width: 100%;
  34. border: 1px solid #ccc;
  35. padding: 2px 10px;
  36. cursor: pointer;
  37. }
  38. .bulletUnit .checkedDept {
  39. border-color: #fe6604;
  40. }
  41. select:disabled {
  42. background-color: #eee;
  43. }
  44. .reasons {
  45. display: none;
  46. height: 160px;
  47. }
  48. #reasons {
  49. height: 160px;
  50. }
  51. #msg1,
  52. #msg2,
  53. #msg3,
  54. #phone {
  55. border: none;
  56. border-bottom: 1px solid #ccc;
  57. margin-bottom: 20px;
  58. background-color: #FFFFFF;
  59. color: #00a1cb;
  60. }
  61. #msg4 {
  62. width: 250px;
  63. height: 50px;
  64. border: none;
  65. border-bottom: 1px solid #ccc;
  66. margin-bottom: 20px;
  67. vertical-align: top;
  68. }
  69. #msg2 {
  70. vertical-align: top;
  71. height: 25px;
  72. }
  73. #msg1:focus,
  74. #msg2:focus,
  75. #msg3:focus,
  76. #msg4:focus,
  77. #phone:focus {
  78. outline: none;
  79. }
  80. </style>
  81. </head>
  82. <body>
  83. <div class="Common">
  84. <table>
  85. <tr class="files-wrappper">
  86. <th class="Importent updatingFiles">上传扫描件:</th>
  87. <td colspan="5">
  88. <div class="fileBox">
  89. </div>
  90. <!--<span class="fjnr"></span>-->
  91. <input class="input" type="file" name="upFile" id="upFile" multiple="multiple" style="display: none;">
  92. <input class="input" type="button" value="上传" id="scwj" />
  93. <!--<input class="input" type="button" value="删除附件" id="scfj" style="display:none;" />-->
  94. <input type="hidden" id="file" />
  95. <span style="color:#FF0000; border: none;">
  96. (文件格式为png,jpg,pdf,doc,docx)
  97. </span>
  98. </td>
  99. </tr>
  100. </table>
  101. <div class="btn_box">
  102. <button class="btns_save">保存</button>
  103. </div>
  104. </div>
  105. <input type="hidden" name="depID" id="depID" value="" />
  106. <script src="../js/adjustHeight.js"></script>
  107. <script>
  108. var wid = helper.request.queryString("wid");
  109. var fileType = helper.request.queryString("fileType");
  110. console.log(fileType)
  111. $(document).ready(function () {
  112. if (fileType =="2") {
  113. getFiles()
  114. } else if(fileType =="1"){
  115. $(".updatingFiles").text("上传附件")
  116. getFile()
  117. }else{
  118. getFiles()
  119. }
  120. //上传附件
  121. $("#scwj").click(function () {
  122. $("#upFile").trigger("click");
  123. })
  124. $("#upFile").change(function () {
  125. upload();
  126. })
  127. $(".btns_save").click(function () {
  128. if (fileType =="2") {
  129. JA();
  130. }else if(fileType =="1"){
  131. JAs()
  132. }else{
  133. JA()
  134. }
  135. });
  136. })
  137. function JA(bUnits) {
  138. $.post(huayi.config.callcenter_url + 'WorkOrder/AddFiles', {
  139. workorderid: wid,
  140. files: $("#file").val(),
  141. token: $.cookie("token"),
  142. }, function (result) {
  143. result = JSON.parse(result);
  144. if (result.state.toLowerCase() == "success") {
  145. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  146. parent.layer.close(index); //再执行关闭
  147. if (fileType) {
  148. parent.load()
  149. }else{
  150. parent.$('#orderlist').bootstrapTable('refresh');
  151. }
  152. parent.layer.msg("上传成功");
  153. }
  154. })
  155. }
  156. function JAs(bUnits) {
  157. $.post(huayi.config.callcenter_url + 'WorkOrder/saveFile', {
  158. fid: wid,
  159. file: $("#file").val(),
  160. token: $.cookie("token"),
  161. }, function (result) {
  162. result = JSON.parse(result);
  163. if (result.state.toLowerCase() == "success") {
  164. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  165. parent.layer.close(index); //再执行关闭
  166. if (fileType) {
  167. parent.load()
  168. }else{
  169. parent.$('#orderlist').bootstrapTable('refresh');
  170. }
  171. parent.layer.msg("上传成功");
  172. }
  173. })
  174. }
  175. // WorkOrder/getFile
  176. function getFiles(){
  177. $.ajax({
  178. type:"get",
  179. url:huayi.config.callcenter_url+"WorkOrder/getFiles",
  180. dataType:"json",
  181. async:true,
  182. data:{
  183. workorderid:wid,
  184. token: $.cookie("token")
  185. },
  186. success:function(res){
  187. if (res.state.toLowerCase() ==="success") {
  188. var dataFile = res.data[0].Files
  189. console.log(dataFile)
  190. getDataFile(dataFile)
  191. }
  192. }
  193. });
  194. }
  195. function getFile(){
  196. $.ajax({
  197. type:"get",
  198. url:huayi.config.callcenter_url+"WorkOrder/getFile",
  199. dataType:"json",
  200. async:true,
  201. data:{
  202. fid:wid,
  203. token: $.cookie("token")
  204. },
  205. success:function(res){
  206. if (res.state.toLowerCase() ==="success") {
  207. var dataFile = res.data[0].File
  208. console.log(dataFile)
  209. getDataFile(dataFile)
  210. }
  211. }
  212. });
  213. }
  214. //上传文件
  215. function upload() {
  216. var Files = document.getElementById("upFile").files;
  217. if (Files.length > 0) {
  218. var formData = new FormData();
  219. for (var i = 0; i < Files.length; i++) {
  220. formData.append('file' + i, Files[i]);
  221. }
  222. formData.append("token", $.cookie("token"));
  223. var typeName=Files[0].name.split('.')[1];
  224. if (typeName == "png" || typeName == 'jpg' || typeName =='pdf'|| typeName =='doc'|| typeName =='docx') {
  225. $.ajax({
  226. url: huayi.config.callcenter_url + "/WorkOrder/UploadFile",
  227. type: "POST",
  228. data: formData,
  229. /**
  230. *必须false才会自动加上正确的Content-Type
  231. */
  232. contentType: false,
  233. /**
  234. * 必须false才会避开jQuery对 formdata 的默认处理
  235. * XMLHttpRequest会对 formdata 进行正确的处理
  236. */
  237. processData: false,
  238. success: function (result) {
  239. document.getElementById("upFile").outerHTML = document.getElementById("upFile").outerHTML;
  240. $("#upFile").change(function () {
  241. upload();
  242. });
  243. var r = $.parseJSON(result);
  244. if (r.state.toLowerCase() == "success") {
  245. $(".fjnr").text(r.data[0].F_FileName);
  246. var fileData =r.data
  247. getDataFile(fileData)
  248. }
  249. }
  250. });
  251. }else{
  252. layer.msg("格式不正确");
  253. }
  254. } else {
  255. layer.confirm('请上传文件!', {
  256. btn: ['确定']
  257. });
  258. }
  259. }
  260. //上传文件隐藏域值
  261. function file_num() {
  262. var str = '';
  263. var Str;
  264. $('.fileBox .files').each(function (j, m) {
  265. var aa = $(m).attr("fiel-num")
  266. console.log(aa);
  267. str += aa + ",";
  268. Str = (str.substring(str.length - 1) == ',') ? str.substring(0, str.length - 1) : str;
  269. })
  270. $("#file").val(Str);
  271. }
  272. function getDataFile(getDataFile){
  273. $(getDataFile).each(function (i, n) {
  274. var strs = '<span class="files" fiel-num="' + n.F_FileId + '">' + n.F_FileName.substring(19) + '<i class="fa fa-remove del_file"></i></span>'
  275. $(strs).appendTo($('.fileBox')).find('.del_file').click(function (event) {
  276. event.stopPropagation();
  277. $(this).parent().remove();
  278. file_num()
  279. })
  280. })
  281. file_num()
  282. }
  283. </script>
  284. </body>
  285. </html>