import Mock from "mockjs";

const data = Mock.mock({
  "items|+1": [
    {
      "time|+1": ["2020.04"],
      rate: "13%",
      add: "393.25",
      tax: "390",
      total: "3418.25",
      echartList: [
        { name: "增值税专用发票", value: "1" },
        { name: "增值税普通发票", value: "2" },
      ],
      list: [
        { name: "增值税专用发票", value: "1", sum: "321" },
        { name: "增值税普通发票", value: "1", sum: "331" },
        { name: "合计", value: "2", sum: "652" },
      ],
    },
  ],
});
const incomeData = Mock.mock({
  "items|+1": [
    {
      "time|+1": ["2020-04-01"],
      rate: "10%",
      add: "373",
      tax: "170",
      total: "3333.25",
      echartList: [
        { name: "增值税专用发票", value: "3" },
        { name: "增值税普通发票", value: "4" },
      ],
      list: [
        { name: "增值税专用发票", value: "3", sum: "200" },
        { name: "增值税普通发票", value: "5", sum: "300" },
        { name: "合计", value: "8", sum: "500" },
      ],
    },
  ],
});
export default [
  {
    url: `/invoice-list`,
    type: "post",
    response: (req, res, next) => {
      // req.body 可获取post参数
      // req.query 可获取get参数
      const items = data.items;
      return {
        body: {
          total: items.length,
          items: items,
        },
        head: {
          errorCode: "0",
          data: null,
        },
      };
    },
  },
  {
    url: `/income-list`,
    type: "post",
    response: (req, res, next) => {
      // req.body 可获取post参数
      // req.query 可获取get参数
      const items = incomeData.items;
      return {
        body: {
          total: items.length,
          items: items,
        },
        head: {
          errorCode: "0",
          data: null,
        },
      };
    },
  },
];
