<template>
  <div class="mod-__icMaterialCode} resi-container">
    <el-card ref="searchCard" class="search-card">
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item>
          <el-input size="small" v-model="dataForm.id" placeholder="id" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" size="small" @click="getDataList()">{{ $t('query') }}</el-button>
        </el-form-item>
      </el-form>
    </el-card>
    <el-card class="resi-card-table">
      <div class="resi-row-btn">
        <el-button class="diy-button--add" type="primary" size="small" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>
        <el-button class="diy-button--add" type="danger" size="small" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>
      </div>
      <el-table v-loading="dataListLoading" class="resi-table" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%" :height="tableHeight">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
                  <el-table-column prop="id" label="ID" header-align="center" align="center"></el-table-column>
                  <el-table-column prop="customerId" label="客户Id" header-align="center" align="center"></el-table-column>
                  <el-table-column prop="agencyId" label="组织ID" header-align="center" align="center"></el-table-column>
                  <el-table-column prop="name" label="名称" header-align="center" align="center"></el-table-column>
                  <el-table-column prop="introduce" label="介绍" header-align="center" align="center"></el-table-column>
                  <el-table-column prop="picture" label="照片" header-align="center" align="center"></el-table-column>
                  <el-table-column prop="remark" label="备注" header-align="center" align="center"></el-table-column>
                  <el-table-column prop="code" label="二维码" header-align="center" align="center"></el-table-column>
                  <el-table-column prop="delFlag" label="删除标记;0：未删除，1：已删除" header-align="center" align="center"></el-table-column>
                  <el-table-column prop="revision" label="乐观锁" header-align="center" align="center"></el-table-column>
                  <el-table-column prop="createdBy" label="创建人" header-align="center" align="center"></el-table-column>
                  <el-table-column prop="createdTime" label="创建时间" header-align="center" align="center"></el-table-column>
                  <el-table-column prop="updatedBy" label="更新人" header-align="center" align="center"></el-table-column>
                  <el-table-column prop="updatedTime" label="更新时间" header-align="center" align="center"></el-table-column>
                <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button>
            <el-button type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
              :current-page="page"
              :page-sizes="[10, 20, 50, 100]"
              :page-size="limit"
              :total="total"
              layout="total, sizes, prev, pager, next, jumper"
              @size-change="pageSizeChangeHandle"
              @current-change="pageCurrentChangeHandle">
      </el-pagination>
    </el-card>
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
  </div>
</template>

<script>
  import mixinViewModule from '@/mixins/view-module'
  import AddOrUpdate from './icmaterialcode-add-or-update.vue'
  import {mapGetters} from 'vuex'

  export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '//icMaterialCode/page',
        getDataListIsPage: true,
        deleteURL: '//icMaterialCode',
        deleteIsBatch: true
      },
      dataForm: {
        id: ''
      }
    }
  },
  components: {
    AddOrUpdate
  },
  computed: {
    ...mapGetters(["clientHeight", "iframeHeight"]),
    tableHeight() {
      const h = this.clientHeight - 360 + this.iframeHeight;
      const _h = this.clientHeight - 360;
      return this.$store.state.inIframe ? h : _h;
    },
  }
}
</script>
<style lang="scss" scoped>
  @import "@/assets/scss/modules/management/list-main.scss";

  .resi-container .resi-card-table {
    ::v-deep .el-table th {
      color: #fff;
      background-color: rgba(33, 149, 254, 1);
    }
  }

  .resi-table {
    ::v-deep .el-button--text {
      text-decoration: underline;
    }
  }

  .search-card {
    .el-card__body {
      padding: 20px 20px 0 20px;
    }
  }

  .resi-row-btn {
    margin-bottom: 13px;
    .upload-btn {
      display: inline-block;
      margin: 0 10px;
    }
  }

</style>
