<template>
  <div class="" style="padding:15px 10px 0 10px">
    <el-form :model="queryParams" ref="queryForm" :inline="true" style="padding:0 0 0 0" size="small">
      <el-form-item label="资产名称" prop="assetsName">
        <el-input v-model="queryParams.assetsName" placeholder="请输入资产名称"></el-input>
      </el-form-item>
      <el-form-item label="资产属性" prop="assetsAttribute">
        <el-select v-model="queryParams.assetsAttribute" placeholder="请选择资产属性" :disabled="$attrs.readOnly">
          <el-option v-for="dicts in dict.type.asset_attributes" :key="dicts.value" :value="dicts.value"
                     :label="dicts.label"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="领用时间" prop="time">
        <el-date-picker style="width: 100%" v-model="queryParams.time" type="datetimerange" range-separator="至"
                        start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd HH:mm"
                        format="yyyy-MM-dd HH:mm">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button icon="el-icon-search" size="mini" type="primary" @click="search">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        <!--                <el-button icon="el-icon-s-promotion" size="mini" @click="submit">提交</el-button>-->
      </el-form-item>
    </el-form>
    <el-table :data="tableData">
      <el-table-column prop="lesson" label="序号" width="60" align="center" style="height: 20px;" type="index">
      </el-table-column>
      <el-table-column prop="assetsName" label="资产名称" align="center">

      </el-table-column>
      <el-table-column label="领用数量" align="center" prop="assetsNumbers">

      </el-table-column>
      <el-table-column label="单位" align="center" prop="assetsUnit">

      </el-table-column>
      <el-table-column label="规格型号" align="center" prop="assetsSpecs">

      </el-table-column>
      <el-table-column label="资产类型" align="center" prop="assetsAttribute">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.asset_attributes" :value="scope.row.assetsAttribute"/>
        </template>
      </el-table-column>
      <el-table-column prop="claimType" label="领用类型" align="center">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.collecting_type" :value="scope.row.claimType"/>
        </template>
      </el-table-column>
      <el-table-column label="资产归属" align="center" prop="claimBelongName"/>
      <el-table-column label="领取人" align="center" prop="collectByName"/>
      <el-table-column label="领取时间" align="center" prop="collectDate"/>
      <el-table-column label="操作" align="center" width="80">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-view" @click="view(scope.row)"
                     v-hasPermi="['system:device:remove']">查看
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize" @pagination="search"/>

    <el-dialog :visible.sync="open" title="领用记录详情" :modal="false" style="width:100%;height:100%">
      <div>
        <el-form :model="rowData" label-width="80px" :inline="true">
          <el-form-item label="资产名称">
            <el-input v-model="rowData.assetsName" readonly></el-input>
          </el-form-item>
          <el-form-item label="领用数量">
            <el-input v-model="rowData.assetsNumbers" readonly></el-input>
          </el-form-item>
          <el-form-item label="单位">
            <el-input v-model="rowData.assetsUnit" readonly></el-input>
          </el-form-item>
          <el-form-item label="规格型号">
            <el-input v-model="rowData.assetsSpecs" readonly></el-input>
          </el-form-item>
          <el-form-item label="资产类型">
            <el-select :value="rowData.assetsAttribute" style="width:206px">
              <el-option v-for="dicts in dict.type.asset_attributes" :key="dicts.value"
                         :value="dicts.value" :label="dicts.label"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="领用类型">
            <el-select :value="rowData.claimType" style="width:206px">
              <el-option v-for="dicts in dict.type.collecting_type" :key="dicts.value"
                         :value="dicts.value" :label="dicts.label"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="资产归属">
            <el-input v-model="rowData.claimBelongName" readonly></el-input>
          </el-form-item>
          <el-form-item label="领取人">
            <el-input v-model="rowData.collectBy" readonly></el-input>
          </el-form-item>
          <el-form-item label="领取时间">
            <el-input v-model="rowData.collectDate" readonly></el-input>
          </el-form-item>
        </el-form>
      </div>
      <div style="text-align:right;padding: 0 50px 0 0;">
        <el-button @click="close" type="primary" plain>关闭</el-button>
      </div>

    </el-dialog>
  </div>
</template>

<script>
import {
  queryMyClaim
} from "@/api/smartSchool/officialWork/collectionRecord.js";

export default {
  dicts: ["asset_attributes", "collecting_type"],
  name: '',
  data() {
    return {
      queryParams: {
        assetsName: "",
        assetsAttribute: null,
        startDate: "",
        endtDate: "",
        time: [],
        pageNum: 1,
        pageSize: 10,
      },
      tableData: [],
      // 行数据
      rowData: {},
      open: false,
      total: 0,
    }
  },
  components: {},
  methods: {
    /** 查询 */
    search() {
      this.loading = true;
      this.queryParams.startDate = this.queryParams.time[0]
      this.queryParams.endDate = this.queryParams.time[1]
      console.log(this.queryParams);

      // this.total=this.tableData.length
      queryMyClaim(this.queryParams).then((response) => {
        this.tableData = response.data
        this.total = this.tableData.length
        this.loading = false;
        // console.log(response);

      });
    },
    // 重置
    resetQuery() {
      this.resetForm("queryForm");
      this.search();
    },
    /** 提交 */
    submit() {
      this.loading = true;
      // getMyTable().then((response) => {
      //     this.tableData = response.rows
      //     console.log(response.rows);

      // });
    },
    /** 查看 */
    view(row) {
      this.rowData = row;
      this.open = true
      // getMyTable().then((response) => {
      //     this.tableData = response.rows
      //     console.log(response.rows);

      // });
    },
    close() {
      this.open = false
    }
  },
  created() {
    this.search()


  },
}
</script>

<style scoped>
.opacity {
  background-color: #fff;
  filter: Alpha(Opacity=60);
  opacity: 0.8;
  pointer-events: none;
}
</style>

