| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- <template>
- <ArtSearchBar
- ref="searchBarRef"
- v-model="formData"
- :items="formItems"
- :rules="rules"
- :showExpand="false"
- :isExpand="true"
- @reset="handleReset"
- @search="handleSearch"
- >
- </ArtSearchBar>
- </template>
- <script setup lang="ts">
- import { ref, computed, onMounted, h } from 'vue'
- interface Props {
- modelValue: Record<string, any>
- schoolList: Api.Common.SelectRelationInfo[]
- companyList: Api.Common.SelectInfo[],
- userList: Api.Common.SelectInfo[]
- }
- interface Emits {
- (e: 'update:modelValue', value: Record<string, any>): void
- (e: 'search', params: Record<string, any>): void
- (e: 'reset'): void
- }
- const props = defineProps<Props>()
- const emit = defineEmits<Emits>()
- // 表单数据双向绑定
- const searchBarRef = ref()
- const formData = computed({
- get: () => props.modelValue,
- set: (val) => emit('update:modelValue', val)
- })
- // 校验规则
- const rules = {
- // name: [{ required: true, message: '请输入用户名', trigger: 'blur' }]
- }
- const props1 = {
- checkStrictly: true
- }
- // 表单配置
- const formItems = computed(() => [
- {
- label: '食堂名称',
- key: 'name',
- type: 'input',
- placeholder: '请输入食堂名称',
- clearable: true
- },
- {
- label: '餐饮公司',
- key: 'company_id',
- type: 'select',
- filterable: true,
- props: {
- options: props.companyList.map((item) => ({
- label: item.name,
- value: item.id
- }))
- }
- },
- {
- label: '学校',
- key: 'school_id',
- type: 'select',
- props: {
- filterable: true,
- placeholder: '可搜索',
- clearable: true,
- options: props.schoolList.map((item) => ({
- label: item.name,
- value: item.id
- }))
- }
- },
- {
- label: '是否直营',
- key: 'is_direct',
- type: 'select',
- filterable: true,
- props: {
- options: [
- { label: '全部', value: -1 },
- { label: '直营', value: 1 },
- { label: '非直营', value: 0 }
- ]
- }
- },
- {
- label: '手机号',
- key: 'phone',
- type: 'input',
- placeholder: '请输入手机号',
- clearable: true
- },
- {
- label: '最后跟进人',
- key: 'last_user_id',
- type: 'select',
- labelWidth: '90px',
- span:6,
- filterable: true,
- props: {
- emptyValues:[0],
- valueOnClear:0,
- options: props.userList.map((item) => ({
- label: item.name,
- value: item.id
- })),
- },
- },
- {
- label: '最后跟进时间',
- key: 'last_date',
- span:8,
- labelWidth: '100px',
- type: 'datetimerange',
- filterable: true,
- props: {
- type: 'datetimerange',
- valueFormat: 'YYYY-MM-DD HH:mm:ss',
- rangeSeparator: '至',
- startPlaceholder: '开始日期时间',
- endPlaceholder: '结束日期时间'
- }
- },
- ])
- // 事件
- function handleReset() {
- emit('reset')
- }
- async function handleSearch() {
- await searchBarRef.value.validate()
- emit('search', formData.value)
- }
- </script>
|