<script setup lang="ts">
import {onMounted, ref} from 'vue';
import { useNaiveForm } from '@/hooks/common/form';
import { $t } from '@/locales';
import { useDict } from '@/hooks/business/dict';
import {fetchGetSubcategorySelect} from "@/service/api/business/subcategory";
defineOptions({
  name: 'DetailEntrySearch'
});

interface Emits {
  (e: 'reset'): void;
  (e: 'search'): void;
}

const emit = defineEmits<Emits>();

const { formRef, validate, restoreValidation } = useNaiveForm();


const model = defineModel<Api.Mps.DetailEntrySearchParams>('model', { required: true });

const { options: mpsCustTypeOptions } = useDict('mps_cust_type');
/** 业务类型选项 */
const subcategoryIdOptions = ref<CommonType.Option<CommonType.IdType>[]>([]);
const {options: mpsCheckStatusOptions} = useDict('mps_check_status');

onMounted(() => {
  getSubcategoryOptions();
});

async function getSubcategoryOptions() {
  const { error, data } = await fetchGetSubcategorySelect();

  if (!error) {
    subcategoryIdOptions.value = data.map(item => ({
      label: item.name,
      value: item.id
    }));
  }
}

async function reset() {
  Object.assign(model.value.params!, {});
  await restoreValidation();
  emit('reset');
}

async function search() {
  await validate();
  emit('search');
}
</script>

<template>
  <NCard :bordered="false" size="small" class="card-wrapper">
    <NCollapse>
      <NCollapseItem :title="$t('common.search')" name="user-search">
        <NForm ref="formRef" :model="model" label-placement="left" :label-width="80">
          <NGrid responsive="screen" item-responsive>
<!--            <NFormItemGi span="24 s:12 m:6" label="业务类型id" path="subcategoryId" class="pr-24px">-->
<!--              <NInput v-model:value="model.subcategoryId" placeholder="请输入业务类型id" />-->
<!--            </NFormItemGi>-->
            <NFormItemGi span="24 s:12 m:6" label="业务名称" path="subcategoryName" class="pr-24px">
<!--              <NInput v-model:value="model.subcategoryName" placeholder="请输入业务类型名称" />-->
                <NSelect
                  v-model:value="model.subcategoryId"
                  filterable
                  placeholder="选择业务类型"
                  :options="subcategoryIdOptions"
                  clearable
                />
            </NFormItemGi>

