/* global window */import modelExtend from 'dva-model-extend'import queryString from 'query-string'import { config } from 'utils'import { create, remove, update } from 'services/module'import * as moduleService from 'services/module'import { pageModel } from './common'const { query, queryDictByDictNo} = moduleServiceconst { prefix } = configexport default modelExtend(pageModel, {namespace: 'module',state: {currentItem: {},modalVisible: false,modalType: 'create',selectedRowKeys: [],},subscriptions: {setup ({ dispatch, history }) {history.listen((location) => {if (location.pathname === '/module') {const payload = queryString.parse(location.search) || { page: 1, pageSize: 10 }dispatch({type: 'query',payload,})}})},},effects: {* query ({ payload = {} }, { call, put }) {const data = yield call(query, payload)if (data) {yield put({type: 'querySuccess',payload: {list: data.items,pagination: {current: Number(data.currentPage) || 1,pageSize: Number(data.pageSize) || 20,total: data.totalNum,},},})}},* queryDictByNo ({ payload = {dictNo:1} }, { call, put }) {const data = yield call(queryDictByDictNo, payload)if (data) {yield put({type: 'querySuccess',payload: {list: data,},})}},* delete ({ payload }, { call, put, select }) {const data = yield call(remove, { id: payload })const { selectedRowKeys } = yield select(_ => _.user)if (data.success) {yield put({ type: 'updateState', payload: { selectedRowKeys: selectedRowKeys.filter(_ => _ !== payload) } })} else {throw data}},* multiDelete ({ payload }, { call, put }) {const data = yield call(dicService.multiRemove, payload)if (data.success) {yield put({ type: 'updateState', payload: { selectedRowKeys: [] } })} else {throw data}},* create ({ payload }, { call, put }) {const data = yield call(create, payload)if (data.success) {yield put({ type: 'hideModal' })} else {throw data}},* update ({ payload }, { select, call, put }) {const id = yield select(({ user }) => user.currentItem.id)const newUser = { ...payload, id }const data = yield call(update, newUser)if (data.success) {yield put({ type: 'hideModal' })} else {throw data}},},reducers: {showModal (state, { payload }) {return { ...state, ...payload, modalVisible: true }},hideModal (state) {return { ...state, modalVisible: false }},},})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。