region.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <!--
  2. * @Title:
  3. * @Description: 危险区选择
  4. * @Author: swp
  5. * @Date: 2022-08-24 10:49:21
  6. * @LastEditors:
  7. * @LastEditTime: 2022-08-24 10:49:21
  8. -->
  9. <template>
  10. <view class="container">
  11. <uni-nav-bar dark :fixed="true" backgroundColor="#3F9EFF" statusBar="false" left-icon="left" left-text="返回"
  12. @clickLeft="toBack">
  13. <view class="nav-title">
  14. <text>{{title}}</text>
  15. </view>
  16. </uni-nav-bar>
  17. <uni-section title="行政区选择" type="line">
  18. <view class="search-block">
  19. <view style="padding-left: 10px;padding-right: 10px;">
  20. <uni-data-select v-model="cityRegionValue" :localdata="cityRegionData" @change="cityRegionChange"
  21. :clear="false" placeholder="请选择盟市"></uni-data-select>
  22. </view>
  23. <view style="padding-left: 10px;padding-right: 10px;margin-top: 10px;">
  24. <uni-data-select v-model="districtRegionValue" :localdata="districtRegionData"
  25. @change="districtRegionChange" placeholder="请选择区旗县"></uni-data-select>
  26. </view>
  27. <view style="padding-left: 10px;padding-right: 10px;margin-top: 10px;">
  28. <uni-data-select v-model="townRegionValue" :localdata="townRegionData" @change="townRegionChange"
  29. placeholder="请选择乡镇"></uni-data-select>
  30. </view>
  31. <view style="padding-left: 10px;padding-right: 10px;margin-top: 10px;">
  32. <uni-data-select v-model="countryRegionValue" :localdata="countryRegionData"
  33. @change="countryRegionChange" placeholder="请选择村"></uni-data-select>
  34. </view>
  35. </view>
  36. </uni-section>
  37. <view class="search-block">
  38. <view class="rtu-code">
  39. <uni-easyinput :styles="inputStyles" @input="searchRtuCodeValClear" prefixIcon="search"
  40. v-model="searchRtuCodeVal" placeholder="请录入危险区名称">
  41. </uni-easyinput>
  42. </view>
  43. <view class="submit-btn">
  44. <button type="default" @click="search">查 询</button>
  45. </view>
  46. </view>
  47. <view v-if="list.length>0">
  48. <uni-list>
  49. <uni-list-item v-for="item in list" :key="item.id">
  50. <template v-slot:body>
  51. <view class="list-item-block">
  52. <view class="line">
  53. <text class="title text-ellipsis text-underline" style="color: blue;"
  54. @click="selectDangerArea(item)">{{item.dangerAreaName}}</text>
  55. </view>
  56. <view class="line" style="margin-top: 5px;">
  57. <text class="lable">所属行政区:</text>
  58. <text class="content" style="color: gray;">{{item.fullAadName}}</text>
  59. </view>
  60. </view>
  61. </template>
  62. </uni-list-item>
  63. </uni-list>
  64. <uni-group>
  65. <view class="pagination-block">
  66. <uni-pagination show-icon :page-size="pageSize" :current="pageCurrent" :total="total"
  67. @change="pageChange" />
  68. </view>
  69. </uni-group>
  70. </view>
  71. <view v-else class="view-flex-inline-center">
  72. <view style="margin-top: 10px;color: gray;font-size: 1rem;">暂无数据</view>
  73. </view>
  74. </view>
  75. </view>
  76. </template>
  77. <script>
  78. import http from '@/http/api.js';
  79. export default {
  80. name: 'regionSelect',
  81. components: {},
  82. data() {
  83. return {
  84. title: '危险区选择',
  85. cityRegionValue: '',
  86. districtRegionValue: '',
  87. townRegionValue: '',
  88. countryRegionValue: '',
  89. cityRegionData: [],
  90. districtRegionData: [],
  91. townRegionData: [],
  92. countryRegionData: [],
  93. pageSize: 10,
  94. pageCurrent: 1,
  95. total: 0,
  96. list: [],
  97. searchRtuCodeVal: '',
  98. query: {},
  99. inputStyles: {
  100. color: '#808080',
  101. borderColor: '#d3d3d3'
  102. },
  103. loading: false,
  104. searchViewStyles: {
  105. width: '100%',
  106. height: '40px'
  107. },
  108. }
  109. },
  110. computed: {
  111. },
  112. onInit(option) {
  113. },
  114. onLoad(option) {
  115. this.getCityRegion({});
  116. },
  117. onShow() {
  118. },
  119. onReady() {
  120. },
  121. methods: {
  122. //返回上一页
  123. toBack() {
  124. uni.navigateBack({
  125. delta: 1
  126. })
  127. },
  128. // 分页触发
  129. pageChange(e) {
  130. this.pageCurrent = e.current;
  131. let params = {};
  132. if (this.searchRtuCodeVal != '' && this.searchRtuCodeVal.length > 0) {
  133. params['dangerAreaName'] = this.searchRtuCodeVal;
  134. }
  135. this.getDangerAreaPage(params);
  136. },
  137. cityRegionChange(e) {
  138. this.cityRegionValue = e;
  139. this.districtRegionData = [];
  140. this.districtRegionValue = '';
  141. this.townRegionData = [];
  142. this.townRegionValue = '';
  143. this.countryRegionData = [];
  144. this.countryRegionValue = '';
  145. let p = {
  146. 'parentCode': this.cityRegionValue
  147. }
  148. this.getDistrictRegion(p);
  149. this.pageCurrent = 1;
  150. this.query['adcd'] = this.cityRegionValue;
  151. this.getDangerAreaPage({});
  152. },
  153. districtRegionChange(e) {
  154. if (e == undefined || e == null || e == '') {
  155. this.districtRegionValue = '';
  156. this.townRegionData = [];
  157. this.townRegionValue = '';
  158. this.countryRegionData = [];
  159. this.countryRegionValue = '';
  160. this.pageCurrent = 1;
  161. this.query['adcd'] = this.cityRegionValue;
  162. this.getDangerAreaPage({});
  163. } else {
  164. this.districtRegionValue = e;
  165. this.townRegionData = [];
  166. this.townRegionValue = '';
  167. this.countryRegionData = [];
  168. this.countryRegionValue = '';
  169. let p = {
  170. 'parentCode': this.districtRegionValue
  171. }
  172. this.getTownRegion(p);
  173. this.pageCurrent = 1;
  174. this.query['adcd'] = this.districtRegionValue;
  175. this.getDangerAreaPage({});
  176. }
  177. },
  178. townRegionChange(e) {
  179. if (e == undefined || e == null || e == '') {
  180. this.townRegionValue = '';
  181. this.countryRegionData = [];
  182. this.countryRegionValue = '';
  183. this.pageCurrent = 1;
  184. this.query['adcd'] = this.districtRegionValue;
  185. this.getDangerAreaPage({});
  186. } else {
  187. this.townRegionValue = e;
  188. this.countryRegionData = [];
  189. this.countryRegionValue = '';
  190. let p = {
  191. 'parentCode': this.townRegionValue
  192. }
  193. this.getCountryRegion(p);
  194. this.pageCurrent = 1;
  195. this.query['adcd'] = this.townRegionValue;
  196. this.getDangerAreaPage({});
  197. }
  198. },
  199. countryRegionChange(e) {
  200. if (e == undefined || e == null || e == '') {
  201. this.countryRegionValue = '';
  202. this.pageCurrent = 1;
  203. this.query['adcd'] = this.townRegionValue;
  204. this.getDangerAreaPage({});
  205. } else {
  206. this.countryRegionValue = e;
  207. this.pageCurrent = 1;
  208. this.query['adcd'] = this.countryRegionValue;
  209. this.getDangerAreaPage({});
  210. }
  211. },
  212. getCityRegion(params = {}) {
  213. let that = this;
  214. http.request({
  215. url: '/galaxy-business/baseinfo/region/whole/yj/list',
  216. method: 'GET',
  217. data: params,
  218. }).then(res => {
  219. that.cityRegionData = res.data.map(item => {
  220. return {
  221. value: item.adcd,
  222. text: item.adnm,
  223. }
  224. })
  225. if (res.data.length > 0) {
  226. that.cityRegionValue = res.data[0].adcd;
  227. that.districtRegionData = [];
  228. that.districtRegionValue = '';
  229. that.townRegionData = [];
  230. that.townRegionValue = '';
  231. that.countryRegionData = [];
  232. that.countryRegionValue = '';
  233. let p = {
  234. 'parentCode': that.cityRegionValue
  235. }
  236. that.getDistrictRegion(p);
  237. that.pageCurrent = 1;
  238. that.query['adcd'] = this.cityRegionValue;
  239. that.getDangerAreaPage({});
  240. }
  241. }).catch(err => {
  242. console.log(err)
  243. })
  244. },
  245. getDistrictRegion(params = {}) {
  246. let that = this;
  247. http.request({
  248. url: '/galaxy-business/baseinfo/region/whole/yj/list',
  249. method: 'GET',
  250. data: params,
  251. }).then(res => {
  252. that.districtRegionData = res.data.map(item => {
  253. return {
  254. value: item.adcd,
  255. text: item.adnm,
  256. }
  257. })
  258. }).catch(err => {
  259. console.log(err)
  260. })
  261. },
  262. getTownRegion(params = {}) {
  263. let that = this;
  264. http.request({
  265. url: '/galaxy-business/baseinfo/region/whole/yj/list',
  266. method: 'GET',
  267. data: params,
  268. }).then(res => {
  269. that.townRegionData = res.data.map(item => {
  270. return {
  271. value: item.adcd,
  272. text: item.adnm,
  273. }
  274. })
  275. }).catch(err => {
  276. console.log(err)
  277. })
  278. },
  279. getCountryRegion(params = {}) {
  280. let that = this;
  281. http.request({
  282. url: '/galaxy-business/baseinfo/region/whole/yj/list',
  283. method: 'GET',
  284. data: params,
  285. }).then(res => {
  286. that.countryRegionData = res.data.map(item => {
  287. return {
  288. value: item.adcd,
  289. text: item.adnm,
  290. }
  291. })
  292. }).catch(err => {
  293. console.log(err)
  294. })
  295. },
  296. getDangerAreaPage(params = {}) {
  297. const current = this.pageCurrent;
  298. const size = this.pageSize;
  299. let postData = Object.assign(params, this.query);
  300. let that = this;
  301. http.request({
  302. url: '/galaxy-business/map/dangerarea/page',
  303. method: 'GET',
  304. params: {
  305. current,
  306. size,
  307. },
  308. data: postData,
  309. }).then(res => {
  310. if (res.data.records != null) {
  311. that.list = res.data.records;
  312. }
  313. this.total = res.data.total;
  314. }).catch(err => {
  315. console.log(err)
  316. })
  317. },
  318. search() {
  319. this.pageCurrent = 1;
  320. let params = {};
  321. if (this.searchRtuCodeVal != '' && this.searchRtuCodeVal.length > 0) {
  322. params['dangerAreaName'] = this.searchRtuCodeVal;
  323. }
  324. this.getDangerAreaPage(params);
  325. },
  326. searchRtuCodeValClear(e) {
  327. if (e == null || e == '' || e.length == 0) {
  328. this.searchRtuCodeVal = '';
  329. this.getDangerAreaPage({});
  330. }
  331. },
  332. onBackPress() {
  333. // #ifdef APP-PLUS
  334. plus.key.hideSoftKeybord();
  335. // #endif
  336. },
  337. selectDangerArea(item) {
  338. let p = {
  339. 'dangerAreaId': item.dangerAreaPid,
  340. 'dangerAreaName': item.dangerAreaName
  341. };
  342. uni.$emit('dangerAreaId', JSON.stringify(p))
  343. this.toBack();
  344. },
  345. }
  346. }
  347. </script>
  348. <style lang="scss" scoped>
  349. $nav-height: 75px;
  350. </style>