| | |
| | | private String benchmarkUrl; |
| | | private String auditor; |
| | | private String auditorName; |
| | | private String csId; |
| | | |
| | | public String getContractId() { |
| | | return contractId; |
| | |
| | | public void setAuditorName(String auditorName) { |
| | | this.auditorName = auditorName; |
| | | } |
| | | |
| | | public String getCsId() { |
| | | return csId; |
| | | } |
| | | |
| | | public void setCsId(String csId) { |
| | | this.csId = csId; |
| | | } |
| | | } |
| | |
| | | } else { |
| | | SemanticWord copy = new SemanticWord(); |
| | | BeanUtils.copyProperties(copy, importParam); |
| | | if (copy.getChanger() == null || copy.getChanger().isEmpty()) { |
| | | return Result.error("文案编辑不能为空!"); |
| | | } |
| | | copy.setContractId(importParam.getContractId()); |
| | | copy.setBrand(data.getBrand()); |
| | | copy.setCategoryOne(data.getCategory()); |
| | | copy.setWord(data.getSemanticQuestion()); |
| | | copy.setOutWord(data.getLeakWord()); |
| | | QueryWrapper qw = new QueryWrapper<SysUser>(); |
| | | qw.eq("realName", data.getCreator()); |
| | | Page result = (Page) sysUserService.queryPageList(req, qw, 2, 1).getResult(); |
| | | if (result.getTotal() != 1) { |
| | | return Result.error("未查询到用户:" + data.getCreator()); |
| | | } |
| | | String userId = ((SysUser)(result).getRecords().get(0)).getId(); |
| | | copy.setChanger(userId); |
| | | // QueryWrapper qw = new QueryWrapper<SysUser>(); |
| | | // qw.eq("realName", data.getCreator()); |
| | | // Page result = (Page) sysUserService.queryPageList(req, qw, 2, 1).getResult(); |
| | | // if (result.getTotal() != 1) { |
| | | // return Result.error("未查询到用户:" + data.getCreator()); |
| | | // } |
| | | // String userId = ((SysUser)(result).getRecords().get(0)).getId(); |
| | | // copy.setChanger(userId); |
| | | semanticWords.add(copy); |
| | | } |
| | | } |
| | |
| | | @RequiresPermissions("contract:contract:batchGenerateCopy") |
| | | @RequestMapping(value = "/batchGenerateCopy", method = RequestMethod.POST) |
| | | public Result<?> batchGenerateCopy(@RequestBody ContractParam cp) { |
| | | if (cp.getCsId() == null){ |
| | | cp.setCsId("2020795745607319553"); |
| | | } |
| | | if (cp.getContractId().isEmpty()) { |
| | | return Result.error("文案编号不能为空"); |
| | | } else if (cp.getFileName().isEmpty()) { |
| | |
| | | return Result.error("该合同不存在语义词"); |
| | | } else { |
| | | // 调用异步方法执行实际生成逻辑 |
| | | copywritingAsyncService.asyncBatchGenerateCopy( |
| | | cp.getContractId(), list, cp.getFileName(), cp.getYoushang(), |
| | | cp.getBenchmarkUrl(),cp.getAuditor(), cp.getAuditorName() |
| | | ); |
| | | copywritingAsyncService.asyncBatchGenerateCopy(list, cp); |
| | | // 立即返回响应,不等待生成完成 |
| | | return Result.OK("开始生成,任务已提交至后台处理"); |
| | | } |
| | |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.modules.demo.contract.controller.ContractParam; |
| | | import org.jeecg.modules.demo.contract.entity.SemanticWord; |
| | | import org.jeecg.modules.demo.copywriting.entity.CopyGenerateTask; |
| | | import org.jeecg.modules.demo.copywriting.entity.Copywriting; |
| | | import org.jeecg.modules.demo.copywriting.service.ICopywritingService; |
| | | import org.jeecg.modules.demo.copywriting.service.impl.CopyGenerateTaskServiceImpl; |
| | | import org.jeecg.modules.demo.copywritingScheme.entity.CopywritingScheme; |
| | | import org.jeecg.modules.demo.copywritingScheme.service.ICopywritingSchemeService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private CopywritingController copywritingController; |
| | | |
| | | @Autowired |
| | | private ICopywritingSchemeService copywritingSchemeService; |
| | | @Autowired |
| | | public ICopywritingService copywritingService; |
| | | @Async("copywritingAsyncExecutor") |
| | | public void asyncBatchGenerateCopy(String contractId, List<SemanticWord> semanticWords, |
| | | String fileName, String youshang, |
| | | String benchmarkUrl, |
| | | String auditor, String auditorName) { |
| | | public void asyncBatchGenerateCopy(List<SemanticWord> semanticWords, ContractParam cp) { |
| | | // 1. 生成唯一任务ID,创建待处理任务 |
| | | String taskId = UUID.randomUUID().toString().replace("-", ""); |
| | | CopyGenerateTask task = new CopyGenerateTask(); |
| | | task.setId(taskId); |
| | | task.setContractId(contractId); |
| | | task.setContractId(cp.getContractId()); |
| | | task.setStatus("PENDING"); |
| | | taskService.save(task); |
| | | |
| | |
| | | taskService.updateById(task); |
| | | |
| | | // 3. 执行实际的文案生成逻辑(你的核心业务) |
| | | System.out.println("开始处理合同[" + contractId + "]的文案生成"); |
| | | System.out.println("开始处理合同[" + cp.getContractId() + "]的文案生成"); |
| | | for (SemanticWord semanticWord : semanticWords) { |
| | | Copywriting copywriting = new Copywriting(); |
| | | Result title = copywritingController.getResult(semanticWord.getOutWord(), |
| | |
| | | } |
| | | copywriting.setStatus("1"); |
| | | copywriting.setWordId(semanticWord.getId()); |
| | | CopywritingScheme copywritingScheme = new CopywritingScheme(); |
| | | copywritingScheme.setId(cp.getCsId()); |
| | | Result text = copywritingController.getResult( |
| | | fileName, |
| | | benchmarkUrl, |
| | | cp.getFileName(), |
| | | cp.getBenchmarkUrl(), |
| | | cp.getBenchmarkUrl(), |
| | | semanticWord.getOutWord(), |
| | | youshang, |
| | | cp.getYoushang(), |
| | | semanticWord.getWord(), |
| | | "e9ca23d68d884d4ebb19d07889727dae"); |
| | | "e9ca23d68d884d4ebb19d07889727dae",copywritingScheme); |
| | | if (text.isSuccess()) { |
| | | copywriting.setText(text.getResult().toString()); |
| | | } else { |
| | | throw new IllegalArgumentException("生成失败!"+text.getResult().toString()); |
| | | } |
| | | copywriting.setAuditer(auditor); |
| | | copywriting.setAuditer(cp.getAuditor()); |
| | | copywriting.setOutStatus("1"); |
| | | copywriting.setCreateBy(auditorName); |
| | | copywriting.setCreateBy(cp.getAuditorName()); |
| | | copywriting.setFileName(cp.getFileName()); |
| | | copywriting.setUrlName(cp.getBenchmarkUrl()); |
| | | copywritingService.save(copywriting); |
| | | } |
| | | // 假设生成成功,这里可以记录生成结果 |
| | | task.setStatus("SUCCESS"); |
| | | task.setMessage("文案生成完成,共生成" + semanticWords.size() + "条"); |
| | | task.setFinishTime(new Date()); |
| | | System.out.println("完成处理合同[" + contractId + "]的文案生成"); |
| | | System.out.println("完成处理合同[" + cp.getContractId() + "]的文案生成"); |
| | | |
| | | } catch (Exception e) { |
| | | // 4. 异常时更新为失败状态,记录原因 |
| | |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import opennlp.tools.dictionary.serializer.Entry; |
| | | import org.jeecg.modules.demo.copywritingScheme.entity.CopywritingScheme; |
| | | import org.jeecg.modules.demo.copywritingScheme.service.ICopywritingSchemeService; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | import org.jeecg.modules.system.service.ISysUserService; |
| | | import org.jetbrains.annotations.NotNull; |
| | |
| | | private ISemanticWordService semanticWordService;; |
| | | @Autowired |
| | | private ISysUserService sysUserService; |
| | | |
| | | |
| | | @Autowired |
| | | private ICopywritingSchemeService copywritingSchemeService; |
| | | /** |
| | | * 分页列表查询 |
| | | * |
| | |
| | | @RequiresPermissions("copywriting:copywriting:aiCreateCopyWriting") |
| | | @RequestMapping(value = "/aiCreateCopyWriting", method = RequestMethod.POST) |
| | | public Result<?> aiCreateCopyWriting( |
| | | @RequestParam("jianli") String jianli, |
| | | @RequestParam(name = "file", required = false) String jianli, |
| | | @RequestParam(name = "url", required = false) String jianli2, |
| | | @RequestParam String wenanyaoqiu, |
| | | @RequestParam String louchu, |
| | | @RequestParam String youshang, |
| | | @RequestParam String wenti, |
| | | @RequestParam String user) { |
| | | return getResult(jianli, wenanyaoqiu, louchu, youshang, wenti, user); |
| | | @RequestParam String user, |
| | | @RequestParam String csId) { |
| | | if (csId == null){ |
| | | csId = "2020795745607319553"; |
| | | } |
| | | CopywritingScheme copywritingScheme = new CopywritingScheme(); |
| | | copywritingScheme.setId(csId); |
| | | return getResult(jianli, jianli2, wenanyaoqiu, louchu, youshang, wenti, user, copywritingScheme); |
| | | } |
| | | |
| | | public Result<?> getResult(String jianli, String wenanyaoqiu, String louchu, String youshang, String wenti, String user) { |
| | | if (jianli == null || jianli.equals("")) { |
| | | return Result.error("请选择文件"); |
| | | public Result<?> getResult(String jianli, String jianli2, String wenanyaoqiu, String louchu, String youshang, String wenti, String user, CopywritingScheme cs) { |
| | | QueryWrapper<CopywritingScheme> copywritingSchemeQueryWrapper = new QueryWrapper<>(); |
| | | |
| | | if (cs.getId() == null){ |
| | | cs.setId("2020795745607319553"); |
| | | } |
| | | copywritingSchemeQueryWrapper.eq("id", cs.getId()); |
| | | List<CopywritingScheme> list = copywritingSchemeService.list(copywritingSchemeQueryWrapper); |
| | | if(list.size()==0) { |
| | | return Result.error("方案不存在"); |
| | | } else { |
| | | cs = list.get(0); |
| | | } |
| | | // 配置信息 |
| | | String serverFileRoot = uploadPath; |
| | | String workflowUrl = "http://14.103.174.44/v1/workflows/run"; |
| | | String fileUploadUrl = "http://14.103.174.44/v1/files/upload"; // 文件上传接口(假设) |
| | | String authToken = "app-J1Tqytg0ZetcrVTF2fVHHY8B"; |
| | | String workflowUrl = cs.getWorkflowUrl(); |
| | | String fileUploadUrl = cs.getFileUploadUrl(); // 文件上传接口(假设) |
| | | String authToken = cs.getAuthToken(); |
| | | String userId = user; |
| | | String appId = "cf85fe4d-b76b-4c4c-801a-1336c880d473"; |
| | | String appId = cs.getAppId(); |
| | | |
| | | try { |
| | | // 步骤1:上传简历文件,获取 upload_file_id 列表 |
| | | List<String> jianliFileList = Arrays.asList(jianli.split(",")); |
| | | List<String> jianliFileIds = new ArrayList<>(); |
| | | for (String fileName : jianliFileList) { |
| | | // 修正:只过滤路径遍历字符,保留合法的 / |
| | | String safeFileName = File.separator + fileName.trim() |
| | | // 过滤 ../ 和 ./ 序列(防止访问上级目录) |
| | | .replaceAll("\\.\\./", "") |
| | | .replaceAll("\\./", ""); |
| | | Map<String, Object> inputs = new HashMap<>(); |
| | | if (jianli != null) { |
| | | // 步骤2:构建 inputs 参数(按接口要求格式) |
| | | List<String> jianliFileList = Arrays.asList(jianli.split(",")); |
| | | if (jianliFileList == null || jianliFileList.isEmpty()) { |
| | | // 步骤1:上传简历文件,获取 upload_file_id 列表 |
| | | List<String> jianliFileIds = new ArrayList<>(); |
| | | for (String fileName : jianliFileList) { |
| | | // 修正:只过滤路径遍历字符,保留合法的 / |
| | | String safeFileName = File.separator + fileName.trim() |
| | | // 过滤 ../ 和 ./ 序列(防止访问上级目录) |
| | | .replaceAll("\\.\\./", "") |
| | | .replaceAll("\\./", ""); |
| | | |
| | | // 进一步安全校验:确保拼接后的文件路径在服务器根目录下(核心安全措施) |
| | | File file = new File(serverFileRoot + safeFileName); |
| | | String canonicalPath = file.getCanonicalPath(); // 获取标准化路径(自动解析 ../ 等) |
| | | String canonicalRootPath = new File(serverFileRoot).getCanonicalPath(); |
| | | File file = new File(serverFileRoot + safeFileName); |
| | | String canonicalPath = file.getCanonicalPath(); // 获取标准化路径(自动解析 ../ 等) |
| | | String canonicalRootPath = new File(serverFileRoot).getCanonicalPath(); |
| | | |
| | | // 校验:如果文件路径不在服务器根目录下,视为非法请求 |
| | | if (!canonicalPath.startsWith(canonicalRootPath)) { |
| | | throw new RuntimeException("非法文件访问:" + fileName); |
| | | } |
| | | if (!canonicalPath.startsWith(canonicalRootPath)) { |
| | | throw new RuntimeException("非法文件访问:" + fileName); |
| | | } |
| | | |
| | | // 再判断文件是否存在 |
| | | if (!file.exists() || !file.isFile()) { |
| | | return Result.error("服务器不存在文件:" + safeFileName + ",路径:" + file.getAbsolutePath()); |
| | | if (!file.exists() || !file.isFile()) { |
| | | return Result.error("服务器不存在文件:" + safeFileName + ",路径:" + file.getAbsolutePath()); |
| | | } |
| | | // 调用文件上传接口,获取 upload_file_id |
| | | String fileId = uploadFileToServer(file, fileUploadUrl, authToken); |
| | | jianliFileIds.add(fileId); |
| | | } |
| | | |
| | | |
| | | // 处理简历文件(jianli 是 variable_name,对应接口的 {variable_name}) |
| | | if (!jianliFileIds.isEmpty()) { |
| | | // 若支持多个文件,可能需要数组形式;单个文件则直接放对象 |
| | | List<Map<String, String>> jianliFiles = new ArrayList<>(); |
| | | for (String fileId : jianliFileIds) { |
| | | Map<String, String> fileInfo = new HashMap<>(); |
| | | fileInfo.put("transfer_method", "local_file"); // 固定值,接口要求 |
| | | fileInfo.put("upload_file_id", fileId); // 上传文件返回的ID |
| | | fileInfo.put("type", "document"); // 文件类型,如 document/image 等(按接口要求) |
| | | jianliFiles.add(fileInfo); |
| | | } |
| | | inputs.put("jianli", jianliFiles); // jianli 对应 {variable_name} |
| | | } else { |
| | | inputs.put("jianli", new ArrayList<>()); // 空文件列表 |
| | | } |
| | | } |
| | | // 调用文件上传接口,获取 upload_file_id |
| | | String fileId = uploadFileToServer(file, fileUploadUrl, authToken); |
| | | jianliFileIds.add(fileId); |
| | | } |
| | | |
| | | // 步骤2:构建 inputs 参数(按接口要求格式) |
| | | Map<String, Object> inputs = new HashMap<>(); |
| | | |
| | | // 处理简历文件(jianli 是 variable_name,对应接口的 {variable_name}) |
| | | if (!jianliFileIds.isEmpty()) { |
| | | // 若支持多个文件,可能需要数组形式;单个文件则直接放对象 |
| | | List<Map<String, String>> jianliFiles = new ArrayList<>(); |
| | | for (String fileId : jianliFileIds) { |
| | | Map<String, String> fileInfo = new HashMap<>(); |
| | | fileInfo.put("transfer_method", "local_file"); // 固定值,接口要求 |
| | | fileInfo.put("upload_file_id", fileId); // 上传文件返回的ID |
| | | fileInfo.put("type", "document"); // 文件类型,如 document/image 等(按接口要求) |
| | | jianliFiles.add(fileInfo); |
| | | } |
| | | inputs.put("jianli", jianliFiles); // jianli 对应 {variable_name} |
| | | } else { |
| | | inputs.put("jianli", new ArrayList<>()); // 空文件列表 |
| | | if (jianli2 != null) { |
| | | inputs.put("jianli2", jianli2); |
| | | } |
| | | |
| | | // 添加其他文本参数 |
| | | inputs.put("benchmarkUrl", wenanyaoqiu); |
| | | inputs.put("louchu", louchu); |
| | |
| | | // 连接超时:建立TCP连接的超时时间,单位毫秒(建议设5秒) |
| | | factory.setConnectTimeout(5000); |
| | | // 读取超时:等待服务端响应数据的超时时间,单位毫秒(根据接口耗时调整,这里设30秒) |
| | | factory.setReadTimeout(100000); |
| | | factory.setReadTimeout(200000); |
| | | // 步骤4:调用工作流接口 |
| | | RestTemplate restTemplate = new RestTemplate(factory); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | |
| | | |
| | | @TableField(exist = false) |
| | | private String contractId; |
| | | /**方案编号*/ |
| | | @Excel(name = "方案编号", width = 15) |
| | | @Schema(description = "方案编号") |
| | | private java.lang.String schemeId; |
| | | /**生成文案文件名*/ |
| | | @Excel(name = "生成文案文件名", width = 15) |
| | | @Schema(description = "生成文案文件名") |
| | | private java.lang.String fileName; |
| | | /**生成文案url*/ |
| | | @Excel(name = "生成文案url", width = 15) |
| | | @Schema(description = "生成文案url") |
| | | private java.lang.String urlName; |
| | | } |
| New file |
| | |
| | | package org.jeecg.modules.demo.copywritingScheme.controller; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLDecoder; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.common.system.query.QueryRuleEnum; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.demo.copywritingScheme.entity.CopywritingScheme; |
| | | import org.jeecg.modules.demo.copywritingScheme.service.ICopywritingSchemeService; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import org.jeecgframework.poi.excel.ExcelImportUtil; |
| | | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
| | | import org.jeecgframework.poi.excel.entity.ExportParams; |
| | | import org.jeecgframework.poi.excel.entity.ImportParams; |
| | | import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | import com.alibaba.fastjson.JSON; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | /** |
| | | * @Description: 文案生成方案 |
| | | * @Author: jeecg-boot |
| | | * @Date: 2026-02-09 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Tag(name="文案生成方案") |
| | | @RestController |
| | | @RequestMapping("/copywritingScheme/copywritingScheme") |
| | | @Slf4j |
| | | public class CopywritingSchemeController extends JeecgController<CopywritingScheme, ICopywritingSchemeService> { |
| | | @Autowired |
| | | private ICopywritingSchemeService copywritingSchemeService; |
| | | |
| | | /** |
| | | * 分页列表查询 |
| | | * |
| | | * @param copywritingScheme |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "文案生成方案-分页列表查询") |
| | | @Operation(summary="文案生成方案-分页列表查询") |
| | | @GetMapping(value = "/list") |
| | | public Result<IPage<CopywritingScheme>> queryPageList(CopywritingScheme copywritingScheme, |
| | | @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, |
| | | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | |
| | | |
| | | QueryWrapper<CopywritingScheme> queryWrapper = QueryGenerator.initQueryWrapper(copywritingScheme, req.getParameterMap()); |
| | | Page<CopywritingScheme> page = new Page<CopywritingScheme>(pageNo, pageSize); |
| | | IPage<CopywritingScheme> pageList = copywritingSchemeService.page(page, queryWrapper); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param copywritingScheme |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "文案生成方案-添加") |
| | | @Operation(summary="文案生成方案-添加") |
| | | @RequiresPermissions("copywritingScheme:copywriting_scheme:add") |
| | | @PostMapping(value = "/add") |
| | | public Result<String> add(@RequestBody CopywritingScheme copywritingScheme) { |
| | | copywritingSchemeService.save(copywritingScheme); |
| | | |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 编辑 |
| | | * |
| | | * @param copywritingScheme |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "文案生成方案-编辑") |
| | | @Operation(summary="文案生成方案-编辑") |
| | | @RequiresPermissions("copywritingScheme:copywriting_scheme:edit") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) |
| | | public Result<String> edit(@RequestBody CopywritingScheme copywritingScheme) { |
| | | copywritingSchemeService.updateById(copywritingScheme); |
| | | return Result.OK("编辑成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id删除 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "文案生成方案-通过id删除") |
| | | @Operation(summary="文案生成方案-通过id删除") |
| | | @RequiresPermissions("copywritingScheme:copywriting_scheme:delete") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<String> delete(@RequestParam(name="id",required=true) String id) { |
| | | copywritingSchemeService.removeById(id); |
| | | return Result.OK("删除成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "文案生成方案-批量删除") |
| | | @Operation(summary="文案生成方案-批量删除") |
| | | @RequiresPermissions("copywritingScheme:copywriting_scheme:deleteBatch") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { |
| | | this.copywritingSchemeService.removeByIds(Arrays.asList(ids.split(","))); |
| | | return Result.OK("批量删除成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id查询 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "文案生成方案-通过id查询") |
| | | @Operation(summary="文案生成方案-通过id查询") |
| | | @GetMapping(value = "/queryById") |
| | | public Result<CopywritingScheme> queryById(@RequestParam(name="id",required=true) String id) { |
| | | CopywritingScheme copywritingScheme = copywritingSchemeService.getById(id); |
| | | if(copywritingScheme==null) { |
| | | return Result.error("未找到对应数据"); |
| | | } |
| | | return Result.OK(copywritingScheme); |
| | | } |
| | | |
| | | /** |
| | | * 导出excel |
| | | * |
| | | * @param request |
| | | * @param copywritingScheme |
| | | */ |
| | | @RequiresPermissions("copywritingScheme:copywriting_scheme:exportXls") |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, CopywritingScheme copywritingScheme) { |
| | | return super.exportXls(request, copywritingScheme, CopywritingScheme.class, "文案生成方案"); |
| | | } |
| | | |
| | | /** |
| | | * 通过excel导入数据 |
| | | * |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | @RequiresPermissions("copywritingScheme:copywriting_scheme:importExcel") |
| | | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | return super.importExcel(request, response, CopywritingScheme.class); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package org.jeecg.modules.demo.copywritingScheme.entity; |
| | | |
| | | import java.io.Serializable; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.Date; |
| | | import java.math.BigDecimal; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import org.jeecg.common.constant.ProvinceCityArea; |
| | | import org.jeecg.common.util.SpringContextUtils; |
| | | import lombok.Data; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.jeecgframework.poi.excel.annotation.Excel; |
| | | import org.jeecg.common.aspect.annotation.Dict; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | /** |
| | | * @Description: 文案生成方案 |
| | | * @Author: jeecg-boot |
| | | * @Date: 2026-02-09 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Data |
| | | @TableName("copywriting_scheme") |
| | | @Accessors(chain = true) |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @Schema(description="文案生成方案") |
| | | public class CopywritingScheme implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /**主键*/ |
| | | @TableId(type = IdType.ASSIGN_ID) |
| | | @Schema(description = "主键") |
| | | private String id; |
| | | /**创建人*/ |
| | | @Schema(description = "创建人") |
| | | private String createBy; |
| | | /**创建日期*/ |
| | | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | @Schema(description = "创建日期") |
| | | private Date createTime; |
| | | /**更新人*/ |
| | | @Schema(description = "更新人") |
| | | private String updateBy; |
| | | /**更新日期*/ |
| | | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | @Schema(description = "更新日期") |
| | | private Date updateTime; |
| | | /**所属部门*/ |
| | | @Schema(description = "所属部门") |
| | | private String sysOrgCode; |
| | | /**方案名称*/ |
| | | @Excel(name = "方案名称", width = 15) |
| | | @Schema(description = "方案名称") |
| | | private String schemeName; |
| | | /**API服务器*/ |
| | | @Excel(name = "API服务器", width = 15) |
| | | @Schema(description = "API服务器") |
| | | private String workflowUrl; |
| | | /**API服务器文件上传地址*/ |
| | | @Excel(name = "API服务器文件上传地址", width = 15) |
| | | @Schema(description = "API服务器文件上传地址") |
| | | private String fileUploadUrl; |
| | | /**API 密钥*/ |
| | | @Excel(name = "API 密钥", width = 15) |
| | | @Schema(description = "API 密钥") |
| | | private String authToken; |
| | | /**智能体编号*/ |
| | | @Excel(name = "智能体编号", width = 15) |
| | | @Schema(description = "智能体编号") |
| | | private String appId; |
| | | } |
| New file |
| | |
| | | package org.jeecg.modules.demo.copywritingScheme.mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.jeecg.modules.demo.copywritingScheme.entity.CopywritingScheme; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * @Description: 文案生成方案 |
| | | * @Author: jeecg-boot |
| | | * @Date: 2026-02-09 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface CopywritingSchemeMapper extends BaseMapper<CopywritingScheme> { |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.jeecg.modules.demo.copywritingScheme.mapper.CopywritingSchemeMapper"> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | package org.jeecg.modules.demo.copywritingScheme.service; |
| | | |
| | | import org.jeecg.modules.demo.copywritingScheme.entity.CopywritingScheme; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | /** |
| | | * @Description: 文案生成方案 |
| | | * @Author: jeecg-boot |
| | | * @Date: 2026-02-09 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface ICopywritingSchemeService extends IService<CopywritingScheme> { |
| | | |
| | | } |
| New file |
| | |
| | | package org.jeecg.modules.demo.copywritingScheme.service.impl; |
| | | |
| | | import org.jeecg.modules.demo.copywritingScheme.entity.CopywritingScheme; |
| | | import org.jeecg.modules.demo.copywritingScheme.mapper.CopywritingSchemeMapper; |
| | | import org.jeecg.modules.demo.copywritingScheme.service.ICopywritingSchemeService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | |
| | | /** |
| | | * @Description: 文案生成方案 |
| | | * @Author: jeecg-boot |
| | | * @Date: 2026-02-09 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service |
| | | public class CopywritingSchemeServiceImpl extends ServiceImpl<CopywritingSchemeMapper, CopywritingScheme> implements ICopywritingSchemeService { |
| | | |
| | | } |
| New file |
| | |
| | | <template> |
| | | <view> |
| | | <!--标题和返回--> |
| | | <cu-custom :bgColor="NavBarColor" isBack :backRouterName="backRouteName"> |
| | | <block slot="backText">返回</block> |
| | | <block slot="content">文案生成方案</block> |
| | | </cu-custom> |
| | | <!--表单区域--> |
| | | <view> |
| | | <form> |
| | | <view class="cu-form-group"> |
| | | <view class="flex align-center"> |
| | | <view class="title"><text space="ensp">方案名称:</text></view> |
| | | <input placeholder="请输入方案名称" v-model="model.schemeName"/> |
| | | </view> |
| | | </view> |
| | | <view class="cu-form-group"> |
| | | <view class="flex align-center"> |
| | | <view class="title"><text space="ensp">API服务器:</text></view> |
| | | <input placeholder="请输入API服务器" v-model="model.workflowUrl"/> |
| | | </view> |
| | | </view> |
| | | <view class="cu-form-group"> |
| | | <view class="flex align-center"> |
| | | <view class="title"><text space="ensp">API服务器文件上传地址:</text></view> |
| | | <input placeholder="请输入API服务器文件上传地址" v-model="model.fileUploadUrl"/> |
| | | </view> |
| | | </view> |
| | | <view class="cu-form-group"> |
| | | <view class="flex align-center"> |
| | | <view class="title"><text space="ensp">API 密钥:</text></view> |
| | | <input placeholder="请输入API 密钥" v-model="model.authToken"/> |
| | | </view> |
| | | </view> |
| | | <view class="cu-form-group"> |
| | | <view class="flex align-center"> |
| | | <view class="title"><text space="ensp">智能体编号:</text></view> |
| | | <input placeholder="请输入智能体编号" v-model="model.appId"/> |
| | | </view> |
| | | </view> |
| | | <view class="padding"> |
| | | <button class="cu-btn block bg-blue margin-tb-sm lg" @click="onSubmit"> |
| | | <text v-if="loading" class="cuIcon-loading2 cuIconfont-spin"></text>提交 |
| | | </button> |
| | | </view> |
| | | </form> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | import myDate from '@/components/my-componets/my-date.vue' |
| | | |
| | | export default { |
| | | name: "CopywritingSchemeForm", |
| | | components:{ myDate }, |
| | | props:{ |
| | | formData:{ |
| | | type:Object, |
| | | default:()=>{}, |
| | | required:false |
| | | } |
| | | }, |
| | | data(){ |
| | | return { |
| | | CustomBar: this.CustomBar, |
| | | NavBarColor: this.NavBarColor, |
| | | loading:false, |
| | | model: {}, |
| | | backRouteName:'index', |
| | | url: { |
| | | queryById: "/copywritingScheme/copywritingScheme/queryById", |
| | | add: "/copywritingScheme/copywritingScheme/add", |
| | | edit: "/copywritingScheme/copywritingScheme/edit", |
| | | }, |
| | | } |
| | | }, |
| | | created(){ |
| | | this.initFormData(); |
| | | }, |
| | | methods:{ |
| | | initFormData(){ |
| | | if(this.formData){ |
| | | let dataId = this.formData.dataId; |
| | | this.$http.get(this.url.queryById,{params:{id:dataId}}).then((res)=>{ |
| | | if(res.data.success){ |
| | | console.log("表单数据",res); |
| | | this.model = res.data.result; |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | onSubmit() { |
| | | let myForm = {...this.model}; |
| | | this.loading = true; |
| | | let url = myForm.id?this.url.edit:this.url.add; |
| | | this.$http.post(url,myForm).then(res=>{ |
| | | console.log("res",res) |
| | | this.loading = false |
| | | this.$Router.push({name:this.backRouteName}) |
| | | }).catch(()=>{ |
| | | this.loading = false |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | </script> |
| New file |
| | |
| | | <template> |
| | | <view> |
| | | <!--标题和返回--> |
| | | <cu-custom :bgColor="NavBarColor" isBack> |
| | | <block slot="backText">返回</block> |
| | | <block slot="content">文案生成方案</block> |
| | | </cu-custom> |
| | | <!--滚动加载列表--> |
| | | <mescroll-body ref="mescrollRef" bottom="88" @init="mescrollInit" :up="upOption" :down="downOption" @down="downCallback" @up="upCallback"> |
| | | <view class="cu-list menu"> |
| | | <view class="cu-item" v-for="(item,index) in list" :key="index" @click="goHome"> |
| | | <view class="flex" style="width:100%"> |
| | | <text class="text-lg" style="color: #000;"> |
| | | {{ item.createBy}} |
| | | </text> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </mescroll-body> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js"; |
| | | import Mixin from "@/common/mixin/Mixin.js"; |
| | | |
| | | export default { |
| | | name: '文案生成方案', |
| | | mixins: [MescrollMixin,Mixin], |
| | | data() { |
| | | return { |
| | | CustomBar:this.CustomBar, |
| | | NavBarColor:this.NavBarColor, |
| | | url: "/copywritingScheme/copywritingScheme/list", |
| | | }; |
| | | }, |
| | | methods: { |
| | | goHome(){ |
| | | this.$Router.push({name: "index"}) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| New file |
| | |
| | | import { render } from '@/common/renderUtils'; |
| | | //列表数据 |
| | | export const columns = [ |
| | | { |
| | | title: '方案名称', |
| | | align:"center", |
| | | dataIndex: 'schemeName' |
| | | }, |
| | | { |
| | | title: 'API服务器', |
| | | align:"center", |
| | | dataIndex: 'workflowUrl' |
| | | }, |
| | | { |
| | | title: 'API服务器文件上传地址', |
| | | align:"center", |
| | | dataIndex: 'fileUploadUrl' |
| | | }, |
| | | { |
| | | title: 'API 密钥', |
| | | align:"center", |
| | | dataIndex: 'authToken' |
| | | }, |
| | | { |
| | | title: '智能体编号', |
| | | align:"center", |
| | | dataIndex: 'appId' |
| | | }, |
| | | ]; |
| New file |
| | |
| | | <route lang="json5" type="page"> |
| | | { |
| | | layout: 'default', |
| | | style: { |
| | | navigationStyle: 'custom', |
| | | navigationBarTitleText: '文案生成方案', |
| | | }, |
| | | } |
| | | </route> |
| | | <template> |
| | | <PageLayout :navTitle="navTitle" :backRouteName="backRouteName"> |
| | | <scroll-view class="scrollArea" scroll-y> |
| | | <view class="form-container"> |
| | | <wd-form ref="form" :model="myFormData"> |
| | | <wd-cell-group border> |
| | | <view class="{ 'mt-14px': 0 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['schemeName']" |
| | | :label="get4Label('方案名称')" |
| | | name='schemeName' |
| | | prop='schemeName' |
| | | placeholder="请选择方案名称" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 1 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['workflowUrl']" |
| | | :label="get4Label('API服务器')" |
| | | name='workflowUrl' |
| | | prop='workflowUrl' |
| | | placeholder="请选择API服务器" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 0 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['fileUploadUrl']" |
| | | :label="get4Label('API服务器文件上传地址')" |
| | | name='fileUploadUrl' |
| | | prop='fileUploadUrl' |
| | | placeholder="请选择API服务器文件上传地址" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 1 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['authToken']" |
| | | :label="get4Label('API 密钥')" |
| | | name='authToken' |
| | | prop='authToken' |
| | | placeholder="请选择API 密钥" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 0 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['appId']" |
| | | :label="get4Label('智能体编号')" |
| | | name='appId' |
| | | prop='appId' |
| | | placeholder="请选择智能体编号" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | </wd-cell-group> |
| | | </wd-form> |
| | | </view> |
| | | </scroll-view> |
| | | <view class="footer"> |
| | | <wd-button :disabled="loading" block :loading="loading" @click="handleSubmit">提交</wd-button> |
| | | </view> |
| | | </PageLayout> |
| | | </template> |
| | | |
| | | <script lang="ts" setup> |
| | | import { onLoad } from '@dcloudio/uni-app' |
| | | import { http } from '@/utils/http' |
| | | import { useToast } from 'wot-design-uni' |
| | | import { useRouter } from '@/plugin/uni-mini-router' |
| | | import { ref, onMounted, computed,reactive } from 'vue' |
| | | import OnlineImage from '@/components/online/view/online-image.vue' |
| | | import OnlineFile from '@/components/online/view/online-file.vue' |
| | | import OnlineFileCustom from '@/components/online/view/online-file-custom.vue' |
| | | import OnlineSelect from '@/components/online/view/online-select.vue' |
| | | import OnlineTime from '@/components/online/view/online-time.vue' |
| | | import OnlineDate from '@/components/online/view/online-date.vue' |
| | | import OnlineRadio from '@/components/online/view/online-radio.vue' |
| | | import OnlineCheckbox from '@/components/online/view/online-checkbox.vue' |
| | | import OnlineMulti from '@/components/online/view/online-multi.vue' |
| | | import OnlinePopupLinkRecord from '@/components/online/view/online-popup-link-record.vue' |
| | | import OnlinePca from '@/components/online/view/online-pca.vue' |
| | | import SelectDept from '@/components/SelectDept/SelectDept.vue' |
| | | import SelectUser from '@/components/SelectUser/SelectUser.vue' |
| | | import {duplicateCheck} from "@/service/api"; |
| | | defineOptions({ |
| | | name: 'CopywritingSchemeForm', |
| | | options: { |
| | | styleIsolation: 'shared', |
| | | }, |
| | | }) |
| | | const toast = useToast() |
| | | const router = useRouter() |
| | | const form = ref(null) |
| | | // 定义响应式数据 |
| | | const myFormData = reactive({}) |
| | | const loading = ref(false) |
| | | const navTitle = ref('新增') |
| | | const dataId = ref('') |
| | | const backRouteName = ref('CopywritingSchemeList') |
| | | // 定义 initForm 方法 |
| | | const initForm = (item) => { |
| | | console.log('initForm item', item) |
| | | if(item?.dataId){ |
| | | dataId.value = item.dataId; |
| | | navTitle.value = item.dataId?'编辑':'新增'; |
| | | initData(); |
| | | } |
| | | } |
| | | // 初始化数据 |
| | | const initData = () => { |
| | | http.get("/copywritingScheme/copywritingScheme/queryById",{id:dataId.value}).then((res) => { |
| | | if (res.success) { |
| | | let obj = res.result |
| | | Object.assign(myFormData, { ...obj }) |
| | | }else{ |
| | | toast.error(res?.message || '表单加载失败!') |
| | | } |
| | | }) |
| | | } |
| | | const handleSuccess = () => { |
| | | uni.$emit('refreshList'); |
| | | router.back() |
| | | } |
| | | /** |
| | | * 校验唯一 |
| | | * @param values |
| | | * @returns {boolean} |
| | | */ |
| | | async function fieldCheck(values: any) { |
| | | const onlyField = [ |
| | | ]; |
| | | for (const field of onlyField) { |
| | | if (values[field]) { |
| | | // 仅校验有值的字段 |
| | | const res: any = await duplicateCheck({ |
| | | tableName: 'copywriting_scheme', |
| | | fieldName: field, // 使用处理后的字段名 |
| | | fieldVal: values[field], |
| | | dataId: values.id, |
| | | }); |
| | | if (!res.success) { |
| | | toast.warning(res.message); |
| | | return true; // 校验失败 |
| | | } |
| | | } |
| | | } |
| | | return false; // 校验通过 |
| | | } |
| | | // 提交表单 |
| | | const handleSubmit = async () => { |
| | | // 判断字段必填和正则 |
| | | if (await fieldCheck(myFormData)) { |
| | | return |
| | | } |
| | | let url = dataId.value?'/copywritingScheme/copywritingScheme/edit':'/copywritingScheme/copywritingScheme/add'; |
| | | form.value |
| | | .validate() |
| | | .then(({ valid, errors }) => { |
| | | if (valid) { |
| | | loading.value = true; |
| | | http.post(url,myFormData).then((res) => { |
| | | loading.value = false; |
| | | if (res.success) { |
| | | toast.success('保存成功'); |
| | | handleSuccess() |
| | | }else{ |
| | | toast.error(res?.message || '表单保存失败!') |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | .catch((error) => { |
| | | console.log(error, 'error') |
| | | loading.value = false; |
| | | }) |
| | | } |
| | | // 标题 |
| | | const get4Label = computed(() => { |
| | | return (label) => { |
| | | return label && label.length > 4 ? label.substring(0, 4) : label; |
| | | } |
| | | }) |
| | | |
| | | // 标题 |
| | | const getFormSchema = computed(() => { |
| | | return (dictTable,dictCode,dictText) => { |
| | | return { |
| | | dictCode, |
| | | dictTable, |
| | | dictText |
| | | }; |
| | | } |
| | | }) |
| | | /** |
| | | * 获取日期控件的扩展类型 |
| | | * @param picker |
| | | * @returns {string} |
| | | */ |
| | | const getDateExtendType = (picker: string) => { |
| | | let mapField = { |
| | | month: 'year-month', |
| | | year: 'year', |
| | | quarter: 'quarter', |
| | | week: 'week', |
| | | day: 'date', |
| | | } |
| | | return picker && mapField[picker] |
| | | ? mapField[picker] |
| | | : 'date' |
| | | } |
| | | //设置pop返回值 |
| | | const setFieldsValue = (data) => { |
| | | Object.assign(myFormData, {...data }) |
| | | } |
| | | // onLoad 生命周期钩子 |
| | | onLoad((option) => { |
| | | initForm(option) |
| | | }) |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .footer { |
| | | width: 100%; |
| | | padding: 10px 20px; |
| | | padding-bottom: calc(constant(safe-area-inset-bottom) + 10px); |
| | | padding-bottom: calc(env(safe-area-inset-bottom) + 10px); |
| | | } |
| | | :deep(.wd-cell__label) { |
| | | font-size: 14px; |
| | | color: #444; |
| | | } |
| | | :deep(.wd-cell__value) { |
| | | text-align: left; |
| | | } |
| | | </style> |
| New file |
| | |
| | | <route lang="json5" type="page"> |
| | | { |
| | | layout: 'default', |
| | | style: { |
| | | navigationBarTitleText: '文案生成方案', |
| | | navigationStyle: 'custom', |
| | | }, |
| | | } |
| | | </route> |
| | | <template> |
| | | <PageLayout navTitle="文案生成方案" backRouteName="index" routeMethod="pushTab"> |
| | | <view class="wrap"> |
| | | <z-paging |
| | | ref="paging" |
| | | :fixed="false" |
| | | v-model="dataList" |
| | | @query="queryList" |
| | | :default-page-size="15" |
| | | > |
| | | <template v-for="item in dataList" :key="item.id"> |
| | | <wd-swipe-action> |
| | | <view class="list" @click="handleEdit(item)"> |
| | | <template v-for="(cItem, cIndex) in columns" :key="cIndex"> |
| | | <view v-if="cIndex < 3" class="box" :style="getBoxStyle"> |
| | | <view class="field ellipsis">{{ cItem.title }}</view> |
| | | <view class="value cu-text-grey">{{ item[cItem.dataIndex] }}</view> |
| | | </view> |
| | | </template> |
| | | </view> |
| | | <template #right> |
| | | <view class="action"> |
| | | <view class="button" @click="handleAction('del', item)">删除</view> |
| | | </view> |
| | | </template> |
| | | </wd-swipe-action> |
| | | </template> |
| | | </z-paging> |
| | | <view class="add u-iconfont u-icon-add" @click="handleAdd"></view> |
| | | </view> |
| | | </PageLayout> |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | | import { ref, onMounted, computed } from 'vue' |
| | | import { http } from '@/utils/http' |
| | | import usePageList from '@/hooks/usePageList' |
| | | import {columns} from './CopywritingSchemeData'; |
| | | defineOptions({ |
| | | name: 'CopywritingSchemeList', |
| | | options: { |
| | | styleIsolation: 'shared', |
| | | } |
| | | }) |
| | | //分页加载配置 |
| | | let { toast, router, paging, dataList, queryList } = usePageList('/copywritingScheme/copywritingScheme/list'); |
| | | |
| | | //样式 |
| | | const getBoxStyle = computed(() => { |
| | | return { width: "calc(33% - 5px)" } |
| | | }) |
| | | |
| | | // 其他操作 |
| | | const handleAction = (val, item) => { |
| | | if (val == 'del') { |
| | | http.delete("/copywritingScheme/copywritingScheme/delete?id="+item.id,{id:item.id}).then((res) => { |
| | | toast.success('删除成功~') |
| | | paging.value.reload() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | // go 新增页 |
| | | const handleAdd = () => { |
| | | router.push({ |
| | | name: 'CopywritingSchemeForm' |
| | | }) |
| | | } |
| | | |
| | | //go 编辑页 |
| | | const handleEdit = (record) => { |
| | | router.push({ |
| | | name: 'CopywritingSchemeForm', |
| | | params: {dataId: record.id}, |
| | | }) |
| | | } |
| | | |
| | | onMounted(() => { |
| | | // 监听刷新列表事件 |
| | | uni.$on('refreshList', () => { |
| | | queryList(1,10) |
| | | }) |
| | | }) |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .wrap { |
| | | height: 100%; |
| | | } |
| | | :deep(.wd-swipe-action) { |
| | | margin-top: 10px; |
| | | background-color: #fff; |
| | | } |
| | | .list { |
| | | padding: 10px 10px; |
| | | width: 100%; |
| | | text-align: left; |
| | | display: flex; |
| | | justify-content: space-between; |
| | | .box { |
| | | width: 33%; |
| | | .field { |
| | | margin-bottom: 10px; |
| | | line-height: 20px; |
| | | } |
| | | } |
| | | } |
| | | .action { |
| | | width: 60px; |
| | | height: 100%; |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: center; |
| | | .button { |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: center; |
| | | flex: 1; |
| | | height: 100%; |
| | | color: #fff; |
| | | &:first-child { |
| | | background-color: #fa4350; |
| | | } |
| | | } |
| | | } |
| | | .add { |
| | | height: 70upx; |
| | | width: 70upx; |
| | | text-align: center; |
| | | line-height: 70upx; |
| | | background-color: #fff; |
| | | border-radius: 50%; |
| | | position: fixed; |
| | | bottom: 80upx; |
| | | right: 30upx; |
| | | box-shadow: 0 0 5px 2px rgba(0, 0, 0, 0.1); |
| | | color: #666; |
| | | } |
| | | </style> |
| New file |
| | |
| | | import {defHttp} from '/@/utils/http/axios'; |
| | | import { useMessage } from "/@/hooks/web/useMessage"; |
| | | |
| | | const { createConfirm } = useMessage(); |
| | | |
| | | enum Api { |
| | | list = '/copywritingScheme/copywritingScheme/list', |
| | | save='/copywritingScheme/copywritingScheme/add', |
| | | edit='/copywritingScheme/copywritingScheme/edit', |
| | | deleteOne = '/copywritingScheme/copywritingScheme/delete', |
| | | deleteBatch = '/copywritingScheme/copywritingScheme/deleteBatch', |
| | | importExcel = '/copywritingScheme/copywritingScheme/importExcel', |
| | | exportXls = '/copywritingScheme/copywritingScheme/exportXls', |
| | | } |
| | | /** |
| | | * 导出api |
| | | * @param params |
| | | */ |
| | | export const getExportUrl = Api.exportXls; |
| | | /** |
| | | * 导入api |
| | | */ |
| | | export const getImportUrl = Api.importExcel; |
| | | /** |
| | | * 列表接口 |
| | | * @param params |
| | | */ |
| | | export const list = (params) => |
| | | defHttp.get({url: Api.list, params}); |
| | | |
| | | /** |
| | | * 删除单个 |
| | | */ |
| | | export const deleteOne = (params,handleSuccess) => { |
| | | return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => { |
| | | handleSuccess(); |
| | | }); |
| | | } |
| | | /** |
| | | * 批量删除 |
| | | * @param params |
| | | */ |
| | | export const batchDelete = (params, handleSuccess) => { |
| | | createConfirm({ |
| | | iconType: 'warning', |
| | | title: '确认删除', |
| | | content: '是否删除选中数据', |
| | | okText: '确认', |
| | | cancelText: '取消', |
| | | onOk: () => { |
| | | return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => { |
| | | handleSuccess(); |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | /** |
| | | * 保存或者更新 |
| | | * @param params |
| | | */ |
| | | export const saveOrUpdate = (params, isUpdate) => { |
| | | let url = isUpdate ? Api.edit : Api.save; |
| | | return defHttp.post({url: url, params}); |
| | | } |
| New file |
| | |
| | | import {BasicColumn} from '/@/components/Table'; |
| | | import {FormSchema} from '/@/components/Table'; |
| | | import { rules} from '/@/utils/helper/validator'; |
| | | import { render } from '/@/utils/common/renderUtils'; |
| | | import { getWeekMonthQuarterYear } from '/@/utils'; |
| | | //列表数据 |
| | | export const columns: BasicColumn[] = [ |
| | | { |
| | | title: '方案名称', |
| | | align:"center", |
| | | dataIndex: 'schemeName' |
| | | }, |
| | | { |
| | | title: 'API服务器', |
| | | align:"center", |
| | | dataIndex: 'workflowUrl' |
| | | }, |
| | | { |
| | | title: 'API服务器文件上传地址', |
| | | align:"center", |
| | | dataIndex: 'fileUploadUrl' |
| | | }, |
| | | { |
| | | title: 'API 密钥', |
| | | align:"center", |
| | | dataIndex: 'authToken' |
| | | }, |
| | | { |
| | | title: '智能体编号', |
| | | align:"center", |
| | | dataIndex: 'appId' |
| | | }, |
| | | ]; |
| | | //查询数据 |
| | | export const searchFormSchema: FormSchema[] = [ |
| | | ]; |
| | | //表单数据 |
| | | export const formSchema: FormSchema[] = [ |
| | | { |
| | | label: '方案名称', |
| | | field: 'schemeName', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: 'API服务器', |
| | | field: 'workflowUrl', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: 'API服务器文件上传地址', |
| | | field: 'fileUploadUrl', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: 'API 密钥', |
| | | field: 'authToken', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: '智能体编号', |
| | | field: 'appId', |
| | | component: 'Input', |
| | | }, |
| | | // TODO 主键隐藏字段,目前写死为ID |
| | | { |
| | | label: '', |
| | | field: 'id', |
| | | component: 'Input', |
| | | show: false |
| | | }, |
| | | ]; |
| | | |
| | | // 高级查询数据 |
| | | export const superQuerySchema = { |
| | | schemeName: {title: '方案名称',order: 0,view: 'text', type: 'string',}, |
| | | workflowUrl: {title: 'API服务器',order: 1,view: 'text', type: 'string',}, |
| | | fileUploadUrl: {title: 'API服务器文件上传地址',order: 2,view: 'text', type: 'string',}, |
| | | authToken: {title: 'API 密钥',order: 3,view: 'text', type: 'string',}, |
| | | appId: {title: '智能体编号',order: 4,view: 'text', type: 'string',}, |
| | | }; |
| | | |
| | | /** |
| | | * 流程表单调用这个方法获取formSchema |
| | | * @param param |
| | | */ |
| | | export function getBpmFormSchema(_formData): FormSchema[]{ |
| | | // 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema |
| | | return formSchema; |
| | | } |
| New file |
| | |
| | | <template> |
| | | <div> |
| | | <!--引用表格--> |
| | | <BasicTable @register="registerTable" :rowSelection="rowSelection"> |
| | | <!--插槽:table标题--> |
| | | <template #tableTitle> |
| | | <a-button type="primary" v-auth="'copywritingScheme:copywriting_scheme:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> |
| | | <a-button type="primary" v-auth="'copywritingScheme:copywriting_scheme:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button> |
| | | <j-upload-button type="primary" v-auth="'copywritingScheme:copywriting_scheme:importExcel'" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button> |
| | | |
| | | <a-dropdown v-if="selectedRowKeys.length > 0"> |
| | | <template #overlay> |
| | | <a-menu> |
| | | <a-menu-item key="1" @click="batchHandleDelete"> |
| | | <Icon icon="ant-design:delete-outlined"></Icon> |
| | | 删除 |
| | | </a-menu-item> |
| | | </a-menu> |
| | | </template> |
| | | <a-button v-auth="'copywritingScheme:copywriting_scheme:deleteBatch'">批量操作 |
| | | <Icon icon="mdi:chevron-down"></Icon> |
| | | </a-button> |
| | | </a-dropdown> |
| | | <!-- 高级查询 --> |
| | | <super-query :config="superQueryConfig" @search="handleSuperQuery" /> |
| | | </template> |
| | | <!--操作栏--> |
| | | <template #action="{ record }"> |
| | | <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/> |
| | | </template> |
| | | <!--字段回显插槽--> |
| | | <template v-slot:bodyCell="{ column, record, index, text }"> |
| | | </template> |
| | | </BasicTable> |
| | | <!-- 表单区域 --> |
| | | <CopywritingSchemeModal @register="registerModal" @success="handleSuccess"></CopywritingSchemeModal> |
| | | </div> |
| | | </template> |
| | | |
| | | <script lang="ts" name="copywritingScheme-copywritingScheme" setup> |
| | | import {ref, reactive, computed, unref} from 'vue'; |
| | | import {BasicTable, useTable, TableAction} from '/@/components/Table'; |
| | | import {useModal} from '/@/components/Modal'; |
| | | import { useListPage } from '/@/hooks/system/useListPage' |
| | | import CopywritingSchemeModal from './components/CopywritingSchemeModal.vue' |
| | | import {columns, searchFormSchema, superQuerySchema} from './CopywritingScheme.data'; |
| | | import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './CopywritingScheme.api'; |
| | | import { downloadFile } from '/@/utils/common/renderUtils'; |
| | | import { useUserStore } from '/@/store/modules/user'; |
| | | import { useMessage } from '/@/hooks/web/useMessage'; |
| | | import { getDateByPicker } from '/@/utils'; |
| | | //日期个性化选择 |
| | | const fieldPickers = reactive({ |
| | | }); |
| | | const queryParam = reactive<any>({}); |
| | | const checkedKeys = ref<Array<string | number>>([]); |
| | | const userStore = useUserStore(); |
| | | const { createMessage } = useMessage(); |
| | | //注册model |
| | | const [registerModal, {openModal}] = useModal(); |
| | | //注册table数据 |
| | | const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({ |
| | | tableProps:{ |
| | | title: '文案生成方案', |
| | | api: list, |
| | | columns, |
| | | canResize:true, |
| | | formConfig: { |
| | | //labelWidth: 120, |
| | | schemas: searchFormSchema, |
| | | autoSubmitOnEnter:true, |
| | | showAdvancedButton:true, |
| | | fieldMapToNumber: [ |
| | | ], |
| | | fieldMapToTime: [ |
| | | ], |
| | | }, |
| | | actionColumn: { |
| | | width: 120, |
| | | fixed:'right' |
| | | }, |
| | | beforeFetch: (params) => { |
| | | if (params && fieldPickers) { |
| | | for (let key in fieldPickers) { |
| | | if (params[key]) { |
| | | params[key] = getDateByPicker(params[key], fieldPickers[key]); |
| | | } |
| | | } |
| | | } |
| | | return Object.assign(params, queryParam); |
| | | }, |
| | | }, |
| | | exportConfig: { |
| | | name:"文案生成方案", |
| | | url: getExportUrl, |
| | | params: queryParam, |
| | | }, |
| | | importConfig: { |
| | | url: getImportUrl, |
| | | success: handleSuccess |
| | | }, |
| | | }) |
| | | |
| | | const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext |
| | | |
| | | // 高级查询配置 |
| | | const superQueryConfig = reactive(superQuerySchema); |
| | | |
| | | /** |
| | | * 高级查询事件 |
| | | */ |
| | | function handleSuperQuery(params) { |
| | | Object.keys(params).map((k) => { |
| | | queryParam[k] = params[k]; |
| | | }); |
| | | reload(); |
| | | } |
| | | /** |
| | | * 新增事件 |
| | | */ |
| | | function handleAdd() { |
| | | openModal(true, { |
| | | isUpdate: false, |
| | | showFooter: true, |
| | | }); |
| | | } |
| | | /** |
| | | * 编辑事件 |
| | | */ |
| | | function handleEdit(record: Recordable) { |
| | | openModal(true, { |
| | | record, |
| | | isUpdate: true, |
| | | showFooter: true, |
| | | }); |
| | | } |
| | | /** |
| | | * 详情 |
| | | */ |
| | | function handleDetail(record: Recordable) { |
| | | openModal(true, { |
| | | record, |
| | | isUpdate: true, |
| | | showFooter: false, |
| | | }); |
| | | } |
| | | /** |
| | | * 删除事件 |
| | | */ |
| | | async function handleDelete(record) { |
| | | await deleteOne({id: record.id}, handleSuccess); |
| | | } |
| | | /** |
| | | * 批量删除事件 |
| | | */ |
| | | async function batchHandleDelete() { |
| | | await batchDelete({ids: selectedRowKeys.value}, handleSuccess); |
| | | } |
| | | /** |
| | | * 成功回调 |
| | | */ |
| | | function handleSuccess() { |
| | | (selectedRowKeys.value = []) && reload(); |
| | | } |
| | | /** |
| | | * 操作栏 |
| | | */ |
| | | function getTableAction(record){ |
| | | return [ |
| | | { |
| | | label: '编辑', |
| | | onClick: handleEdit.bind(null, record), |
| | | auth: 'copywritingScheme:copywriting_scheme:edit' |
| | | } |
| | | ] |
| | | } |
| | | /** |
| | | * 下拉操作栏 |
| | | */ |
| | | function getDropDownAction(record){ |
| | | return [ |
| | | { |
| | | label: '详情', |
| | | onClick: handleDetail.bind(null, record), |
| | | }, { |
| | | label: '删除', |
| | | popConfirm: { |
| | | title: '是否确认删除', |
| | | confirm: handleDelete.bind(null, record), |
| | | placement: 'topLeft', |
| | | }, |
| | | auth: 'copywritingScheme:copywriting_scheme:delete' |
| | | } |
| | | ] |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | </script> |
| | | |
| | | <style lang="less" scoped> |
| | | :deep(.ant-picker),:deep(.ant-input-number){ |
| | | width: 100%; |
| | | } |
| | | </style> |
| New file |
| | |
| | | -- 注意:该页面对应的前台目录为views/copywritingScheme文件夹下 |
| | | -- 如果你想更改到其他目录,请修改sql中component字段对应的值 |
| | | |
| | | |
| | | -- 主菜单 |
| | | INSERT INTO sys_permission(id, parent_id, name, url, component, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_route, is_leaf, keep_alive, hidden, hide_tab, description, status, del_flag, rule_flag, create_by, create_time, update_by, update_time, internal_or_external) |
| | | VALUES ('177062978662501', NULL, '文案生成方案', '/copywritingScheme/copywritingSchemeList', 'copywritingScheme/CopywritingSchemeList', NULL, NULL, 0, NULL, '1', 0.00, 0, NULL, 1, 0, 0, 0, 0, NULL, '1', 0, 0, 'admin', '2026-02-09 17:36:26', NULL, NULL, 0); |
| | | |
| | | -- 新增 |
| | | INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) |
| | | VALUES ('177062978662502', '177062978662501', '添加文案生成方案', NULL, NULL, 0, NULL, NULL, 2, 'copywritingScheme:copywriting_scheme:add', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-02-09 17:36:26', NULL, NULL, 0, 0, '1', 0); |
| | | |
| | | -- 编辑 |
| | | INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) |
| | | VALUES ('177062978662503', '177062978662501', '编辑文案生成方案', NULL, NULL, 0, NULL, NULL, 2, 'copywritingScheme:copywriting_scheme:edit', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-02-09 17:36:26', NULL, NULL, 0, 0, '1', 0); |
| | | |
| | | -- 删除 |
| | | INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) |
| | | VALUES ('177062978662504', '177062978662501', '删除文案生成方案', NULL, NULL, 0, NULL, NULL, 2, 'copywritingScheme:copywriting_scheme:delete', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-02-09 17:36:26', NULL, NULL, 0, 0, '1', 0); |
| | | |
| | | -- 批量删除 |
| | | INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) |
| | | VALUES ('177062978662505', '177062978662501', '批量删除文案生成方案', NULL, NULL, 0, NULL, NULL, 2, 'copywritingScheme:copywriting_scheme:deleteBatch', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-02-09 17:36:26', NULL, NULL, 0, 0, '1', 0); |
| | | |
| | | -- 导出excel |
| | | INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) |
| | | VALUES ('177062978662506', '177062978662501', '导出excel_文案生成方案', NULL, NULL, 0, NULL, NULL, 2, 'copywritingScheme:copywriting_scheme:exportXls', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-02-09 17:36:26', NULL, NULL, 0, 0, '1', 0); |
| | | |
| | | -- 导入excel |
| | | INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) |
| | | VALUES ('177062978662507', '177062978662501', '导入excel_文案生成方案', NULL, NULL, 0, NULL, NULL, 2, 'copywritingScheme:copywriting_scheme:importExcel', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-02-09 17:36:26', NULL, NULL, 0, 0, '1', 0); |
| | | |
| | | -- 角色授权(以 admin 角色为例,role_id 可替换) |
| | | INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('177062978662508', 'f6817f48af4fb3af11b9e8bf182f618b', '177062978662501', NULL, '2026-02-09 17:36:26', '127.0.0.1'); |
| | | INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('177062978662509', 'f6817f48af4fb3af11b9e8bf182f618b', '177062978662502', NULL, '2026-02-09 17:36:26', '127.0.0.1'); |
| | | INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('177062978662510', 'f6817f48af4fb3af11b9e8bf182f618b', '177062978662503', NULL, '2026-02-09 17:36:26', '127.0.0.1'); |
| | | INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('177062978662511', 'f6817f48af4fb3af11b9e8bf182f618b', '177062978662504', NULL, '2026-02-09 17:36:26', '127.0.0.1'); |
| | | INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('177062978662512', 'f6817f48af4fb3af11b9e8bf182f618b', '177062978662505', NULL, '2026-02-09 17:36:26', '127.0.0.1'); |
| | | INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('177062978662513', 'f6817f48af4fb3af11b9e8bf182f618b', '177062978662506', NULL, '2026-02-09 17:36:26', '127.0.0.1'); |
| | | INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('177062978662514', 'f6817f48af4fb3af11b9e8bf182f618b', '177062978662507', NULL, '2026-02-09 17:36:26', '127.0.0.1'); |
| New file |
| | |
| | | <template> |
| | | <div style="min-height: 400px"> |
| | | <BasicForm @register="registerForm"></BasicForm> |
| | | <div style="width: 100%;text-align: center" v-if="!formDisabled"> |
| | | <a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提 交</a-button> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script lang="ts"> |
| | | import {BasicForm, useForm} from '/@/components/Form/index'; |
| | | import {computed, defineComponent} from 'vue'; |
| | | import {defHttp} from '/@/utils/http/axios'; |
| | | import { propTypes } from '/@/utils/propTypes'; |
| | | import {getBpmFormSchema} from '../CopywritingScheme.data'; |
| | | import {saveOrUpdate} from '../CopywritingScheme.api'; |
| | | |
| | | export default defineComponent({ |
| | | name: "CopywritingSchemeForm", |
| | | components:{ |
| | | BasicForm |
| | | }, |
| | | props:{ |
| | | formData: propTypes.object.def({}), |
| | | formBpm: propTypes.bool.def(true), |
| | | }, |
| | | setup(props){ |
| | | const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({ |
| | | labelWidth: 150, |
| | | schemas: getBpmFormSchema(props.formData), |
| | | showActionButtonGroup: false, |
| | | baseColProps: {span: 24} |
| | | }); |
| | | |
| | | const formDisabled = computed(()=>{ |
| | | if(props.formData.disabled === false){ |
| | | return false; |
| | | } |
| | | return true; |
| | | }); |
| | | |
| | | let formData = {}; |
| | | const queryByIdUrl = '/copywritingScheme/copywritingScheme/queryById'; |
| | | async function initFormData(){ |
| | | let params = {id: props.formData.dataId}; |
| | | const data = await defHttp.get({url: queryByIdUrl, params}); |
| | | formData = {...data} |
| | | //设置表单的值 |
| | | await setFieldsValue(formData); |
| | | //默认是禁用 |
| | | await setProps({disabled: formDisabled.value}) |
| | | } |
| | | |
| | | async function submitForm() { |
| | | let data = getFieldsValue(); |
| | | let params = Object.assign({}, formData, data); |
| | | console.log('表单数据', params) |
| | | await saveOrUpdate(params, true) |
| | | } |
| | | |
| | | initFormData(); |
| | | |
| | | return { |
| | | registerForm, |
| | | formDisabled, |
| | | submitForm, |
| | | } |
| | | } |
| | | }); |
| | | </script> |
| New file |
| | |
| | | <template> |
| | | <BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit"> |
| | | <BasicForm @register="registerForm" name="CopywritingSchemeForm" /> |
| | | </BasicModal> |
| | | </template> |
| | | |
| | | <script lang="ts" setup> |
| | | import {ref, computed, unref, reactive} from 'vue'; |
| | | import {BasicModal, useModalInner} from '/@/components/Modal'; |
| | | import {BasicForm, useForm} from '/@/components/Form/index'; |
| | | import {formSchema} from '../CopywritingScheme.data'; |
| | | import {saveOrUpdate} from '../CopywritingScheme.api'; |
| | | import { useMessage } from '/@/hooks/web/useMessage'; |
| | | import { getDateByPicker } from '/@/utils'; |
| | | const { createMessage } = useMessage(); |
| | | // Emits声明 |
| | | const emit = defineEmits(['register','success']); |
| | | const isUpdate = ref(true); |
| | | const isDetail = ref(false); |
| | | //表单配置 |
| | | const [registerForm, { setProps,resetFields, setFieldsValue, validate, scrollToField }] = useForm({ |
| | | labelWidth: 150, |
| | | schemas: formSchema, |
| | | showActionButtonGroup: false, |
| | | baseColProps: {span: 24} |
| | | }); |
| | | //表单赋值 |
| | | const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => { |
| | | //重置表单 |
| | | await resetFields(); |
| | | setModalProps({confirmLoading: false,showCancelBtn:!!data?.showFooter,showOkBtn:!!data?.showFooter}); |
| | | isUpdate.value = !!data?.isUpdate; |
| | | isDetail.value = !!data?.showFooter; |
| | | if (unref(isUpdate)) { |
| | | //表单赋值 |
| | | await setFieldsValue({ |
| | | ...data.record, |
| | | }); |
| | | } |
| | | // 隐藏底部时禁用整个表单 |
| | | setProps({ disabled: !data?.showFooter }) |
| | | }); |
| | | //日期个性化选择 |
| | | const fieldPickers = reactive({ |
| | | }); |
| | | //设置标题 |
| | | const title = computed(() => (!unref(isUpdate) ? '新增' : !unref(isDetail) ? '详情' : '编辑')); |
| | | //表单提交事件 |
| | | async function handleSubmit(v) { |
| | | try { |
| | | let values = await validate(); |
| | | // 预处理日期数据 |
| | | changeDateValue(values); |
| | | setModalProps({confirmLoading: true}); |
| | | //提交表单 |
| | | await saveOrUpdate(values, isUpdate.value); |
| | | //关闭弹窗 |
| | | closeModal(); |
| | | //刷新列表 |
| | | emit('success'); |
| | | } catch ({ errorFields }) { |
| | | if (errorFields) { |
| | | const firstField = errorFields[0]; |
| | | if (firstField) { |
| | | scrollToField(firstField.name, { behavior: 'smooth', block: 'center' }); |
| | | } |
| | | } |
| | | return Promise.reject(errorFields); |
| | | } finally { |
| | | setModalProps({confirmLoading: false}); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理日期值 |
| | | * @param formData 表单数据 |
| | | */ |
| | | const changeDateValue = (formData) => { |
| | | if (formData && fieldPickers) { |
| | | for (let key in fieldPickers) { |
| | | if (formData[key]) { |
| | | formData[key] = getDateByPicker(formData[key], fieldPickers[key]); |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | |
| | | </script> |
| | | |
| | | <style lang="less" scoped> |
| | | /** 时间和数字输入框样式 */ |
| | | :deep(.ant-input-number) { |
| | | width: 100%; |
| | | } |
| | | |
| | | :deep(.ant-calendar-picker) { |
| | | width: 100%; |
| | | } |
| | | </style> |