<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="资产条码" prop="code">
        <el-input
          v-model="queryParams.code"
          placeholder="请输入资产条码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="资产名称" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入资产名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="资产编号" prop="number">
        <el-input
          v-model="queryParams.number"
          placeholder="请输入资产编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="资产分类" prop="categoryNumber">
          <el-select v-model="queryParams.categoryNumber" placeholder="请选择资产分类">
            <el-option
              v-for="item in categoryList"
              :key="item.number"
              :label="item.name"
              :value="parseInt(item.number)"
            ></el-option>
          </el-select>
        </el-form-item>
      <el-form-item label="规格型号" prop="specificationsModel">
        <el-input
          v-model="queryParams.specificationsModel"
          placeholder="请输入规格型号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="ABC分类" prop="abcCategory">
        <el-input
          v-model="queryParams.abcCategory"
          placeholder="请输入ABC分类"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="使用部门" prop="userDepartment">
        <el-input
          v-model="queryParams.userDepartment"
          placeholder="请输入使用部门"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="管理部门" prop="department">
        <el-input
          v-model="queryParams.department"
          placeholder="请输入管理部门"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="责任人" prop="responsiblePerson">
        <el-input
          v-model="queryParams.responsiblePerson"
          placeholder="请输入责任人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="所在位置" prop="locationNumber">
        <el-select v-model="queryParams.locationNumber" placeholder="请选择所在位置">
            <el-option
              v-for="item in locationList"
              :key="item.number"
              :label="item.name"
              :value="parseInt(item.number)"
            ></el-option>
          </el-select>
      </el-form-item>
      <el-form-item label="资产性质" prop="property">
        <el-input
          v-model="queryParams.property"
          placeholder="请输入资产性质"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="购置日期" prop="purchaseDate">
        <el-date-picker clearable
          v-model="queryParams.purchaseDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择购置日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="启用日期" prop="commissioningDate">
        <el-date-picker clearable
          v-model="queryParams.commissioningDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择启用日期">
        </el-date-picker>
      </el-form-item>
      <!-- <el-form-item label="原值" prop="originalValue">
        <el-input
          v-model="queryParams.originalValue"
          placeholder="请输入原值"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="使用年限" prop="durableYears">
        <el-input
          v-model="queryParams.durableYears"
          placeholder="请输入使用年限"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="净值" prop="netValue">
        <el-input
          v-model="queryParams.netValue"
          placeholder="请输入净值"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="残值" prop="residualValue">
        <el-input
          v-model="queryParams.residualValue"
          placeholder="请输入残值"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="累计折旧" prop="accumulatedDepreciation">
        <el-input
          v-model="queryParams.accumulatedDepreciation"
          placeholder="请输入累计折旧"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="最近折旧日期" prop="lastDepreciationDate">
        <el-date-picker clearable
          v-model="queryParams.lastDepreciationDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择最近折旧日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="折旧方式" prop="depreciationMethod">
        <el-input
          v-model="queryParams.depreciationMethod"
          placeholder="请输入折旧方式"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同编号" prop="contractNumber">
        <el-input
          v-model="queryParams.contractNumber"
          placeholder="请输入合同编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出厂编号" prop="factoryNumber">
        <el-input
          v-model="queryParams.factoryNumber"
          placeholder="请输入出厂编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="制造商" prop="manufacturer">
        <el-input
          v-model="queryParams.manufacturer"
          placeholder="请输入制造商"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应商" prop="supplier">
        <el-input
          v-model="queryParams.supplier"
          placeholder="请输入供应商"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="维保到期日期" prop="maintenanceDate">
        <el-date-picker clearable
          v-model="queryParams.maintenanceDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择维保到期日期">
        </el-date-picker>
      </el-form-item>
      <!-- <el-form-item label="维修电话" prop="maintenanceTel">
        <el-input
          v-model="queryParams.maintenanceTel"
          placeholder="请输入维修电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="维修人员" prop="maintenanceUser">
        <el-input
          v-model="queryParams.maintenanceUser"
          placeholder="请输入维修人员"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="所属公司" prop="corporation">
        <el-input
          v-model="queryParams.corporation"
          placeholder="请输入所属公司"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="记录状态" prop="recordStatus">
        <el-select v-model="queryParams.recordStatus" placeholder="请选择记录状态" clearable>
          <el-option
            v-for="dict in dict.type.asset_record_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="预留字段a" prop="reservedColumnA">
        <el-input
          v-model="queryParams.reservedColumnA"
          placeholder="请输入预留字段a"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段b" prop="reservedColumnB">
        <el-input
          v-model="queryParams.reservedColumnB"
          placeholder="请输入预留字段b"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段c" prop="reservedColumnC">
        <el-input
          v-model="queryParams.reservedColumnC"
          placeholder="请输入预留字段c"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段d" prop="reservedColumnD">
        <el-input
          v-model="queryParams.reservedColumnD"
          placeholder="请输入预留字段d"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段e" prop="reservedColumnE">
        <el-input
          v-model="queryParams.reservedColumnE"
          placeholder="请输入预留字段e"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段f" prop="reservedColumnF">
        <el-input
          v-model="queryParams.reservedColumnF"
          placeholder="请输入预留字段f"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段g" prop="reservedColumnG">
        <el-input
          v-model="queryParams.reservedColumnG"
          placeholder="请输入预留字段g"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段h" prop="reservedColumnH">
        <el-input
          v-model="queryParams.reservedColumnH"
          placeholder="请输入预留字段h"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段i" prop="reservedColumnI">
        <el-input
          v-model="queryParams.reservedColumnI"
          placeholder="请输入预留字段i"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段j" prop="reservedColumnJ">
        <el-input
          v-model="queryParams.reservedColumnJ"
          placeholder="请输入预留字段j"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['asset:information:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['asset:information:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['asset:information:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['asset:information:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="informationList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <!-- <el-table-column label="编号" align="center" prop="id" /> -->
      <el-table-column label="资产条码" align="center" prop="code" />
      <el-table-column label="资产名称" align="center" prop="name" />
      <el-table-column label="资产编号" align="center" prop="number" />
      <el-table-column label="照片" align="center" prop="imageUrl" width="100" >
        <template slot-scope="scope">
          <image-preview :src="scope.row.imageUrl" :width="50" :height="50" v-show="(scope.row.imageUrl===''||scope.row.imageUrl==null)?false:true"/>
        </template>
      </el-table-column>
      <el-table-column label="资产分类" align="center" prop="categoryNumber" >
        <template slot-scope="scope">
          <span>{{ scope.row.categoryNumber != null ? categoryName(scope.row.categoryNumber) : ""}}</span>
        </template>
      </el-table-column>
      <el-table-column label="规格型号" align="center" prop="specificationsModel" />
      <el-table-column label="ABC分类" align="center" prop="abcCategory" />
      <el-table-column label="管理状态" align="center" prop="manageStatus" />
      <el-table-column label="使用部门" align="center" prop="userDepartment" >
        <template slot-scope="scope">
          <span>{{ scope.row.userDepartment != null ? companyName(scope.row.userDepartment) : ""}}</span>
        </template>
      </el-table-column>
      <el-table-column label="管理部门" align="center" prop="department">
        <template slot-scope="scope">
          <span>{{ scope.row.department != null ? companyName(scope.row.department) : ""}}</span>
        </template>
      </el-table-column>
      <el-table-column label="责任人" align="center" prop="responsiblePerson" />
      <el-table-column label="所在位置" align="center" prop="locationNumber" >
        <template slot-scope="scope">
          <span>{{ scope.row.locationNumber != null ? locationName(scope.row.locationNumber) : ""}}</span>
        </template>
      </el-table-column>
      <el-table-column label="资产性质" align="center" prop="property" />
      <el-table-column label="购置日期" align="center" prop="purchaseDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.purchaseDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="启用日期" align="center" prop="commissioningDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.commissioningDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="原值" align="center" prop="originalValue" />
      <el-table-column label="使用年限" align="center" prop="durableYears" />
      <el-table-column label="净值" align="center" prop="netValue" />
      <el-table-column label="残值" align="center" prop="residualValue" />
      <el-table-column label="累计折旧" align="center" prop="accumulatedDepreciation" />
      <el-table-column label="最近折旧日期" align="center" prop="lastDepreciationDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.lastDepreciationDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="折旧方式" align="center" prop="depreciationMethod" />
      <el-table-column label="合同编号" align="center" prop="contractNumber" />
      <el-table-column label="出厂编号" align="center" prop="factoryNumber" />
      <el-table-column label="制造商" align="center" prop="manufacturer" />
      <el-table-column label="供应商" align="center" prop="supplier" />
      <el-table-column label="资产用途" align="center" prop="purpose" />
      <el-table-column label="维保到期日期" align="center" prop="maintenanceDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.maintenanceDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="维修电话" align="center" prop="maintenanceTel" />
      <el-table-column label="维修人员" align="center" prop="maintenanceUser" />
      <el-table-column label="所属公司" align="center" prop="corporation" >
        <template slot-scope="scope">
          <span>{{ scope.row.corporation != null ? companyName(scope.row.corporation) : ""}}</span>
        </template>
      </el-table-column>
      <el-table-column label="记录状态" align="center" prop="recordStatus">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.asset_record_status" :value="scope.row.recordStatus"/>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="预留字段a" align="center" prop="reservedColumnA" />
      <el-table-column label="预留字段b" align="center" prop="reservedColumnB" />
      <el-table-column label="预留字段c" align="center" prop="reservedColumnC" />
      <el-table-column label="预留字段d" align="center" prop="reservedColumnD" />
      <el-table-column label="预留字段e" align="center" prop="reservedColumnE" />
      <el-table-column label="预留字段f" align="center" prop="reservedColumnF" />
      <el-table-column label="预留字段g" align="center" prop="reservedColumnG" />
      <el-table-column label="预留字段h" align="center" prop="reservedColumnH" />
      <el-table-column label="预留字段i" align="center" prop="reservedColumnI" />
      <el-table-column label="预留字段j" align="center" prop="reservedColumnJ" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['asset:information:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['asset:information: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="getList"
    />

    <!-- 添加或修改资产信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="资产条码" prop="code">
          <el-input v-model="form.code" placeholder="请输入资产条码" />
        </el-form-item>
        <el-form-item label="资产名称" prop="name">
          <el-input v-model="form.name" placeholder="请输入资产名称" />
        </el-form-item>
        <el-form-item label="资产编号" prop="number">
          <el-input v-model="form.number" placeholder="请输入资产编号" />
        </el-form-item>
        <el-form-item label="照片">
          <image-upload-temp v-model="form.imageUrl" :limit="1" />
        </el-form-item>
        <el-form-item label="资产分类" prop="categoryNumber">
          <el-select v-model="form.categoryNumber" placeholder="请选择资产分类">
            <el-option
              v-for="item in categoryList"
              :key="item.number"
              :label="item.name"
              :value="item.number"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="规格型号" prop="specificationsModel">
          <el-input v-model="form.specificationsModel" placeholder="请输入规格型号" />
        </el-form-item>
        <el-form-item label="ABC分类" prop="abcCategory">
          <el-input v-model="form.abcCategory" placeholder="请输入ABC分类" />
        </el-form-item>
        <el-form-item label="使用部门" prop="userDepartment">
              <treeselect
                v-model="form.userDepartment"
                :options="deptOptions"
                :normalizer="normalizer"
                placeholder="选择使用部门"
              />
        </el-form-item>
        <el-form-item label="管理部门" prop="department">
              <treeselect
                v-model="form.department"
                :options="deptOptions"
                :normalizer="normalizer"
                placeholder="选择管理部门"
              />
        </el-form-item>
        <el-form-item label="责任人" prop="responsiblePerson">
          <el-input v-model="form.responsiblePerson" placeholder="请输入责任人" />
        </el-form-item>
        <el-form-item label="所在位置" prop="locationNumber">
          <el-select v-model="form.locationNumber" placeholder="请选择所在位置">
            <el-option
              v-for="item in locationList"
              :key="item.number"
              :label="item.name"
              :value="item.number"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="资产性质" prop="property">
          <el-input v-model="form.property" placeholder="请输入资产性质" />
        </el-form-item>
        <el-form-item label="购置日期" prop="purchaseDate">
          <el-date-picker clearable
            v-model="form.purchaseDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择购置日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="启用日期" prop="commissioningDate">
          <el-date-picker clearable
            v-model="form.commissioningDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择启用日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="原值" prop="originalValue">
          <el-input v-model="form.originalValue" placeholder="请输入原值" />
        </el-form-item>
        <el-form-item label="使用年限" prop="durableYears">
          <el-input v-model="form.durableYears" placeholder="请输入使用年限" />
        </el-form-item>
        <el-form-item label="净值" prop="netValue">
          <el-input v-model="form.netValue" placeholder="请输入净值" />
        </el-form-item>
        <el-form-item label="残值" prop="residualValue">
          <el-input v-model="form.residualValue" placeholder="请输入残值" />
        </el-form-item>
        <el-form-item label="累计折旧" prop="accumulatedDepreciation">
          <el-input v-model="form.accumulatedDepreciation" placeholder="请输入累计折旧" />
        </el-form-item>
        <el-form-item label="最近折旧日期" prop="lastDepreciationDate">
          <el-date-picker clearable
            v-model="form.lastDepreciationDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择最近折旧日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="折旧方式" prop="depreciationMethod">
          <el-input v-model="form.depreciationMethod" placeholder="请输入折旧方式" />
        </el-form-item>
        <el-form-item label="合同编号" prop="contractNumber">
          <el-input v-model="form.contractNumber" placeholder="请输入合同编号" />
        </el-form-item>
        <el-form-item label="出厂编号" prop="factoryNumber">
          <el-input v-model="form.factoryNumber" placeholder="请输入出厂编号" />
        </el-form-item>
        <el-form-item label="制造商" prop="manufacturer">
          <el-input v-model="form.manufacturer" placeholder="请输入制造商" />
        </el-form-item>
        <el-form-item label="供应商" prop="supplier">
          <el-input v-model="form.supplier" placeholder="请输入供应商" />
        </el-form-item>
        <el-form-item label="资产用途" prop="purpose">
          <el-input v-model="form.purpose" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="维保到期日期" prop="maintenanceDate">
          <el-date-picker clearable
            v-model="form.maintenanceDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择维保到期日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="维修电话" prop="maintenanceTel">
          <el-input v-model="form.maintenanceTel" placeholder="请输入维修电话" />
        </el-form-item>
        <el-form-item label="维修人员" prop="maintenanceUser">
          <el-input v-model="form.maintenanceUser" placeholder="请输入维修人员" />
        </el-form-item>
        <el-form-item label="所属公司" prop="corporation">
              <treeselect
                v-model="form.corporation"
                :options="deptOptions"
                :normalizer="normalizer"
                placeholder="选择所属公司"
              />
        </el-form-item>
        <el-form-item label="记录状态" prop="recordStatus">
          <el-select v-model="form.recordStatus" placeholder="请选择记录状态">
            <el-option
              v-for="dict in dict.type.asset_record_status"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
        <el-form-item label="预留字段a" prop="reservedColumnA">
          <el-input v-model="form.reservedColumnA" placeholder="请输入预留字段a" />
        </el-form-item>
        <el-form-item label="预留字段b" prop="reservedColumnB">
          <el-input v-model="form.reservedColumnB" placeholder="请输入预留字段b" />
        </el-form-item>
        <el-form-item label="预留字段c" prop="reservedColumnC">
          <el-input v-model="form.reservedColumnC" placeholder="请输入预留字段c" />
        </el-form-item>
        <el-form-item label="预留字段d" prop="reservedColumnD">
          <el-input v-model="form.reservedColumnD" placeholder="请输入预留字段d" />
        </el-form-item>
        <el-form-item label="预留字段e" prop="reservedColumnE">
          <el-input v-model="form.reservedColumnE" placeholder="请输入预留字段e" />
        </el-form-item>
        <el-form-item label="预留字段f" prop="reservedColumnF">
          <el-input v-model="form.reservedColumnF" placeholder="请输入预留字段f" />
        </el-form-item>
        <el-form-item label="预留字段g" prop="reservedColumnG">
          <el-input v-model="form.reservedColumnG" placeholder="请输入预留字段g" />
        </el-form-item>
        <el-form-item label="预留字段h" prop="reservedColumnH">
          <el-input v-model="form.reservedColumnH" placeholder="请输入预留字段h" />
        </el-form-item>
        <el-form-item label="预留字段i" prop="reservedColumnI">
          <el-input v-model="form.reservedColumnI" placeholder="请输入预留字段i" />
        </el-form-item>
        <el-form-item label="预留字段j" prop="reservedColumnJ">
          <el-input v-model="form.reservedColumnJ" placeholder="请输入预留字段j" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listInformation, getInformation, delInformation, addInformation, updateInformation } from "@/api/asset/information";
import { listCategory } from "@/api/asset/category";
import { listLocation } from "@/api/asset/location";
import ImageUploadTemp from "@/components/ImageUploadTemp"
import { listDept } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";

export default {
  name: "Information",
  dicts: ['asset_record_status'],
  components:{
    ImageUploadTemp,Treeselect
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      arr: [],
      // 所属位置表格数据
      locationList: [],
      // 资产分类表格数据
      categoryList: [],
      // 资产信息表格数据
      informationList: [],
      // 部门树选项
      deptOptions: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        code: null,
        name: null,
        number: null,
        imageUrl: null,
        categoryNumber: null,
        specificationsModel: null,
        abcCategory: null,
        manageStatus: null,
        userDepartment: null,
        department: null,
        responsiblePerson: null,
        locationNumber: null,
        property: null,
        purchaseDate: null,
        commissioningDate: null,
        originalValue: null,
        durableYears: null,
        netValue: null,
        residualValue: null,
        accumulatedDepreciation: null,
        lastDepreciationDate: null,
        depreciationMethod: null,
        contractNumber: null,
        factoryNumber: null,
        manufacturer: null,
        supplier: null,
        purpose: null,
        maintenanceDate: null,
        maintenanceTel: null,
        maintenanceUser: null,
        corporation: null,
        recordStatus: null,
        reservedColumnA: null,
        reservedColumnB: null,
        reservedColumnC: null,
        reservedColumnD: null,
        reservedColumnE: null,
        reservedColumnF: null,
        reservedColumnG: null,
        reservedColumnH: null,
        reservedColumnI: null,
        reservedColumnJ: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        number: [
          { required: true, message: "资产编号不能为空", trigger: "blur" }
        ],
        specificationsModel: [
          { required: true, message: "规格型号不能为空", trigger: "blur" }
        ],
        manageStatus: [
          { required: true, message: "管理状态不能为空", trigger: "change" }
        ],
        recordStatus: [
          { required: true, message: "记录状态不能为空", trigger: "change" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询资产信息列表 */
    getList() {
      this.loading = true;
      listDept().then((response) => {
        this.deptOptions = this.handleTree(response.data, "deptId");
        this.arr = response.data
      });
      listCategory().then(response => {
        this.categoryList = response.rows;
      });
      listLocation().then((response) => {
        this.locationList = response.rows;
      });
      listInformation(this.queryParams).then(response => {
        this.informationList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 转换部门数据结构 */
    normalizer(node) {
      if (node.children && !node.children.length) {
        delete node.children;
      }
      return {
        id: node.deptId,
        label: node.deptName,
        children: node.children,
      };
    },
    //获取公司名
    companyName(val){
       let num = parseInt(val)
       let arr2 = this.arr.filter(item => item.deptId===num);
       return arr2[0].deptName
    },
    //获取资产分类名
    categoryName(val){
       //let num = parseInt(val)
       let arr2 = this.categoryList.filter(item => item.number===val);
       return arr2[0].name
    },
    //获取所在位置名
    locationName(val){
      //let num = parseInt(val)
      let arr2 = this.locationList.filter(item => item.number===val);
       return arr2[0].name
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        code: null,
        name: null,
        number: null,
        imageUrl: null,
        categoryNumber: null,
        specificationsModel: null,
        abcCategory: null,
        manageStatus: null,
        userDepartment: null,
        department: null,
        responsiblePerson: null,
        locationNumber: null,
        property: null,
        purchaseDate: null,
        commissioningDate: null,
        originalValue: null,
        durableYears: null,
        netValue: null,
        residualValue: null,
        accumulatedDepreciation: null,
        lastDepreciationDate: null,
        depreciationMethod: null,
        contractNumber: null,
        factoryNumber: null,
        manufacturer: null,
        supplier: null,
        purpose: null,
        maintenanceDate: null,
        maintenanceTel: null,
        maintenanceUser: null,
        corporation: null,
        recordStatus: null,
        remark: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        reservedColumnA: null,
        reservedColumnB: null,
        reservedColumnC: null,
        reservedColumnD: null,
        reservedColumnE: null,
        reservedColumnF: null,
        reservedColumnG: null,
        reservedColumnH: null,
        reservedColumnI: null,
        reservedColumnJ: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd(row) {
      this.reset();
      if (row != undefined) {
        this.form.parentId = row.deptId;
      }
      this.open = true;
      this.title = "添加资产信息";
      listDept().then(response => {
        this.deptOptions = this.handleTree(response.data, "deptId");
      });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getInformation(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改资产信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateInformation(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addInformation(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除资产信息编号为"' + ids + '"的数据项？').then(function() {
        return delInformation(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('asset/information/export', {
        ...this.queryParams
      }, `information_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
