<!--
  @description: 项目经理-采购计划明细--产品未使用
  @author:gmy
  @routerPath:/procurement/procurementPlanDetailList
  @date： 2020-8-3 14:29:01
-->
<template>
  <div>
    <!--标题-->
    <div class="title title_border p0-16">
      <i class="el-icon-s-home" />采购计划明细
    </div>
    <section class="p0-16">
      <!--查询条件-->
      <div class="crud_menu_title clearfix">
        <span class="icon-line fl">查询条件</span>
        <span class="fr pointer" @click="handleToggleSearch">
          <el-link
            :underline="false"
            :class="toggleSearchStatus ? 'arrow-is-active' : ''"
            type="primary"
            class="toggleSearchStatus icon el-icon-arrow-down"
          />
          {{ toggleSearchStatus ? "收起高级查询" : "展开高级查询" }}
        </span>
      </div>
      <section :class="{ SearchContent_show: toggleSearchStatus }" class="clearfix SearchContent">
        <div class="SearchContent_leftInput fl">
          <el-form
            ref="searchForm"
            :model="searchForm"
            label-width="98px"
            label-position="left"
            inline
          >
            <el-form-item
              ref="purchasePlanNo"
              label="采购计划编号"
              class="el-form-item--two"
              prop="purchasePlanNo"
            >
              <el-input
                v-model.trim="searchForm.purchasePlanNo"
                placeholder="采购计划编号"
                style="width:20vw"
                @keyup.enter.native="onSearch"
              />
            </el-form-item>
            <!--采购计划名称-->
            <el-form-item
              ref="purchasePlanName"
              label="采购计划名称"
              prop="purchasePlanName"
              class="el-form-item--two"
            >
              <el-input
                v-model.trim="searchForm.purchasePlanName"
                placeholder="采购计划名称"
                style="width:20vw"
                @keyup.enter.native="onSearch"
              />
            </el-form-item>
            <!--行项目编号-->
            <el-form-item
              ref="purchaseNo"
              label="行项目编号"
              class="el-form-item--two"
              prop="purchaseNo"
            >
              <el-input
                v-model.trim="searchForm.purchaseNo"
                placeholder="行项目编号"
                style="width:20vw"
                @keyup.enter.native="onSearch"
              />
            </el-form-item>
            <!--物资名称-->
            <el-form-item
              ref="purchaseDesc"
              label="产品描述"
              prop="purchaseDesc"
              class="el-form-item--two"
            >
              <el-input
                v-model.trim="searchForm.purchaseDesc"
                placeholder="产品描述"
                style="width:20vw"
                @keyup.enter.native="onSearch"
              />
            </el-form-item>
            <!--类型-->
            <el-form-item
              ref="purchaseType"
              label="类别"
              prop="purchaseType"
              class="el-form-item--two"
            >
              <el-select v-model="searchForm.purchaseType" placeholder="请选择" style="width:20vw">
                <el-option
                  v-for="item in plan_purchase_typeList"
                  :key="item.typename"
                  :label="item.typename"
                  :value="item.typecode"
                />
              </el-select>
            </el-form-item>
            <!--采购组织形式-->
            <el-form-item
              ref="purchaseOrganization"
              label="采购组织形式"
              prop="purchaseOrganization"
              class="el-form-item--two"
            >
              <el-select
                v-model="searchForm.purchaseOrganization"
                placeholder="请选择"
                style="width:20vw"
              >
                <el-option
                  v-for="item in plan_purchase_organizationList"
                  :key="item.typename"
                  :label="item.typename"
                  :value="item.typecode"
                />
              </el-select>
            </el-form-item>
            <!--采购单位-->
            <el-form-item
              ref="purchaseDepartName"
              label="采购单位"
              prop="purchaseDepartName"
              class="el-form-item--two"
            >
              <el-input
                v-model.trim="searchForm.purchaseDepartName"
                placeholder="采购单位"
                style="width:20vw"
                @keyup.enter.native="onSearch"
              />
            </el-form-item>
            <el-form-item
              ref="sourcingDepartName"
              label="采购执行单位"
              prop="sourcingDepartName"
              class="el-form-item--two"
            >
              <el-input
                v-model.trim="searchForm.sourcingDepartName"
                placeholder="采购执行人"
                style="width:20vw"
                @keyup.enter.native="onSearch"
              />
            </el-form-item>
            <!--采购计划状态-->
            <el-form-item
              ref="tenderMethod"
              label="采购计划状态"
              prop="tenderMethod"
              class="el-form-item--two"
            >
              <el-select v-model="searchForm.dataStatus" placeholder="请选择" style="width:20vw">
                <el-option
                  v-for="item in plan_data_statusList"
                  :key="item.typename"
                  :label="item.typename"
                  :value="item.typecode"
                />
              </el-select>
            </el-form-item>
            <el-form-item
              ref="purchaseCode"
              label="产品编码"
              prop="purchaseCode"
              class="el-form-item--two"
            >
              <el-input
                v-model.trim="searchForm.purchaseCode"
                placeholder="产品编码"
                style="width:20vw"
                @keyup.enter.native="onSearch"
              />
            </el-form-item>
          </el-form>
        </div>
        <div class="fr">
          <el-button type="primary" @click="onSearch">
            搜 索
          </el-button>
          <el-button plain type="info" @click="resetForm('searchForm')">
            重 置
          </el-button>
        </div>
      </section>
      <!--查询结果-->
      <div class="crud_menu_title">
        <span class="icon-line">查询结果</span>
      </div>
      <section>
        <el-table ref="smallTable" v-loading="loading" :data="tableData">
          <el-table-column type="index" label="序号" align="center" width="60" />
          <el-table-column
            prop="purchasePlanNo"
            label="采购计划编号"
            header-align="center"
            align="center"
            min-width="160"
          />
          <el-table-column
            prop="purchasePlanName"
            label="采购计划名称"
            header-align="center"
            align="left"
            min-width="280"
          />
          <el-table-column
            prop="purchaseNo"
            label="行项目编号"
            min-width="160"
            header-align="center"
            align="center"
          />
          <el-table-column
            prop="versionNo"
            label="版本号"
            min-width="80"
            header-align="center"
            align="left"
          />
          <el-table-column
            prop="purchaseCode"
            label="产品编码"
            min-width="160"
            header-align="center"
            align="left"
          />
          <el-table-column
            label="产品描述"
            prop="purchaseDesc"
            min-width="320"
            header-align="center"
            align="left"
          />
          <el-table-column
            prop="purchaseType"
            label="类别"
            header-align="center"
            align="center"
            min-width="80"
          >
            <template slot-scope="scope">
              <p>{{ filterDictText(plan_purchase_typeList,scope.row.purchaseType ) }}</p>
            </template>
          </el-table-column>
          <el-table-column
            label="采购单位"
            min-width="180"
            header-align="center"
            align="left"
          >
            <template slot-scope="scope">
              <span>
                {{ scope.row.purchaseDepartName }}
              </span>
            </template>
          </el-table-column>
          <el-table-column
            prop="sourcingDepartName"
            label="采购执行单位"
            min-width="140"
            header-align="center"
            align="left"
          />
          <el-table-column
            prop="purchaseOrganization"
            label="采购组织形式"
            header-align="center"
            align="center"
            min-width="110"
          >
            <template slot-scope="scope">
              <p>{{ filterDictText(plan_purchase_organizationList,scope.row.purchaseOrganization ) }}</p>
            </template>
          </el-table-column>
          <el-table-column
            prop="dataStatus"
            label="采购计划状态"
            header-align="center"
            align="center"
            min-width="110"
          >
            <template slot-scope="scope">
              <p>{{ filterDictText(plan_data_statusList,scope.row.dataStatus ) }}</p>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" width="100" fixed="right">
            <template slot-scope="scope">
              <el-link type="primary" @click.stop="detail(scope.row)">
                [查看]
              </el-link>
              <el-link type="primary" @click="openLog(scope.row.planDetailId)">
                [日志]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
        <!--分页组件-->
        <pagination :pagination-data="paginationData" @change="loadData" />
        <!-- 采购计划日志 -->
        <procurementPlanLog ref="procurementPlanLog" />
      </section>
    </section>
  </div>
