updateInfo.vue 16 KB

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