<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="80px">
      <el-form-item label="设备名称">
        <el-input v-model="queryParams.equipmentName" clearable placeholder="请输入设备名称"></el-input>
      </el-form-item>
      <el-form-item label="归属类型">
        <el-select v-model="queryParams.affiliationType" placeholder="请选择归属类型" clearable>
          <el-option v-for="(item, index) in dict.type.affiliation_type" :key="index" :label="item.label"
            :value="item.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="分类编码">
        <el-input v-model="queryParams.classificationCode" clearable placeholder="请输入分类编码"></el-input>
      </el-form-item>
      <el-form-item label="设备状态">
        <el-select v-model="queryParams.equipmentState" clearable placeholder="请选择设备状态">
          <el-option v-for="(item, index) in dict.type.equipment_state" :key="index" :label="item.label"
            :value="item.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="getList">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <!--  -->
    <el-table v-loading="loading" :data="outBoundData" stripe>
      <el-table-column type="selection" width="55"></el-table-column>
      <el-table-column label="序号" type="index" width="55" align="center" fixed="left" />
      <el-table-column label="出库类型" align="center" prop="outStockType" fixed="left" width="200" />
      <el-table-column label="设备名称" align="center" prop="equipmentName" fixed="left" />
      <el-table-column label="型号" align="center" prop="model" fixed="left" />
      <el-table-column label="规格" align="center" prop="specification" fixed="left" />
      <el-table-column label="分类编码" align="center" prop="classificationCode" />
      <el-table-column label="单位" align="center" prop="unit" />
      <el-table-column align="center" prop="affiliationType" label="归属类型">
        <template slot-scope="{ row }">
          <div>{{ selectDictLabel(dict.type.affiliation_type, row.affiliationType) }}</div>
        </template>
      </el-table-column>
      <el-table-column align="center" prop="equipmentState" label="设备状态">
        <template slot-scope="{ row }">
          <div>{{ selectDictLabel(dict.type.equipment_state, row.equipmentState) }}</div>
        </template>
      </el-table-column>
      <el-table-column label="投产日期" align="center" prop="dateOfProduction" width="200" />
      <el-table-column label="价格（元）" align="center" prop="price" width="180" />
      <el-table-column label="效用年限（年）" align="center" prop="lifeOfUtility" width="120px" />
      <el-table-column label="地点" align="center" prop="place" />
      <el-table-column label="使用人" align="center" prop="useName" />
      <el-table-column label="备注" align="center" prop="remark" width="200" />
      <el-table-column label="操作" align="center" prop="orgname" width="200" fixed="right">
        <template slot-scope="{ row }">
          <el-button type="text" size="small" @click="handleLook(row)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination ref="pageBlock" v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize" @pagination="getList" />

    <el-dialog title="详细信息" :visible.sync="dialogVisible" width="50%">
      <el-form :model="outBoundForm" :rules="outBoundRules" ref="achievementForm" label-width="110px"
        label-position="right">
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="出库类型" prop="outStockType">
              <el-input v-model="outBoundForm.outStockType" placeholder=" 请输入出库类型" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="归属类型" prop="affiliationType">
              <el-input v-model="outBoundForm.affiliationType" placeholder="请输入归属类型" disabled></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="设备名称" prop="equipmentName">
              <el-input v-model="outBoundForm.equipmentName" placeholder="请输入设备名称" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备状态" prop="equipmentState">
              <el-input v-model="outBoundForm.equipmentState" placeholder="请输入设备状态" disabled></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="型号" prop="model">
              <el-input v-model="outBoundForm.model" placeholder="请输入型号" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="投产日期" prop="dateOfProduction">
              <el-input v-model="outBoundForm.dateOfProduction" placeholder="请输入投产日期" disabled></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="规格" prop="specification">
              <el-input v-model="outBoundForm.specification" placeholder="请输入规格" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="价格（元）" prop="price">
              <el-input v-model="outBoundForm.price" placeholder="请输入价格" disabled></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="分类编码" prop="classificationCode">
              <el-input v-model="outBoundForm.classificationCode" placeholder="请输入分类编码" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="效用年限（年）" prop="lifeOfUtility">
              <el-input v-model="outBoundForm.lifeOfUtility" placeholder="请输入效用年限" disabled></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="单位" prop="affiliationType">
              <el-input v-model="outBoundForm.affiliationType" placeholder="请输入单位" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="使用人" prop="useName">
              <el-input v-model="outBoundForm.useName" placeholder="请输入使用人" disabled></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="地点" prop="place">
              <el-input v-model="outBoundForm.place" placeholder="请输入地点" disabled></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="24">
            <el-form-item label="备注" prop="remark">
              <el-input type="textarea" v-model="outBoundForm.remark" placeholder="请输入备注" disabled></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>


import {
  getoutStock,
  queryoutStock,
} from '@/api/smartSchool/schoolProperty/outboundLedger.js'
export default {
  dicts: ['equipment_state', 'affiliation_type'],
  data() {
    return {
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        equipmentName: '',
        affiliationType: '',
        classificationCode: '',
        equipmentState: '',
      },
      loading: false,
      total: 0,
      outBoundData: [

      ],
      outBoundForm: {},
      outBoundRules: {

      },
      dialogVisible: false,
    }
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      getoutStock(this.queryParams).then((response) => {
        this.outBoundData = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.dialogVisible = false;

    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        equipmentName: '',
        affiliationType: '',
        classificationCode: '',
        equipmentState: '',

      };
      this.getList();
    },
    /** 查看详情 */
    handleLook(row) {
      const id = row.id || this.ids;
      this.$modal.loading('正在加载数据，请稍等...');
      queryoutStock(id).then(response => {
        this.$modal.closeLoading();
        this.outBoundForm = response.data;
        this.dialogVisible = true;
        this.isEdit = false;
        this.title = "查看入库台帐";

      }).catch(error => {

      })
    },















  },
}
</script>

<style lang="scss" scoped></style>
