<!-- 商机-详情 -->
<template>
  <div class="md-content">
    <el-row type="flex" justify="space-between">
      <el-col :span="6">
        <el-button size="small" @click="handleBack">返回</el-button>
      </el-col>
      <el-form ref="form" :model="form.basic">
        <el-col :span="10">
          <el-input v-model="form.basic.boName" placeholder="商机名称" :disabled="true"/>
        </el-col>
        <el-col :span="6">
          <el-select v-model="form.basic.boState" placeholder="商机状态" :disabled="true">
                <el-option
                  v-for="dict in dict.type.mk_bo_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
          </el-select>
        </el-col>
        <el-col :span="6">
          <el-select v-model="form.basic.winningState" placeholder="赢丢单状态" :disabled="true">
                <el-option
                  v-for="dict in dict.type.mk_bo_winstate"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
          </el-select>
        </el-col>
      </el-form>
      <el-button-group>
        <el-col :span="6">
          <el-button size="small" icon="el-icon-d-arrow-left" ></el-button>
        </el-col>
        <el-col :span="6">
          <el-button size="small" icon="el-icon-arrow-left" ></el-button>
        </el-col>
        <el-col :span="6">
          <el-button size="small" icon="el-icon-arrow-right" ></el-button>
        </el-col>
        <el-col :span="6">
          <el-button size="small" icon="el-icon-d-arrow-right" ></el-button>
        </el-col>
      </el-button-group>
    </el-row>

    <el-tabs v-model="masterTabs" @tab-click="masterTabsSwitch">
      <el-tab-pane label="基本信息" name="first">
        项目流程
        <el-steps :active="form.basic.boStage" finish-status="success">
          <el-step title="审核"></el-step>
          <el-step title="立项"></el-step>
          <el-step title="考察"></el-step>
          <el-step title="开院务会"></el-step>
          <el-step title="院内立项"></el-step>
          <el-step title="调研"></el-step>
          <el-step title="解决方案"></el-step>
          <el-step title="签合同"></el-step>
          <el-step title="进场实施"></el-step>
          <el-step title="落地方案"></el-step>
          <el-step title="实施交付"></el-step>
          <el-step title="上线仪式"></el-step>
        </el-steps>
        <el-button style="margin-top: 12px;" @click="next">下一步</el-button>
        <el-row>
          基本信息
        </el-row>
        <el-form ref="form" :model="form.basic" label-width="80px">
          <el-row>
            <el-col :span="8">
              <el-form-item label="商机来源" prop="boSource">
                <el-select v-model="form.basic.boSource" placeholder="商机来源" :disabled="true">
                  <el-option
                    v-for="dict in dict.type.mk_bo_source"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="商机类型" prop="boType">
                <el-select v-model="form.basic.boType" placeholder="商机类型" :disabled="true">
                  <el-option
                    v-for="dict in dict.type.mk_bo_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="客户名称" prop="customerName">
                <el-input v-model="form.basic.customerName" placeholder="请输入客户名称" :disabled="true"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="医院营收总额" prop="totalHosRevenue">
                <el-input v-model="form.basic.totalHosRevenue" placeholder="请输入医院营收总额" :disabled="true"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="医院耗材预估值" prop="hosDiscreetValue">
                <el-input v-model="form.basic.hosDiscreetValue" placeholder="请输入医院耗材预估值" :disabled="true"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="赢单率" prop="abc">
                <el-input v-model="form.basic.abc" placeholder="赢单率" :disabled="true"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-form-item label="商机内容" prop="boContent">
                <el-input v-model="form.basic.boContent" placeholder="商机内容" :disabled="true"/>
              </el-form-item>
          </el-row>
        </el-form>
        <el-row>
          流程信息
        </el-row>
        <el-tabs v-model="secondTabs" @tab-click="secondTabsSwitch">
          <el-tab-pane label="阶段动作" name="jd1" style="height: 150px;overflow-y: scroll;" v-if="form.basic.boStage == 0">
            <el-form ref="form" :model="form.basic" :rules="rules">
              <el-row>
                <el-col :span="10">
                  <el-form-item label="医院应收总额" prop="totalHosRevenue">
                    <el-input v-model="form.basic.totalHosRevenue" placeholder="医院应收总额" :disabled="true"/>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="10">
                  <el-form-item label="医院耗材预估额" prop="hosDiscreetValue">
                    <el-input v-model="form.basic.hosDiscreetValue" placeholder="医院耗材预估额" :disabled="true"/>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </el-tab-pane>
          <el-tab-pane label="阶段动作" name="jd2" style="height: 150px;overflow-y: scroll;" v-if="form.basic.boStage == 1">
            <el-form ref="form" :model="form.basic.boFlow" :rules="rules">
              <el-row>
                项目立项是否通过
                <el-radio v-model = form.basic.boFlow.projectApproval label="1">是</el-radio>
                <el-radio v-model = form.basic.boFlow.projectApproval label="0">否</el-radio>
              </el-row>
              <el-row v-if="form.basic.boFlow.projectApproval == 1">
                <el-col :span="1.5">
                  <el-input v-model="form.basic.boFlow.businessCouncilAccessoryName" placeholder="请上传商机审议会" :disabled="true"/>
                </el-col>
                <el-col :span="1.5">
                  <el-button
                    type="info"
                    plain
                    icon="el-icon-upload2"
                    size="mini"
                    @click="uploadAccessory(`business_council_accessory`)"
                    v-hasPermi="['system:user:import']"
                  >上传</el-button>
                  <el-button
                    size="mini"
                    type="text"
                    icon="el-icon-delete"
                    @click="deleteAccessory(`business_council_accessory`,1)"
                    v-hasPermi="['system:basic:remove']"
                  >删除</el-button>
                </el-col>
              </el-row>
              <el-row v-if="form.basic.boFlow.projectApproval == 1">
                <el-col :span="1.5">
                  <el-input v-model="form.basic.boFlow.projectProposalAccessoryName" placeholder="请上传立项书" :disabled="true"/>
                </el-col>
                <el-col :span="1.5">
                  <el-button
                    type="info"
                    plain
                    icon="el-icon-upload2"
                    size="mini"
                    @click="uploadAccessory(`project_proposal_accessory`)"
                    v-hasPermi="['system:user:import']"
                  >上传</el-button>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="10" v-if="form.basic.boFlow.projectApproval == 0">
                    项目未通过原因：<el-input v-model="form.basic.boFlow.noPassCause" />
                </el-col>
              </el-row>
            </el-form>
          </el-tab-pane>
          <el-tab-pane label="立项模板" name="lx" style="height: 150px;overflow-y: scroll;" v-if="form.basic.boStage == 1">
            <el-row>
              <el-button @click="pojproDownload">标准立项书</el-button>
            </el-row>
            <el-row>
              <el-button @click="pojproDownload">商机审会决议书</el-button>
            </el-row>
          </el-tab-pane>
          <el-tab-pane label="项目人员组成" name="xmry" style="height: 150px;overflow-y: scroll;" v-if="form.basic.boStage == 1">
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button
                  type="primary"
                  plain
                  icon="el-icon-plus"
                  size="mini"
                  @click="handleAdd"
                  v-hasPermi="['drp-business:task:add']"
                >新增</el-button>
              </el-col>
            </el-row>
            <el-table v-loading="loading" :data="form.pojpsn">
              <el-table-column type="selection" width="55" align="center" />
              <el-table-column label="名称" align="center" prop="staffName" />
              <el-table-column label="岗位名称" align="center" prop="pojpost" />
              <el-table-column label="负责事项" align="center" prop="duty" />
            </el-table>
          </el-tab-pane>
          <el-tab-pane label="方案模板" name="fa" style="height: 150px;overflow-y: scroll;" v-if="form.basic.boStage == 6">
            <el-row>
              <el-button @click="pojproDownload">售前提案文件模板</el-button>
            </el-row>
            <el-row>
              <el-button @click="pojproDownload">考察报告模板</el-button>
            </el-row>
            <el-row>
              <el-button @click="pojproDownload">调研相关文件模板</el-button>
            </el-row>
            <el-row>
              <el-button @click="pojproDownload">投标模板</el-button>
            </el-row>
            <el-row>
              <el-button @click="pojproDownload">其他文件</el-button>
            </el-row>
          </el-tab-pane>
          <el-tab-pane label="售前提案" name="sq" style="height: 150px;overflow-y: scroll;" v-if="form.basic.boStage == 6">
            <el-form ref="form" :model="form.basic.boFlow" :rules="rules">
              <el-row>
                <el-col :span="1.5">
                  <el-input v-model="form.basic.boFlow.preSaleProposalAccessoryName" placeholder="请上传售前提案文件" :disabled="true"/>
                </el-col>
                <el-col :span="1.5">
                  <el-button
                    type="info"
                    plain
                    icon="el-icon-upload2"
                    size="mini"
                    @click="uploadAccessory(`pre_sale_proposal_accessory`)"
                    v-hasPermi="['system:user:import']"
                  >上传</el-button>
                </el-col>
              </el-row>
            </el-form>
          </el-tab-pane>
          <el-tab-pane label="邀请考察" name="kc" style="height: 150px;overflow-y: scroll;" v-if="form.basic.boStage == 6">
            <el-form ref="form" :model="form.basic.boFlow" :rules="rules">
              <el-row>
                <el-col :span="5">
                  <el-form-item label="考察开始时间" prop="inspectStartTime">
                    <el-date-picker
                      v-model="form.basic.boFlow.inspectStartTime"
                      type="datetime"
                      placeholder="选择日期时间">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="5">
                  <el-form-item label="考察结束时间" prop="inspectStartTime">
                    <el-date-picker
                      v-model="form.basic.boFlow.inspectEndTime"
                      type="datetime"
                      placeholder="选择日期时间">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="1.5">
                  <el-input v-model="form.basic.boFlow.investigationReportAccessoryName" placeholder="请上传考察报告" :disabled="true"/>
                </el-col>
                <el-col :span="1.5">
                  <el-button
                    type="info"
                    plain
                    icon="el-icon-upload2"
                    size="mini"
                    @click="uploadAccessory(`investigation_report_accessory`)"
                    v-hasPermi="['system:user:import']"
                  >上传</el-button>
                </el-col>
              </el-row>
            </el-form>
          </el-tab-pane>
          <el-tab-pane label="开院务会" name="kh" style="height: 150px;overflow-y: scroll;" v-if="form.basic.boStage == 6">
            <el-form ref="form" :model="form.basic.boFlow" :rules="rules">
              <el-row>
                <el-col :span="5">
                  <el-form-item label="开院务会时间" prop="conferenceTime">
                    <el-date-picker
                      v-model="form.basic.boFlow.conferenceTime"
                      type="datetime"
                      placeholder="选择日期时间">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </el-tab-pane>
          <el-tab-pane label="院内立项" name="yn" style="height: 150px;overflow-y: scroll;" v-if="form.basic.boStage == 6">
            <el-form ref="form" :model="form.basic.boFlow" :rules="rules">
              <el-row>
                <el-col :span="5">
                  <el-form-item label="院内立项时间" prop="hospitalApprovalTime">
                    <el-date-picker
                      v-model="form.basic.boFlow.conferenceTime"
                      type="datetime"
                      placeholder="选择日期时间">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="5">
                  <el-form-item label="院内立项牵头人" prop="hospitalApprovalInitiator">
                    <el-input v-model="form.basic.boFlow.hospitalApprovalInitiator" placeholder="院内立项牵头人" />
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </el-tab-pane>
          <el-tab-pane label="进场调研" name="jc" style="height: 150px;overflow-y: scroll;" v-if="form.basic.boStage == 6">
            <el-form ref="form" :model="form.basic.boFlow" :rules="rules">
              <el-row>
                <el-col :span="5">
                  <el-form-item label="调研时间" prop="researchTime">
                    <el-date-picker
                      v-model="form.basic.boFlow.researchTime"
                      type="datetime"
                      placeholder="选择日期时间">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="1.5">
                  <el-input v-model="form.basic.boFlow.investigateReportAccessoryName" placeholder="调研报告" :disabled="true"/>
                </el-col>
                <el-col :span="1.5">
                  <el-button
                    type="info"
                    plain
                    icon="el-icon-upload2"
                    size="mini"
                    @click="uploadAccessory(`investigation_report_accessory`)"
                    v-hasPermi="['system:user:import']"
                  >上传</el-button>
                </el-col>
              </el-row>
            </el-form>
          </el-tab-pane>
          <el-tab-pane label="挂网投标" name="gw" style="height: 150px;overflow-y: scroll;" v-if="form.basic.boStage == 7">
            <el-form ref="form" :model="form.basic.boFlow" :rules="rules">
              <el-row>
                <el-col :span="5">
                  <el-form-item label="挂网时间" prop="researchTime">
                    <el-date-picker
                      v-model="form.basic.boFlow.hangingTime"
                      type="datetime"
                      placeholder="选择日期时间">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="5">
                  <el-form-item label="投标书" prop="researchTime">
                    <el-input v-model="form.basic.boFlow.biddingDocumentsAccessoryName" placeholder="请上传投标书" :disabled="true"/>
                  </el-form-item>
                </el-col>
                <el-col :span="5">
                  <el-button
                    type="info"
                    plain
                    icon="el-icon-upload2"
                    size="mini"
                    @click="uploadAccessory(`bidding_documents_accessory`)"
                    v-hasPermi="['system:user:import']"
                  >上传</el-button>
                </el-col>
                <el-col :span="5">
                  <el-form-item label="我方优势" prop="researchTime">
                    <el-input v-model="form.ourAdvantage" placeholder="我方优势" />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="5">
                  投标是否通过
                  <el-radio v-model = form.basic.boFlow.biddingDocumentsPass label="1">是</el-radio>
                  <el-radio v-model = form.basic.boFlow.biddingDocumentsPass label="0">否</el-radio>
                </el-col>
              </el-row>
              <el-row v-if="form.basic.boFlow.biddingDocumentsPass == 1">
                <el-col :span="1.5">
                  <el-input v-model="form.basic.boFlow.letterAcceptanceAccessoryName" placeholder="中标通知书" :disabled="true"/>
                </el-col>
                <el-col :span="1.5">
                  <el-button
                    type="info"
                    plain
                    icon="el-icon-upload2"
                    size="mini"
                    @click="uploadAccessory(`letter_acceptance_accessory`)"
                    v-hasPermi="['system:user:import']"
                  >上传</el-button>
                </el-col>
              </el-row>
            </el-form>
          </el-tab-pane>
          <el-tab-pane label="合同签订" name="ht" style="height: 150px;overflow-y: scroll;" v-if="form.basic.boStage == 7">
            <el-form ref="form" :model="form.basic.boFlow" :rules="rules">
              <el-row>
                <el-col :span="5">
                  <el-form-item label="合同签订时间" prop="contractSigningTime">
                    <el-date-picker
                      v-model="form.basic.boFlow.contractSigningTime"
                      type="datetime"
                      placeholder="选择日期时间">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="5">
                  <el-input v-model="form.basic.boFlow.contractDocumentAccessoryName" placeholder="合同文件" :disabled="true"/>
                </el-col>
                <el-col :span="5">
                  <el-button
                    type="info"
                    plain
                    icon="el-icon-upload2"
                    size="mini"
                    @click="uploadAccessory(`contract_document_accessory`)"
                    v-hasPermi="['system:user:import']"
                  >上传</el-button>
                </el-col>
              </el-row>
            </el-form>
          </el-tab-pane>
          <el-tab-pane label="跟进记录" name="gj" style="height: 150px;overflow-y: scroll;" v-if="form.basic.boStage == 0 || form.basic.boStage == 1 || form.basic.boStage == 6 || form.basic.boStage == 7">
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button
                  type="primary"
                  plain
                  icon="el-icon-plus"
                  size="mini"
                  @click="handleAdd"
                  v-hasPermi="['drp-business:task:add']"
                >新增</el-button>
              </el-col>
            </el-row>
            <el-table v-loading="loading" :data="form.behavior">
              <el-table-column type="selection" width="55" align="center" />
              <el-table-column label="跟进人" align="center" prop="code" />
              <el-table-column label="跟进日期" align="center" prop="name" />
              <el-table-column label="是否跟进" align="center" prop="type" />
              <el-table-column label="联系人" align="center" prop="type" />
              <el-table-column label="拜访效果" align="center" prop="type" />
              <el-table-column label="是否需要上级协助" align="center" prop="type" />
              <el-table-column label="协助事项" align="center" prop="type" />
              <el-table-column label="跟进内容" align="center" prop="type" />
            </el-table>
          </el-tab-pane>
        </el-tabs>
        <el-row>
          其它信息
        </el-row>
        <el-form ref="form" :model="form.basic" label-width="80px">
          <el-row>
            <el-col :span="8">
              <el-form-item label="销售组织" prop="marketingOrganizing">
                <el-input v-model="form.basic.marketingOrganizing" placeholder="销售组织" :disabled="true"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="销售区域" prop="marketingArea">
                <el-input v-model="form.basic.marketingArea" placeholder="销售区域" :disabled="true"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="部门" prop="deptName">
                <el-input v-model="form.basic.deptName" placeholder="部门" :disabled="true"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="负责人" prop="principal">
                <el-input v-model="form.basic.principal" placeholder="负责人" :disabled="true"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="创建人" prop="createBy">
                <el-input v-model="form.basic.createBy" placeholder="创建人" :disabled="true"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="创建时间" prop="createTime">
                <el-input v-model="form.basic.createTime" placeholder="创建时间" :disabled="true"/>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>

      </el-tab-pane>
      <el-tab-pane label="商机任务" name="second">
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="el-icon-plus"
              size="mini"
              @click="handleAdd"
              v-hasPermi="['drp-business:task:add']"
            >新增</el-button>
          </el-col>
        </el-row>
        <el-table v-loading="loading" :data="form.task">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="任务编码" align="center" prop="code" />
          <el-table-column label="任务名称" align="center" prop="name" />
          <el-table-column label="任务类型" align="center" prop="type" />
          <el-table-column label="任务状态" align="center" prop="state" />
          <el-table-column label="客户名称" align="center" prop="customerName" />
          <el-table-column label="联系人名称" align="center" prop="linkmanName" />
          <el-table-column label="销售组织名称" align="center" prop="salesOrgName" />
          <el-table-column label="部门名称" align="center" prop="deptName" />
          <el-table-column label="负责人名称" align="center" prop="staffName" />
          <el-table-column label="截止时间" align="center" prop="deadlineDate" width="180">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.deadlineDate, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="任务内容" align="center" prop="content" />
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="商机联系人" name="third">
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="el-icon-plus"
              size="mini"
              @click="handleAdd"
              v-hasPermi="['drp-business:task:add']"
            >新增</el-button>
          </el-col>
        </el-row>
        <el-table v-loading="loading" :data="form.contact">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="名称" align="center" prop="code" />
          <el-table-column label="性别" align="center" prop="name" />
          <el-table-column label="联系电话" align="center" prop="type" />
          <el-table-column label="部门" align="center" prop="state" />
          <el-table-column label="职务" align="center" prop="customerName" />
          <el-table-column label="决策力" align="center" prop="linkmanName" />
          <el-table-column label="态度" align="center" prop="salesOrgName" />
          <el-table-column label="地址" align="center" prop="deptName" />
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="附件信息" name="fourth">
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="info"
              plain
              icon="el-icon-upload2"
              size="mini"
              @click="uploadAccessory(`list`)"
              v-hasPermi="['system:user:import']"
            >上传</el-button>
          </el-col>
        </el-row>
        <el-table v-loading="loading" :data="form.accessory">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column type="index" label="序号" width="55" align="center" />
          <el-table-column label="名称" align="center" prop="fileName" />
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="deleteAccessory(`list`,scope.row)"
                v-hasPermi="['system:basic:remove']"
              >删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
    </el-tabs>

    <!-- 上传对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls,.doc,docx"
        :headers="upload.headers"
        :action="upload.url + '?boId=' + form.basic.id + '&flag=' + upload.flag"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>

