warrantyadd.vue 12 KB

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