| | |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.konghq</groupId> |
| | | <artifactId>unirest-java</artifactId> |
| | | <version>3.14.1</version> <!-- 最新稳定版,兼容Java8+ --> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>easyexcel</artifactId> |
| | | <version>3.3.2</version> |
| New file |
| | |
| | | package org.jeecg.config; |
| | | |
| | | import jakarta.annotation.PostConstruct; |
| | | import kong.unirest.Unirest; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * Unirest 3.x 全局配置类,项目启动时仅执行一次 |
| | | */ |
| | | @Component |
| | | public class UnirestConfig { |
| | | |
| | | /** |
| | | * @PostConstruct:Spring Bean初始化后立即执行,全局仅一次 |
| | | */ |
| | | @PostConstruct |
| | | public void initUnirest() { |
| | | // 重置配置(可选,防止项目中其他地方提前初始化了Unirest) |
| | | Unirest.config().reset(); |
| | | // 全局配置:超时、连接池、重连,项目启动时只配一次 |
| | | Unirest.config() |
| | | .connectTimeout(5000) |
| | | .socketTimeout(30000); |
| | | } |
| | | |
| | | /** |
| | | * 项目关闭时销毁Unirest,释放连接池资源(可选,优雅停机) |
| | | */ |
| | | // @PreDestroy |
| | | // public void shutdownUnirest() { |
| | | // Unirest.shutDown(); |
| | | // } |
| | | } |
| | |
| | | return Result.error("未找到对应数据"); |
| | | } |
| | | contractService.updateMain(contract, contractPage.getContractFileList(),contractPage.getSemanticWordList()); |
| | | |
| | | if (contractPage.getStatus() != null) { |
| | | UpdateWrapper<SemanticWord> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.set("status", contractPage.getStatus()); // 替换为实际要修改的字段名(如semantic_id) |
| | | updateWrapper.eq("contract_id", contract.getId()); // 复用查询条件 |
| | | boolean update = semanticWordService.update(updateWrapper); |
| | | } |
| | | return Result.OK("编辑成功!"); |
| | | } |
| | | BeanUtils.copyProperties(contractPage, contract); |
| | |
| | | private String contractId; |
| | | private String fileName; |
| | | private String youshang; |
| | | private String wenti; |
| | | private String copywritingRequirements; |
| | | private String benchmarkUrl; |
| | | private String auditor; |
| | | private String auditorName; |
| | | |
| | |
| | | this.youshang = youshang; |
| | | } |
| | | |
| | | public String getWenti() { |
| | | return wenti; |
| | | public String getBenchmarkUrl() { |
| | | return benchmarkUrl; |
| | | } |
| | | |
| | | public void setWenti(String wenti) { |
| | | this.wenti = wenti; |
| | | } |
| | | |
| | | public String getCopywritingRequirements() { |
| | | return copywritingRequirements; |
| | | } |
| | | |
| | | public void setCopywritingRequirements(String copywritingRequirements) { |
| | | this.copywritingRequirements = copywritingRequirements; |
| | | public void setBenchmarkUrl(String benchmarkUrl) { |
| | | this.benchmarkUrl = benchmarkUrl; |
| | | } |
| | | |
| | | public String getAuditor() { |
| | |
| | | import org.apache.commons.beanutils.BeanUtils; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.modules.demo.contract.entity.Contract; |
| | | import org.jeecg.modules.demo.contract.entity.ExcelDataDTO; |
| | | import org.jeecg.modules.demo.contract.entity.SemanticWord; |
| | | import org.jeecg.modules.demo.contract.service.IContractService; |
| | | import org.jeecg.modules.demo.contract.service.ISemanticWordService; |
| | | import org.jeecg.modules.demo.copywriting.controller.CopywritingAsyncService; |
| | | import org.jeecg.modules.listener.ExcelDataListener; |
| | |
| | | private ISysUserService sysUserService; |
| | | @Autowired |
| | | private ISemanticWordService semanticWordService; |
| | | @Autowired |
| | | private IContractService contractService; |
| | | /** |
| | | * Excel文件导入接口(适配大类、品牌等五列) |
| | | * @return 导入结果 |
| | |
| | | copy.setContractId(importParam.getContractId()); |
| | | copy.setBrand(data.getBrand()); |
| | | copy.setCategoryOne(data.getCategory()); |
| | | copy.setWord(data.getLeakWord()); |
| | | copy.setOutWord(data.getSemanticQuestion()); |
| | | 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(); |
| | |
| | | } |
| | | } |
| | | semanticWordService.saveBatch(semanticWords); |
| | | |
| | | Contract contract = new Contract(); |
| | | contract.setId(importParam.getContractId()); |
| | | contract.setIsImportStatus("1"); |
| | | contractService.updateById(contract); |
| | | |
| | | // 示例:调用Service保存数据(替换为你的实际业务逻辑) |
| | | // excelDataService.saveBatch(dataList); |
| | |
| | | return Result.error("文件不能为空"); |
| | | } else if (cp.getYoushang().isEmpty()) { |
| | | return Result.error("友商不能为空"); |
| | | } else if (cp.getWenti().isEmpty()) { |
| | | return Result.error("问题描述不能为空"); |
| | | } else if (cp.getCopywritingRequirements().isEmpty()) { |
| | | return Result.error("文案要求不能为空"); |
| | | } else if (cp.getAuditor().isEmpty() || cp.getAuditorName().isEmpty()) { |
| | | return Result.error("用户不能为空"); |
| | | } |
| | |
| | | } else { |
| | | // 调用异步方法执行实际生成逻辑 |
| | | copywritingAsyncService.asyncBatchGenerateCopy( |
| | | cp.getContractId(), list, cp.getFileName(), cp.getYoushang(), cp.getWenti(), |
| | | cp.getCopywritingRequirements(),cp.getAuditor(), cp.getAuditorName() |
| | | cp.getContractId(), list, cp.getFileName(), cp.getYoushang(), |
| | | cp.getBenchmarkUrl(),cp.getAuditor(), cp.getAuditorName() |
| | | ); |
| | | // 立即返回响应,不等待生成完成 |
| | | return Result.OK("开始生成,任务已提交至后台处理"); |
| | |
| | | @Schema(description = "是否停止服务") |
| | | private java.lang.String isDropService; |
| | | |
| | | @Excel(name = "是否为导入合同(0否、1是)", width = 1) |
| | | @Schema(description = "是否为导入合同(0否、1是)") |
| | | private java.lang.String isImportStatus; |
| | | |
| | | |
| | | } |
| | |
| | | public ICopywritingService copywritingService; |
| | | @Async("copywritingAsyncExecutor") |
| | | public void asyncBatchGenerateCopy(String contractId, List<SemanticWord> semanticWords, |
| | | String fileName, String youshang, String wenti, |
| | | String wenanyaoqiu, |
| | | String fileName, String youshang, |
| | | String benchmarkUrl, |
| | | String auditor, String auditorName) { |
| | | // 1. 生成唯一任务ID,创建待处理任务 |
| | | String taskId = UUID.randomUUID().toString().replace("-", ""); |
| | |
| | | copywriting.setWordId(semanticWord.getId()); |
| | | Result text = copywritingController.getResult( |
| | | fileName, |
| | | wenanyaoqiu, |
| | | benchmarkUrl, |
| | | semanticWord.getOutWord(), |
| | | youshang, |
| | | wenti, |
| | | semanticWord.getWord(), |
| | | "e9ca23d68d884d4ebb19d07889727dae"); |
| | | if (text.isSuccess()) { |
| | | copywriting.setText(text.getResult().toString()); |
| | |
| | | } |
| | | |
| | | // 添加其他文本参数 |
| | | inputs.put("wenanyaoqiu", wenanyaoqiu); |
| | | inputs.put("benchmarkUrl", wenanyaoqiu); |
| | | inputs.put("louchu", louchu); |
| | | inputs.put("youshang", youshang); |
| | | inputs.put("wenti", wenti); |
| New file |
| | |
| | | package org.jeecg.modules.demo.mediaList.controller; |
| | | |
| | | import kong.unirest.Unirest; |
| | | import okhttp3.MultipartBody; |
| | | import okhttp3.OkHttpClient; |
| | | import okhttp3.Request; |
| | | import okhttp3.Response; |
| | | import org.springframework.http.*; |
| | | |
| | | import java.net.http.HttpResponse; |
| | | 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.mediaList.entity.MediaList; |
| | | import org.jeecg.modules.demo.mediaList.service.IMediaListService; |
| | | |
| | | 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.util.LinkedMultiValueMap; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.client.RestTemplate; |
| | | 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-06 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Tag(name="媒体资源列表") |
| | | @RestController |
| | | @RequestMapping("/mediaList/mediaList") |
| | | @Slf4j |
| | | public class MediaListController extends JeecgController<MediaList, IMediaListService> { |
| | | @Autowired |
| | | private IMediaListService mediaListService; |
| | | |
| | | /** |
| | | * 分页列表查询 |
| | | * |
| | | * @param mediaList |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "媒体资源列表-分页列表查询") |
| | | @Operation(summary="媒体资源列表-分页列表查询") |
| | | @GetMapping(value = "/list") |
| | | public Result<IPage<MediaList>> queryPageList(MediaList mediaList, |
| | | @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, |
| | | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | |
| | | |
| | | QueryWrapper<MediaList> queryWrapper = QueryGenerator.initQueryWrapper(mediaList, req.getParameterMap()); |
| | | Page<MediaList> page = new Page<MediaList>(pageNo, pageSize); |
| | | IPage<MediaList> pageList = mediaListService.page(page, queryWrapper); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param mediaList |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "媒体资源列表-添加") |
| | | @Operation(summary="媒体资源列表-添加") |
| | | @RequiresPermissions("mediaList:media_list:add") |
| | | @PostMapping(value = "/add") |
| | | public Result<String> add(@RequestBody MediaList mediaList) { |
| | | mediaListService.save(mediaList); |
| | | |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 编辑 |
| | | * |
| | | * @param mediaList |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "媒体资源列表-编辑") |
| | | @Operation(summary="媒体资源列表-编辑") |
| | | @RequiresPermissions("mediaList:media_list:edit") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) |
| | | public Result<String> edit(@RequestBody MediaList mediaList) { |
| | | mediaListService.updateById(mediaList); |
| | | return Result.OK("编辑成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id删除 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "媒体资源列表-通过id删除") |
| | | @Operation(summary="媒体资源列表-通过id删除") |
| | | @RequiresPermissions("mediaList:media_list:delete") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<String> delete(@RequestParam(name="id",required=true) String id) { |
| | | mediaListService.removeById(id); |
| | | return Result.OK("删除成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "媒体资源列表-批量删除") |
| | | @Operation(summary="媒体资源列表-批量删除") |
| | | @RequiresPermissions("mediaList:media_list:deleteBatch") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { |
| | | this.mediaListService.removeByIds(Arrays.asList(ids.split(","))); |
| | | return Result.OK("批量删除成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id查询 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "媒体资源列表-通过id查询") |
| | | @Operation(summary="媒体资源列表-通过id查询") |
| | | @GetMapping(value = "/queryById") |
| | | public Result<MediaList> queryById(@RequestParam(name="id",required=true) String id) { |
| | | MediaList mediaList = mediaListService.getById(id); |
| | | if(mediaList==null) { |
| | | return Result.error("未找到对应数据"); |
| | | } |
| | | return Result.OK(mediaList); |
| | | } |
| | | |
| | | /** |
| | | * 导出excel |
| | | * |
| | | * @param request |
| | | * @param mediaList |
| | | */ |
| | | @RequiresPermissions("mediaList:media_list:exportXls") |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, MediaList mediaList) { |
| | | return super.exportXls(request, mediaList, MediaList.class, "媒体资源列表"); |
| | | } |
| | | |
| | | /** |
| | | * 通过excel导入数据 |
| | | * |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | @RequiresPermissions("mediaList:media_list:importExcel") |
| | | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | return super.importExcel(request, response, MediaList.class); |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | |
| | | @RequiresPermissions("mediaList:media_list:initMedia") |
| | | @RequestMapping(value = "/initMedia", method = RequestMethod.POST) |
| | | public Result<?> initMedia() { |
| | | int j = 1; |
| | | mediaListService.remove(new QueryWrapper<MediaList>()); |
| | | // 改造死循环:原代码i==0是死循环,这里改为合理的循环(示例:执行1次,可根据你的需求修改) |
| | | for (int i = 0; i == 0; j ++) { |
| | | try { |
| | | kong.unirest.HttpResponse<String> response = Unirest.post("http://8.138.187.158:8082/api/media/media_list") |
| | | .field("api_key", "sk_4c8f6a970de896e232909e2959254441") // 普通表单字段 |
| | | .field("page", String.valueOf(j)) // 推荐用String.valueOf,比j+""更优雅 |
| | | .field("page_size", "100") |
| | | .asString(); |
| | | List<MediaList> mediaLists = JSON.parseArray(JSON.parseObject(response.getBody()).getString("data"), MediaList.class); |
| | | if(mediaLists.isEmpty()) { |
| | | i = 1; |
| | | } |
| | | mediaListService.saveBatch(mediaLists); |
| | | } catch (Exception e) { |
| | | // 异常捕获:避免外部接口调用失败导致整个初始化方法报错 |
| | | log.error("调用外部媒体列表接口失败,异常信息:", e); |
| | | // 可选:抛出异常/返回失败结果,根据业务需求调整 |
| | | // return Result.error("初始化失败,调用外部接口异常:" + e.getMessage()); |
| | | return Result.error("初始化失败"); |
| | | } |
| | | } |
| | | return Result.OK("初始化成功"); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package org.jeecg.modules.demo.mediaList.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-06 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Data |
| | | @TableName("media_list") |
| | | @Accessors(chain = true) |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @Schema(description="媒体资源列表") |
| | | public class MediaList implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /**主键*/ |
| | | @TableId(type = IdType.ASSIGN_ID) |
| | | @Schema(description = "主键") |
| | | private String id; |
| | | /**资源编号*/ |
| | | @Excel(name = "资源编号", width = 15) |
| | | @Schema(description = "资源编号") |
| | | private String resourceId; |
| | | /**媒体名称*/ |
| | | @Excel(name = "媒体名称", width = 15) |
| | | @Schema(description = "媒体名称") |
| | | private String title; |
| | | /**描述*/ |
| | | @Excel(name = "描述", width = 15) |
| | | @Schema(description = "描述") |
| | | private String remarks; |
| | | /**地址*/ |
| | | @Excel(name = "地址", width = 15) |
| | | @Schema(description = "地址") |
| | | private String caseLink; |
| | | /**筛选1*/ |
| | | @Excel(name = "筛选1", width = 15) |
| | | @Schema(description = "筛选1") |
| | | private String field1; |
| | | /**筛选2*/ |
| | | @Excel(name = "筛选2", width = 15) |
| | | @Schema(description = "筛选2") |
| | | private String field2; |
| | | /**筛选3*/ |
| | | @Excel(name = "筛选3", width = 15) |
| | | @Schema(description = "筛选3") |
| | | private String field3; |
| | | /**筛选4*/ |
| | | @Excel(name = "筛选4", width = 15) |
| | | @Schema(description = "筛选4") |
| | | private String field4; |
| | | /**筛选5*/ |
| | | @Excel(name = "筛选5", width = 15) |
| | | @Schema(description = "筛选5") |
| | | private String field5; |
| | | /**筛选6*/ |
| | | @Excel(name = "筛选6", width = 15) |
| | | @Schema(description = "筛选6") |
| | | private String field6; |
| | | /**筛选7*/ |
| | | @Excel(name = "筛选7", width = 15) |
| | | @Schema(description = "筛选7") |
| | | private String field7; |
| | | /**筛选8*/ |
| | | @Excel(name = "筛选8", width = 15) |
| | | @Schema(description = "筛选8") |
| | | private String field8; |
| | | /**筛选9*/ |
| | | @Excel(name = "筛选9", width = 15) |
| | | @Schema(description = "筛选9") |
| | | private String field9; |
| | | /**pc权重*/ |
| | | @Excel(name = "pc权重", width = 15) |
| | | @Schema(description = "pc权重") |
| | | private String pcWeigh; |
| | | /**移动权重*/ |
| | | @Excel(name = "移动权重", width = 15) |
| | | @Schema(description = "移动权重") |
| | | private String wapWeigh; |
| | | /**出稿率*/ |
| | | @Excel(name = "出稿率", width = 15) |
| | | @Schema(description = "出稿率") |
| | | private String publishRate; |
| | | /**平均发布时间*/ |
| | | @Excel(name = "平均发布时间", width = 15) |
| | | @Schema(description = "平均发布时间") |
| | | private String publishTime; |
| | | /**可用状态 1可接单 0不接单*/ |
| | | @Excel(name = "可用状态 1可接单 0不接单", width = 15) |
| | | @Schema(description = "可用状态 1可接单 0不接单") |
| | | private String status; |
| | | /**媒体价格*/ |
| | | @Excel(name = "媒体价格", width = 15) |
| | | @Schema(description = "媒体价格") |
| | | private String price; |
| | | } |
| New file |
| | |
| | | package org.jeecg.modules.demo.mediaList.entity; |
| | | |
| | | import lombok.Data; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 外部媒体列表接口的整体响应实体 |
| | | */ |
| | | @Data |
| | | public class MediaListResponse { |
| | | /** 响应码(示例中为1) */ |
| | | private Integer code; |
| | | /** 响应信息(示例中为获取成功) */ |
| | | private String msg; |
| | | /** 时间戳字符串(示例中为1770344463) */ |
| | | private String time; |
| | | /** 媒体列表数据核心数组 */ |
| | | private List<MediaList> data; |
| | | } |
| New file |
| | |
| | | package org.jeecg.modules.demo.mediaList.mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.jeecg.modules.demo.mediaList.entity.MediaList; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * @Description: 媒体资源列表 |
| | | * @Author: jeecg-boot |
| | | * @Date: 2026-02-06 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface MediaListMapper extends BaseMapper<MediaList> { |
| | | |
| | | } |
| 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.mediaList.mapper.MediaListMapper"> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | package org.jeecg.modules.demo.mediaList.service; |
| | | |
| | | import org.jeecg.modules.demo.mediaList.entity.MediaList; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | /** |
| | | * @Description: 媒体资源列表 |
| | | * @Author: jeecg-boot |
| | | * @Date: 2026-02-06 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface IMediaListService extends IService<MediaList> { |
| | | |
| | | } |
| New file |
| | |
| | | package org.jeecg.modules.demo.mediaList.service.impl; |
| | | |
| | | import org.jeecg.modules.demo.mediaList.entity.MediaList; |
| | | import org.jeecg.modules.demo.mediaList.mapper.MediaListMapper; |
| | | import org.jeecg.modules.demo.mediaList.service.IMediaListService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | |
| | | /** |
| | | * @Description: 媒体资源列表 |
| | | * @Author: jeecg-boot |
| | | * @Date: 2026-02-06 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service |
| | | public class MediaListServiceImpl extends ServiceImpl<MediaListMapper, MediaList> implements IMediaListService { |
| | | |
| | | } |
| 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.resourceId"/> |
| | | </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.title"/> |
| | | </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.remarks"/> |
| | | </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.caseLink"/> |
| | | </view> |
| | | </view> |
| | | <view class="cu-form-group"> |
| | | <view class="flex align-center"> |
| | | <view class="title"><text space="ensp">筛选1:</text></view> |
| | | <input placeholder="请输入筛选1" v-model="model.field1"/> |
| | | </view> |
| | | </view> |
| | | <view class="cu-form-group"> |
| | | <view class="flex align-center"> |
| | | <view class="title"><text space="ensp">筛选2:</text></view> |
| | | <input placeholder="请输入筛选2" v-model="model.field2"/> |
| | | </view> |
| | | </view> |
| | | <view class="cu-form-group"> |
| | | <view class="flex align-center"> |
| | | <view class="title"><text space="ensp">筛选3:</text></view> |
| | | <input placeholder="请输入筛选3" v-model="model.field3"/> |
| | | </view> |
| | | </view> |
| | | <view class="cu-form-group"> |
| | | <view class="flex align-center"> |
| | | <view class="title"><text space="ensp">筛选4:</text></view> |
| | | <input placeholder="请输入筛选4" v-model="model.field4"/> |
| | | </view> |
| | | </view> |
| | | <view class="cu-form-group"> |
| | | <view class="flex align-center"> |
| | | <view class="title"><text space="ensp">筛选5:</text></view> |
| | | <input placeholder="请输入筛选5" v-model="model.field5"/> |
| | | </view> |
| | | </view> |
| | | <view class="cu-form-group"> |
| | | <view class="flex align-center"> |
| | | <view class="title"><text space="ensp">筛选6:</text></view> |
| | | <input placeholder="请输入筛选6" v-model="model.field6"/> |
| | | </view> |
| | | </view> |
| | | <view class="cu-form-group"> |
| | | <view class="flex align-center"> |
| | | <view class="title"><text space="ensp">筛选7:</text></view> |
| | | <input placeholder="请输入筛选7" v-model="model.field7"/> |
| | | </view> |
| | | </view> |
| | | <view class="cu-form-group"> |
| | | <view class="flex align-center"> |
| | | <view class="title"><text space="ensp">筛选8:</text></view> |
| | | <input placeholder="请输入筛选8" v-model="model.field8"/> |
| | | </view> |
| | | </view> |
| | | <view class="cu-form-group"> |
| | | <view class="flex align-center"> |
| | | <view class="title"><text space="ensp">筛选9:</text></view> |
| | | <input placeholder="请输入筛选9" v-model="model.field9"/> |
| | | </view> |
| | | </view> |
| | | <view class="cu-form-group"> |
| | | <view class="flex align-center"> |
| | | <view class="title"><text space="ensp">pc权重:</text></view> |
| | | <input placeholder="请输入pc权重" v-model="model.pcWeigh"/> |
| | | </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.wapWeigh"/> |
| | | </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.publishRate"/> |
| | | </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.publishTime"/> |
| | | </view> |
| | | </view> |
| | | <view class="cu-form-group"> |
| | | <view class="flex align-center"> |
| | | <view class="title"><text space="ensp">可用状态 1可接单 0不接单:</text></view> |
| | | <input placeholder="请输入可用状态 1可接单 0不接单" v-model="model.status"/> |
| | | </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.price"/> |
| | | </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: "MediaListForm", |
| | | components:{ myDate }, |
| | | props:{ |
| | | formData:{ |
| | | type:Object, |
| | | default:()=>{}, |
| | | required:false |
| | | } |
| | | }, |
| | | data(){ |
| | | return { |
| | | CustomBar: this.CustomBar, |
| | | NavBarColor: this.NavBarColor, |
| | | loading:false, |
| | | model: {}, |
| | | backRouteName:'index', |
| | | url: { |
| | | queryById: "/mediaList/mediaList/queryById", |
| | | add: "/mediaList/mediaList/add", |
| | | edit: "/mediaList/mediaList/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: "/mediaList/mediaList/list", |
| | | }; |
| | | }, |
| | | methods: { |
| | | goHome(){ |
| | | this.$Router.push({name: "index"}) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| New file |
| | |
| | | import { render } from '@/common/renderUtils'; |
| | | //列表数据 |
| | | export const columns = [ |
| | | { |
| | | title: '资源编号', |
| | | align:"center", |
| | | dataIndex: 'resourceId' |
| | | }, |
| | | { |
| | | title: '媒体名称', |
| | | align:"center", |
| | | dataIndex: 'title' |
| | | }, |
| | | { |
| | | title: '描述', |
| | | align:"center", |
| | | dataIndex: 'remarks' |
| | | }, |
| | | { |
| | | title: '地址', |
| | | align:"center", |
| | | dataIndex: 'caseLink' |
| | | }, |
| | | { |
| | | title: '筛选1', |
| | | align:"center", |
| | | dataIndex: 'field1' |
| | | }, |
| | | { |
| | | title: '筛选2', |
| | | align:"center", |
| | | dataIndex: 'field2' |
| | | }, |
| | | { |
| | | title: '筛选3', |
| | | align:"center", |
| | | dataIndex: 'field3' |
| | | }, |
| | | { |
| | | title: '筛选4', |
| | | align:"center", |
| | | dataIndex: 'field4' |
| | | }, |
| | | { |
| | | title: '筛选5', |
| | | align:"center", |
| | | dataIndex: 'field5' |
| | | }, |
| | | { |
| | | title: '筛选6', |
| | | align:"center", |
| | | dataIndex: 'field6' |
| | | }, |
| | | { |
| | | title: '筛选7', |
| | | align:"center", |
| | | dataIndex: 'field7' |
| | | }, |
| | | { |
| | | title: '筛选8', |
| | | align:"center", |
| | | dataIndex: 'field8' |
| | | }, |
| | | { |
| | | title: '筛选9', |
| | | align:"center", |
| | | dataIndex: 'field9' |
| | | }, |
| | | { |
| | | title: 'pc权重', |
| | | align:"center", |
| | | dataIndex: 'pcWeigh' |
| | | }, |
| | | { |
| | | title: '移动权重', |
| | | align:"center", |
| | | dataIndex: 'wapWeigh' |
| | | }, |
| | | { |
| | | title: '出稿率', |
| | | align:"center", |
| | | dataIndex: 'publishRate' |
| | | }, |
| | | { |
| | | title: '平均发布时间', |
| | | align:"center", |
| | | dataIndex: 'publishTime' |
| | | }, |
| | | { |
| | | title: '可用状态 1可接单 0不接单', |
| | | align:"center", |
| | | dataIndex: 'status' |
| | | }, |
| | | { |
| | | title: '媒体价格', |
| | | align:"center", |
| | | dataIndex: 'price' |
| | | }, |
| | | ]; |
| 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['resourceId']" |
| | | :label="get4Label('资源编号')" |
| | | name='resourceId' |
| | | prop='resourceId' |
| | | placeholder="请选择资源编号" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 1 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['title']" |
| | | :label="get4Label('媒体名称')" |
| | | name='title' |
| | | prop='title' |
| | | placeholder="请选择媒体名称" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 0 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['remarks']" |
| | | :label="get4Label('描述')" |
| | | name='remarks' |
| | | prop='remarks' |
| | | placeholder="请选择描述" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 1 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['caseLink']" |
| | | :label="get4Label('地址')" |
| | | name='caseLink' |
| | | prop='caseLink' |
| | | placeholder="请选择地址" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 0 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['field1']" |
| | | :label="get4Label('筛选1')" |
| | | name='field1' |
| | | prop='field1' |
| | | placeholder="请选择筛选1" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 1 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['field2']" |
| | | :label="get4Label('筛选2')" |
| | | name='field2' |
| | | prop='field2' |
| | | placeholder="请选择筛选2" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 0 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['field3']" |
| | | :label="get4Label('筛选3')" |
| | | name='field3' |
| | | prop='field3' |
| | | placeholder="请选择筛选3" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 1 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['field4']" |
| | | :label="get4Label('筛选4')" |
| | | name='field4' |
| | | prop='field4' |
| | | placeholder="请选择筛选4" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 0 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['field5']" |
| | | :label="get4Label('筛选5')" |
| | | name='field5' |
| | | prop='field5' |
| | | placeholder="请选择筛选5" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 1 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['field6']" |
| | | :label="get4Label('筛选6')" |
| | | name='field6' |
| | | prop='field6' |
| | | placeholder="请选择筛选6" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 0 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['field7']" |
| | | :label="get4Label('筛选7')" |
| | | name='field7' |
| | | prop='field7' |
| | | placeholder="请选择筛选7" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 1 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['field8']" |
| | | :label="get4Label('筛选8')" |
| | | name='field8' |
| | | prop='field8' |
| | | placeholder="请选择筛选8" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 0 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['field9']" |
| | | :label="get4Label('筛选9')" |
| | | name='field9' |
| | | prop='field9' |
| | | placeholder="请选择筛选9" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 1 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['pcWeigh']" |
| | | :label="get4Label('pc权重')" |
| | | name='pcWeigh' |
| | | prop='pcWeigh' |
| | | placeholder="请选择pc权重" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 0 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['wapWeigh']" |
| | | :label="get4Label('移动权重')" |
| | | name='wapWeigh' |
| | | prop='wapWeigh' |
| | | placeholder="请选择移动权重" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 1 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['publishRate']" |
| | | :label="get4Label('出稿率')" |
| | | name='publishRate' |
| | | prop='publishRate' |
| | | placeholder="请选择出稿率" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 0 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['publishTime']" |
| | | :label="get4Label('平均发布时间')" |
| | | name='publishTime' |
| | | prop='publishTime' |
| | | placeholder="请选择平均发布时间" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 1 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['status']" |
| | | :label="get4Label('可用状态 1可接单 0不接单')" |
| | | name='status' |
| | | prop='status' |
| | | placeholder="请选择可用状态 1可接单 0不接单" |
| | | :rules="[ |
| | | ]" |
| | | clearable |
| | | /> |
| | | </view> |
| | | <view class="{ 'mt-14px': 0 == 0 }"> |
| | | <wd-input |
| | | label-width="100px" |
| | | v-model="myFormData['price']" |
| | | :label="get4Label('媒体价格')" |
| | | name='price' |
| | | prop='price' |
| | | 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: 'MediaListForm', |
| | | 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('MediaListList') |
| | | // 定义 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("/mediaList/mediaList/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: 'media_list', |
| | | 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?'/mediaList/mediaList/edit':'/mediaList/mediaList/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 './MediaListData'; |
| | | defineOptions({ |
| | | name: 'MediaListList', |
| | | options: { |
| | | styleIsolation: 'shared', |
| | | } |
| | | }) |
| | | //分页加载配置 |
| | | let { toast, router, paging, dataList, queryList } = usePageList('/mediaList/mediaList/list'); |
| | | |
| | | //样式 |
| | | const getBoxStyle = computed(() => { |
| | | return { width: "calc(33% - 5px)" } |
| | | }) |
| | | |
| | | // 其他操作 |
| | | const handleAction = (val, item) => { |
| | | if (val == 'del') { |
| | | http.delete("/mediaList/mediaList/delete?id="+item.id,{id:item.id}).then((res) => { |
| | | toast.success('删除成功~') |
| | | paging.value.reload() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | // go 新增页 |
| | | const handleAdd = () => { |
| | | router.push({ |
| | | name: 'MediaListForm' |
| | | }) |
| | | } |
| | | |
| | | //go 编辑页 |
| | | const handleEdit = (record) => { |
| | | router.push({ |
| | | name: 'MediaListForm', |
| | | 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 = '/mediaList/mediaList/list', |
| | | save='/mediaList/mediaList/add', |
| | | edit='/mediaList/mediaList/edit', |
| | | deleteOne = '/mediaList/mediaList/delete', |
| | | deleteBatch = '/mediaList/mediaList/deleteBatch', |
| | | importExcel = '/mediaList/mediaList/importExcel', |
| | | exportXls = '/mediaList/mediaList/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: 'resourceId' |
| | | }, |
| | | { |
| | | title: '媒体名称', |
| | | align:"center", |
| | | dataIndex: 'title' |
| | | }, |
| | | { |
| | | title: '描述', |
| | | align:"center", |
| | | dataIndex: 'remarks' |
| | | }, |
| | | { |
| | | title: '地址', |
| | | align:"center", |
| | | dataIndex: 'caseLink' |
| | | }, |
| | | { |
| | | title: '筛选1', |
| | | align:"center", |
| | | dataIndex: 'field1' |
| | | }, |
| | | { |
| | | title: '筛选2', |
| | | align:"center", |
| | | dataIndex: 'field2' |
| | | }, |
| | | { |
| | | title: '筛选3', |
| | | align:"center", |
| | | dataIndex: 'field3' |
| | | }, |
| | | { |
| | | title: '筛选4', |
| | | align:"center", |
| | | dataIndex: 'field4' |
| | | }, |
| | | { |
| | | title: '筛选5', |
| | | align:"center", |
| | | dataIndex: 'field5' |
| | | }, |
| | | { |
| | | title: '筛选6', |
| | | align:"center", |
| | | dataIndex: 'field6' |
| | | }, |
| | | { |
| | | title: '筛选7', |
| | | align:"center", |
| | | dataIndex: 'field7' |
| | | }, |
| | | { |
| | | title: '筛选8', |
| | | align:"center", |
| | | dataIndex: 'field8' |
| | | }, |
| | | { |
| | | title: '筛选9', |
| | | align:"center", |
| | | dataIndex: 'field9' |
| | | }, |
| | | { |
| | | title: 'pc权重', |
| | | align:"center", |
| | | dataIndex: 'pcWeigh' |
| | | }, |
| | | { |
| | | title: '移动权重', |
| | | align:"center", |
| | | dataIndex: 'wapWeigh' |
| | | }, |
| | | { |
| | | title: '出稿率', |
| | | align:"center", |
| | | dataIndex: 'publishRate' |
| | | }, |
| | | { |
| | | title: '平均发布时间', |
| | | align:"center", |
| | | dataIndex: 'publishTime' |
| | | }, |
| | | { |
| | | title: '可用状态 1可接单 0不接单', |
| | | align:"center", |
| | | dataIndex: 'status' |
| | | }, |
| | | { |
| | | title: '媒体价格', |
| | | align:"center", |
| | | dataIndex: 'price' |
| | | }, |
| | | ]; |
| | | //查询数据 |
| | | export const searchFormSchema: FormSchema[] = [ |
| | | ]; |
| | | //表单数据 |
| | | export const formSchema: FormSchema[] = [ |
| | | { |
| | | label: '资源编号', |
| | | field: 'resourceId', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: '媒体名称', |
| | | field: 'title', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: '描述', |
| | | field: 'remarks', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: '地址', |
| | | field: 'caseLink', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: '筛选1', |
| | | field: 'field1', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: '筛选2', |
| | | field: 'field2', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: '筛选3', |
| | | field: 'field3', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: '筛选4', |
| | | field: 'field4', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: '筛选5', |
| | | field: 'field5', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: '筛选6', |
| | | field: 'field6', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: '筛选7', |
| | | field: 'field7', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: '筛选8', |
| | | field: 'field8', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: '筛选9', |
| | | field: 'field9', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: 'pc权重', |
| | | field: 'pcWeigh', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: '移动权重', |
| | | field: 'wapWeigh', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: '出稿率', |
| | | field: 'publishRate', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: '平均发布时间', |
| | | field: 'publishTime', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: '可用状态 1可接单 0不接单', |
| | | field: 'status', |
| | | component: 'Input', |
| | | }, |
| | | { |
| | | label: '媒体价格', |
| | | field: 'price', |
| | | component: 'Input', |
| | | }, |
| | | // TODO 主键隐藏字段,目前写死为ID |
| | | { |
| | | label: '', |
| | | field: 'id', |
| | | component: 'Input', |
| | | show: false |
| | | }, |
| | | ]; |
| | | |
| | | // 高级查询数据 |
| | | export const superQuerySchema = { |
| | | resourceId: {title: '资源编号',order: 0,view: 'text', type: 'string',}, |
| | | title: {title: '媒体名称',order: 1,view: 'text', type: 'string',}, |
| | | remarks: {title: '描述',order: 2,view: 'text', type: 'string',}, |
| | | caseLink: {title: '地址',order: 3,view: 'text', type: 'string',}, |
| | | field1: {title: '筛选1',order: 4,view: 'text', type: 'string',}, |
| | | field2: {title: '筛选2',order: 5,view: 'text', type: 'string',}, |
| | | field3: {title: '筛选3',order: 6,view: 'text', type: 'string',}, |
| | | field4: {title: '筛选4',order: 7,view: 'text', type: 'string',}, |
| | | field5: {title: '筛选5',order: 8,view: 'text', type: 'string',}, |
| | | field6: {title: '筛选6',order: 9,view: 'text', type: 'string',}, |
| | | field7: {title: '筛选7',order: 10,view: 'text', type: 'string',}, |
| | | field8: {title: '筛选8',order: 11,view: 'text', type: 'string',}, |
| | | field9: {title: '筛选9',order: 12,view: 'text', type: 'string',}, |
| | | pcWeigh: {title: 'pc权重',order: 13,view: 'text', type: 'string',}, |
| | | wapWeigh: {title: '移动权重',order: 14,view: 'text', type: 'string',}, |
| | | publishRate: {title: '出稿率',order: 15,view: 'text', type: 'string',}, |
| | | publishTime: {title: '平均发布时间',order: 16,view: 'text', type: 'string',}, |
| | | status: {title: '可用状态 1可接单 0不接单',order: 17,view: 'text', type: 'string',}, |
| | | price: {title: '媒体价格',order: 18,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="'mediaList:media_list:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> |
| | | <a-button type="primary" v-auth="'mediaList:media_list:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button> |
| | | <j-upload-button type="primary" v-auth="'mediaList:media_list: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="'mediaList:media_list: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> |
| | | <!-- 表单区域 --> |
| | | <MediaListModal @register="registerModal" @success="handleSuccess"></MediaListModal> |
| | | </div> |
| | | </template> |
| | | |
| | | <script lang="ts" name="mediaList-mediaList" 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 MediaListModal from './components/MediaListModal.vue' |
| | | import {columns, searchFormSchema, superQuerySchema} from './MediaList.data'; |
| | | import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './MediaList.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: 'mediaList:media_list:edit' |
| | | } |
| | | ] |
| | | } |
| | | /** |
| | | * 下拉操作栏 |
| | | */ |
| | | function getDropDownAction(record){ |
| | | return [ |
| | | { |
| | | label: '详情', |
| | | onClick: handleDetail.bind(null, record), |
| | | }, { |
| | | label: '删除', |
| | | popConfirm: { |
| | | title: '是否确认删除', |
| | | confirm: handleDelete.bind(null, record), |
| | | placement: 'topLeft', |
| | | }, |
| | | auth: 'mediaList:media_list:delete' |
| | | } |
| | | ] |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | </script> |
| | | |
| | | <style lang="less" scoped> |
| | | :deep(.ant-picker),:deep(.ant-input-number){ |
| | | width: 100%; |
| | | } |
| | | </style> |
| New file |
| | |
| | | -- 注意:该页面对应的前台目录为views/mediaList文件夹下 |
| | | -- 如果你想更改到其他目录,请修改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 ('177034393526201', NULL, '媒体资源列表', '/mediaList/mediaListList', 'mediaList/MediaListList', NULL, NULL, 0, NULL, '1', 0.00, 0, NULL, 1, 0, 0, 0, 0, NULL, '1', 0, 0, 'admin', '2026-02-06 10:12:15', 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 ('177034393526202', '177034393526201', '添加媒体资源列表', NULL, NULL, 0, NULL, NULL, 2, 'mediaList:media_list:add', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-02-06 10:12:15', 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 ('177034393526203', '177034393526201', '编辑媒体资源列表', NULL, NULL, 0, NULL, NULL, 2, 'mediaList:media_list:edit', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-02-06 10:12:15', 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 ('177034393526204', '177034393526201', '删除媒体资源列表', NULL, NULL, 0, NULL, NULL, 2, 'mediaList:media_list:delete', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-02-06 10:12:15', 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 ('177034393526205', '177034393526201', '批量删除媒体资源列表', NULL, NULL, 0, NULL, NULL, 2, 'mediaList:media_list:deleteBatch', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-02-06 10:12:15', 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 ('177034393526206', '177034393526201', '导出excel_媒体资源列表', NULL, NULL, 0, NULL, NULL, 2, 'mediaList:media_list:exportXls', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-02-06 10:12:15', 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 ('177034393526207', '177034393526201', '导入excel_媒体资源列表', NULL, NULL, 0, NULL, NULL, 2, 'mediaList:media_list:importExcel', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2026-02-06 10:12:15', 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 ('177034393526308', 'f6817f48af4fb3af11b9e8bf182f618b', '177034393526201', NULL, '2026-02-06 10:12:15', '127.0.0.1'); |
| | | INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('177034393526309', 'f6817f48af4fb3af11b9e8bf182f618b', '177034393526202', NULL, '2026-02-06 10:12:15', '127.0.0.1'); |
| | | INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('177034393526310', 'f6817f48af4fb3af11b9e8bf182f618b', '177034393526203', NULL, '2026-02-06 10:12:15', '127.0.0.1'); |
| | | INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('177034393526311', 'f6817f48af4fb3af11b9e8bf182f618b', '177034393526204', NULL, '2026-02-06 10:12:15', '127.0.0.1'); |
| | | INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('177034393526312', 'f6817f48af4fb3af11b9e8bf182f618b', '177034393526205', NULL, '2026-02-06 10:12:15', '127.0.0.1'); |
| | | INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('177034393526313', 'f6817f48af4fb3af11b9e8bf182f618b', '177034393526206', NULL, '2026-02-06 10:12:15', '127.0.0.1'); |
| | | INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('177034393526314', 'f6817f48af4fb3af11b9e8bf182f618b', '177034393526207', NULL, '2026-02-06 10:12:15', '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 '../MediaList.data'; |
| | | import {saveOrUpdate} from '../MediaList.api'; |
| | | |
| | | export default defineComponent({ |
| | | name: "MediaListForm", |
| | | 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 = '/mediaList/mediaList/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="MediaListForm" /> |
| | | </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 '../MediaList.data'; |
| | | import {saveOrUpdate} from '../MediaList.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> |