schangxiang@126.com
2025-05-20 e050767314ff74ac13727f33398ad16c1e183945
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import {
  ref,
  onMounted,
  reactive,
  computed,
  Ref,
  watch,
  SetupContext,
  h,
} from 'vue'
import { injectModel } from '@/libs/Provider/Provider'
import { $EntityName$Drawer } from '../Models/$EntityName$Drawer'
import { ElMessage } from 'element-plus'
import isEqual from 'lodash/isEqual'
import { ConfirmBox } from '@/components/ConfirmBox/ConfirmBox'
import { cloneDeep } from 'lodash'
// ÒýÈ빫¹²Ñ¡ÏîÅäÖÃ
import { 
  FILTER_MODE_OPTIONS_STRING, 
  FILTER_MODE_OPTIONS_NUM,
  FILTER_MODE_OPTIONS_BOOL
} from '@/components/DyFormForHighQuery/DyFormForHighQueryOptions';
// ÒýÈ빫¹²±íµ¥¹¤¾ßÎļþ 
import { collectFormDataForHighQuery,onResetForHighSelect,onResetForHighQuery } from '@/utils/myformUtils';
import { 
  BOOLEAN_OPTIONS
} from '@/utils/commonOptionConstants';
 
export const use$EntityName$QueryDrawer = (props: any, ctx?: any) => {
  const $PageMenuInstanceName$Drawer = injectModel<$EntityName$Drawer>('$EntityName$Drawer')
  /**
   * ÓÃÀ´¶Ô±ÈµÄ³õʼ»¯Êý¾Ý
   */
  const initiateData: Ref<Record<string, any>> = ref({})
  const formData = ref<Record<string, any>>({})
  // ref
  const formRef = ref()
 
  const disabled = ref(false)
 
  const current = computed(() => {
    return props.row || null
  })
 
  const inputNumber = (attrs) => {
    return (
      <el-input-number
        min="1"
        step="1"
        precision="0"
        {...attrs}
      ></el-input-number>
    )
  }
 
    const datePickerRange = (attrs) => {
    return (
      <el-date-picker
        type="daterange"
        value-format="YYYY-MM-DD HH:mm:ss"
        start-placeholder="¿ªÊ¼ÈÕÆÚ"
        end-placeholder="½áÊøÈÕÆÚ"
        {...attrs}
      ></el-date-picker>
    )
  }
 
  const dateTimePickerRange = (attrs) => {
    return (
      <el-date-picker
        type="datetimerange"
        value-format="YYYY-MM-DD HH:mm:ss"
        start-placeholder="¿ªÊ¼ÈÕÆÚ"
        end-placeholder="½áÊøÈÕÆÚ"
        {...attrs}
      ></el-date-picker>
    )
  }
 
  const visible = computed({
    get() {
      return props.modelValue
    },
    set(val) {
      ctx.emit('update:modelValue', val)
    },
  })
  /**
   * ¸ß¼¶²éѯµÄform×Ö¶Î
   */
  const formItems = reactive([
    $PageAddFormAttributes_Query$
  ])
  /**
   * Ð£ÑéÊÇ·ñÓÐÊý¾Ý±ä»¯
   */
  const checkIsEqualObject = () => {
    const data = {
      formData: formData.value,
    }
    const check = isEqual(initiateData.value, data)
    return check
  }
 
  const onClose = (done: () => void) => {
    if (visible.value) {
      visible.value = false
      const data =collectFormDataForHighQuery(formItems,formData); 
      ctx.emit('close', data)
    }
  }
  /**
   * È·Èϲéѯ
   */
  const onConfirmQuery = async () => {
    const data =collectFormDataForHighQuery(formItems,formData); 
    ctx.emit('confirmQuery', data)
  }
    /**
    * ÖØÖòéѯ - ÓÅ»¯°æ
    */
    const onReset = async () => {
        // 1. Çå¿ÕËùÓлù´¡×ֶΣ¨²»°üº¬¹ýÂËģʽ×ֶΣ©,Ó¦Óûù´¡×ֶγõʼֵ  
        onResetForHighQuery(formItems,formData);
  
        // 2. Ê¹ÓÃÔ­Óз½·¨ÖØÖùýÂËģʽ×Ö¶Î
        onResetForHighSelect(formItems,formData);
  
        // 3. Ïò¸¸×é¼þ·¢ËÍ×Ô¶¨Òåʼþ
        ctx.emit('restQuery');
    }
 
  const updateCheckData = () => {
    initiateData.value = {
      formData: {
        ...formData.value,
      },
    }
  }
  const updateFormItemOptions = (propName: string, enumData: any[]) => {
    const item = formItems.find((item) => item.prop === propName)
    if (item && enumData) {
      item.options = enumData.map((item) => ({
        label: item.description,
        value: item.value,
      }))
    }
  }
  /**
   * Í¨Óòéѯö¾Ù
   */
  const commonQueryEnumForFrom = async () => {
    $CommonQueryEnumForFrom$
  }
  commonQueryEnumForFrom()
  onResetForHighSelect(formItems,formData);//ÖØÖù«¹²select²éѯ  
  /**
   * µ¯´°´ò¿ª»ñÈ¡ÏêÇé
   */
  const onOpen = async () => {
    disabled.value = false
    updateCheckData()
  }
 
  watch(() => current.value, onOpen)
 
  return {
    formItems,
    formData,
    visible,
    formRef,
    onOpen,
    onClose,
    onConfirmQuery,
    onReset,
  }
}