<template>
  <div class="app-content">
    <div class="search">
      <el-select v-model="table.getdataListParm.parammaps.enable" placeholder="操作模块" class="filter-item" style="width: 120px;" clearable>
        <el-option v-for="item in operationModuleList" :key="item.id" :label="item.name" :value="item.id" />
      </el-select>
      <el-input v-model="table.getdataListParm.parammaps.rolename" placeholder="操作内容" style="width: 180px;" class="filter-item" clearable />
      <el-select v-model="table.getdataListParm.parammaps.enable" placeholder="操作方式" class="filter-item" style="width: 120px;" clearable>
        <el-option v-for="item in operationModeList" :key="item.id" :label="item.name" :value="item.id" />
      </el-select>
      <el-select v-model="table.getdataListParm.parammaps.enable" placeholder="操作人" class="filter-item" style="width: 120px;" clearable>
        <el-option v-for="item in operatorList" :key="item.id" :label="item.name" :value="item.id" />
      </el-select>
      <el-date-picker ref="inputDatetime" v-model="table.getdataListParm.parammaps.inputDatetime" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 250px;" />
      <el-button class="successBorder" @click="form_search">查询</el-button>
      <el-button class="successBorder" @click="handleRefresh">重置</el-button>
    </div>
    <div class="table">
      <el-table
        :key="table.tableKey"
        v-loading="table.listLoading"
        element-loading-text="给我一点时间"
        :data="table.list"
        border
        fit
        highlight-current-row
        style="width: 100%;"
        :row-style="rowStyle"
        :cell-style="cellStyle"
        class="elTable table-fixed"
      >
        <el-table-column label="序号" align="center" type="index" width="50px">
          <template slot-scope="scope">
            <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作模块" min-width="130px" align="center" prop="rolename" />
        <el-table-column label="操作方式" min-width="130px" align="center" prop="rolename" />
        <el-table-column label="操作内容" min-width="130px" align="center" prop="rolename" />
        <el-table-column label="操作人" min-width="130px" align="center" prop="rolename" />
        <el-table-column label="操作时间" min-width="130px" align="center" prop="rolename" />
        <el-table-column label="操作" align="center" width="50px" class-name="small-padding fixed-width" fixed="right">
          <template slot-scope="{row}">
            <el-button class="miniSuccess" icon="el-icon-search" @click="form_see(row)" />
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
    </div>

    <el-dialog :title="textMap[see.dialogStatus]" :visible.sync="see.dialogFormVisible" :close-on-click-modal="false" width="90%">
      <div class="app-add">
        <div class="seeContent">
          <div class="left">
            <div v-for="(i,item) in 4">
              <b>操作模块：</b>
              <span>配方计划/配方模板</span>
            </div>
          </div>
          <div class="right">
            <div class="right-t">上</div>
            <div class="right-b">
              <div class="right-b-l">
                <div class="title">
                  修改前
                </div>
                <div class="right-content" v-for="(i,item) in 24">
                  <b>操作模块：</b>
                  <span>配方计划/配方模板</span>
                </div>
              </div>
              <div class="right-b-r">
                <div class="title">
                  修改前
                </div>
                <div class="right-content" v-for="(i,item) in 24">
                  <b>操作模块：</b>
                  <span>配方计划/配方模板</span>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button class="cancelClose cancelClose1" @click="see.dialogFormVisible = false; ">关闭</el-button>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { postJson } from '@/api/common'
import Cookies from 'js-cookie'
import { parseTime } from '@/utils/index.js'
import Pagination from '@/components/Pagination'
export default {
  name: 'Operation',
  components: { Pagination },
  data() {
    return {
      operationModuleList: [], // 操作模块
      operationModeList:[],//操作方式
      operatorList:[],//操作人
      table: {
        getdataListParm: {
          name: 'getRoleList',
          page: 1,
          offset: 1,
          pagecount: parseInt(Cookies.get('pageCount')),
          returntype: 'Map',
          parammaps: {
            pastureid: Cookies.get('pastureid'),
            rolename: '',
            createmp: '',
            enable: '',
            startTime: '',
            stopTime: '',
            inputDatetime: ''
          }
        },
        tableKey: 0,
        list: [],
        total: 0,
        listLoading: true,
        temp: {}
      },
      see: {
        dialogFormVisible: false,
        dialogStatus: '',
        temp: {}
      },
      textMap: {
        see: '操作详情'
      },
      rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
      cellStyle: { padding: 0 + 'px' }
    }
  },
  created() {
    this.getList()
  },

  methods: {
    getList() {
      this.table.listLoading = true
      let url = 'authdata/GetDataByName'
      let data = this.table.getdataListParm
      postJson(url,data).then(response => {
        console.log('table数据', response.data.list)
        if (response.data.list !== null) {
          this.table.list = response.data.list
          this.table.pageNum = response.data.pageNum
          this.table.pageSize = response.data.pageSize
          this.table.total = response.data.total
        } else {
          this.table.list = []
        }
        setTimeout(() => {
          this.table.listLoading = false
        }, 100)
      })
    },
    form_search() {
      if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
        this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
        this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
      } else {
        this.table.getdataListParm.parammaps.inputDatetime = ''
        this.table.getdataListParm.parammaps.startTime = ''
        this.table.getdataListParm.parammaps.stopTime = ''
      }
      this.table.getdataListParm.offset = 1
      this.getList()
    },
    handleRefresh() {
      console.log('点击了重置')
    },
    form_see(row) {
      this.see.dialogStatus = 'see'
      this.see.dialogFormVisible = true
      this.see.temp = Object.assign({}, row)
    }
  }
}
</script>
<style lang="scss" scoped>
  .search{margin-top:10px;}
  
  .seeContent{
    flex: 1;
    height: 100%;
    display: flex;
    height: 400px;
    border-bottom: 1px solid #000;
    .left{
      width: 300px;
      height: 100%;
      border-right: 1px solid #000;
      padding-top: 10px;
      text-align: center;
      div{font-size: 14px;line-height: 18px;}
    }
    .right{
      flex: 1;
      height: 100%;
      .right-t{height: 50px;border-bottom: 1px solid #000;text-align: center;line-height: 50px;}
      .right-b{
        flex: 1;display: flex;height: 350px;border-right: 1px solid #000;overflow-y: auto;
        div{
          flex: 1 1;text-align: center;
          .title{padding-top: 10px;}
          .right-content{font-size: 12px;line-height: 18px;}
        }
        .right-b-l{
          border-right: 1px solid #000;height: 100%;
        }
      }
    }
  }
  .app-add{padding-bottom: 30px;}
  /deep/ .el-dialog__body{
    padding: 0 0;
  }
</style>