<!--            <NFormItemGi span="24 s:12 m:6" label="营销人员名称" path="yxName" class="pr-24px">-->
<!--              <NInput v-model:value="model.yxName" placeholder="请输入营销人员名称" />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="经办人员名称" path="jbName" class="pr-24px">-->
<!--              <NInput v-model:value="model.jbName" placeholder="请输入经办人员名称" />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="营销人员营销号" path="yxId" class="pr-24px">-->
<!--              <NInput v-model:value="model.yxId" placeholder="请输入营销人员营销号" />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="经办人员营销号" path="jbId" class="pr-24px">-->
<!--              <NInput v-model:value="model.jbId" placeholder="请输入经办人员营销号" />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="数据日期" path="date" class="pr-24px">-->
<!--              <NDatePicker-->
<!--                v-model:formatted-value="model.date"-->
<!--                type="datetime"-->
<!--                value-format="yyyy-MM-dd HH:mm:ss"-->
<!--                clearable-->
<!--              />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="部门名称" path="deptName" class="pr-24px">-->
<!--              <NInput v-model:value="model.deptName" placeholder="请输入部门名称" />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="部门id" path="deptId" class="pr-24px">-->
<!--              <NInput v-model:value="model.deptId" placeholder="请输入部门id" />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="客户类型（1-个人，2-对公）" path="custType" class="pr-24px">-->
<!--              <NSelect-->
<!--                v-model:value="model.custType"-->
<!--                placeholder="请选择客户类型（1-个人，2-对公）"-->
<!--                :options="mpsCustTypeOptions"-->
<!--                clearable-->
<!--              />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="客户身份证号" path="custId" class="pr-24px">-->
<!--              <NInput v-model:value="model.custId" placeholder="请输入客户身份证号" />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="客户姓名" path="custName" class="pr-24px">-->
<!--              <NInput v-model:value="model.custName" placeholder="请输入客户姓名" />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="客户账号/卡号" path="custAcctNo" class="pr-24px">-->
<!--              <NInput v-model:value="model.custAcctNo" placeholder="请输入客户账号/卡号" />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="客户联系电话" path="custPhoneNo" class="pr-24px">-->
<!--              <NInput v-model:value="model.custPhoneNo" placeholder="请输入客户联系电话" />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="磁条卡更换登记id" path="magneticCardId" class="pr-24px">-->
<!--              <NInput v-model:value="model.magneticCardId" placeholder="请输入磁条卡更换登记id" />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="综合收单商户名" path="acquiringName" class="pr-24px">-->
<!--              <NInput v-model:value="model.acquiringName" placeholder="请输入综合收单商户名" />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="综合收单商户号" path="acquiringId" class="pr-24px">-->
<!--              <NInput v-model:value="model.acquiringId" placeholder="请输入综合收单商户号" />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="网上支付开通渠道" path="internetChannel" class="pr-24px">-->
<!--              <NSelect-->
<!--                v-model:value="model.internetChannel"-->
<!--                placeholder="请选择网上支付开通渠道"-->
<!--                :options="mpsCustTypeOptions"-->
<!--                clearable-->
<!--              />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="交警处罚决定书" path="trafficId" class="pr-24px">-->
<!--              <NInput v-model:value="model.trafficId" placeholder="请输入交警处罚决定书" />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="职工所属单位" path="workplace" class="pr-24px">-->
<!--              <NInput v-model:value="model.workplace" placeholder="请输入职工所属单位" />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="公积金缴纳账户名称" path="surplusAccountName" class="pr-24px">-->
<!--              <NInput v-model:value="model.surplusAccountName" placeholder="请输入公积金缴纳账户名称" />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="取暖费户号" path="heatingNo" class="pr-24px">-->
<!--              <NInput v-model:value="model.heatingNo" placeholder="请输入取暖费户号" />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="核对标志（0未核对 1核对通过 9核对失败）" path="checkFlag" class="pr-24px">-->
<!--              <NInput v-model:value="model.checkFlag" placeholder="请输入核对标志（0未核对 1核对通过 9核对失败）" />-->
<!--            </NFormItemGi>-->
              <NFormItemGi span="24 s:12 m:8" label="核对标志" path="checkFlag" class="pr-24px">
                <NSelect v-model:value="model.checkFlag" :options="mpsCheckStatusOptions" placeholder="请选择核对状态" clearable />
              </NFormItemGi>
<!--            <NFormItemGi span="24 s:12 m:6" label="核对时间" path="checkTime" class="pr-24px">-->
<!--              <NDatePicker-->
<!--                v-model:formatted-value="model.checkTime"-->
<!--                type="datetime"-->
<!--                value-format="yyyy-MM-dd HH:mm:ss"-->
<!--                clearable-->
<!--              />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="核对人员（人工核对时）" path="checkUser" class="pr-24px">-->
<!--              <NInput v-model:value="model.checkUser" placeholder="请输入核对人员（人工核对时）" />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="核对方式（0系统 1人工 2其他1 3其他2 4其他3）" path="checkType" class="pr-24px">-->
<!--              <NSelect-->
<!--                v-model:value="model.checkType"-->
<!--                placeholder="请选择核对方式（0系统 1人工 2其他1 3其他2 4其他3）"-->
<!--                :options="[]"-->
<!--                clearable-->
<!--              />-->
<!--            </NFormItemGi>-->
<!--            <NFormItemGi span="24 s:12 m:6" label="核对结果" path="checkMsg" class="pr-24px">-->
<!--              <NInput v-model:value="model.checkMsg" placeholder="请输入核对结果" />-->
<!--            </NFormItemGi>-->
            <NFormItemGi span="24" class="pr-24px">
              <NSpace class="w-full" justify="end">
                <NButton @click="reset">
                  <template #icon>
                    <SvgIcon local-icon="round-refresh" class="text-icon" />
                  </template>
                  {{ $t('common.reset') }}
                </NButton>
                <NButton type="primary" ghost @click="search">
                  <template #icon>
                    <SvgIcon local-icon="round-search" class="text-icon" />
                  </template>
                  {{ $t('common.search') }}
                </NButton>
              </NSpace>
            </NFormItemGi>
          </NGrid>
        </NForm>
      </NCollapseItem>
    </NCollapse>
  </NCard>
</template>

<style scoped></style>
