zrlibs
2025-03-21 cd24c776d772c7ad797891afd779b3b072293ec2
src/views/examples/report.vue
@@ -1,9 +1,20 @@
<template>
  <div class="example-report-view" ref="refView">
    <DataTable
      :tableHeight="tableHeight"
      :height="height"
      :formObject="formObject"
      :buttons="buttons"
      :columns="columns"
      :data="data"
      :page="page"
      :limit="limit"
      :limits="limits"
      :total="total"
      :loading="loading"
      @on-change="onPageChange"
      @on-page-size-change="onPageSizeChange"
      @on-prev="onPrev"
      @on-next="onNext"
    ></DataTable>
  </div>
</template>
@@ -11,6 +22,7 @@
<script>
import { ref } from "vue";
import DataTable from "@/components/examples/data-table.vue";
import { exportExcel } from "./excel.js";
export default {
  name: "ExampleReportView",
  components: {
@@ -18,76 +30,302 @@
  },
  data() {
    return {
      formObject: {
        options: {},
        items: [],
      },
      buttons: [
        {
          showName: "查询",
          onClick: () => this.onSearchClick(),
        },
        {
          showName: "清空",
          onClick: () => this.onClearClick(),
        },
        {
          showName: "导出",
          onClick: () => this.onExportClick(),
        },
      ],
      columns: [],
      data: [],
      tableHeight: 0,
      height: 0,
      // 分页参数
      page: 1,
      limit: 30,
      limits: [10, 20, 30],
      total: 0,
      loading: false,
    };
  },
  methods: {
    async loadColumns() {
      this.columns = [
    async loadForm() {
      this.formObject.options = {
        labelWidth: 110,
      };
      this.formObject.items = [
        {
          type: "index",
          title: " ",
          render: (h, { index }) => {
            return h(index);
          },
          width: 50,
          label: "供应商编码:",
          field: "SupplierCode",
          value: "",
          type: "input",
          suffix: "ios-more",
          span: 6,
          onSuffixClick: () => {},
        },
        {
          key: "WH_Code",
          title: "仓库编码",
          width: 150,
          label: "供应商名称:",
          field: "SupplierName",
          value: "",
          type: "input",
          suffix: "ios-more",
          span: 6,
          onSuffixClick: () => {},
        },
        {
          key: "WH_Name",
          title: "仓库名称",
          label: "ASN单号:",
          field: "ASNCode",
          value: "",
          type: "input",
          suffix: "ios-more",
          span: 6,
          onSuffixClick: () => {},
        },
        {
          key: "WH_Leader",
          title: "仓库负责人",
          width: 100,
          label: "存货:",
          field: "Invertory",
          value: "",
          type: "input",
          suffix: "ios-more",
          span: 6,
          onSuffixClick: () => {},
        },
        {
          key: "WH_Tel",
          title: "仓库电话",
          width: 100,
          label: "代购订单号:",
          field: "PurchaseOrderNo",
          value: "",
          type: "input",
          suffix: "ios-more",
          span: 6,
          onSuffixClick: () => {},
        },
        {
          key: "Address",
          title: "地址",
          width: 100,
          label: "订单交期:",
          field: "OrderDate",
          value: "",
          type: "daterange",
          span: 12,
          onChange: () => {},
        },
        {
          key: "TopLevelWH_Code",
          title: "上级仓库编码",
          width: 100,
          label: "状态:",
          field: "State",
          value: "",
          type: "input",
          span: 6,
          options: [
            { labe: "一", value: 1 },
            { labe: "二", value: 2 },
            { labe: "三", value: 3 },
          ],
        },
        {
          key: "IsThisLevel",
          title: "是否本级",
          width: 70,
        },
        {
          key: "IsEscrow",
          title: "是否代管",
          width: 70,
        },
        {
          key: "IsEnable",
          title: "是否启用",
          width: 70,
          label: "采购员:",
          field: "Purchase",
          value: "",
          type: "input",
          span: 6,
        },
      ];
    },
    async loadData() {},
    async loadColumns() {
      this.columns = [
        {
          key: "index",
          title: " ",
          render: (h, { index }) => {
            return h("div", (this.page - 1) * this.limit + index + 1);
          },
          width: 40,
          align: "center",
        },
        {
          key: "ASNCode",
          title: "ASN单号",
          width: 100,
          sortable: true,
          resizable: true,
        },
        {
          key: "CloseState",
          title: "关闭状态",
          width: 100,
          sortable: true,
          resizable: true,
        },
        {
          key: "InventoryState",
          title: "存货状态",
          width: 100,
          sortable: true,
          resizable: true,
        },
        {
          key: "InvertoryName",
          title: "存货名称",
          width: 100,
          resizable: true,
        },
        {
          key: "SpecModel",
          title: "规格型号",
          width: 100,
          sortable: true,
          resizable: true,
        },
        {
          key: "AuditState",
          title: "审核状态",
          width: 100,
          resizable: true,
        },
        {
          key: "SendDate",
          title: "发货日期",
          width: 100,
          sortable: true,
          resizable: true,
        },
        {
          key: "SupplierCode",
          title: "供应商编码",
          width: 100,
          resizable: true,
        },
        {
          key: "SupplierName",
          title: "供应商名称",
          width: 100,
          resizable: true,
        },
        {
          key: "Creator",
          title: "创建人",
          width: 100,
        },
        {
          key: "CreateTime",
          title: "创建时间",
          width: 100,
          sortable: true,
        },
        {
          key: "PurchasePoint",
          title: "采购点",
          width: 100,
        },
      ];
    },
    // 加载数据行
    async loadData() {
      let msg = this.$Message.loading("正在加载数据...");
      this.loading = true;
      let { data, total } = await this.fakeDataList();
      msg();
      this.data = data;
      this.total = total;
      this.loading = false;
    },
    // 加载全部数据(导出)
    async loadAllData() {
      let msg = this.$Message.loading("正在加载数据...");
      this.loading = true;
      let { data } = await this.fakeDataList(this.total);
      msg();
      this.loading = false;
      return data;
    },
    // 测试数据列表
    fakeDataList(limit) {
      return new Promise((resolve) => {
        let total = 99;
        let fakeList = [];
        for (let i = 0; i < (limit || this.limit); i++) {
          let row = {
            ASNCode: `ASN单号-${(this.page - 1) * this.limit + i + 1}`,
            CloseState: `关闭状态-${(this.page - 1) * this.limit + i + 1}`,
            InventoryState: `存货状态-${(this.page - 1) * this.limit + i + 1}`,
            InvertoryName: `存货名称-${(this.page - 1) * this.limit + i + 1}`,
            SpecModel: `规格型号-${(this.page - 1) * this.limit + i + 1}`,
            AuditState: `审核状态-${(this.page - 1) * this.limit + i + 1}`,
            SendDate: `发货日期-${(this.page - 1) * this.limit + i + 1}`,
            SupplierCode: `供应商编码-${(this.page - 1) * this.limit + i + 1}`,
            SupplierName: `供应商名称-${(this.page - 1) * this.limit + i + 1}`,
            Creator: `创建人-${(this.page - 1) * this.limit + i + 1}`,
            CreateTime: `创建时间-${(this.page - 1) * this.limit + i + 1}`,
            PurchasePoint: `采购点-${(this.page - 1) * this.limit + i + 1}`,
          };
          if ((this.page - 1) * this.limit + i + 1 < 100) fakeList.push(row);
        }
        setTimeout(() => {
          resolve({ data: fakeList, total });
        }, 1 * 1000);
      });
    },
    resize() {
      this.tableHeight = this.refView.clientHeight;
      this.height = this.refView.clientHeight - 20;
    },
    onSearchClick() {
      alert(JSON.stringify(this.form, "", "    "));
    },
    onClearClick() {
      this.form.SupplierCode = "";
      this.form.ASNName = "";
      this.form.ASNCode = "";
      this.form.Invertory = "";
      this.form.PurchaseOrderNo = "";
      this.form.OrderDate = [];
      this.form.State = "";
      this.form.Purchase = "";
      this.form.PurchaseType = "";
      this.form.DocumentType = "";
      this.form.CloseState = "";
      this.form.IsArrived = "";
      this.form.ASNCreateDate = "";
    },
    async onExportClick() {
      let datas = await this.loadAllData();
      await exportExcel(this, datas);
    },
    onPageChange(page) {
      this.page = page;
      this.loadData();
    },
    onPageSizeChange(limit) {
      this.limit = limit;
      this.loadData();
    },
    onPrev(page) {
      this.page = page;
      this.loadData();
    },
    onNext(page) {
      this.page = page;
      this.loadData();
    },
  },
  async mounted() {
    await this.loadForm();
    await this.loadColumns();
    await this.loadData();
    this.loadData();
    this.$nextTick(() => {
      this.resize();
    });
@@ -99,7 +337,7 @@
};
</script>
<style lang="less" scoped>
<style lang="less">
.example-report-view {
  height: 100%;
}