<template>
  <div class="project-cost-ledger-container">
    <div class="project-cost-ledger-inner">
      <div class="title_wrap">
        <div class="enterprise_title">
          项目成本台账
        </div>
      </div>
      <div class="content-project">
        <el-form :model="formdata" label-width="82px" label-position="right"  :inline="true" >
          <el-row>
            <el-form-item label="工程名称">
              <el-input v-model="formdata.customerName" placeholder="请输入工程名称" clearable></el-input>
            </el-form-item>
            <el-form-item label="IPM项目编码" label-width="100px">
              <el-input v-model="formdata.customerName" placeholder="请输入IPM项目编码" clearable></el-input>
            </el-form-item>
            <el-form-item label="成本阶段">
              <el-select v-model="formdata.customerClass" multiple placeholder="请选择" :collapse-tags="true" clearable>
                  <el-option v-for="(item,index) in cbStagelist" :label="item.dictLabel" :value="item.dictValue" :key="index"></el-option>
              </el-select>
            </el-form-item>
          </el-row>
          <el-divider></el-divider>
          <el-form-item label="  ">
            <el-button type="primary" size="small" @click="getSearch">查询</el-button>
            <el-button size="small" @click="clears">重置</el-button>
          </el-form-item>
        </el-form>
      </div>

      <div class="table-project">
        <div class="table-item-jf1" v-if="total == 0 && !isSkeleton">
          <img class="item-jf-img" src="@/assets/images/kong.png" alt="">
          <div class="item-jf-titel">暂无数据，点击按钮导入项目成本数据</div>
          <el-button type="primary" class="jf-btn" size="small" @click="addPro">新增项目</el-button>
        </div>
      </div>
      <el-dialog
        class="pro-news"
        :visible.sync="dialogVisible"
        width="480px">
        <div class="poptitle">
          <span>新建商机</span>
        </div>
        <el-form class="popform" label-width="97px" :model="queryParam" :rules="rules" ref="ruleForm">
          <el-form-item label="项目名称" class="row">
            <el-input type="text" v-model="queryParam.projectName" placeholder="请输入完整的项目名称"></el-input>
          </el-form-item>
          <el-form-item label="IPM项目编码" class="row">
            <el-input type="text" placeholder="请输入IPM项目编码" v-model="queryParam.ipmProjectNo">
              <template slot="append"><div class="pro-getbtn" @click="getipmProjectNo">获取数据</div></template>
            </el-input>
          </el-form-item>
          <el-form-item label="文件名称" class="row">
            <el-input type="text" placeholder="请输入文件名称" v-model="queryParam.projectFileName"></el-input>
          </el-form-item>
          <el-form-item label="成本阶段" class="row" prop="cbStage">
            <el-select placeholder="请选择成本阶段" v-model="queryParam.cbStage">
              <el-option v-for="(item,index) in cbStagelist" :label="item.dictLabel" :value="item.dictValue" :key="index"></el-option>
            </el-select>
          </el-form-item>
        </el-form >
        <div class="popbot">
          <div class="btn btn_cancel h32" @click="dialogVisible = false">取消</div>
          <div class="btn btn_primary h32" :class="{'btn_disabled':!queryParam.cbStage}" :disabled="!queryParam.cbStage">下一步，导入数据</div>
        </div>
        <!--<el-form class="popform" :model="queryParam" ref="ruleForm" label-width="137px" :rules="rules" >-->
          <!--<el-form-item label="联系人姓名：" class="row" prop="name">-->
            <!--<el-input type="text" v-model="queryParam.name" :οnkeyup="queryParam.name=queryParam.name.replace(/^\s+|\s+$/g,'')" placeholder="请输入"></el-input>-->
          <!--</el-form-item>-->
          <!--<el-form-item label="联系人性别：" class="row">-->
            <!--<el-radio-group v-model="queryParam.sex">-->
              <!--<el-radio label=1>男</el-radio>-->
              <!--<el-radio label=0>女</el-radio>-->
            <!--</el-radio-group>-->
          <!--</el-form-item>-->
          <!--<el-form-item label="联系方式：" class="row">-->
            <!--<el-input type="text" maxlength="11" @input="inputphone"  v-model="queryParam.contactInformation" placeholder="请输入"></el-input>-->
          <!--</el-form-item>-->
          <!--&lt;!&ndash;<el-form-item label="关联企业：" class="row" v-if="thistype == 'project'">&ndash;&gt;-->
          <!--<el-form-item label="关联企业：" class="row">-->
            <!--<el-input type="text" v-model="queryParam.companyName" placeholder="请输入"></el-input>-->
          <!--</el-form-item>-->
          <!--<el-form-item label="联系人角色：" class="row">-->
            <!--<el-input type="text" v-model="queryParam.role" placeholder="请输入"></el-input>-->
          <!--</el-form-item>-->
          <!--<el-form-item label="联系人职位：" class="row">-->
            <!--<el-input type="text" v-model="queryParam.position" placeholder="请输入"></el-input>-->
          <!--</el-form-item>-->
          <!--&lt;!&ndash;<el-form-item label="内部维护人：" class="row">&ndash;&gt;-->
          <!--&lt;!&ndash;<el-input type="text" v-model="queryParam.accendant" placeholder="请输入"></el-input>&ndash;&gt;-->
          <!--&lt;!&ndash;</el-form-item>&ndash;&gt;-->
          <!--<el-form-item label="备注：" class="row">-->
            <!--<el-input-->
              <!--type="textarea"-->
              <!--maxlength="200"-->
              <!--:rows="2"-->
              <!--show-word-limit-->
              <!--placeholder="请输入"-->
              <!--v-model="queryParam.remark">-->
            <!--</el-input>-->
          <!--</el-form-item>-->
          <!--<div class="popbot">-->
            <!--<div class="btn btn_cancel h32" @click="cancel">返回</div>-->
            <!--<div class="btn btn_primary h32" @click="save">保存</div>-->
          <!--</div>-->
        <!--</el-form>-->
      </el-dialog>

    </div>
  </div>
