warrantyadd.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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="datainfo.houseId"
  29. :list='fwlist'
  30. valueName='label'
  31. keyName="value"
  32. :showClose='showClose'
  33. :valuea="datainfo.houseId"
  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=e.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. this.datainfo.houseId=res.rows[0].houseId
  200. }
  201. }
  202. })
  203. },
  204. getPreview(idx,arr) {
  205. var newArr=[];
  206. arr.forEach(ite=>{
  207. var ds=this.baseUrl+ite
  208. newArr.push(ds)
  209. })
  210. uni.previewImage({
  211. urls: newArr,
  212. current:idx,
  213. success: function(data) {},
  214. fail: function(err) {}
  215. });
  216. },
  217. getDelFn(idx){
  218. var that=this;
  219. if(this.isdisabled){
  220. return
  221. }
  222. uni.showModal({
  223. title: '确认删除',
  224. content: "是否确认删除",
  225. cancelText: '取消',
  226. confirmText: '确认',
  227. success: function(res) {
  228. if (res.confirm) {
  229. that.phofile.splice(idx,1)
  230. } else if (res.cancel) {
  231. }
  232. }
  233. });
  234. },
  235. getaddImage(e){
  236. let that = this;
  237. let file =[],count=9
  238. uni.chooseImage({
  239. // count: 1,
  240. success:function(res){
  241. let img= res.tempFilePaths;
  242. if(img.length + file.length > count){
  243. uni.showToast({
  244. title: '最多上传'+count+'张图片',
  245. icon: 'none',
  246. duration: 2000
  247. })
  248. }else{
  249. let imglen = res.tempFilePaths.length;
  250. var fuwufile = [];
  251. uploadmore('/common/upload',img,0,0,0,imglen,fuwufile,function(rs){
  252. that.phofile = that.phofile.concat(rs);
  253. })
  254. }
  255. }
  256. });
  257. },
  258. getDetailFn(){
  259. var that=this;
  260. repairDet(this.id).then(res=>{
  261. if(res.code==200){
  262. this.datainfo=res.data;
  263. this.repairStatus=res.data.repairStatus;
  264. if(res.data.repairImages){
  265. this.phofile=res.data.repairImages.split(',')
  266. }
  267. if(res.data.visitPhoto){
  268. this.visitPhoto=res.data.visitPhoto.split(',')
  269. }
  270. if(res.data.completionPhoto){
  271. this.completionPhoto=res.data.completionPhoto.split(',')
  272. }
  273. }
  274. })
  275. },
  276. time() {
  277. var date = new Date();
  278. var y = date.getFullYear();
  279. var m = date.getMonth() + 1;
  280. var d = date.getDate();
  281. var h = date.getHours();
  282. var min = date.getMinutes();
  283. var s = date.getSeconds();
  284. var yearStr = y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d)
  285. var timeStr = (h < 10 ? ('0' + h) : h) + ':' + (min < 10 ? ('0' + min) : min) + ':' + (s < 10 ? (
  286. '0' + s) : s);
  287. var kaTime = yearStr + ' ' + timeStr;
  288. return kaTime
  289. },
  290. getSubmit(){
  291. var that=this;
  292. this.$refs.form.validate().then(res => {
  293. var params=JSON.parse(JSON.stringify(this.datainfo))
  294. var phofile=JSON.parse(JSON.stringify(this.phofile))
  295. if(phofile&&phofile.length){
  296. params.repairImages=this.phofile.join(',');
  297. }
  298. if(!params.maintenanceCategory){
  299. this.$toast('请选择项目')
  300. return
  301. }
  302. // if(!params.repairTitle){
  303. // this.$toast('请输入标题')
  304. // return
  305. // }
  306. // if(!params.houseAddress){
  307. // this.$toast('请选择报修门户')
  308. // return
  309. // }
  310. if(!params.phoneNumber){
  311. this.$toast('请输入联系方式')
  312. return
  313. }
  314. if(this.ptype=='add'){
  315. params.userId=this.userId;
  316. params.repairTime=this.time();
  317. repairAdd(params).then(res=>{
  318. if(res.code==200){
  319. this.$toast("新增成功")
  320. setTimeout(function(){
  321. uni.$emit("repairList")
  322. uni.navigateBack({
  323. delta:1
  324. })
  325. },1500)
  326. }
  327. })
  328. }else{
  329. repairPut(params).then(res=>{
  330. if(res.code==200){
  331. this.$toast("修改成功")
  332. setTimeout(function(){
  333. uni.$emit("repairList")
  334. uni.navigateBack({
  335. delta:1
  336. })
  337. },1500)
  338. }
  339. })
  340. }
  341. })
  342. },
  343. }
  344. }
  345. </script>
  346. <style>
  347. page{background: #F3F3F0;}
  348. </style>
  349. <style lang="scss" scoped>
  350. .address /deep/ .select-wrap{border: none;width: 100%;}
  351. .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;}
  352. .address /deep/ .uni-forms-item:last-child{border-bottom: none;}
  353. .address /deep/ .uni-forms-item__label{font-weight: bold;font-size: 26rpx;color: #222327;flex: 0 0 auto;width: auto !important;padding-left: 12rpx;}
  354. .address /deep/ .uni-easyinput{flex: 1;text-align: right;font-size: 26rpx;color: #222327;}
  355. .address /deep/ .uni-easyinput__content-textarea{min-height: 140rpx;font-size: 26rpx;
  356. border-radius: 10rpx;padding: 20rpx 14rpx;text-align: left;}
  357. .address /deep/ .uni-easyinput__placeholder-class{font-size: 26rpx;color: #AAAAAA;}
  358. .address /deep/ .uni-input-input{font-size: 26rpx;}
  359. .address /deep/ .uni-textarea-textarea{font-size: 26rpx;}
  360. .address /deep/ .is-required{font-size: 26rpx;color: #F40027;margin-right: 4rpx;}
  361. .address /deep/ .is-disabled{color: #222327;background-color: #ffffff !important;}
  362. .address{min-height: 100vh;padding: 20rpx 18rpx 100rpx;display: flex;flex-direction: column;}
  363. .adrbox{background: #FFFFFF;border-radius: 20rpx;margin-bottom: 24rpx;
  364. .rimg{width: 16rpx;height: 28rpx;flex: 0 0 auto;margin-left: 20rpx;
  365. image{width: 100%;height: 100%;}
  366. }
  367. &.mjbox{
  368. padding: 36rpx 24rpx 18rpx;
  369. .tit{font-weight: bold;font-size: 26rpx;color: #272727;padding-left: 18rpx;}
  370. .adrlist{
  371. 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;
  372. &.act{background: #DFEAFF;border: 2rpx solid #0256FD;color: #0256FD;}
  373. }
  374. }
  375. }
  376. .chtop{margin-bottom: 8rpx;padding-top: 32rpx;
  377. view{font-weight: bold;font-size: 28rpx;color: #272727;}
  378. .line{width: 14rpx;height: 48rpx;background: #0256FD;border-radius:0 12rpx 12rpx 0;margin-right: 18rpx;}
  379. }
  380. .voice{font-weight: 500;display: flex;justify-content:flex-end;align-items: center;margin-top: 40rpx;font-size: 24rpx;color: #45CB99;
  381. image{width: 24rpx;height: 24rpx;margin-right: 8rpx;}
  382. }
  383. .imgs{display: flex;align-items: center;flex-wrap: wrap;padding: 0 24rpx;
  384. .img{width: 198rpx;height:142rpx;border-radius: 20rpx;margin: 0 12rpx 20rpx 12rpx;position: relative;
  385. // &:nth-of-type(2n){margin-right: 0;}
  386. }
  387. .pico{width: 100%;height: 100%;border-radius: 20rpx;}
  388. .del{width: 24rpx;height: 24rpx;position: absolute;right: 0;top: 0;}
  389. .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;
  390. image{width: 48rpx;height: 42rpx;margin-bottom: 12rpx;}
  391. view{font-weight: 500;font-size: 24rpx;color: #666666;}
  392. }
  393. }
  394. .checkimg{width: 80rpx;height: 40rpx;margin-right: 8rpx;}
  395. }
  396. </style>