</template>

<script>
/* api接口*/
import { listPurchasePlanDetailAllPages } from '@/api/procurement/purchasplan'
/* 公共参数方法*/
import { ListMixin } from '@/mixins/ListMixin'
import { procurementPlanGrounpMixins } from '../mixins/procurementPlanGroupMixins' // 字典信息
import { filterObj, restoreInitialValue, filterDictText } from '@/assets/js/utils'

/* 分页组件*/
import pagination from '@comp/common/pagination/pagination'
import procurementPlanLog from './procurementPlanLog-dialog.vue' // 采购计划日志
export default {
  name: 'PurchasePlanDetailsList',
  components: {
    pagination, // 分页
    procurementPlanLog // 采购计划日志
  },
  mixins: [ListMixin, procurementPlanGrounpMixins],
  data() {
    return {
      //  当前用户选择采购单列表弹框
      myPurchasePlanListDialog: {
        dialog: false
      },
      purchaserType: '01', // 00采购员  01采购执行人
      loading: true,
      date: '',
      searchForm: {
        purchaseType: '', // 类型
        purchaseOrganization: '', // 采购组织形式
        dataStatus: '', // 采购计划状态
        purchaseDepartName: '', // 采购单位
        purchaseDesc: '', // 物资描述
        purchaseNo: '', // 行项目编号
        purchasePlanName: '', // 采购计划名称
        purchasePlanNo: '', // 采购计划编号
        sourcingDepartName: '' // 采购执行人
      },
      tableData: [],
      implementPurchaseList: '', // 自行采购选中集合
      purchaseDepartName: '' // 采购单位
    }
  },
  created() {
    this.loadData() // 查询数据
    // this.initWebTypeGroup() // 字典接口数据方法
  },
  methods: {
    filterDictText, // 数据字典方发
    // 获取数据
    loadData() {
      const params = this.getQueryParams() // 查询条件
      listPurchasePlanDetailAllPages(params)
        .then(response => {
          this.loading = false
          this.tableData = response.data.records
          this.paginationData.total = response.data.total
        })
        .catch(() => {
          this.loading = false
        })
    },
    // 查询条件
    getQueryParams() {
      const param = Object.assign({}, this.searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    },
    // 搜索
    onSearch() {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.loadData() // 查询数据
    },
    // 重置
    resetForm() {
      // 清空数据
      restoreInitialValue(this.searchForm)
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.loadData() // 查询数据
    },
    // 查看
    detail(row) {
      this.$router.push({
        path: '/procurement/procurementPlanDetail',
        query: { planDetailId: row.planDetailId }
      })
    },
    // 打开采购计划日志
    openLog(planDetailId) {
      this.$refs.procurementPlanLog.openDialogInitData(planDetailId)
    }
  }
}
</script>

<style lang="less" scoped>
/deep/.el-table__body-wrapper::-webkit-scrollbar {
  padding-top: 5px;
  height: 10px;
}
</style>
