<template>
  <div>
    <el-card class="el-card">
      <el-form :model="filterQuery" class="query-form" label-width="100px" v-if="showSearch">
        <el-row>
          <el-col :span="11">
            <el-form-item label="单据标识">
              <el-input v-model="filterQuery.type" style="width: 90%" placeholder="请输入单据标识" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="11">
            <el-form-item label="单据名称">
              <el-input v-model="filterQuery.typeName" style="width: 90%" placeholder="请输入单据名称" clearable></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <div class="top-right-btn">
        <el-button-group style="display:flex;">
          <el-button icon="el-icon-view" type="primary" @click="hideSearch">显示/隐藏搜索栏</el-button>
          <el-button type="primary" icon="el-icon-refresh" @click="onReset">重置</el-button>
          <el-button type="primary" icon="el-icon-search" @click="onSubmitFind">查询</el-button>
<!--          <el-button type="primary" icon="el-icon-plus" @click="onAdd">新增</el-button>-->
        </el-button-group>
      </div>
      <el-divider style="margin: 15px"></el-divider>

      <el-table v-loading="loading" :data="list" style="width: 100%" border highlight-current-row>
        <el-table-column label="序号" type="index" width="60"></el-table-column>
        <el-table-column label="单据标识" prop="type"></el-table-column>
        <el-table-column label="单据名称" prop="typeName"></el-table-column>
        <el-table-column label="排序" prop="approvalSort"></el-table-column>
        <el-table-column label="操作" width="120">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click.native.stop="openEdit(scope.row)">审批过程
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>

    <el-dialog
      title="审批过程"
      :visible.sync="openEditVisible"
      width="80%"
      v-if="openEditVisible"
      @close='closeDialog'
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :before-close="handleClose"
    >
      <sysApprovalFlowConfigEdit
        :closeDialog="closeDialog"
        v-on:cancelDialog="getId"
        :idQuery="idQuery"
      ></sysApprovalFlowConfigEdit>
    </el-dialog>

  </div>
</template>

<script>
import {getList} from "@/api/basic/sysApprovalFlowConfig";
import sysApprovalFlowConfigEdit from "@/views/basic/approval/sysApprovalFlowConfigEdit";

export default {
  name: "SysApprovalFlowConfig",
  data() {
    return {
      openEditVisible: false,
      showSearch: true,
      activities: [],
      filterQuery: {
        type: '',
        typeName: '',
        page: 1,
        limit: 10
      },
      detailList: [],
      list: [],
      total: 0,
      idQuery: {},
    }
  }
  ,
  methods: {
    getId(id) {
      return
    },
    handleClose() {
      this.openEditVisible = false
      this.getList();
    },
    closeDialog() {
      this.openEditVisible = false;
      this.getList();
    },
    openEdit(row) {
      this.idQuery.type = row.type;
      this.idQuery.formData = row;
      this.openEditVisible = true;
    },
    hideSearch() {
      this.showSearch = !this.showSearch;
    },
    onSubmitFind() {
      this.filterQuery.page = 1;
      this.getList();
    },
    onReset() {
      this.filterQuery = {
        type: '',
        typeName: '',
        page: 1,
        limit: 10
      };
      this.getList();
    },
    getList() {
      this.loading = true;
      getList(this.filterQuery).then((response) => {
        if (response.code == 20000) {
          this.list = response.data.list || [];
          this.total = response.data.total || 0;
          this.detailList = []
        } else {
          this.$message.error(response.message);
        }
        this.loading = false;
      })
        .catch(() => {
          this.loading = false;
          this.list = [];
          this.total = 0;
        });

    }
  }
  ,
  computed: {
  },
  components: {
    sysApprovalFlowConfigEdit
  },
  created() {
    this.getList();
  }
}
</script>

<style scoped lang="scss" rel="stylesheet/scss">
.content {
  display: flex;
  justify-content: space-between;
  padding: 15px 0px;

  span {
    flex: 1;
  }
}
</style>
