explanation.vue 6.73 KB
<template>
  <div>
    <Card title="案件补充说明">
      <div class="explanation">
        <div class="explanation-item" v-for="(item, idx) in supplementListTemp" :key="idx">
          <div class="explanation-list">
            <label class="label" for="">{{ `说明${idx + 1}:` }}</label>
            <el-input :disabled="isCheck || isDisabled || item.operation == 1" :placeholder="`请输入说明${idx + 1}`" v-model="item.content" maxlength="200" type="textarea" :rows="3"></el-input>
            <i class="el-icon-delete del" v-if="!isCheck && supplementListTemp.length > 1 && item.operation != 1" @click="handleDel(idx)"></i>
            <div class="follow-list" @click="showFollow">跟进记录</div>
          </div>
          <div class="operator">
            <div>操作人:{{ item.operationUser ? item.operationUser : '--' }}</div>
            <div>操作时间:{{ item.operationTime ? item.operationTime : '--' }}</div>
          </div>
        </div>
      </div>
      <div v-if="!isCheck && !isDisabled" class="add-explanation" @click="addExplanation">
        <i class="el-icon-circle-plus-outline"></i>
        <span>新增说明</span>
      </div>
    </Card>
    <!-- 跟进记录 -->
    <GLDialog :title="followDialogTitle" mode="mid" :close-on-press-escape="false" :close-on-click-modal="false" :visible.sync="followDialog" bef :okText="followOkText" @onOk="toAddFollw" @onCancel="closeFollow">
      <template v-if="!followEditStatus">
        <div class="wrap_time_line">
          <templatece v-if="!followResult">
            <el-timeline reverse="true">
              <el-timeline-item :class="[{ spec: !index }]" v-for="(item, index) in followListData" :key="index" :timestamp="item.createdDate">
                {{ item.content }}
              </el-timeline-item>
            </el-timeline>
          </templatece>
          <template v-else>
            <div style="margin-top: 60px; text-align: center">暂无跟进记录</div>
          </template>
        </div>
      </template>
      <template v-if="followEditStatus">
        <div class="wrap_time_line">
          <div class="col">
            <div class="label">
              <span style="color: #eb4e4e">*</span>
              <span>具体描述:</span>
            </div>
            <div class="fill">
              <el-input maxlength="200" style="width: 432px" type="textarea" :rows="3" placeholder="请输入" v-model="followContent"></el-input>
            </div>
          </div>
        </div>
      </template>
    </GLDialog>
  </div>
</template>
<script type="text/ecmascript-6">
import Card from './card.vue'
import * as dayjs from 'dayjs'
export default {
  name: 'explanation',
  data() {
    return {
      followDialog: false,
      followListData: [],
      followDialogTitle: '跟进记录',
      followOkText: '新增',
      followEditStatus: false,
      followContent: '',
      followResult: false,
      curentFollowInfo: '',
      supplementListTemp: [{ content: '' }]
    }
  },
  components: {
    Card
  },
  props: {
    supplementList: {
      type: Array,
      default: function () {
        return [{ content: '' }]
      }
    },
    isCheck: Boolean,
    isDisabled: Boolean,
    operatorName: String,
    id: Number
  },
  mounted() {},
  watch: {
    supplementList: {
      deep: true,
      handler(val) {
        this.supplementListTemp = val
        val.forEach(item => {
          item.operationTime = dayjs(item.operationTime).format('YYYY-MM-DD HH:mm:ss')
        })
      },
      immediate: true
    }
  },
  methods: {
    showFollow() {
      this.followDialog = true
      this.curentFollowInfo = {
        id: this.id,
        operatorName: this.operatorName
      }
      this.followListData = []
      this.getFollowList(this.curentFollowInfo)
    },
    closeFollow() {
      if (this.followEditStatus) {
        // 切换
        this.followDialogTitle = '跟进记录'
        this.followEditStatus = false
        this.followOkText = '新增'
      } else {
        // 关闭弹窗
        this.followDialog = false
        this.curentFollowInfo = null
        this.followOkText = '新增'
      }
    },
    toAddFollw() {
      if (!this.followEditStatus) {
        // 切换新增
        this.followDialogTitle = '新增记录'
        this.followOkText = '提交'
        this.followEditStatus = true
      } else {
        // 切换查看
        this.followDialogTitle = '跟进记录'
        this.followOkText = '新增'
        this.followEditStatus = false
        this.createFollow()
      }
    },
    createFollow() {
      let para = {
        claimsId: this.curentFollowInfo.id,
        content: this.followContent,
        createdBy: this.curentFollowInfo.operatorName
      }
      this.$apis.claims.addGHClaimFollowsListApi(para).then(res => {
        this.followDialogTitle = '跟进记录'
        this.followOkText = '新增'
        this.followEditStatus = false
        this.getFollowList(this.curentFollowInfo)
        this.$message({
          message: '新增成功',
          type: 'success'
        })
      })
    },
    getFollowList(row) {
      this.$apis.claims.getGHClaimFollowsListApi({ claimsId: row.id }).then(res => {
        res.forEach(el => {
          el.createdDate = dayjs(el.createdDate).format('YYYY-MM-DD HH:mm:ss')
        })
        this.followListData = res || []
        this.followResult = res.length ? false : true
      })
    },
    handleDel(idx) {
      this.$delete(this.supplementListTemp, idx)
    },
    addExplanation() {
      const idx = this.supplementListTemp.length
      const newObj = { claimsId: this.supplementListTemp[idx - 1].claimsId, content: '' }
      this.$set(this.supplementListTemp, idx, newObj)
    }
  }
}
</script>
<style lang="scss" scoped>
.explanation {
  .explanation-item {
    margin-bottom: 20px;
    &:last-child {
      margin-bottom: 10px;
    }
  }
  .explanation-list {
    position: relative;
    display: flex;
    /deep/ .el-textarea {
      width: 580px;
    }
    .label {
      width: 154px;
      font-size: 14px;
      font-weight: 400;
      line-height: 32px;
      color: #333;
      text-align: right;
      flex-shrink: 0;
    }
  }
  .del {
    color: #c6c6c6;
    font-size: 16px;
    margin-left: 10px;
    cursor: pointer;
    margin-top: 28px;
  }
}

.add-explanation {
  color: #2a58ad;
  display: inline-flex;
  align-items: center;
  margin-left: 154px;
  cursor: pointer;
  .el-icon-circle-plus-outline {
    font-size: 20px;
    margin-right: 6px;
  }
  span {
    font-size: 12px;
  }
}
.operator {
  font-size: 12px;
  color: #666666;
  display: flex;
  justify-content: space-between;
  margin-left: 154px;
  width: 580px;
  margin-top: 4px;
  margin-bottom: 20px;
}
.follow-list {
  font-size: 14px;
  color: #2a58ad;
  bottom: 0;
  position: absolute;
  left: 742px;
  cursor: pointer;
}
</style>