<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="状态">
              <a-select default-value="0" v-model="queryParam.status">
                <a-select-option value="0">
                  全部
                </a-select-option>
                <a-select-option value="1">
                  审核中
                </a-select-option>
                <a-select-option value="2">
                  已通过
                </a-select-option>
                <a-select-option value="3">
                  已驳回
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <!--<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>-->
    </div>

    <!-- table区域-begin -->

    <a-table ref="table" size="middle" bordered rowKey="id" :columns="columns" :dataSource="dataSource"
      :pagination="ipagination" :loading="loading" @change="handleTableChange">
      <span slot="action" slot-scope="text, record">
        <a @click="handleEditStatus(record,'2')" :disabled="record.status!=1">通过</a>

        <a-divider type="vertical" />
        <a @click="handleEditStatus(record,'3')" :disabled="record.status!=1">驳回</a>


      </span>
    </a-table>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <projectTransferRecord-modal ref="modalForm" @ok="modalFormOk"></projectTransferRecord-modal>
  </a-card>
</template>

<script>
  import ProjectTransferRecordModal from './modules/ProjectTransferRecordModal'
  import {
    JeecgListMixin
  } from '@/mixins/JeecgListMixin'
  import {
    postAction
  } from "../../../api/manage";
  import qs from 'qs'
  export default {
    name: "ProjectTransferRecordList",
    mixins: [JeecgListMixin],
    components: {
      ProjectTransferRecordModal
    },
    data() {
      return {
        description: '账户转项目记录管理页面',
        // 表头
        columns: [{
            title: '账户id',
            align: "center",
            dataIndex: 'accountId'
          },
          {
            title: '账户名称',
            align: "center",
            dataIndex: 'accountId_dictText'
          },
          {
            title: '原项目',
            align: "center",
            dataIndex: 'soucreProject_dictText'
          },
          {
            title: '目标项目',
            align: "center",
            dataIndex: 'targetProject_dictText'
          },
          {
            title: '申请人',
            align: "center",
            dataIndex: 'userId_dictText'
          },
          {
            title: '审核人',
            align: "center",
            dataIndex: 'reviewerId_dictText'
          },
          {
            title: '审核状态',
            align: "center",
            dataIndex: 'status_dictText'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: "center",
            scopedSlots: {
              customRender: 'action'
            },
          }
        ],
        url: {
          list: "/ctop/projectTransferRecord/auditList",
          delete: "/ctop/projectTransferRecord/delete",
          deleteBatch: "/ctop/projectTransferRecord/deleteBatch"
        },
      }
    },
    computed: {
      importExcelUrl: function () {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      handleDele(record) {
        if (confirm("确认要删除此数据？")) {
          postAction()
        }
      },
      handleEditStatus(item, status) {
        var params = qs.stringify({
          id: item.id,
          status: status
        })
        postAction('/ctop/projectTransferRecord/editStatus', params).then(res => {
          if (res.success) {
            this.$message.success(res.message)
            this.loadData()
          } else {
            this.$message.success(res.message)
          }
        })
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>