search.vue 2.48 KB
Newer Older
yanzhongrong's avatar
yanzhongrong committed
1 2 3 4
<template>
  <div>
    <el-form class="search-form" :model="form" ref="form" label-width="80px" :inline="true" size="mini">
      <el-form-item label="操作对象" >
yanzhongrong's avatar
yanzhongrong committed
5 6 7 8 9
        <el-select v-model="form.operateObj" placeholder="请选择操作对象" clearable >
          <el-option v-for="item in operatObj"
            :key="item.dictValue"
            :label="item.dictValue"
            :value="+item.dictValue1">
yanzhongrong's avatar
yanzhongrong committed
10 11 12 13
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="操作内容">
yanzhongrong's avatar
yanzhongrong committed
14 15 16 17 18 19 20
        <el-select v-model="form.operateContent" placeholder="请选择操作内容" clearable >
          <el-option v-for="item in operatContent"
            :key="item.dictValue"
            :label="item.dictValue"
            :value="item.dictValue1">
          </el-option>
        </el-select>
yanzhongrong's avatar
yanzhongrong committed
21 22
      </el-form-item>
      <el-form-item label="操作结果">
yanzhongrong's avatar
yanzhongrong committed
23 24
        <el-select v-model="form.operateResult" placeholder="请选择操作结果" clearable >
          <el-option v-for="(val, key) in resultEnum"
yanzhongrong's avatar
yanzhongrong committed
25 26
            :key="val"
            :label="val"
yanzhongrong's avatar
yanzhongrong committed
27
            :value="+key">
yanzhongrong's avatar
yanzhongrong committed
28 29 30 31 32 33 34 35 36 37 38 39
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="success"  @click="toSearch">查询</el-button>
        <el-button type="primary"  @click="reset">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
yanzhongrong's avatar
yanzhongrong committed
40
import { selectDictType } from '@/api/baseData'
yanzhongrong's avatar
yanzhongrong committed
41 42 43 44
export default {
  name: 'search',
  data() {
    return {
yanzhongrong's avatar
yanzhongrong committed
45 46 47 48 49 50
      operatContent: [],
      operatObj: [],
      resultEnum: {
        0: '失败',
        1: '成功',
      },
yanzhongrong's avatar
yanzhongrong committed
51 52 53 54 55
      form: formInit()
    }
  },
  computed: {
  },
yanzhongrong's avatar
yanzhongrong committed
56 57 58
  mounted() {
    this.getInit()
  },
yanzhongrong's avatar
yanzhongrong committed
59 60 61 62 63 64
  methods: {
    toSearch() {
      this.$emit('search', this.form)
    },
    reset() {
      this.form = formInit()
yanzhongrong's avatar
yanzhongrong committed
65
      this.$emit('search')
yanzhongrong's avatar
yanzhongrong committed
66 67 68 69 70 71 72 73 74 75
    },
    getInit() {
      selectDictType({dictType: '06'}).then(res => {
        let list = res || []
        this.operatContent = list
      })
      selectDictType({dictType: '07'}).then(res => {
        let list = res || []
        this.operatObj = list
      })
yanzhongrong's avatar
yanzhongrong committed
76 77 78 79 80 81
    }
  }
}

function formInit() {
  return {
yanzhongrong's avatar
yanzhongrong committed
82 83 84
    operateContent: '',
    operateObj: null,
    operateResult: null,
yanzhongrong's avatar
yanzhongrong committed
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
  }
}
</script>
<style scoped lang="scss">
.w200 {
  width: 200px;
}
.search-form {
  padding: 10px;
  background-color: #EAF1FE;
  margin-bottom: 20px;
  border-radius: 8px;
  .el-form-item--mini.el-form-item, .el-form-item--small.el-form-item {
    margin-bottom: 0;
  }
}
</style>