zrlibs
2025-03-21 cd24c776d772c7ad797891afd779b3b072293ec2
src/views/examples/data-table/index.vue
@@ -1,70 +1,9 @@
<template>
  <div class="example-data-table" ref="refView">
    <div class="search-form">
      <Form :model="form" :label-width="110">
        <Row>
          <Col span="6">
            <FormItem label="仓库编码:">
              <Input v-model="form.code" size="small"></Input>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="仓库名称:">
              <Input v-model="form.name" size="small"></Input>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="仓库负责人:">
              <Input v-model="form.leader" size="small"></Input>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="仓库电话:">
              <Input v-model="form.tel" size="small"></Input>
            </FormItem>
          </Col>
        </Row>
        <Row>
          <Col span="6">
            <FormItem label="上级仓库编码:">
              <Input v-model="form.topCode" size="small"></Input>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="地址:">
              <Input v-model="form.address" size="small"></Input>
            </FormItem>
          </Col>
          <Col span="4">
            <FormItem :label-width="34">
              <Checkbox v-model="form.isThisLevel" size="small"
                >是否本级</Checkbox
              >
            </FormItem>
          </Col>
          <Col span="4">
            <FormItem :label-width="34">
              <Checkbox v-model="form.isEscrow" size="small">是否代管</Checkbox>
            </FormItem>
          </Col>
          <Col span="4">
            <FormItem :label-width="34">
              <Checkbox v-model="form.isEnable" size="small">是否启用</Checkbox>
            </FormItem>
          </Col>
        </Row>
      </Form>
    </div>
    <div class="buttons">
      <Space>
        <Button type="success" size="small" @click="onAddClick">新增</Button>
        <Button type="warning" size="small" @click="onEditClick">修改</Button>
        <Button type="error" size="small" @click="onDelClick">删除</Button>
        <Button type="primary" size="small" @click="onViewClick">查看</Button>
      </Space>
    </div>
    <DataTable
      :tableHeight="tableHeight"
      :height="height"
      :formObject="formObject"
      :buttons="buttons"
      :columns="columns"
      :data="data"
      :page="page"
@@ -98,9 +37,31 @@
  },
  data() {
    return {
      formObject: {
        options: {},
        items: [],
      },
      buttons: [
        {
          showName: "新增",
          onClick: () => this.onAddClick(),
        },
        {
          showName: "修改",
          onClick: () => this.onEditClick(),
        },
        {
          showName: "删除",
          onClick: () => this.onDelClick(),
        },
        {
          showName: "查看",
          onClick: () => this.onViewClick(),
        },
      ],
      columns: [],
      data: [],
      tableHeight: 0,
      height: 0,
      // 分页信息
      page: 1,
      limit: 30,
@@ -129,12 +90,60 @@
    };
  },
  methods: {
    async loadForm() {
      this.formObject.options = {
        labelWidth: 110,
      };
      this.formObject.items = [
        {
          label: "仓库编码:",
          field: "SupplierCode",
          value: "",
          type: "input",
          span: 6,
        },
        {
          label: "仓库名称:",
          field: "SupplierName",
          value: "",
          type: "input",
          span: 6,
        },
        {
          label: "仓库电话:",
          field: "ASNCode",
          value: "",
          type: "input",
          span: 12,
        },
        {
          label: "地址:",
          field: "Invertory",
          value: "",
          type: "checkbox",
          span: 6,
        },
        {
          label: "是否本级",
          field: "PurchaseOrderNo",
          value: "",
          type: "checkbox",
          span: 6,
        },
        {
          label: "是否代管",
          field: "OrderDate",
          value: "",
          type: "checkbox",
          span: 12,
        },
      ];
    },
    async loadColumns() {
      this.columns = [
        {
          type: "selection",
          width: 40,
          fixed: "left",
          align: "center",
        },
        {
@@ -144,81 +153,13 @@
            return h("div", (this.page - 1) * this.limit + index + 1);
          },
          width: 40,
          fixed: "left",
          align: "center",
        },
        {
          key: "row_button",
          title: " ",
          render: (h, { row, index }) => {
            return h(
              resolveComponent("Space"),
              {},
              {
                default: () => [
                  h("a", [
                    h(
                      resolveComponent("Tooltip"),
                      {
                        content: "修改",
                        style: {
                          marginRight: "3px",
                        },
                      },
                      {
                        default: () =>
                          h(resolveComponent("icon"), {
                            type: "md-build",
                            size: 14,
                            color: "#f90",
                            onClick: () => this.onEditRowClick(index),
                          }),
                      }
                    ),
                    h(
                      resolveComponent("Tooltip"),
                      {
                        content: "删除",
                        transfer: true,
                        style: {
                          verticalAlign: "-1px",
                        },
                      },
                      {
                        default: () =>
                          h(
                            resolveComponent("Poptip"),
                            {
                              title: "是否确定删除此项?",
                              transfer: true,
                              confirm: true,
                              onOnOk: () => this.onDelClickItem(index),
                              onOnCancel: () => {},
                            },
                            {
                              default: () =>
                                h(resolveComponent("icon"), {
                                  type: "ios-trash-outline",
                                  size: 18,
                                  color: "#ed4014",
                                }),
                            }
                          ),
                      }
                    ),
                  ]),
                ],
              }
            );
          },
          width: 50,
          fixed: "left",
        },
        {
          key: "code",
          title: "仓库编码",
          width: 150,
          fixed: "left",
          sortable: true,
          resizable: true,
        },
@@ -308,6 +249,49 @@
          align: "center",
          sortable: true,
        },
        {
          key: "row_button",
          title: " ",
          render: (h, { row, index }) => {
            return h(
              resolveComponent("Space"),
              {},
              {
                default: () => [
                  h("a", [
                    h(
                      "span",
                      {
                        style: {
                          marginRight: "12px",
                        },
                        onClick: () => this.onEditRowClick(index),
                      },
                      "修改"
                    ),
                    ,
                    h(
                      resolveComponent("Poptip"),
                      {
                        title: "是否确定删除此项?",
                        transfer: true,
                        confirm: true,
                        onOnOk: () => this.onDelClickItem(index),
                        onOnCancel: () => {},
                      },
                      {
                        default: () => h("span", "删除"),
                      }
                    ),
                  ]),
                ],
              }
            );
          },
          width: 100,
          align: "center",
          fixed: "right",
        },
      ];
    },
    // 加载数据行
@@ -351,13 +335,7 @@
      });
    },
    resize() {
      let height =
        this.refView.clientHeight -
        this.$el.querySelector(".search-form").clientHeight -
        this.$el.querySelector(".buttons").clientHeight -
        9 -
        9;
      this.tableHeight = height;
      this.height = this.refView.clientHeight - 20;
    },
    onAddClick() {
      this.infoDialog.model = "add";
@@ -440,6 +418,7 @@
    },
  },
  async mounted() {
    await this.loadForm();
    await this.loadColumns();
    this.$nextTick(() => {
      this.resize();
@@ -456,8 +435,7 @@
<style lang="less">
.example-data-table {
  height: 100%;
  .search-form,
  .buttons {
  .search-form {
    margin-bottom: 9px;
  }
  .table {