import { getModule, Module, MutationAction, VuexModule } from 'vuex-module-decorators';
import store from '@/store';
import http from '@/utils/request';
import { url } from '@/utils/url';
import { session } from '@/store/modules/session';
import { stringify } from 'query-string';

@Module({
  namespaced: true,
  dynamic: true,
  store,
  name: 'raw.model',
})
export class ReceiptModule extends VuexModule {
  /**
   * 原材料菜单
   */
  menuList = [];
  /**
   * 查询原材料菜单列表
   */
  @MutationAction
  async getMenuList() {
    const result: any = await http.post(
      url.menu,
      stringify({
        factoryCode: session.factoryCode,
        loginName: session.loginName,
        resType: 3,
      }),
    );
    console.log('aaaa', result);
    const menuList = result.data;
    return { menuList };
  }
}

export default getModule(ReceiptModule);
