region.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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. <!-- <uni-icons class="input-uni-icon" type="map-pin-ellipse" size="18" color="orangered" /> -->
  58. <text class="lable">所属行政区:</text>
  59. <text class="content" style="color: gray;">{{item.adnm}}</text>
  60. </view>
  61. </view>
  62. </template>
  63. </uni-list-item>
  64. </uni-list>
  65. <uni-group>
  66. <view class="pagination-block">
  67. <uni-pagination show-icon :page-size="pageSize" :current="pageCurrent" :total="total"
  68. @change="pageChange" />
  69. </view>
  70. </uni-group>
  71. </view>
  72. <view v-else class="view-flex-inline-center">
  73. <view style="margin-top: 10px;color: gray;font-size: 1rem;">暂无数据</view>
  74. </view>
  75. </view>
  76. </view>
  77. </template>
  78. <script>
  79. import http from '@/http/api.js';
  80. export default {
  81. name: 'regionSelect',
  82. components: {},
  83. data() {
  84. return {
  85. title: '危险区选择',
  86. cityRegionValue: '',
  87. districtRegionValue: '',
  88. townRegionValue: '',
  89. countryRegionValue: '',
  90. cityRegionData: [],
  91. districtRegionData: [],
  92. townRegionData: [],
  93. countryRegionData: [],
  94. pageSize: 10,
  95. pageCurrent: 1,
  96. total: 0,
  97. list: [],
  98. searchRtuCodeVal: '',
  99. query: {},
  100. inputStyles: {
  101. color: '#808080',
  102. borderColor: '#d3d3d3'
  103. },
  104. loading: false,
  105. searchViewStyles: {
  106. width: '100%',
  107. height: '40px'
  108. },
  109. }
  110. },
  111. computed: {
  112. },
  113. onInit(option) {
  114. },
  115. onLoad(option) {
  116. this.getCityRegion({});
  117. },
  118. onShow() {
  119. },
  120. onReady() {
  121. },
  122. methods: {
  123. //返回上一页
  124. toBack() {
  125. uni.navigateBack({
  126. delta: 1
  127. })
  128. },
  129. // 分页触发
  130. pageChange(e) {
  131. this.pageCurrent = e.current;
  132. let params = {};
  133. if (this.searchRtuCodeVal != '' && this.searchRtuCodeVal.length > 0) {
  134. params['dangerAreaName'] = this.searchRtuCodeVal;
  135. }
  136. this.getDangerAreaPage(params);
  137. },
  138. cityRegionChange(e) {
  139. this.cityRegionValue = e;
  140. this.districtRegionData = [];
  141. this.districtRegionValue = '';
  142. this.townRegionData = [];
  143. this.townRegionValue = '';
  144. this.countryRegionData = [];
  145. this.countryRegionValue = '';
  146. let p = {
  147. 'parentCode': this.cityRegionValue
  148. }
  149. this.getDistrictRegion(p);
  150. this.pageCurrent = 1;
  151. this.query['adcd'] = this.cityRegionValue;
  152. this.getDangerAreaPage({});
  153. },
  154. districtRegionChange(e) {
  155. if (e == undefined || e == null || e == '') {
  156. this.districtRegionValue = '';
  157. this.townRegionData = [];
  158. this.townRegionValue = '';
  159. this.countryRegionData = [];
  160. this.countryRegionValue = '';
  161. this.pageCurrent = 1;
  162. this.query['adcd'] = this.cityRegionValue;
  163. this.getDangerAreaPage({});
  164. } else {
  165. this.districtRegionValue = e;
  166. this.townRegionData = [];
  167. this.townRegionValue = '';
  168. this.countryRegionData = [];
  169. this.countryRegionValue = '';
  170. let p = {
  171. 'parentCode': this.districtRegionValue
  172. }
  173. this.getTownRegion(p);
  174. this.pageCurrent = 1;
  175. this.query['adcd'] = this.districtRegionValue;
  176. this.getDangerAreaPage({});
  177. }
  178. },
  179. townRegionChange(e) {
  180. if (e == undefined || e == null || e == '') {
  181. this.townRegionValue = '';
  182. this.countryRegionData = [];
  183. this.countryRegionValue = '';
  184. this.pageCurrent = 1;
  185. this.query['adcd'] = this.districtRegionValue;
  186. this.getDangerAreaPage({});
  187. } else {
  188. this.townRegionValue = e;
  189. this.countryRegionData = [];
  190. this.countryRegionValue = '';
  191. let p = {
  192. 'parentCode': this.townRegionValue
  193. }
  194. this.getCountryRegion(p);
  195. this.pageCurrent = 1;
  196. this.query['adcd'] = this.townRegionValue;
  197. this.getDangerAreaPage({});
  198. }
  199. },
  200. countryRegionChange(e) {
  201. if (e == undefined || e == null || e == '') {
  202. this.countryRegionValue = '';
  203. this.pageCurrent = 1;
  204. this.query['adcd'] = this.townRegionValue;
  205. this.getDangerAreaPage({});
  206. } else {
  207. this.countryRegionValue = e;
  208. this.pageCurrent = 1;
  209. this.query['adcd'] = this.countryRegionValue;
  210. this.getDangerAreaPage({});
  211. }
  212. },
  213. getCityRegion(params = {}) {
  214. let that = this;
  215. http.request({
  216. url: '/galaxy-business/baseinfo/region/whole/yj/list',
  217. method: 'GET',
  218. data: params,
  219. }).then(res => {
  220. that.cityRegionData = res.data.map(item => {
  221. return {
  222. value: item.adcd,
  223. text: item.adnm,
  224. }
  225. })
  226. }).catch(err => {
  227. console.log(err)
  228. })
  229. },
  230. getDistrictRegion(params = {}) {
  231. let that = this;
  232. http.request({
  233. url: '/galaxy-business/baseinfo/region/whole/yj/list',
  234. method: 'GET',
  235. data: params,
  236. }).then(res => {
  237. that.districtRegionData = res.data.map(item => {
  238. return {
  239. value: item.adcd,
  240. text: item.adnm,
  241. }
  242. })
  243. }).catch(err => {
  244. console.log(err)
  245. })
  246. },
  247. getTownRegion(params = {}) {
  248. let that = this;
  249. http.request({
  250. url: '/galaxy-business/baseinfo/region/whole/yj/list',
  251. method: 'GET',
  252. data: params,
  253. }).then(res => {
  254. that.townRegionData = res.data.map(item => {
  255. return {
  256. value: item.adcd,
  257. text: item.adnm,
  258. }
  259. })
  260. }).catch(err => {
  261. console.log(err)
  262. })
  263. },
  264. getCountryRegion(params = {}) {
  265. let that = this;
  266. http.request({
  267. url: '/galaxy-business/baseinfo/region/whole/yj/list',
  268. method: 'GET',
  269. data: params,
  270. }).then(res => {
  271. that.countryRegionData = res.data.map(item => {
  272. return {
  273. value: item.adcd,
  274. text: item.adnm,
  275. }
  276. })
  277. }).catch(err => {
  278. console.log(err)
  279. })
  280. },
  281. getDangerAreaPage(params = {}) {
  282. const current = this.pageCurrent;
  283. const size = this.pageSize;
  284. let postData = Object.assign(params, this.query);
  285. let that = this;
  286. http.request({
  287. url: '/galaxy-business/map/dangerarea/page',
  288. method: 'GET',
  289. params: {
  290. current,
  291. size,
  292. },
  293. data: postData,
  294. }).then(res => {
  295. if (res.data.records != null) {
  296. that.list = res.data.records;
  297. }
  298. this.total = res.data.total;
  299. }).catch(err => {
  300. console.log(err)
  301. })
  302. },
  303. search() {
  304. this.pageCurrent = 1;
  305. let params = {};
  306. if (this.searchRtuCodeVal != '' && this.searchRtuCodeVal.length > 0) {
  307. params['dangerAreaName'] = this.searchRtuCodeVal;
  308. }
  309. this.getDangerAreaPage(params);
  310. },
  311. searchRtuCodeValClear(e) {
  312. if (e == null || e == '' || e.length == 0) {
  313. this.searchRtuCodeVal = '';
  314. this.getDangerAreaPage({});
  315. }
  316. },
  317. onBackPress() {
  318. // #ifdef APP-PLUS
  319. plus.key.hideSoftKeybord();
  320. // #endif
  321. },
  322. selectDangerArea(item) {
  323. let p = {
  324. 'dangerAreaId': item.dangerAreaPid,
  325. 'dangerAreaName': item.dangerAreaName
  326. };
  327. uni.$emit('dangerAreaId', JSON.stringify(p))
  328. this.toBack();
  329. },
  330. }
  331. }
  332. </script>
  333. <style lang="scss" scoped>
  334. $nav-height: 75px;
  335. </style>