ProblemDeal.cshtml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. 
  2. @{
  3. ViewBag.Title = "ProblemDeal";
  4. Layout = "~/Views/MobileProblem/_APPMain.cshtml";
  5. }
  6. <link href="~/Content/Scripts/plugins/mui/css/webuploader.css" rel="stylesheet" />
  7. <script src="~/Content/Scripts/plugins/mui/js/webuploader.js"></script>
  8. <script src="https://cdn.staticfile.org/vue-resource/1.5.1/vue-resource.min.js"></script>
  9. <style>
  10. .SelectDiv {
  11. float: right;
  12. font-size: 14px;
  13. color: #8f8f94;
  14. }
  15. [v-cloak] {
  16. display: none !important;
  17. }
  18. .mui-btn-success{
  19. color: #fff;
  20. border: 1px solid #00aaff;
  21. background-color: #00aaff;
  22. }
  23. </style>
  24. <div id="vue" v-cloak>
  25. <header class="mui-bar mui-bar-nav">
  26. <a class="mui-icon mui-icon-left-nav mui-pull-left mui-action-back" style="color:#ffffff"></a>
  27. <h1 class="mui-title" style="color:white">问题处理</h1>
  28. </header>
  29. <nav class="mui-bar mui-bar-tab">
  30. <button v-on:click="ProblemDealSubmit()" type="button" class="mui-btn mui-btn-primary" style="width:90%;background-color: #2ab8ff;border:none;margin-left:5%">提交</button>
  31. </nav>
  32. <div class="mui-content mui-scroll-wrapper" id="scr1">
  33. <div class="mui-scroll">
  34. <template >
  35. <h5 style="font-size:15px;padding:10px 17px">处理说明</h5>
  36. <div class="mui-input-row" style="font-size:14px">
  37. <textarea v-model="DealDescribe" rows="6" placeholder="请填写相关说明描述" style="font-size:15px"></textarea>
  38. </div>
  39. </template>
  40. <ul class="mui-table-view mui-table-view-chevron">
  41. <li class="mui-table-view-cell">
  42. 是否完成
  43. <div id="Iscomplete" class="mui-switch mui-switch-mini ">
  44. <div class="mui-switch-handle"></div>
  45. </div>
  46. </li>
  47. <li v-if="Iscomplete" class="mui-table-view-cell">
  48. <a v-on:click="SelectVison" class="mui-navigate-right">
  49. 解决版本
  50. <div class="SelectDiv">{{Vision}}</div>
  51. </a>
  52. </li>
  53. </ul>
  54. @*<div v-if="Iscomplete" class="mui-input-row" style="margin-top:10px">
  55. <textarea v-model="SolutionPlan" rows="6" placeholder="请填写解决方案" style="font-size:15px"></textarea>
  56. </div>*@
  57. <ul id="fileList" class="mui-table-view mui-grid-view mui-grid-9" style="border-color:transparent;">
  58. </ul>
  59. <button style="margin:10px" id="pick" type="button" class="mui-btn mui-btn-success mui-icon mui-icon-plus">添加附件</button>
  60. <div style="display:none" id="picker">选择文件</div>
  61. <button style="margin-top: 30px;display:none;" id="ctlBtn" class="btn btn-default">开始上传</button>
  62. </div>
  63. </div>
  64. </div>
  65. <script>
  66. var ProblemId = '@ViewBag.ID';
  67. var ProcessId;
  68. var t;
  69. var Count = 0;
  70. var vm = new Vue({
  71. el: '#vue',
  72. data: {
  73. msg: 'Hello World!',
  74. ProblemId: ProblemId,
  75. Iscomplete: false,//是否完成
  76. VisionPicker: null,
  77. Vision: '',//解决版本
  78. DealDescribe: '',//处理描述
  79. SolutionPlan:''//解决方案
  80. }, created: function () {
  81. },
  82. methods: {
  83. ///获取存在问题产品的所有版本
  84. GetProblemVison:function(){
  85. var that = this;
  86. mui.post('/MobileProblem/GetProblemVison/' + ProblemId, {}, function (data) {
  87. var d = [];
  88. for (var i = 0; i < data.length; i++) {
  89. var c = {};
  90. c.value = data[i].ID;
  91. c.text = data[i].版本号;
  92. d.push(c);
  93. }
  94. that.VisionPicker.setData(d);
  95. }, 'json');
  96. },
  97. ///选择版本
  98. SelectVison: function () {
  99. var that = this;
  100. that.VisionPicker.show(function (items) {
  101. that.Vision = items[0].text;
  102. });
  103. },
  104. //提交处理请求
  105. ProblemDealSubmit:function(){
  106. var that=this;
  107. if(!this.DealDescribe){
  108. mui.toast('请填写处理描述');
  109. return;
  110. }
  111. t = mui.showLoading("处理中..", "div");
  112. //提交
  113. mui.post('/MobileProblem/ProblemDealSubmit/' + ProblemId,
  114. { ProblemID:ProblemId,
  115. DealDescribe:that.DealDescribe,
  116. Iscomplete:that.Iscomplete,
  117. Vision:that.Vision,
  118. SolutionPlan:that.SolutionPlan
  119. }, function (data) {
  120. if (data.code == 200) {
  121. ProcessId = data.msg;
  122. $("#ctlBtn").click();
  123. } else {
  124. mui.hideLoading(t);
  125. mui.toast(data.msg);
  126. }
  127. }, 'json');
  128. },
  129. //初始化
  130. Init: function () {
  131. var that = this;
  132. mui.init();
  133. mui('.mui-scroll-wrapper').scroll();
  134. this.GetProblemVison();
  135. this.VisionPicker = new mui.PopPicker();
  136. document.getElementById("Iscomplete").addEventListener("toggle", function (event) {
  137. that.Iscomplete = event.detail.isActive;
  138. })
  139. },
  140. //初始化上传接口
  141. InitUploader: function () {
  142. var $list = $("#fileList");
  143. var $btn = $("#ctlBtn");
  144. var uploader = WebUploader.create({
  145. auto: false,
  146. // swf文件路径
  147. swf: '/Content/Scripts/plugins/mui/js/Uploader.swf',
  148. // 文件接收服务端。
  149. server: '/MobileProblem/FlieUploadAndSave',
  150. // 选择文件的按钮。可选。
  151. // 内部根据当前运行是创建,可能是input元素,也可能是flash.
  152. pick: '#picker',
  153. // 不压缩image, 默认如果是jpeg,文件上传前会压缩一把再上传!
  154. resize: false
  155. });
  156. uploader.on('fileQueued', function (file) {
  157. $list.append('<li id="' + file.id + '" class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3"><span class="mui-icon mui-icon-upload"></span>' +
  158. '<div class="mui-media-body">' + file.name + '</div> </li>');
  159. });
  160. uploader.on('uploadSuccess', function (file,response) {
  161. var $li = $('#' + file.id),
  162. $error = $li.find('div.error');
  163. // 避免重复创建
  164. if (!$error.length) {
  165. $error = $('<div class="error" style="color:#4cd964;font-size:13px"></div>').appendTo($li);
  166. }
  167. $error.text('上传成功');
  168. if (response.code ==200) {
  169. Count += 1;
  170. }
  171. });
  172. uploader.on('uploadError', function (file) {
  173. var $li = $('#' + file.id),
  174. $error = $li.find('div.error');
  175. // 避免重复创建
  176. if (!$error.length) {
  177. $error = $('<div class="error" style="color:red;font-size:13px"></div>').appendTo($li);
  178. }
  179. $error.text('上传失败');
  180. });
  181. uploader.on('uploadComplete', function (file) {
  182. });
  183. uploader.on('uploadFinished', function () {
  184. mui.hideLoading(t);
  185. mui.toast("处理成功!成功上传" + Count + "个附件");
  186. setTimeout(function () {
  187. //mui.openWindow({
  188. // url: '/MobileProblem/ProblemDetail/' + ProblemId
  189. //});
  190. window.location.href = '/MobileProblem/ProblemDetail/'+ ProblemId
  191. }, 500);
  192. })
  193. $btn.on('click', function () {
  194. uploader.options.formData.ProcessId = ProcessId;
  195. uploader.upload();
  196. });
  197. document.getElementById('pick').addEventListener('tap', function () {
  198. $(".webuploader-element-invisible").click();
  199. });
  200. }
  201. },
  202. mounted: function () {
  203. this.Init();
  204. this.InitUploader();
  205. }
  206. })
  207. </script>