<template>
  <a-modal
    :title="title"
    :width="modelStyle.width"
    :visible="visible"
    :bodyStyle="bodyStyle"
    :confirmLoading="confirmLoading"
    :maskClosable="false"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭"
    :footer="null">
  <page-layout :title="'需求编号：'+model.code" :noBreadcrumb='true'>

    <!-- 操作 -->
<!--    <a-card :bordered="false">-->
      <detail-list title="需求信息">
        <detail-list-item term="需求名称">{{model.name||'name'}}</detail-list-item>
        <detail-list-item term="归属行业">{{model.tradeType}}</detail-list-item>
        <detail-list-item term="需求人数">{{model.number?model.number:'若干'}}</detail-list-item>
        <!--<detail-list-item term="期数">{{model.stage}}</detail-list-item>-->
        <detail-list-item term="参考单价">{{model.price}}</detail-list-item>
        <detail-list-item term="工作地点">{{model.provinceCityCountry}}</detail-list-item>
        <detail-list-item term="详细地址">{{model.address}}</detail-list-item>
      </detail-list>
      <detail-list>
        <detail-list-item term="需求状态">{{statuss}}</detail-list-item>
        <detail-list-item term="创建时间">{{model.createTime}}</detail-list-item>
      </detail-list>
      <a-divider style="margin-bottom: 32px"/>
      <detail-list title="需求描述：">
        <div class='detail-content'>{{model.description}}</div>
      </detail-list>
      <a-divider style="margin-bottom: 32px"/>
      <detail-list title="接单资质：">
        <div class='detail-content'>{{model.qualification}}</div>
      </detail-list>
    <a-divider style="margin-bottom: 32px"/>
    <detail-list title="验收标准：">
      <div class='detail-content'>{{model.acceptanceCriteria}}</div>
      </detail-list>

    <a-divider style="margin-bottom: 32px"/>
       <!--<template v-if="model.authenticationStatus!=0">-->
          <!--<detail-list title="其他信息" v-has="'require:viewcontracts'">-->

            <!--&lt;!&ndash;<detail-list-item term="通过平台" >&ndash;&gt;-->
              <!--&lt;!&ndash;{{model.subcontractType!=null ?'是':'否'}}&ndash;&gt;-->
            <!--&lt;!&ndash;</detail-list-item>&ndash;&gt;-->

            <!--<detail-list-item term="企业合同" >-->
              <!--<template v-if="model.serviceContractType === 0 ||model.serviceContractType === 1">-->
                <!--{{model.serviceContractType === 0 ? model.serviceContract ? '线上合同(已上传)':'线上合同(未上传)':'线下合同'}}-->
                  <!--<a @click="handleWorkDownload(model.serviceContract)" style="margin-left: 15px" v-has="'require:viewContracts1'">查看</a>-->
                  <!--<a @click="handleSelectEditModal(model)" style="margin-left: 15px" v-has="'require:editContracts1'">修改</a>-->
              <!--</template>-->
            <!--</detail-list-item>-->

            <!--&lt;!&ndash;<template v-if="model.subcontractType!=null">&ndash;&gt;-->
              <!--&lt;!&ndash;<detail-list-item term="外包合同" >&ndash;&gt;-->
                  <!--&lt;!&ndash;{{model.subcontractType === 0 ? model.subcontract ? '线上合同(已上传)':'线上合同(未上传)':'线下合同'}}&ndash;&gt;-->
                    <!--&lt;!&ndash;<a @click="handleWorkDownload(model.subcontract)" style="margin-left: 15px" v-has="'require:viewContracts'">查看</a>&ndash;&gt;-->
                    <!--&lt;!&ndash;<a @click="handleSubcontractEditModal(model)" style="margin-left: 15px" v-has="'require:editContracts'">修改</a>&ndash;&gt;-->
              <!--&lt;!&ndash;</detail-list-item>&ndash;&gt;-->
            <!--&lt;!&ndash;</template>&ndash;&gt;-->

            <!--&lt;!&ndash;<template v-if="model.subcontractType!=null">&ndash;&gt;-->
              <!--&lt;!&ndash;<detail-list-item style="float: right" term="外包服务费比例" >&ndash;&gt;-->
                <!--&lt;!&ndash;{{model.subcontractorFeeRate}}%&ndash;&gt;-->
              <!--&lt;!&ndash;</detail-list-item>&ndash;&gt;-->
            <!--&lt;!&ndash;</template>&ndash;&gt;-->

            <!--&lt;!&ndash;<detail-list-item style="float: right" term="服务费比例" >&ndash;&gt;-->
              <!--&lt;!&ndash;{{model.serviceFeeRate}}%&ndash;&gt;-->
            <!--&lt;!&ndash;</detail-list-item>&ndash;&gt;-->

          <!--</detail-list>-->
      <!--</template>-->
<!--    </a-card>-->

    <hw-view-service-contract-modal ref="modalSelectForm" @ok="modalFormOk"></hw-view-service-contract-modal>

    <hw-view-subcontract-modal ref="modalSelectSubcontractForm" @ok="modalFormOk"></hw-view-subcontract-modal>

  </page-layout>
  </a-modal>
</template>

