baoxian.vue 6.33 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></a>
              <a-button type="link" size="small" icon="delete" style="font-size: 12px">删除</a-button>
            </a-popconfirm>
          </span>
        </a-table>
      </div>
    </a-card>
    <BaoxianModal
      ref="commonBankAccountModal"
      :typeBtn.sync="typeBtn"
      @commonBankAccountModalOk="commonBankAccountModalOk"
    >
    </BaoxianModal>
  </div>
</template>
<script>
import { JeecgListMixin } from '@/mixins/CoreListMixin'
import { delGuaranteeInfoFollow, setGuaranteeInfoFollwStatus } from '@/api/configApi'
import BaoxianModal from './baoxianModal.vue'

export default {
  name: 'Baoxian',
  mixins: [JeecgListMixin],
  components: {
    BaoxianModal,
  },
  props: {
    model: {
      type: Array,
      default: () => {
        return []
      },
    },
    modelList: {
      default: () => {
        return []
      },
    },
    disableSubmit: {
      type: Boolean,
      default: false,
    },
    typeBtn: {
      type: String,
    },
  },
  data() {
    return {
      title: '',
      titleModal: '',
      addList: [],
      xinzeng: {},
      bankData: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          align: 'center',
          width: 60,
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '险种',
          align: 'center',
          width: '100px',
          dataIndex: 'insureClass',
        },
        {
          title: '保单号',
          align: 'center',
          width: '100px',
          dataIndex: 'insureNo',
        },
        {
          title: '投保时间',
          align: 'center',
          dataIndex: 'insureTime',
        },
        {
          title: '期限(月)',
          align: 'center',
          dataIndex: 'insureLimit',
        },
        {
          title: '投保人',
          align: 'center',
          dataIndex: 'insureMan',
        },
        {
          title: '被保险人',
          align: 'center',
          dataIndex: 'quiltInsureMan',
        },
        {
          title: '保额(元)',
          align: 'center',
          dataIndex: 'insureQuota',
          customRender: (t, r, index) => {
            return this.$numMoney(t)
          },
        },
        {
          title: '保费(元)',
          align: 'center',
          dataIndex: 'insureAmount',
          customRender: (t, r, index) => {
            return this.$numMoney(t)
          },
        },
        {
          title: '备注',
          align: 'center',
          dataIndex: 'remark',
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'status',
          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.model
    // ref绑定自定义事件
    this.$refs.commonBankAccountModal.$on('tableList', this.getTableList)
  },
  methods: {
    getTableList(res) {
      console.log(res)
      this.newTable.push(res)
    },
    handleAddModal(title) {
      this.$emit('handleSubmit2')
      this.$refs.commonBankAccountModal.updateBtn = 'add'
      this.$refs.commonBankAccountModal.modelList = this.modelList
      this.$refs.commonBankAccountModal.guaranteeFileIdentifyingCode = []
    },
    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.disableSubmit = false
      this.$refs.commonBankAccountModal.modelList = this.modelList
      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>