<!--
  @description: 订单详情-订单基本信息组件
  @author: gmy
  @routerPath:
  @date： 2020-09-23 11:41:12
-->
<template>
  <div>
    <p class="page-title">
      1.订单基本信息
    </p>
    <table class="from_table mb16">
      <tr>
        <td>订单编号</td>
        <td>{{ orderInfoBase.orderCode }}</td>
        <td>
          <p v-if="isEdit==='00'">
            订单名称
          </p>
          <el-form-item v-else label="订单名称" prop="orderName" />
        </td>
        <td>
          <p v-if="isEdit==='00'">
            {{ orderInfoBase.orderName }}
          </p>
          <el-input v-else v-model="orderInfoBase.orderName" maxlength="100" show-word-limit />
        </td>
      </tr>
      <tr>
        <td>采购单编号</td>
        <td>
          <!-- roleCode角色编码  12表示供应商 供应商查看订单不可点击采购单弹框 -->
          <el-link v-if="roleCode!=='12'" type="primary" @click="orderProjectClick(orderInfoBase.tenderId)">
            {{ orderInfoBase.tenderNo }}
          </el-link>
          <p v-else>
            {{ orderInfoBase.tenderNo }}
          </p>
        </td>
        <td>采购单名称</td>
        <td>{{ orderInfoBase.tenderName }}</td>
      </tr>
      <tr>
        <td>采购方式</td>
        <td>
          {{ filterDictText(tendermethodList, orderInfoBase.tenderMethod) }}
        </td>
        <td>采购单位</td>
        <td>{{ orderInfoBase.purchaseDepartName }}</td>
      </tr>
      <tr>
        <td>创建日期</td>
        <td>{{ $Moment(orderInfoBase.createTime).format(momentDate) }}</td>
        <td>状态</td>
        <td>
          {{ filterDictText(procurementOrderOrderStatus, orderInfoBase.orderStatus) }}
        </td>
      </tr>
      <tr>
        <td>供应商名称</td>
        <td>{{ orderInfoBase.winningDepartName }}</td>
        <td>报价单号</td>
        <td>
          <!-- 查看供应商报价事件  项目id 标段id 供应商id -->
          <el-link type="primary" @click="orderSupplierClick(true)">
            {{ orderInfoBase.negRecordCode }}
          </el-link>
        </td>
      </tr>
      <tr>
        <td>
          <p v-if="isEdit==='00'">
            送货地址
          </p>
          <el-form-item v-else label="送货地址" prop="deliveryAreaName" />
        </td>
        <td colspan="3">
          <p v-if="isEdit==='00'">
            <span>{{ orderInfoBase.deliveryAreaName }}</span><span>{{ orderInfoBase.deliveryAddress }}</span>
          </p>
          <!--地区组件-->
          <el-row v-else :span="24" style="display:flex">
            <!--地区组件-->
            <cascader v-model="orderInfoBase.deliveryAreaName" :region-text="orderInfoBase.deliveryAreaName" style="width: 40%" @regionData="regionData" />
            <el-form-item :inline-message="true" prop="deliveryAddress" style="width:56%;">
              <el-input v-model="orderInfoBase.deliveryAddress" placeholder="请输入详细地址" />
            </el-form-item>
          </el-row>
        </td>
      </tr>
      <tr>
        <td>
          <p v-if="isEdit==='00'">
            是否签合同
          </p>
          <el-form-item v-else label="是否签合同" prop="isPushContract" />
        </td>
        <td colspan="3">
          <p v-if="isEdit==='00'">
            <span v-if="orderInfoBase.isPushContract">{{ orderInfoBase.isPushContract === "01" ? "是" : "否" }}</span>
          </p>
          <p v-else>
            <el-radio v-model="orderInfoBase.isPushContract" label="01">
              是
            </el-radio>
            <el-radio v-model="orderInfoBase.isPushContract" label="00">
              否
            </el-radio>
          </p>
        </td>
      </tr>
    </table>
    <p class="page-title">
      2.订单条款
    </p>
    <table class="from_table mb16">
      <tr class="singleRow">
        <td>
          <el-form-item v-if="isEdit!=='00'" label="订单条款" />
          <p v-else>
            订单条款
          </p>
        </td>
        <td colspan="3">
          <p v-if="isEdit==='00'" v-html="preText(orderInfoBase.orderTerms)" />
          <el-input
            v-else
            v-model="orderInfoBase.orderTerms"
            :autosize="{ minRows: 10, maxRows: 10 }"
            type="textarea"
            maxlength="4000"
            show-word-limit
          />
        </td>
      </tr>
      <tr class="singleRow">
        <td>
          订单条款附件
        </td>
        <td colspan="3">
          <downloadFile v-if="isEdit==='00'" :data="orderTerms" />
          <upload
            v-else
            ref="upload"
            :data="orderTerms"
            :auto-delete="true"
            :auto-upload="true"
            tip-text="上传附件格式（*.doc;*.docx;*.pdf;*.png;*.jpg;*.zip;*.jpeg;*.txt;*.xlsx;*.xls;*.ppt;*.pptx;*.rar）"
            accept=".doc,.docx,.pdf,.png,.jpg,.zip,.jpeg,.txt,.xlsx,.xls,.ppt,.pptx,.rar"
            title=""
            file-ref="fileRef"
          />
        </td>
      </tr>
    </table>
    <p class="page-title">
      3.开票信息
    </p>
    <table class="from_table mb16">
      <tr>
        <td><el-form-item label="开票银行" /></td>
        <td>{{ orderInfoBase.billingBank }}</td>
        <td><el-form-item label="开票账号" /></td>
        <td>{{ orderInfoBase.billingAccountNo }}</td>
      </tr>
      <tr>
        <td><el-form-item label="开票税号" /></td>
        <td>{{ orderInfoBase.billingDutyParagraph }}</td>
        <td><el-form-item label="开票电话" /></td>
        <td>{{ orderInfoBase.billingTel }}</td>
      </tr>
      <tr>
        <td><el-form-item label="开票类型" prop="billingType" /></td>
        <td>
          <el-radio-group v-if="isEdit!=='00'" v-model="orderInfoBase.billingType">
            <el-radio
              v-for="(item) in billingTypeList"
              :key="item.typecode"
              :label="item.typecode"
            >
              {{ item.typename }}
            </el-radio>
          </el-radio-group>
          <p v-else>
            {{ filterDictText(billingTypeList, orderInfoBase.billingType) }}
          </p>
        </td>
        <td />
        <td />
      </tr>
      <tr>
        <td><el-form-item label="开票地址" /></td>
        <td colspan="3">
          {{ orderInfoBase.billingAddress }}
        </td>
      </tr>
      <tr>
        <td><el-form-item label="开票备注" /></td>
        <td colspan="3">
          <p v-if="isEdit==='00'">
            {{ orderInfoBase.billingRemarks }}
          </p>
          <el-input v-else v-model="orderInfoBase.billingRemarks" />
        </td>
      </tr>
    </table>
    <p v-if="roleCode!=='12'" class="page-title">
      4.内部审核意见
    </p>
    <table v-if="roleCode!=='12'" class="tableData mb16">
      <tr class="singleRow">
        <td>意见（内部）</td>
        <td colspan="3">
          <p v-if="isEdit==='00'">
            {{ orderInfoBase.internalOpinion }}
          </p>
          <el-input v-else v-model="orderInfoBase.internalOpinion" />
        </td>
      </tr>
      <tr class="singleRow">
        <td>订单内部审核附件</td>
        <td colspan="3">
          <downloadFile v-if="isEdit==='00'" :data="orderApproval" />
          <upload
            v-else
            ref="upload"
            :data="orderApproval"
            :auto-delete="true"
            :auto-upload="true"
            tip-text="上传附件格式（*.doc;*.docx;*.pdf;*.png;*.jpg;*.zip;*.jpeg;*.txt;*.xlsx;*. xls;*.ppt;*.pptx;*.rar）"
            accept=".doc, .docx, .pdf, .png, .jpg, .zip;.jpeg;.txt;.xlsx;. xls;.ppt;.pptx;.rar"
            title=""
            file-ref="fileRef"
          />
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
/* 公共方法 */
import { filterDictText } from '@/assets/js/utils' // 深拷贝
import { orderManagementGroupMixin } from '../mixins/orderManagementGroupMixins'
import { orderManagementMixins } from '../mixins/orderManagementMixins'

