<!--
  @description: 采购员报价记录弹框
  @Modifier：gmy
  @date2020-8-12- 14:29
-->
<template>
  <el-dialog
    v-dialogDrag
    :visible.sync="dialogData.dialog"
    :close-on-click-modal="false"
    :lock-scroll="false"
    title="报价记录"
    width="840px"
    append-to-body
    custom-class="el-dialog__body-p8 el-dialog_table"
  >
    <!--搜索-->
    <div class="clearfix p0-16">
      <el-form ref="searchForm" :model="searchForm" inline>
        <!--采购计划名称-->
        <el-form-item
          ref="purchasePlanName"
          label="供应商名称"
          prop="purchasePlanName"
        >
          <el-input
            v-model.trim="searchForm.supplierName"
            placeholder="供应商名称"
            style="width: 200px"
            @keyup.enter.native="onSearch"
          />
        </el-form-item>
        <!--物资名称-->
        <el-form-item ref="tenderMethod" label="操作类型" class="list_seach_select" prop="tenderMethod">
          <el-select v-model="searchForm.useStatus" placeholder="请选择" style="width: 200px">
            <el-option
              v-for="item in offer_use_statusList"
              :key="item.typename"
              :label="item.typename"
              :value="item.typecode"
            />
          </el-select>
        </el-form-item>
        <el-form-item class="fr">
          <el-button
            type="primary"
            @click="onSearch('searchForm')"
          >
            搜索
          </el-button>
          <el-button
            plain
            type="info"
            @click="resetForm('searchForm')"
          >
            重置
          </el-button>
        </el-form-item>
      </el-form>
    </div>
    <!--报价记录-->
    <div>
      <el-table
        ref="smallTable"
        v-loading="loading"
        :data="tableData"
        class="pointer"
      >
        <el-table-column
          type="index"
          label="序号"
          align="center"
          width="60"
        />
        <el-table-column
          prop="supplierName"
          label="供应商名称"
          align="left"
          width="160"
        />
        <el-table-column
          label="操作类型"
          header-align="center"
          align="left"
          min-width="110"
        >
          <template slot-scope="scope">
            <p>
              {{ scope.row.useStatus==='01'? '报价': '撤销报价' }}
            </p>
          </template>
        </el-table-column>
        <el-table-column
          prop="purchaseNo"
          label="操作时间"
          min-width="150"
          header-align="center"
          align="center"
        >
          <template slot-scope="scope">
            <p>
              {{ $Moment(scope.row.createTime).format(momentSaveFormat) }}
            </p>
          </template>
        </el-table-column>
        <el-table-column
          label="Ip地址"
          width="125"
          header-align="center"
          align="left"
        >
          <template slot-scope="scope">
            <span :style="{'color':scope.row.isSameIp==='01'?'red':''}">{{ scope.row.offerIp }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="offerBrowser"
          label="报价浏览器"
          width="110"
          header-align="center"
          align="left"
        />
      </el-table>
      <!--分页组件-->
      <pagination :pagination-data="paginationData" @change="loadData" />
    </div>
  </el-dialog>
</template>

<script>
/* api接口*/
import { getOfferRecordList } from '@/api/procurement/procurementOffer'
/* 公共参数方法*/
import { ListMixin } from '@/mixins/ListMixin'
import { filterObj } from '@/assets/js/utils'
import { commonMxin } from '@/mixins/commonMxin'
import { procurementOfferGroupMixin } from '../mixins/procurementOffGroupMixin'
/* 分页组件*/
import pagination from '@comp/common/pagination/pagination'
/* api接口*/
export default {
  name: 'MyPurchasePlanListDialog',
  components: {
    pagination
  },
  mixins: [ListMixin, commonMxin, procurementOfferGroupMixin],
  props: {
    dialogData: {
      type: Object,
      default: function() {
        return
      }
    }
  },
  data() {
    return {
      purchaserType: '00', // 00采购员  01采购执行人
      loading: true,
      date: '',
      searchForm: {
        stageId: '', // 轮次id
        useStatus: '', // 操作类型
        supplierName: '' // 供应商名称
      },
      tableData: [],
      implementPurchaseList: ''// 自行采购选中集合
    }
  },
  watch: {
    'dialogData.dialog'(val) {
      // 打开弹框加载数据
      if (val) {
        // 根据项目信息选择的采购方式来动态改变数据
        this.searchForm.stageId = this.dialogData.stageId
        this.loadData()
      }
    }
  },
  created() {
    // 查询字典
    this.inCodes()
  },
  methods: {
    // 查询条件
    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() {
      this.searchForm.useStatus = ''
      this.searchForm.supplierName = ''
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.loadData()
    },
    // 加载数据
    loadData() {
      const params = this.getQueryParams() // 查询条件
      getOfferRecordList(params)
        .then(response => {
          this.loading = false
          this.tableData = response.data.records
          this.paginationData.total = response.data.total
        })
        .catch(() => {
          this.loading = false
        })
    }
  }
}
</script>

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