| | |
| | | ref="searchBarRef" |
| | | v-model="formData" |
| | | :items="formItems" |
| | | :rules="rules" |
| | | :showExpand="false" |
| | | @reset="handleReset" |
| | | @search="handleSearch" |
| | | > |
| | | </ArtSearchBar> |
| | | /> |
| | | </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 rules = {} |
| | | const statusOptions = ref([ |
| | | { label: '启用', value: true }, |
| | | { label: '禁用', value: false } |
| | | ]) |
| | | |
| | | const formItems = computed(() => [ |
| | | { |
| | | label: '角色名称', |
| | | key: 'roleName', |
| | | key: 'name', |
| | | type: 'input', |
| | | placeholder: '请输入角色名称', |
| | | clearable: true |
| | | }, |
| | | { |
| | | label: '角色编码', |
| | | key: 'roleCode', |
| | | type: 'input', |
| | | placeholder: '请输入角色编码', |
| | | clearable: true |
| | | }, |
| | | { |
| | | label: '角色描述', |
| | | key: 'description', |
| | | type: 'input', |
| | | placeholder: '请输入角色描述', |
| | | clearable: true |
| | | }, |
| | | { |
| | | label: '角色状态', |
| | | key: 'enabled', |
| | | type: 'select', |
| | | props: { |
| | | placeholder: '请选择状态', |
| | | options: statusOptions.value, |
| | | placeholder: '请输入角色名称', |
| | | clearable: true |
| | | } |
| | | }, |
| | | { |
| | | label: '创建日期', |
| | | key: 'daterange', |
| | | type: 'datetime', |
| | | label: '角色编码', |
| | | key: 'code', |
| | | type: 'input', |
| | | props: { |
| | | style: { width: '100%' }, |
| | | placeholder: '请选择日期范围', |
| | | type: 'daterange', |
| | | rangeSeparator: '至', |
| | | startPlaceholder: '开始日期', |
| | | endPlaceholder: '结束日期', |
| | | valueFormat: 'YYYY-MM-DD', |
| | | shortcuts: [ |
| | | { text: '今日', value: [/* @__PURE__ */ new Date(), /* @__PURE__ */ new Date()] }, |
| | | { text: '最近一周', value: [new Date(Date.now() - 6048e5), /* @__PURE__ */ new Date()] }, |
| | | { text: '最近一个月', value: [new Date(Date.now() - 2592e6), /* @__PURE__ */ new Date()] } |
| | | 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 } |
| | | ] |
| | | } |
| | | } |
| | | ]) |
| | | const handleReset = () => { |
| | | |
| | | function handleReset() { |
| | | emit('update:modelValue', createRoleSearchState()) |
| | | emit('reset') |
| | | } |
| | | const handleSearch = async (params) => { |
| | | |
| | | async function handleSearch(params) { |
| | | await searchBarRef.value.validate() |
| | | emit('search', params) |
| | | } |