warrantyadd.vue 13 KB

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