<template>
    <div>
        <form-option title="日常检查记录">
            <el-form :inline="true" :model="formData" ref="form" label-width="100px">
                <el-form-item label="" prop="keyword">
                    <el-input v-model="formData.keyword" placeholder="请输入检查单位或人员"></el-input>
                </el-form-item>
                <el-button type="default" icon="el-icon-search" @click="handleQuery">搜索</el-button>
                <el-button size="mini" round icon="el-icon-arrow-left" @click="back">返回</el-button>
            </el-form>
        </form-option>
    </div>
</template>

<script>
import FormOption from '@/component/FormOption'

export default {
    components: {
        FormOption,
    },
    data () {
        return {
            formData: {
                keyword: '',
            }
        }
    },
    mounted () {
    },
    methods: {
        back() {
            this.$router.back()
        },
        resetForm() {
            this.$refs.form.resetFields()
            this.$parent.resetForm()
        },
        handleQuery() {
          let queryString = ""
          let expressions = []
          if (this.formData.keyword) {
            expressions.push("(enforce_obj_name" + "==" + "'*" + this.formData.keyword+ "*',executor_names" + "==" + "'*" + this.formData.keyword+ "*')")
          }
          if (expressions.length !== 0) {
            queryString = expressions.reduce(function(previousValue, currentValue, index, array) {
              return previousValue + ";" + currentValue
            })
          }
          this.$emit('query', queryString)
        }
    }
}
</script>
