vue3板提交合同模板条款库

jg-waiwang-pro
mhsnet 9 months ago
parent e10730d9cf
commit 4c66b90b09

@ -0,0 +1,7 @@
<?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="jnpf.mapper.ContractClauseMapper">
</mapper>

@ -0,0 +1,16 @@
package jnpf.mapper;
import jnpf.entity.ContractClauseEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* ContractClause
* V3.5
* https://www.jnpfsoft.com
* JNPF
* 2024-01-23
*/
public interface ContractClauseMapper extends BaseMapper<ContractClauseEntity> {
}

@ -0,0 +1,35 @@
package jnpf.service;
import jnpf.model.contractclause.*;
import jnpf.entity.*;
import java.util.*;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
/**
* ContractClause
* V3.5
* https://www.jnpfsoft.com
* JNPF
* 2024-01-23
*/
public interface ContractClauseService extends IService<ContractClauseEntity> {
List<ContractClauseEntity> getList(ContractClausePagination contractClausePagination);
List<ContractClauseEntity> getTypeList(ContractClausePagination contractClausePagination,String dataType);
ContractClauseEntity getInfo(String id);
void delete(ContractClauseEntity entity);
void create(ContractClauseEntity entity);
boolean update(String id, ContractClauseEntity entity);
//子表方法
//副表数据方法
String checkForm(ContractClauseForm form,int i);
void saveOrUpdate(ContractClauseForm contractClauseForm,String id, boolean isSave) throws Exception;
}