<script>


  import PageLayout from '@/components/page/PageLayout'
  import STable from '@/components/table/'
  import DetailList from '@/components/tools/DetailList'
  import ABadge from 'ant-design-vue/es/badge/Badge'
  import { httpAction, getAction, putAction, downFile } from '@/api/manage'
  import pick from 'lodash.pick'
  import JDate from '@/components/jeecg/JDate'
  import { initDictOptions } from '@/components/dict/JDictSelectUtil'
  import { axios } from '@/utils/request'
  import {ajaxFilterDictText} from '@/components/dict/JDictSelectUtil'
  import HwViewServiceContractModal from './HwViewServiceContractModal'
  import HwViewSubcontractModal from './HwViewSubcontractModal'

  const confirmOrder = (params) => putAction('/ordermanager/hwOrder/confirmOrder', params)
  const closeOrder = (params) => putAction('/ordermanager/hwOrder/closeOrder', params)
  const limitOrder = (params) => putAction('/ordermanager/hwOrder/limitOrder', params)

  const DetailListItem = DetailList.Item

  export default {
    name: 'HwRequireViewModal',
    components: {
      HwViewSubcontractModal,
      HwViewServiceContractModal,
      PageLayout,
      ABadge,
      DetailList,
      DetailListItem,
      STable,
      JDate,

    },
    data() {
      return {
        statuss:"",
        title: '需求详情',
        modelStyle: {
          width: '80%',
          style: { top: '20px' },
          fullScreen: false
        },
        bodyStyle: {
          height: (window.innerHeight * 0.80) + 'px',
          'overflow-y': 'auto'
        },
        confirmLoading: false,
        visible: false,
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 }
        },
        activeTabKey: '1',
        loading: false,
        model: {},
        electronicContractStatus_dictText:'',
        validatorRules: {
          serviceContractType: { rules: [{ required: true, message: '请输入合同方式' }] }
        },
        detailLength: 0,
        url: {
          add: '/ordermanager/hwOrder/add',
          edit: '/ordermanager/hwOrder/edit',
          getColumns: '/ordermanager/hwOrder/detail?id=',
          downloadUrl: window._CONFIG['domianURL'] + '/hpSys/common/ossDownload'
        }
      }
    },
    created() {
    },

    watch: {

    },
    methods: {
      close() {
        this.$emit('ok')
        this.visible = false
      },
      add() {
        this.edit({})
      },
      edit(record) {
        this.model={}
        this.model = Object.assign({}, record)
        ajaxFilterDictText('trade_type',this.model.tradeType).then((res) => {
              this.model.tradeType=res
        })
        if(record.authenticationStatus===0){
          this.statuss='审核中'
        }else if(record.authenticationStatus===1){
          this.statuss='打回'
        }else if(record.authenticationStatus===2){
          if(record.isOn===1){
            this.statuss='发布中'
          }else if(record.isOn===0){
            this.statuss='下架'
          }
        }
        this.visible = true

      },
      handleOk() {
        this.$emit('ok')
        this.visible = false
      },
      handleCancel() {
        this.close()
      },



      //修改企业合同
      handleSelectEditModal(model) {
        this.$refs.modalSelectForm.edit(model)
        this.$refs.modalSelectForm.title = '修改企业合同'
        this.$refs.modalSelectForm.disableSubmit = false
      },
      handleSubcontractEditModal(model) {
        this.$refs.modalSelectSubcontractForm.edit(model)
        this.$refs.modalSelectSubcontractForm.title = '修改外包合同'
        this.$refs.modalSelectSubcontractForm.disableSubmit = false
      },


      //查看合同
      handleWorkDownload(fileName) {
        if(!fileName){
          this.$message.warning("未知的文件")
          return;
        }
        if(fileName.indexOf(",")>0){
          fileName = fileName.substring(0,fileName.indexOf(","))
        }
        window.open(window._CONFIG['imgDomainOssURL'] + fileName, '_blank', 'toolbar=yes');
      },

      modalFormOk(){
        this.routeReload()
      },
      //刷新路由
      routeReload(){
        this.reloadFlag = false
        let ToggleMultipage = "ToggleMultipage"
        this.$store.dispatch(ToggleMultipage,false)
        this.$nextTick(()=>{
          this.$store.dispatch(ToggleMultipage,true)
          this.reloadFlag = true
        })
      },
    }
  }
</script>
<style lang="scss" scoped>
  .title {
    color: rgba(0, 0, 0, .85);
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 16px;
  }

  .detail-layout {
    margin-left: 44px;
  }

  .text {
    color: rgba(0, 0, 0, .45);
  }

  .heading {
    color: rgba(0, 0, 0, .85);
    font-size: 20px;
  }

  .step-item {
    min-height: 148px !important;
  }

  ::v-deep .page-header{
    padding: 0;
  }

  ::v-deep .detail-list .title{
    font-size: 20px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #000000;
    margin-bottom: 26px;
  }

  ::v-deep .detail-list .term{
    font-size: 14px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #000000;
  }

  ::v-deep .detail-list .content{
    font-size: 14px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: rgba(0,0,0,0.65);
  }

  .detail-content{
    font-size: 14px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #000000;
  }
</style>