index.vue 3.88 KB
<template>
  <GLDialog :destroy-on-close="isdestroy" :close-on-click-modal="false" title="跟进人配置" mode="mid" :visible.sync="isFollowSync" :before-close="handleCancel">
    <GLTable :hasPage="false" :hasNum="true" :tableData="followListData" :tableParams="followTableParams">
      <div slot="followName" slot-scope="scope">
        <el-form v-if="scope.scope.followName == ''">
          <el-form-item style="margin-bottom: 0px">
            <el-input v-model="followName" placeholder="请输入" maxlength="5"></el-input>
          </el-form-item>
        </el-form>

        <span v-else>{{ scope.scope.followName }}</span>
      </div>
      <div class="table-btns" slot="table-btns" slot-scope="scope">
        <el-button type="text" size="small" @click="handleDelete(scope.scope, scope.index)">删除</el-button>
      </div>
    </GLTable>
    <div class="add-wrap" @click="addLine">
      <i class="el-icon-circle-plus-outline add-icon"></i>
      添加
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button size="small" @click="handleCancel">取消</el-button>
      <el-button type="primary" size="small" @click="handleSave">确定</el-button>
    </span>
  </GLDialog>
</template>
<script>
export default {
  data() {
    return {
      isdestroy: true,
      followListData: [],
      followName: '',
      followTableParams: {
        listName: 'list',
        tableOption: false,
        tableColumns: [
          {
            label: '跟进人',
            prop: 'followName',
            addHtml: 'followName'
          },
          {
            label: '操作',
            prop: '',
            width: 80,
            fixed: 'right',
            addHtml: 'table-btns'
          }
        ]
      }
    }
  },
  props: {
    isFollowSync: {
      type: Boolean,
      default: false
    }
  },
  created() {
    this.getFollowPersonList()
  },
  methods: {
    getFollowPersonList() {
      this.$apis.claims
        .getFollowPersonList({
          pageSize: 10000,
          pageNum: 1
        })
        .then(res => {
          this.followListData = res.list
        })
    },
    addLine() {
      if (this.followListData.length > 0 && this.followListData[this.followListData.length - 1].followName == '') {
        return
      }
      this.followName = ''
      this.followListData.push({ followName: '' })
    },
    handleSave() {
      if (this.followListData[this.followListData.length - 1].followName == '' && this.followName == '') {
        this.$message({
          type: 'error',
          message: '请输入跟进人'
        })
        return
      }
      if (this.followName) {
        this.$apis.claims.addFollowPerson({ followName: this.followName }).then(res => {
          this.$message({
            type: 'success',
            message: '添加成功!'
          })
        })
      }
      this.$emit('handleClose')
    },
    handleCancel() {
      //   this.isFollowSync = false
      this.$emit('handleClose')
    },
    handleCalculate() {},
    //删除
    handleDelete(data, index) {
      if (data.id) {
        this.$confirm('确定要删除吗, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(() => {
            if (data.id) {
              this.$apis.claims.delFollowPerson({ id: data.id }).then(res => {})
              this.followListData.splice(index, 1)
            }
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            })
          })
      } else {
        this.followListData.splice(index, 1)
      }
    }
  }
}
</script>
<style scoped lang="scss">
.add-wrap {
  display: flex;
  align-items: center;
  font-size: 12px;
  color: #2a58ad;
  margin-top: 10px;
  cursor: pointer;
  .add-icon {
    margin-right: 6px;
    font-size: 20px;
    color: #2a58ad;
  }
}
</style>