addRepair.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <div class="reportRepair">
  3. <div class="reportBody">
  4. <ul class="detailUl">
  5. <li class="detailLi">
  6. <span class="liName">当前企业</span>
  7. <input class="liInfo" style="text-align: right" v-model="form.companyName"/>
  8. </li>
  9. <li class="detailLi">
  10. <span class="liName">
  11. <span style="color: red;margin-right: 10rpx;">*</span>
  12. 您是想
  13. </span>
  14. <van-radio-group :value="form.type" @change="onChange">
  15. <van-radio name="1">报事</van-radio>
  16. <van-radio name="2">咨询</van-radio>
  17. </van-radio-group>
  18. </li>
  19. <li class="detailLi2">
  20. <span class="liName">
  21. 快捷选择
  22. </span>
  23. <div class="detailLi2Box">
  24. <div class="detailLi2BoxTop">
  25. <div class="checkItem" :class="{
  26. checked: quickSleced.value && item.value === quickSleced.value,
  27. }" v-for="item in checkList" @click="clickCheck(item)">{{item.label}}</div>
  28. </div>
  29. <van-field
  30. :value="form.description"
  31. autosize
  32. type="textarea"
  33. placeholder="请输入文字进行报事报修描述"
  34. class="myField"
  35. maxlength="800"
  36. show-word-limit
  37. @input="changeIpt"
  38. />
  39. </div>
  40. </li>
  41. <li class="detailLi">
  42. <span class="liName">
  43. <span style="color: red;margin-right: 10rpx;">*</span>
  44. 位置
  45. </span>
  46. <van-radio-group :value="form.position" @change="onChange2">
  47. <van-radio name="1">室内</van-radio>
  48. <van-radio name="2">公区</van-radio>
  49. </van-radio-group>
  50. </li>
  51. <li class="detailLi2">
  52. <span class="liName">
  53. 补充说明
  54. <span style="color: #B3B3B3;font-size: 28rpx">(支持图片/视频上传限20M内,最多6张)</span>
  55. </span>
  56. <div class="detailLi2Box" style="margin: 24rpx 0 0 0">
  57. <van-uploader
  58. accept="media"
  59. :max-count="6"
  60. @delete="deleteRYXXZP"
  61. :file-list="fileList"
  62. @after-read="uploadRYXXZP"
  63. :show-upload="true"
  64. @click-preview="showClick"
  65. />
  66. </div>
  67. </li>
  68. <li class="detailLi" style="border-bottom: none">
  69. <span class="liName">
  70. 报事人
  71. </span>
  72. <span class="liInfo">
  73. {{submitUser}}
  74. </span>
  75. </li>
  76. </ul>
  77. </div>
  78. <div class="buttonBox">
  79. <button class="btn zcBtn">暂存</button>
  80. <button class="btn tjBtn" @tap="submit">提交</button>
  81. </div>
  82. </div>
  83. </template>
  84. <script>
  85. import { repairAdd,getUserLocalStorageInfo,getByCodes, getCompanyById} from "@/js_sdk/http";
  86. import dayjs from "dayjs";
  87. export default {
  88. data(){
  89. return{
  90. getUserLocalStorageInfo: getUserLocalStorageInfo(),
  91. dc_key: ['QUICK_SELECTION'],
  92. isCheck:false,
  93. isCheck2:false,
  94. form: {
  95. groupId: '',
  96. companyId: getUserLocalStorageInfo().userId,
  97. type: '1',
  98. serviceType: '',
  99. description: '',
  100. position: '1',
  101. userId:getUserLocalStorageInfo().userId + '-' + getUserLocalStorageInfo().username + '-' + getUserLocalStorageInfo().phone,
  102. fileUrl: '',
  103. status: 'unAcceptance'
  104. },
  105. submitUser:getUserLocalStorageInfo().username + '-' + getUserLocalStorageInfo().phone,
  106. checkList:[
  107. // {name:'挂件安装'},
  108. // {name:'我要投诉'},
  109. // {name:'疏通管道'},
  110. // {name:'维修线路'},
  111. // {name:'更换灯泡'},
  112. // {name:'网络维修'},
  113. // {name:'保洁服务'},
  114. // {name:'其他维修'},
  115. ],
  116. quickSleced: {},
  117. fileList:[],
  118. dic_SelectList:[]
  119. }
  120. },
  121. created(){
  122. this.getByCodes()
  123. },
  124. mounted(){
  125. },
  126. methods:{
  127. showClick(e){
  128. console.log(e)
  129. },
  130. changeIpt(e){
  131. this.form.description = e.detail
  132. },
  133. onChange(e){
  134. // console.log(e)
  135. this.form.type = e.detail
  136. },
  137. onChange2(e){
  138. // console.log(e)
  139. this.form.position = e.detail
  140. },
  141. async getByCodes() {
  142. let data = await getByCodes(JSON.stringify(this.dc_key));
  143. this.dic_SelectList = this.$common.handleDicList(data);
  144. this.checkList = this.dic_SelectList.QUICK_SELECTION
  145. },
  146. toRecord() {
  147. uni.navigateTo({
  148. url:'/pages/subPackages/reportRepair/repairRecord'
  149. })
  150. },
  151. clickCheck(item){
  152. if (this.quickSleced.value && this.quickSleced.value === item.value) {
  153. this.quickSleced = {}
  154. } else {
  155. this.quickSleced = item
  156. // this.form.description = item.lable
  157. this.$set(this.form, 'description', item.label)
  158. }
  159. },
  160. submit(){
  161. if (this.quickSleced.value == null || this.quickSleced.value === '') {
  162. uni.showToast({
  163. title: '请选择服务类型',
  164. icon: 'none',
  165. mask: true,
  166. duration: 1000
  167. });
  168. return
  169. }
  170. if (this.fileList.length <= 0 || !this.fileList){
  171. uni.showToast({
  172. title: '请上传补充说明图片',
  173. icon: 'none',
  174. mask: true,
  175. duration: 1000
  176. });
  177. return
  178. }
  179. let picArr = []
  180. this.fileList.forEach(item=>{
  181. // console.log(item)
  182. picArr.push(item)
  183. })
  184. this.form.fileUrl = JSON.stringify(picArr)
  185. this.form.serviceType = this.quickSleced.value
  186. this.form.createdBy = this.getUserLocalStorageInfo.userId
  187. repairAdd(this.form).then((res) => {
  188. uni.showToast({
  189. title: '填报成功',
  190. icon: 'success',
  191. mask: true,
  192. duration: 1000
  193. });
  194. uni.navigateBack()
  195. })
  196. },
  197. deleteRYXXZP(event) {
  198. this.fileList.splice(event.detail.index, 1);
  199. this.$forceUpdate();
  200. },
  201. uploadRYXXZP(event) {
  202. // console.log(event)
  203. let that = this;
  204. const { file } = event.detail;
  205. console.log(event.detail)
  206. uni.uploadFile({
  207. url: that.$constant.BASE_URI + "/wx/fileController/upload",
  208. filePath: file.url,
  209. name: "file",
  210. formData: { user: "test" },
  211. success(res) {
  212. // 上传完成需要更新 fileList
  213. let data = JSON.parse(res.data);
  214. if (event.detail.file.type==='image'){
  215. that.fileList.push({
  216. imgUrl: "/FileController/download/" + data.data[0],
  217. id: data.data[0],
  218. url:
  219. that.$constant.BASE_URI +
  220. "/FileController/download/" +
  221. data.data[0],
  222. type:event.detail.file.type,
  223. isImage:true,
  224. });
  225. }else{
  226. that.fileList.push({
  227. imgUrl: "/FileController/download/" + data.data[0],
  228. id: data.data[0],
  229. url:
  230. that.$constant.BASE_URI +
  231. "/FileController/download/" +
  232. data.data[0],
  233. type:event.detail.file.type,
  234. isVideo:true
  235. });
  236. }
  237. },
  238. fail(res) {},
  239. });
  240. },
  241. }
  242. }
  243. </script>
  244. <style lang="scss">
  245. .reportRepair{
  246. .reportBody{
  247. margin-top: 24rpx;
  248. padding: 38rpx 36rpx;
  249. background: white;
  250. //height: 1416rpx;
  251. box-sizing: border-box;
  252. .record {
  253. display: flex;
  254. align-items: center;
  255. justify-content: flex-end;
  256. color: #0365F9;
  257. font-size: 32rpx;
  258. .recordImg{
  259. width: 36rpx;
  260. height: 36rpx;
  261. padding: 5rpx 0 0 10rpx;
  262. }
  263. }
  264. .detailUl{
  265. margin-top: 20rpx;
  266. .liName{
  267. font-size: 32rpx;
  268. color: rgba(51, 51, 51, 1);
  269. white-space: nowrap;
  270. }
  271. .detailLi{
  272. display: flex;
  273. justify-content: space-between;
  274. align-items: center;
  275. padding: 32rpx 0;
  276. border-bottom: 2rpx solid #E6E6E6;
  277. .liInfo{
  278. display: flex;
  279. justify-content: flex-end;
  280. gap: 0 64prx;
  281. max-width: 428rpx;
  282. color: rgba(102, 102, 102, 1);
  283. font-size: 32rpx;
  284. line-height: 38rpx;
  285. }
  286. .van-radio-group{
  287. display: flex;
  288. align-items: center;
  289. gap: 0 32rpx;
  290. }
  291. }
  292. .detailLi2{
  293. display: flex;
  294. flex-direction: column;
  295. padding: 32rpx 0;
  296. border-bottom: 2rpx solid #E6E6E6;
  297. .detailLi2BoxTop{
  298. display: flex;
  299. flex-wrap: wrap;
  300. justify-content: space-between;
  301. margin: 12rpx 0;
  302. .checkItem{
  303. width: 160rpx;
  304. height: 64rpx;
  305. font-size: 28rpx;
  306. color: #666666;
  307. display: flex;
  308. align-items: center;
  309. justify-content: center;
  310. background: #F5F7FA;
  311. border-radius: 8rpx;
  312. margin: 12rpx 0;
  313. }
  314. .checked{
  315. background: #0365F9;
  316. color: white;
  317. }
  318. }
  319. }
  320. }
  321. }
  322. .van-cell {
  323. background: #F5F7FA !important;
  324. border-radius: 8rpx;
  325. font-size: 28rpx;
  326. }
  327. .buttonBox{
  328. display: flex;
  329. justify-content: center;
  330. .btn{
  331. width: 240rpx;
  332. height: 80rpx;
  333. display: flex;
  334. border-radius: 8rpx;
  335. align-items: center;
  336. justify-content: center;
  337. margin: 48rpx 16rpx 150rpx 16rpx;
  338. color: white;
  339. letter-spacing: 2rpx;
  340. text-indent: 2rpx;
  341. }
  342. .zcBtn{
  343. background: #FE8643;
  344. }
  345. .tjBtn{
  346. background: #0365F9;
  347. }
  348. }
  349. }
  350. </style>