Step2.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <div>
  3. <common @asynCallBack="asynCallBack" :projectCheck="false"></common>
  4. <top-header :pageTitle="pageTitle"></top-header>
  5. <div class="mui-content vongi-xzdw">
  6. <div class="mui-content-padded vongi-xzdw-search">
  7. <input @focusin="searchIn" @focusout="searchOut" @keyup="doSearchCompany" v-model="searchForm.name" type="search"
  8. placeholder="请输入公司名称">
  9. <span class="mui-icon mui-icon-search"></span>
  10. </div>
  11. <div v-show="showType=='select'">
  12. <div class="mui-content-padded fyy-date mui-clearfix">
  13. <h5>{{firstAreaName}} > {{secondAreaName}}</h5>
  14. </div>
  15. <!--地区选择-->
  16. <div v-show="nowLevel==1" class="mui-row mui-fullscreen vongi-xzdw-city">
  17. <div class="mui-col-xs-3">
  18. <div class="mui-segmented-control mui-segmented-control-inverted mui-segmented-control-vertical">
  19. <a @click="clickFirstArea(item)" v-for="(item,index) in firstAreaList" :class="'mui-control-item '+(item.name==firstAreaName?'mui-active':'')"
  20. v-text="item.name"></a>
  21. </div>
  22. </div>
  23. <div class="mui-col-xs-9">
  24. <div class="mui-control-content">
  25. <ul class="mui-table-view">
  26. <li @click="clickSecondArea(item)" v-for="(item,index) in secondAreaList" class="mui-table-view-cell" v-text="item.name"></li>
  27. </ul>
  28. </div>
  29. </div>
  30. </div>
  31. <!--公司选择-->
  32. <div v-show="nowLevel==2" class="mui-row mui-fullscreen vongi-xzdw-city">
  33. <div class="mui-col-xs-3">
  34. <div class="mui-segmented-control mui-segmented-control-inverted mui-segmented-control-vertical">
  35. <a @click="clickFirstCompany(item)" v-for="(item,index) in firstCompanyList" :class="'mui-control-item '+(item.name==secondAreaName?'mui-active':'')"
  36. v-text="item.name"></a>
  37. </div>
  38. </div>
  39. <div class="mui-col-xs-9">
  40. <div class="mui-control-content">
  41. <ul class="mui-table-view">
  42. <li @click="clickSecondCompany(item)" v-for="(item,index) in secondCompanyList" class="mui-table-view-cell"
  43. v-text="item.name"></li>
  44. </ul>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. <!--搜索结果的状态-->
  51. <div v-show="showType=='search'" class="mui-content vongi-xzdw" style="padding-top: 0;">
  52. <ul class="mui-table-view vongi-xzyljg">
  53. <li v-for="(item,index) in searchCompanyList" class="mui-table-view-cell mui-media">
  54. <a @click="clickSearchCompany(item)" v-text="item.name">
  55. </a>
  56. </li>
  57. </ul>
  58. </div>
  59. <loading :visible="isLoading"></loading>
  60. </div>
  61. </template>
  62. <script>
  63. import * as API_Person from '@/apis/person'
  64. import Common from '$project/components/Common.vue'
  65. import Loading from '$project/components/Loading.vue'
  66. import TopHeader from '$project/components/TopHeader.vue'
  67. import isReachBottom from '$project/utils/isReachBottom'
  68. import {
  69. mapGetters,
  70. mapMutations
  71. } from 'vuex'
  72. import * as types from '$project/store/mutation-types'
  73. export default {
  74. name: 'RegisterResidenceStep2',
  75. components: {
  76. Common,
  77. Loading,
  78. TopHeader
  79. },
  80. data() {
  81. return {
  82. pageTitle: '选择小区',
  83. subForm: {
  84. sceneId: '',
  85. sceneName: '',
  86. personRoleId: '',
  87. roleName: '',
  88. name: '',
  89. telephone: '',
  90. personId: '',
  91. companyId: '',
  92. companyName: '请选择',
  93. companyStructureId: '',
  94. //companyStructureName: '请选择',
  95. //最终选择的数据
  96. selectCompanyStructureList: [],
  97. address: '',
  98. idCard: '',
  99. faceImageUrl: '',
  100. popularizePersonId: ''
  101. },
  102. isLoading: false,
  103. firstAreaList: [],
  104. secondAreaList: [],
  105. firstAreaName: '',
  106. secondAreaName: '',
  107. //当前选择的层次
  108. nowLevel: 1,
  109. companyForm: {
  110. sceneId: '',
  111. regionId: '',
  112. },
  113. firstCompanyList: [],
  114. secondCompanyList: [],
  115. showType: 'select',
  116. searchForm: {
  117. sceneId: '',
  118. name: '',
  119. totalPage: 1,
  120. pageIndex: 1,
  121. pageSize: 20,
  122. },
  123. searchCompanyList: [],
  124. inputIng: false,
  125. }
  126. },
  127. created() {
  128. this.subForm = this.register_form_data;
  129. this.companyForm.sceneId = this.subForm.sceneId;
  130. this.searchForm.sceneId = this.subForm.sceneId;
  131. },
  132. methods: {
  133. //获取一级地区列表
  134. getFirstAreaList() {
  135. this.firstAreaName = '';
  136. this.getRegionList();
  137. },
  138. //获取地区列表
  139. getRegionList() {
  140. this.isLoading = true;
  141. API_Person.getRegionList(this.firstAreaName).then(response => {
  142. this.isLoading = false;
  143. if (this.firstAreaName) {
  144. for (var i = 0; i < response.length; i++) {
  145. if (response[i].name == this.firstAreaName) {
  146. this.secondAreaList = response[i].list;
  147. break;
  148. }
  149. }
  150. } else {
  151. this.firstAreaList = response;
  152. this.firstAreaName = response[0].name;
  153. }
  154. }).catch(error => {
  155. this.isLoading = false;
  156. mui.toast(error);
  157. })
  158. },
  159. //一级地区选择点击
  160. clickFirstArea(item) {
  161. this.firstAreaName = item.name;
  162. },
  163. //二级地区选择点击
  164. clickSecondArea(item) {
  165. this.companyForm.regionId = item.id;
  166. this.secondAreaName = item.name;
  167. this.nowLevel = 2;
  168. this.firstCompanyList = this.secondAreaList;
  169. //this.companyForm.regionId = this.secondAreaList[0].id;
  170. },
  171. //获取公司列表
  172. getCompanyList() {
  173. this.isLoading = true;
  174. API_Person.getCompanyList(this.companyForm).then(response => {
  175. this.isLoading = false;
  176. this.secondCompanyList = response.list;
  177. }).catch(error => {
  178. this.isLoading = false;
  179. mui.toast(error);
  180. })
  181. },
  182. //一级公司选择
  183. clickFirstCompany(item) {
  184. this.secondAreaName = item.name;
  185. this.companyForm.regionId = item.id;
  186. },
  187. //二级公司选择
  188. clickSecondCompany(item) {
  189. this.subForm.companyId = item.id;
  190. this.subForm.companyName = item.name;
  191. this.set_register_form_data(this.subForm);
  192. this.$router.push({
  193. name: 'RegisterResidenceStep1'
  194. })
  195. },
  196. //搜索出来的公司选择
  197. clickSearchCompany(item) {
  198. this.subForm.companyId = item.id;
  199. this.subForm.companyName = item.name;
  200. this.set_register_form_data(this.subForm);
  201. this.$router.push({
  202. name: 'RegisterResidenceStep1'
  203. })
  204. },
  205. //进入搜索
  206. searchIn() {
  207. this.inputIng = false;
  208. this.showType = 'search';
  209. },
  210. //离开搜索
  211. searchOut() {
  212. if (!this.searchForm.name) {
  213. this.showType = 'select';
  214. }
  215. },
  216. //搜索
  217. doSearchCompany() {
  218. if (this.inputIng) {
  219. return false
  220. }
  221. this.inputIng = true;
  222. var _this = this;
  223. setTimeout(function() {
  224. if (_this.searchForm.name) {
  225. _this.searchForm.pageIndex = 1;
  226. _this.getSearchCompanyList();
  227. }
  228. }, 500);
  229. },
  230. //根据公司名称搜索
  231. getSearchCompanyList() {
  232. this.isLoading = true;
  233. API_Person.getCompanyListBySeach(this.searchForm).then(response => {
  234. this.isLoading = false;
  235. if (response) {
  236. if (this.searchForm.pageIndex == 1) {
  237. this.searchCompanyList = response.data;
  238. this.searchForm.pageIndex = response.pageNumber;
  239. this.searchForm.totalPage = response.totalPage;
  240. } else {
  241. this.searchCompanyList = [
  242. ...this.searchCompanyList,
  243. ...response.data
  244. ];
  245. }
  246. }
  247. this.searchForm.pageIndex++;
  248. this.inputIng = false;
  249. }).catch(error => {
  250. this.isLoading = false;
  251. mui.toast(error);
  252. })
  253. },
  254. //下拉事件
  255. handleScrool() {
  256. if (isReachBottom()) {
  257. console.log('到达底部')
  258. if (this.listForm.pageIndex <= this.listForm.totalPage && this.isLoading == false) {
  259. this.getSearchCompanyList();
  260. } else {
  261. return;
  262. }
  263. }
  264. },
  265. asynCallBack() {
  266. },
  267. ...mapMutations({
  268. set_register_form_data: types.SET_REGISTER_FORM_DATA,
  269. })
  270. },
  271. mounted() {
  272. this.getFirstAreaList();
  273. //监控下拉加载事件
  274. var _this = this;
  275. window.addEventListener('scroll', _this.handleScrool);
  276. },
  277. destroyed() {
  278. //销毁监听事件
  279. var _this = this;
  280. window.removeEventListener('scroll', _this.handleScrool);
  281. },
  282. computed: {
  283. ...mapGetters({
  284. openId: 'wx_openid',
  285. token: 'token',
  286. person_data: 'person_data',
  287. person_popedom: 'person_popedom',
  288. register_form_data: 'register_form_data'
  289. })
  290. },
  291. watch: {
  292. 'firstAreaName': function(val) {
  293. this.getRegionList();
  294. },
  295. 'companyForm.regionId': function(val) {
  296. this.getCompanyList();
  297. }
  298. }
  299. }
  300. </script>
  301. <style scoped src="$project/assets/css/xpwyfyy.css"></style>
  302. <style scoped src="$project/assets/css/sczpfyy.css"></style>
  303. <style src="$project/assets/css/iconfont.css"></style>
  304. <style>
  305. </style>