danbaoren.vue 6.27 KB
<template>
  <div>
    <a-card :title="title" :bordered="false">
      <a-button
        v-if="!disableSubmit"
        style="margin-bottom: 10px; float: right; position: relative; z-index: 10"
        @click="handleAddModal(titleModal)"
        type="primary"
        icon="plus"
        >新增</a-button
      >
      <div>
        <a-table
          ref="table"
          size="middle"
          bordered
          :columns="bankData"
          :dataSource="newTable"
          :pagination="false"
          :loading="loading"
          :rowKey="(record, index) => index"
          @change="handleTableChange"
        >
          <!-- 字符串超长截取省略号显示-->
          <span slot="esContent" slot-scope="text">
            <j-ellipsis :value="text" :length="10" />
          </span>
          <span slot="actionOpen" slot-scope="text, record">
            <a-switch size="small" :disabled="disableSubmit" :checked="record.status == 1 ? true : false" @change="onChange(record)" />
          </span>
          <span v-if="typeBtn == 'edit'" slot="action" slot-scope="text, record">
            <a-button
              type="link"
              size="small"
              @click="handleAddModalEdit(title, record)"
              icon="edit"
              style="font-size: 12px"
              >修改</a-button
            >
            <a-divider type="vertical" />
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record)">
              <a-button
              type="link"
              size="small"
              icon="delete"
              style="font-size: 12px"
              >删除</a-button
            >
            </a-popconfirm>
          </span>
        </a-table>
      </div>
    </a-card>
    <DanbaorenModal
      ref="commonBankAccountModal"
      :typeBtn.sync="typeBtn"
      @commonBankAccountModalOk="commonBankAccountModalOk"
      @ok="commonBankAccountModalOk"
    >
    </DanbaorenModal>
  </div>
</template>
<script>
import { JeecgListMixin } from '@/mixins/CoreListMixin'
import { delGuaranteeInfoFollow, setGuaranteeInfoFollwStatus,queryGuarantorInfoByName } from '@/api/configApi'
import DanbaorenModal from './danbaorenModal.vue'

export default {
  name: 'Danbaoren',
  mixins: [JeecgListMixin],
  components: {
    DanbaorenModal,
  },
  props: {
    model2: {
      type: Array,
      default: () => {
        return []
      },
    },
    modelList:{
      default: () => {
        return []
      },
    },
    disableSubmit: {
      type: Boolean,
      default: false,
    },
    typeBtn: {
      type: String,
    },
  },
  data() {
    return {
      title: '',
      titleModal: '',
      bankData: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          align: 'center',
          width: 60,
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '担保人类型',
          align: 'center',
          width: '100px',
          dataIndex: 'guaranteeManType',
          customRender: (t, r, index) => {
            if (t == 1) {
              return '个人'
            } else if (t == 2) {
              return '企业'
            }
          },
        },
        {
          title: '担保人名称',
          align: 'center',
          width: '100px',
          dataIndex: 'guaranteeManName',
        },
        {
          title: '担保人证件号',
          align: 'center',
          dataIndex: 'guaranteeIdCardNo',
        },
        {
          title: '担保签约日期',
          align: 'center',
          dataIndex: 'guaranteeTimeContract',
        },
        {
          title: '联系人手机号',
          align: 'center',
          dataIndex: 'guaranteeMobilePhone',
        },
        {
          title: '本次担保金额(元)',
          align: 'center',
          dataIndex: 'guaranteeAmount',
          customRender: (t, r, index) => {
            return this.$numMoney(t)
          },
        },
        {
          title: '备注',
          align: 'center',
          dataIndex: 'remark',
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: '',
          scopedSlots: { customRender: 'actionOpen' },
        },
        {
          title: '操作',
          dataIndex: 'action',
          scopedSlots: { customRender: 'action' },
          align: 'center',
          width: 180,
          fixed: 'right',
        },
      ],
      disableMixinCreated: true,
      newTable: [],
    }
  },
  created() {},
  mounted() {
    this.newTable = []
    this.newTable = this.model2
    // ref绑定自定义事件
    this.$refs.commonBankAccountModal.$on('tableList', this.getTableList)
  },
  methods: {
    handleAddModal(title) {
      this.$emit('handleSubmit2')
      this.$refs.commonBankAccountModal.updateBtn = 'add'
      this.$refs.commonBankAccountModal.modelList = this.modelList
      this.$refs.commonBankAccountModal.guaranteeFileIdentifyingCode = []
    },
    getTableList(res) {
      this.newTable.push(res)
    },
    add(res) {
      console.log(res)
      this.$refs.commonBankAccountModal.add(this.applyNo)
      this.$refs.commonBankAccountModal.title = '新增'
      this.$refs.commonBankAccountModal.disableSubmit = false
      this.$emit('success')
    },
    handleAddModalEdit(title, record) {
      this.$refs.commonBankAccountModal.edit(record)
      this.$refs.commonBankAccountModal.title = '修改'
      this.$refs.commonBankAccountModal.modelList = this.modelList
      this.$refs.commonBankAccountModal.disableSubmit = false
      this.$emit('success')
      this.$refs.commonBankAccountModal.updateBtn = 'edit'
    },
    handleDelete(record) {
      console.log(record)
      let _p = { id: record.id }
      delGuaranteeInfoFollow(_p).then((res) => {
        if (res.status.statusCode == 0) {
          this.$emit('load')
          this.$message.success(res.status.statusReason)
        } else {
          this.$message.warning(res.status.statusReason)
        }
      })
    },
    commonBankAccountModalOk() {
      this.$emit('load')
    },
    onChange: function (v) {
      let _p = {
        id: v.id,
        status: v.status == 1 ? 2 : 1,
      }
      setGuaranteeInfoFollwStatus(_p).then((res) => {
        this.$emit('load')
      })
    },
  },
}
</script>
<style>
</style>