广丰卷烟厂数采质量分析系统
zhuguifei
2026-03-02 80ff784bf60637cd348ae665fc907f7b1e527dd8
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#set($ModuleName=$moduleName.substring(0, 1).toUpperCase() + $moduleName.substring(1))
<script setup lang="ts">
import { toRaw } from 'vue';
import { jsonClone } from '@sa/utils';
import { useNaiveForm } from '@/hooks/common/form';
import { $t } from '@/locales';
 
defineOptions({
  name: '${BusinessName}Search'
});
 
interface Emits {
  (e: 'search'): void;
}
 
const emit = defineEmits<Emits>();
 
const { formRef, validate, restoreValidation } = useNaiveForm();
 
#foreach ($column in $columns)
    #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
        #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
const dateRange${AttrName} = ref<[string, string] | null>(null);
#end#end
const model = defineModel<Api.$ModuleName.${BusinessName}SearchParams>('model', { required: true });
 
const defaultModel = jsonClone(toRaw(model.value));
 
function resetModel() {
  #foreach ($column in $columns)
    #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
        #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
  dateRange${AttrName}.value = null;
    #end
#end
  Object.assign(model.value, defaultModel);
}
 
async function reset() {
  await restoreValidation();
  resetModel();
  emit('search');
}
 
async function search() {
  await validate();
#foreach ($column in $columns)
    #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
        #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
  if (dateRange${AttrName}.value?.length) {
    model.value.params!.begin${AttrName} = dateRange${AttrName}.value[0];
    model.value.params!.end${AttrName} = dateRange${AttrName}.value[1];
  }
    #end
#end
  emit('search');
}
</script>
 
<template>
  <NCard :bordered="false" size="small" class="card-wrapper">
    <NCollapse>
      <NCollapseItem :title="$t('common.search')" name="$moduleName-${business__name}-search">
        <NForm ref="formRef" :model="model" label-placement="left" :label-width="80">
          <NGrid responsive="screen" item-responsive>
#set($immediateDictList = [])
#foreach($column in $columns)
#if($column.query)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
            <NFormItemGi span="24 s:12 m:6" label="$column.columnComment" label-width="auto" path="$column.javaField" class="pr-24px">
            #if($!StrUtil.contains("select, radio, checkbox", $column.htmlType) && $column.dictType)
              <DictSelect
                v-model:value="model.$column.javaField"
                placeholder="请选择$column.columnComment"
                dict-code="$column.dictType"
                clearable
#if(!$column.isList() && !$immediateDictList.contains($column.dictType))#set($void = $immediateDictList.add($column.dictType))
                immediate
#end
              />
            #elseif($!StrUtil.contains("select, radio, checkbox", $column.htmlType))
              <NSelect
                v-model:value="model.$column.javaField"
                placeholder="请选择$column.columnComment"
                :options="[]"
                clearable
              />
            #elseif($column.htmlType == 'datetime' && $column.queryType != "BETWEEN")
              <NDatePicker
                v-model:formatted-value="model.$column.javaField"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
                clearable
              />
            #elseif($column.htmlType == 'datetime' && $column.queryType == "BETWEEN")
              <NDatePicker
                v-model:formatted-value="dateRange${AttrName}"
                type="datetimerange"
                value-format="yyyy-MM-dd HH:mm:ss"
                clearable
              />
#else              <NInput v-model:value="model.$column.javaField" placeholder="请输入$column.columnComment" />
    #end
            </NFormItemGi>
  #end
#end
            <NFormItemGi :show-feedback="false" span="24" class="pr-24px">
              <NSpace class="w-full" justify="end">
                <NButton @click="reset">
                  <template #icon>
                    <icon-ic-round-refresh class="text-icon" />
                  </template>
                  {{ $t('common.reset') }}
                </NButton>
                <NButton type="primary" ghost @click="search">
                  <template #icon>
                    <icon-ic-round-search class="text-icon" />
                  </template>
                  {{ $t('common.search') }}
                </NButton>
              </NSpace>
            </NFormItemGi>
          </NGrid>
        </NForm>
      </NCollapseItem>
    </NCollapse>
  </NCard>
</template>
 
<style scoped></style>