st-comp 0.0.234 → 0.0.236

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.234",
4
+ "version": "0.0.236",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -33,7 +33,7 @@
33
33
  } else if(props.data?.[index]?.label === '额') {
34
34
  widthList.value[index] = '85px'
35
35
  } else if(['开', '高', '低', '收'].includes(props.data?.[index]?.label)) {
36
- widthList.value[index] = `${item.offsetWidth + 22}px`
36
+ widthList.value[index] = `${item.offsetWidth + 24}px`
37
37
  } else {
38
38
  widthList.value[index] = `${item.offsetWidth + 36}px`
39
39
  }
@@ -23,13 +23,12 @@
23
23
  <!-- 添加标签弹窗 -->
24
24
  <el-dialog
25
25
  v-model="visible"
26
- title="Tips"
27
26
  width="1000"
28
27
  >
29
28
  <template #header>
30
29
  <div>
31
30
  添加标签
32
- <el-radio-group v-model="tagType" size="small" style="margin-left: 8px; vertical-align: 5px;" v-if="0">
31
+ <el-radio-group v-model="tagType" size="small" style="margin-left: 8px; vertical-align: 5px;">
33
32
  <el-radio-button label="个人" value="person" />
34
33
  <el-radio-button label="系统" value="system" />
35
34
  </el-radio-group>
@@ -41,8 +40,8 @@
41
40
  <el-checkbox :checked="isCheck(item)" @change="changeCheckBox(item)">
42
41
  <div style="display: flex; width: 280px;">
43
42
  <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>
43
+ <el-button size="small" :icon="Edit" @click="editTag(item)" v-if="tagType === 'person'"></el-button>
44
+ <el-button size="small" :icon="Delete" @click="deleteTag(item)" v-if="tagType === 'person'"></el-button>
46
45
  </div>
47
46
  </el-checkbox>
48
47
  </div>
@@ -55,6 +54,21 @@
55
54
  </template>
56
55
  </el-dialog>
57
56
  <!-- 编辑标签弹窗 -->
57
+ <el-dialog
58
+ v-model="editVisible"
59
+ title="编辑标签"
60
+ top="20vh"
61
+ width="600"
62
+ >
63
+ <div style="margin-bottom: 12px;">原名称:{{ editItem?.name }}</div>
64
+ <el-input v-model="editValue" />
65
+ <template #footer>
66
+ <div class="dialog-footer">
67
+ <el-button @click="editVisible = false">取消</el-button>
68
+ <el-button type="primary" @click="changeTag()">确定</el-button>
69
+ </div>
70
+ </template>
71
+ </el-dialog>
58
72
  </template>
59
73
 
60
74
  <script setup>
@@ -69,14 +83,17 @@ const data = defineModel("data", { default: [] });
69
83
  const visible = ref(false);
70
84
  const tagType = ref('person'); // 标签类型
71
85
  const searchValue = ref(''); // 搜索值
72
- const totalTagList = ref([]); // 全部标签列表
86
+ const tagMap = ref({}); // 全部标签映射
73
87
  const tagList = ref([]); // 标签列表
74
88
  const checkList = ref([]); // 勾选列表
89
+ const editVisible = ref(false); // 编辑标签弹窗
90
+ const editItem = ref(null); // 编辑标签对象
91
+ const editValue = ref(''); // 编辑标签值
75
92
 
