<template>
  <div id="workSpace">
    <el-card style="position: relative;">
      <el-form label-width="100px">
        <el-row :gutter="10">
          <el-col :span="1.5">
              <el-form-item label="单据标题">
                <el-input
                  v-model.trim="queryParams.docSubject"
                  size="mini"
                  clearable
                  style="width: 200px"
                />
              </el-form-item>
            </el-col>

          <el-col :span="1.5">
              <el-form-item label="单据类型">
                <el-select multiple v-model="queryParams.modelIds" size="mini" style="width: 200px" clearable>
                  <el-option v-for="dict in dict.type.oa_templete_id" :key="dict.value" :label="dict.label" :value="dict.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
        </el-row>
      </el-form>

      <div style="position: absolute;top: 18px;right: 10px;">
        <el-button type="primary" size="mini" @click="searchList">搜索</el-button>
        <el-button size="mini" plain @click="resetList">重置</el-button>
      </div>

      <div class="btn_grooup">
        <el-button type="primary" size="mini" @click="xxxx">批量同意</el-button>
      </div>

      <el-table
        v-loading="loading"
        :data="tableList" 
        fit
        :cell-style="{ borderColor: '#c0c0c0' }"
        :header-cell-style="{ borderColor: '#c0c0c0' }"
        class="exporttable"
        max-height="410"
        border
        highlight-current-row
        style="font-size: 12px;"
        @selection-change="handleSelectionChange"
        @row-click="rowSelect"
        @row-dblclick="doubleClick"
        ref="tables"
      >
        <el-table-column type="selection" width="55" />
        <el-table-column label="序号" type="index" align="center" width="50px"/>
        <el-table-column show-overflow-tooltip label="标题" align="center" prop="docSubject"/>
        <el-table-column show-overflow-tooltip label="创建人" align="center" prop="docCreate"/>
        <el-table-column
          fixed="right"
          label="操作"
          align="center"
          width="180"
          >
          <template slot-scope="scope">
            <el-button type="text" size="mini" @click="check(scope.row)">查看</el-button>
            <el-button type="text" size="mini" @click="agree(scope.row)">同意</el-button>
          </template>
        </el-table-column>
      </el-table>

    </el-card>
  </div>
</template>

<script>
import { getWorkSpaceList } from '@/api/purchase/workSpace.js'
export default {
  name: 'workSpace',
  dicts: ['oa_templete_id'],
  data() {
    return {
      queryParams: {
        modelIds:[],
        docSubject: '',
        pageNum: 1,
        pageSize: 10
      },
      loading: false,
      tableList: [],
      total: 0
    }
  },
  created() {
    this.getList(this.queryParams)
  },
  methods: {
    getList(params){
      getWorkSpaceList(params).then(res => {
        if (res.code === 200) {
          this.tableList = res.rows
          this.total = res.total
        }
      }).then(() => {
        this.loading = false
      }).catch(err => {
        this.loading = false
      })
    },
    searchList() {
      this.getList(this.queryParams)
    },
    resetList() {},
    handleSelectionChange() {},
    rowSelect() {},
    doubleClick() {},
    xxxx() {},
    check() {},
    agree(row) {
      console.log(row)
      this.$router.push({path: row.linkUrl ,query: {billCode: row.billCode}})
    }
  }
}
</script>

<style lang="scss" scoped>
#workSpace {
  padding: 12px;
  box-sizing: border-box;
  overflow-y: scroll;
}
.btn_grooup {
  margin-bottom: 10px;
  display: flex;
  justify-content: flex-end;
}
</style>
<style>
.exporttable {
  border: solid 1px #c0c0c0;
}
.el-table .el-table__header-wrapper th {
  font-size: 14px;
}
</style>