公用的搜索组件


<template>
  <div>
    <el-form inline>
      <el-form-item v-for="item in searchForm" :key="item.prop" :label="item.label">
        <!-- 新建公告 -->
        <el-button
          v-if="item.type==='NewBtn'"
          class="filter-item"
          style="margin-left: 10px;"
          type="primary"
          icon="el-icon-circle-plus-outline"
          @click="handleNew"
        >建立公告</el-button>
        <!-- 新建角色-->
        <el-button
          v-if="item.type==='NewRoleBtn'"
          class="filter-item filter-item-test"
          style="margin-left: 10px;"
          type="primary"
          icon="el-icon-circle-plus-outline"
          @click="handleNewrole"
        >建立角色</el-button>
        <!-- 输入框 -->
        <el-input
          v-if="item.type==='Input'"
          v-model="listQuery.title"
          :placeholder="placeholder"
          style="width: 200px;"
          class="filter-item"
          @keyup.enter.native="handleFilter"
        />

        <!-- 下拉选择器 -->
        <el-select
          v-if="item.type==='select'"
          v-model="listQuery.importance"
          placeholder="请选择"
          clearable
          style="width: 90px"
          class="filter-item"
        >
          <el-option v-for="items in importanceOptions" :key="items" :label="items" :value="items" />
        </el-select>
        <!-- 搜索按钮 -->
        <el-button
          v-if="item.type==='SearchBtn'"
          class="filter-item"
          type="primary"
          icon="el-icon-search"
          @click="handleFilter"
        >搜索</el-button>
        <!-- 导出表格 -->
        <el-button
          v-if="item.type==='downloadBtn'"
          class="filter-item"
          :loading="downloadLoading"
          type="primary"
          icon="el-icon-download"
          @click="handleDownload"
        >导出</el-button>
        <!-- 添加 -->
        <el-button
          v-if="item.type==='addBtn'"
          class="filter-item"
          style="margin-left: 10px;"
          type="primary"
          icon="el-icon-plus"
          @click="handleCreate"
        >添加</el-button>
        <!-- 上传 -->
        <el-button
          v-if="item.type==='UploadBtn'"
          class="filter-item"
          style="margin-left: 10px;"
          type="primary"
          icon="el-icon-upload"
          @click="handleUpload"
        >上传</el-button>
        <!-- 更新 -->
        <el-button
          v-if="item.type==='UpdateBtn'"
          class="filter-item"
          style="margin-left: 10px;"
          type="primary"
          icon="el-icon-refresh"
          @click="handleUpdate"
        >更新</el-button>
        <!-- 审核 -->
        <el-button
          v-if="item.type==='AuditBtn'"
          class="filter-item"
          style="margin-left: 10px;"
          type="primary"
          icon="el-icon-edit"
          @click="handleAudit"
        >审核</el-button>
        <!-- 批量审核 -->
        <el-button
          v-if="item.type==='BatchReviewBtn'"
          class="filter-item"
          style="margin-left: 10px;"
          type="primary"
          icon="el-icon-edit-outline"
          @click="handleBatchReview"
        >批量审核</el-button>
        <!-- 撤销 -->
        <el-button
          v-if="item.type==='BackoutBtn'"
          class="filter-item"
          style="margin-left: 10px;"
          type="primary"
          icon="el-icon-back"
          @click="handleBackout"
        >撤销</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  props: {
    // 所有的搜索组件
    searchForm: {
      type: Array,
      default: () => []
    },
    // 双向数据绑定
    listQuery: {
      type: Object,
      default: () => {}
    },
    // 下拉选择器
    importanceOptions: {
      type: Array,
      default: () => []
    },
    // 下载的加载
    downloadLoading: {
      type: Boolean,
      default: false
    },
    // 输入框的内容
    placeholder: {
      type: String,
      default: ''
    }
  },
  data() {
    return {}
  },
  methods: {
    // 搜索按钮传给父组件
    handleFilter() {
      this.$emit('handleFilter')
    },
    // 导出表格
    handleDownload() {
      this.$emit('handleDownload')
    },
    // 添加
    handleCreate() {
      this.$emit('handleCreate')
    },
    // 新建公告
    handleNew() {
      this.$emit('handleNew')
    },
    // 上传
    handleUpload() {
      this.$emit('handleUpload')
    },
    // 更新
    handleUpdate() {
      this.$emit('handleUpdate')
    },
    // 审核
    handleAudit() {
      this.$emit('handleAudit')
    },
    // 批量审核
    handleBatchReview() {
      this.$emit('handleBatchReview')
    },
    // 撤销
    handleBackout() {
      this.$emit('handleBackout')
    },
    // 新建角色
    handleNewrole() {
      this.$emit('handleNewrole')
    }
  }
}
</script>
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容