</template>
<script>
  import '@/assets/styles/public.scss'
  import { checkProjectCodeExist } from '@/api/projectCostLedger/index'
  import { getDicts } from '@/api/system/dict/data'

  export default {
  name: "projectCostLedger",
  data() {
    return {
      formdata:{},
      isSkeleton:false,
      total:0,
      dialogVisible:false,
      cbStagelist:[],
      //新建项目参数
      queryParam:{
        projectName:'',//项目名称
        ipmProjectNo:'',//	IPM项目编码
        isGetProjectDetail:0,//	是否获取项目详情 0:否、1:是)
        projectFileName:'',//	文件名称
        cbStage:'',//成本阶段
      },
      rules:{
        cbStage:[{ required: true, message: '请选择成本阶段！', trigger: 'blur' },],
      },
    };
  },
  //可访问data属性
  created() {
    //成本阶段
    getDicts('pro_cbstage').then(res=>{
      this.cbStagelist = res.data
    })

  },
  //计算集
  computed: {

  },
  //方法集
  methods: {
    addPro(){
      this.dialogVisible = true
      this.queryParam = {
        projectName: '',//项目名称
        ipmProjectNo: '',//	IPM项目编码
        isGetProjectDetail: 0,//	是否获取项目详情 0:否、1:是)
        projectFileName: '',//	文件名称
        cbStage: ''//成本阶段
      }
    },
    getSearch(){
      this.formdata.pageNum = 1
      // this.customerAll()
    },
    getipmProjectNo(){
      //点击且校验了当前编码有数据才获取
      checkProjectCodeExist(this.queryParam.ipmProjectNo).then(res=>{
        if(res.code == 200 && res.data == true){
          this.queryParam.isGetProjectDetail = 1
        }else{
          this.queryParam.isGetProjectDetail = 0
        }
      })
    },
    clears(){
      this.formdata={
        customerName: '',
        customerClass:[],
        areas:[],
        province:[],
        city:[],
        customerState:[],
        creditLevel:[],
        credential:[],
        approveDateBegion:null,
        approveDateEnd:null,
        times:[],
        pageSize:50,
        pageNum:1,
      }
      // this.customerAll()
    },

  },
}
</script>
<style lang="scss" scoped>
  .project-cost-ledger-container {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: 16px 24px;

    .project-cost-ledger-inner {
      width: 100%;
      height: 100%;
    }

    .content-project {
      background: #fff;
      padding-top: 14px;

      .el-form-item {
        margin-bottom: 16px;
      }

      .el-divider {
        margin-bottom: 16px;
      }
    }

    .table-project {
      background: #fff;
      margin-top: 16px;
      height: calc(100vh - 296px);
      padding-top: 1px;
      min-height: 350px;

      .table-item-jf1 {
        margin-top: calc(27vh - 90px);

        .item-jf-img {
          margin-bottom: 16px;
        }
      }

      .item-jf-titel {
        font-size: 14px;
        color: #232323;
        line-height: 22px;
        margin-bottom: 16px;
      }

      .jf-btn {
        display: block;
        background: #0081ff;
        margin: auto;
      }
    }

    ::v-deep .pro-news {
      .el-dialog__body {
        padding: 24px 0 0;
      }

      .el-dialog__headerbtn {
        top: 20px;
        right: 20px;
        z-index: 3;
      }

      .poptitle {
        line-height: 56px;
        border-bottom: 1px solid #eee;
        height: 56px;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;

        > span {
          padding-left: 20px;
          font-weight: bold;
          font-size: 16px;
          color: #232323;
          font-family: Microsoft YaHei-Bold, Microsoft YaHei;
          width: 385px;
          display: block;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
      }

      .popform {
        padding: 24px 20px 0;

        .row {
          margin-bottom: 16px;
          position: relative;

          .el-form-item__label {
            font-weight: 400;
            opacity: 0.8;
            padding: 0;
            font-size: 14px;
            color: #232323;
            padding-right: 16px;
          }

          .el-input,
          .el-textarea,
          .el-select {
            display: inline-block;
            width: 343px;

            .el-input__inner,
            .el-textarea__inner {
              width: 100%;
              height: 32px;
              border-radius: 0px;

              &:hover {
                border-color: #0081ff;
              }
            }

            .el-textarea__inner {
              height: 90px;
              font-family: inherit;
              color: #000;
            }

            .el-input__suffix {
              height: 32px;
            }

            .el-input__icon {
              line-height: 32px;
            }
          }

          .el-form-item__error {
            padding-top: 2px;
          }
        }
        .el-input-group--append{
          position: relative;
          .el-input-group__append{
            position: absolute;
            right: 0;
            width: 76px;
            top: 0;
            border: 0;
            background: none;
            &:hover{
              background: none !important;
            }
            .pro-getbtn{
              border-left: 1px solid #DCDFE6;
              height: 32px;
              color: #0081FF;
              line-height: 32px;
              text-align: center;
            }
          }
        }
      }

      .popbot {
        border-top: 1px solid #EEEEEE;
        text-align: right;
        margin-top: 24px;
        padding: 16px 20px;

        .btn {
          border-radius: 2px;
          margin-left: 12px;
          padding: 0 24px;
          &.btn_disabled{
            background: #8BD1FF;
          }
        }
      }
    }
  }

</style>
