warrantyadd.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <view class="address">
  3. <uni-forms ref="form" class="flex1" :model="datainfo">
  4. <view class="adrbox">
  5. <view class="chtop flexc">
  6. <view class="line"></view>
  7. <view>报修信息</view>
  8. </view>
  9. <view class="plr15">
  10. <uni-forms-item label="项目" required name="maintenanceCategory">
  11. <picker range-key='dictLabel' :disabled="isdisabled" :value="bxlbidx" :range="bxlbList" @change='bindDateChange'>
  12. <view class="flexc">
  13. <view class="flex1 txr f13 co27" v-if="datainfo.maintenanceCategory&&!bxlb">{{statusFormats(datainfo.maintenanceCategory,bxlbList,'bxlb')}}</view>
  14. <view class="flex1 txr f13" v-else :class="bxlb?'co27':'coa'">{{bxlb||"请选择项目"}}</view>
  15. <view class="rimg"><image :src="rimg"></image></view>
  16. </view>
  17. </picker>
  18. </uni-forms-item>
  19. <uni-forms-item label="标题" required name="repairTitle">
  20. <view class="flexc">
  21. <uni-easyinput :disabled="isdisabled" v-model="datainfo.repairTitle" :inputBorder='false' placeholder="请输入报修标题" />
  22. <view class="rimg"></view>
  23. </view>
  24. </uni-forms-item>
  25. <uni-forms-item label="报修门户" name="portalId">
  26. <w-select
  27. style="margin-left: 20rpx;"
  28. v-model="chooseValue"
  29. :list='fwlist'
  30. valueName='label'
  31. keyName="value"
  32. :chosevalue="datainfo.houseAddress"
  33. :filterable='filterable'
  34. @change='getchange'
  35. >
  36. </w-select>
  37. </uni-forms-item>
  38. <uni-easyinput type="textarea" maxlength="200" :disabled="isdisabled" autoHeight v-model="datainfo.repairDetails" :inputBorder='false' placeholder="请详细描述您要报修的内容(最多可输入200字哦" />
  39. <view class="voice mb28">
  40. <view class="flexc" @click="getVoiceFn">
  41. <image :src="voice"></image>
  42. 语音输入
  43. </view>
  44. </view>
  45. </view>
  46. <!-- 图片 -->
  47. <view class="imgs">
  48. <block v-if="phofile&&phofile.length">
  49. <view class="img" v-for="(ite,idx) in phofile" :key="idx" @click="getPreview(idx,phofile)">
  50. <image :src="baseUrl+ite" class="pico"></image>
  51. <image :src="del" class="del" @click.stop="getDelFn(idx)"></image>
  52. </view>
  53. </block>
  54. <view class="addbox" @click="getaddImage">
  55. <image :src="photo" class="pico"></image>
  56. <view>添加图片</view>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="adrbox">
  61. <view class="plr15">
  62. <uni-forms-item label="联系方式" :disabled="isdisabled" name="phoneNumber">
  63. <view class="flexc">
  64. <uni-easyinput v-model="datainfo.phoneNumber" :inputBorder='false' placeholder="请输入联系方式" />
  65. <view class="rimg"></view>
  66. </view>
  67. </uni-forms-item>
  68. </view>
  69. </view>
  70. </uni-forms>
  71. <view class="rfbtn mt30" @click="getEditFn" v-if="isdisabled">修改</view>
  72. <view class="rfbtn mt30" @click="getSubmit" v-else>提交信息</view>
  73. <loading></loading>
  74. <voice-input :voiceflag="voiceflag" @getVoice="getVoice" @getClose="getvoiceClose"></voice-input>
  75. </view>
  76. </template>
  77. <script>
  78. import config from '@/config'
  79. const baseUrl = config.baseUrl
  80. import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
  81. import {uploadmore,selectValueKey} from '@/utils/common.js'
  82. import {houseInfolistNoPage} from "@/api/work/work.js"
  83. import {repairAdd,repairPut,repairDet} from "@/api/work/service.js"
  84. import {getDictionaryFn} from "@/api/system/user.js"
  85. import wSelect from "@/work/components/w-select/w-select.vue"
  86. import voiceInput from "@/news/components/popup/voice.vue"
  87. export default{
  88. components:{wSelect,voiceInput},
  89. data(){
  90. return{
  91. rimg:require('@/static/images/rimg.png'),
  92. check: require('@/mine/static/check.png'),
  93. ncheck: require('@/mine/static/ncheck.png'),
  94. voice: require('@/work/static/voice.png'),
  95. photo:require("@/work/static/service/photo.png"),
  96. del:require('@/work/static/service/rdel.png'),
  97. datainfo:{
  98. // "repairId":"",//报修ID
  99. "portalId":"",//门户id
  100. "houseAddress":"",//详细门牌号
  101. "repairTime":"",//报修时间
  102. "phoneNumber":"",//报修用户手机号码
  103. "repairTitle":"",//报修标题
  104. "maintenanceCategory":"",//报修类别
  105. "repairDetails":"",//报修详情
  106. "repairImages":"",//报修详情图片
  107. },
  108. checkflag:true,
  109. baseUrl:config.baseUrl,
  110. tabval:'0',
  111. phofile:[],
  112. bxlbList:[],
  113. bxlbidx:0,
  114. bxlb:"",
  115. id:'',
  116. ptype:"add",
  117. isdisabled:false,
  118. fwlist:[],
  119. chooseValue:'',
  120. filterable:true,
  121. userId:this.$store.state.user.userId,
  122. voiceflag:false,
  123. }
  124. },
  125. onLoad: function(e) {
  126. this.init();
  127. if(e.id){
  128. this.id=e.id;
  129. this.ptype='edit';
  130. // this.isdisabled=true;
  131. this.getDetailFn()
  132. }
  133. },
  134. methods:{
  135. checkPermi,checkRole,
  136. bindDateChange(e){
  137. var val=e.detail.value;
  138. this.datainfo.maintenanceCategory=this.bxlbList[val].dictValue;
  139. this.bxlb=this.bxlbList[val].dictLabel;
  140. },
  141. getVoiceFn(){
  142. this.voiceflag=true;
  143. },
  144. getvoiceClose(){
  145. this.voiceflag=false;
  146. },
  147. getVoice(data){
  148. this.datainfo.repairDetails=data;
  149. },
  150. getEditFn(){
  151. this.isdisabled=false;
  152. },
  153. statusFormats(data, list,type) {
  154. var aite=selectValueKey(list, data);
  155. if(type=='bxlb'){
  156. this.bxlbidx=aite.key
  157. }
  158. return aite.actions;
  159. },
  160. getchange(e){
  161. this.datainfo.portalId=e.value;
  162. this.datainfo.houseAddress=e.label;
  163. // this.datainfo.detailAddress=e.location;
  164. },
  165. init(){
  166. //报修类别
  167. getDictionaryFn('baoxiutype').then(res=>{
  168. if(res.code==200){
  169. this.bxlbList = res.data.map(v => {
  170. return {
  171. dictLabel: v.dictLabel,
  172. dictValue: v.dictValue
  173. }
  174. })
  175. }
  176. })
  177. // 自己的房屋
  178. var params={
  179. userId:this.userId,
  180. pageSize: 100,
  181. pageNum: 1,
  182. }
  183. houseInfolistNoPage(params).then(res=>{
  184. if(res.code==200){
  185. this.fwlist= res.rows.map(v => {
  186. return {
  187. label: v.detailedAddress,
  188. value: v.houseId,
  189. location: v.location
  190. }
  191. })
  192. }
  193. })
  194. },
  195. getPreview(idx,arr) {
  196. var newArr=[];
  197. arr.forEach(ite=>{
  198. var ds=this.baseUrl+ite
  199. newArr.push(ds)
  200. })
  201. uni.previewImage({
  202. urls: newArr,
  203. current:idx,
  204. success: function(data) {},
  205. fail: function(err) {}
  206. });
  207. },
  208. getDelFn(idx){
  209. var that=this;
  210. if(this.isdisabled){
  211. return
  212. }
  213. uni.showModal({
  214. title: '确认删除',
  215. content: "是否确认删除",
  216. cancelText: '取消',
  217. confirmText: '确认',
  218. success: function(res) {
  219. if (res.confirm) {
  220. that.phofile.splice(idx,1)
  221. } else if (res.cancel) {
  222. }
  223. }
  224. });
  225. },
  226. getaddImage(e){
  227. let that = this;
  228. let file =[],count=9
  229. uni.chooseImage({
  230. // count: 1,
  231. success:function(res){
  232. let img= res.tempFilePaths;
  233. if(img.length + file.length > count){
  234. uni.showToast({
  235. title: '最多上传'+count+'张图片',
  236. icon: 'none',
  237. duration: 2000
  238. })
  239. }else{
  240. let imglen = res.tempFilePaths.length;
  241. var fuwufile = [];
  242. uploadmore('/common/upload',img,0,0,0,imglen,fuwufile,function(rs){
  243. that.phofile = that.phofile.concat(rs);
  244. })
  245. }
  246. }
  247. });
  248. },
  249. getDetailFn(){
  250. var that=this;
  251. repairDet(this.id).then(res=>{
  252. if(res.code==200){
  253. this.datainfo=res.data;
  254. this.repairStatus=res.data.repairStatus;
  255. if(res.data.repairImages){
  256. this.phofile=res.data.repairImages.split(',')
  257. }
  258. if(res.data.visitPhoto){
  259. this.visitPhoto=res.data.visitPhoto.split(',')
  260. }
  261. if(res.data.completionPhoto){
  262. this.completionPhoto=res.data.completionPhoto.split(',')
  263. }
  264. }
  265. })
  266. },
  267. time() {
  268. var date = new Date();
  269. var y = date.getFullYear();
  270. var m = date.getMonth() + 1;
  271. var d = date.getDate();
  272. var h = date.getHours();
  273. var min = date.getMinutes();
  274. var s = date.getSeconds();
  275. var yearStr = y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d)
  276. var timeStr = (h < 10 ? ('0' + h) : h) + ':' + (min < 10 ? ('0' + min) : min) + ':' + (s < 10 ? (
  277. '0' + s) : s);
  278. var kaTime = yearStr + ' ' + timeStr;
  279. return kaTime
  280. },
  281. getSubmit(){
  282. var that=this;
  283. this.$refs.form.validate().then(res => {
  284. var params=JSON.parse(JSON.stringify(this.datainfo))
  285. var phofile=JSON.parse(JSON.stringify(this.phofile))
  286. if(phofile&&phofile.length){
  287. params.repairImages=this.phofile.join(',');
  288. }
  289. if(!params.maintenanceCategory){
  290. this.$toast('请选择项目')
  291. return
  292. }
  293. if(!params.repairTitle){
  294. this.$toast('请输入标题')
  295. return
  296. }
  297. if(!params.houseAddress){
  298. this.$toast('请选择报修门户')
  299. return
  300. }
  301. if(!params.phoneNumber){
  302. this.$toast('请输入联系方式')
  303. return
  304. }
  305. if(this.ptype=='add'){
  306. params.userId=this.userId;
  307. params.repairTime=this.time();
  308. repairAdd(params).then(res=>{
  309. if(res.code==200){
  310. this.$toast("新增成功")
  311. setTimeout(function(){
  312. uni.$emit("repairList")
  313. uni.navigateBack({
  314. delta:1
  315. })
  316. },1500)
  317. }
  318. })
  319. }else{
  320. repairPut(params).then(res=>{
  321. if(res.code==200){
  322. this.$toast("修改成功")
  323. setTimeout(function(){
  324. uni.$emit("repairList")
  325. uni.navigateBack({
  326. delta:1
  327. })
  328. },1500)
  329. }
  330. })
  331. }
  332. })
  333. },
  334. }
  335. }
  336. </script>
  337. <style>
  338. page{background: #F3F3F0;}
  339. </style>
  340. <style lang="scss" scoped>
  341. .address /deep/ .select-wrap{border: none;width: 100%;}
  342. .address /deep/ .uni-forms-item{min-height: 106rpx;box-sizing: border-box;display: flex;align-items: center;margin-bottom: 0;border-bottom: 2rpx solid #E6E6E6;padding:10rpx 0;}
  343. .address /deep/ .uni-forms-item:last-child{border-bottom: none;}
  344. .address /deep/ .uni-forms-item__label{font-weight: bold;font-size: 26rpx;color: #222327;flex: 0 0 auto;width: auto !important;padding-left: 12rpx;}
  345. .address /deep/ .uni-easyinput{flex: 1;text-align: right;font-size: 26rpx;color: #222327;}
  346. .address /deep/ .uni-easyinput__content-textarea{min-height: 140rpx;font-size: 26rpx;
  347. border-radius: 10rpx;padding: 20rpx 14rpx;text-align: left;}
  348. .address /deep/ .uni-easyinput__placeholder-class{font-size: 26rpx;color: #AAAAAA;}
  349. .address /deep/ .uni-input-input{font-size: 26rpx;}
  350. .address /deep/ .uni-textarea-textarea{font-size: 26rpx;}
  351. .address /deep/ .is-required{font-size: 26rpx;color: #F40027;margin-right: 4rpx;}
  352. .address /deep/ .is-disabled{color: #222327;background-color: #ffffff !important;}
  353. .address{min-height: 100vh;padding: 20rpx 18rpx 100rpx;display: flex;flex-direction: column;}
  354. .adrbox{background: #FFFFFF;border-radius: 20rpx;margin-bottom: 24rpx;
  355. .rimg{width: 16rpx;height: 28rpx;flex: 0 0 auto;margin-left: 20rpx;
  356. image{width: 100%;height: 100%;}
  357. }
  358. &.mjbox{
  359. padding: 36rpx 24rpx 18rpx;
  360. .tit{font-weight: bold;font-size: 26rpx;color: #272727;padding-left: 18rpx;}
  361. .adrlist{
  362. view{font-weight: bold;font-size: 26rpx;color: #666666;min-width: 198rpx;padding: 0 10rpx;box-sizing: border-box;margin: 0 12rpx 24rpx;height: 64rpx;display: flex;align-items: center;justify-content: center;border-radius: 10rpx;border: 2rpx solid #C1C1C1;
  363. &.act{background: #DFEAFF;border: 2rpx solid #0256FD;color: #0256FD;}
  364. }
  365. }
  366. }
  367. .chtop{margin-bottom: 8rpx;padding-top: 32rpx;
  368. view{font-weight: bold;font-size: 28rpx;color: #272727;}
  369. .line{width: 14rpx;height: 48rpx;background: #0256FD;border-radius:0 12rpx 12rpx 0;margin-right: 18rpx;}
  370. }
  371. .voice{font-weight: 500;display: flex;justify-content:flex-end;align-items: center;margin-top: 40rpx;font-size: 24rpx;color: #45CB99;
  372. image{width: 24rpx;height: 24rpx;margin-right: 8rpx;}
  373. }
  374. .imgs{display: flex;align-items: center;flex-wrap: wrap;padding: 0 24rpx;
  375. .img{width: 198rpx;height:142rpx;border-radius: 20rpx;margin: 0 12rpx 20rpx 12rpx;position: relative;
  376. // &:nth-of-type(2n){margin-right: 0;}
  377. }
  378. .pico{width: 100%;height: 100%;border-radius: 20rpx;}
  379. .del{width: 24rpx;height: 24rpx;position: absolute;right: 0;top: 0;}
  380. .addbox{background: #F0F0F0;border-radius: 20rpx;display: flex;align-items: center;flex-direction: column;width: 198rpx;height:142rpx;justify-content: center;margin:0 12rpx 20rpx 12rpx;
  381. image{width: 48rpx;height: 42rpx;margin-bottom: 12rpx;}
  382. view{font-weight: 500;font-size: 24rpx;color: #666666;}
  383. }
  384. }
  385. .checkimg{width: 80rpx;height: 40rpx;margin-right: 8rpx;}
  386. }
  387. </style>