</template>

<script>
import {getBasic,getBehaviorList,delAccessory} from "@/api/business/spd/bo/basic";
import { listTask, getTask, delTask, addTask, updateTask } from "@/api/business/spd/bo/task";
import { listAccessory, } from "@/api/business/spd/bo/accessory";
import {listPojpsn} from "@/api/business/spd/bo/pojpsn";
import { getToken } from "@/utils/auth";

export default {
  name: 'bo-details',
  dicts: ['mk_bo_type','mk_bo_state','mk_bo_winstate','mk_bo_source'],
  data() {
      return {
        masterTabs: 'first',
        secondTabs: 'jd1',
        // 基本信息
        form: {
          basic:{
            boFlow:{}
          },
          task:[],
          contact:[],
          accessory:[],
          pojpsn:[],
          behavior:[],
          pojpsn:[],
        },
        // 上传参数
        upload: {
          // 是否显示弹出层
          open: false,
          // 弹出层标题
          title: "",
          // 是否禁用上传
          isUploading: false,
          // 上传类型
          flag: "",
          // 设置上传的请求头部
          headers: { Authorization: "Bearer " + getToken() },
          // 上传的地址
          url: process.env.VUE_APP_BASE_API + "/mk/bo/basic/upload"
        },
      }
  },
  methods: {
    // 返回
    handleBack() {
      this.$router.push('/business/spd/bo/basic');
    },
    //主多页签切换
    masterTabsSwitch(e) {
        console.log('主标签页切换',e);
        switch(e.name) {
          case 'second':
              //获取商机任务
              const p = {"bo": this.form.basic.id};
              listTask(p).then(response => {
                this.form.task = response.rows;
              });
              break;
          case 'third':
              //获取联系人
              break;
          case 'fourth':
              //获取附件列表
              listAccessory(this.form.basic.id).then(response => {
                this.form.accessory = response.rows;
              });
              break;
          default:
              break;
        }
    },
    //次多页签切换
    secondTabsSwitch(e) {
        console.log('次标签页切换',e);
        switch(e.name) {
          case 'gj':
              //获取跟进记录
              getBehaviorList(this.form.basic.id).then(response => {
                this.form.behavior = response.rows;
              });
              break;
          case 'xmry':
              //获取成员
              const p = {"bo": this.form.basic.id};
              listPojpsn(p).then(response => {
                this.form.pojpsn = response.rows;
              });
              break;
          default:
              break;
        }
    },
    //下一步
    next() {
        if(this.form.basic.boStage == 1){
          this.form.basic.boStage += 5;
        }else if(this.form.basic.boStage == 7){
          this.form.basic.boStage += 5;
        }else{
          this.form.basic.boStage++;
        }
      },
    //测试
    handleAdd(){

    },
    //上传附件公共方法
    uploadAccessory(f) {
      // this.upload.title = "上传附件";
      this.upload.open = true;
      this.upload.flag = f;
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    //删除附件
    deleteAccessory(f,row){
      // console.log("flag",f);
      // console.log("row",row);
      // delAccessory(this.form.basic.id,f,row.id);
      this.$modal.confirm('是否确认删除？').then(function() {
        return delAccessory(this.form.basic.id,f,row.id);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },

    //立项书下载
    //标准立项书
    pojproDownload(){

    },
    //商机审会决议书
    pojproDownload1(){

    },
  },
  created() {
    console.log("详情id:",this.$route.params.id);
    getBasic(this.$route.params.id).then(response => {
      this.form.basic = response.data;
    });
  },
}
</script>


<style scoped>
.md-content>>>.el-form-item {
  margin-bottom: 10px;
}

.md-content>>>.el-tabs--border-card>.el-tabs__content {
  padding-bottom: 8px;
}

.md-content .md-auditInfo>>>.el-form-item {
  margin-bottom: 0px;
}

.md-main>>>.el-form-item,
.md-vice>>>.el-form-item {
  width: 100%;
  box-sizing: border-box;
}

.md-main>>>.el-form-item__label,
.md-vice>>>.el-form-item__label {
  width: 40%;
}

.md-main>>>.el-form-item__content,
.md-md-vice>>>.el-form-item__content {
  width: 60%;
}

.md-content>>>.el-form-item__label {
  font-weight: normal;
  /* text-align: left;
  width: 28%; */
  white-space: nowrap;
  /* IE6 需要定义宽度 */
  overflow: hidden;

  -o-text-overflow: ellipsis;
  /* Opera */
  text-overflow: ellipsis;
  /* IE, Safari (WebKit) */
  /* -moz-binding: url('ellipsis.xml#ellipsis'); */
  /* Firefox */
}

.md-main>>>.material-table {
  height: 100%;
}

.md-vice>>>.material-table {
  height: 140px;
  overflow-y: auto;
  overflow-x: auto;
}
</style>
