123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- import { connect } from 'herculex';
- import { getIn } from 'herculex/dist/utils/manipulate';
- import { getDepList } from '../utils/service';
- import { history } from '../utils';
- import { reportCmPV_YL } from '../utils/cloudMonitorHelper';
- Component(connect({
- mapStateToProps: {
- bookingInfo: state => getIn(state, ['$global', 'bookingInfo'], {}),
- titleBarHeight: state => state.$global.titleBarHeight
- }
- })({
- props: {
- componentData: {}
- },
- data: {
- showLoading: true,
- noData: false,
- keyWord: '',
-
-
- deparmentList: [],
- chidrenList: [],
-
- bookInfo: {}
- },
- didMount() {
- console.log(this.data.titleBarHeight);
- const {
- serviceCode
- } = getCurrentPages().pop().options;
- reportCmPV_YL({
- title: '预约挂号',
- query: {
- serviceCode
- }
- });
- this.getDepartmentList();
- my.setNavigationBar({
- title: '选择科室'
- });
- },
- methods: {
-
- async getDepartmentList(departmentId = '', keyWord) {
- this.setData({
- noData: false,
- showLoading: true,
- deparmentList: [],
- chidrenList: []
- });
- const params = {
- departmentId,
- keyWord
- };
- const [, res] = await getDepList(params);
- if (res && res.length) {
- const departmentList = this.addTitle(res);
- this.setData({
- showLoading: false,
- activeTab: 0,
- deparmentList: departmentList,
- noData: false
- }, () => {
-
- departmentId = this.data.deparmentList[0].departmentId;
- const departmentName = this.data.deparmentList[0].name;
- const {
- hasChildren
- } = this.data.deparmentList[0];
- this.getChildrenList(departmentId, departmentName, hasChildren, keyWord);
- });
- } else {
- this.setData({
- showLoading: false,
- noData: true
- });
- }
- },
-
- addTitle(list) {
- return list.map(item => {
-
- item.title = item.name;
- return item;
- });
- },
-
- async getChildrenList(parentId, parentName, hasChildren, keyWord) {
- if (!hasChildren) {
- this.setData({
- chidrenList: this.addTitle([{
- departmentId: parentId,
- name: parentName,
- hasChildren
- }])
- });
- return;
- }
- this.setData({
- chidrenList: []
- });
- const params = {
- parentId,
- parentName,
- keyWord
- };
- const [, res] = await getDepList(params);
- if (res && res.length) {
- const departmentList = this.addTitle(res);
- if (this.data.deparmentList && this.data.deparmentList.length) {
- this.setData({
- chidrenList: departmentList
- });
- }
- }
- },
- handleChange(index) {
- this.setData({
- activeTab: index
- });
- const {
- departmentId,
- name,
- hasChildren
- } = this.data.deparmentList[index];
- this.getChildrenList(departmentId, name, hasChildren, this.data.keyWord);
- },
- clearkeyWord() {
- this.setData({
- keyWord: ''
- });
- this.getDepartmentList();
- },
- handleInput(keyWord) {
- this.setData({
- keyWord
- });
- this.getDepartmentList('', keyWord);
- },
- onItemClick(e) {
- const {
- departmentId,
- departmentName
- } = e.target.dataset;
- const bookInfo = {
- depId: departmentId,
- depName: departmentName
- };
- this.setData({
- bookInfo
- });
- history.openPage({
- pageType: 'choose-a-doctor',
- data: {
- bookInfo
- }
- });
- },
- handleRefresh() {
- this.getDepartmentList();
- }
- }
- }));
|