<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-sys__user">
      <search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
      <base-table
        :table-props="tableProps"
        :page="listQuery.page"
        :limit="listQuery.limit"
        :table-data="tableData"
      />
      <pagination
        :limit.sync="listQuery.limit"
        :page.sync="listQuery.page"
        :total="listQuery.total"
        @pagination="getDataList"
      />
      <!-- 弹窗, 新增 / 修改 -->
      <base-dialog
        :dialogTitle="addOrEditTitle"
        :dialogVisible="addOrUpdateVisible"
        @cancel="handleCancel"
        @confirm="handleConfirm"
        :before-close="handleCancel"
      >
        <add-or-update ref="addOrUpdate" @successSubmit="successSubmit"></add-or-update>
      </base-dialog>
    </div>
  </el-card>
</template>

<script>
import basicPage from '@/mixins/basic-page'
import basicFilter from '@/filters/basic-filter'

const tableProps = [
  {
    prop: "name",
    label: "名称",
  },
  {
    prop: "code",
    label: "编码",
  },
  {
    prop: "type",
    label: "类型",
    filter: basicFilter("tType"),
  },
];

export default {
  mixins: [basicPage],
  data() {
    return {
      urlOptions: {
        getDataListURL: '/qualityPlanning/controlGraph/page',
        deleteURL: '/qualityPlanning/controlGraph',
        exportUrl: '/qualityPlanning/controlGraph/export'
      },
      tableProps,
      tableData: [],
      formConfig: [
        {
          type: "select",
          label: "类型",
          selectOptions: [
            { id: 1, name: "计量" },
            { id: 2, name: "计数" },
          ],
          param: "type",
          defaultSelect: "",
        },
        {
          type: "button",
          btnName: "查询",
          name: "search",
          color: "primary",
        },
      ],
    };
  },
  components: {
  },
  methods: {
    //search-bar点击
    buttonClick(val) {
      switch (val.btnName) {
        case "search":
          this.listQuery.type = val.type;
          this.listQuery.page = 1;
          this.getDataList();
          break;
        case "add":
          this.addOrEditTitle = '新增'
          this.addOrUpdateVisible = true;
          this.addOrUpdateHandle()
          break;
        case "export":
          this.exportHandle('控制图形')
          break;
        default:
          console.log(val)
       }
    },
  },
};
</script>
