repair.vue 17 KB

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