<template>
    <global-page title="筛选">
        <view class="search-form">
            <up-form labelPosition="left" labelWidth="auto" :model="formData" ref="formRef">
                <up-form-item label="任务状态" prop="state" :borderBottom="true">
                    <global-picker
                        v-model="formData.state"
                        pickAlign="right"
                        clearable
                        :options="[
                            { label: 'OPEN', value: '1' },
                            { label: 'CLOSE', value: '2' }
                        ]"
                    ></global-picker>
                </up-form-item>
                <up-form-item label="提出人" prop="presenter" :borderBottom="true">
                    <up-input v-model="formData.presenter" inputAlign="right" border="none" placeholder="请输入" clearable></up-input>
                </up-form-item>
                <up-form-item label="管理席位" prop="seat" :borderBottom="true">
                    <global-picker
                        v-model="formData.seat"
                        pickAlign="right"
                        :options="assignWorkStore.getSeatUnitSelect"
                        clearable
                        filter
                    ></global-picker>
                </up-form-item>
                <up-form-item label="工作类型" prop="workType" :borderBottom="true">
                    <global-picker
                        v-model="formData.workType"
                        pickAlign="right"
                        :options="getParamsByType('LayoutWorkType')"
                        clearable
                    ></global-picker>
                </up-form-item>
                <up-form-item label="开始日期" :borderBottom="true">
                    <global-calendar
                        pickAlign="right"
                        v-model:startTime="formData.startTimeS"
                        v-model:endTime="formData.startTimeE"
                        clearable
                    ></global-calendar>
                </up-form-item>
            </up-form>
        </view>
        <template #bottom>
            <view class="footer-btn">
                <up-row gutter="10">
                    <up-col span="6">
                        <global-button type="primary" plain size="large" :radius="5" @tap="handleReset">重置</global-button>
                    </up-col>
                    <up-col span="6"><global-button type="primary" size="large" :radius="5" @tap="handleConfirm">确定</global-button></up-col>
                </up-row>
            </view>
        </template>
    </global-page>
</template>

<script setup>
import useAssignWorkStore from 'mocp/store/assign-work'
import { storeToRefs } from 'pinia'
import { cloneDeep } from 'lodash'
import { ref } from 'vue'
import { getParamsByType } from 'mocp/hooks/use-params/useParams'

//获取下拉框选项
const assignWorkStore = useAssignWorkStore()
//获取查询表单数据
const { searchData } = storeToRefs(assignWorkStore)
const formData = ref(cloneDeep(searchData.value))
const handleReset = () => {
    assignWorkStore.resetForm()
    uni.$mocpJump.navigateTo('/panel/assign-work/list')
    uni.$emit('assignWorkReload')
}
const handleConfirm = () => {
    assignWorkStore.setState('searchData', formData.value)
    uni.$mocpJump.navigateTo('/panel/assign-work/list')
    uni.$emit('assignWorkReload')
}
</script>
<style lang="scss" scoped>
.search-form {
    padding: 24rpx 24rpx 0 24rpx;
    background: #fff;
}
.footer-btn {
    padding: 24rpx 32rpx;
    background-color: #fff;
}
</style>
