st-comp 0.0.220 → 0.0.221

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "st-comp",
3
3
  "public": true,
4
- "version": "0.0.220",
4
+ "version": "0.0.221",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -0,0 +1,33 @@
1
+ <template>
2
+ <div class="kline-averageTips">
3
+ <div
4
+ v-for="(item, index) in data"
5
+ :key="index"
6
+ class="kline-averageTips-item"
7
+ :style="{ color: item.color, width: `calc(100% / ${data.length} - 10px)` }"
8
+ >{{ item.label }} {{ item.value }}</div>
9
+ </div>
10
+ </template>
11
+
12
+ <script setup lang="ts">
13
+ defineProps({
14
+ // 提示数据
15
+ data: {
16
+ type: Array,
17
+ require: true,
18
+ },
19
+ })
20
+ </script>
21
+
22
+ <style lang="scss" scoped>
23
+ .kline-averageTips {
24
+ width: 100%;
25
+ color: #fff;
26
+ font-size: 12px;
27
+ line-height: 1.5;
28
+ &-item {
29
+ display: inline-block;
30
+ margin-right: 10px;
31
+ }
32
+ }
33
+ </style>
@@ -19,7 +19,7 @@
19
19
  />
20
20
  </el-select>
21
21
  </div>
22
- <Tips :data="subIndicatorTips" />
22
+ <AverageTips :data="subIndicatorTips" />
23
23
  </div>
24
24
  <div
25
25
  class="klineSub-chart"
@@ -32,7 +32,7 @@
32
32
  import dayjs from "dayjs";
33
33
  import { ref, onMounted, onUnmounted, nextTick, computed } from "vue";
34
34
  import * as echarts from "echarts";
35
- import Tips from "../Tips/index.vue";
35
+ import AverageTips from "../AverageTips/index.vue";
36
36
  import { stMath } from "st-func";
37
37
  const { round } = stMath;
38
38
 
@@ -1,22 +1,40 @@
1
1
  <template>
2
- <div class="kline-tips">
2
+ <div class="kline-tips" ref="tipsRef">
3
3
  <div
4
4
  v-for="(item, index) in data"
5
5
  :key="index"
6
6
  class="kline-tips-item"
7
- :style="{ color: item.color }"
7
+ :style="{ color: item.color, width: widthList[index] ? widthList[index] : null }"
8
8
  >{{ item.label }} {{ item.value }}</div>
9
9
  </div>
10
10
  </template>
11
11
 
12
12
  <script setup lang="ts">
