remarkDialog.vue 4.08 KB
<!-- 跟进记录 -->
<template>
  <baseDialog
    :dialog-config="dialogConfig"
    :is-show.sync="dialogShow"
    class="accountDailog"
    @handleClick="handleAddConfirm"
  >
    <div class="reject-dialog">
      <d2-table
        :table-params="tableParams"
        :tableData="infoForm.remarks"
        :hasPage="false"
      >
        <template
          slot="ramark"
          slot-scope="scope"
        >
          <template v-if="isEdit && scope.index == 0">
            <el-input
              v-model="scope.scope.remark"
              type="text"
              placeholder="请输入内容"
              maxlength="15"
              size="small"
            ></el-input>
          </template>
          <template v-else>
            {{ scope.scope.remark || '-'}}
          </template>
        </template>
        <template
          slot="auth-button"
          slot-scope="scope"
        >
          <template v-if="scope.index == 0">
            <template v-if="isEdit">
              <el-button
                type="text"
                size="mini"
                @click="cancel"
              >
                取消
              </el-button>
            </template>
            <template v-else>
              <el-button
                type="text"
                size="mini"
                @click="handleRamrk(scope.scope.remark)"
              >
                编辑备注
              </el-button>
            </template>
          </template>
          <template v-else>
            -
          </template>
        </template>
      </d2-table>
    </div>
  </baseDialog>
</template>

<script>
import { followRecordUpdate } from '@api/invitation'
import { deepClone } from '@/common/util'
import dayjs from "dayjs"
export default {
  name: 'RemarkDialog',
  data () {
    return {
      userInfo: this.$store.state.d2admin.user.info,
      infoForm: {
        remarks: []
      },
      dialogConfig: {
        title: '跟进记录',
        width: '720px'
      },
      originData: '',
      isEdit: false,
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        tableOption: {
          width: '80px'
        },

        tableColumns: [
          {
            label: '跟进时间',
            formatter: (cellValue) => {
              return dayjs(cellValue.updatedDate).format("YYYY-MM-DD HH:mm:ss")
            },
            width: '182',
          }, {
            label: '跟进人',
            prop: "userName",
            width: '80',
          }, {
            label: '事件',
            width: '80',
            formatter: (cellValue) => {
              return {
                1: "车主领券",
                2: "车主预约",
                3: "预约时间",
                4: "修改时间",
                5: "取消预约",
              }[cellValue.eventType] || '-'
            }
          }, {
            label: '备注',
            prop: 'remark',
            addHtml: 'ramark'
          }
        ]
      },
    }
  },

  props: {
    visible: {
      type: Boolean,
      default: false
    },
    paramsObj: {
      type: Object,
      default: {}
    }
  },
  computed: {
    dialogShow: {
      get () {
        return this.visible
      },
      set (newVal) {
        this.$emit('dialogClose', { flag: newVal })
      }
    }
  },

  mounted () {
    this.isEdit = false
    this.originData = ''
    this.infoForm.remarks = deepClone(this.paramsObj.remarks)
  },

  methods: {
    handleRamrk (e) {
      this.originData = e
      this.isEdit = true
    },
    cancel () {
      this.isEdit = false
      this.infoForm.remarks[0].remark = this.originData
    },
    handleAddConfirm () {
      let { remark } = this.infoForm.remarks[0],
        { inviteFollowRecordId } = this.paramsObj,
        params = {
          remark,
          inviteFollowRecordId
        }
      if(!remark) {
        return this.dialogShow = true
      }
      followRecordUpdate(params).then(res => {
        this.notice.okTips('操作成功')
        this.dialogShow = true
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.reject-dialog {
  margin-top: 20px;
}
</style>