<template>
  <div>
    <a-card>
      <sd-data-table-ex
        ref="accesForm"
        form-id="oaAccessIPSetting"
        page-id="securitySetting/oaAccessIPSetting"
        :columns="columns"
        :actions="actions"
        show-selection
        :search-fields="['ruleCode']"
      >
        <template v-slot:form>
          <sd-form-item name="ruleName" component="a-select" @change="onChange"></sd-form-item>
          <sd-form-item name="ruleCode"></sd-form-item>
          <sd-form-item name="ruleType"></sd-form-item>
          <sd-form-item name="startIp"></sd-form-item>
          <sd-form-item name="endIp"></sd-form-item>
          <sd-form-item name="state"></sd-form-item>
          <sd-form-item name="controlDigit" :hidden="true"></sd-form-item>
          <sd-form-item name="id" :hidden="true"></sd-form-item>
        </template>
      </sd-data-table-ex>
    </a-card>
  </div>
</template>

<script>
import TableActionTypes from '@/common/services/table-action-types'
import TableColumnTypes from '@/common/services/table-column-types'
import components from './_import-components/sd-security-acces-import'
export default {
  name: 'SdSecurityAcces',
  metaInfo: {
    title: '安全访问',
  },
  components,
  data() {
    return {
      columns: [
        {
          title: '规则名称',
          dataIndex: 'ruleName',
          sdClickable: true,
        },
        {
          title: '规则编码',
          dataIndex: 'ruleCode',
        },
        {
          title: '规则类型',
          dataIndex: 'ruleType',
        },
        {
          title: '起始IP',
          dataIndex: 'startIp',
        },
        {
          title: '截止IP',
          dataIndex: 'endIp',
        },
        {
          title: '状态', // 0启用 1禁用
          dataIndex: 'state',
          sdRender: TableColumnTypes.ex.switch,
        },
        {
          title: '控制位数',
          dataIndex: 'controlDigit',
        },
      ],
      actions: [
        {
          label: '新建',
          id: 'new',
          type: TableActionTypes.ex.create,
        },
        {
          label: '删除',
          id: 'delete',
          type: TableActionTypes.ex.delete,
        },
      ],
    }
  },
  methods: {
    onChange(code) {
      this.$refs.accesForm.getDetailModal().setFieldValue('ruleCode', code)
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
</style>
