text: 
  import React from 'react'
  import pathToRegexp from 'path-to-regexp'
  import { routerRedux } from 'dva/router'
  import { notification } from 'antd'
  import GlobalComponents from '../../custcomponents';
  import appLocaleName from '../../common/Locale.tool'
  import modeltool from '../../utils/modeltool'
  const {setupModel,hasError,handleClientError,handleServerError,keepValueWithKeySuffix}=modeltool
  
  const notifySuccess=(userContext)=>{
  
  	notification.success({
          message: appLocaleName(userContext,'Success'),
          description: appLocaleName(userContext,'Success'),
        })
  
  }
  
  
  export default {
  
    namespace: '_userApp',
  
    state: {},
  
    subscriptions: {
      
      setup({ dispatch, history }) { 
        history.listen((location) => {
        	const modelName = 'userApp'
        	const parameter = {dispatch,history,location,modelName}
          //console.log("setupModel",setupModel,typeof(setupModel))
        	setupModel(parameter)
  
        })
      },
    },
    effects: {
      *view({ payload }, { call, put, select }) { 
      
        const cachedData = yield select(state => state._userApp)
        //if the data in the cache, just show it, there is no delay
        const link = payload.pathname
        //if the data in the cache, just show it, there is no delay
        if(cachedData.class){
          //yield put({ type: 'breadcrumb/gotoLink', payload: { displayName:cachedData.displayName,link }} )
          yield put({ type: 'updateState', payload: cachedData })
          
          if(payload.useCache){
          	return //use cache for returning page
          }
          
        }else{
          yield put({ type: 'showLoading', payload })
        }
        
        const {UserAppService} = GlobalComponents;
        const data = yield call(UserAppService.view, payload.id)
        
        const displayName = payload.displayName||data.displayName
        
        
        yield put({ type: 'breadcrumb/gotoLink', payload: { displayName,link }} )
        
  
        yield put({ type: 'updateState', payload: data })
      },
      *load({ payload }, { call, put }) { 
        const {UserAppService} = GlobalComponents;
        //yield put({ type: 'showLoading', payload })
        const data = yield call(UserAppService.load, payload.id, payload.parameters)
        const newPlayload = { ...payload, ...data }
        
        console.log('this is the data id: ', data.id)
        yield put({ type: 'updateState', payload: newPlayload })
      },
      
      *doJob({ payload }, { call, put }) { 
        const userContext = null
        const {TaskService} = GlobalComponents;
        //yield put({ type: 'showLoading', payload })      
        const {serviceNameToCall, id, parameters} = payload;
        if(!serviceNameToCall){
        	handleClientError(appLocaleName(userContext,'ServiceNotRegistered'))
        	return;
        }
        "react/dva_object_model.jsp"
        
        const data = yield call(serviceNameToCall, id, parameters)
        if(handleServerError(data)){
        	return
        }
        const newPlayload = { ...payload, ...data }
        
        console.log('this is the data id: ', data.id)
        yield put({ type: 'updateState', payload: newPlayload })
      },
         
      
      
      *gotoCreateForm({ payload }, { put }) {
        const { id, role } = payload
        yield put(routerRedux.push(`/userApp/${id}/list/${role}CreateForm`))
      },
      *gotoUpdateForm({ payload }, { put }) {
        const { id, role, selectedRows, currentUpdateIndex } = payload
        const state = { id, role, selectedRows, currentUpdateIndex }
        const location = { pathname: `/userApp/${id}/list/${role}UpdateForm`, state }
        yield put(routerRedux.push(location))
      },
      *goback({ payload }, { put }) {
        const { id, type,listName } = payload
        yield put(routerRedux.push(`/userApp/${id}/list/${type}List/${listName}`))
      },
  
  
  
  
      *addQuickLink({ payload }, { call, put }) {
        const userContext = null
        const {UserAppService} = GlobalComponents;
  
        const { id, role, parameters, continueNext } = payload
        console.log('get form parameters', parameters)
        const data = yield call(UserAppService.addQuickLink, id, parameters)
        if (hasError(data)) {
          handleServerError(data)
          return
        }
        const newPlayload = { ...payload, ...data }
        yield put({ type: 'updateState', payload: newPlayload })
        // yield put(routerRedux.push(`/userApp/${id}/list/${role}CreateForm'))
        notifySuccess(userContext)
        if (continueNext) {
          return
        }
        const partialList = true
        const newState = {...data, partialList}
        const location = { pathname: `/userApp/${id}/list/QuickLinkList/快速链接+${appLocaleName(userContext,'List')}`, state: newState }
        yield put(routerRedux.push(location))
      },
      *updateQuickLink({ payload }, { call, put }) {
        const userContext = null
        const {UserAppService} = GlobalComponents;      
        const { id, type, parameters, continueNext, selectedRows, currentUpdateIndex } = payload
        console.log('get form parameters', parameters)
        const data = yield call(UserAppService.updateQuickLink, id, parameters)
        if (hasError(data)) {
          handleServerError(data)
          return
        }
        const partialList = true
        
        const newPlayload = { ...payload, ...data, selectedRows, currentUpdateIndex,partialList }
        yield put({ type: 'updateState', payload: newPlayload })
        notifySuccess(userContext)
        
        if (continueNext) {
          return
        }
        const location = { pathname: `/userApp/${id}/list/QuickLinkList/快速链接列表`, state: newPlayload }
        yield put(routerRedux.push(location))
      },
      *gotoNextQuickLinkUpdateRow({ payload }, { call, put }) {
        const { id, type, parameters, continueNext, selectedRows, currentUpdateIndex } = payload
        const newPlayload = { ...payload, selectedRows, currentUpdateIndex }
        yield put({ type: 'updateState', payload: newPlayload })
      },
      *removeQuickLinkList({ payload }, { call, put }) {
       const userContext = null
        const {UserAppService} = GlobalComponents; 
        const { id, role, parameters, continueNext } = payload
        console.log('get form parameters', parameters)
        const data = yield call(UserAppService.removeQuickLinkList, id, parameters)
        if (hasError(data)) {
          handleServerError(data)
          return
        }
        const newPlayload = { ...payload, ...data }
  
        yield put({ type: 'updateState', payload: newPlayload })
        notifySuccess(userContext)
      },
  
  
  
  
      *addListAccess({ payload }, { call, put }) {
        const userContext = null
        const {UserAppService} = GlobalComponents;
  
        const { id, role, parameters, continueNext } = payload
        console.log('get form parameters', parameters)
        const data = yield call(UserAppService.addListAccess, id, parameters)
        if (hasError(data)) {
          handleServerError(data)
          return
        }
        const newPlayload = { ...payload, ...data }
        yield put({ type: 'updateState', payload: newPlayload })
        // yield put(routerRedux.push(`/userApp/${id}/list/${role}CreateForm'))
        notifySuccess(userContext)
        if (continueNext) {
          return
        }
        const partialList = true
        const newState = {...data, partialList}
        const location = { pathname: `/userApp/${id}/list/ListAccessList/访问列表+${appLocaleName(userContext,'List')}`, state: newState }
        yield put(routerRedux.push(location))
      },
      *updateListAccess({ payload }, { call, put }) {
        const userContext = null
        const {UserAppService} = GlobalComponents;      
        const { id, type, parameters, continueNext, selectedRows, currentUpdateIndex } = payload
        console.log('get form parameters', parameters)
        const data = yield call(UserAppService.updateListAccess, id, parameters)
        if (hasError(data)) {
          handleServerError(data)
          return
        }
        const partialList = true
        
        const newPlayload = { ...payload, ...data, selectedRows, currentUpdateIndex,partialList }
        yield put({ type: 'updateState', payload: newPlayload })
        notifySuccess(userContext)
        
        if (continueNext) {
          return
        }
        const location = { pathname: `/userApp/${id}/list/ListAccessList/访问列表列表`, state: newPlayload }
        yield put(routerRedux.push(location))
      },
      *gotoNextListAccessUpdateRow({ payload }, { call, put }) {
        const { id, type, parameters, continueNext, selectedRows, currentUpdateIndex } = payload
        const newPlayload = { ...payload, selectedRows, currentUpdateIndex }
        yield put({ type: 'updateState', payload: newPlayload })
      },
      *removeListAccessList({ payload }, { call, put }) {
       const userContext = null
        const {UserAppService} = GlobalComponents; 
        const { id, role, parameters, continueNext } = payload
        console.log('get form parameters', parameters)
        const data = yield call(UserAppService.removeListAccessList, id, parameters)
        if (hasError(data)) {
          handleServerError(data)
          return
        }
        const newPlayload = { ...payload, ...data }
  
        yield put({ type: 'updateState', payload: newPlayload })
        notifySuccess(userContext)
      },
  
  
  
  
      *addObjectAccess({ payload }, { call, put }) {
        const userContext = null
        const {UserAppService} = GlobalComponents;
  
        const { id, role, parameters, continueNext } = payload
        console.log('get form parameters', parameters)
        const data = yield call(UserAppService.addObjectAccess, id, parameters)
        if (hasError(data)) {
          handleServerError(data)
          return
        }
        const newPlayload = { ...payload, ...data }
        yield put({ type: 'updateState', payload: newPlayload })
        // yield put(routerRedux.push(`/userApp/${id}/list/${role}CreateForm'))
        notifySuccess(userContext)
        if (continueNext) {
          return
        }
        const partialList = true
        const newState = {...data, partialList}
        const location = { pathname: `/userApp/${id}/list/ObjectAccessList/对象访问+${appLocaleName(userContext,'List')}`, state: newState }
        yield put(routerRedux.push(location))
      },
      *updateObjectAccess({ payload }, { call, put }) {
        const userContext = null
        const {UserAppService} = GlobalComponents;      
        const { id, type, parameters, continueNext, selectedRows, currentUpdateIndex } = payload
        console.log('get form parameters', parameters)
        const data = yield call(UserAppService.updateObjectAccess, id, parameters)
        if (hasError(data)) {
          handleServerError(data)
          return
        }
        const partialList = true
        
        const newPlayload = { ...payload, ...data, selectedRows, currentUpdateIndex,partialList }
        yield put({ type: 'updateState', payload: newPlayload })
        notifySuccess(userContext)
        
        if (continueNext) {
          return
        }
        const location = { pathname: `/userApp/${id}/list/ObjectAccessList/对象访问列表`, state: newPlayload }
        yield put(routerRedux.push(location))
      },
      *gotoNextObjectAccessUpdateRow({ payload }, { call, put }) {
        const { id, type, parameters, continueNext, selectedRows, currentUpdateIndex } = payload
        const newPlayload = { ...payload, selectedRows, currentUpdateIndex }
        yield put({ type: 'updateState', payload: newPlayload })
      },
      *removeObjectAccessList({ payload }, { call, put }) {
       const userContext = null
        const {UserAppService} = GlobalComponents; 
        const { id, role, parameters, continueNext } = payload
        console.log('get form parameters', parameters)
        const data = yield call(UserAppService.removeObjectAccessList, id, parameters)
        if (hasError(data)) {
          handleServerError(data)
          return
        }
        const newPlayload = { ...payload, ...data }
  
        yield put({ type: 'updateState', payload: newPlayload })
        notifySuccess(userContext)
      },
  
    },
    
    reducers: {
      updateState(state, action) {
        const payload = { ...action.payload, loading: true }
        const valueToKeep = keepValueWithKeySuffix(state,"Parameters") 
        return { ...valueToKeep, ...payload}
      },
      showLoading(state, action) {
        // const loading=true
        const payload = { ...action.payload, loading: true }
        const valueToKeep = keepValueWithKeySuffix(state,"Parameters") 
        return { ...valueToKeep, ...payload}
      },
    },
  }
  
  