<template>
  <div class="app-container">
    <el-form ref="queryForm" :model="queryParams" size="small" label-width="80px" inline>
      <el-form-item label="标题" prop="purchaseName">
        <el-input v-model="queryParams.purchaseName" placeholder="请输入标题" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="预算项目" prop="budgetName">
        <el-input v-model="queryParams.budgetName" placeholder="请输入预算项目" 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-form-item>
      <el-form-item>
        <el-button icon="el-icon-refresh" size="mini" @click="handleReset">重置
        </el-button>
      </el-form-item>
    </el-form>
    <!--    <el-row :gutter="10" class="mb8">-->
    <!--      <el-col :span="1.5">-->
    <!--   -->
    <!--      </el-col>-->
    <!--      <el-col :span="1.5">-->
    <!--        -->
    <!--      </el-col>-->
    <!--    </el-row>-->
    <el-table v-loading="loading" :data="purchaseList">
      <el-table-column type="index" label="序号" align="center" width="50"></el-table-column>
      <el-table-column label="标题" align="center" prop="purchaseName" />
      <el-table-column label="预算项目" prop="budgetName" align="center"></el-table-column>
      <el-table-column label="采购费用(元)" align="center" prop="purchaseMoney" />
      <el-table-column label="期望日期" align="center" prop="expectedDate"></el-table-column>
      <el-table-column label="申请部门" align="center" prop="deptName"></el-table-column>
      <el-table-column label="申请人" align="center" prop="applyUser">
      </el-table-column>
      <el-table-column label="申请时间" align="center" prop="applyTime"></el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" key="operate">
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="handleView(scope.row)">详 情
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <ExPagination v-show="total > 0" :total="total" :limit.sync="queryParams.pageSize" :page.sync="queryParams.pageNum"
      @pagination="getList"></ExPagination>
    <!-- 查看详情 -->
    <el-dialog :title="title" :visible.sync="openPur" width="60%">
      <el-form ref="form" :model="form" label-width="110px">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="标题">
              <el-input v-model="form.purchaseName" readonly></el-input>
            </el-form-item>
            <el-form-item label="预算项目">
              <el-input v-model="form.budgetName" readonly></el-input>
            </el-form-item>
            <el-form-item label="采购费用(元)">
              <el-input v-model="form.purchaseMoney" readonly></el-input>
            </el-form-item>
            <el-form-item label="申请时间">
              <el-input v-model="form.applyTime" readonly></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="期望日期">
              <el-input v-model="form.expectedDate" readonly></el-input>
            </el-form-item>
            <el-form-item label="申请部门">
              <el-input v-model="form.deptName" readonly></el-input>
            </el-form-item>
            <el-form-item label="申请人">
              <el-input v-model="form.applyUser" readonly></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-table :data="projectDetail" v-loading="loading" style="width: 100%">
        <el-table-column type="index" label="序号" width="48"></el-table-column>
        <el-table-column prop="assetsTypeName" label="资产分类" align="center" >
          <template slot-scope="scope">
            <span >{{ scope.row.assetsTypeName }}</span>
          
          </template>
        </el-table-column>
        <el-table-column prop="assetsName" label="资产名称" align="center" >
          <template slot-scope="{ row }">
            <span >{{ row.assetsName }}</span>
         
          </template>
        </el-table-column>
        <el-table-column prop="assetsSpecs" label="规格型号" >
          <template slot-scope="{ row }">
            <span >{{ row.assetsSpecs }}</span>
         
          </template>
        </el-table-column>
        <el-table-column prop="assetsUnit" label="单位" align="center" >
          <template slot-scope="{ row }">
            <span >{{ row.assetsUnit }}</span>
         
          </template>
        </el-table-column>
        <el-table-column prop="assetsPrice" label="单价-元" align="center" >
          <template slot-scope="{ row }">
            <span >{{ row.assetsPrice }}</span>
        
          </template>
        </el-table-column>
        <el-table-column prop="assetsNumbers" label="数量" align="center" >
          <template slot-scope="{ row }">
            <span >{{ row.assetsNumbers }}</span>
        
          </template>
        </el-table-column>
        <el-table-column prop="totalPrice" label="小计" align="center">
          <template slot-scope="{ row }">
            <span>{{ row.assetsPrice * row.assetsNumbers }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="remark" label="备注" align="center">
          <template slot-scope="{ row }">
            <span >{{ row.remark }}</span>
         
          </template>
        </el-table-column>
      </el-table>


      <div slot="footer">
        <el-button type="primary" @click="closePage">关 闭</el-button>
      </div>


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

<script>
import { purchaseList, getPurchaseDetail } from "@/api/smartSchool/logisticsManage/purchaseInfo.js"

export default {
  name: '',
  components: {},
  props: {},
  data() {
    return {
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      //   遮罩效果
      loading: true,
      // 采购信息列表
      purchaseList: [],
      // 标题
      title: "",
      // 总条数
      total: 0,
      //   查看对话框
      openPur: false,
      //查看弹窗表单
      projectDetail: [],
      // 查看详情表单
      form: {},
    };
  },
  watch: {},
  computed: {},
  methods: {
    // 获取采购信息列表
    getList() {
      this.loading = true;
      purchaseList(this.queryParams).then(response => {
        this.purchaseList = response.rows;
        this.total = response.total;
        this.loading = false;
      }).catch(() => {
      })
    },
    // 新增
    handleAdd() {
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    // 重置
    handleReset() {
      this.resetForm("queryForm");
      this.getList();
    },
    // 查看详情
    handleView(row) {
      this.title = "采购信息详情";
      this.openPur = true;
      getPurchaseDetail(row.id).then((response) => {
        this.form = response.data;
        this.projectDetail = response.data.list;
        console.log('this.form', this.form);
      }).catch(() => {
      })
    },
    //  关闭详情
    closePage() {
      this.form = {};
      this.openPur = false;
    }
  },
  created() {
    this.getList();
  },
  mounted() {
  }
};
</script>
<style scoped lang="less"></style>
