<template>
  <div class="app-container">
    <!-- 搜索 -->
    <el-form>
      <el-form-item prop="ruleName" label="规范名称">
        <el-input
          v-model="search.ruleName"
          placeholder="请输入规范名称"
          clearable
        />
      </el-form-item>
      <el-form-item prop="ruleTypeId" label="规范类型">
        <el-select
          v-model="search.ruleTypeId"
          url="/dict/find/dict"
          :params="{ dictCode: 'rule_type' }"
          placeholder="请选择规范类型"
        ></el-select>
      </el-form-item>
      <el-form-item prop="orgType" label="受检对象">
        <el-select
          prop="orgType"
          label="受检对象"
          v-model="search.orgType"
          placeholder="请选择受检对象"
          clearable
        >
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
    </el-form>



    <!-- 按钮 -->

      <div style="margin-bottom: 20px;">
        <el-button type="primary" size="mini" @click="onEdit()">新增 </el-button>
      </div>
      <!-- <k-btn-tip type="danger" @click="onDel()" class="ml-2">批量删除</k-btn-tip> -->



      <!--        <el-table-column prop="id" label="序号"></el-table-column>-->
    <el-table>
      <el-table-column type="index" label="序号"></el-table-column>
      <el-table-column prop="ruleName" label="规范名称"></el-table-column>
      <el-table-column prop="ruleTypeName" label="规范类型"></el-table-column>
      <el-table-column prop="orgTypeText" label="受检对象"></el-table-column>
      <el-table-column prop="orgName" label="发布机构"></el-table-column>
      <el-table-column prop="ruleStatus" label="状态">
        <template slot-scope="r">
          <span>{{ r.row.ruleStatus == 0 ? "启用" : "禁用" }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="remark" label="备注"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="r">
          <el-button type="text" @click="onEdit(r.row.id)">编辑 </el-button>
          <k-btn-tip type="text" @click="onDel(r.row.id)">删除 </k-btn-tip>
        </template>
      </el-table-column>
    </el-table>


    <!-- 编辑 -->
    <dialog-edit ref="editDialog" @success="refresh(true)"></dialog-edit>

  </div>
</template>

<script>
import KSearchTable from '../../../components/table/search.table'
import { mapState, mapMutations } from "vuex";
import DialogEdit from "./dialog.edit";

export default {
  name: "ruletype",
  components: {
    KSearchTable,
    DialogEdit,
  },
  data() {
    const { params, query } = this.$route;
    return {
      isShow: false,
      search: {
        ruleName: null,
        ruleTypeId: null,
        orgType: null,
        ...query,
      },
      options: [
        {
          label: "一级分行",
          value: 0,
        },
        {
          value: 1,
          label: "二级分行",
        },
        {
          value: 2,
          label: "一级支行",
        },
        {
          value: 3,
          label: "营业网点",
        },
        {
          value: 4,
          label: "离行自助银行",
        },
        {
          value: 5,
          label: "金库",
        },
        {
          value: 6,
          label: "办公大楼",
        },
        {
          value: 7,
          label: "监控中心",
        },
        {
          value: 8,
          label: "园区",
        },
        {
          value: 9,
          label: "其他",
        },{
          value: 10,
          label: "现金中心",
        },
      ],
    };
  },
  props: {},
  watch: {},
  computed: {
    //...mapState([]),
  },
  methods: {
    //...mapMutations([]),
    refresh(isCurrent) {
      this.$refs.st[isCurrent ? "refresh" : "search"]();
    },

    //
    onEdit(id, other = {}) {
      this.$refs.editDialog.show(id, other);
    },
    async onDel(id) {
      await this.$api.app.delRule(id);
      this.refresh(true);
    },
    //apimark//
  },
  mounted() {},
};
</script>

<style lang="scss">
.brand {
}
</style>
