|
|
@@ -452,7 +452,7 @@
|
|
|
import { ref, computed, reactive, onMounted, onUnmounted } from 'vue'
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
import { Pointer, Rank, ArrowUp, ArrowDown, Delete, View, Hide, Lock, Unlock, Plus, Document, Picture, Refresh, Upload, Search, ArrowLeft } from '@element-plus/icons-vue'
|
|
|
-import { Material_List } from '@/api/mes/job'
|
|
|
+import { Material_List, Template_Material_Add } from '@/api/mes/job'
|
|
|
|
|
|
const canvasRef = ref(null)
|
|
|
const canvasAreaRef = ref(null)
|
|
|
@@ -777,9 +777,13 @@ onUnmounted(() => {
|
|
|
document.removeEventListener('click', handleGlobalClick)
|
|
|
})
|
|
|
|
|
|
-// 保存模版
|
|
|
-const saveTemplate = () => {
|
|
|
- // 构建模版数据
|
|
|
+// 保存模版(生成模版)
|
|
|
+const saveTemplate = async () => {
|
|
|
+ if (!layers.value.length) {
|
|
|
+ ElMessage.warning('请先添加图片或文字,再生成模版')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
const templateData = {
|
|
|
canvasWidth: canvasWidth.value,
|
|
|
canvasHeight: canvasHeight.value,
|
|
|
@@ -812,15 +816,18 @@ const saveTemplate = () => {
|
|
|
originalHeight: layer.originalHeight
|
|
|
}))
|
|
|
}
|
|
|
-
|
|
|
- // 这里可以根据实际需求发送请求到后端保存模版
|
|
|
- // 暂时使用本地存储示例
|
|
|
- console.log('保存模版数据:', templateData)
|
|
|
-
|
|
|
- // 示例: 保存到本地存储
|
|
|
- localStorage.setItem('templateDesign', JSON.stringify(templateData))
|
|
|
-
|
|
|
- ElMessage.success('模版保存成功!')
|
|
|
+
|
|
|
+ try {
|
|
|
+ const res = await Template_Material_Add(templateData)
|
|
|
+ if (res && res.code === 0) {
|
|
|
+ ElMessage.success('模版生成成功!')
|
|
|
+ } else {
|
|
|
+ ElMessage.error(res?.msg || '模版生成失败')
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.error('Template_Material_Add error:', e)
|
|
|
+ ElMessage.error('模版生成失败')
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const getLayerStyle = (layer) => {
|