repair.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. <template>
  2. <view>
  3. <image src="/static/icon/background.png" mode="" class="background"></image>
  4. <view style="padding-top: 100rpx;">
  5. <view class="align-items">
  6. <back></back>
  7. </view>
  8. <view class="project-content">
  9. <view class="font-forty-eight blue">
  10. 项目名称:{{name}}
  11. </view>
  12. <view class="font-forty-eight blue">
  13. 项目地址:{{address}}
  14. </view>
  15. </view>
  16. <view>
  17. <view class="font-fifty-six SourceHanSansCN choose" @click="openHouse('district')">
  18. {{districtName ? districtName :'选择行政区区'}}
  19. </view>
  20. </view>
  21. <view>
  22. <view class="font-fifty-six SourceHanSansCN choose" @click="openHouse('xiaoqu')">
  23. {{house ? house : '选择小区'}}
  24. </view>
  25. </view>
  26. <view>
  27. <view class="font-fifty-six SourceHanSansCN choose" @click="openHouse('louyu')">
  28. {{bulid ? bulid : '选择楼宇'}}
  29. </view>
  30. </view>
  31. <view>
  32. <view class="font-fifty-six SourceHanSansCN choose" @click="openHouse('danyuan')">
  33. {{unit ? unit : '选择单元'}}
  34. </view>
  35. </view>
  36. <view>
  37. <view class="font-fifty-six SourceHanSansCN choose" @click="openHouse('menpai')">
  38. {{houseNumber ? houseNumber : '选择门牌'}}
  39. </view>
  40. </view>
  41. <view>
  42. <view class="font-fifty-six SourceHanSansCN choose" @click="openQualified()">
  43. {{isqualified ? isqualified : '是否'+(id=='004'?'合格':'维修')}}
  44. <u-select v-model="qualifiedShow" :list="qualifiedList" @confirm="qualifiedConfirm()"></u-select>
  45. </view>
  46. </view>
  47. <view class="upload">
  48. <text class="font-forty SourceHanSansCN">备注:</text>
  49. <textarea value="" placeholder="请输入备注" v-model="remark" />
  50. </view>
  51. <view class="" style="display: flex; flex-wrap: wrap; margin: 0 55rpx;">
  52. <image src="/static/icon/chooseimg.png" mode="" style="width: 190rpx; height: 190rpx; margin: 0 12rpx; "
  53. @click="choose()"></image>
  54. <view v-for="(item,index) in imgArr" :key="index" style="position: relative;">
  55. <view v-if="item.substring(item.length - 3) == 'png' || item.substring(item.length - 3) == 'jpg' ">
  56. <image :src="item" mode="" style="width: 190rpx; height: 190rpx; margin: 0 20rpx;"
  57. @click="showPhoto(index)">
  58. </image>
  59. </view>
  60. <view v-else>
  61. <video :src="item" style="width: 190rpx; height: 190rpx; margin: 0 20rpx;"></video>
  62. </view>
  63. <view @click="remove(index)"
  64. style="position: absolute; top: 0; right: 14rpx; border-radius: 50%; background-color: #FF0000;">
  65. <u-icon name="close" color="#FFFFFF" size="35"></u-icon>
  66. </view>
  67. </view>
  68. </view>
  69. <view class="project background-color1 font-sixty-four white" @click="updatePhoto()">
  70. 确定上传
  71. </view>
  72. </view>
  73. <u-popup v-model="pop" mode="bottom" height="1000rpx">
  74. <view style="margin: 20rpx;">
  75. <u-search v-show="inputShow" placeholder="请输入搜索内容" v-model="keyword" :action-style="{'font-size':'40rpx'}"
  76. @custom="searchinfo(selectType)"></u-search>
  77. </view>
  78. <view>
  79. <scroll-view scroll-y="true" style="height: 600rpx; text-align: center;">
  80. <view v-for="(item,index) in chooseHouseList" :key="item.value">
  81. <view :class="current === index ? 'active' : '' " style="color: #000000;font-size: 56rpx;"
  82. @click="active(item,index)">
  83. {{item.label}}
  84. </view>
  85. </view>
  86. </scroll-view>
  87. <view class="">
  88. <button type="default" class="font-fifty-six" @click="search(selectType)">确定</button>
  89. </view>
  90. <view class="">
  91. <button type="default" @click="pop = false;" class="font-fifty-six">取消</button>
  92. </view>
  93. </view>
  94. </u-popup>
  95. </view>
  96. </template>
  97. <script>
  98. import service from '@/api/index.js'
  99. export default {
  100. data() {
  101. return {
  102. action: this.$HTTP.webUrl + `/obs`,
  103. headers: {
  104. MAuthorization: "wxBearer " + uni.getStorageSync('token')
  105. },
  106. url: [],
  107. id: 0,
  108. name: '',
  109. address: '',
  110. photo: [],
  111. uploading: false,
  112. imgArr: [],
  113. progress: 0, //图片或视频上传百分比
  114. inputShow: false,
  115. districtId: 0,
  116. districtName: '选择行政区',
  117. pop: false,
  118. housename: '',
  119. houseid: 0,
  120. buildid: 0,
  121. unitid: 0,
  122. numberid: 0,
  123. houseShow: false,
  124. current: -1,
  125. chooseHouseList: [],
  126. house: '选择小区',
  127. bulid: '选择楼宇',
  128. unit: '选择单元',
  129. houseNumber: '选择门牌',
  130. serviceType: '',
  131. housedata: 0,
  132. remark: '',
  133. keyword: '',
  134. loading: false,
  135. isqualified: null,
  136. qualifiedShow: false,
  137. qualifiedList: [{
  138. value: '是',
  139. label: '是',
  140. },
  141. {
  142. value: '否',
  143. label: '否',
  144. }
  145. ]
  146. }
  147. },
  148. onLoad(e) {
  149. console.log(e)
  150. this.id = e.id;
  151. this.name = e.name;
  152. this.address = e.address
  153. // this.getEngineDetail();
  154. },
  155. methods: {
  156. showPhoto(index) {
  157. uni.previewImage({
  158. current: index,
  159. urls: this.imgArr,
  160. })
  161. },
  162. updatePhoto() {
  163. if (this.housedata == 0 || this.housedata == null) {
  164. this.$UTILS.showPrompt('请选择门牌号!')
  165. return
  166. }
  167. if (this.isqualified == null || this.isqualified == '') {
  168. this.$UTILS.showPrompt('请选择是否合格!')
  169. return
  170. }
  171. if (this.imgArr.length <= 0) {
  172. this.$UTILS.showPrompt('请上传照片!')
  173. return
  174. }
  175. if (this.loading == false) {
  176. this.$UTILS.showPrompt('照片或视频未上传完毕,无法提交!')
  177. return
  178. }
  179. let param = {
  180. // photo: this.imgArr,
  181. picUrl: this.imgArr,
  182. serviceType: this.id,
  183. houseId: this.housedata,
  184. remark: this.remark,
  185. whether: this.isqualified,
  186. //小区
  187. areaId: this.houseid,
  188. areaName: this.house,
  189. //楼宇
  190. buildingId: this.buildid,
  191. buildingName: this.bulid,
  192. //单元
  193. unitId: this.unitid,
  194. unitName: this.unit,
  195. //房间
  196. houseName: this.houseNumber,
  197. }
  198. console.log('param', param)
  199. // this.$UTILS.showPrompt('提交成功!')
  200. service.submitOrder(param).then(res => {
  201. this.$UTILS.showPrompt('提交成功!')
  202. this.houseNumber = null;
  203. this.imgArr = null;
  204. }).catch(e => {
  205. this.$UTILS.showPrompt('提交失败!')
  206. console.error(e)
  207. })
  208. },
  209. // //获取小区
  210. // getArea() {
  211. // service.getArea().then(res => {
  212. // this.chooseHouseList = [];
  213. // res.forEach((item, index) => {
  214. // this.chooseHouseList.push({
  215. // value: item.id,
  216. // label: item.name,
  217. // selectType: 'xiaoqu'
  218. // })
  219. // })
  220. // })
  221. // },
  222. searchinfo(selectType) {
  223. if (selectType == 'xiaoqu') {
  224. console.log('ssss', this.selectType)
  225. service.getArea({
  226. name: this.keyword
  227. }).then(res => {
  228. this.chooseHouseList = [];
  229. res.forEach((item, index) => {
  230. this.chooseHouseList.push({
  231. value: item.id,
  232. label: item.name,
  233. selectType: 'xiaoqu'
  234. })
  235. })
  236. })
  237. this.keyword = '';
  238. } else if (selectType == 'louyu') {
  239. console.log('ssss', this.selectType)
  240. service.getBuilding({
  241. areaId: this.houseid,
  242. name: this.keyword
  243. }).then(res => {
  244. this.chooseHouseList = [];
  245. res.forEach((item, index) => {
  246. this.chooseHouseList.push({
  247. value: item.id,
  248. label: item.name,
  249. selectType: 'louyu'
  250. })
  251. })
  252. })
  253. this.keyword = '';
  254. } else if (selectType == 'danyuan') {
  255. console.log('ssss', this.selectType)
  256. service.getUnit({
  257. buildingId: this.buildid,
  258. name: this.keyword
  259. }).then(res => {
  260. this.chooseHouseList = [];
  261. res.forEach((item, index) => {
  262. this.chooseHouseList.push({
  263. value: item.id,
  264. label: item.name,
  265. selectType: 'danyuan'
  266. })
  267. })
  268. })
  269. this.keyword = '';
  270. } else if (selectType == 'menpai') {
  271. console.log('ssss', this.selectType)
  272. service.getAllHouse({
  273. unitId: this.unitid,
  274. name: this.keyword
  275. }).then(res => {
  276. this.chooseHouseList = [];
  277. res.forEach((item, index) => {
  278. this.chooseHouseList.push({
  279. value: item.id,
  280. label: item.name,
  281. selectType: 'menpai'
  282. })
  283. })
  284. })
  285. this.keyword = '';
  286. }
  287. },
  288. openHouse(selectType) {
  289. if (selectType === 'district') {
  290. this.inputShow = false
  291. //选择行政区
  292. this.housename = null;
  293. this.selectType = 'district'
  294. service.getDistrict().then(res => {
  295. // console.log(res);
  296. this.chooseHouseList = [];
  297. res.forEach((item, index) => {
  298. this.chooseHouseList.push({
  299. value: item.dictValue,
  300. label: item.dictLabel,
  301. selectType: 'district'
  302. })
  303. })
  304. })
  305. } else if (selectType === 'xiaoqu') {
  306. this.inputShow = true
  307. //选择小区
  308. this.selectType = 'xiaoqu'
  309. service.getArea({
  310. district: this.districtId
  311. }).then(res => {
  312. this.chooseHouseList = [];
  313. res.forEach((item, index) => {
  314. this.chooseHouseList.push({
  315. value: item.id,
  316. label: item.name,
  317. selectType: 'xiaoqu'
  318. })
  319. })
  320. })
  321. } else if (selectType === 'louyu') {
  322. this.inputShow = true
  323. //选择楼宇
  324. this.selectType = 'louyu'
  325. this.housename = null;
  326. this.buildid = 0;
  327. service.getBuilding({
  328. areaId: this.houseid
  329. }).then(res => {
  330. this.chooseHouseList = [];
  331. res.forEach(item => {
  332. this.chooseHouseList.push({
  333. value: item.id,
  334. label: item.name,
  335. selectType: 'louyu'
  336. })
  337. })
  338. })
  339. } else if (selectType === 'danyuan') {
  340. this.inputShow = true
  341. //选择单元
  342. this.selectType = 'danyuan'
  343. this.housename = null;
  344. this.unitid = 0;
  345. service.getUnit({
  346. buildingId: this.buildid
  347. }).then(res => {
  348. this.chooseHouseList = [];
  349. res.forEach(item => {
  350. this.chooseHouseList.push({
  351. value: item.id,
  352. label: item.name,
  353. selectType: 'danyuan'
  354. })
  355. })
  356. })
  357. } else if (selectType === 'menpai') {
  358. this.inputShow = true
  359. //选择门牌
  360. console.log('menpai', this.numberid)
  361. this.selectType = 'menpai'
  362. this.housename = null;
  363. this.numberid = null;
  364. service.getAllHouse({
  365. unitId: this.unitid
  366. }).then(res => {
  367. this.chooseHouseList = [];
  368. res.forEach(item => {
  369. this.chooseHouseList.push({
  370. value: item.id,
  371. label: item.name,
  372. selectType: 'menpai'
  373. })
  374. })
  375. })
  376. }
  377. this.pop = !this.pop;
  378. },
  379. active(item, index) {
  380. this.current = index;
  381. this.housename = item.label;
  382. if (item.selectType == 'district') { //行政区
  383. this.districtId = item.value;
  384. } else if (item.selectType == 'xiaoqu') {
  385. this.houseid = item.value;
  386. } else if (item.selectType == 'louyu') {
  387. this.buildid = item.value;
  388. } else if (item.selectType == 'danyuan') {
  389. this.unitid = item.value;
  390. } else if (item.selectType == 'menpai') {
  391. this.numberid = item.value
  392. }
  393. this.selectType = item.selectType;
  394. },
  395. search(selectType) {
  396. if (selectType == 'district') {
  397. this.districtName = this.housename;
  398. service.getArea({
  399. district: this.districtId
  400. }).then(res => {
  401. this.chooseHouseList = [];
  402. res.forEach(item => {
  403. this.chooseHouseList.push({
  404. value: item.dictValue,
  405. label: item.dictLabel,
  406. selectType: 'xiaoqu'
  407. })
  408. })
  409. })
  410. this.current = -1;
  411. this.house = null;
  412. this.bulid = null;
  413. this.unit = null;
  414. this.houseNumber = null;
  415. this.houseid = 0;
  416. this.buildid = 0;
  417. this.unitid = 0;
  418. this.housedata = 0;
  419. } else if (selectType == 'xiaoqu') {
  420. this.house = this.housename;
  421. service.getBuilding({
  422. areaId: this.houseid
  423. }).then(res => {
  424. this.chooseHouseList = [];
  425. res.forEach(item => {
  426. this.chooseHouseList.push({
  427. value: item.id,
  428. label: item.name,
  429. selectType: 'louyu'
  430. })
  431. })
  432. })
  433. this.current = -1;
  434. this.bulid = null;
  435. this.unit = null;
  436. this.houseNumber = null;
  437. this.buildid = 0;
  438. this.unitid = 0;
  439. this.housedata = 0;
  440. } else if (selectType == 'louyu') {
  441. this.bulid = this.housename;
  442. service.getUnit({
  443. buildingId: this.buildid
  444. }).then(res => {
  445. this.chooseHouseList = [];
  446. res.forEach(item => {
  447. this.chooseHouseList.push({
  448. value: item.id,
  449. label: item.name,
  450. selectType: 'danyuan'
  451. })
  452. })
  453. })
  454. this.unit = null;
  455. this.houseNumber = null;
  456. this.current = -1;
  457. this.unitid = 0;
  458. this.housedata = 0;
  459. } else if (selectType == 'danyuan') {
  460. this.unit = this.housename;
  461. service.getAllHouse({
  462. unitId: this.unitid
  463. }).then(res => {
  464. this.chooseHouseList = [];
  465. res.forEach(item => {
  466. this.chooseHouseList.push({
  467. value: item.id,
  468. label: item.name,
  469. selectType: 'menpai'
  470. })
  471. })
  472. })
  473. this.houseNumber = null;
  474. this.current = -1;
  475. this.housedata = 0;
  476. } else if (selectType == 'menpai') {
  477. this.houseNumber = this.housename;
  478. this.housedata = this.numberid;
  479. // console.log('this.housedata', this.housedata)
  480. this.current = -1;
  481. }
  482. this.pop = false;
  483. },
  484. // getEngineDetail() {
  485. // service.getEngineDetail({
  486. // id: this.id
  487. // }).then(res => {
  488. // this.photo = res.photo
  489. // })
  490. // },
  491. choose() {
  492. let _this = this;
  493. uni.showActionSheet({
  494. title: '上传',
  495. itemList: ['图片', '视频'],
  496. success: (res) => {
  497. // console.log(res)
  498. if (res.tapIndex == 0) {
  499. this.chooseimage()
  500. } else {
  501. this.choosevideo()
  502. }
  503. }
  504. })
  505. },
  506. chooseimage() {
  507. console.log('图片')
  508. let _this = this;
  509. uni.chooseImage({
  510. sizeType: ['album', 'camera'],
  511. success(resp) {
  512. console.log('res--uni.chooseMedia', resp);
  513. resp.tempFiles.forEach((item, index) => {
  514. const task = uni.uploadFile({
  515. url: _this.$HTTP.webUrl + `/obs`,
  516. filePath: item.path,
  517. name: 'file',
  518. formData: {},
  519. header: _this.headers,
  520. success: res => {
  521. // 判断是否json字符串,将其转为json格式
  522. let data = _this.$u.test.jsonString(res
  523. .data) ? JSON.parse(res.data) : res.data;
  524. if (![200, 201, 204].includes(res.statusCode)) {
  525. // this.uploadError(index, data);
  526. _this.$UTILS.showPrompt('上传失败!')
  527. } else {
  528. // 上传成功
  529. // this.lists[index].response = data;
  530. // this.lists[index].progress = 100;
  531. // this.lists[index].error = false;
  532. // this.$emit('on-success', data, index, this.lists, this
  533. // .index);
  534. if (_this.progress === 100) {
  535. // console.log('_this.progress', _this.progress)
  536. // console.log('data----', data)
  537. // console.log('res--', res)
  538. _this.imgArr.push(data.data.url)
  539. // console.log('imgArr', _this.imgArr)
  540. _this.$UTILS.showPrompt('上传成功!')
  541. }
  542. }
  543. },
  544. fail: e => {
  545. _this.$UTILS.showPrompt('上传失败!')
  546. this.uploadError(index, e);
  547. },
  548. complete: res => {
  549. _this.uploading = false;
  550. // _this.uploadFile(index + 1);
  551. // this.$emit('on-change', res, index, this.lists, this
  552. // .index);
  553. }
  554. });
  555. task.onProgressUpdate(res => {
  556. // if (res.progress > 0) {
  557. // this.lists[index].progress = res.progress;
  558. // this.$emit('on-progress', res, index, this.lists, this.index);
  559. // }
  560. _this.progress = res.progress;
  561. console.log('onProgressUpdate', res)
  562. uni.showLoading({
  563. title: '上传中'
  564. })
  565. if (_this.progress != 100) {
  566. _this.loading = false
  567. console.log('_this.loading false', _this.loading)
  568. } else {
  569. _this.loading = true
  570. console.log('_this.loading true', _this.loading)
  571. }
  572. });
  573. })
  574. },
  575. })
  576. },
  577. choosevideo() {
  578. let _this = this;
  579. console.log('视频')
  580. uni.chooseVideo({
  581. sourceType: ['album', 'camera'],
  582. maxDuration: 30,
  583. success(resp) {
  584. const task = uni.uploadFile({
  585. url: _this.$HTTP.webUrl + `/obs`,
  586. filePath: resp.tempFilePath,
  587. name: 'file',
  588. formData: {},
  589. header: _this.headers,
  590. success: res => {
  591. // 判断是否json字符串,将其转为json格式
  592. let data = _this.$u.test.jsonString(res
  593. .data) ? JSON.parse(res.data) : res.data;
  594. if (![200, 201, 204].includes(res.statusCode)) {
  595. this.uploadError(index, data);
  596. } else {
  597. // 上传成功
  598. // this.lists[index].response = data;
  599. // this.lists[index].progress = 100;
  600. // this.lists[index].error = false;
  601. // this.$emit('on-success', data, index, this.lists, this
  602. // .index);
  603. if (_this.progress === 100) {
  604. console.log('_this.progress', _this.progress)
  605. console.log('data----', data)
  606. console.log('res--', res)
  607. _this.imgArr.push(data.data.url)
  608. console.log('imgArr', _this.imgArr)
  609. _this.$UTILS.showPrompt('上传成功!')
  610. }
  611. }
  612. },
  613. fail: e => {
  614. _this.$UTILS.showPrompt('上传失败!')
  615. this.uploadError(index, e);
  616. },
  617. complete: res => {
  618. uni.hideLoading();
  619. _this.uploading = false;
  620. // _this.uploadFile(index + 1);
  621. // this.$emit('on-change', res, index, this.lists, this
  622. // .index);
  623. }
  624. });
  625. task.onProgressUpdate(res => {
  626. // if (res.progress > 0) {
  627. // this.lists[index].progress = res.progress;
  628. // this.$emit('on-progress', res, index, this.lists, this.index);
  629. // }
  630. _this.progress = res.progress;
  631. console.log('onProgressUpdate', res)
  632. uni.showLoading({
  633. title: '上传中'
  634. })
  635. if (_this.progress != 100) {
  636. _this.loading = false
  637. console.log('_this.loading false', _this.loading)
  638. } else {
  639. _this.loading = true
  640. console.log('_this.loading true', _this.loading)
  641. }
  642. });
  643. },
  644. })
  645. },
  646. remove(index) {
  647. uni.showModal({
  648. title: '提示',
  649. content: '是否删除该图片或视频?',
  650. success: (res) => {
  651. if (res.confirm) {
  652. this.imgArr.splice(index, 1)
  653. console.log('this.imgarr', this.imgArr)
  654. }
  655. }
  656. })
  657. },
  658. openQualified() {
  659. this.qualifiedShow = !this.qualifiedShow;
  660. },
  661. qualifiedConfirm(e) {
  662. this.isqualified = e[0].value;
  663. }
  664. }
  665. }
  666. </script>
  667. <style lang="scss" scoped>
  668. .background {
  669. z-index: -1;
  670. position: fixed;
  671. width: 100%;
  672. height: 100%;
  673. background-size: 100% 100%;
  674. }
  675. .choose {
  676. text-align: center;
  677. padding: 20rpx;
  678. margin: 30rpx;
  679. color: #FFFFFF;
  680. background: #43CEB1;
  681. border-radius: 64rpx;
  682. }
  683. .upload {
  684. margin: 30rpx;
  685. padding: 30rpx 20rpx;
  686. border: 2rpx solid #3857F3;
  687. border-radius: 48rpx;
  688. }
  689. .active {
  690. background-color: #1890FF;
  691. }
  692. .project-content {
  693. border: 4rpx solid #3857F3;
  694. margin: 80rpx 55rpx 30rpx;
  695. padding: 30rpx 20rpx;
  696. border-radius: 48rpx;
  697. }
  698. .project {
  699. border-radius: 72rpx;
  700. padding: 25rpx 0;
  701. text-align: center;
  702. margin: 60rpx 55rpx 0;
  703. }
  704. .project-img {
  705. width: 300rpx;
  706. height: 168rpx;
  707. margin: 20rpx auto;
  708. }
  709. </style>