Step3.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <template>
  2. <div>
  3. <common @asynCallBack="asynCallBack" :projectCheck="false"></common>
  4. <top-header :pageTitle="pageTitle"></top-header>
  5. <div class="mui-content">
  6. <div class="mui-content-padded vongi-qingjiadt">
  7. <form class="mui-input-group">
  8. <div class="mui-input-row">
  9. <label>所在小区</label>
  10. <span v-text="subForm.companyName"></span>
  11. </div>
  12. <div class="mui-input-row">
  13. <label>您的身份</label>
  14. <span v-text="subForm.roleName"></span>
  15. </div>
  16. <div class="mui-input-row" @click="openPopover">
  17. <label>选择房号</label>
  18. <span id="openPopover" class="address">{{subForm.structureName?subForm.structureName:'点击选择房号'}}</span>
  19. </div>
  20. </form>
  21. </div>
  22. <div id="popover" class="mui-popover">
  23. <div class="mui-scroll-wrapper">
  24. <div class="mui-scroll">
  25. <div class="address-title">
  26. <h4>请选择房号</h4>
  27. <i class="mui-icon mui-icon-closeempty" @click="openPopover"></i>
  28. </div>
  29. <div class="address-table">
  30. <ul>
  31. <li v-for="(item,i) in selectDataJson"
  32. :class="{active:i==selectIndex}"
  33. :key="i" @click="changeIndex(i)">{{item.name}}</li>
  34. </ul>
  35. </div>
  36. <!--这里放置真实显示的DOM内容-->
  37. <ul class="mui-table-view">
  38. <li class="mui-table-view-cell " v-for="(item,i) in sz1"
  39. @click="clickLi(item)"
  40. :key="i">{{item.name}}</li>
  41. </ul>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="mui-content-padded vongi-qingjiadt" v-if="false">
  46. <form class="mui-input-group">
  47. <div v-for="(item,index) in structureNameList" :key="index" class="mui-input-row">
  48. <label v-text="item"></label>
  49. <button @click="selectStructure(index)" class="mui-btn mui-btn-block mui-navigate-right mui-ellipsis" type='button'
  50. style="width:65%">
  51. {{subForm.selectCompanyStructureList[index]?subForm.selectCompanyStructureList[index].name:'请选择'}}
  52. </button>
  53. </div>
  54. </form>
  55. </div>
  56. <div class="vongi-btn vongi-login-btn">
  57. <button class="mui-btn mui-btn-primary" @click="nextStep">
  58. 下一步
  59. </button>
  60. </div>
  61. </div>
  62. <loading :visible="isLoading"></loading>
  63. </div>
  64. </template>
  65. <script>
  66. import Vue from 'vue'
  67. require('$project/assets/js/mui.picker.min.js');
  68. import * as API_Person from '@/apis/person'
  69. import Common from '$project/components/Common.vue'
  70. import Loading from '$project/components/Loading.vue'
  71. import TopHeader from '$project/components/TopHeader.vue'
  72. import {
  73. mapGetters,
  74. mapMutations
  75. } from 'vuex'
  76. import * as types from '$project/store/mutation-types'
  77. export default {
  78. name: 'RegisterResidenceStep3',
  79. components: {
  80. Common,
  81. Loading,
  82. TopHeader
  83. },
  84. data() {
  85. return {
  86. pageTitle: '注册',
  87. subForm: {
  88. sceneId: '',
  89. sceneName: '',
  90. personRoleId: '',
  91. roleName: '',
  92. name: '',
  93. telephone: '',
  94. structureName:"",
  95. personId: '',
  96. companyId: '',
  97. companyName: '请选择',
  98. companyStructureId: '',
  99. //最终选择的数据
  100. selectCompanyStructureList: [],
  101. address: '',
  102. idCard: '',
  103. faceImageUrl: '',
  104. popularizePersonId: ''
  105. },
  106. isLoading: false,
  107. structureList: [],
  108. structureNameList: [],
  109. dataJson:[],
  110. selectIndex:0,
  111. selectDataJson:[
  112. {
  113. code:'',
  114. name:'请选择'
  115. },{
  116. code:'',
  117. name:'请选择'
  118. },{
  119. code:'',
  120. name:'请选择'
  121. }
  122. ]
  123. }
  124. },
  125. created() {
  126. this.subForm = this.register_form_data;
  127. },
  128. methods: {
  129. openPopover(){
  130. mui('#popover').popover('toggle');
  131. mui(".mui-scroll-wrapper").scroll()
  132. },
  133. clickLi(item){
  134. // this.subForm.companyStructureId=''
  135. var bl=true;
  136. if(this.selectDataJson[this.selectIndex].code==item.code){
  137. bl=false;
  138. }
  139. this.selectDataJson[this.selectIndex]=item
  140. if(this.selectIndex+1<this.selectDataJson.length){
  141. if(bl){
  142. var index=this.selectIndex+1;
  143. for(var i=index; i< this.selectDataJson.length;i++){
  144. this.selectDataJson[i]={
  145. code:'',
  146. name:'请选择'
  147. }
  148. }
  149. this.$forceUpdate();
  150. }
  151. this.selectIndex++
  152. }else{
  153. this.openPopover()
  154. }
  155. this.subForm.structureName=""
  156. this.selectDataJson.forEach(item=>{
  157. if(item.code!=''){
  158. this.subForm.structureName=item.name;
  159. }
  160. })
  161. this.$forceUpdate();
  162. },
  163. changeIndex(i){
  164. if(i==this.selectIndex||i==0){
  165. this.selectIndex=i;
  166. return
  167. }
  168. if(this.selectDataJson[i-1].code==""){
  169. mui.toast('请先选择上一项');
  170. }else{
  171. this.selectIndex=i;
  172. }
  173. },
  174. //获取公司部门列表
  175. getStructureList() {
  176. this.isLoading = true;
  177. API_Person.communityList({
  178. communityId: this.subForm.companyId
  179. }).then(response => {
  180. this.isLoading = false;
  181. this.dataJson=response.list;
  182. }).catch(error => {
  183. this.isLoading = false;
  184. mui.toast(error);
  185. })
  186. },
  187. //选择部门
  188. selectStructure(index) {
  189. if (this.structureList[index]) {
  190. var structureList = [];
  191. for (var i = 0; i < this.structureList[index].length; i++) {
  192. structureList.push({
  193. value: this.structureList[index][i]['id'],
  194. text: this.structureList[index][i]['structureName'],
  195. })
  196. }
  197. var _this = this;
  198. var picker = new mui.PopPicker();
  199. picker.setData(structureList);
  200. picker.show(function(selectItems) {
  201. _this.getStructureListNext(index);
  202. //设置保存数据
  203. Vue.set(_this.subForm.selectCompanyStructureList, index, {
  204. id: selectItems[0].value,
  205. name: selectItems[0].text
  206. })
  207. })
  208. } else {
  209. mui.toast('请选择' + this.structureNameList[index - 1]);
  210. }
  211. },
  212. //获取下一层机构数据
  213. getStructureListNext(index) {
  214. //如果有下一层数据就去读取
  215. if (this.structureNameList[index + 1]) {
  216. this.isLoading = true;
  217. API_Person.getCompanyStructureByName(this.subForm.companyId, this.structureNameList[index + 1]).then(response => {
  218. this.isLoading = false;
  219. Vue.set(this.structureList, index + 1, response)
  220. }).catch(error => {
  221. this.isLoading = false;
  222. mui.toast(error);
  223. })
  224. }
  225. },
  226. //检测表单
  227. checkForm() {
  228. if (!this.subForm.companyStructureId ) {
  229. mui.toast('请选择房号');
  230. return false;
  231. } else {
  232. return true;
  233. }
  234. },
  235. //下一步
  236. nextStep() {
  237. this.subForm.companyStructureId=this.selectDataJson[this.selectDataJson.length-1].code
  238. //this.subForm.companyStructureName==this.selectDataJson[this.selectDataJson.length-1].name
  239. if (this.checkForm()) {
  240. this.set_register_form_data(this.subForm);
  241. this.$router.push({
  242. name: 'RegisterResidenceStep4'
  243. })
  244. }
  245. },
  246. asynCallBack() {
  247. },
  248. ...mapMutations({
  249. set_register_form_data: types.SET_REGISTER_FORM_DATA,
  250. })
  251. },
  252. mounted() {
  253. mui(".mui-scroll-wrapper").scroll()
  254. //获取公司部门列表
  255. this.getStructureList();
  256. },
  257. destroyed() {
  258. },
  259. computed: {
  260. sz1(){
  261. var sz=[]
  262. if(this.selectIndex==0){
  263. this.dataJson.forEach(item=>{
  264. sz.push({
  265. code:item.id,
  266. name:item.name,
  267. children:item.children
  268. })
  269. })
  270. }else{
  271. //console.log(this.selectDataJson[this.selectIndex])
  272. this.selectDataJson[this.selectIndex-1].children.map(item=>{
  273. if(!item.children){
  274. item.children=[]
  275. }
  276. sz.push({
  277. code:item.id,
  278. name:item.name,
  279. children:item.children
  280. })
  281. })
  282. }
  283. return sz;
  284. },
  285. ...mapGetters({
  286. openId: 'wx_openid',
  287. token: 'token',
  288. person_data: 'person_data',
  289. person_popedom: 'person_popedom',
  290. register_form_data: 'register_form_data'
  291. })
  292. }
  293. }
  294. </script>
  295. <style scoped src="$project/assets/css/xpwyfyy.css"></style>
  296. <style src="$project/assets/css/iconfont.css"></style>
  297. <style src="$project/assets/css/mui.picker.min.css"></style>
  298. <style lang="scss" scoped>
  299. .mui-popover {
  300. .mui-table-view{
  301. max-height: 500px;
  302. }
  303. .mui-table-view-cell{
  304. position: relative;
  305. }
  306. .select::before{
  307. content: "\e472";
  308. position: absolute;
  309. font-family: Muiicons;
  310. font-size: 30px;
  311. right: 5px;
  312. top: 10px;
  313. color:#f5b33d;
  314. }
  315. }
  316. .address{
  317. font-size: 15px;
  318. color:#757575;
  319. }
  320. .address-title{
  321. padding-top:20px;
  322. text-align: center;
  323. position: relative;
  324. i{position: absolute;right: 10px;top:20px}
  325. }
  326. .address-table{
  327. padding: 10px;
  328. ul{
  329. overflow: hidden;
  330. }
  331. ul li{
  332. float: left;
  333. margin-right: 15px;
  334. color:#999;
  335. font-size: 14px;
  336. list-style:none;
  337. }
  338. .active{
  339. color:#1890ff;
  340. }
  341. }
  342. .mui-popover{
  343. width: 100%;
  344. left: 0!important;
  345. right: 0;
  346. bottom: 0;
  347. top:200px!important;
  348. border-radius:10px 10px 0 0;
  349. }
  350. .mui-popover .mui-popover-arrow{
  351. display: none;
  352. }
  353. </style>