/*  公共组件 */
import cascader from '@comp/common/cascader' // 地区三级联动
import upload from '@comp/common/updownload/upload' // 文件上传组件
import downloadFile from '@comp/common/updownload/downloadFile'

export default {
  name: 'ProcurementOrderBaseCompVue',
  components: {
    upload, // 文件上传
    cascader, // 三级联动组件
    downloadFile // 文件回显
  },
  mixins: [orderManagementGroupMixin, orderManagementMixins],
  props: {
    // 订单基本信息 不可编辑的
    orderInfoBase: {
      type: Object,
      default: function() {
        return {}
      }
    },
    // 区分编辑/查看 00 查看 其他值编辑
    isEdit: {
      type: String,
      default: function() {
        return ''
      }
    },
    // 采购单查看点击事件
    orderProjectClick: {
      type: Function,
      default: function(tenderId) {}
    },
    // 报价单查看点击事件 布尔值
    orderSupplierClick: {
      type: Function,
      default: function() {}
    }
  },
  data() {
    return {
      radioType: false,
      roleCode: '', // 角色编码
      content: '' // 默认条款信息

    }
  },
  created() {
    this.roleCode = this.$store.getters.info.currentRol.roleCode // 角色code
    this.orderTerms.bizId = this.$route.params.orderId // 订单条款附件id
    this.orderApproval.bizId = this.$route.params.orderId // 订单内部审核附件id
    // 查询数据字典
    this.getProcurementOderInfo()
    // 查询订单条款是否存在
  },
  methods: {
    filterDictText,
    // 所在区域三级联动组件使用
    regionData(regionName, location) {
      this.orderInfoBase.deliveryAreaName = regionName
      this.orderInfoBase.deliveryAreaCode = location.join(',')
    },
    // 将文本域的文本进行处理让文本保存换行空格形式，传递给后端
    preText(pretext) {
      return pretext
        .replace(/\r\n/g, '<br />')
    }
  }
}
</script>

<style scoped>

</style>
