index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <div class="repair-box">
  3. <div class="repair-content fixed-page-content">
  4. <div class="white-box page-1">
  5. <div class="page-1-head" @click="goNavigator('repairRecord')">
  6. <i class="iconfont icon-daichulihetong"></i>
  7. <span>报事记录</span>
  8. </div>
  9. </div>
  10. <div class="white-box page-2">
  11. <div class="cell-item">
  12. <p class="label">当前企业</p>
  13. <p class="tit">{{companyName}}</p>
  14. </div>
  15. <div class="cell-item">
  16. <p class="label required">您是想</p>
  17. <div class="tit">
  18. <van-radio-group v-model="form.type">
  19. <van-radio name="1" checked-color="#976CEB" >报事</van-radio>
  20. <van-radio name="2" checked-color="#976CEB">咨询</van-radio>
  21. </van-radio-group>
  22. </div>
  23. </div>
  24. <div class="block-cell-item">
  25. <p class="label">快捷选择</p>
  26. <div class="tit">
  27. <ul class="custom-select-list">
  28. <li
  29. v-for="item in quickList"
  30. v-if="item.value!==''"
  31. :key="item.value"
  32. :class="{
  33. active: quickSleced.value && item.value === quickSleced.value,
  34. }"
  35. @click="quickSelect(item)"
  36. >
  37. {{ item.label }}
  38. </li>
  39. </ul>
  40. <van-field
  41. v-model="form.description"
  42. rows="4"
  43. autosize
  44. type="textarea"
  45. maxlength="100"
  46. placeholder="输入文字进行报事报修描述"
  47. show-word-limit
  48. >
  49. </van-field>
  50. </div>
  51. </div>
  52. </div>
  53. <div class="white-box page-3">
  54. <div class="cell-item">
  55. <p class="label required">位置</p>
  56. <div class="tit">
  57. <van-radio-group v-model="form.position">
  58. <van-radio
  59. :name="item.val"
  60. checked-color="#976CEB"
  61. v-for="item in positionList"
  62. :key="item.val"
  63. @change="changePosition(item.val)"
  64. >{{ item.lable }}</van-radio
  65. >
  66. </van-radio-group>
  67. </div>
  68. </div>
  69. <div class="block-cell-item">
  70. <p class="label">
  71. 补充说明<span
  72. class="tips"
  73. >(支持图片/视频上传限20M内,最多6张)</span
  74. >
  75. </p>
  76. <div class="tit">
  77. <van-uploader
  78. :multiple="true"
  79. v-model="fileUrls[0]"
  80. :max-count="6"
  81. :after-read="afterRead"
  82. :before-delete="beforeDelete"
  83. capture="camera"
  84. :accept="'image/*'"
  85. >
  86. </van-uploader>
  87. </div>
  88. </div>
  89. <div class="cell-item">
  90. <p class="label">报事人</p>
  91. <p class="tit">{{form.userId}}</p>
  92. </div>
  93. </div>
  94. </div>
  95. <div class="repair-bottom bottom-button">
  96. <button class="btn" @click="submit">提交</button>
  97. </div>
  98. </div>
  99. </template>
  100. <script>
  101. // import Base from '@/pages/base/base'
  102. // import axios from 'axios'
  103. // import { add } from '../../service/api_repair'
  104. // import { getCompanyById } from '@/service/api_road_show'
  105. import {
  106. add,
  107. getCompanyById2,
  108. } from "@/js_sdk/http";
  109. // import { Toast } from 'vant'
  110. // import auth from '@/service/auth'
  111. export default {
  112. data() {
  113. return {
  114. dc_key: ['QUICK_SELECTION'],
  115. reportTypeSleced: '1',
  116. quickSleced: {},
  117. quickList: [
  118. // {
  119. // val: '1',
  120. // lable: '挂件安装'
  121. // },
  122. ],
  123. positionSleced: '1',
  124. positionList: [
  125. {
  126. val: '1',
  127. lable: '室内'
  128. },
  129. {
  130. val: '2',
  131. lable: '公区'
  132. }
  133. ],
  134. fileUrlList: [],
  135. fileUrls: [],
  136. companyName: '',
  137. form: {
  138. groupId: '',
  139. companyId: '',
  140. type: '1',
  141. serviceType: '',
  142. description: '',
  143. position: '1',
  144. userId: auth.currUser().trueName + '-' + auth.currUser().phoneNo,
  145. fileUrl: '',
  146. status: 'unAcceptance'
  147. }
  148. }
  149. },
  150. // mixins: [Base],
  151. mounted() {
  152. this.initDict(this.dc_key).then((res) => {
  153. this.quickList = this.dc_data.QUICK_SELECTION
  154. })
  155. getCompanyById2({ id: auth.currUser().id, type: '2,3' }).then(res => {
  156. this.form.companyId = res.data.id
  157. this.companyName = res.data.businessName
  158. })
  159. },
  160. methods: {
  161. /**
  162. *
  163. */
  164. quickSelect(item) {
  165. if (this.quickSleced.value && this.quickSleced.value === item.value) {
  166. this.quickSleced = {}
  167. } else {
  168. this.quickSleced = item
  169. // this.form.description = item.lable
  170. this.$set(this.form, 'description', item.label)
  171. }
  172. },
  173. /**
  174. * 上传文件
  175. */
  176. afterRead(file) {
  177. if (file instanceof Array) {
  178. file.map((v) => {
  179. this.uploadImg(v)
  180. })
  181. } else {
  182. this.uploadImg(file)
  183. }
  184. },
  185. beforeDelete(file, detail) {
  186. // this.handleImagUrlList = []
  187. const vm = this
  188. // name.index代表图片的索引
  189. vm.fileUrlList.splice(detail.index, 1)
  190. return (file, name) => {
  191. const fileIndex = name.index
  192. vm.fileUrlList[detail.index].splice(fileIndex, 1)
  193. }
  194. },
  195. /**
  196. * 上传图片
  197. */
  198. uploadImg(file) {
  199. const _this = this
  200. const formParam = new FormData() // 创建form对象
  201. formParam.append('file', file.file)// 通过append向form对象添加数据
  202. console.log(formParam.get('file')) // FormData私有类对象,访问不到,可以通过get判断值是否传进去
  203. // upload(formParam).then((res) => {
  204. // console.log(res)
  205. // })
  206. const config = {
  207. headers: {
  208. 'Content-Type': 'multipart/form-data',
  209. 'MVVM-Key': String(new Date().getTime()),
  210. 'xx': 'anything'
  211. } // 这里是重点,需要和后台沟通好请求头,Content-Type不一定是这个值
  212. } // 添加请求头
  213. return new Promise((resolve, reject) => {
  214. axios.post('/smartParkH5Server/wx/fileController/upload', formParam, config)
  215. .then(response => {
  216. let files = response.data.data.substring(1, response.data.data.length)
  217. files = files.substring(0, files.length - 1)
  218. _this.fileUrlList.push(_this.$common.castEval(files))
  219. }).catch((err, x) => {
  220. reject(err, x)
  221. })
  222. })
  223. },
  224. submit() {
  225. if (this.quickSleced.value == null || this.quickSleced.value === '') {
  226. Toast('请选择服务类型')
  227. return
  228. }
  229. if(this.fileUrlList == null || this.fileUrlList == [] || this.fileUrlList == undefined || this.fileUrlList.length <= 0){
  230. Toast('请上传补充说明图片')
  231. return
  232. }
  233. this.form.groupId = '870261874875170816'// 园区
  234. this.form.fileUrl = JSON.stringify(this.fileUrlList)
  235. this.form.userId = auth.currUser().id + '-' + auth.currUser().trueName + '-' + auth.currUser().phoneNo
  236. this.form.serviceType = this.quickSleced.value
  237. this.form.createdBy = auth.currUser().id
  238. add(this.form).then((res) => {
  239. Toast('填报成功')
  240. this.$router.push({
  241. path: '/repairRecord'
  242. })
  243. })
  244. },
  245. changePosition(val) {
  246. }
  247. }
  248. }
  249. </script>
  250. <style lang="scss" scoped>
  251. .repair-box {
  252. width: 100%;
  253. height: 100%;
  254. .page-1 {
  255. font-size: 30px;
  256. color: var(--violetColor2);
  257. padding: 30px;
  258. box-sizing: border-box;
  259. .page-1-head {
  260. display: flex;
  261. align-items: center;
  262. justify-content: flex-end;
  263. i {
  264. font-size: 38px;
  265. margin-right: 10px;
  266. }
  267. }
  268. }
  269. .page-2 {
  270. .van-cell {
  271. padding: 20px;
  272. border-radius: 10px;
  273. background: $page-color-base;
  274. box-sizing: border-box;
  275. textarea {
  276. height: 60px;
  277. }
  278. }
  279. }
  280. }
  281. </style>