13
- defineProps({
13
+ import { ref, watch, nextTick } from "vue";
14
+ const props = defineProps({
14
15
  // 提示数据
15
16
  data: {
16
17
  type: Array,
17
18
  require: true,
18
19
  },
19
20
  })
21
+
22
+ const tipsRef = ref<any>(null)
23
+ const widthList = ref<Array<string>>([])
24
+
25
+ watch(() => props.data, () => {
26
+ if (widthList.value.length === 0) {
27
+ nextTick(() => {
28
+ Array.from(tipsRef.value.children).forEach((item: any, index) => {
29
+ if (String(props.data?.[index]?.value)?.includes('%')) {
30
+ widthList.value[index] = '70px'
31
+ } else {
32
+ widthList.value[index] = `${item.offsetWidth + 14}px`
33
+ }
34
+ })
35
+ })
36
+ }
37
+ })
20
38
  </script>
21
39
 
22
40
  <style lang="scss" scoped>
@@ -0,0 +1,191 @@
1
+ <template>
2
+ <div>
3
+ <el-tag
4
+ v-for="(item, index) in showCheckTagList"
5
+ closable
6
+ style="margin-right: 10px;"
7
+ type="info"
8
+ @close="handleAction('delete', index)"
9
+ >
10
+ <span>{{ item.name }}</span>
11
+ </el-tag>
12
+ <el-button
13
+ class="screen-btn"
14
+ type="primary"
15
+ plain
16
+ size="small"
17
+ :icon="Plus"
18
+ @click="handleAction('add')"
19
+ >
20
+ 添加标签
21
+ </el-button>
22
+ </div>
23
+ <!-- 添加标签弹窗 -->
24
+ <el-dialog
25
+ v-model="visible"
26
+ title="Tips"
27
+ width="1000"
28
+ >
29
+ <template #header>
30
+ <div>
31
+ 添加标签
32
+ <el-radio-group v-model="tagType" size="small" style="margin-left: 8px; vertical-align: 5px;" v-if="0">
33
+ <el-radio-button label="个人" value="person" />
34
+ <el-radio-button label="系统" value="system" />
35
+ </el-radio-group>
36
+ <el-input v-model="searchValue" size="small" style="width: 120px; margin-left: 8px;" placeholder="请输入标签名称" />
37
+ </div>
38
+ </template>
39
+ <div class="tag-list">
40
+ <div class="tab-list-item" v-for="item in tagList">
41
+ <el-checkbox :checked="isCheck(item)" @change="changeCheckBox(item)">
42
+ <div style="display: flex; width: 280px;">
43
+ <div style="flex: 1;line-height: 24px;">{{ item.name }}</div>
44
+ <el-button size="small" :icon="Edit" v-if="0"></el-button>
45
+ <el-button size="small" :icon="Delete" @click="deleteTag(item)"></el-button>
46
+ </div>
47
+ </el-checkbox>
48
+ </div>
49
+ </div>
50
+ <template #footer>
51
+ <div class="dialog-footer">
52
+ <el-button @click="visible = false">取消</el-button>
53
+ <el-button type="primary" @click="handleAction('submit')">确定</el-button>
54
+ </div>
55
+ </template>
56
+ </el-dialog>
57
+ <!-- 编辑标签弹窗 -->
58
+ </template>
59
+
60
+ <script setup>
61
+ import { inject, ref, watch, computed, nextTick } from "vue";
62
+ import { Plus, Edit, Delete } from "@element-plus/icons-vue";
63
+
64
+ let searchTimer = null
65
+
66
+ const { request } = inject("stConfig"); // 组件库全局配置
67
+
68
+ const data = defineModel("data", { default: [] });
69
+ const visible = ref(false);
70
+ const tagType = ref('person'); // 标签类型
71
+ const searchValue = ref(''); // 搜索值
72
+ const totalTagList = ref([]); // 全部标签列表
73
+ const tagList = ref([]); // 标签列表
74
+ const checkList = ref([]); // 勾选列表
75
+
76
+ const showCheckTagList = computed(() => {
77
+ return data.value.map(id => {
78
+ return {
79
+ name: totalTagList.value?.find(i => i.id === id)?.tagName,
80
+ id,
81
+ }
82
+ })
83
+ })
84
+
85
+ watch(() => tagType.value, () => {
86
+ searchValue.value = ''
87
+ })
88
+
89
+ watch(() => searchValue.value, () => {
90
+ clearTimeout(searchTimer)
91
+ searchTimer = setTimeout(() => {
92
+ getTagList()
93
+ }, 300)
94
+ })
95
+
96
+ const isCheck = (item) => {
97
+ return Boolean(checkList.value.includes(item.id))
98
+ }
99
+
100
+ const changeCheckBox = (item) => {
101
+ if (isCheck(item)) {
102
+ // 已经勾选
103
+ checkList.value = checkList.value.filter(i => i !== item.id)
104
+ } else {
105
+ checkList.value.push(item.id)
106
+ }
107
+ }
108
+
109
+ const handleAction = (action, index) => {
110
+ switch (action) {
111
+ // 新增
112
+ case "add": {
113
+ tagList.value = []
114
+ visible.value = true;
115
+ searchValue.value = '';
116
+ checkList.value = [...data.value]
117
+ getTagList()
118
+ break;
119
+ }
120
+ // 编辑
121
+ case "edit": {
122
+ const item = data.value[index];
123
+ compositeOrderForm.value = { ...item };
124
+ visible.value = true;
125
+ break;
126
+ }
127
+ // 窗口确认
128
+ case "submit": {
129
+ visible.value = false;
130
+ data.value = [...checkList.value]
131
+ break;
132
+ }
133
+ // 删除
134
+ case "delete": {
135
+ data.value.splice(index, 1);
136
+ break;
137
+ }
138
+ }
139
+ };
140
+
141
+ const deleteTag = (item) => {
142
+ ElMessageBox.alert(`确认删除标签“${item.name}”吗?`, '删除标签', {
143
+ confirmButtonText: 'OK',
144
+ callback: async (action) => {
145
+ if (action === 'confirm') {
146
+ await request.post('/alarm/deliversign/deleteTag', { tagId: item.id })
147
+ getTagList()
148
+ Elmessage.success('删除成功!')
149
+ }
150
+ },
151
+ })
152
+ }
153
+
154
+ const getTagList = async (isTotal = false) => {
155
+ if (tagType.value === 'person') {
156
+ // 个人标签
157
+ const res = await request.post('/alarm/deliversign/findTagsByUserId', { tagName: searchValue.value })
158
+ tagList.value = []
159
+ nextTick(() => {
160
+ tagList.value = res.body?.map(item => ({
161
+ name: item.tagName,
162
+ id: item.id
163
+ }))
164
+ })
165
+ if (isTotal) {
166
+ totalTagList.value = res.body
167
+ }
168
+ } else {
169
+ // 系统标签
170
+ }
171
+ }
172
+
173
+ getTagList(true)
174
+
175
+ defineExpose({
176
+ updateTag: () => {
177
+ getTagList(true)
178
+ }
179
+ })
180
+ </script>
181
+
182
+ <style lang="scss" scoped>
183
+ .tag-list {
184
+ max-height: 40vh;
185
+ overflow-y: scroll;
186
+ .tab-list-item {
187
+ display: inline-block;
188
+ width: 33%;
189
+ }
190
+ }
191
+ </style>
@@ -1,9 +1,10 @@
1
1
  <script setup name="VarietySearch">
2
- import { watch, computed, provide } from "vue";
2
+ import { watch, computed, provide, ref } from "vue";
3
3
  import defaultConfig from "./config.js";
4
4
  import FactorScreen from "./components/FactorScreen/index.vue";
5
5
  import CommonIndicator from "./components/CommonIndicator/index.vue";
6
6
  import CompositeOrder from "./components/CompositeOrder/index.vue";
7
+ import AddTag from "./components/AddTag/index.vue";
7
8
 
8
9
  const props = defineProps({ config: { type: Object, default: {} } });
9
10
  const searchData = defineModel("searchData");
@@ -34,6 +35,9 @@ searchData.value = Object.assign(searchData.value, {
34
35
  compositeOrder: [],
35
36
  });
36
37
 
38
+ // 添加标签
39
+ const addTagRef = ref();
40
+
37
41
  // 合并配置项
38
42
  const config = computed(() => {
39
43
  const result = {};
@@ -482,6 +486,10 @@ defineExpose({
482
486
  compositeOrder: [],
483
487
  };
484
488
  },
489
+ // 更新标签
490
+ updateTag: () => {
491
+ addTagRef.value.updateTag();
492
+ },
485
493
  });
486
494
  </script>
487
495
 
@@ -548,23 +556,16 @@ defineExpose({
548
556
  </div>
549
557
  </template>
550
558
  <!-- 自定标签 -->
551
- <template v-if="config.customTag?.show && customTagDict.length">
559
+ <template v-if="config.customTag?.show">
552
560
  <div class="variety-search-row">
553
561
  <div class="title">
554
562
  <span>自定标签: </span>
555
563
  <span @click="clearRow('customTag')">不限</span>
556
564
  </div>
557
- <el-checkbox-group
558
- v-model="searchData.customTag"
559
- size="small"
560
- >
561
- <el-checkbox
562
- v-for="{ label, value } in customTagDict"
563
- :label="label"
564
- :value="value"
565
- :key="value"
566
- />
567
- </el-checkbox-group>
565
+ <AddTag
566
+ ref="addTagRef"
567
+ v-model:data="searchData.customTag"
568
+ />
568
569
  </div>
569
570
  </template>
570
571
  <!-- 价差转换 -->
@@ -1,6 +1,6 @@
1
1
  import axios from "axios";
2
2
 
3
- const token = "d06d8c9c2ea6c489dc94820c084f7d28";
3
+ const token = "8461980aa5ae69587e642326d4c030a2";
4
4
  const host = "http://192.168.12.38:5173";
5
5
 
6
6
  // 获取指标线配置