st-comp 0.0.47 → 0.0.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,310 @@
1
+ <template>
2
+ <el-dialog
3
+ v-model="visible"
4
+ class="st-VarietySearch-modelSearch-dialog"
5
+ :title="data.label"
6
+ align-center
7
+ :draggable="true"
8
+ width="510"
9
+ >
10
+ <template v-if="data.type === 'default'">
11
+ <div class="st-VarietySearch-modelSearch-dialog-content">
12
+ <el-button
13
+ v-for="(item, index) in data.options"
14
+ class="st-VarietySearch-modelSearch-dialog-content-btn"
15
+ :key="index"
16
+ size="small"
17
+ :style="item.style"
18
+ :type="index === activeIndex ? 'primary' : ''"
19
+ @click="btnClick(item, index)"
20
+ >{{ item.btnText }}</el-button>
21
+ </div>
22
+ <div>
23
+ <span>自定义:</span>
24
+ <el-input
25
+ v-model="start"
26
+ :class="!(start || end) && check ? 'st-VarietySearch-factorFilter-border-red' : ''"
27
+ size="small"
28
+ style="width: 150px"
29
+ >
30
+ <template #append v-if="typeof unitOptions === 'string'">
31
+ {{ unitOptions }}
32
+ </template>
33
+ <template #append v-else-if="typeof unitOptions === 'object'">
34
+ <el-select
35
+ v-model="startUnit"
36
+ :style="{ width: '60px' }"
37
+ placeholder=""
38
+ size="small"
39
+ >
40
+ <el-option
41
+ v-for="item in unitOptions"
42
+ :key="item.value"
43
+ :label="item.label"
44
+ :value="item.value"
45
+ />
46
+ </el-select>
47
+ </template>
48
+ </el-input>
49
+ <span style="margin: 0 10px;">~</span>
50
+ <el-input
51
+ v-model="end"
52
+ :class="!(start || end) && check ? 'st-VarietySearch-factorFilter-border-red' : ''"
53
+ controls-position="right"
54
+ style="width: 150px"
55
+ size="small"
56
+ >
57
+ <template #append v-if="typeof unitOptions === 'string'">
58
+ {{ unitOptions }}
59
+ </template>
60
+ <template #append v-else-if="typeof unitOptions === 'object'">
61
+ <el-select
62
+ v-model="endUnit"
63
+ :style="{ width: '60px' }"
64
+ placeholder=""
65
+ size="small"
66
+ >
67
+ <el-option
68
+ v-for="item in unitOptions"
69
+ :key="item.value"
70
+ :label="item.label"
71
+ :value="item.value"
72
+ />
73
+ </el-select>
74
+ </template>
75
+ </el-input>
76
+ </div>
77
+ </template>
78
+ <template v-else-if="data.type === 'radio'">
79
+ <el-radio-group v-model="radio" class="ml-4">
80
+ <el-radio
81
+ v-for="item in data.options"
82
+ :label="item.value"
83
+ size="small"
84
+ >{{ item.label }}</el-radio>
85
+ </el-radio-group>
86
+ </template>
87
+ <template v-else-if="data.type === 'tFeaturelncomes'">
88
+ <div class="st-VarietySearch-modelSearch-dialog-content">
89
+ <el-button
90
+ v-for="(item, index) in data.options"
91
+ class="st-VarietySearch-modelSearch-dialog-content-btn"
92
+ :key="index"
93
+ size="small"
94
+ :style="item.style"
95
+ :type="index === activeIndex ? 'primary' : ''"
96
+ @click="btnClick(item, index)"
97
+ >{{ item.btnText }}</el-button>
98
+ </div>
99
+ <div style="margin-bottom: 10px">
100
+ <span>自定义:</span>
101
+ <el-input-number
102
+ v-model="withFewYears"
103
+ :class="!withFewYears && check ? 'st-VarietySearch-factorFilter-border-red' : ''"
104
+ size="small"
105
+ :min="-9999999"
106
+ :max="9999999"
107
+ controls-position="right"
108
+ style="width: 70px"
109
+ />
110
+ <span> 年内 </span>
111
+ <el-input-number
112
+ v-model="yearsCount"
113
+ size="small"
114
+ :min="0"
115
+ :max="9999999"
116
+ controls-position="right"
117
+ style="width: 70px"
118
+ />
119
+ <span>
120
+ 年以上盈利{{ rule === 1 ? "超" : "跌" }}过
121
+ </span>
122
+ <el-input-number
123
+ v-model="netProfit"
124
+ :class="!netProfit && check ? 'st-VarietySearch-factorFilter-border-red' : ''"
125
+ size="small"
126
+ :min="0"
127
+ :max="9999999"
128
+ controls-position="right"
129
+ style="width: 80px"
130
+ />
131
+ <span> 亿</span>
132
+ </div>
133
+ </template>
134
+ <template #footer>
135
+ <div class="dialog-footer">
136
+ <el-button size="small" @click="visible = false">取消</el-button>
137
+ <el-button size="small" type="primary" @click="submit">
138
+ 确认
139
+ </el-button>
140
+ </div>
141
+ </template>
142
+ </el-dialog>
143
+ </template>
144
+
145
+ <script setup>
146
+ import { ref, computed, watch } from 'vue'
147
+
148
+ const emit = defineEmits(['update:modelValue', 'submit']);
149
+ const props = defineProps({
150
+ modelValue: {
151
+ type: Boolean,
152
+ require: true,
153
+ },
154
+ data: {
155
+ type: Object,
156
+ default: () => ({}),
157
+ }
158
+ })
159
+
160
+ const activeIndex = ref(-1) // 快捷选中的index
161
+ const start = ref('') // default类型下的起始值
162
+ const end = ref('') // default类型下的结束值
163
+ const startUnit = ref('') // default类型下的起始值单位
164
+ const endUnit = ref('') // default类型下的结束值单位
165
+ const unitOptions = ref() // default类型下的自定义单位
166
+ const radio = ref() // radio类型下的单选值
167
+ const withFewYears = ref() // tFeaturelncomes类型下的几年内数据
168
+ const yearsCount = ref() // tFeaturelncomes类型下的几年上
169
+ const netProfit = ref() // tFeaturelncomes类型下的差值
170
+ const rule = ref() // tFeaturelncomes类型下的涨跌规则
171
+ const check = ref(false) // 表单校验
172
+
173
+ const visible = computed({
174
+ get() {
175
+ return props.modelValue;
176
+ },
177
+ set(val) {
178
+ emit('update:modelValue', val);
179
+ },
180
+ });
181
+
182
+ watch(visible, () => {
183
+ if (visible) {
184
+ activeIndex.value = -1
185
+ start.value = ''
186
+ end.value = ''
187
+ startUnit.value = ''
188
+ endUnit.value = ''
189
+ unitOptions.value = null
190
+ radio.value = null
191
+ withFewYears.value = null
192
+ yearsCount.value = null
193
+ netProfit.value = null
194
+ rule.value = null
195
+
196
+ if (props.data.type === 'default') {
197
+ start.value = props.data.start
198
+ end.value = props.data.end
199
+ startUnit.value = props.data.startUnit
200
+ endUnit.value = props.data.endUnit
201
+ unitOptions.value = props.data.unitOptions
202
+ }else if (props.data.type === 'radio') {
203
+ radio.value = props.data.radio
204
+ } else if (props.data.type === 'tFeaturelncomes') {
205
+ withFewYears.value = props.data.withFewYears
206
+ yearsCount.value = props.data.yearsCount
207
+ netProfit.value = props.data.netProfit
208
+ rule.value = props.data.rule
209
+ }
210
+ }
211
+ })
212
+
213
+ watch(
214
+ () => [start.value, end.value, startUnit.value, endUnit.value],
215
+ () => { activeIndex.value = -1 },
216
+ { deep: true }
217
+ )
218
+
219
+ const btnClick = (item, index) => {
220
+ activeIndex.value = index
221
+ if (props.data.type === 'default') {
222
+ start.value = item.start
223
+ end.value = item.end
224
+ startUnit.value = item.startUnit
225
+ endUnit.value = item.endUnit
226
+ } else if (props.data.type === 'tFeaturelncomes') {
227
+ withFewYears.value = item.withFewYears
228
+ yearsCount.value = item.yearsCount
229
+ netProfit.value = item.netProfit
230
+ rule.value = item.rule
231
+ }
232
+ }
233
+
234
+ const submit = () => {
235
+ const { type } = props.data
236
+ if (type === 'default') {
237
+ if (!(start.value || end.value)) {
238
+ check.value = true
239
+ ElMessage.error('请检查参数后重试!')
240
+ return
241
+ }
242
+ check.value = false
243
+ emit('submit', {
244
+ ...props.data,
245
+ isEmit: true,
246
+ start: start.value ? Number(start.value) : null,
247
+ end: end.value ? Number(end.value): null,
248
+ startUnit: startUnit.value,
249
+ endUnit: endUnit.value,
250
+ })
251
+ } else if (type === 'radio') {
252
+ if (radio.value === null) {
253
+ ElMessage.error('请检查参数后重试!')
254
+ return
255
+ }
256
+ emit('submit', {
257
+ ...props.data,
258
+ isEmit: true,
259
+ radio: radio.value,
260
+ radioLabel: props.data.options.find(item => item.value === radio.value).label
261
+ })
262
+ } else if (type === 'tFeaturelncomes') {
263
+ if (!(withFewYears.value || netProfit.value)) {
264
+ check.value = true
265
+ ElMessage.error('请检查参数后重试!')
266
+ return
267
+ }
268
+ check.value = false
269
+ emit('submit', {
270
+ ...props.data,
271
+ isEmit: true,
272
+ withFewYears: withFewYears.value,
273
+ yearsCount: yearsCount.value,
274
+ netProfit: netProfit.value,
275
+ rule: rule.value,
276
+ })
277
+ }
278
+ visible.value = false
279
+ }
280
+ </script>
281
+
282
+ <style lang="scss">
283
+ .st-VarietySearch-modelSearch-border-red .el-input__wrapper,
284
+ .st-VarietySearch-modelSearch-border-red .el-select__wrapper {
285
+ box-shadow: 0 0 0 1px var(--el-color-danger) inset;
286
+ }
287
+ .st-VarietySearch-modelSearch-dialog {
288
+ .el-dialog__header {
289
+ padding-top: 10px;
290
+ .el-dialog__headerbtn {
291
+ width: 40px;
292
+ height: 40px;
293
+ }
294
+ }
295
+ .el-dialog__body {
296
+ border-top: 1px solid var(--el-border-color);
297
+ border-bottom: 1px solid var(--el-border-color);
298
+ padding: 15px 20px;
299
+ }
300
+ }
301
+ </style>
302
+
303
+ <style lang="scss" scoped>
304
+ .st-VarietySearch-modelSearch-dialog-content {
305
+ &-btn {
306
+ margin-bottom: 10px;
307
+ margin-left: 0;
308
+ }
309
+ }
310
+ </style>