warrantyadd.vue 12 KB

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