<template>
    <dialog-edit :visible.sync="visible"
                 :title="$t('common.lawFirmFeedbackProcessing')"
                 :editModel="'V'"
                 :form="form"
                 :api="api"
                 :footerBtnShow="isFootView"
                 :appendToBody="true"
                 :autoClose="true"
                 @close="closeDialog">
    <!--订单信息-->
        <el-row>
            <payment-info :keyId="assetInfoId" :title="$t('traceMgr.orderInfo')"></payment-info>
        </el-row>
        <el-row class="textRight threeBtn">
            <auth-button type="primary" size="medium" :label="$t('traceMgr.downloadingData')" @click="showBusinessFileDownloadDialog" class="iconfont iconycxiazai"></auth-button>
            <auth-button type="primary" size="medium" :label="$t('common.lawFirmFeedbackProcessingDetails')" @click="getLawView"></auth-button>
            <auth-button type="primary" size="medium" :label="$t('common.save')" @click="saveLawFirm" :loading="isLoading" class="iconfont iconbaocun11"></auth-button>
        </el-row>
        <!--律所反馈-->
        <el-row>
            <el-tabs>
                <el-tab-pane :label="$t('traceMgr.lawFirm')"></el-tab-pane>
            </el-tabs>
        </el-row>
        <!--律所问题列表-->
        <data-table :sourceData.sync="lawFeedbackReviewListDetailsData"
                    :columns="QAColumns"
                    :showSelection="true"
                    :border="true"
                    :stripe="true"
                    operateBtnLayout=""
                    :showPage="false"
                    @selectRowChange="selectionData"
                    :queryParas="searchFormQueryParas" :menuFlag="true">
            <!--反馈-->
            <template slot="feedbackContent" slot-scope="scope">
                <el-input rows="3" type="textarea" v-model="scope.data.row.feedbackContent" maxlegth="50"></el-input>
            </template>
            <!--预计解决时间-->
            <template slot="estimatedFinishTime" slot-scope="scope">
                    <el-date-picker :picker-options="expireTimeOption" v-model="scope.data.row.estimatedFinishTime"></el-date-picker>
            </template>
            <!--操作-->
            <template slot="operate" slot-scope="scope">
                <!--<btn-upload :classType="true" :uploadApi="uploadApi" :rowData="scope.data.row" @uploadFailed="uploadFailed" @uploadSuccess="uploadSuccess"></btn-upload>-->
              <btn-upload v-if="scope.data.row.fileId === '0'" :classType="true" size="small" :uploadApi="uploadApi" :rowData="scope.data.row" @uploadFailed="uploadFailed" @uploadSuccess="uploadSuccess"></btn-upload>
              <btn-upload v-if="scope.data.row.fileId !== '0'" :icon="'iconfont iconzhongxinshangchuan'" :fileID="scope.data.row.fileId" :classType="true" size="small" :uploadApi="uploadApi" :rowData="scope.data.row" @uploadFailed="uploadFailed" @uploadSuccess="uploadSuccess"></btn-upload>
              <btn-download v-if="scope.data.row.fileId !== '0'" :fileID="scope.data.row.fileId"></btn-download>
            </template>
        </data-table>
        <!--联系人-->
        <el-row class="marginBottom2 title" v-if="lawFirmTaskType!==$t('common.theRegionalCommissioner')">
          <el-col v-for="(employeeInfo, index) in employees" :key="index">
            <el-col :span="4" v-if="index === 0">
              <el-col size="3" color="#1e90ff" :span="8">{{$t('traceMgr.contactor')}}：</el-col>
              <el-col size="3" color="#1e90ff" :span="16">{{employeeInfo.employeeName}}</el-col>
              <!--<span size="3" color="#1e90ff">{{$t('traceMgr.contactor')}}：{{employeeInfo.employeeName}}</span>-->
            </el-col>
            <el-col :span="4" v-else>
              <el-col size="3" color="#1e90ff" :span="8">&nbsp;</el-col>
              <el-col size="3" color="#1e90ff" :span="16">{{employeeInfo.employeeName}}</el-col>
            </el-col>

            <el-col :span="4" v-if="index === 0">
              <el-col size="3" color="#1e90ff" :span="8">{{$t('traceMgr.phoneNumber')}}：</el-col>
              <el-col size="3" color="#1e90ff" :span="12">{{employeeInfo.telephone}}</el-col>
              <!--<span size="3" color="#1e90ff">{{$t('traceMgr.phoneNumber')}}：{{employeeInfo.telephone}}</span>-->
            </el-col>
            <el-col :span="4" v-else>
              <el-col size="3" color="#1e90ff" :span="8">&nbsp;</el-col>
              <el-col size="3" color="#1e90ff" :span="12">{{employeeInfo.telephone}}</el-col>
            </el-col>
          </el-col>
        </el-row>
        <!--话术-->
        <el-row class="word_wrap marginBottom6">
          <el-col :span="1" class="text-center">
            <span>{{$t('traceMgr.wordsTechnique')}}</span>
          </el-col>
          <el-col :span="12">
            <!--<speech-craft-input v-model="content"></speech-craft-input>-->
            <speech-craft-input v-model="content" :defaultSpeechFlag="false" @defaultSpeech="setDefaultSpeech"
                                v-loading="contentLoading"
                                :element-loading-text="$t('traceMgr.contentLoading')"
                                element-loading-spinner="el-icon-loading"
                                element-loading-background="rgba(255, 255, 255, 0.7)"></speech-craft-input>
          </el-col>
        </el-row>
        <!--律所反馈处理详情-->
        <dialog-edit :visible.sync="lawBoxVisible"
                     :title="$t('common.lawFirmFeedbackProcessingDetails')"
                     :editModel="'V'"
                     :form="form"
                     :api="api"
                     :appendToBody="true">
            <data-table :sourceData.sync="detailsInfosListData"
                        :columns="detailsInfosColumns"
                        :border="true"
                        :stripe="true"
                        operateBtnLayout=""
                        :showPage="false"
                        :queryParas="searchFormQueryParas"
                        :spanMethod="mergedCell">
                <!--操作-->
                <el-table-column :label="$t('traceMgr.relatedPartyAttachments')" align="center" fixed="right" :width="180">
                    <template  slot-scope="scope">
                        <btn-batch-download v-if="scope.row.fileIds.length > 0" :fileID="scope.row.fileIds"></btn-batch-download>
                    </template>
                </el-table-column>
            </data-table>
        </dialog-edit>
        <!--底部按钮-->
        <div slot="footer" class="dialog-footer">
            <auth-button type="primary" size="medium" :loading="isLoading" :label="$t('common.complete')" @click="submitLawFirm"></auth-button>
            <el-button size="medium" @click="closeDialog">{{$t('common.close')}}</el-button>
        </div>
        <!--弹出资料下载-->
        <business-file-download-dialog
                :visible.sync = "showBusinessFileDownloadDialogValue"
                :form="downloadForm"
        ></business-file-download-dialog>
    </dialog-edit>