@ -0,0 +1,294 @@
package jnpf.service.impl;
import jnpf.entity.*;
import jnpf.mapper.ContractClauseMapper;
import jnpf.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jnpf.model.contractclause.*;
import java.math.BigDecimal;
import cn.hutool.core.util.ObjectUtil;
import jnpf.permission.model.authorize.AuthorizeConditionModel;
import jnpf.util.GeneraterSwapUtil;
import jnpf.database.model.superQuery.SuperQueryJsonModel;
import jnpf.database.model.superQuery.ConditionJsonModel;
import jnpf.database.model.superQuery.SuperQueryConditionModel;
import java.lang.reflect.Field;
import com.baomidou.mybatisplus.annotation.TableField;
import java.util.regex.Pattern;
import jnpf.model.QueryModel;
import java.util.stream.Collectors;
import jnpf.base.model.ColumnDataModel;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import jnpf.database.model.superQuery.SuperJsonModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.text.SimpleDateFormat;
import jnpf.util.*;
import java.util.*;
import jnpf.base.UserInfo;
import jnpf.permission.entity.UserEntity;
/**
*
* ContractClause
* V3.5
* https://www.jnpfsoft.com
* JNPF
* 2024-01-23
*/
@Service
public class ContractClauseServiceImpl extends ServiceImpl<ContractClauseMapper, ContractClauseEntity> implements ContractClauseService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Override
public List<ContractClauseEntity> getList(ContractClausePagination contractClausePagination){
return getTypeList(contractClausePagination,contractClausePagination.getDataType());
}
/** 列表查询 */
@Override
public List<ContractClauseEntity> getTypeList(ContractClausePagination contractClausePagination,String dataType){
String userId=userProvider.get().getUserId();
List<String> AllIdList =new ArrayList();
List<List<String>> intersectionList =new ArrayList<>();
boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc");
String columnData = !isPc ? ContractClauseConstant.getAppColumnData() : ContractClauseConstant.getColumnData();
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
int total=0;
int contractClauseNum =0;
QueryWrapper<ContractClauseEntity> contractClauseQueryWrapper=new QueryWrapper<>();
List<String> allSuperIDlist = new ArrayList<>();
String superOp ="";
if (ObjectUtil.isNotEmpty(contractClausePagination.getSuperQueryJson())){
List<String> allSuperList = new ArrayList<>();
List<List<String>> intersectionSuperList = new ArrayList<>();
String queryJson = contractClausePagination.getSuperQueryJson();
SuperJsonModel superJsonModel = JsonUtil.getJsonToBean(queryJson, SuperJsonModel.class);
int superNum = 0;
QueryWrapper<ContractClauseEntity> contractClauseSuperWrapper = new QueryWrapper<>();
contractClauseSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(contractClauseSuperWrapper,ContractClauseEntity.class,queryJson,"0"));
int contractClauseNum1 = contractClauseSuperWrapper.getExpression().getNormal().size();
if (contractClauseNum1>0){
List<String> contractClauseList =this.list(contractClauseSuperWrapper).stream().map(ContractClauseEntity::getId).collect(Collectors.toList());
allSuperList.addAll(contractClauseList);
intersectionSuperList.add(contractClauseList);
superNum++;
}
superOp = superNum > 0 ? superJsonModel.getMatchLogic() : "";
//and or
if(superOp.equalsIgnoreCase("and")){
allSuperIDlist = generaterSwapUtil.getIntersection(intersectionSuperList);
}else{
allSuperIDlist = allSuperList;
}
}
List<String> allRuleIDlist = new ArrayList<>();
String ruleOp ="";
if (ObjectUtil.isNotEmpty(ruleJson)){
List<String> allRuleList = new ArrayList<>();
List<List<String>> intersectionRuleList = new ArrayList<>();
SuperJsonModel ruleJsonModel = JsonUtil.getJsonToBean(ruleJson, SuperJsonModel.class);
int ruleNum = 0;
QueryWrapper<ContractClauseEntity> contractClauseSuperWrapper = new QueryWrapper<>();
contractClauseSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(contractClauseSuperWrapper,ContractClauseEntity.class,ruleJson,"0"));
int contractClauseNum1 = contractClauseSuperWrapper.getExpression().getNormal().size();
if (contractClauseNum1>0){
List<String> contractClauseList =this.list(contractClauseSuperWrapper).stream().map(ContractClauseEntity::getId).collect(Collectors.toList());
allRuleList.addAll(contractClauseList);
intersectionRuleList.add(contractClauseList);
ruleNum++;
}
ruleOp = ruleNum > 0 ? ruleJsonModel.getMatchLogic() : "";
//and or
if(ruleOp.equalsIgnoreCase("and")){
allRuleIDlist = generaterSwapUtil.getIntersection(intersectionRuleList);
}else{
allRuleIDlist = allRuleList;
}
}
boolean pcPermission = false;
boolean appPermission = false;
if(isPc && pcPermission){
if (!userProvider.get().getIsAdministrator()){
Object contractClauseObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(contractClauseQueryWrapper,ContractClauseEntity.class,contractClausePagination.getMenuId(),"0"));
if (ObjectUtil.isEmpty(contractClauseObj)){
return new ArrayList<>();
} else {
contractClauseQueryWrapper = (QueryWrapper<ContractClauseEntity>)contractClauseObj;
if( contractClauseQueryWrapper.getExpression().getNormal().size()>0){
contractClauseNum++;
}
}
}
}
if(!isPc && appPermission){
if (!userProvider.get().getIsAdministrator()){
Object contractClauseObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(contractClauseQueryWrapper,ContractClauseEntity.class,contractClausePagination.getMenuId(),"0"));
if (ObjectUtil.isEmpty(contractClauseObj)){
return new ArrayList<>();
} else {
contractClauseQueryWrapper = (QueryWrapper<ContractClauseEntity>)contractClauseObj;
if( contractClauseQueryWrapper.getExpression().getNormal().size()>0){
contractClauseNum++;
}
}
}
}
if(isPc){
if(ObjectUtil.isNotEmpty(contractClausePagination.getTitle())){
contractClauseNum++;
String value = contractClausePagination.getTitle() instanceof List ?
JsonUtil.getObjectToString(contractClausePagination.getTitle()) :
String.valueOf(contractClausePagination.getTitle());
contractClauseQueryWrapper.lambda().like(ContractClauseEntity::getTitle,value);
}
if(ObjectUtil.isNotEmpty(contractClausePagination.getContent())){
contractClauseNum++;
String value = contractClausePagination.getContent() instanceof List ?
JsonUtil.getObjectToString(contractClausePagination.getContent()) :
String.valueOf(contractClausePagination.getContent());
contractClauseQueryWrapper.lambda().like(ContractClauseEntity::getContent,value);
}
if(ObjectUtil.isNotEmpty(contractClausePagination.getType())){
contractClauseNum++;
contractClauseQueryWrapper.lambda().eq(ContractClauseEntity::getType,contractClausePagination.getType());
}
if(ObjectUtil.isNotEmpty(contractClausePagination.getStatus())){
contractClauseNum++;
contractClauseQueryWrapper.lambda().eq(ContractClauseEntity::getStatus,contractClausePagination.getStatus());
}
}
List<String> intersection = generaterSwapUtil.getIntersection(intersectionList);
if (total>0){
if (intersection.size()==0){
intersection.add("jnpfNullList");
}
contractClauseQueryWrapper.lambda().in(ContractClauseEntity::getId, intersection);
}
//是否有高级查询
if (StringUtil.isNotEmpty(superOp)){
if (allSuperIDlist.size()==0){
allSuperIDlist.add("jnpfNullList");
}
List<String> finalAllSuperIDlist = allSuperIDlist;
contractClauseQueryWrapper.lambda().and(t->t.in(ContractClauseEntity::getId, finalAllSuperIDlist));
}
//是否有数据过滤查询
if (StringUtil.isNotEmpty(ruleOp)){
if (allRuleIDlist.size()==0){
allRuleIDlist.add("jnpfNullList");
}
List<String> finalAllRuleIDlist = allRuleIDlist;
contractClauseQueryWrapper.lambda().and(t->t.in(ContractClauseEntity::getId, finalAllRuleIDlist));
}
//排序
if(StringUtil.isEmpty(contractClausePagination.getSidx())){
contractClauseQueryWrapper.lambda().orderByDesc(ContractClauseEntity::getId);
}else{
try {
String sidx = contractClausePagination.getSidx();
String[] strs= sidx.split("_name");
ContractClauseEntity contractClauseEntity = new ContractClauseEntity();
Field declaredField = contractClauseEntity.getClass().getDeclaredField(strs[0]);
declaredField.setAccessible(true);
String value = declaredField.getAnnotation(TableField.class).value();
contractClauseQueryWrapper="asc".equals(contractClausePagination.getSort().toLowerCase())?contractClauseQueryWrapper.orderByAsc(value):contractClauseQueryWrapper.orderByDesc(value);
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
}
if("0".equals(dataType)){
if((total>0 && AllIdList.size()>0) || total==0){
Page<ContractClauseEntity> page=new Page<>(contractClausePagination.getCurrentPage(), contractClausePagination.getPageSize());
IPage<ContractClauseEntity> userIPage=this.page(page, contractClauseQueryWrapper);
return contractClausePagination.setData(userIPage.getRecords(),userIPage.getTotal());
}else{
List<ContractClauseEntity> list = new ArrayList();
return contractClausePagination.setData(list, list.size());
}
}else{
return this.list(contractClauseQueryWrapper);
}
}
@Override
public ContractClauseEntity getInfo(String id){
QueryWrapper<ContractClauseEntity> queryWrapper=new QueryWrapper<>();
queryWrapper.lambda().eq(ContractClauseEntity::getId,id);
return this.getOne(queryWrapper);
}
@Override
public void create(ContractClauseEntity entity){
this.save(entity);
}
@Override
public boolean update(String id, ContractClauseEntity entity){
return this.updateById(entity);
}
@Override
public void delete(ContractClauseEntity entity){
if(entity!=null){
this.removeById(entity.getId());
}
}
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
@Override
public String checkForm(ContractClauseForm form,int i) {
boolean isUp =StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0");
String id="";
String countRecover = "";
if (isUp){
id = form.getId();
}
//主表字段验证
if(StringUtil.isEmpty(form.getTitle())){
return "条款标题不能为空";
}
return countRecover;
}
/**
* ()
* @param id
* @param contractClauseForm
* @return
*/
@Override
@Transactional
public void saveOrUpdate(ContractClauseForm contractClauseForm,String id, boolean isSave) throws Exception{
UserInfo userInfo=userProvider.get();
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
contractClauseForm = JsonUtil.getJsonToBean(
generaterSwapUtil.swapDatetime(ContractClauseConstant.getFormData(),contractClauseForm),ContractClauseForm.class);
ContractClauseEntity entity = JsonUtil.getJsonToBean(contractClauseForm, ContractClauseEntity.class);
if(isSave){
String mainId = RandomUtil.uuId() ;
entity.setId(mainId);
}else{
}
this.saveOrUpdate(entity);
}
}

