dangerareacheck.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. <!--
  2. *危险区现场巡查
  3. *
  4. -->
  5. <template>
  6. <view class="container">
  7. <uni-nav-bar dark :fixed="true" backgroundColor="#3F9EFF" statusBar="false" left-icon="left" left-text="返回"
  8. @clickLeft="toBack">
  9. <view class="nav-title">
  10. <text>{{title}}</text>
  11. </view>
  12. </uni-nav-bar>
  13. <uni-forms ref="baseForm" :model="formData">
  14. <uni-section title="行政区及危险区选择" type="circle">
  15. <view class="search-block">
  16. <view style="padding-left: 15px;padding-right: 15px;margin-top: 0px;">
  17. <uni-forms-item v-if="checkType==1" name="cityRegionValue" label="盟市" label-width="120px"
  18. required>
  19. <uni-data-select v-model="formData.cityRegionValue" :localdata="cityRegionData"
  20. @change="cityRegionChange" :clear="false" placeholder="请选择盟市"></uni-data-select>
  21. </uni-forms-item>
  22. <uni-forms-item v-if="checkType==1" name="districtRegionValue" label="区旗县" label-width="120px"
  23. required>
  24. <uni-data-select v-model="formData.districtRegionValue" :localdata="districtRegionData"
  25. @change="districtRegionChange" placeholder="请选择区旗县"></uni-data-select>
  26. </uni-forms-item>
  27. <uni-forms-item v-if="checkType==1" name="townRegionValue" label="乡镇" label-width="120px"
  28. required>
  29. <uni-data-select v-model="formData.townRegionValue" :localdata="townRegionData"
  30. @change="townRegionChange" placeholder="请选择乡镇"></uni-data-select>
  31. </uni-forms-item>
  32. <uni-forms-item v-if="checkType==1" name="countryRegionValue" label="村" label-width="120px"
  33. required>
  34. <uni-data-select v-model="formData.countryRegionValue" :localdata="countryRegionData"
  35. @change="countryRegionChange" placeholder="请选择村"></uni-data-select>
  36. </uni-forms-item>
  37. <uni-forms-item name="dangerAreaValue" label="危险区" label-width="120px">
  38. <uni-data-select v-model="formData.dangerAreaValue" :localdata="dangerAreaData"
  39. @change="dangerAreaChange" placeholder="请选择危险区"></uni-data-select>
  40. </uni-forms-item>
  41. </view>
  42. </view>
  43. </uni-section>
  44. <uni-section title="定位信息" type="circle">
  45. <view style="padding-left: 15px;padding-right: 15px;">
  46. <view class="view-flex-inline" style="margin-bottom: 10px;">
  47. <view style="width: 100px;">经纬度</view>
  48. <view v-if="longitude != '' && latitude != ''">{{longitude}},{{latitude}}</view>
  49. </view>
  50. <view style="margin-bottom: 5px;font-size: 0.6rem;color:skyblue;">
  51. 备注:定位地址可进行人工修改</view>
  52. <uni-forms-item name='address' label="定位地址" label-width="120px">
  53. <uni-easyinput v-model="formData.address" placeholder="请录入定位地址" />
  54. </uni-forms-item>
  55. <uni-forms-item name='riverName' label="山洪沟名称" label-width="120px">
  56. <uni-easyinput v-model="formData.riverName" placeholder="请录入山洪沟名称" />
  57. </uni-forms-item>
  58. </view>
  59. </uni-section>
  60. <uni-section title="巡查反馈" type="circle">
  61. <view style="padding-left: 15px;padding-right: 15px;">
  62. <uni-forms-item name="isFlood" label="是否有山洪" label-width="120px" required>
  63. <uni-data-checkbox v-model="formData.isFlood" :localdata="checkItems.items"
  64. style="padding-top: 4px;">
  65. </uni-data-checkbox>
  66. </uni-forms-item>
  67. <uni-forms-item name="isDamage" label="是否成灾" label-width="120px" required>
  68. <uni-data-checkbox v-model="formData.isDamage" :localdata="checkItems.items"
  69. style="padding-top: 4px;">
  70. </uni-data-checkbox>
  71. </uni-forms-item>
  72. <uni-forms-item name="isWarn" label="是否发布预警" label-width="120px" required>
  73. <uni-data-checkbox v-model="formData.isWarn" :localdata="checkItems.items"
  74. style="padding-top: 4px;">
  75. </uni-data-checkbox>
  76. </uni-forms-item>
  77. <uni-forms-item v-if="formData.isWarn==1" name='warnInfo' label="预警信息" label-width="120px">
  78. <uni-easyinput v-model="formData.warnInfo" placeholder="请录入预警信息" />
  79. </uni-forms-item>
  80. <uni-forms-item name="isTransfer" label="是否人员转移" label-width="120px" required>
  81. <uni-data-checkbox v-model="formData.isTransfer" :localdata="checkItems.items"
  82. style="padding-top: 4px;">
  83. </uni-data-checkbox>
  84. </uni-forms-item>
  85. <uni-forms-item v-if="formData.isTransfer==1" name='transferInfo' label="人员转移信息"
  86. label-width="120px">
  87. <uni-easyinput v-model="formData.transferInfo" placeholder="请录入转移人数" />
  88. </uni-forms-item>
  89. <uni-forms-item name='remark' label="备注" label-width="120px">
  90. <uni-easyinput v-model="formData.remark" placeholder="请录入人员转移及人员伤亡、损失等灾害情况" />
  91. </uni-forms-item>
  92. </view>
  93. </uni-section>
  94. <uni-section title="巡查图片" sub-title="点击下方按钮开始拍摄" type="circle">
  95. <view style="padding-left: 15px;padding-right: 15px;">
  96. <view class="view-flex-inline">
  97. <view v-for="(item, index) in checkPhotos" :key="index" class="view-flex-block-center"
  98. style="width: 100px;">
  99. <view class="img-container">
  100. <view class="note-image-box">
  101. <view class="note-image-item">
  102. <view class="close-icon" @click="onCheckPhotoDel(index)">
  103. <uni-icons type="closeempty" size="18" color="#fff"></uni-icons>
  104. </view>
  105. <view class="image-box">
  106. <image :src="toOss(item)" mode="widthFix">
  107. </image>
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. </view>
  113. <view class="view-flex-block-center" style="width: 80px;">
  114. <view class="img-container">
  115. <view class="note-image-box">
  116. <view class="note-image-item" @click="onCheckPhotoAdd()">
  117. <view class="image-box">
  118. <uni-icons type="plusempty" size="50" color="#eee"></uni-icons>
  119. </view>
  120. </view>
  121. </view>
  122. </view>
  123. </view>
  124. </view>
  125. </view>
  126. </uni-section>
  127. </uni-forms>
  128. <view class="footer">
  129. <view class="control">
  130. <view class="view-flex-inline-center">
  131. <view class="block"
  132. style="width: 120px;height:28px;margin-left: 10px;margin-right: 10px;border-radius:7px;background-color:lightpink"
  133. @click="toSubmit()">
  134. <view class="view-flex-block-center">
  135. <uni-icons class="input-uni-icon" type="checkmarkempty" size="18" color="#999" />
  136. </view>
  137. <view class="view-flex-block-center" style="padding-left:5px;">
  138. <text style="color:black;font-size:0.7rem">立即提交</text>
  139. </view>
  140. </view>
  141. </view>
  142. </view>
  143. </view>
  144. </view>
  145. </template>
  146. <script>
  147. import {
  148. role
  149. } from "@/api/role.js";
  150. import http from '@/http/api.js';
  151. import {
  152. oss,
  153. devUrl,
  154. prodUrl
  155. } from '@/common/setting';
  156. import {
  157. gcoord
  158. } from '@/static/js/gcoord.global.prod.js'
  159. export default {
  160. data() {
  161. return {
  162. title: '现场巡查',
  163. baseURL: '',
  164. baseOSS: '',
  165. checkType: 0,
  166. id: '',
  167. warnId: '',
  168. warnAdcd: '',
  169. latitude: '',
  170. longitude: '',
  171. query: {},
  172. formData: {
  173. cityRegionValue: '',
  174. districtRegionValue: '',
  175. townRegionValue: '',
  176. countryRegionValue: '',
  177. dangerAreaValue: '',
  178. address: '',
  179. riverName: '',
  180. isFlood: 0,
  181. isDamage: 0,
  182. isWarn: 0,
  183. isTransfer: 0,
  184. warnInfo: '',
  185. transferInfo: '',
  186. remark: '',
  187. },
  188. rules: {
  189. cityRegionValue: {
  190. rules: [{
  191. required: true,
  192. errorMessage: '必选项',
  193. }]
  194. },
  195. districtRegionValue: {
  196. rules: [{
  197. required: true,
  198. errorMessage: '必选项',
  199. }, ]
  200. },
  201. townRegionValue: {
  202. rules: [{
  203. required: true,
  204. errorMessage: '必选项',
  205. }, ]
  206. },
  207. countryRegionValue: {
  208. rules: [{
  209. required: true,
  210. errorMessage: '必选项',
  211. }, ]
  212. },
  213. isFlood: {
  214. rules: [{
  215. required: true,
  216. errorMessage: '必选项',
  217. }, ]
  218. },
  219. isDamage: {
  220. rules: [{
  221. required: true,
  222. errorMessage: '必选项',
  223. }, ]
  224. },
  225. isWarn: {
  226. rules: [{
  227. required: true,
  228. errorMessage: '必选项',
  229. }, ]
  230. },
  231. isTransfer: {
  232. rules: [{
  233. required: true,
  234. errorMessage: '必选项',
  235. }, ]
  236. },
  237. },
  238. checkPhotos: [],
  239. checkItems: {
  240. items: [{
  241. 'value': 0,
  242. 'text': '否'
  243. }, {
  244. 'value': 1,
  245. 'text': '是'
  246. }],
  247. current: 0,
  248. },
  249. cityRegionData: [],
  250. districtRegionData: [],
  251. townRegionData: [],
  252. countryRegionData: [],
  253. dangerAreaData: [],
  254. }
  255. },
  256. onLoad(option) {
  257. let that = this;
  258. this.baseOSS = oss;
  259. this.baseURL = process.env.NODE_ENV === 'development' ? devUrl : prodUrl;
  260. this.checkType = option.type;
  261. if (this.checkType == 2) {
  262. this.id = option.id;
  263. this.warnId = option.warnId;
  264. this.warnAdcd = option.warnAdcd;
  265. this.formData.isWarn = 1;
  266. let params = {};
  267. params['id'] = this.id;
  268. this.getWarnDetail(params);
  269. }
  270. uni.getLocation({
  271. type: 'wgs84',
  272. success: function(res) {
  273. //console.log('当前位置:' + JSON.stringify(res));
  274. that.latitude = res.latitude;
  275. that.longitude = res.longitude;
  276. that.getAddress(res.longitude, res.latitude);
  277. },
  278. fail(res) {
  279. uni.showModal({
  280. content: '获取经纬度失败',
  281. showCancel: false
  282. });
  283. }
  284. });
  285. if (this.checkType == 1) {
  286. this.getCityRegion({});
  287. } else if (this.checkType == 2) {
  288. this.getDangerAreaList({
  289. 'adcd': this.warnAdcd
  290. })
  291. }
  292. },
  293. computed: {},
  294. onShow() {},
  295. onReady() {
  296. this.$refs.baseForm.setRules(this.rules)
  297. },
  298. methods: {
  299. toOss(path) {
  300. let url = this.baseOSS + path;
  301. return url;
  302. },
  303. //返回上一页
  304. toBack() {
  305. uni.navigateBack({
  306. delta: 1
  307. })
  308. },
  309. onBackPress() {
  310. // #ifdef APP-PLUS
  311. plus.key.hideSoftKeybord();
  312. // #endif
  313. },
  314. getAddress(lng, lat) {
  315. let that = this;
  316. let url = 'https://apis.map.qq.com/ws/geocoder/v1/?location=' + lat + ',' + lng +
  317. '&key=4HYBZ-EB23D-SLC42-HQ5R3-LP3LQ-OZFU5';
  318. console.log(url);
  319. http.request({
  320. url: url,
  321. method: 'GET',
  322. }).then(res => {
  323. //console.log(JSON.stringify(res));
  324. }).catch(err => {
  325. //console.log(JSON.stringify(err))
  326. that.formData.address = err.data.result.address;
  327. })
  328. },
  329. getWarnDetail(params = {}) {
  330. let that = this;
  331. Object.assign(this.query, params);
  332. http.request({
  333. url: '/galaxy-business/yj/warn/detail',
  334. method: 'GET',
  335. params: this.query
  336. }).then(res => {
  337. if (res.success) {
  338. that.formData.warnInfo = res.data.warnInfo;
  339. }
  340. }).catch(err => {
  341. console.log(err)
  342. })
  343. },
  344. cityRegionChange(e) {
  345. this.formData.cityRegionValue = e;
  346. this.districtRegionData = [];
  347. this.formData.districtRegionValue = '';
  348. this.townRegionData = [];
  349. this.formData.townRegionValue = '';
  350. this.countryRegionData = [];
  351. this.formData.countryRegionValue = '';
  352. this.dangerAreaData = [];
  353. this.formData.dangerAreaValue = '';
  354. let p = {
  355. 'parentCode': this.formData.cityRegionValue
  356. }
  357. this.getDistrictRegion(p);
  358. },
  359. districtRegionChange(e) {
  360. if (e == undefined || e == null || e == '') {
  361. this.formData.districtRegionValue = '';
  362. this.townRegionData = [];
  363. this.formData.townRegionValue = '';
  364. this.countryRegionData = [];
  365. this.formData.countryRegionValue = '';
  366. this.dangerAreaData = [];
  367. this.formData.dangerAreaValue = '';
  368. } else {
  369. this.formData.districtRegionValue = e;
  370. this.townRegionData = [];
  371. this.formData.townRegionValue = '';
  372. this.countryRegionData = [];
  373. this.formData.countryRegionValue = '';
  374. this.dangerAreaData = [];
  375. this.formData.dangerAreaValue = '';
  376. let p = {
  377. 'parentCode': this.formData.districtRegionValue
  378. }
  379. this.getTownRegion(p);
  380. }
  381. },
  382. townRegionChange(e) {
  383. if (e == undefined || e == null || e == '') {
  384. this.formData.townRegionValue = '';
  385. this.countryRegionData = [];
  386. this.formData.countryRegionValue = '';
  387. this.dangerAreaData = [];
  388. this.formData.dangerAreaValue = '';
  389. } else {
  390. this.formData.townRegionValue = e;
  391. this.countryRegionData = [];
  392. this.formData.countryRegionValue = '';
  393. this.dangerAreaData = [];
  394. this.formData.dangerAreaValue = '';
  395. let p = {
  396. 'parentCode': this.formData.townRegionValue
  397. }
  398. this.getCountryRegion(p);
  399. }
  400. },
  401. countryRegionChange(e) {
  402. if (e == undefined || e == null || e == '') {
  403. this.formData.countryRegionValue = '';
  404. this.formData.dangerAreaValue = '';
  405. this.dangerAreaData = [];
  406. } else {
  407. this.formData.countryRegionValue = e;
  408. this.formData.dangerAreaValue = '';
  409. this.dangerAreaData = [];
  410. this.getDangerAreaList({
  411. 'adcd': this.formData.countryRegionValue
  412. })
  413. }
  414. },
  415. dangerAreaChange(e) {
  416. if (e == undefined || e == null || e == '') {
  417. this.formData.dangerAreaValue = '';
  418. } else {
  419. this.formData.dangerAreaValue = e;
  420. }
  421. },
  422. getCityRegion(params = {}) {
  423. let that = this;
  424. http.request({
  425. url: '/galaxy-business/baseinfo/region/whole/yj/list',
  426. method: 'GET',
  427. data: params,
  428. }).then(res => {
  429. that.cityRegionData = res.data.map(item => {
  430. return {
  431. value: item.adcd,
  432. text: item.adnm,
  433. }
  434. })
  435. }).catch(err => {
  436. console.log(err)
  437. })
  438. },
  439. getDistrictRegion(params = {}) {
  440. let that = this;
  441. http.request({
  442. url: '/galaxy-business/baseinfo/region/whole/yj/list',
  443. method: 'GET',
  444. data: params,
  445. }).then(res => {
  446. that.districtRegionData = res.data.map(item => {
  447. return {
  448. value: item.adcd,
  449. text: item.adnm,
  450. }
  451. })
  452. }).catch(err => {
  453. console.log(err)
  454. })
  455. },
  456. getTownRegion(params = {}) {
  457. let that = this;
  458. http.request({
  459. url: '/galaxy-business/baseinfo/region/whole/yj/list',
  460. method: 'GET',
  461. data: params,
  462. }).then(res => {
  463. that.townRegionData = res.data.map(item => {
  464. return {
  465. value: item.adcd,
  466. text: item.adnm,
  467. }
  468. })
  469. }).catch(err => {
  470. console.log(err)
  471. })
  472. },
  473. getCountryRegion(params = {}) {
  474. let that = this;
  475. http.request({
  476. url: '/galaxy-business/baseinfo/region/whole/yj/list',
  477. method: 'GET',
  478. data: params,
  479. }).then(res => {
  480. that.countryRegionData = res.data.map(item => {
  481. return {
  482. value: item.adcd,
  483. text: item.adnm,
  484. }
  485. })
  486. }).catch(err => {
  487. console.log(err)
  488. })
  489. },
  490. getDangerAreaList(params = {}) {
  491. let postData = Object.assign(params, this.query);
  492. let that = this;
  493. http.request({
  494. url: '/galaxy-business/map/dangerarea/select',
  495. method: 'GET',
  496. data: postData,
  497. }).then(res => {
  498. that.dangerAreaData = res.data.map(item => {
  499. return {
  500. value: item.dangerAreaPid,
  501. text: item.dangerAreaName,
  502. }
  503. })
  504. }).catch(err => {
  505. console.log(err)
  506. })
  507. },
  508. onCheckPhotoAdd() {
  509. let that = this;
  510. uni.chooseImage({
  511. sourceType: ['camera'],
  512. sizeType: ['compressed'],
  513. success: (res) => {
  514. const len = res.tempFilePaths.length;
  515. if (len === 1) {
  516. res.tempFilePaths.forEach(path => {
  517. that.uploadCheckPhoto(path);
  518. })
  519. } else {
  520. uni.showModal({
  521. content: '只能选择一张图片,请确认!',
  522. showCancel: false
  523. });
  524. }
  525. }
  526. })
  527. },
  528. uploadCheckPhoto(imagePath) {
  529. let that = this;
  530. uni.showLoading({
  531. title: '上传中'
  532. });
  533. uni.uploadFile({
  534. url: this.baseURL + '/galaxy-resource/oss/endpoint/put-file-attach?Blade-Auth=' +
  535. uni.getStorageSync('accessToken'),
  536. fileType: 'image',
  537. filePath: imagePath,
  538. name: 'file',
  539. success: (uploadFileRes) => {
  540. if (uploadFileRes.statusCode == 200) {
  541. let data = JSON.parse(uploadFileRes.data);
  542. if (data.success) {
  543. let path = data.data['name'];
  544. that.checkPhotos.push(path);
  545. }
  546. }
  547. },
  548. fail: (err) => {
  549. console.log(err);
  550. reject('err')
  551. },
  552. complete() {
  553. uni.hideLoading()
  554. }
  555. });
  556. },
  557. onCheckPhotoDel(index) {
  558. this.checkPhotos.splice(index, 1);
  559. },
  560. toSubmit() {
  561. let that = this;
  562. this.$refs.baseForm.validate().then(res => {
  563. //console.log('表单数据信息1:', res);
  564. that.submit();
  565. }).catch(err => {
  566. //console.log('表单错误信息:', err);
  567. uni.showModal({
  568. content: "录入错误,请根据提示信息检查录入内容!",
  569. showCancel: false,
  570. success(res) {
  571. if (res.confirm) {
  572. //that.$refs.baseForm.clearValidate();
  573. }
  574. }
  575. });
  576. })
  577. },
  578. submit() {
  579. let formdata = this.formData;
  580. formdata['checkType'] = this.checkType;
  581. if (this.checkType == 1) {
  582. if (this.formData.countryRegionValue != undefined && this.formData.countryRegionValue != '' && this
  583. .formData.countryRegionValue.length > 0) {
  584. formdata['adcd'] = this.formData.countryRegionValue;
  585. }
  586. } else if (this.checkType == 2) {
  587. formdata['warnId'] = this.warnId;
  588. formdata['adcd'] = this.warnAdcd;
  589. }
  590. if (this.formData.dangerAreaValue != undefined && this.formData.dangerAreaValue != '' && this.formData
  591. .dangerAreaValue.length > 0) {
  592. formdata['dangerAreaPid'] = this.formData.dangerAreaValue;
  593. }
  594. formdata['longitude'] = this.longitude;
  595. formdata['latitude'] = this.latitude;
  596. if (this.checkPhotos.length > 0) {
  597. let photos = '';
  598. for (let i = 0; i < this.checkPhotos.length; i++) {
  599. if (photos.length > 0) {
  600. photos = photos + ',';
  601. }
  602. photos = photos + this.checkPhotos[i];
  603. }
  604. formdata['checkPhotos'] = photos;
  605. }
  606. //console.log('toSubmit事件:', JSON.stringify(formdata));
  607. let that = this;
  608. http.request({
  609. url: '/galaxy-business/yj/check/report',
  610. method: 'POST',
  611. data: formdata
  612. }).then(res => {
  613. //console.log('res ', JSON.stringify(res));
  614. if (res.success) {
  615. if (res.code == 200) {
  616. //that.clearCache();
  617. uni.showModal({
  618. content: '巡查信息已成功提交',
  619. showCancel: false,
  620. success(res) {
  621. if (res.confirm) {
  622. that.toBack();
  623. }
  624. }
  625. });
  626. } else {
  627. uni.showModal({
  628. content: '提交失败',
  629. showCancel: false
  630. });
  631. }
  632. } else {
  633. uni.showModal({
  634. content: '提交失败',
  635. showCancel: false
  636. });
  637. }
  638. }).catch(err => {
  639. // console.log('errr3',JSON.stringify(err));
  640. uni.showModal({
  641. content: '' + err.data.msg,
  642. showCancel: false
  643. });
  644. })
  645. },
  646. }
  647. }
  648. </script>
  649. <style lang="scss" scoped>
  650. .container {
  651. padding: 0 0 100rpx;
  652. }
  653. </style>