commonRiskModal.vue 3.11 KB
<template>
  <a-modal title="规则集" :width="900" :centered="false" :visible="visible" @cancel="handleCancel" :confirmLoading="confirmLoading" :footer="null" cancelText="关闭" :maskClosable="false" style="top:40px;" class="scope-link-man">
    <a-card :bordered="false">
      <span style="color:rgba(0,0,0,.85);margin-right:20px;">策略节点</span>
      <a-select v-model="riskNode" placeholder="请选择策略节点" style="width:180px;" @change="selectUserHierarchy">
        <a-select-option v-for="(item, index) in selectData" :key="index" :value="item">
          {{item}}
        </a-select-option>
      </a-select>
    </a-card>
    <a-table ref="table" size="middle" bordered :columns="riskData" :dataSource="dataSource" :pagination="false" :loading="loading" :rowKey="record => record.id" @change="handleTableChange" style="margin-bottom:20px;">
      <!-- 字符串超长截取省略号显示-->
      <span slot="esContent" slot-scope="text">
        <j-ellipsis :value="text" :length="10" />
      </span>
      <span slot="rule" slot-scope="text, record">
        {{record.ruleName}} {{record.judge}} {{record.threshold}}
      </span>
    </a-table>
  </a-modal>

</template>
<script>
import { JeecgListMixin } from '@/mixins/CoreListMixin'
import { deleteCollCusBankAccount } from '@/api/configApi'

export default {
  name: 'commonBankAccountTable',
  mixins: [JeecgListMixin],
  data () {
    return {
      title: '',
      confirmLoading: false,
      visible: false,
      riskNode: '',
      riskData: [
        {
          title: '策略节点',
          align: 'center',
          width: '100px',
          dataIndex: 'nodeName'
        },
        {
          title: '规则',
          dataIndex: 'rule',
          scopedSlots: { customRender: 'rule' },
          align: 'center',
          width: 200,
        },
        {
          title: '取值',
          align: 'center',
          dataIndex: 'ruleValue'
        },
        {
          title: '结果',
          align: 'center',
          dataIndex: 'ruleResult'
        },
      ],
      model: [],
      selectData: [],
      disableMixinCreated: true,
      dataSource: [],
    }
  },
  created () {

  },
  methods: {
    edit (res) {
      this.selectData = []
      // this.objForEach(res.rules)
      // this.keyFindVal()
      this.visible = true
    },
    close () {
      this.$emit('close')
      this.visible = false
    },
    handleCancel () {
      this.close()
    },
    selectUserHierarchy (key) {
      this.riskNode = key
      this.dataSource = []
      this.keyFindVal()
    },
    // 返回数据处理
    objForEach (obj) {
      this.model = []
      Object.keys(obj).forEach((key) => {
        this.model.push(obj[key])
        this.selectData.push(key)
      });
      this.selectData.map(v => {
        this.riskNode = this.selectData[0] // 默认选择第一个
      })

    },
    keyFindVal () {
      this.dataSource = []
      // 根据key找val  
      this.model.map(v => {
        v.map(v1 => {
          if (this.riskNode == v1.nodeName) {
            this.dataSource.push(v1)
          }
        })
      })
    }
  }
}
</script>
<style>
</style>