@ -0,0 +1,190 @@
package jnpf.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jnpf.base.ActionResult;
import jnpf.base.UserInfo;
import jnpf.exception.DataException;
import jnpf.permission.entity.UserEntity;
import jnpf.service.*;
import jnpf.entity.*;
import jnpf.util.*;
import jnpf.model.contractclause.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.*;
import jnpf.annotation.JnpfField;
import jnpf.base.vo.PageListVO;
import jnpf.base.vo.PaginationVO;
import jnpf.base.vo.DownloadVO;
import jnpf.config.ConfigValueUtil;
import jnpf.base.entity.ProvinceEntity;
import java.io.IOException;
import java.util.stream.Collectors;
import jnpf.engine.entity.FlowTaskEntity;
import jnpf.exception.WorkFlowException;
import org.springframework.transaction.annotation.Transactional;
/**
* ContractClause
* @ V3.5
* @ https://www.jnpfsoft.com
* @ JNPF
* @ 2024-01-23
*/
@Slf4j
@RestController
@Tag(name = "ContractClause" , description = "scm")
@RequestMapping("/api/scm/ContractClause")
public class ContractClauseController {
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private ContractClauseService contractClauseService;
/**
*
*
* @param contractClausePagination
* @return
*/
@Operation(summary = "获取列表")
@PostMapping("/getList")
public ActionResult list(@RequestBody ContractClausePagination contractClausePagination)throws IOException{
List<ContractClauseEntity> list= contractClauseService.getList(contractClausePagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (ContractClauseEntity entity : list) {
Map<String, Object> contractClauseMap=JsonUtil.entityToMap(entity);
contractClauseMap.put("id", contractClauseMap.get("id"));
//副表数据
//子表数据
realList.add(contractClauseMap);
}
//数据转换
realList = generaterSwapUtil.swapDataList(realList, ContractClauseConstant.getFormData(), ContractClauseConstant.getColumnData(), contractClausePagination.getModuleId(),false);
//返回对象
PageListVO vo = new PageListVO();
vo.setList(realList);
PaginationVO page = JsonUtil.getJsonToBean(contractClausePagination, PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
*
*
* @param contractClauseForm
* @return
*/
@PostMapping()
@Operation(summary = "创建")
public ActionResult create(@RequestBody @Valid ContractClauseForm contractClauseForm) {
String b = contractClauseService.checkForm(contractClauseForm,0);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
try{
contractClauseService.saveOrUpdate(contractClauseForm, null ,true);
}catch(Exception e){
return ActionResult.fail("新增数据失败");
}
return ActionResult.success("创建成功");
}
/**
*
* @param id
* @param contractClauseForm
* @return
*/
@PutMapping("/{id}")
@Operation(summary = "更新")
public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid ContractClauseForm contractClauseForm,
@RequestParam(value = "isImport", required = false) boolean isImport){
contractClauseForm.setId(id);
if (!isImport) {
String b = contractClauseService.checkForm(contractClauseForm,1);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
}
ContractClauseEntity entity= contractClauseService.getInfo(id);
if(entity!=null){
try{
contractClauseService.saveOrUpdate(contractClauseForm,id,false);
}catch(Exception e){
return ActionResult.fail("修改数据失败");
}
return ActionResult.success("更新成功");
}else{
return ActionResult.fail("更新失败,数据不存在");
}
}
/**
*
* @param id
* @return
*/
@Operation(summary = "删除")
@DeleteMapping("/{id}")
@Transactional
public ActionResult delete(@PathVariable("id") String id){
ContractClauseEntity entity= contractClauseService.getInfo(id);
if(entity!=null){
//主表数据删除
contractClauseService.delete(entity);
}
return ActionResult.success("删除成功");
}
/**
* ()
* 使-
* @param id
* @return
*/
@Operation(summary = "表单信息(详情页)")
@GetMapping("/detail/{id}")
public ActionResult detailInfo(@PathVariable("id") String id){
ContractClauseEntity entity= contractClauseService.getInfo(id);
if(entity==null){
return ActionResult.fail("表单数据不存在!");
}
Map<String, Object> contractClauseMap=JsonUtil.entityToMap(entity);
contractClauseMap.put("id", contractClauseMap.get("id"));
//副表数据
//子表数据
contractClauseMap = generaterSwapUtil.swapDataDetail(contractClauseMap,ContractClauseConstant.getFormData(),"519502523443183621",false);
return ActionResult.success(contractClauseMap);
}
/**
* ()
* 使-
* @param id
* @return
*/
@Operation(summary = "信息")
@GetMapping("/{id}")
public ActionResult info(@PathVariable("id") String id){
ContractClauseEntity entity= contractClauseService.getInfo(id);
if(entity==null){
return ActionResult.fail("表单数据不存在!");
}
Map<String, Object> contractClauseMap=JsonUtil.entityToMap(entity);
contractClauseMap.put("id", contractClauseMap.get("id"));
//副表数据
//子表数据
contractClauseMap = generaterSwapUtil.swapDataForm(contractClauseMap,ContractClauseConstant.getFormData(),ContractClauseConstant.TABLEFIELDKEY,ContractClauseConstant.TABLERENAMES);
return ActionResult.success(contractClauseMap);
}
}

@ -0,0 +1,53 @@
package jnpf.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.util.Date;
/**
*
*
* @ V3.5
* @ https://www.jnpfsoft.com
* @ JNPF
* @ 2024-01-23
*/
@Data
@TableName("jg_contract_clause")
public class ContractClauseEntity {
@TableId(value ="ID" )
private String id;
@TableField(value = "TITLE" , updateStrategy = FieldStrategy.IGNORED)
private String title;
@TableField(value = "TYPE" , updateStrategy = FieldStrategy.IGNORED)
private String type;
@TableField(value = "STATUS" , updateStrategy = FieldStrategy.IGNORED)
private String status;
@TableField(value = "CONTENT" , updateStrategy = FieldStrategy.IGNORED)
private String content;
@TableField("WEIGHT")
private Integer weight;
@TableField(value = "REMARK" , updateStrategy = FieldStrategy.IGNORED)
private String remark;
@TableField(value = "ATTACHMENT" , updateStrategy = FieldStrategy.IGNORED)
private String attachment;
@TableField(value = "EFFECTIVE_DATE" , updateStrategy = FieldStrategy.IGNORED)
private Date effectiveDate;
@TableField("F_CREATOR_TIME")
private Date creatorTime;
@TableField("F_CREATOR_USER_ID")
private String creatorUserId;
@TableField("F_LAST_MODIFY_TIME")
private Date lastModifyTime;
@TableField("F_LAST_MODIFY_USER_ID")
private String lastModifyUserId;
@TableField("F_DELETE_TIME")
private Date deleteTime;
@TableField("F_DELETE_USER_ID")
private String deleteUserId;
@TableField("F_DELETE_MARK")
private Integer deleteMark;
@TableField("F_TENANT_ID")
private String tenantId;
@TableField("F_FLOW_ID")
private String flowId;
}

@ -0,0 +1,41 @@
package jnpf.model.contractclause;
import lombok.Data;
import java.util.List;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* ContractClause
* @ V3.5
* @ https://www.jnpfsoft.com
* @ JNPF
* @ 2024-01-23
*/
@Data
public class ContractClauseForm {
/** 主键 */
private String id;
/** 条款类型 **/
@JsonProperty("type")
private String type;
/** 生效日期 **/
@JsonProperty("effectiveDate")
private String effectiveDate;
/** 条款标题 **/
@JsonProperty("title")
private String title;
/** 条款内容 **/
@JsonProperty("content")
private String content;
/** 附件 **/
@JsonProperty("attachment")
private Object attachment;
/** 备注 **/
@JsonProperty("remark")
private String remark;
/** 状态 **/
@JsonProperty("status")
private String status;
}

@ -0,0 +1,42 @@
package jnpf.model.contractclause;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import jnpf.base.Pagination;
import java.util.List;
/**
*
* ContractClause
* @ V3.5
* @ https://www.jnpfsoft.com
* @ JNPF
* @ 2024-01-23
*/
@Data
public class ContractClausePagination extends Pagination {
/** 查询key */
private String[] selectKey;
/** json */
private String json;
/** 数据类型 0-当前页1-全部数据 */
private String dataType;
/** 高级查询 */
private String superQueryJson;
/** 功能id */
private String moduleId;
/** 菜单id */
private String menuId;
/** 条款标题 */
@JsonProperty("title")
private Object title;
/** 条款内容 */
@JsonProperty("content")
private Object content;
/** 条款类型 */
@JsonProperty("type")
private Object type;
/** 条款状态 */
@JsonProperty("status")
private Object status;
}

@ -0,0 +1,148 @@
<template>
<BasicModal v-bind="$attrs" @register="registerModal" :title="title" width="600px"
:minHeight="100" :showOkBtn="false">
<template #insertFooter>
</template>
<!-- 表单 -->
<a-row class="dynamic-form ">
<a-form :colon="false" size="default" layout= "horizontal"
labelAlign= "right"
:labelCol="{ style: { width: '100px' } }" :model="dataForm" ref="formRef">
<a-row :gutter="15">
<!-- 具体表单 -->
<a-col :span="24" class="ant-col-item" >
<a-form-item
name="type" >
<template #label>条款类型</template>
<p>{{dataForm.type}}</p>
</a-form-item>
</a-col>
<a-col :span="24" class="ant-col-item" >
<a-form-item
name="effectiveDate" >
<template #label>生效日期</template>
<p>{{dataForm.effectiveDate}}</p>
</a-form-item>
</a-col>
<a-col :span="24" class="ant-col-item" >
<a-form-item
name="title" >
<template #label>条款标题</template>
<p>{{dataForm.title}}</p>
</a-form-item>
</a-col>
<a-col :span="24" class="ant-col-item" >
<a-form-item
name="content" >
<template #label>条款内容</template>
<p>{{dataForm.content}}</p>
</a-form-item>
</a-col>
<a-col :span="24" class="ant-col-item" >
<a-form-item
name="attachment" >
<template #label>附件</template>
<JnpfUploadFile v-model:value="dataForm.attachment"
disabled
detailed :fileSize="20" sizeUnit="MB" :limit="9" pathType="defaultPath" :isAccount="0" buttonText="点击上传" >
</JnpfUploadFile>
</a-form-item>
</a-col>
<a-col :span="24" class="ant-col-item" >
<a-form-item
name="remark" >
<template #label>备注</template>
<p>{{dataForm.remark}}</p>
</a-form-item>
</a-col>
<a-col :span="24" class="ant-col-item" >
<a-form-item
name="status" >
<template #label>状态</template>
<p>{{dataForm.status}}</p>
</a-form-item>
</a-col>
<!-- 表单结束 -->
</a-row>
</a-form>
</a-row>
</BasicModal>
<!-- 有关联表单详情开始 -->
<RelationDetail ref="relationDetailRef" />
<!-- 有关联表单详情结束 -->
</template>
<script lang="ts" setup>
import { getDetailInfo } from './helper/api';
import { getConfigData } from '/@/api/onlineDev/visualDev';
import { reactive, toRefs, nextTick, ref, computed, unref ,toRaw} from 'vue';
import { BasicModal, useModal } from '/@/components/Modal';
//
import RelationDetail from '/@/views/common/dynamicModel/list/detail/index.vue';
//
import { usePermission } from '/@/hooks/web/usePermission';
import { useMessage } from '/@/hooks/web/useMessage';
interface State {
dataForm: any;
title: string;
}
defineOptions({ name: 'Detail' });
const { createMessage, createConfirm } = useMessage();
const [registerModal, { openModal, setModalProps, closeModal }] = useModal();
const relationDetailRef = ref<any>(null);
const state = reactive<State>({
dataForm:{},
title: '详情',
});
const { title, dataForm } = toRefs(state);
//
const { hasFormP } = usePermission();
defineExpose({ init });
function init(data) {
state.dataForm.id = data.id;
openModal();
nextTick(() => {
setTimeout(initData, 0);
});
}
function initData() {
changeLoading(true);
if (state.dataForm.id) {
getData(state.dataForm.id);
} else {
closeModal();
}
}
function getData(id) {
getDetailInfo(id).then((res) => {
state.dataForm = res.data || {};
nextTick(() => {
changeLoading(false);
});
});
}
function toDetail(modelId, id) {
if (!id) return;
getConfigData(modelId).then((res) => {
if (!res.data || !res.data.formData) return;
const formConf = JSON.parse(res.data.formData);
formConf.popupType = 'general';
const data = { id, formConf, modelId };
relationDetailRef.value?.init(data);
});
}
function setFormProps(data) {
setModalProps(data);
}
function changeLoading(loading) {
setFormProps({ loading });
}
</script>

@ -0,0 +1,392 @@
<template>
<BasicModal v-bind="$attrs" @register="registerModal" :title="title" width="600px"
:minHeight="100" :showContinueBtn="showContinueBtn"
:continueText="continueText" cancelText="取消" okText="确定" @ok="handleSubmit(0)" @continue="handleSubmit(1)" :closeFunc="onClose">
<template #insertFooter>
<a-space :size="10" v-if="dataForm.id" class="float-left">
<a-button :disabled="getPrevDisabled" @click="handlePrev"></a-button>
<a-button :disabled="getNextDisabled" @click="handleNext"></a-button>
</a-space>
</template>
<a-row class="dynamic-form ">
<a-form :colon="false" size="default" layout= "horizontal"
labelAlign= "right"
:labelCol="{ style: { width: '100px' } }" :model="dataForm" :rules="dataRule" ref="formRef">
<a-row :gutter="15">
<!-- 具体表单 -->
<a-col :span="24" class="ant-col-item" >
<a-form-item
name="type" >
<template #label>条款类型</template> <JnpfRadio v-model:value="dataForm.type" @change="changeData('type',-1)"
:style='{"width":"100%"}' size="default" :options="optionsObj.typeOptions" :fieldNames="optionsObj.typeProps"
direction="horizontal" optionType="default" >
</JnpfRadio>
</a-form-item>
</a-col>
<a-col :span="24" class="ant-col-item" >
<a-form-item
name="effectiveDate" >
<template #label>生效日期</template> <JnpfDatePicker v-model:value="dataForm.effectiveDate" @change="changeData('effectiveDate',-1)"
placeholder="请选择" :allowClear='true' :style='{"width":"100%"}' format="yyyy-MM-dd" :startTime="getRelationDate(false,1,1,'','')" :endTime="getRelationDate(false,1,1,'','')" >
</JnpfDatePicker>
</a-form-item>
</a-col>
<a-col :span="24" class="ant-col-item" >
<a-form-item
name="title" >
<template #label>条款标题</template> <JnpfInput v-model:value="dataForm.title" @change="changeData('title',-1)"
placeholder="请输入" :allowClear='true' :style='{"width":"100%"}'>
</JnpfInput>
</a-form-item>
</a-col>
<a-col :span="24" class="ant-col-item" >
<a-form-item
name="content" >
<template #label>条款内容</template> <JnpfTextarea v-model:value="dataForm.content" @change="changeData('content',-1)"
placeholder="请输入" :allowClear='true' :style='{"width":"100%"}' :autoSize='{"minRows":4,"maxRows":4}' >
</JnpfTextarea>
</a-form-item>
</a-col>
<a-col :span="24" class="ant-col-item" >
<a-form-item
name="attachment" >
<template #label>附件</template> <JnpfUploadFile v-model:value="dataForm.attachment" @change="changeData('attachment',-1)"
:fileSize="20" sizeUnit="MB" :limit="9" pathType="defaultPath" :isAccount="0" buttonText="点击上传" tipText="支持格式:.rar .zip .doc .docx .pdf 单个文件不能超过20MB" >
</JnpfUploadFile>
</a-form-item>
</a-col>
<a-col :span="24" class="ant-col-item" >
<a-form-item
name="remark" >
<template #label>备注</template> <JnpfTextarea v-model:value="dataForm.remark" @change="changeData('remark',-1)"
placeholder="请输入" :maxlength="200" :allowClear='true' :style='{"width":"100%"}' :autoSize='{"minRows":4,"maxRows":4}' >
</JnpfTextarea>
</a-form-item>
</a-col>
<a-col :span="24" class="ant-col-item" >
<a-form-item
name="status" >
<template #label>状态</template> <JnpfRadio v-model:value="dataForm.status" @change="changeData('status',-1)"
:style='{"width":"100%"}' size="default" :options="optionsObj.statusOptions" :fieldNames="optionsObj.statusProps"
direction="horizontal" optionType="default" >
</JnpfRadio>
</a-form-item>
</a-col>
<!-- 表单结束 -->
</a-row>
</a-form>
</a-row>
</BasicModal>
</template>
<script lang="ts" setup>
import { create, update, getInfo } from './helper/api';
import { reactive, toRefs, nextTick, ref, unref, computed,toRaw } from 'vue';
import { BasicModal, useModal } from '/@/components/Modal';
import { JnpfRelationForm } from '/@/components/Jnpf';
import { useMessage } from '/@/hooks/web/useMessage';
import { useUserStore } from '/@/store/modules/user';
import type { FormInstance } from 'ant-design-vue';
import { thousandsFormat , getDateTimeUnit, getTimeUnit} from '/@/utils/jnpf';
import { getDictionaryDataSelector } from '/@/api/systemData/dictionary';
import { getDataInterfaceRes } from '/@/api/systemData/dataInterface';
import dayjs from 'dayjs';
//
import { usePermission } from '/@/hooks/web/usePermission';
interface State {
dataForm: any;
tableRows: any;
dataRule: any;
optionsObj: any;
childIndex: any;
isEdit: any;
interfaceRes: any;
//
ableAll: any;
title: string;
continueText: string; allList: any[];
currIndex: number;
isContinue: boolean;
submitType: number;
showContinueBtn: boolean;
}
const emit = defineEmits(['reload']);
const userStore = useUserStore();
const userInfo = userStore.getUserInfo;
const { createMessage, createConfirm } = useMessage();
const [registerModal, { openModal, setModalProps }] = useModal();
const formRef = ref<FormInstance>();
const state = reactive<State>({
dataForm: {
type:'contractClausePurchase',
effectiveDate:undefined,
title:undefined,
content:undefined,
attachment:[],
remark:undefined,
status:'1',
},
tableRows:{
},
dataRule: {
type: [
{
required: true,
message: '不能为空',
trigger: 'change'
},
],
effectiveDate: [
{
required: true,
message: '不能为空',
trigger: 'change'
},
],
title: [
{
required: true,
message: '不能为空',
trigger: 'blur'
},
],
content: [
{
required: true,
message: '不能为空',
trigger: 'blur'
},
],
},
optionsObj:{
typeOptions:[],
typeProps:{"label":"fullName","value":"enCode" },
statusOptions:[],
statusProps:{"label":"fullName","value":"enCode" },
},
childIndex: -1,
isEdit: false,
interfaceRes: {"attachment":[],"remark":[],"type":[],"title":[],"effectiveDate":[],"content":[],"status":[]},
//
ableAll:{
},
title: "",
continueText: "", allList: [],
currIndex: 0,
isContinue: false,
submitType: 0,
showContinueBtn: true ,
});
const { title, continueText, showContinueBtn, dataRule, dataForm, optionsObj, ableAll } = toRefs(state);
const getPrevDisabled = computed(() => state.currIndex === 0);
const getNextDisabled = computed(() => state.currIndex === state.allList.length - 1);
//
const { hasFormP } = usePermission();
defineExpose({ init });
function init(data) {
state.isContinue = false;
state.title = !data.id ? '新增' : '编辑';
state.continueText = !data.id ? '确定并新增' : '确定并继续'; setFormProps({ continueLoading: false });
state.dataForm.id = data.id;
openModal();
state.allList = data.allList;
state.currIndex = state.allList.length && data.id ? state.allList.findIndex((item) => item.id === data.id) : 0;
nextTick(() => {
getForm().resetFields();
setTimeout(initData, 0);
});
}
function initData() {
changeLoading(true);
if (state.dataForm.id) {
getData(state.dataForm.id);
} else {
//options
gettypeOptions();
getstatusOptions();
//
state.dataForm={
type:'contractClausePurchase',
effectiveDate:undefined,
title:undefined,
content:undefined,
attachment:[],
remark:undefined,
status:'1',
};
state.childIndex = -1;
changeLoading(false);
}
}
function getForm() {
const form = unref(formRef);
if (!form) {
throw new Error('form is null!');
}
return form;
}
function getData(id) {
getInfo(id).then((res) => {
state.dataForm = res.data || {};
gettypeOptions();
getstatusOptions();
state.childIndex = -1;
changeLoading(false);
});
}
async function handleSubmit(type) {
try {
const values = await getForm()?.validate();
if (!values) return;
state.submitType = type;
state.submitType === 1 ? setFormProps({ continueLoading: true }) : setFormProps({ confirmLoading: true });
const formMethod = state.dataForm.id ? update : create;
formMethod(state.dataForm)
.then((res) => {
createMessage.success(res.msg);
state.submitType === 1 ? setFormProps({ continueLoading: false }) : setFormProps({ confirmLoading: false });
if (state.submitType == 1) {
initData();
state.isContinue = true;
} else {
setFormProps({ visible: false });
emit('reload');
}
})
.catch(() => {
state.submitType === 1 ? setFormProps({ continueLoading: false }) : setFormProps({ confirmLoading: false });
});
} catch (_) {}
}
function handlePrev() {
state.currIndex--;
handleGetNewInfo();
}
function handleNext() {
state.currIndex++;
handleGetNewInfo();
}
function handleGetNewInfo() {
changeLoading(true);
getForm().resetFields();
const id = state.allList[state.currIndex].id;
getData(id);
}
function setFormProps(data) {
setModalProps(data);
}
function changeLoading(loading) {
setModalProps({ loading });
}
async function onClose() {
if (state.isContinue) emit('reload');
return true;
}
function changeData(model, index) {
state.isEdit = false
state.childIndex = index
for (let key in state.interfaceRes) {
if (key != model) {
let faceReList = state.interfaceRes[key]
for (let i = 0; i < faceReList.length; i++) {
let relationField = faceReList[i].relationField;
if(relationField){
let modelAll = relationField.split('-');
let faceMode = '';
for (let i = 0; i < modelAll.length; i++) {
faceMode += modelAll[i];
}
if (faceMode == model) {
let options = 'get' + key + 'Options';
eval(options)(true);
changeData(key, index)
}
}
}
}
}
}
function changeDataFormData(type, data, model,index,defaultValue) {
if(!state.isEdit) {
if (type == 2) {
for (let i = 0; i < state.dataForm[data].length; i++) {
if (index == -1) {
state.dataForm[data][i][model] = defaultValue
} else if (index == i) {
state.dataForm[data][i][model] = defaultValue
}
}
} else {
state.dataForm[data] = defaultValue
}
}
}
//--
function gettypeOptions() {
getDictionaryDataSelector('519484014000605701').then(res => {
state.optionsObj.typeOptions = res.data.list
})
}
//--
function getstatusOptions() {
getDictionaryDataSelector('519495883595713029').then(res => {
state.optionsObj.statusOptions = res.data.list
})
}
function getRelationDate(timeRule, timeType, timeTarget, timeValueData, dataValue) {
let timeDataValue: any = null;
let timeValue = Number(timeValueData);
if (timeRule) {
if (timeType == 1) {
timeDataValue = timeValue;
} else if (timeType == 2) {
timeDataValue = dataValue;
} else if (timeType == 3) {
timeDataValue = new Date().getTime();
} else if (timeType == 4 || timeType == 5) {
const type = getTimeUnit(timeTarget);
const method = timeType == 4 ? 'subtract' : 'add';
timeDataValue = dayjs()[method](timeValue, type).valueOf();
}
}
return timeDataValue;
}
function getRelationTime(timeRule, timeType, timeTarget, timeValue, formatType, dataValue) {
let format = formatType == 'HH:mm' ? 'HH:mm:00' : formatType;
let timeDataValue: any = null;
if (timeRule) {
if (timeType == 1) {
timeDataValue = timeValue || '00:00:00';
if (timeDataValue.split(':').length == 3) {
timeDataValue = timeDataValue;
} else {
timeDataValue = timeDataValue + ':00';
}
} else if (timeType == 2) {
timeDataValue = dataValue;
} else if (timeType == 3) {
timeDataValue = dayjs().format(format);
} else if (timeType == 4 || timeType == 5) {
const type = getTimeUnit(timeTarget + 3);
const method = timeType == 4 ? 'subtract' : 'add';
timeDataValue = dayjs()[method](timeValue, type).format(format);
}
}
return timeDataValue;
}
</script>

@ -0,0 +1,34 @@
import { defHttp } from '/@/utils/http/axios';
// 获取列表
export function getList(data) {
return defHttp.post({ url: '/api/scm/ContractClause/getList', data });
}
// 新建
export function create(data) {
return defHttp.post({ url:'/api/scm/ContractClause', data });
}
// 修改
export function update(data) {
return defHttp.put({ url: '/api/scm/ContractClause/'+ data.id, data });
}
// 详情(无转换数据)
export function getInfo(id) {
return defHttp.get({ url: '/api/scm/ContractClause/' + id });
}
// 获取(转换数据)
export function getDetailInfo(id) {
return defHttp.get({ url: '/api/scm/ContractClause/detail/' + id });
}
// 删除
export function del(id) {
return defHttp.delete({ url: '/api/scm/ContractClause/' + id });
}
// 批量删除数据
export function batchDelete(data) {
return defHttp.delete({ url: '/api/scm/ContractClause/batchRemove', data });
}
// 导出
export function exportData(data) {
return defHttp.post({ url: '/api/scm/ContractClause/Actions/Export', data });
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1,480 @@
<template>
<div class="jnpf-content-wrapper">
<div class="jnpf-content-wrapper-center">
<div class="jnpf-content-wrapper-search-box">
<BasicForm @register="registerSearchForm" :schemas="searchSchemas"
@advanced-change="redoHeight" @submit="handleSearchSubmit" @reset="handleSearchReset"
class="search-form">
</BasicForm>
</div>
<div class="jnpf-content-wrapper-content">
<BasicTable @register="registerTable" v-bind="getTableBindValue" ref="tableRef"
@columns-change="handleColumnChange">
<template #tableTitle>
<a-button type="primary" preIcon="icon-ym icon-ym-btn-add"
@click="addHandle()">新增</a-button>
</template>
<template #toolbar>
<a-tooltip placement="top">
<template #title>
<span>{{ t('common.superQuery') }}</span>
</template>
<filter-outlined @click="openSuperQuery(true, { columnOptions: superQueryJson })" />
</a-tooltip>
</template>
<template #bodyCell="{ column, record, index }">
<template v-for="(item, index) in childColumnList" v-if="childColumnList.length">
<template
v-if="column?.id?.includes('-') && item.children && item.children[0] && column.key === item.children[0]?.dataIndex">
<ChildTableColumn :data="record[item.prop]" :head="item.children"
@toggleExpand="toggleExpand(record, item.prop+`Expand`)" @toDetail="toDetail"
:expand="record[item.prop+`Expand`]" :key="index" />
</template>
</template>
<template v-if="column.jnpfKey === 'relationForm'">
<p class="link-text"
@click="toDetail(column.modelId, record[column.dataIndex+`_id`])">
{{ record[column.dataIndex] }}</p>
</template>
<template v-if="column.jnpfKey === 'inputNumber'">
<jnpf-input-number v-model:value="record[column.prop]" :precision="column.precision" :thousands="column.thousands" disabled detailed />
</template>
<template v-if="column.jnpfKey === 'calculate'">
<jnpf-calculate
v-model:value="record[column.prop]"
:isStorage="column.isStorage"
:precision="column.precision"
:thousands="column.thousands"
detailed />
</template>
<template v-if="column.key === 'action' && !record.top">
<TableAction :actions="getTableActions(record)" />
</template>
</template>
</BasicTable>
</div>
</div>
<Form ref="formRef" @reload="reload" />
<Detail ref="detailRef" />
<RelationDetail ref="relationDetailRef" />
<SuperQueryModal @register="registerSuperQueryModal" @superQuery="handleSuperQuery" />
</div>
</template>
<script lang="ts" setup>
import { getList, del, exportData, batchDelete } from './helper/api';
import { getConfigData } from '/@/api/onlineDev/visualDev';
import { getDictionaryDataSelector } from '/@/api/systemData/dictionary';
import { getDataInterfaceRes } from '/@/api/systemData/dataInterface';
import { ref, reactive, onMounted, toRefs, computed, unref, nextTick, toRaw } from 'vue';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { useOrganizeStore } from '/@/store/modules/organize';
import { useUserStore } from '/@/store/modules/user';
import { BasicModal, useModal } from '/@/components/Modal';
import { usePopup } from '/@/components/Popup';
import { ScrollContainer } from '/@/components/Container';
import { BasicLeftTree, TreeActionType } from '/@/components/Tree';
import { BasicForm, useForm } from '/@/components/Form';
import { BasicTable, useTable, TableAction, ActionItem, TableActionType } from '/@/components/Table';
import { SuperQueryModal } from '/@/components/CommonModal';
import Form from './Form.vue';
import Detail from './Detail.vue';
//
import RelationDetail from '/@/views/common/dynamicModel/list/detail/index.vue';
//
import ChildTableColumn from '/@/views/common/dynamicModel/list/ChildTableColumn.vue';
import { useRoute } from 'vue-router';
import { FilterOutlined } from '@ant-design/icons-vue';
import { getSearchFormSchemas } from '/@/components/FormGenerator/src/helper/transform';
import { cloneDeep } from 'lodash-es';
import columnList from './helper/columnList';
import searchList from './helper/searchList';
import superQueryJson from './helper/superQueryJson';
import { dyOptionsList, systemComponentsList } from '/@/components/FormGenerator/src/helper/config';
import { thousandsFormat} from '/@/utils/jnpf';
interface State {
formFlowId: string;
flowList: any[];
config: any;
columnList: any[];
printListOptions: any[];
columnBtnsList: any[];
customBtnsList: any[];
treeFieldNames: any;
leftTreeData: any[];
leftTreeLoading: boolean;
treeActiveId: string;
treeActiveNodePath: any;
columns: any[];
complexColumns: any[];
childColumnList: any[];
exportList: any[];
cacheList: any[];
currFlow: any;
isCustomCopy: boolean;
candidateType: number;
currRow: any;
workFlowFormData: any;
expandObj: any;
columnSettingList: any[];
searchSchemas: any[];
treeRelationObj: any;
treeQueryJson: any;
}
const route = useRoute();
const { createMessage, createConfirm } = useMessage();
const { t } = useI18n();
const organizeStore = useOrganizeStore();
const userStore = useUserStore();
const userInfo = userStore.getUserInfo;
const [registerExportModal, { openModal: openExportModal, closeModal: closeExportModal, setModalProps: setExportModalProps }] = useModal();
const [registerImportModal, { openModal: openImportModal }] = useModal();
const [registerSuperQueryModal, { openModal: openSuperQuery }] = useModal();
const formRef = ref<any>(null);
const tableRef = ref<Nullable<TableActionType>>(null);
const detailRef = ref<any>(null);
const relationDetailRef = ref<any>(null);
const defaultSearchInfo = {
menuId: route.meta.modelId as string,
moduleId:'519502523443183621',
superQueryJson: '',
dataType:0,
};
const searchInfo = reactive({
...cloneDeep(defaultSearchInfo),
});
const state = reactive<State>({
formFlowId: '',
flowList: [],
config: {},
columnList: [],
printListOptions: [],
columnBtnsList: [],
customBtnsList: [],
treeFieldNames: {
children: 'children' ,
title: 'fullName' ,
key: 'id' ,
isLeaf: 'isLeaf',
},
leftTreeData: [],
leftTreeLoading: false,
treeActiveId: '',
treeActiveNodePath: [],
columns: [],
complexColumns: [], //
childColumnList: [],
exportList: [],
cacheList: [],
currFlow: {},
isCustomCopy: false,
candidateType: 1,
currRow: {},
workFlowFormData: {},
expandObj: {},
columnSettingList: [],
searchSchemas: [],
treeRelationObj: null,
treeQueryJson: {},
});
const { flowList, childColumnList, searchSchemas } = toRefs(state);
const [registerSearchForm, { updateSchema, resetFields, submit: searchFormSubmit }] = useForm({
baseColProps: { span: 6 },
showActionButtonGroup: true,
showAdvancedButton: true,
compact: true,
});
const [registerTable, { reload, setLoading, getFetchParams, getSelectRowKeys, redoHeight,clearSelectedRowKeys }] = useTable({
api: getList,
immediate: false,
clickToRowSelect: false,
afterFetch: (data) => {
const list = data.map((o) => ({
...o,
...state.expandObj,
}));
state.cacheList = cloneDeep(list);
return list;
},
});
const getTableBindValue = computed(() => {
let columns = state.complexColumns;
const data: any = {
pagination: { pageSize: 20 }, //
searchInfo: unref(searchInfo),
defSort: {
sort: "desc", //sort
sidx: "", //defaultSidx
},
columns,
bordered: true,
actionColumn: {
width: 150,
title: '操作',
dataIndex: 'action',
},
};
return data;
});
function init() {
state.config = {};
searchInfo.menuId = route.meta.modelId as string;
state.columnList = columnList;
setLoading(true);
getSearchSchemas();
getColumnList();
nextTick(() => {
//
searchFormSubmit();
});
}
function getSearchSchemas() {
const schemas = getSearchFormSchemas(searchList);
state.searchSchemas = schemas;
schemas.forEach((cur) => {
const config = cur.__config__;
if (dyOptionsList.includes(config.jnpfKey)) {
if (config.dataType === 'dictionary') {
if (!config.dictionaryType) return;
getDictionaryDataSelector(config.dictionaryType).then((res) => {
updateSchema([{ field: cur.field, componentProps: { options: res.data.list } }]);
});
}
if (config.dataType === 'dynamic') {
if (!config.propsUrl) return;
const query = { paramList: config.templateJson || [] };
getDataInterfaceRes(config.propsUrl, query).then((res) => {
const data = Array.isArray(res.data) ? res.data : [];
updateSchema([{ field: cur.field, componentProps: { options: data } }]);
});
}
}
cur.defaultValue = cur.value;
});
}
function getColumnList() {
//
let columnList = state.columnList;
state.exportList = columnList;
let columns = columnList.map((o) => ({
...o,
title: o.label,
dataIndex: o.prop,
align: o.align,
fixed: o.fixed == 'none' ? false : o.fixed,
sorter: o.sortable,
width: o.width || 100,
}));
//
columns = getComplexColumns(columns);
state.columns = columns.filter((o) => o.prop.indexOf('-') < 0);
//
getChildComplexColumns(columns);
}
//
function getComplexColumns(columns) {
//
let complexHeaderList: any[] = [];
if (!complexHeaderList.length) return columns;
let childColumns: any[] = [];
for (let i = 0; i < complexHeaderList.length; i++) {
const e = complexHeaderList[i];
e.title = e.fullName;
e.align = e.align;
e.dataIndex = e.id;
e.prop = e.id;
e.children = [];
e.jnpfKey = 'complexHeader';
if (e.childColumns?.length) {
childColumns.push(...e.childColumns);
for (let k = 0; k < e.childColumns.length; k++) {
const item = e.childColumns[k];
for (let j = 0; j < columns.length; j++) {
const o = columns[j];
if (o.__vModel__ == item && o.fixed !== 'left' && o.fixed !== 'right' && !o.__config__.isSubTable) e.children.push({ ...o });
}
}
}
}
complexHeaderList = complexHeaderList.filter(o => o.children.length);
for (let i = 0; i < columns.length; i++) {
const item = columns[i];
if (!childColumns.includes(item.__vModel__) || item.__config__.isSubTable) complexHeaderList.push(item);
}
return complexHeaderList;
}
//
function getChildComplexColumns(columnList) {
let list: any[] = [];
for (let i = 0; i < columnList.length; i++) {
const e = columnList[i];
if (!e.prop.includes('-')) {
list.push(e);
} else {
let prop = e.prop.split('-')[0];
let vModel = e.prop.split('-')[1];
let label = e.label.split('-')[0];
let childLabel = e.label.replace(label + '-', '');
let newItem = {
align: 'center',
jnpfKey: 'table',
prop,
label,
title: label,
dataIndex: prop,
children: [],
};
e.dataIndex = vModel;
e.title = childLabel;
if (!state.expandObj.hasOwnProperty(prop+`Expand`)) state.expandObj[prop+`Expand`] = false;
if (!list.some((o) => o.prop === prop)) list.push(newItem);
for (let i = 0; i < list.length; i++) {
if (list[i].prop === prop) {
list[i].children.push(e);
break;
}
}
}
}
//
getMergeList(list);
state.complexColumns = list;
state.childColumnList = list.filter((o) => o.jnpfKey === 'table');
// 100
for (let i = 0; i < state.childColumnList.length; i++) {
const e = state.childColumnList[i];
if (e.children?.length) e.children = e.children.map(o => ({ ...o, width: 100 }));
}
}
function getMergeList(list) {
list.forEach((item) => {
if (item.jnpfKey === 'table' && item.children && item.children.length) {
item.children.forEach((child, index) => {
if (index == 0) {
child.customCell = () => ({
rowspan: 1,
colspan: item.children.length,
class: 'child-table-box',
});
} else {
child.customCell = () => ({
rowspan: 0,
colspan: 0,
});
}
});
}
});
}
function toggleExpand(row, field) {
row[field] = !row[field];
}
//
function toDetail(modelId, id) {
if (!id) return;
getConfigData(modelId).then((res) => {
if (!res.data || !res.data.formData) return;
const formConf = JSON.parse(res.data.formData);
formConf.popupType = 'general';
const data = { id, formConf, modelId };
relationDetailRef.value?.init(data);
});
}
function handleColumnChange(data) {
state.columnSettingList = data;
}
function getTableActions(record): ActionItem[] {
return [
{
label: '编辑',
onClick: updateHandle.bind(null, record),
},
{
label: '删除',
color: 'error',
modelConfirm: {
onOk: handleDelete.bind(null, record.id),
},
},
{
label: '详情',
onClick: goDetail.bind(null, record),
},
];
}
//
function updateHandle(record) {
//
const data = {
id: record.id,
menuId: searchInfo.menuId,
allList: state.cacheList,
};
formRef.value?.init(data);
}
//
function handleDelete(id) {
del(id).then((res) => {
createMessage.success(res.msg);
clearSelectedRowKeys();
reload();
});
}
//
function goDetail(record) {
//
const data = {
id: record.id,
};
detailRef.value?.init(data);
}
//
function addHandle() {
//
const data = {
id: '',
menuId: searchInfo.menuId,
allList: state.cacheList,
};
formRef.value?.init(data);
}
//
function handleSuperQuery(superQueryJson) {
searchInfo.superQueryJson = superQueryJson;
reload({ page: 1 });
}
function handleSearchReset() {
searchFormSubmit();
}
function handleSearchSubmit(data) {
clearSelectedRowKeys();
let obj = {
...defaultSearchInfo,
superQueryJson: searchInfo.superQueryJson,
...data,
...(state.treeQueryJson || {})
};
Object.keys(searchInfo).map(key => {
delete searchInfo[key];
});
for (let [key, value] of Object.entries(obj)) {
searchInfo[key.replaceAll('-', '_')] = value;
}
console.log(searchInfo);
reload({ page: 1 });
}
onMounted(() => {
init();
});
</script>
Loading…
Cancel
Save