dangerareacheck.vue 20 KB

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