</template>
<script>

import tracemgrApi from '@/api/tracemgrApi'
import authcenterApi from '@/api/authcenterApi'
import businessFileDownloadDialog from '@/components/tracemgr/common/businessFileDownloadDialog.vue'
import * as format from '@/filters/index'
import { UPLOAD_API } from '@/constant.js'

import {
  DialogEdit,
  paymentInfo,
  DataTable,
  btnUpload,
  btnDownload,
  speechCraftInput,
  btnBatchDownload,
  dymForm,
  authButton
} from 'newepoch-components'

export default {
  name: 'taskDialog',
  components: {
    DialogEdit,
    authButton,
    paymentInfo,
    dymForm,
    btnUpload,
    btnDownload,
    speechCraftInput,
    btnBatchDownload,
    DataTable,
    tracemgrApi,
    authcenterApi,
    businessFileDownloadDialog,
    format
  },
  props: {
    visible: {
      type: Boolean,
      default: function () {
        return false
      }
    },
    close: {
      type: Function
    },
    taskId: {
      type: String
    },
    assetCode: {
      type: String
    },
    assetInfoId: {
      type: String
    },
    lawFirmTaskType: {
      type: String
    },
    supplierId: {
      type: String
    }
  },
  data () {
    return {
      expireTimeOption: {
        disabledDate (time) {
          return time.getTime() < Date.now() - 8.64e7 // 禁用以前的日期，今天不禁用
        }
      },
      selectedRows: [],
      contentLoading: false,
      initContent: '',
      content: '',
      supplierName: '',
      projectCompanyName: '',
      factorAmount: '',
      feedbackContent: '',
      solution: '',
      feedbackContentAndSolution: '',
      regionAttache: '',
      factorCommissioner: '',
      officePhone: '',
      phone: '',
      constractName: '',
      isLoading: false,
      downloadForm: {
        assetCode: '',
        assetInfoId: ''
      },
      submitData: [],
      //  start 合并单元格变量
      spanArr: [],
      sIdx: 0,
      position: 0,
      sameRowArr: [],
      // end
      employees: [],
      showBusinessFileDownloadDialogValue: false,
      isRecordListVisible: true,
      uploadApi: UPLOAD_API,
      api: {},
      searchFormQueryParas: {},
      feedback: '',
      possibleResolutionTime: '',
      // 律所反馈处理详细数据
      detailsInfosListData: [
      ],
      // 律所反馈列表：明细：数据
      lawFeedbackReviewListDetailsData: [
      ],
      form: {},
      autosize: {
        minRows: 8,
        maxRows: 10
      },
      lawBoxVisible: false,
      dymForm: {
        productType: '',
        productId: ''
      },
      isFootView: false,
      // 律所反馈处理详情
      detailsInfosColumns: [
        {
          // 反馈批次
          prop: 'feedbackFrequency',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.feedbackBatch,
          align: 'center',
          width: 100
        },
        {
          // 律所反馈意见
          prop: 'feedbackQuestionContent',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.lawFirmFeedback,
          align: 'left',
          width: 150
        },
        {
          // 合规处理意见
          prop: 'practicableSuggestion',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.complianceHandlingOpinions,
          align: 'left',
          width: 150
        },
        {
          // 需补资料
          prop: 'supplementNoFile',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.informationNeeded,
          align: 'left',
          width: 120
        },
        {
          // 相关方
          prop: 'relationType',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.interestedParty,
          align: 'center',
          width: 100,
          format: (row) => {
            return format.formatDict(row.relationType === undefined ? '' : row.relationType + '', 'tracemgr_lawfirms_related_part')
          }
        },
        {
          // 处理人
          prop: 'relationChargeUserName',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.handler,
          align: 'center',
          width: 80
        },
        {
          // 处理时间
          prop: 'dealTime',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.processingTime,
          align: 'center',
          width: '80px',
          format: function (row) {
            if (row.dealTime) {
              return row.dealTime.replace(/.[0-9]*$/, '')
            }
          }
        },
        {
          // 处理状态(名称)
          prop: 'relationDealStatus',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.processingStatus,
          align: 'center',
          width: 80,
          format: (row) => {
            return format.formatDict(row.relationDealStatus === undefined ? '' : row.relationDealStatus + '', 'tracemgr_lawfirms_task_status')
          }
        },
        {
          // 相关方意见
          prop: 'relationResolution',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.CommentsFromInterestedParties,
          align: 'left',
          width: 100
        }
      ],
      // 律所反馈列表：主表
      lawFeedbackReviewList: {

      },
      // 律所反馈列表：明细：dataTable列定义
      QAColumns: [
        // 律所反馈意见
        {
          prop: 'lawFeedbackopinion',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.lawFirmFeedback1,
          align: 'left',
          width: 100
        },
        // 合规处理意见
        {
          prop: 'officerFeedbackOpinion',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.complianceHandlingOpinions,
          align: 'left',
          width: 100
        },
        // 需补资料
        {
          prop: 'supplementaryInformation',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.informationNeeded,
          align: 'left',
          width: 100
        },
        // 处理人员
        {
          prop: 'processingPersonnel',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.processingStaff,
          align: 'center',
          width: 80
        },
        // 反馈
        {
          prop: 'feedbackContent',
          label: this.$i18n.messages[this.$i18n.locale].common.feedback,
          align: 'left',
          width: 100,
          slot: true
        },
        // 预计解决时间
        {
          prop: 'estimatedFinishTime',
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.possibleResolutionTime,
          align: 'center',
          width: 100,
          slot: true
        },
        // 操作
        {
          prop: 'operate',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].common.operate,
          align: 'center',
          width: 70,
          slot: true
        },
        // 处理状态
        {
          prop: 'processingStateText',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].traceMgr.processingStatus,
          align: 'center',
          width: '60px',
          format: (row) => {
            return format.formatDict(row.processingStateText, 'tracemgr_bpm_task_status')
          }
        }
      ]
    }
  },
  computed: {
    dialogVisible: {
      get: function () {
        return this.visible
      },
      set: function (val) {
        this.$emit('update:visible', val)
      }
    }
  },
  watch: {
    visible: {
      handler: function (newValue) {
        if (newValue) {
          let $this = this
          // 任务台-任务-律所反馈处理-反馈信息列表
          tracemgrApi['lawFirmProblemList'].getList({ 'assetCode': this.assetCode, 'taskId': this.taskId, 'relationType': this.lawFirmTaskType }).then(res => {
            $this.lawFeedbackReviewListDetailsData = res.data.lawFeedbackList
          })

          this.$nextTick(() => {
            // 获取联系人信息
            tracemgrApi['onlineAuditTaskDialog'].getEmployeeInfos({ 'assetCode': this.assetCode }).then(res => {
              this.employees = res.data
            })
            this.getAssetPaymentInfo()
          })
        }
      }
    },
    lawBoxVisible: {
      handler: function (newValue) {
        if (newValue) {
          let $this = this
          // 任务台-任务-律所反馈处理：律所反馈处理详情
          tracemgrApi['abnormalOrderListApi'].getLawFirmAbnormalListByOrderId({ 'assetCode': this.assetCode }).then(res => {
            if (res.data) {
              let data = res.data
              let arr = []
              for (let i = 0; i < data.length; i++) {
                let feedbackFrequency = data[i].feedbackFrequency
                let feedbackQuestionContent = data[i].feedbackQuestionContent
                for (let j = 0; j < data[i].relationHistoryRelationDtos.length; j++) {
                  data[i].relationHistoryRelationDtos[j].feedbackFrequency = feedbackFrequency
                  data[i].relationHistoryRelationDtos[j].feedbackQuestionContent = feedbackQuestionContent
                  arr.push(data[i].relationHistoryRelationDtos[j])
                }
              }
              $this.detailsInfosListData = arr
              this.spanArr = []
              this.sameRowArr = []
            }
          })
        }
      }
    }
  },
  methods: {
    stringReplace (str, replaceParam1) {
      return str.replace('{0}', replaceParam1)
    },
    getLawView () {
      this.lawBoxVisible = true
    },
    uploadSuccess (returnData, rowData) {
      this.success(this.$i18n.messages[this.$i18n.locale].traceMgr.file + returnData.fileName + this.$i18n.messages[this.$i18n.locale].common.uploadSuccess)
      rowData.fileId = returnData.fileID
      rowData.fileName = returnData.fileName
    },
    uploadFailed: function (a, b, c) {
      this.error(this.$i18n.messages[this.$i18n.locale].traceMgr.fileEorro)
    },
    showBusinessFileDownloadDialog () {
      this.downloadForm.assetCode = this.assetCode
      this.downloadForm.assetInfoId = this.assetInfoId
      this.showBusinessFileDownloadDialogValue = true
    },
    businessFileDownloadDialogClose () {
      this.showBusinessFileDownloadDialogValue = false
    },
    // 保存数据
    saveLawFirm () {
      let data = {}
      if (this.lawFeedbackReviewListDetailsData !== null && this.lawFeedbackReviewListDetailsData.length > 0) {
        for (let i = 0; i < this.lawFeedbackReviewListDetailsData.length; i++) {
          if (this.lawFeedbackReviewListDetailsData[i].fileId !== '0' && this.lawFeedbackReviewListDetailsData[i].fileId !== undefined) {
            let fileInfo = {}
            let fileInfoList = []
            fileInfo.fileId = this.lawFeedbackReviewListDetailsData[i].fileId
            fileInfo.fileName = this.lawFeedbackReviewListDetailsData[i].fileName
            fileInfoList.push(fileInfo)
            this.lawFeedbackReviewListDetailsData[i].fileList = JSON.stringify(fileInfoList)
          }
        }
        data['lawFeedbackListJsonString'] = JSON.stringify(this.lawFeedbackReviewListDetailsData)
        tracemgrApi['taskDialog'].save(data).then(res => {
          this.isLoading = false

          if (res.data === true) {
            this.success(this.$i18n.messages[this.$i18n.locale].common.saveSuccess)
          } else {
            this.error(this.$i18n.messages[this.$i18n.locale].traceMgr.saveError)
          }
        }, res => {
          this.error(this.$i18n.messages[this.$i18n.locale].traceMgr.saveError)
          this.isLoading = false
        })
      } else {
        this.isLoading = false
        this.error(this.$i18n.messages[this.$i18n.locale].traceMgr.noSaveData)
      }
    },
    selectionData (value) {
      this.selectedRows = value
    },
    submitLawFirm () {
      if (this.lawFeedbackReviewListDetailsData !== null && this.lawFeedbackReviewListDetailsData.length > 0) {
        // 验证提交数据
        let selectedRows = this.selectedRows
        this.submitData = []
        if (selectedRows.length > 0) {
          for (let i = 0; i < selectedRows.length; i++) {
            // 反馈意见
            if (selectedRows[i].feedbackContent === null || selectedRows[i].feedbackContent === undefined || selectedRows[i].feedbackContent.trim() === '') {
              //  附件
              if (selectedRows[i].fileId === null || selectedRows[i].fileId === undefined || selectedRows[i].fileId === '0') {
                this.$message({
                  message: this.stringReplace(this.$i18n.messages[this.$i18n.locale].traceMgr.pleaseInput, (i + 1)),
                  type: 'error'
                })
                return
              }
            }

            let data = {}
            let fileInfo = {}
            let fileInfoList = []
            fileInfo.fileId = selectedRows[i].fileId
            fileInfo.fileName = selectedRows[i].fileName
            fileInfoList.push(fileInfo)
            data['feedbackTaskDetailId'] = selectedRows[i].otLawfirmFeedbackTaskDetailId
            data['estimateSupplementTime'] = selectedRows[i].estimatedFinishTime
            data['relationResolution'] = selectedRows[i].feedbackContent
            data['taskId'] = selectedRows[i].taskInfoId
            data['assetInfoId'] = selectedRows[i].assetInfoId
            if (selectedRows[i].fileId !== '0') {
              data['fileList'] = JSON.stringify(fileInfoList)
            }
            data['modifyTime'] = selectedRows[i].modifyTime
            data['status'] = selectedRows[i].processingStateText
            data['type'] = this.lawFirmTaskType
            data['keyId'] = selectedRows[i].keyId
            this.submitData.push(data)
          }

          // 确认是否提交
          this.$confirm(this.$i18n.messages[this.$i18n.locale].common.submitConfirm, this.$i18n.messages[this.$i18n.locale].common.tip, {
            confirmButtonText: this.$i18n.messages[this.$i18n.locale].traceMgr.sure,
            cancelButtonText: this.$i18n.messages[this.$i18n.locale].traceMgr.cancel,
            type: 'warning'
          }).then(() => {
            // 确认提交
            this.isLoading = true
            // 先保存
            // for (let i = 0; i < this.lawFeedbackReviewListDetailsData.length; i++) {
            //   if (this.lawFeedbackReviewListDetailsData[i].fileId !== '0' && this.lawFeedbackReviewListDetailsData[i].fileId !== undefined) {
            //     let fileInfo = {}
            //     let fileInfoList = []
            //     fileInfo.fileId = this.lawFeedbackReviewListDetailsData[i].fileId
            //     fileInfo.fileName = this.lawFeedbackReviewListDetailsData[i].fileName
            //     fileInfoList.push(fileInfo)
            //     this.lawFeedbackReviewListDetailsData[i].fileList = JSON.stringify(fileInfoList)
            //   }
            // }
            // let data = {}
            // data['lawFeedbackListJsonString'] = JSON.stringify(this.lawFeedbackReviewListDetailsData)
            // tracemgrApi['taskDialog'].save(data).then(res => {
            //   if (res.data === true) {
            //
            //   } else {
            //     this.isLoading = false
            //     this.error(this.$i18n.messages[this.$i18n.locale].traceMgr.submitFailed)
            //   }
            // }, res => {
            //   this.error(this.$i18n.messages[this.$i18n.locale].traceMgr.submitFailed)
            //   this.isLoading = false
            // })
            // 提交
            tracemgrApi['taskDialog'].submit(this.submitData).then(res => {
              // 隐藏加载
              this.isLoading = false

              if (res.data === true) {
                this.success(this.$i18n.messages[this.$i18n.locale].traceMgr.submitSuccess)
                this.closeDialog()
              } else {
                this.error(this.$i18n.messages[this.$i18n.locale].traceMgr.submitFailed)
              }
            }, res => {
              this.error(this.$i18n.messages[this.$i18n.locale].traceMgr.submitFailed)
              this.isLoading = false
            })
          })
        } else {
          this.$message({
            message: this.$i18n.messages[this.$i18n.locale].traceMgr.selectMessage,
            type: 'error'
          })
        }
      } else {
        this.error(this.$i18n.messages[this.$i18n.locale].traceMgr.noSubmit)
      }
    },
    // 合并Grid列
    mergedCell: function ({ row, column, rowIndex, columnIndex }) {
      if (this.spanArr.length === 0) {
        this.getSpanArr()
      }
      if (this.spanArr.length === 0) {
        this.getSpanArr()
      }
      if (columnIndex === 0) { // 对第一列进行合并
        const _row = this.spanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      }
      if (columnIndex === 1) { // 对第二列进行合并
        const _row = this.spanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      }
    },
    getSpanArr () {
      this.spanArr = [] // 避免表格错乱！
      let $this = this
      this.sIdx = 0
      this.detailsInfosListData.forEach((item, index) => {
        item.index = index
        if (index === 0) {
          $this.spanArr.push(1)
          $this.position = 0
          $this.sameRowArr.push([index])
        } else {
          if ($this.detailsInfosListData[index].feedbackFrequency === $this.detailsInfosListData[index - 1].feedbackFrequency &&
            $this.detailsInfosListData[index].feedbackQuestionContent === $this.detailsInfosListData[index - 1].feedbackQuestionContent) { // 这里是要合并行
            $this.spanArr[this.position] += 1
            $this.spanArr.push(0)
            $this.sameRowArr[$this.sIdx].push(index)
          } else {
            $this.spanArr.push(1)
            $this.position = index
            $this.sIdx += 1
            $this.sameRowArr.push([index])
          }
        }
      })
    },
    closeDialog () {
      this.dialogVisible = false
      this.$parent.handleFilter()
    },
    getAssetPaymentInfo () {
      this.contentLoading = true
      // 话术
      tracemgrApi['onlineAuditTaskDialog'].getOrderInfo(this.assetInfoId).then(res => {
        // 供应商名称
        this.supplierName = res.data.assetPaymentInfoDTO.creditor
        // 项目公司名称
        this.projectCompanyName = res.data.assetPaymentInfoDTO.debtor
        // 保理金额
        this.factorAmount = res.data.assetPaymentInfoDTO.factoringMoney
        // 合同名称
        this.constractName = res.data.assetPaymentInfoDTO.bussContractName

        this.getSpeechCraftInfo()
      }).catch(res => {
        this.content = this.$i18n.messages[this.$i18n.locale].traceMgr.noneData
        this.contentLoading = false
      })
    },
    getSpeechCraftInfo () {
      // 获取话术信息:区域专员、电话、手机号
      tracemgrApi['fileList'].getSpeechCraftInfo({ 'assetId': this.assetInfoId }).then(res => {
        if (this.lawFirmTaskType === this.$i18n.messages[this.$i18n.locale].common.theRegionalCommissioner) {
          // 区域专员
          this.regionAttache = res.data.regionalCommissioner
          // 座机
          this.officePhone = res.data.regionalTelephone
          // 手机
          this.phone = res.data.regionalPhoneNumber
        } else {
          // 保理专员
          this.factorCommissioner = res.data.factoringCommissioner
          // 座机
          this.officePhone = res.data.factoringTelephone
          // 手机
          this.phone = res.data.factoringPhoneNumber
        }
        this.getContent()
      }).catch(res => {
        this.content = this.$i18n.messages[this.$i18n.locale].traceMgr.noneData
        this.contentLoading = false
      })
    },
    getContent () {
      // 反馈意见和解决办法
      this.feedbackContentAndSolution = ''
      for (let i = 0; i < this.lawFeedbackReviewListDetailsData.length; i++) {
        if (this.lawFirmTaskType === this.$i18n.messages[this.$i18n.locale].common.theRegionalCommissioner) {
          this.feedbackContentAndSolution = this.feedbackContentAndSolution + this.$i18n.messages[this.$i18n.locale].traceMgr.contentMessage18 + this.lawFeedbackReviewListDetailsData[i].lawFeedbackopinion +
        '\n' + this.$i18n.messages[this.$i18n.locale].traceMgr.abnormalHandleSeven + this.lawFeedbackReviewListDetailsData[i].officerFeedbackOpinion + '\n'
        } else {
          this.feedbackContentAndSolution = this.feedbackContentAndSolution + (i + 1) + '.' + this.lawFeedbackReviewListDetailsData[i].officerFeedbackOpinion + '\n'
        }
      }

      if (this.assetCode === undefined) {
        this.assetCode = ''
      }

      if (this.lawFirmTaskType === this.$i18n.messages[this.$i18n.locale].common.theRegionalCommissioner) {
        // 区域专员
        this.content = this.$i18n.messages[this.$i18n.locale].traceMgr.contentMessage10 + this.assetCode + ' ' +
      this.$i18n.messages[this.$i18n.locale].traceMgr.generateMassfive + this.supplierName + ' ' +
      this.$i18n.messages[this.$i18n.locale].traceMgr.generateMasssix + this.projectCompanyName + ' ' +
      this.$i18n.messages[this.$i18n.locale].traceMgr.fileListThere + parseFloat(this.factorAmount).toFixed(2) +
      this.$i18n.messages[this.$i18n.locale].traceMgr.contentMessage19 +
      this.feedbackContentAndSolution +
      this.$i18n.messages[this.$i18n.locale].traceMgr.contentMessage20 +
      '\n' +
      this.$i18n.messages[this.$i18n.locale].traceMgr.contentMessage7 + this.regionAttache + '\n' +
      this.$i18n.messages[this.$i18n.locale].traceMgr.contentMessage8 + this.officePhone + '\n' +
      this.$i18n.messages[this.$i18n.locale].traceMgr.contentMessage9 + this.phone
      } else {
        // 保理专员
        this.content = this.$i18n.messages[this.$i18n.locale].traceMgr.contentMessage10 + this.assetCode + ' ' +
      this.$i18n.messages[this.$i18n.locale].traceMgr.fileListTwo + this.constractName + ' ' +
      this.$i18n.messages[this.$i18n.locale].traceMgr.fileListThere + parseFloat(this.factorAmount).toFixed(2) +
      this.$i18n.messages[this.$i18n.locale].traceMgr.contentMessage21 +
      this.feedbackContentAndSolution + '\n' +
      '\n' +
      this.$i18n.messages[this.$i18n.locale].traceMgr.contentMessage22 +
      '\n' +
      this.$i18n.messages[this.$i18n.locale].traceMgr.contentMessage17 + this.factorCommissioner + '\n' +
      this.$i18n.messages[this.$i18n.locale].traceMgr.contentMessage8 + this.officePhone + '\n' +
      this.$i18n.messages[this.$i18n.locale].traceMgr.contentMessage9 + this.phone
      }

      this.initContent = JSON.parse(JSON.stringify(this.content))
      this.contentLoading = false
    },
    setDefaultSpeech () {
      this.content = this.initContent
    }
  },
  // 初始化加载
  mounted () {
  }
}
</script>

<style scoped lang="scss">
    @import '~@/styles/tracemgr/factoringCommissioner/taskTable/lawFirm/taskDialog.scss';
</style>
