Ver código fonte

feat(config): 添加复制配置功能

- 在配置列表中新增复制配置按钮
- 实现复制配置时清空原配置ID逻辑
- 优化表单奖励时间处理逻辑
- 统一弹窗标题为"复制投放设置"
- 保留原有编辑和查看功能不受影响
fugui001 4 dias atrás
pai
commit
3cf010cfa4
1 arquivos alterados com 24 adições e 2 exclusões
  1. 24 2
      src/views/system/business/config/index.vue

+ 24 - 2
src/views/system/business/config/index.vue

@@ -119,7 +119,12 @@
                 投放配置
               </el-button>
             </el-tooltip>
-
+            <el-tooltip content="复制配置" placement="top">
+              <el-button link type="success" size="small" @click="handleCopyUpdate(scope.row, 'edit')" v-hasPermi="['business:config:edit']">
+                <el-icon><Setting /></el-icon>
+                复制配置
+              </el-button>
+            </el-tooltip>
             <!-- 停止按钮 -->
             <!-- 动态:停止 或 开始 按钮 -->
             <template v-if="scope.row.enabled">
@@ -386,7 +391,24 @@ const handleUpdate = async (row, action = 'edit') => {
 
   dialog.visible = true;
 };
-
+const handleCopyUpdate = async (row, action = 'edit') => {
+  reset();
+  resetFormPrize();
+  mode.value = action; // 设置模式
+  dialog.title = action === 'view' ? '复制投放设置' : '复制投放设置';
+  const _id = row?.id || ids.value[0];
+  const res = await getConfig(_id);
+  res.data.id = null;
+  // 1. 赋值 form
+  Object.assign(form.value, res.data);
+  // 2. 处理 execTimes -> formPrize.rewards
+  if (res.data.execTimes && Array.isArray(res.data.execTimes)) {
+    formPrize.rewards = res.data.execTimes.filter((time) => time).map((time) => ({ execDates: time }));
+  } else {
+    formPrize.rewards = [{ execDates: '' }]; // 默认一个空行
+  }
+  dialog.visible = true;
+};
 /** 提交按钮 */
 const submitForm = () => {
   configFormRef.value?.validate(async (valid: boolean) => {