123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <template>
- <div id="c-search">
- <el-form :inline="true" v-if="fields.length > 0">
- <el-row>
- <el-col :span="6" v-for="i in fields" :key="i.model">
- <el-form-item :label="i.label">
- <template v-if="i.type === 'select'">
- <slot :name="i.model"></slot>
- </template>
- <template v-else>
- <el-input v-model="form[i.model]" :placeholder="`输入${i.label}`"></el-input>
- </template>
- </el-form-item>
- </el-col>
- <el-col :span="24" style="text-align: right">
- <el-button size="mini" type="primary" @click="toSearch">查询</el-button>
- <el-button size="mini" @click="toReset">重置</el-button>
- </el-col>
- </el-row>
- </el-form>
- </div>
- </template>
- <script>
- const _ = require('lodash');
- export default {
- name: 'c-search',
- props: {
- form: { type: Object, default: () => ({}) },
- fields: { type: Array, default: () => [] },
- },
- model: {
- prop: 'form',
- event: 'change',
- },
- data: function () {
- return {};
- },
- methods: {
- toSearch() {
- this.$emit('query');
- },
- toReset() {
- this.form = {};
- this.$emit(query);
- },
- },
- };
- </script>
- <style lang="less" scoped></style>
|