index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <template>
  2. <view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='报修'></cus-header>
  4. <div class="form">
  5. <div class="item">
  6. <div class="left">报修区域</div>
  7. <div class="right">
  8. <div class="right" @tap="areaShow = true">
  9. <text v-if="params.repairRegionName">{{params.repairRegionName}} ></text>
  10. <div class="tip" v-else>
  11. 请选择<u-icon name="arrow-right" color="#B9C0C8" size="28"
  12. style="margin-left: 10rpx;"></u-icon>
  13. </div>
  14. </div>
  15. </div>
  16. </div>
  17. <div class="item" v-if="params.repairRegionName">
  18. <div class="left">报修位置</div>
  19. <div class="right">
  20. <div class="right" @tap="showPlace">
  21. <text v-if="params.repairPositionName">{{params.repairPositionName}} ></text>
  22. <div class="tip" v-else>
  23. 请选择<u-icon name="arrow-right" color="#B9C0C8" size="28"
  24. style="margin-left: 10rpx;"></u-icon>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. <div class="item">
  30. <div class="left">报修类型</div>
  31. <div class="right">
  32. <div class="right" @tap="typeShow = true">
  33. <text v-if="params.repairTypeName">{{params.repairTypeName}} ></text>
  34. <div class="tip" v-else>
  35. 请选择<u-icon name="arrow-right" color="#B9C0C8" size="28"
  36. style="margin-left: 10rpx;"></u-icon>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="item">
  42. <div class="left">联系人</div>
  43. <div class="right">
  44. <input type="text" v-model="params.contactPerson" placeholder-class="repair-inp-ph" placeholder="请输入">
  45. </div>
  46. </div>
  47. <div class="item">
  48. <div class="left">联系电话</div>
  49. <div class="right">
  50. <input type="phone" v-model="params.contactPhone" placeholder-class="repair-inp-ph" placeholder="请输入">
  51. </div>
  52. </div>
  53. <div class="pre">
  54. <div class="title">故障描述</div>
  55. <div class="desc">
  56. <u--textarea v-model="params.faultDes" placeholder="请输入" placeholder-class="repair-inp-ph" autoHeight></u--textarea>
  57. </div>
  58. </div>
  59. </div>
  60. <div class="upload">
  61. <div class="title">上传照片</div>
  62. <div class="box" style="width: auto;height: auto;">
  63. <view class="uploadPart">
  64. <view class="allimg" v-for="img in fileList1">
  65. <image :src="img" mode="aspectFill" class="newimg"></image>
  66. <u-icon @click="deletePic(img)" class="mytrash" name="close-circle" color="#999"
  67. size="30"></u-icon>
  68. </view>
  69. <span @click="uploadImg" class="uploadBtn" v-if="fileList1.length<3"><u-icon color="#5c8fff"
  70. size="30px" name="camera-fill"></u-icon></span>
  71. </view>
  72. </div>
  73. </div>
  74. <div class="bottom">
  75. <div class="save" @tap="save">保存</div>
  76. </div>
  77. <u-picker :show="placeShow" :columns="placeColumns" keyName="orgName" title="报修位置" @cancel="placeCancel" @change="changeHandler" @confirm="placeConfirm"></u-picker>
  78. <u-picker :show="placeShow2" :columns="placeColumns2" keyName="orgName" title="报修位置" @cancel="placeCancel" @change="changeHandler" @confirm="placeConfirm"></u-picker>
  79. <u-picker :show="areaShow" :columns="areaColumns" keyName="label" title="报修区域" @cancel="areaShow=false" @confirm="e=>paramsConfirm(e,'repairRegion','repairRegionName')"></u-picker>
  80. <u-picker :show="typeShow" :columns="typeColumns" keyName="label" title="报修类型" @cancel="typeShow=false" @confirm="e=>paramsConfirm(e,'repairType','repairTypeName')"></u-picker>
  81. </view>
  82. </template>
  83. <script>
  84. const baseApi = require('@/http/baseApi.js')
  85. export default {
  86. data() {
  87. return {
  88. placeShow: false,
  89. placeShow2: false,
  90. areaShow: false,
  91. typeShow: false,
  92. alldata:[],
  93. placeColumns:[],
  94. placeColumns2:[],
  95. placeColumnData:[],
  96. areaColumns:[
  97. [{
  98. label: '公共区域',
  99. id: 1
  100. }, {
  101. label: '室内',
  102. id: 2
  103. }]
  104. ],
  105. typeColumns:[[]],
  106. params: {
  107. id: "",
  108. buildingId: "", // 楼栋ID
  109. storeyId: "", // 层数ID
  110. houseId: "", // 房间ID
  111. repairPositionName: "", //报修位置名称
  112. repairRegion: '', //报修修区域
  113. repairRegionName: "", //报修区域名称
  114. repairType: '', //报修类型
  115. repairTypeName: "", //报修类型
  116. contactPerson: "", //联系人
  117. contactPhone: "", //电话
  118. faultDes: "", // 故障描述
  119. faultPics: "", //图片
  120. },
  121. tip:{
  122. repairRegion: '请选择报修区域',
  123. buildingId: "请选择报修位置",
  124. repairType: '请选择报修类型',
  125. contactPerson: "请输入联系人",
  126. contactPhone: "请输入正确的联系电话",
  127. faultDes: "请输入故障描述",
  128. faultPics: "请上传图片"
  129. },
  130. fileList1: [],
  131. }
  132. },
  133. onLoad() {
  134. this.getXjTypeData();
  135. this.getFloorInfo();
  136. },
  137. methods: {
  138. getXjTypeData(){
  139. this.$api.get('/sys/dict/data/getListByType/RepairType').then(res=>{
  140. if(res.data.code===0){
  141. res.data.data.forEach(d=>{
  142. this.typeColumns[0].push({id:d.dictValue,label:d.dictLabel})
  143. })
  144. }else this.$showToast(res.data.msg)
  145. })
  146. },
  147. getFloorInfo(){
  148. this.$api.get('/control/getOrgStructureTree/').then(res=>{
  149. if(res.data.code===0){
  150. this.alldata = res.data.data[0].childrenList;
  151. this.placeColumns = [
  152. this.alldata,
  153. this.alldata[0].childrenList,
  154. []
  155. ]
  156. this.placeColumns2 = [
  157. this.alldata,
  158. this.alldata[0].childrenList,
  159. ]
  160. }else this.$showToast(res.data.msg)
  161. })
  162. },
  163. // 删除图片
  164. deletePic(event) {
  165. this.fileList1.splice(event.index, 1)
  166. },
  167. // 新增图片
  168. uploadImg() {
  169. uni.chooseImage({
  170. count: 3,
  171. success: (chooseImageRes) => {
  172. const tempFilePaths = chooseImageRes.tempFilePaths;
  173. for (let i = 0; i < tempFilePaths.length; i++) {
  174. uni.uploadFile({
  175. url: baseApi.BaseApi + '/uploadFile',
  176. filePath: tempFilePaths[i],
  177. name: 'file',
  178. formData: {
  179. 'user': 'test'
  180. },
  181. success: (res) => {
  182. this.fileList1.push(JSON.parse(res.data).data)
  183. this.params.faultPics = this.fileList1.join(',')
  184. }
  185. });
  186. }
  187. }
  188. });
  189. },
  190. showPlace(){
  191. if (this.params.repairRegionName == '公共区域') this.placeShow2 = true;
  192. else this.placeShow = true;
  193. },
  194. changeHandler(e) {
  195. const {
  196. columnIndex,
  197. value,
  198. values, // values为当前变化列的数组内容
  199. index,
  200. indexs,
  201. picker = this.$refs.uPicker
  202. } = e
  203. if (columnIndex == 0) {
  204. picker.setColumnValues(1, this.alldata[index].childrenList)
  205. if (this.params.repairRegionName == '室内') {
  206. if (this.alldata[indexs[0]].childrenList[0].childrenList == null) {
  207. picker.setColumnValues(2, [])
  208. } else {
  209. picker.setColumnValues(2, this.alldata[indexs[0]].childrenList[0].childrenList)
  210. }
  211. }
  212. } else if (this.params.repairRegionName == '室内' && columnIndex == 1) {
  213. if (this.alldata[indexs[0]].childrenList[indexs[1]].childrenList == null) {
  214. picker.setColumnValues(2, [])
  215. } else {
  216. picker.setColumnValues(2, this.alldata[indexs[0]].childrenList[indexs[1]].childrenList)
  217. }
  218. }
  219. },
  220. placeConfirm(e) {
  221. if(this.params.repairRegionName == '室内'){
  222. if (e.value[2] == undefined) {
  223. this.params.repairPositionName = e.value[0].orgName + '/' + e.value[1].orgName;
  224. this.params.buildingId = e.value[0].orgId;
  225. this.params.storeyId = e.value[1].orgId;
  226. this.params.houseId = '';
  227. } else {
  228. this.params.repairPositionName = e.value[0].orgName + '/' + e.value[1].orgName + '/' + e.value[2].orgName;
  229. this.params.buildingId = e.value[0].orgId;
  230. this.params.storeyId = e.value[1].orgId;
  231. this.params.houseId = e.value[2].orgId;
  232. }
  233. this.placeShow = false;
  234. }else{
  235. this.params.repairPositionName = e.value[0].orgName + '/' + e.value[1].orgName;
  236. this.params.buildingId = e.value[0].orgId;
  237. this.params.storeyId = e.value[1].orgId;
  238. this.params.houseId = '';
  239. this.placeShow2 = false;
  240. }
  241. },
  242. placeCancel() {
  243. if(this.params.repairRegionName == '室内') this.placeShow = false;
  244. else this.placeShow2 = false;
  245. },
  246. paramsConfirm(e,key1,key2){
  247. this.params[key1] = e.value[0].id;
  248. this.params[key2] = e.value[0].label;
  249. this.areaShow = this.typeShow = false;
  250. },
  251. save(){
  252. let flag = true;
  253. for(let t in this.tip){
  254. if((t=='contactPhone'&&!this.$reg.mobile(this.params[t]))||(t!='contactPhone'&&!this.params[t])){
  255. this.$showToast(this.tip[t])
  256. flag = false;
  257. break;
  258. }
  259. }
  260. if(!flag) return;
  261. this.$api.post('/repairorder', this.params).then(res=>{
  262. if(res.data.code===0){
  263. this.$showToast('提交成功');
  264. setTimeout(()=>{
  265. uni.navigateBack();
  266. },1500)
  267. }else this.$showToast(res.data.msg)
  268. })
  269. }
  270. }
  271. }
  272. </script>
  273. <style>
  274. .repair-inp-ph{
  275. color: #B9C0C8 !important;
  276. }
  277. </style>
  278. <style scoped lang="less">
  279. .uploadPart {
  280. display: flex;
  281. justify-content: center;
  282. width: 100%;
  283. .uploadBtn {
  284. width: 160rpx;
  285. height: 160rpx;
  286. background-color: #ECF0FF;
  287. text-align: center;
  288. border-radius: 4rpx;
  289. display: flex;
  290. align-items: center;
  291. justify-content: center;
  292. }
  293. .allimg {
  294. position: relative;
  295. }
  296. .newimg {
  297. width: 160rpx;
  298. height: 160rpx;
  299. margin-right: 10rpx;
  300. }
  301. .mytrash {
  302. position: absolute;
  303. top: 2px;
  304. right: 10px;
  305. }
  306. }
  307. ::v-deep .desc .u-textarea{
  308. border: none;
  309. padding: 0 !important;
  310. }
  311. ::v-deep .upload .u-upload .u-upload__button{
  312. width: 168rpx !important;
  313. height: 180rpx !important;
  314. }
  315. ::v-deep .upload .u-upload .u-icon__icon{
  316. font-size: 24px !important;
  317. }
  318. .page {
  319. padding: 0 24rpx 168rpx;
  320. box-sizing: border-box;
  321. background: #F4F8FB;
  322. .form{
  323. background: #FFFFFF;
  324. border-radius: 16rpx;
  325. padding: 0 24rpx;
  326. margin-top: 20rpx;
  327. .item{
  328. height: 90rpx;
  329. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #ECECEC;
  330. display: flex;
  331. align-items: center;
  332. justify-content: space-between;
  333. .left{
  334. font-family: PingFangSC, PingFang SC;
  335. font-weight: 400;
  336. font-size: 30rpx;
  337. color: #1D2129;
  338. line-height: 42rpx;
  339. }
  340. .right{
  341. font-family: PingFangSC, PingFang SC;
  342. font-weight: 400;
  343. font-size: 28rpx;
  344. color: #1D2129;
  345. line-height: 40rpx;
  346. text-align: right;
  347. .tip{
  348. font-family: PingFangSC, PingFang SC;
  349. font-weight: 400;
  350. font-size: 28rpx;
  351. color: #B9C0C8;
  352. line-height: 40rpx;
  353. text-align: right;
  354. display: flex;
  355. align-items: center;
  356. }
  357. input{
  358. border: none;
  359. outline: none;
  360. font-family: PingFangSC, PingFang SC;
  361. font-weight: 400;
  362. font-size: 28rpx;
  363. color: #1D2129;
  364. line-height: 40rpx;
  365. text-align: right;
  366. }
  367. }
  368. }
  369. .pre{
  370. margin-top: 24rpx;
  371. overflow: hidden;
  372. .title{
  373. font-family: PingFangSC, PingFang SC;
  374. font-weight: 400;
  375. font-size: 30rpx;
  376. color: #1D2129;
  377. line-height: 42rpx;
  378. }
  379. .desc{
  380. margin: 24rpx 0 40rpx;
  381. }
  382. }
  383. }
  384. .upload{
  385. padding: 38rpx 24rpx;
  386. background: #FFFFFF;
  387. border-radius: 16rpx;
  388. margin-top: 20rpx;
  389. .title{
  390. font-family: PingFang-SC, PingFang-SC;
  391. font-weight: bold;
  392. font-size: 30rpx;
  393. color: #1D2129;
  394. line-height: 36rpx;
  395. }
  396. .box{
  397. margin-top: 34rpx;
  398. width: 168rpx;
  399. height: 180rpx;
  400. }
  401. }
  402. .bottom{
  403. width: 100%;
  404. height: 148rpx;
  405. padding: 20rpx 48rpx 0;
  406. box-sizing: border-box;
  407. background: #FFFFFF;
  408. position: fixed;
  409. left: 0;
  410. bottom: 0;
  411. .save{
  412. width: 100%;
  413. height: 88rpx;
  414. background: #198CFF;
  415. border-radius: 16rpx;
  416. font-family: PingFang-SC, PingFang-SC;
  417. font-weight: bold;
  418. font-size: 32rpx;
  419. color: #FFFFFF;
  420. line-height: 88rpx;
  421. text-align: center;
  422. letter-spacing: 2rpx;
  423. }
  424. }
  425. }
  426. </style>