123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- //第一步
- import Vue from 'vue';
- import Vuex from 'vuex';
- import _ from 'lodash';
- Vue.use(Vuex);
- const api = {
- //接口地址
- company: `/api/servicetest/testmess`,
- };
- const state = () => ({});
- const mutations = {};
- const actions = {
- //查询列表 skip:第一页,limit:第一页显示的数据,info:其余查询参数
- async query({ commit }, { skip = 0, limit, ...info } = {}) {
- //连接接口。。。。
- const res = await this.$axios.$get(`${api.company}`, {
- skip,
- limit,
- ...info,
- });
- //把数据集合res返回
- return res;
- },
- //创建数据 payload是添加form表单中的数据集合 创建数据的时候需要拿到form表单里面的数据
- async create({ commit }, payload) {
- //通过$axios提交post请求????
- const res = await this.$axios.$post(`${api.company}`, payload);
- return res;
- },
- //查询详情,payload:参数位,一般传当前数据id
- async fetch({ commit }, payload) {
- //有/一般都是路径
- const res = await this.$axios.$get(`${api.company}/${payload}`);
- return res;
- },
- //修改:id: 当前数据id, data: 当前修改数据的新form表单
- async update({ commit }, { id, ...data }) {
- const res = await this.$axios.$post(`${api.company}/update/${id}`, data);
- return res;
- },
- //删除:payload:参数位,一般传当前数据id
- async delete({ commit }, payload) {
- const res = await this.$axios.$delete(`${api.company}/${payload}`);
- return res;
- },
- };
- export default {
- namespaced: true,
- state,
- mutations,
- actions,
- };
|