76
93
  const showCheckTagList = computed(() => {
77
94
  return data.value.map(id => {
78
95
  return {
79
- name: totalTagList.value?.find(i => i.id === id)?.tagName,
96
+ name: tagMap.value[id],
80
97
  id,
81
98
  }
82
99
  })
@@ -84,6 +101,7 @@ const showCheckTagList = computed(() => {
84
101
 
85
102
  watch(() => tagType.value, () => {
86
103
  searchValue.value = ''
104
+ getTagList()
87
105
  })
88
106
 
89
107
  watch(() => searchValue.value, () => {
@@ -106,6 +124,7 @@ const changeCheckBox = (item) => {
106
124
  }
107
125
  }
108
126
 
127
+ // 标签相关操作
109
128
  const handleAction = (action, index) => {
110
129
  switch (action) {
111
130
  // 新增
@@ -117,13 +136,6 @@ const handleAction = (action, index) => {
117
136
  getTagList()
118
137
  break;
119
138
  }
120
- // 编辑
121
- case "edit": {
122
- const item = data.value[index];
123
- compositeOrderForm.value = { ...item };
124
- visible.value = true;
125
- break;
126
- }
127
139
  // 窗口确认
128
140
  case "submit": {
129
141
  visible.value = false;
@@ -138,6 +150,7 @@ const handleAction = (action, index) => {
138
150
  }
139
151
  };
140
152
 
153
+ // 删除个人标签
141
154
  const deleteTag = (item) => {
142
155
  ElMessageBox.alert(`确认删除标签“${item.name}”吗?`, '删除标签', {
143
156
  confirmButtonText: 'OK',
@@ -145,13 +158,41 @@ const deleteTag = (item) => {
145
158
  if (action === 'confirm') {
146
159
  await request.post('/alarm/deliversign/deleteTag', { tagId: item.id })
147
160
  getTagList()
148
- Elmessage.success('删除成功!')
161
+ ElMessage.success('删除成功!')
149
162
  }
150
163
  },
151
164
  })
152
165
  }
153
166
 
154
- const getTagList = async (isTotal = false) => {
167
+ // 打开编辑标签弹窗
168
+ const editTag = (item) => {
169
+ editItem.value = item
170
+ editValue.value = item.name
171
+ editVisible.value = true
172
+ }
173
+
174
+ // 修改标签
175
+ const changeTag = async () => {
176
+ await request.post('/alarm/deliversign/addOrUpdateFeatureTag', { tagName: editValue.value, tagId: editItem.value.id })
177
+ tagMap.value = {
178
+ ...tagMap.value,
179
+ [editItem.value.id]: editValue.value
180
+ }
181
+ tagList.value = tagList.value.map(item => {
182
+ if (item.id === editItem.value.id) {
183
+ return {
184
+ ...item,
185
+ name: editValue.value
186
+ }
187
+ }
188
+ return item
189
+ })
190
+ editVisible.value = false
191
+ ElMessage.success('修改成功!')
192
+ }
193
+
194
+ // 获取标签列表
195
+ const getTagList = async () => {
155
196
  if (tagType.value === 'person') {
156
197
  // 个人标签
157
198
  const res = await request.post('/alarm/deliversign/findTagsByUserId', { tagName: searchValue.value })
@@ -162,19 +203,44 @@ const getTagList = async (isTotal = false) => {
162
203
  id: item.id
163
204
  }))
164
205
  })
165
- if (isTotal) {
166
- totalTagList.value = res.body
167
- }
168
206
  } else {
169
207
  // 系统标签
208
+ const res = await request.post('/alarm/deliversign/findSystemTagsByTagName', { tagName: searchValue.value })
209
+ tagList.value = []
210
+ nextTick(() => {
211
+ tagList.value = res.body?.map(item => ({
212
+ name: item.tagName,
213
+ id: item.id
214
+ }))
215
+ })
170
216
  }
171
217
  }
172
218
 
173
- getTagList(true)
219
+ // 获取全部标签
220
+ const getTotalTagMap = async () => {
221
+ const res = await Promise.all([
222
+ request.post('/alarm/deliversign/findTagsByUserId'),
223
+ request.post('/alarm/deliversign/findSystemTagsByTagName')
224
+ ])
225
+ tagMap.value = res.reduce((r, i) => {
226
+ return {
227
+ ...r,
228
+ ...i.body?.reduce((bodyR, bodyI) => {
229
+ return {
230
+ ...bodyR,
231
+ [bodyI.id]: bodyI.tagName
232
+ }
233
+ }, {})
234
+ }
235
+ }, {})
236
+ Elmessage.success('删除成功!')
237
+ }
238
+
239
+ getTotalTagMap()
174
240
 
175
241
  defineExpose({
176
242
  updateTag: () => {
177
- getTagList(true)
243
+ getTotalTagMap()
178
244
  }
179
245
  })
180
246
  </script>