remarkDialog.vue 4.13 KB
<!-- 备注 -->
<template>
  <GLDialog
    bigTitle="备注"
    :visible.sync="dialogShow"
    class="accountDailog"
    width="720px"
    mode="big"
    :close-on-click-modal="false"
    :before-close="handleClose"
    @onOk="handleAddConfirm"
    @onCancel="dialogShow = false"
  >
    <!-- 表格区域 开始 -->
    <GLTable
      :tableData="infoForm.remarks"
      :tableParams="tableParams"
      :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>
    </GLTable>
  </GLDialog>
</template>

<script>
import * as dayjs from 'dayjs'
export default {
  name: 'RemarkDialog',
  data () {
    return {
      infoForm: {
        remarks: []
      },
      dialogConfig: {
        title: '跟进记录',
        width: '720px'
      },
      originData: '',
      isEdit: false,
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableOption: {
          width: '120px'
        },
        tableColumns: [
          {
            label: '跟进时间',
            formatter: (cellValue) => {
              return dayjs(cellValue.updatedDate).format("YYYY-MM-DD HH:mm:ss")
            },
            width: '170',
          }, {
            label: '跟进人',
            prop: "userName",
            width: '80',
          }, {
            label: '事件',
            width: '100',
            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: null
    }
  },
  computed: {
    dialogShow: {
      get () {
        return this.visible
      },
      set (newVal) {
        this.$emit('dialogClose', { flag: newVal })
      }
    }
  },

  mounted () {
    console.log('paramsObj', this.paramsObj)
    this.isEdit = false
    this.originData = ''
    this.infoForm.remarks = this.$common.utils.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
      }
      this.$apis.invitation.followRecordUpdate(params).then(res => {
        this.$notify({
          type: 'success',
          title: '操作成功'
        })
        this.dialogShow = true
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.reject-dialog {
  margin-top: 20px;
}
.default-width {
  width: 400px;
}
</style>