commonAttachmentTable.vue 4.21 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="attachmentData" :rowKey="(record, index) => index" :dataSource="saveOrUpdateCusExtAttachmentList" :pagination="false" :loading="loading" @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="handleAttachmentLook(record)">查看</a>
          <a-divider type="vertical" />
          <a @click="handleAttachmentEdit(record)">修改</a>
          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record)">
            <a>删除</a>
          </a-popconfirm>
        </span>
      </a-table>
    </a-card>
    <common-attachment-modal ref="commonAttachmentModal" @ok="commonAttachmentModalOk"></common-attachment-modal>
  </div>
</template>

<script>
import { JeecgListMixin } from '@/mixins/CoreListMixin'
import commonAttachmentModal from './commonAttachmentModal'
import { deleteCusExtAttachment } from '@/api/configApi'

export default {
  name: 'personAttachmentTable',
  mixins: [JeecgListMixin],
  components: {
    commonAttachmentModal
  },
  props: {
    userType: {
      type: Number,
      default: null,
    },
    saveOrUpdateCusExtAttachmentList: {
      type: Array,
      default: () => {
        return [];
      }
    },
    applyNo: {
      type: String,
      default: ''
    },
    disableSubmit: {
      type: Boolean,
      default: false
    },
  },
  data () {
    return {
      title: '',
      attachmentData: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '资料名称',
          align: 'center',
          width: '100px',
          dataIndex: 'name'
        },
        {
          title: '备注',
          align: 'center',
          dataIndex: 'remark'
        },
        {
          title: '操作',
          dataIndex: 'action',
          scopedSlots: { customRender: 'action' },
          align: 'center',
          width: 150,
          fixed: 'right'
        }
      ],
      disableMixinCreated: true,
    }
  },
  created () {
    console.log(this.userType)
    switch (this.userType) {
      case 1:
        this.title = '个人自定义附件上传'
        break;
      case 2:
        this.title = '企业自定义附件上传'
        break;
      case 3:
        this.title = '企业法人自定义附件上传'
        break;
    }
  },
  methods: {
    handleAddModal (title) {
      this.$refs.commonAttachmentModal.add(this.applyNo)
      this.$refs.commonAttachmentModal.title = title ? title : '新增'
      this.$refs.commonAttachmentModal.disableSubmit = false
    },
    // 自定义附件信息查看
    handleAttachmentLook (record) {
      this.$refs.commonAttachmentModal.edit(record)
      this.$refs.commonAttachmentModal.title = '查看'
      this.$refs.commonAttachmentModal.disableSubmit = true
      this.$refs.commonAttachmentModal.onlyread = true
    },
    // 自定义附件信息修改
    handleAttachmentEdit (record) {
      this.$refs.commonAttachmentModal.edit(record)
      this.$refs.commonAttachmentModal.title = '修改'
      this.$refs.commonAttachmentModal.disableSubmit = false
    },
    handleDelete (record) {
      console.log(record)
      let _p = { 'id': record.id }
      deleteCusExtAttachment(_p).then(res => {
        if (res.status.statusCode == 0) {
          this.$emit('editReload');
          this.$message.success(res.status.statusReason)
        } else {
          this.$message.warning(res.status.statusReason)
        }
      })
    },
    commonAttachmentModalOk () {
      this.$emit('editReload');
    },
  }
}
</script>
<style>
</style>