addRepair.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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" placeholder="请输入"/>
  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. userType: getUserLocalStorageInfo().userType
  105. },
  106. submitUser:getUserLocalStorageInfo().username + '-' + getUserLocalStorageInfo().phone,
  107. checkList:[
  108. // {name:'挂件安装'},
  109. // {name:'我要投诉'},
  110. // {name:'疏通管道'},
  111. // {name:'维修线路'},
  112. // {name:'更换灯泡'},
  113. // {name:'网络维修'},
  114. // {name:'保洁服务'},
  115. // {name:'其他维修'},
  116. ],
  117. quickSleced: {},
  118. fileList:[],
  119. dic_SelectList:[]
  120. }
  121. },
  122. created(){
  123. this.getByCodes()
  124. },
  125. mounted(){
  126. },
  127. methods:{
  128. showClick(e){
  129. console.log(e)
  130. },
  131. changeIpt(e){
  132. this.form.description = e.detail
  133. },
  134. onChange(e){
  135. // console.log(e)
  136. this.form.type = e.detail
  137. },
  138. onChange2(e){
  139. // console.log(e)
  140. this.form.position = e.detail
  141. },
  142. async getByCodes() {
  143. let data = await getByCodes(JSON.stringify(this.dc_key));
  144. this.dic_SelectList = this.$common.handleDicList(data);
  145. this.checkList = this.dic_SelectList.QUICK_SELECTION
  146. },
  147. toRecord() {
  148. uni.navigateTo({
  149. url:'/pages/subPackages/reportRepair/repairRecord'
  150. })
  151. },
  152. clickCheck(item){
  153. if (this.quickSleced.value && this.quickSleced.value === item.value) {
  154. this.quickSleced = {}
  155. } else {
  156. this.quickSleced = item
  157. // this.form.description = item.lable
  158. this.$set(this.form, 'description', item.label)
  159. }
  160. },
  161. submit(){
  162. if (this.quickSleced.value == null || this.quickSleced.value === '') {
  163. uni.showToast({
  164. title: '请选择服务类型',
  165. icon: 'none',
  166. mask: true,
  167. duration: 1000
  168. });
  169. return
  170. }
  171. if (this.fileList.length <= 0 || !this.fileList){
  172. uni.showToast({
  173. title: '请上传补充说明图片',
  174. icon: 'none',
  175. mask: true,
  176. duration: 1000
  177. });
  178. return
  179. }
  180. let picArr = []
  181. this.fileList.forEach(item=>{
  182. // console.log(item)
  183. picArr.push(item)
  184. })
  185. this.form.fileUrl = JSON.stringify(picArr)
  186. this.form.serviceType = this.quickSleced.value
  187. this.form.createdBy = this.getUserLocalStorageInfo.userId
  188. repairAdd(this.form).then((res) => {
  189. uni.showToast({
  190. title: '填报成功',
  191. icon: 'success',
  192. mask: true,
  193. duration: 1000
  194. });
  195. uni.navigateBack()
  196. })
  197. },
  198. deleteRYXXZP(event) {
  199. this.fileList.splice(event.detail.index, 1);
  200. this.$forceUpdate();
  201. },
  202. uploadRYXXZP(event) {
  203. // console.log(event)
  204. let that = this;
  205. const { file } = event.detail;
  206. console.log(event.detail)
  207. uni.uploadFile({
  208. url: that.$constant.BASE_URI + "/wx/fileController/upload",
  209. filePath: file.url,
  210. name: "file",
  211. formData: { user: "test" },
  212. success(res) {
  213. // 上传完成需要更新 fileList
  214. let data = JSON.parse(res.data);
  215. if (event.detail.file.type==='image'){
  216. that.fileList.push({
  217. imgUrl: "/FileController/download/" + data.data[0],
  218. id: data.data[0],
  219. url:
  220. that.$constant.BASE_URI +
  221. "/FileController/download/" +
  222. data.data[0],
  223. type:event.detail.file.type,
  224. isImage:true,
  225. });
  226. }else{
  227. that.fileList.push({
  228. imgUrl: "/FileController/download/" + data.data[0],
  229. id: data.data[0],
  230. url:
  231. that.$constant.BASE_URI +
  232. "/FileController/download/" +
  233. data.data[0],
  234. type:event.detail.file.type,
  235. isVideo:true
  236. });
  237. }
  238. },
  239. fail(res) {},
  240. });
  241. },
  242. }
  243. }
  244. </script>
  245. <style lang="scss">
  246. .reportRepair{
  247. .reportBody{
  248. margin-top: 24rpx;
  249. padding: 38rpx 36rpx;
  250. background: white;
  251. //height: 1416rpx;
  252. box-sizing: border-box;
  253. .record {
  254. display: flex;
  255. align-items: center;
  256. justify-content: flex-end;
  257. color: #0365F9;
  258. font-size: 32rpx;
  259. .recordImg{
  260. width: 36rpx;
  261. height: 36rpx;
  262. padding: 5rpx 0 0 10rpx;
  263. }
  264. }
  265. .detailUl{
  266. margin-top: 20rpx;
  267. .liName{
  268. font-size: 32rpx;
  269. color: rgba(51, 51, 51, 1);
  270. white-space: nowrap;
  271. }
  272. .detailLi{
  273. display: flex;
  274. justify-content: space-between;
  275. align-items: center;
  276. padding: 32rpx 0;
  277. border-bottom: 2rpx solid #E6E6E6;
  278. .liInfo{
  279. display: flex;
  280. justify-content: flex-end;
  281. gap: 0 64prx;
  282. max-width: 428rpx;
  283. color: rgba(102, 102, 102, 1);
  284. font-size: 32rpx;
  285. line-height: 38rpx;
  286. }
  287. .van-radio-group{
  288. display: flex;
  289. align-items: center;
  290. gap: 0 32rpx;
  291. }
  292. }
  293. .detailLi2{
  294. display: flex;
  295. flex-direction: column;
  296. padding: 32rpx 0;
  297. border-bottom: 2rpx solid #E6E6E6;
  298. .detailLi2BoxTop{
  299. display: flex;
  300. flex-wrap: wrap;
  301. justify-content: space-between;
  302. margin: 12rpx 0;
  303. .checkItem{
  304. width: 160rpx;
  305. height: 64rpx;
  306. font-size: 28rpx;
  307. color: #666666;
  308. display: flex;
  309. align-items: center;
  310. justify-content: center;
  311. background: #F5F7FA;
  312. border-radius: 8rpx;
  313. margin: 12rpx 0;
  314. }
  315. .checked{
  316. background: #0365F9;
  317. color: white;
  318. }
  319. }
  320. }
  321. }
  322. }
  323. .van-cell {
  324. background: #F5F7FA !important;
  325. border-radius: 8rpx;
  326. font-size: 28rpx;
  327. }
  328. .buttonBox{
  329. display: flex;
  330. justify-content: center;
  331. .btn{
  332. width: 240rpx;
  333. height: 80rpx;
  334. display: flex;
  335. border-radius: 8rpx;
  336. align-items: center;
  337. justify-content: center;
  338. margin: 48rpx 16rpx 150rpx 16rpx;
  339. color: white;
  340. letter-spacing: 2rpx;
  341. text-indent: 2rpx;
  342. }
  343. .zcBtn{
  344. background: #FE8643;
  345. }
  346. .tjBtn{
  347. background: #0365F9;
  348. }
  349. }
  350. }
  351. </style>