@me-framework/me-sku-editor 1.0.1
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/README.en.md +36 -0
- package/README.md +230 -0
- package/dist/demo/assets/iconfont.1782658269305-Bwz3sFC-.ttf +0 -0
- package/dist/demo/assets/iconfont.1782658269305-CiRZOtYp.woff +0 -0
- package/dist/demo/assets/iconfont.1782890314097-BllfKX1O.ttf +0 -0
- package/dist/demo/assets/iconfont.1782890314097-D9epzWxu.woff +0 -0
- package/dist/demo/assets/index-CLHSZeXE.css +1 -0
- package/dist/demo/assets/index-T0Giuvdt.js +157 -0
- package/dist/demo/favicon.svg +1 -0
- package/dist/demo/icons.svg +24 -0
- package/dist/demo/index.html +14 -0
- package/dist/lib/favicon.svg +1 -0
- package/dist/lib/icons.svg +24 -0
- package/dist/lib/me-sku-editor.css +2 -0
- package/dist/lib/me-sku-editor.mjs +22601 -0
- package/dist/lib/me-sku-editor.umd.js +104 -0
- package/document/prompt/sku-editor.md +268 -0
- package/document//344/275/277/347/224/250/346/226/207/346/241/243.md +1028 -0
- package/document//345/274/200/345/217/221/346/214/207/345/215/227.md +637 -0
- package/document//345/277/253/351/200/237/345/274/200/345/247/213.md +292 -0
- package/package.json +76 -0
package/README.en.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# me-sku-editor
|
|
2
|
+
|
|
3
|
+
#### Description
|
|
4
|
+
SKU编辑器
|
|
5
|
+
|
|
6
|
+
#### Software Architecture
|
|
7
|
+
Software architecture description
|
|
8
|
+
|
|
9
|
+
#### Installation
|
|
10
|
+
|
|
11
|
+
1. xxxx
|
|
12
|
+
2. xxxx
|
|
13
|
+
3. xxxx
|
|
14
|
+
|
|
15
|
+
#### Instructions
|
|
16
|
+
|
|
17
|
+
1. xxxx
|
|
18
|
+
2. xxxx
|
|
19
|
+
3. xxxx
|
|
20
|
+
|
|
21
|
+
#### Contribution
|
|
22
|
+
|
|
23
|
+
1. Fork the repository
|
|
24
|
+
2. Create Feat_xxx branch
|
|
25
|
+
3. Commit your code
|
|
26
|
+
4. Create Pull Request
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
#### Gitee Feature
|
|
30
|
+
|
|
31
|
+
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
|
|
32
|
+
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
|
|
33
|
+
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
|
|
34
|
+
4. The most valuable open source project [GVP](https://gitee.com/gvp)
|
|
35
|
+
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
|
|
36
|
+
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
package/README.md
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# @me-framework/me-sku-editor
|
|
2
|
+
|
|
3
|
+
一个功能强大的 Vue 3 商品规格 SKU 编辑器。
|
|
4
|
+
|
|
5
|
+
## 特性
|
|
6
|
+
|
|
7
|
+
- 🎨 **多规格类型** - 支持文字、颜色、图片三种规格类型
|
|
8
|
+
- 🛠️ **可视化编辑** - 直观的拖拽式规格管理
|
|
9
|
+
- 📊 **智能表格** - 自动生成 SKU 组合、单元格合并
|
|
10
|
+
- 📥 **数据导入** - 支持 Excel / JSON 格式导入
|
|
11
|
+
- 📤 **数据导出** - 支持 Excel / JSON 格式导出
|
|
12
|
+
- 🔀 **拖拽排序** - 规格和属性支持拖拽排序,自动更新 sort 字段
|
|
13
|
+
- 📋 **批量编辑** - 一键批量设置 SKU 属性
|
|
14
|
+
- 👁️ **列可见性** - 自定义显示/隐藏表格列
|
|
15
|
+
- 💾 **记忆功能** - 修改规格时保留已编辑的 SKU 数据
|
|
16
|
+
- ✅ **数据校验** - 灵活的校验系统,支持自定义规则,区分错误和警告
|
|
17
|
+
- 🔄 **双格式支持** - 内部格式(ID)和外部格式(名称)自动转换
|
|
18
|
+
|
|
19
|
+
## 安装
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @me-framework/me-sku-editor
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## 快速开始
|
|
26
|
+
|
|
27
|
+
### 1. 安装依赖
|
|
28
|
+
|
|
29
|
+
由于 `me-sku-editor` 使用 `peerDependencies`,你需要在项目中安装以下依赖:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install vue@^3.4.0 element-plus@^2.14.0 @element-plus/icons-vue@^2.3.0 vxe-table@^4.19.0 vxe-pc-ui@^4.15.0
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 2. 在 Vue 项目中使用
|
|
36
|
+
|
|
37
|
+
#### 方式一:按需引入(推荐)
|
|
38
|
+
|
|
39
|
+
```vue
|
|
40
|
+
<script setup lang="ts">
|
|
41
|
+
import { ref } from 'vue'
|
|
42
|
+
import { SkuEditor } from '@me-framework/me-sku-editor'
|
|
43
|
+
import type { Spec, SkuRow } from '@me-framework/me-sku-editor'
|
|
44
|
+
|
|
45
|
+
// 规格数据
|
|
46
|
+
const specs = ref<Spec[]>([
|
|
47
|
+
{
|
|
48
|
+
id: 'spec-1',
|
|
49
|
+
name: '颜色',
|
|
50
|
+
type: 'color',
|
|
51
|
+
sort: 0,
|
|
52
|
+
attributes: [
|
|
53
|
+
{ id: 'attr-1-1', name: '红色', color: '#ff0000', image: '', sort: 0, content: '' },
|
|
54
|
+
{ id: 'attr-1-2', name: '蓝色', color: '#0000ff', image: '', sort: 1, content: '' }
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: 'spec-2',
|
|
59
|
+
name: '尺码',
|
|
60
|
+
type: 'text',
|
|
61
|
+
sort: 1,
|
|
62
|
+
attributes: [
|
|
63
|
+
{ id: 'attr-2-1', name: 'S', color: '', image: '', sort: 0, content: '' },
|
|
64
|
+
{ id: 'attr-2-2', name: 'M', color: '', image: '', sort: 1, content: '' },
|
|
65
|
+
{ id: 'attr-2-3', name: 'L', color: '', image: '', sort: 2, content: '' }
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
])
|
|
69
|
+
|
|
70
|
+
// SKU 数据
|
|
71
|
+
const skuData = ref<SkuRow[]>([])
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<template>
|
|
75
|
+
<div>
|
|
76
|
+
<h2>SKU 编辑器</h2>
|
|
77
|
+
<SkuEditor v-model:specs="specs" v-model:sku-data="skuData" />
|
|
78
|
+
</div>
|
|
79
|
+
</template>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### 方式二:全局注册
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
// main.ts
|
|
86
|
+
import { createApp } from 'vue'
|
|
87
|
+
import App from './App.vue'
|
|
88
|
+
|
|
89
|
+
// 引入 Element Plus
|
|
90
|
+
import ElementPlus from 'element-plus'
|
|
91
|
+
import 'element-plus/dist/index.css'
|
|
92
|
+
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
|
93
|
+
|
|
94
|
+
// 引入 VXE Table
|
|
95
|
+
import VxeUI from 'vxe-pc-ui'
|
|
96
|
+
import 'vxe-pc-ui/es/style.css'
|
|
97
|
+
import VXETable from 'vxe-table'
|
|
98
|
+
import 'vxe-table/lib/style.css'
|
|
99
|
+
|
|
100
|
+
// 引入 me-sku-editor
|
|
101
|
+
import MeSkuEditor from '@me-framework/me-sku-editor'
|
|
102
|
+
|
|
103
|
+
const app = createApp(App)
|
|
104
|
+
|
|
105
|
+
app.use(ElementPlus)
|
|
106
|
+
app.use(VxeUI)
|
|
107
|
+
app.use(VXETable)
|
|
108
|
+
app.use(MeSkuEditor) // 全局注册
|
|
109
|
+
|
|
110
|
+
// 注册 Element Plus 图标
|
|
111
|
+
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
|
112
|
+
app.component(key, component)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
app.mount('#app')
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## API 文档
|
|
119
|
+
|
|
120
|
+
### SkuEditor Props
|
|
121
|
+
|
|
122
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
123
|
+
|------|------|------|--------|
|
|
124
|
+
| `v-model:specs` | 规格数据(双向绑定) | `Spec[]` | `[]` |
|
|
125
|
+
| `v-model:sku-data` | SKU 数据(双向绑定) | `SkuRow[]` | `[]` |
|
|
126
|
+
| `validation-rules` | 校验规则配置 | `ValidationRules` | `{}` |
|
|
127
|
+
|
|
128
|
+
### SkuEditor Methods(通过 ref 调用)
|
|
129
|
+
|
|
130
|
+
```vue
|
|
131
|
+
<script setup lang="ts">
|
|
132
|
+
import { ref } from 'vue'
|
|
133
|
+
import { SkuEditor } from '@me-framework/me-sku-editor'
|
|
134
|
+
import type { InstanceType } from 'vue'
|
|
135
|
+
|
|
136
|
+
const skuEditorRef = ref<InstanceType<typeof SkuEditor>>()
|
|
137
|
+
|
|
138
|
+
// 导出 Excel
|
|
139
|
+
const handleExportExcel = () => {
|
|
140
|
+
skuEditorRef.value?.exportExcel()
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// 导出 JSON
|
|
144
|
+
const handleExportJson = () => {
|
|
145
|
+
skuEditorRef.value?.exportJson()
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// 校验数据
|
|
149
|
+
const handleValidate = () => {
|
|
150
|
+
const result = skuEditorRef.value?.validateSkuData()
|
|
151
|
+
console.log(result)
|
|
152
|
+
}
|
|
153
|
+
</script>
|
|
154
|
+
|
|
155
|
+
<template>
|
|
156
|
+
<SkuEditor ref="skuEditorRef" v-model:specs="specs" v-model:sku-data="skuData" />
|
|
157
|
+
</template>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### 类型定义
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
import type {
|
|
164
|
+
Spec,
|
|
165
|
+
SpecAttribute,
|
|
166
|
+
SpecType,
|
|
167
|
+
AttributeValue,
|
|
168
|
+
SkuRow,
|
|
169
|
+
ValidationRules,
|
|
170
|
+
ValidationResult
|
|
171
|
+
} from '@me-framework/me-sku-editor'
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## 文档
|
|
175
|
+
|
|
176
|
+
- [快速开始指南](./document/快速开始.md) - 5 分钟上手教程
|
|
177
|
+
- [使用文档](./document/使用文档.md) - 完整功能说明
|
|
178
|
+
- [开发指南](./document/开发指南.md) - 二次开发指南
|
|
179
|
+
|
|
180
|
+
## 项目结构
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
src/
|
|
184
|
+
├── components/sku/ # SKU 编辑器组件
|
|
185
|
+
├── composables/sku/ # SKU 相关逻辑
|
|
186
|
+
├── types/sku/ # SKU 类型定义
|
|
187
|
+
└── constants/sku.ts # SKU 常量定义
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## 技术栈
|
|
191
|
+
|
|
192
|
+
- Vue 3 + TypeScript
|
|
193
|
+
- Element Plus
|
|
194
|
+
- VXE Table
|
|
195
|
+
- XLSX
|
|
196
|
+
- Sortable.js
|
|
197
|
+
|
|
198
|
+
## 本地开发
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# 安装依赖
|
|
202
|
+
npm install
|
|
203
|
+
|
|
204
|
+
# 启动开发服务器
|
|
205
|
+
npm run dev
|
|
206
|
+
|
|
207
|
+
# 构建库
|
|
208
|
+
npm run build:lib
|
|
209
|
+
|
|
210
|
+
# 构建 demo
|
|
211
|
+
npm run build:demo
|
|
212
|
+
|
|
213
|
+
# 完整构建(lib + demo)
|
|
214
|
+
npm run build
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
## 最近更新
|
|
220
|
+
|
|
221
|
+
- 移除了兼容模式,统一使用外部格式(spec_json)处理 SKU 数据
|
|
222
|
+
- 新增了数据校验系统,支持自定义校验规则
|
|
223
|
+
- 重构了类型定义结构,更清晰的组织
|
|
224
|
+
- 优化了数据同步机制
|
|
225
|
+
- 新增了打印数据功能
|
|
226
|
+
- SkuGrid 支持行配置属性用于高亮
|
|
227
|
+
|
|
228
|
+
## 许可证
|
|
229
|
+
|
|
230
|
+
MIT
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|