zhou zhou
6 天以前 6e042a90361bb68e7a641af3aea30f9bea7716cf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<template>
  <ArtSearchBar
    ref="searchBarRef"
    v-model="formData"
    :items="formItems"
    :showExpand="false"
    @reset="handleReset"
    @search="handleSearch"
  />
</template>
 
<script setup>
  import { createRoleSearchState } from '../rolePage.helpers'
 
  const props = defineProps({
    modelValue: { required: true }
  })
 
  const emit = defineEmits(['update:modelValue', 'search', 'reset'])
  const searchBarRef = ref()
 
  const formData = computed({
    get: () => props.modelValue,
    set: (val) => emit('update:modelValue', val)
  })
 
  const formItems = computed(() => [
    {
      label: '角色名称',
      key: 'name',
      type: 'input',
      props: {
        placeholder: '请输入角色名称',
        clearable: true
      }
    },
    {
      label: '角色编码',
      key: 'code',
      type: 'input',
      props: {
        placeholder: '请输入角色编码',
        clearable: true
      }
    },
    {
      label: '备注',
      key: 'memo',
      type: 'input',
      props: {
        placeholder: '请输入备注',
        clearable: true
      }
    },
    {
      label: '关键字',
      key: 'condition',
      type: 'input',
      props: {
        placeholder: '输入关键字搜索',
        clearable: true
      }
    },
    {
      label: '状态',
      key: 'status',
      type: 'select',
      props: {
        placeholder: '请选择状态',
        clearable: true,
        options: [
          { label: '正常', value: 1 },
          { label: '禁用', value: 0 }
        ]
      }
    }
  ])
 
  function handleReset() {
    emit('update:modelValue', createRoleSearchState())
    emit('reset')
  }
 
  async function handleSearch(params) {
    await searchBarRef.value.validate()
    emit('search', params)
  }
</script>