|
|
@@ -8,7 +8,7 @@ import actionsMixins from '@/views/components/PictureEditor/mixin/actions/index'
|
|
|
import layerMixins from '@/views/components/PictureEditor/mixin/layer/index'
|
|
|
import colorMixins from '@/views/components/PictureEditor/mixin/color/index'
|
|
|
import editMixins from '@/views/components/PictureEditor/mixin/edit/index'
|
|
|
-import { uploadBaseImg } from '@/apis/other'
|
|
|
+import { uploadBaseImg, updateTemplateColumn } from '@/apis/other'
|
|
|
import {markRaw} from "vue";
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
import useClientStore from '@/stores/modules/client'
|
|
|
@@ -725,7 +725,7 @@ export default {
|
|
|
},
|
|
|
|
|
|
// 确认新增商品文字
|
|
|
- confirmAddGoodsText() {
|
|
|
+ async confirmAddGoodsText() {
|
|
|
if (!this.addGoodsTextForm.key.trim() || !this.addGoodsTextForm.value.trim()) {
|
|
|
this.$message.warning('请填写完整的商品文字信息')
|
|
|
return
|
|
|
@@ -738,14 +738,45 @@ export default {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- // 添加到 goods_text 数组
|
|
|
- this.goods_text.push({
|
|
|
- key: this.addGoodsTextForm.key.trim(),
|
|
|
- value: this.addGoodsTextForm.value.trim()
|
|
|
- })
|
|
|
+ try {
|
|
|
+ // 获取模板ID(编辑模式下)
|
|
|
+ const templateId = this.$route?.params?.id
|
|
|
+ if (!templateId) {
|
|
|
+ this.$message.error('无法获取模板ID,请刷新页面后重试')
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- this.addGoodsTextForm.visible = false
|
|
|
- this.$message.success('商品文字添加成功')
|
|
|
+ // 准备新的商品文字数组(包含新添加的)
|
|
|
+ const newGoodsText = [
|
|
|
+ ...this.goods_text,
|
|
|
+ {
|
|
|
+ key: this.addGoodsTextForm.key.trim(),
|
|
|
+ value: this.addGoodsTextForm.value.trim()
|
|
|
+ }
|
|
|
+ ]
|
|
|
+
|
|
|
+ // 调用接口更新商品文字字段
|
|
|
+ const response = await updateTemplateColumn({
|
|
|
+ id: templateId,
|
|
|
+ template_excel_headers: newGoodsText
|
|
|
+ })
|
|
|
+
|
|
|
+ if (response.data?.code === 0) {
|
|
|
+ // 接口调用成功,更新本地数据
|
|
|
+ this.goods_text.push({
|
|
|
+ key: this.addGoodsTextForm.key.trim(),
|
|
|
+ value: this.addGoodsTextForm.value.trim()
|
|
|
+ })
|
|
|
+
|
|
|
+ this.addGoodsTextForm.visible = false
|
|
|
+ this.$message.success('商品文字添加成功')
|
|
|
+ } else {
|
|
|
+ this.$message.error(response.data?.msg || '更新商品文字失败')
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('更新商品文字失败:', error)
|
|
|
+ this.$message.error('更新商品文字失败,请稍后重试')
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|