repair_fault.html 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>故障维修</title>
  8. <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
  9. <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  10. <link rel="stylesheet" href="https://unpkg.com/vant@2.12/lib/index.css">
  11. <script src="https://unpkg.com/vue@2.6/dist/vue.min.js"></script>
  12. <script src="https://unpkg.com/vant@2.12/lib/vant.min.js"></script>
  13. <style>
  14. *{
  15. margin:0;
  16. padding:0;
  17. box-sizing: border-box;
  18. }
  19. body,html{
  20. background:#F4F8FB;
  21. }
  22. .container{
  23. width:100%;
  24. height:100%;
  25. background:#F4F8FB;
  26. background:url('/images/custom/bg.png') no-repeat top;
  27. background-size:100%;
  28. position:absolute;
  29. top:0;
  30. padding:15px;
  31. box-sizing: border-box;
  32. }
  33. .content{
  34. background:white;
  35. width:100%;
  36. border-radius: 20px;
  37. margin-top:180px;
  38. box-sizing: border-box;
  39. padding:20px;
  40. padding-bottom:10px;
  41. }
  42. .submit{
  43. background:#3F6FFF;
  44. border-radius: 30px;
  45. width:100%;
  46. color:white;
  47. border:none;
  48. margin:20px 0;
  49. padding:10px;
  50. }
  51. .item{
  52. padding-bottom:10px;
  53. border-bottom: 1px solid #F0F0F0;
  54. background:white;
  55. margin-bottom:20px;
  56. }
  57. .border_none{
  58. border:none;
  59. margin-bottom:0;
  60. }
  61. .title{
  62. display:flex;
  63. align-items: center;
  64. background:white;
  65. }
  66. span{
  67. margin-top:0;
  68. color:red;
  69. background:white;
  70. width:7px;
  71. }
  72. p{
  73. font-size:13px;
  74. background:white;
  75. }
  76. input{
  77. font-size:14px;
  78. margin-top:0px;
  79. padding:5px 7px;
  80. width:100%;
  81. border:none;
  82. background:white;
  83. }
  84. .file{
  85. margin-top:5px;
  86. margin-left:7px;
  87. }
  88. .van-toast{
  89. background:black;
  90. }
  91. .nav {
  92. text-align: center;
  93. margin: 8px auto;
  94. color: #fff;
  95. font-weight: bold;
  96. font-size: 20px;
  97. }
  98. </style>
  99. </head>
  100. <body>
  101. <div id="app">
  102. <div class="container">
  103. <div class="nav">故障记录</div>
  104. <div class="content">
  105. <div class="item">
  106. <div class="title">
  107. <span>*</span>
  108. <p>故障地点及状态描述</p>
  109. </div>
  110. <input type="text" placeholder="请填写响应内容" v-model="describe">
  111. </div>
  112. <div class="item">
  113. <div class="title">
  114. <span>*</span>
  115. <p>申诉人</p>
  116. </div>
  117. <input type="text" placeholder="请填写申诉人姓名" v-model="people">
  118. </div>
  119. <div class="item">
  120. <div class="title">
  121. <span>*</span>
  122. <p>申诉电话</p>
  123. </div>
  124. <input type="text" placeholder="请填写相关电话" v-model="phone">
  125. </div>
  126. <div class="item">
  127. <div class="title">
  128. <span></span>
  129. <p>其他事项</p>
  130. </div>
  131. <input type="text" placeholder="请填写其他事项" v-model="other">
  132. </div>
  133. <div class="item border_none">
  134. <div class="title">
  135. <span>*</span>
  136. <p>现场照片</p>
  137. </div>
  138. <van-uploader v-model="picture" :after-read="uploadImage" :deletable="false" multiple :max-count="9" class="file">
  139. </div>
  140. </div>
  141. <button class="submit" @click="submit">提交</button>
  142. </div>
  143. <script>
  144. // import { showToast } from 'vant';
  145. new Vue({
  146. el:'#app',
  147. data(){
  148. return {
  149. describe:'',
  150. people:'',
  151. phone:'',
  152. other:'',
  153. picture:[],
  154. id_list:[]
  155. }
  156. },
  157. methods:{
  158. submit(){
  159. if(this.describe == ''){
  160. vant.Toast('故障地点及状态描述不能为空');
  161. return;
  162. }
  163. if(this.people == ''){
  164. vant.Toast('申诉人不能为空');
  165. return;
  166. }
  167. if(this.phone == ''){
  168. vant.Toast('申诉电话不能为空');
  169. return;
  170. }
  171. let reg = /^1[3456789][0-9]{9}$/
  172. if (!reg.test(this.phone)) {
  173. vant.Toast('手机号码格式不正确');
  174. return
  175. }
  176. if(this.picture.length == 0){
  177. vant.Toast('请上传现场照片');
  178. return
  179. }
  180. const data = {
  181. site:this.describe,
  182. reporter:this.people,
  183. mobile:this.phone,
  184. other_info:this.other,
  185. pic:this.id_list
  186. }
  187. console.log(data)
  188. // const formData = new FormData();
  189. // formData.append('site', this.describe);
  190. // formData.append('reporter', this.people);
  191. // formData.append('mobile', this.phone);
  192. // formData.append('other_info', this.other);
  193. // formData.append('pic', this.id_list);
  194. // axios.post('http://oa.test/api.php?m=openRepairFault&a=add&openkey=d9302364e2a2d9fdcab2707a46fbab5a',data)
  195. axios({
  196. method: 'post',
  197. url: 'http://zq.oa.nxjiewei.com:8011/api.php?m=openRepairFault&a=add&openkey=d9302364e2a2d9fdcab2707a46fbab5a',
  198. data: JSON.stringify(data),
  199. headers: {
  200. 'Content-Type': 'multipart/form-data'
  201. }
  202. })
  203. .then(function (res) {
  204. console.log(res)
  205. })
  206. .catch(function (error) {
  207. console.log(error);
  208. });
  209. },
  210. uploadImage(file) {
  211. const files = file.file;
  212. const formData = new FormData();
  213. formData.append('file', files);
  214. axios({
  215. method: 'post',
  216. url: 'http://zq.oa.nxjiewei.com:8011/api.php?m=openupfile&a=upfile&openkey=d9302364e2a2d9fdcab2707a46fbab5a',
  217. data: formData,
  218. headers: {
  219. 'Content-Type': 'multipart/form-data'
  220. }
  221. })
  222. .then(response => {
  223. console.log('上传成功:', response);
  224. this.id_list.push(response.data.id)
  225. })
  226. .catch(error => {
  227. console.error('上传失败:', error);
  228. });
  229. }
  230. }
  231. });
  232. </script>
  233. </body>
  234. </html>