text: import { querySingleRule, addRule, updateRule } from '../service';
  
  export default {
    namespace: 'templateDetail',
  
    state: {
      templatdetail: {
        Code: '',
        Name: '',
        Type: '',
        Comment: '',
        CreateDate: new Date(),
        HTML: '',
        TI_Z04902: [],
      },
    },
  
    effects: {
      *fetch({ payload }, { call, put }) {
        const response = yield call(querySingleRule, payload);
        if (response && response.Status === 200) {
          yield put({
            type: 'save',
            payload: {
              templatdetail: response.Content,
            },
          });
        }
      },
      *add({ payload, callback }, { call }) {
        const response = yield call(addRule, payload);
        if (callback) callback(response);
      },
      *update({ payload, callback }, { call }) {
        const response = yield call(updateRule, payload);
        if (callback) callback(response);
      },
    },
  
    reducers: {
      save(state, action) {
        return {
          ...state,
          ...action.payload,
        };
      },
    },
  };
  