commonLinkManTable.vue 5.18 KB
<template>
  <div>
    <a-card title="联系人信息" :bordered="false">
      <a-button v-if="!disableSubmit" style="margin-bottom:10px;float:right;position:relative;z-index:10;" @click="handleAddModal(title)" type="primary" icon="plus">增加联系人</a-button>
      <a-table ref="table" size="middle" bordered :columns="linkManData" :dataSource="collCusContactInfoList" :pagination="false" :loading="loading" :rowKey="record => record.id" @change="handleTableChange">
        <!-- 字符串超长截取省略号显示-->
        <span slot="esContent" slot-scope="text">
          <j-ellipsis :value="text" :length="10" />
        </span>
        <span v-if="!disableSubmit" slot="action" slot-scope="text,record">
          <a @click="handleAddModalEdit(title,record)">修改</a>
          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record)">
            <a>删除</a>
          </a-popconfirm>
        </span>
      </a-table>
    </a-card>
    <person-link-man-modal ref="personLinkManModal" @ok="personLinkManModalOk"></person-link-man-modal>
    <company-link-man-modal ref="companyLinkManModal" @ok="companyLinkManModalOk"></company-link-man-modal>
  </div>
</template>
<script>
import { JeecgListMixin } from '@/mixins/CoreListMixin'
import personLinkManModal from '../person/personLinkManModal'
import companyLinkManModal from '../company/companyLinkManModal'
import { deleteCusContactsInfo } from '@/api/configApi'

export default {
  name: 'commonLinkManTable',
  mixins: [JeecgListMixin],
  components: {
    personLinkManModal, // 个人联系人信息
    companyLinkManModal // 企业联系人信息
  },
  props: {
    userType: {
      type: Number,
      default: ''
    },
    collCusContactInfoList: {
      type: Array,
      default: () => {
        return []
      }
    },
    customerNo: {
      type: String,
      default: ''
    },
    disableSubmit: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      title: '',
      selectTionRelation: JSON.parse(sessionStorage.getItem('SELECTION_RELATION')), // 联系关系
      linkManData: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          align: 'center',
          width: 60,
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '联系人姓名',
          align: 'center',
          width: '100px',
          dataIndex: 'contactsName'
        },
        {
          title: '联系人手机号',
          align: 'center',
          dataIndex: 'mobilePhoneView'
        },
        {
          title: '联系人地址',
          align: 'center',
          dataIndex: 'address'
        },
        {
          title: '与联系人关系',
          align: 'center',
          dataIndex: 'relation',
          customRender: (t, r, index) => {
            for (var i = 0; i < this.selectTionRelation.length; i++) {
              if (t === this.selectTionRelation[i].name) {
                return this.selectTionRelation[i].title
              }
            }
          }
        },
        {
          title: '操作',
          dataIndex: 'action',
          scopedSlots: { customRender: 'action' },
          align: 'center',
          width: 120,
          fixed: 'right'
        }
      ],
      disableMixinCreated: true
    }
  },
  created () {
    switch (this.userType) {
      case 1:
        this.title = '个人联系人信息'
        break
      case 2:
        this.title = '企业联系人信息'
        break
      case 3:
        this.title = '企业法人联系人信息'
        break
    }
  },
  methods: {
    handleAddModal (title) {
      console.log(this.customerNo)
      // if (this.userType == 2) {
      //   this.$refs.companyLinkManModal.add(this.customerNo)
      //   this.$refs.companyLinkManModal.title = title ? title : '新增'
      //   this.$refs.companyLinkManModal.disableSubmit = false
      // } else {
      this.$refs.personLinkManModal.add(this.customerNo)
      this.$refs.personLinkManModal.title = title ? title : '新增'
      this.$refs.personLinkManModal.disableSubmit = false
      // }
    },
    handleAddModalEdit (title, record) {
      // if (this.userType == 2) {
      //   this.$refs.companyLinkManModal.edit(record)
      //   this.$refs.companyLinkManModal.title = title ? title : '修改'
      //   this.$refs.companyLinkManModal.disableSubmit = false
      // } else {
      this.$refs.personLinkManModal.edit(record)
      this.$refs.personLinkManModal.title = title ? title : '修改'
      this.$refs.personLinkManModal.disableSubmit = false
      // }
    },
    handleDelete (record) {
      console.log(record)
      let _p = { id: record.id }
      deleteCusContactsInfo(_p).then(res => {
        if (res.status.statusCode == 0) {
          this.$emit('editReload')
          this.$message.success(res.status.statusReason)
        } else {
          this.$message.warning(res.status.statusReason)
        }
      })
    },
    personLinkManModalOk () {
      this.$emit('editReload')
    },
    companyLinkManModalOk () {
      this.$emit('editReload')
    },
    childMethod () { }
  }
}
</script>
<style>
</style>