动态表单APP端新增页面

This commit is contained in:
wenc000 2020-02-11 00:23:09 +08:00
parent 0313511b5c
commit 4aadcec092
13 changed files with 770 additions and 348 deletions

View File

@ -0,0 +1,124 @@
package com.cm.common.plugin.controller.app.apis.dynamic;
import com.cm.common.base.AbstractController;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.plugin.service.dynamic.IDynamicDataService;
import com.cm.common.pojo.ListPage;
import com.cm.common.result.ErrorResult;
import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultList;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: DynamicDataController
* @Description: 动态数据
* @Author: WangGeng
* @Date: 2019/12/4 15:23
* @Version: 1.0
**/
@Api(tags = ISystemConstant.API_TAGS_APP_ROUTE_PREFIX + "动态数据接口")
@RestController
@RequestMapping(ISystemConstant.APP_PREFIX + "/dynamicdata")
public class DynamicDataAppController extends AbstractController {
@Autowired
private IDynamicDataService dynamicDataService;
@ApiOperation(value = "保存动态数据", notes = "保存动态数据接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "tableName", value = "表名", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("savedynamicdata/{tableName}")
public SuccessResult saveDynamicData(@PathVariable("tableName") String tableName, @RequestBody Map<String, Object> params) {
return dynamicDataService.saveDynamicData(tableName, params);
}
@ApiOperation(value = "删除动态数据", notes = "删除动态数据接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "tableName", value = "表名", paramType = "path"),
@ApiImplicitParam(name = "ids", value = "数据ID列表用下划线分隔", paramType = "path", example = "1_2_3")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@DeleteMapping("removedynamicdata/{tableName}/{ids}")
public SuccessResult removeDynamicData(@PathVariable("tableName") String tableName, @PathVariable("ids") String ids) {
return dynamicDataService.removeDynamicData(tableName, ids);
}
@ApiOperation(value = "修改动态数据", notes = "修改动态数据接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "tableName", value = "表名", paramType = "path"),
@ApiImplicitParam(name = "id", value = "id", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PutMapping("updatedynamicdata/{tableName}/{id}")
public SuccessResult updateDynamicData(@PathVariable("tableName") String tableName, @PathVariable("id") String id, @RequestBody Map<String, Object> params) {
return dynamicDataService.updateDynamicData(tableName, id, params);
}
@ApiOperation(value = " 修改动态数据(链接)", notes = " 修改动态数据(链接)接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "tableName", value = "表名", paramType = "path"),
@ApiImplicitParam(name = "id", value = "id", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PutMapping("updatedynamicjoindata/{tableName}/{joinKey}/{joinId}")
public SuccessResult updateDynamicJoinData(@PathVariable("tableName") String tableName, @PathVariable("joinKey") String joinKey, @PathVariable("joinId") String joinId, @RequestBody Map<String, Object> params) {
return dynamicDataService.updateDynamicJoinData(tableName, joinKey, joinId, params);
}
@ApiOperation(value = "动态数据列表", notes = "动态数据列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "tableName", value = "表名", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listdynamicdata/{tableName}")
public List<Map<String, Object>> listDynamicData(@PathVariable("tableName") String tableName) {
Map<String, Object> params = getParams();
return dynamicDataService.listDynamicData(tableName, params);
}
@ApiOperation(value = "分页动态数据列表", notes = "分页动态数据列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "tableName", value = "表名", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpagedynamicdata/{tableName}")
public SuccessResultList<List<Map<String, Object>>> listPageDynamicData(@PathVariable("tableName") String tableName, ListPage listPage) {
Map<String, Object> params = getParams();
listPage.setParams(params);
return dynamicDataService.listPageDynamicData(tableName, listPage);
}
@ApiOperation(value = "动态数据详情", notes = "动态数据详情接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "tableName", value = "表名", paramType = "path"),
@ApiImplicitParam(name = "id", value = "id", paramType = "path"),
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("getdynamicdata/{tableName}/{id}")
public Map<String, Object> getDynamicData(@PathVariable("tableName") String tableName, @PathVariable("id") String id) {
return dynamicDataService.getDynamicData(tableName, id);
}
@ApiOperation(value = "动态数据(链接)详情", notes = "动态数据(链接)详情接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "tableName", value = "表名", paramType = "path"),
@ApiImplicitParam(name = "joinKey", value = "链接键名", paramType = "path"),
@ApiImplicitParam(name = "joinId", value = "链接键值", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("getdynamicjoindata/{tableName}/{joinKey}/{joinId}")
public Map<String, Object> getDynamicJoinData(@PathVariable("tableName") String tableName, @PathVariable("joinKey") String joinKey, @PathVariable("joinId") String joinId) {
return dynamicDataService.getDynamicJoinData(tableName, joinKey, joinId);
}
}

View File

@ -1,16 +1,27 @@
package com.cm.common.plugin.controller.app.routes;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.plugin.enums.dynamic.FieldTypeEnum;
import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormFormShowFieldDTO;
import com.cm.common.plugin.service.dynamic.IDynamicFormService;
import com.cm.common.pojo.bos.DepartmentBO;
import com.cm.common.token.app.AppTokenManager;
import com.cm.common.token.app.entity.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
@ -26,15 +37,96 @@ import org.springframework.web.servlet.ModelAndView;
@RequestMapping(ISystemConstant.APP_ROUTE_PREFIX + "/dynamicform")
public class DynamicFormAppRouteController {
@Autowired
private IDynamicFormService dynamicFormService;
@ApiOperation(value = "动态表单新增页面", notes = "动态表单新增页面接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "tableName", value = "表名", paramType = "path")
})
@GetMapping("savedynamicformrelease/{tableName}")
public ModelAndView saveDynamicForm(@PathVariable("tableName") String tableName) {
@GetMapping("savedynamicform/{tableName}")
public ModelAndView saveDynamicForm(@RequestHeader("token") String token, @PathVariable("tableName") String tableName) {
ModelAndView mv = new ModelAndView("dynamic/form/app/save-dynamic-form.html");
mv.addObject("tableName", tableName);
mv.addObject("token", token);
List<DynamicFormFormShowFieldDTO> dynamicFormFormShowFieldDTOs = dynamicFormService.listFormShowFieldOfPage(tableName);
mv.addObject("dynamicFormFormShowFieldDTOList", dynamicFormFormShowFieldDTOs);
dynamicFormService.setDynamicFieldData(mv, dynamicFormFormShowFieldDTOs);
setCurrentUserIdAndNameValues(mv, token, dynamicFormFormShowFieldDTOs);
return mv;
}
/**
* 设置ID和名称值当前用户部门角色职位等
*
* @param mv
*/
private void setCurrentUserIdAndNameValues(ModelAndView mv, String token, List<DynamicFormFormShowFieldDTO> dynamicFormFormShowFieldDTOs) {
AppTokenUser appTokenUser = AppTokenManager.getInstance().getToken(token).getAppTokenUser();
dynamicFormFormShowFieldDTOs.forEach(dynamicFormFormShowFieldDTO -> {
if (StringUtils.equals(FieldTypeEnum.CURRENT_USER.getValue(), dynamicFormFormShowFieldDTO.getFieldType())) {
mv.addObject("userIdAndValue", String.format("%s|%s", appTokenUser.getId(), appTokenUser.getName()));
mv.addObject("userNameValue", appTokenUser.getName());
} else if (StringUtils.equals(FieldTypeEnum.CURRENT_DEPARTMENT.getValue(), dynamicFormFormShowFieldDTO.getFieldType())) {
List<AppTokenUserDepartment> appTokenUserDepartments = appTokenUser.getDepartments();
StringBuilder idStringBuilder = new StringBuilder();
StringBuilder nameStringBuilder = new StringBuilder();
appTokenUserDepartments.forEach(appTokenUserPosition -> {
if (idStringBuilder.length() > 0) {
idStringBuilder.append(",");
nameStringBuilder.append(",");
}
idStringBuilder.append(appTokenUserPosition.getDepartmentId());
nameStringBuilder.append(appTokenUserPosition.getDepartmentName());
});
mv.addObject("departmentIdAndNamesValue", idStringBuilder.length() > 0 ? idStringBuilder.append("|").append(nameStringBuilder).toString() : "");
mv.addObject("departmentNamesValue", nameStringBuilder.length() > 0 ? nameStringBuilder.toString() : "");
} else if (StringUtils.equals(FieldTypeEnum.CURRENT_ROLE.getValue(), dynamicFormFormShowFieldDTO.getFieldType())) {
List<AppTokenUserRole> appTokenUserRoles = appTokenUser.getRoles();
StringBuilder idStringBuilder = new StringBuilder();
StringBuilder nameStringBuilder = new StringBuilder();
appTokenUserRoles.forEach(appTokenUserPosition -> {
if (idStringBuilder.length() > 0) {
idStringBuilder.append(",");
nameStringBuilder.append(",");
}
idStringBuilder.append(appTokenUserPosition.getRoleId());
nameStringBuilder.append(appTokenUserPosition.getRoleName());
});
mv.addObject("roleIdAndNamesValue", idStringBuilder.length() > 0 ? idStringBuilder.append("|").append(nameStringBuilder).toString() : "");
mv.addObject("roleNamesValue", nameStringBuilder.length() > 0 ? nameStringBuilder.toString() : "");
} else if (StringUtils.equals(FieldTypeEnum.CURRENT_GROUP.getValue(), dynamicFormFormShowFieldDTO.getFieldType())) {
List<AppTokenUserGroup> appTokenUserGroups = appTokenUser.getGroups();
StringBuilder idStringBuilder = new StringBuilder();
StringBuilder nameStringBuilder = new StringBuilder();
appTokenUserGroups.forEach(appTokenUserPosition -> {
if (idStringBuilder.length() > 0) {
idStringBuilder.append(",");
nameStringBuilder.append(",");
}
idStringBuilder.append(appTokenUserPosition.getGroupId());
nameStringBuilder.append(appTokenUserPosition.getGroupName());
});
mv.addObject("groupIdAndNamesValue", idStringBuilder.length() > 0 ? idStringBuilder.append("|").append(nameStringBuilder).toString() : "");
mv.addObject("groupNamesValue", nameStringBuilder.length() > 0 ? nameStringBuilder.toString() : "");
} else if (StringUtils.equals(FieldTypeEnum.CURRENT_POSITION.getValue(), dynamicFormFormShowFieldDTO.getFieldType())) {
List<AppTokenUserPosition> appTokenUserPositions = appTokenUser.getPositions();
StringBuilder idStringBuilder = new StringBuilder();
StringBuilder nameStringBuilder = new StringBuilder();
appTokenUserPositions.forEach(appTokenUserPosition -> {
if (idStringBuilder.length() > 0) {
idStringBuilder.append(",");
nameStringBuilder.append(",");
}
idStringBuilder.append(appTokenUserPosition.getPositionId());
nameStringBuilder.append(appTokenUserPosition.getPositionName());
});
mv.addObject("positionIdAndNamesValue", idStringBuilder.length() > 0 ? idStringBuilder.append("|").append(nameStringBuilder).toString() : "");
mv.addObject("positionNamesValue", nameStringBuilder.length() > 0 ? nameStringBuilder.toString() : "");
}
});
}
}

View File

@ -44,8 +44,6 @@ public class DynamicFormRouteController extends AbstractController {
@Autowired
private IDynamicFormService dynamicFormService;
@Autowired
private IDataDictionaryService dataDictionaryService;
@Autowired
private SecurityComponent securityComponent;
@ApiOperation(value = "动态表单新增页面", notes = "动态表单新增页面接口")
@ -59,7 +57,7 @@ public class DynamicFormRouteController extends AbstractController {
List<DynamicFormFormShowFieldDTO> dynamicFormFormShowFieldDTOs = dynamicFormService.listFormShowFieldOfPage(tableName);
mv.addObject("dynamicFormFormShowFieldDTOList", dynamicFormFormShowFieldDTOs);
setDynamicFieldData(mv, dynamicFormFormShowFieldDTOs);
dynamicFormService.setDynamicFieldData(mv, dynamicFormFormShowFieldDTOs);
setCurrentUserIdAndNameValues(mv, dynamicFormFormShowFieldDTOs);
return mv;
}
@ -77,7 +75,7 @@ public class DynamicFormRouteController extends AbstractController {
List<DynamicFormFormShowFieldDTO> dynamicFormFormShowFieldDTOs = dynamicFormService.listFormShowFieldOfPage(tableName);
mv.addObject("dynamicFormFormShowFieldDTOList", dynamicFormFormShowFieldDTOs);
setDynamicFieldData(mv, dynamicFormFormShowFieldDTOs);
dynamicFormService.setDynamicFieldData(mv, dynamicFormFormShowFieldDTOs);
setCurrentUserIdAndNameValues(mv, dynamicFormFormShowFieldDTOs);
return mv;
}
@ -96,44 +94,10 @@ public class DynamicFormRouteController extends AbstractController {
List<DynamicFormFormShowFieldDTO> dynamicFormFormShowFieldDTOs = dynamicFormService.listFormShowFieldOfPage(tableName);
mv.addObject("dynamicFormFormShowFieldDTOList", dynamicFormFormShowFieldDTOs);
setDynamicFieldData(mv, dynamicFormFormShowFieldDTOs);
dynamicFormService.setDynamicFieldData(mv, dynamicFormFormShowFieldDTOs);
return mv;
}
/**
* 设置动态表单字段
*
* @param mv
* @param dynamicFormFormShowFieldDTOs
*/
private void setDynamicFieldData(ModelAndView mv, List<DynamicFormFormShowFieldDTO> dynamicFormFormShowFieldDTOs) {
List<Map<String, Object>> selectMapList = new ArrayList<>(0);
List<Map<String, Object>> checkboxMapList = new ArrayList<>(0);
List<Map<String, Object>> radioMapList = new ArrayList<>(0);
for (DynamicFormFormShowFieldDTO dynamicFormFormShowFieldDTO : dynamicFormFormShowFieldDTOs) {
String dictionaryId = dynamicFormFormShowFieldDTO.getDictionaryId();
if (StringUtils.equals(FieldTypeEnum.SELECT.getValue(), dynamicFormFormShowFieldDTO.getFieldType())) {
Map<String, Object> selectMap = new HashMap<>(2);
selectMap.put("name", dynamicFormFormShowFieldDTO.getFieldName());
selectMap.put("list", dataDictionaryService.listDictionaryByParentId(dictionaryId));
selectMapList.add(selectMap);
} else if (StringUtils.equals(FieldTypeEnum.CHECKBOX.getValue(), dynamicFormFormShowFieldDTO.getFieldType())) {
Map<String, Object> checkboxMap = new HashMap<>(2);
checkboxMap.put("name", dynamicFormFormShowFieldDTO.getFieldName());
checkboxMap.put("list", dataDictionaryService.listDictionaryByParentId(dictionaryId));
checkboxMapList.add(checkboxMap);
} else if (StringUtils.equals(FieldTypeEnum.RADIO.getValue(), dynamicFormFormShowFieldDTO.getFieldType())) {
Map<String, Object> radioMap = new HashMap<>(2);
radioMap.put("name", dynamicFormFormShowFieldDTO.getFieldName());
radioMap.put("list", dataDictionaryService.listDictionaryByParentId(dictionaryId));
radioMapList.add(radioMap);
}
}
mv.addObject("selectMapList", selectMapList);
mv.addObject("checkboxMapList", checkboxMapList);
mv.addObject("radioMapList", radioMapList);
}
@ApiOperation(value = "动态表单列表页面", notes = "动态表单列表页面接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "tableName", value = "表名", paramType = "path")

View File

@ -7,6 +7,7 @@ import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormDTO;
import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormFormShowFieldDTO;
import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormListShowFieldDTO;
import com.cm.common.plugin.pojo.vos.dynamic.DynamicFormVO;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
import java.util.Map;
@ -103,4 +104,12 @@ public interface IDynamicFormService {
* @throws SearchException
*/
List<Map<String, Object>> listJoinTableField(List<DynamicFormDTO> dynamicFormDTOs) throws SearchException;
/**
* 设置动态表单字段
*
* @param mv
* @param dynamicFormFormShowFieldDTOs
*/
void setDynamicFieldData(ModelAndView mv, List<DynamicFormFormShowFieldDTO> dynamicFormFormShowFieldDTOs);
}

View File

@ -14,12 +14,14 @@ import com.cm.common.plugin.pojo.vos.database.table.TableColumnVO;
import com.cm.common.plugin.pojo.vos.database.table.TableVO;
import com.cm.common.plugin.pojo.vos.dynamic.DynamicFormFieldVO;
import com.cm.common.plugin.pojo.vos.dynamic.DynamicFormVO;
import com.cm.common.plugin.service.datadictionary.IDataDictionaryService;
import com.cm.common.plugin.service.dynamic.IDynamicFormService;
import com.cm.common.plugin.service.dynamic.IDynamicTableService;
import com.cm.common.utils.WStringUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.ModelAndView;
import java.util.*;
@ -40,6 +42,8 @@ public class DynamicFormServiceImpl extends AbstractService implements IDynamicF
private IDynamicFormDao dynamicFormDao;
@Autowired
private IDynamicTableService dynamicTableService;
@Autowired
private IDataDictionaryService dataDictionaryService;
@Override
@ -208,6 +212,35 @@ public class DynamicFormServiceImpl extends AbstractService implements IDynamicF
return listShowField;
}
@Override
public void setDynamicFieldData(ModelAndView mv, List<DynamicFormFormShowFieldDTO> dynamicFormFormShowFieldDTOs) {
List<Map<String, Object>> selectMapList = new ArrayList<>(0);
List<Map<String, Object>> checkboxMapList = new ArrayList<>(0);
List<Map<String, Object>> radioMapList = new ArrayList<>(0);
for (DynamicFormFormShowFieldDTO dynamicFormFormShowFieldDTO : dynamicFormFormShowFieldDTOs) {
String dictionaryId = dynamicFormFormShowFieldDTO.getDictionaryId();
if (StringUtils.equals(FieldTypeEnum.SELECT.getValue(), dynamicFormFormShowFieldDTO.getFieldType())) {
Map<String, Object> selectMap = new HashMap<>(2);
selectMap.put("name", dynamicFormFormShowFieldDTO.getFieldName());
selectMap.put("list", dataDictionaryService.listDictionaryByParentId(dictionaryId));
selectMapList.add(selectMap);
} else if (StringUtils.equals(FieldTypeEnum.CHECKBOX.getValue(), dynamicFormFormShowFieldDTO.getFieldType())) {
Map<String, Object> checkboxMap = new HashMap<>(2);
checkboxMap.put("name", dynamicFormFormShowFieldDTO.getFieldName());
checkboxMap.put("list", dataDictionaryService.listDictionaryByParentId(dictionaryId));
checkboxMapList.add(checkboxMap);
} else if (StringUtils.equals(FieldTypeEnum.RADIO.getValue(), dynamicFormFormShowFieldDTO.getFieldType())) {
Map<String, Object> radioMap = new HashMap<>(2);
radioMap.put("name", dynamicFormFormShowFieldDTO.getFieldName());
radioMap.put("list", dataDictionaryService.listDictionaryByParentId(dictionaryId));
radioMapList.add(radioMap);
}
}
mv.addObject("selectMapList", selectMapList);
mv.addObject("checkboxMapList", checkboxMapList);
mv.addObject("radioMapList", radioMapList);
}
/**
* 判断是否是动态字段
*

View File

@ -15,246 +15,277 @@
</head>
<body>
<div id="app" class="weui-cells weui-cells_form" style="margin-top:0;">
<!-- 文本start -->
<div class="form-item">
<div class="weui-cells__title">输入文本</div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input class="weui-input" placeholder="请输入文本" type="text">
</div>
</div>
</div>
<!-- 文本end -->
<!-- 时间戳start -->
<div class="form-item">
<div class="weui-cells__title">时间戳</div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input class="weui-input" id="datetime" value="" type="text" placeholder="点击选择时间戳">
</div>
</div>
</div>
<!-- 时间戳end -->
<!-- 日期start -->
<div class="form-item">
<div class="weui-cells__title">日期</div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input class="weui-input" id="date" value="" type="text" placeholder="点击选择日期">
</div>
</div>
</div>
<!-- 日期end -->
<!-- 整形start -->
<div class="form-item">
<div class="weui-cells__title">整形</div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input class="weui-input" type="number" pattern="[0-9]*" placeholder="请输入整形">
</div>
</div>
</div>
<!-- 整形end -->
<!-- 双精度start -->
<div class="form-item">
<div class="weui-cells__title">双精度</div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input class="weui-input" type="number" step="0.01" pattern="^[-//+]?//d+(//.//d*)?|//.//d+$" placeholder="请输入双精度">
</div>
</div>
</div>
<!-- 双精度end -->
<!-- 文本域start -->
<div class="form-item">
<div class="weui-cells__title">文本域</div>
<div class="weui-cell">
<div class="weui-cell__bd">
<textarea class="weui-textarea" placeholder="请输入文本域" rows="4"></textarea>
</div>
</div>
</div>
<!-- 文本域end -->
<!-- 富文本start -->
<div class="form-item">
<div class="weui-cells__title">富文本</div>
<div class="weui-cell">
<div class="weui-cell__bd">
<div id="richEditor"></div>
</div>
</div>
</div>
<!-- 富文本end -->
<!-- 下拉列表start -->
<div class="form-item">
<div class="weui-cells__title">下拉列表</div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input class="weui-input" id="select" type="text" value="" placeholder="点击选择">
</div>
</div>
</div>
<!-- 下拉列表end -->
<!-- 单选start -->
<div class="form-item">
<div class="weui-cells__title">单选列表项</div>
<div class="weui-cells weui-cells_radio">
<label class="weui-cell weui-check__label" for="x11">
<form id="uploadFileForm" enctype="multipart/form-data" style="display:none;">
<input type="file" id="uploadFile" name="file" onchange="fileUpload()">
</form>
<div class="form-item" th:each="dynamicFormFormShowFieldDTO, state: ${dynamicFormFormShowFieldDTOList}">
<div th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'string'}">
<!-- 文本start -->
<div class="weui-cells__title" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></div>
<div class="weui-cell">
<div class="weui-cell__bd">
<p>选项1</p>
<input type="text" class="weui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:value="${dynamicFormFormShowFieldDTO.fieldDefault}" th:placeholder="${'请输入'+ dynamicFormFormShowFieldDTO.fieldExplain}">
</div>
<div class="weui-cell__ft">
<input class="weui-check" name="radio1" id="x11" type="radio">
<span class="weui-icon-checked"></span>
</div>
</label>
<label class="weui-cell weui-check__label" for="x12">
<div class="weui-cell__bd">
<p>选项2</p>
</div>
<div class="weui-cell__ft">
<input name="radio1" class="weui-check" id="x12" checked="checked" type="radio">
<span class="weui-icon-checked"></span>
</div>
</label>
</div>
</div>
<!-- 单选end -->
<!-- 复选start -->
<div class="form-item">
<div class="weui-cells__title">复选列表项</div>
<div class="weui-cells weui-cells_checkbox">
<label class="weui-cell weui-check__label" for="s11">
<div class="weui-cell__hd">
<input class="weui-check" name="checkbox1" id="s11" checked="checked" type="checkbox">
<i class="weui-icon-checked"></i>
</div>
<div class="weui-cell__bd">
<p>天下第一</p>
</div>
</label>
<label class="weui-cell weui-check__label" for="s12">
<div class="weui-cell__hd">
<input name="checkbox1" class="weui-check" id="s12" type="checkbox">
<i class="weui-icon-checked"></i>
</div>
<div class="weui-cell__bd">
<p>举世无双</p>
</div>
</label>
</div>
</div>
<!-- 复选end -->
<!-- 文件上传start -->
<div class="form-item">
<div class="weui-cells__title">上传文件</div>
<div class="weui-cells">
<div class="weui-cell file-upload">
<div class="weui-cell__bd">
<p>天字第一号</p>
</div>
<div class="weui-cell__ft" style="font-size: unset;">删除</div>
</div>
<!-- 文本end -->
</div>
<div class="upload-file-button-box">
<a href="javascript:void(0);" class="weui-btn weui-btn_mini bg-blue">上传文件</a>
</div>
</div>
<!-- 文件上传end -->
<!-- 人员选择start -->
<div class="form-item">
<div class="weui-cells__title">选择人员</div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input id="selectUser" type="hidden">
<input id="selectUserSelectUser" class="weui-input" placeholder="点击选择人员" type="text" readonly>
<div th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'datetime'}">
<!-- 时间戳start -->
<div class="weui-cells__title" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input type="text" class="weui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:value="${dynamicFormFormShowFieldDTO.fieldDefault}" th:placeholder="${'请选择'+ dynamicFormFormShowFieldDTO.fieldExplain}" readonly>
</div>
</div>
<!-- 时间戳end -->
</div>
</div>
<!-- 人员选择end -->
<!-- 部门选择start -->
<div class="form-item">
<div class="weui-cells__title">选择人员</div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input id="selectDepartment" type="hidden">
<input id="selectDepartmentSelectDepartment" class="weui-input" placeholder="点击选择部门" type="text" readonly>
<div th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'date'}">
<!-- 日期start -->
<div class="weui-cells__title" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input type="text" class="weui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:value="${dynamicFormFormShowFieldDTO.fieldDefault}" th:placeholder="${'请选择'+ dynamicFormFormShowFieldDTO.fieldExplain}" readonly>
</div>
</div>
<!-- 日期end -->
</div>
<div th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'number'}">
<!-- 整形start -->
<div class="weui-cells__title" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input type="number" class="weui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:value="${dynamicFormFormShowFieldDTO.fieldDefault}" th:placeholder="${'请输入'+ dynamicFormFormShowFieldDTO.fieldExplain}" pattern="[0-9]*" >
</div>
</div>
<!-- 整形end -->
</div>
<div th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'double'}">
<!-- 双精度start -->
<div class="weui-cells__title" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input type="number" class="weui-input" step="0.01" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:value="${dynamicFormFormShowFieldDTO.fieldDefault}" th:placeholder="${'请输入'+ dynamicFormFormShowFieldDTO.fieldExplain}" pattern="^[-//+]?//d+(//.//d*)?|//.//d+$">
</div>
</div>
<!-- 双精度end -->
</div>
<div th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'textarea'}">
<!-- 文本域start -->
<div class="weui-cells__title" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></div>
<div class="weui-cell">
<div class="weui-cell__bd">
<textarea class="weui-textarea" rows="4" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:placeholder="${'请输入'+ dynamicFormFormShowFieldDTO.fieldExplain}" placeholder="请输入文本域"></textarea>
</div>
</div>
<!-- 文本域end -->
</div>
<div th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'richText'}">
<!-- 富文本start -->
<div class="weui-cells__title" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></div>
<div class="weui-cell">
<div class="weui-cell__bd">
<div th:id="${dynamicFormFormShowFieldDTO.fieldName}"></div>
</div>
</div>
<!-- 富文本end -->
</div>
<div th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'select'}">
<!-- 下拉列表start -->
<div class="weui-cells__title" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input type="text" class="weui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:placeholder="${'请选择'+ dynamicFormFormShowFieldDTO.fieldExplain}">
</div>
</div>
<!-- 下拉列表end -->
</div>
<div th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'radio'}">
<!-- 单选start -->
<div class="weui-cells__title" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></div>
<div class="weui-cells weui-cells_radio" th:each="radioMap: ${radioMapList}" th:if="${radioMap.name eq dynamicFormFormShowFieldDTO.fieldName}">
<label class="weui-cell weui-check__label" th:for="${dynamicFormFormShowFieldDTO.fieldName + '_' + status.index}" th:each="radio, status: ${radioMap.list}">
<div class="weui-cell__bd">
<p th:text="${radio.dictionaryName}"></p>
</div>
<div class="weui-cell__ft">
<input class="weui-check" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:id="${dynamicFormFormShowFieldDTO.fieldName + '_' + status.index}" th:value="${radio.dictionaryId}" type="radio">
<span class="weui-icon-checked"></span>
</div>
</label>
</div>
<!-- 单选end -->
</div>
<div th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'checkbox'}">
<!-- 复选start -->
<div class="weui-cells__title" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></div>
<div class="weui-cells weui-cells_checkbox" th:each="checkboxMap: ${checkboxMapList}" th:if="${checkboxMap.name eq dynamicFormFormShowFieldDTO.fieldName}">
<label class="weui-cell weui-check__label" th:for="${dynamicFormFormShowFieldDTO.fieldName + '_' + status.index}" th:each="checkbox, status: ${checkboxMap.list}">
<div class="weui-cell__hd">
<input type="checkbox" class="weui-check" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:id="${dynamicFormFormShowFieldDTO.fieldName + '_' + status.index}" th:value="${radio.dictionaryId}">
<i class="weui-icon-checked"></i>
</div>
<div class="weui-cell__bd">
<p th:text="${radio.dictionaryName}"></p>
</div>
</label>
</div>
<!-- 复选end -->
</div>
<div th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'file'}">
<!-- 文件上传start -->
<div class="weui-cells__title" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></div>
<div class="weui-cells" th:id="${dynamicFormFormShowFieldDTO.fieldName +'Box'}"></div>
<div class="upload-file-button-box">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}">
<a href="javascript:void(0);" th:id="${dynamicFormFormShowFieldDTO.fieldName +'UploadFile'}" th:attr="data-name=${dynamicFormFormShowFieldDTO.fieldName}" class="weui-btn weui-btn_mini bg-blue">上传文件</a>
</div>
<!-- 文件上传end -->
</div>
<div th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'selectUser'}">
<!-- 人员选择start -->
<div class="weui-cells__title" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:value="${dynamicFormFormShowFieldDTO.fieldDefault}">
<input type="text" class="weui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'SelectUser'}" th:placeholder="${'请选择'+ dynamicFormFormShowFieldDTO.fieldExplain}" readonly>
</div>
</div>
<!-- 人员选择end -->
</div>
<div th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'selectDepartment'}">
<!-- 部门选择start -->
<div class="weui-cells__title" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:value="${dynamicFormFormShowFieldDTO.fieldDefault}">
<input type="text" class="weui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'SelectDepartment'}" th:placeholder="${'请选择'+ dynamicFormFormShowFieldDTO.fieldExplain}" readonly>
</div>
</div>
<!-- 部门选择end -->
</div>
<div th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'leftJoin' or dynamicFormFormShowFieldDTO.fieldType eq 'innerJoin' or dynamicFormFormShowFieldDTO.fieldType eq 'rightJoin'}">
<!-- 联表start -->
<div class="weui-cells__title" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input type="text" class="weui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:placeholder="${'请选择'+ dynamicFormFormShowFieldDTO.fieldExplain}">
</div>
</div>
<!-- 联表end -->
</div>
<div th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'currentUser'}">
<!-- 当前用户start -->
<div class="weui-cells__title" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:value="${userIdAndValue}">
<input type="text" class="weui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'CurrentUser'}" th:value="${userNameValue}" readonly>
</div>
</div>
<!-- 当前用户end -->
</div>
<div th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'currentDepartment'}">
<!-- 当前部门start -->
<div class="weui-cells__title" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:value="${departmentIdAndNamesValue}">
<input type="text" class="weui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'CurrentDepartment'}" th:value="${departmentNamesValue}" readonly>
</div>
</div>
<!-- 当前部门end -->
</div>
<div th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'currentRole'}">
<!-- 当前角色start -->
<div class="weui-cells__title" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:value="${roleIdAndNamesValue}">
<input type="text" class="weui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'CurrentRole'}" th:value="${roleNamesValue}" readonly>
</div>
</div>
<!-- 当前角色end -->
</div>
<div th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'currentGroup'}">
<!-- 当前组start -->
<div class="weui-cells__title" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:value="${positionIdAndNamesValue}">
<input type="text" class="weui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'CurrentGroup'}" th:value="${positionNamesValue}" readonly>
</div>
</div>
<!-- 当前组end -->
</div>
<div th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'currentPosition'}">
<!-- 当前职位start -->
<div class="weui-cells__title" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:value="${groupIdAndNamesValue}">
<input type="text" class="weui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'CurrentPosition'}" th:value="${groupNamesValue}" readonly>
</div>
</div>
<!-- 当前职位end -->
</div>
</div>
<!-- 部门选择end -->
</div>
<input type="hidden" id="tableName" th:value="${tableName}"/>
<input type="hidden" id="token" th:value="${token}"/>
<script type="text/javascript" src="assets/js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="assets/wxpage/js/zepto.min.js"></script>
<script type="text/javascript" src="assets/wxpage/js/zepto.weui.js"></script>
<script type="text/javascript" src="assets/wxpage/js/php.js"></script>
<script type="text/javascript" src="assets/js/vue.min.js"></script>
<script type="text/javascript" src="assets/js/vendor/layer/layer.js"></script>
<script type="text/javascript" src="assets/js/restajax.js"></script>
<script type="text/javascript" src="assets/wxpage/js/dialog.js"></script>
<script type="text/javascript" src="assets/js/vendor/wangEditor/wangEditor.min.js"></script>
<script type="text/javascript">
<script type="text/javascript" th:inline="javascript">
var token = $('#token').val();
var currentUploadFileId = '';
var wangEditor = window.wangEditor;
var wangEditorArray = [];
var formFieldList = [[${dynamicFormFormShowFieldDTOList}]];
var selectMapList = [[${selectMapList}]];
function initRichEditor(id) {
// 富文本
var E = window.wangEditor
var editor = new E(id);
editor.customConfig.menus = [
'head',
'bold',
'fontSize',
'italic',
'justify',
'quote'
];
var editor = new wangEditor('#'+ id);
editor.customConfig.menus = ['head', 'bold', 'fontSize', 'italic', 'justify', 'quote'];
editor.customConfig.zIndex = 100;
editor.create()
editor.customConfig.uploadImgMaxSize = 5 * 1024 * 1024;
editor.customConfig.uploadImgMaxLength = 1;
editor.customConfig.uploadFileName = 'image';
editor.customConfig.uploadImgServer = 'app/file/wangeditorimage';
editor.customConfig.uploadImgHeaders = {token: token};
editor.customConfig.uploadImgHooks = {
fail: function (xhr, editor, result) {
top.dialog.msg('系统错误,图片上传失败');
},
error: function (xhr, editor) {
top.dialog.msg('网络异常');
},
timeout: function (xhr, editor) {
top.dialog.msg('网络请求超时');
}
};
editor.create();
var wangEditorObj = {};
wangEditorObj['richEditor'] = editor;
wangEditorArray.push(wangEditorObj);
}
initRichEditor('#richEditor');
function initSelect(id, name, data) {
// 下拉选择
$(id).select({
$('#'+ id).select({
title: name,
items: data
});
}
initSelect('#select', '选择手机', [
{
title: "iPhone 8",
value: "001",
},
{
title: "iPhone 9",
value: "002",
},
{
title: "iPhone x",
value: "003",
},
{
title: "iPhone xs",
value: "004",
},
{
title: "iPhone xs1",
value: "005",
},
{
title: "iPhone xs2",
value: "006",
},
{
title: "iPhone xs3",
value: "007",
},
{
title: "iPhone xs4",
value: "008",
}
]);
function initDateTime(id, title, min, max) {
// 时间戳
$(id).datetimePicker({
$('#'+ id).datetimePicker({
title: title,
min: min,
max: max,
@ -263,11 +294,10 @@
}
});
}
initDateTime('#datetime', '出发时间', '1960-12-12 00:00:00', '2060-12-12 23:59:59');
function initDate(id, title, startYear, endYear) {
// 日期
$(id).datetimePicker({
$('#'+ id).datetimePicker({
title: title,
years: range(startYear, endYear),
times: function () {
@ -281,103 +311,199 @@
}
});
}
initDate('#date', '生日', 1960, 2060);
// 选择人员
$(document).on('click', '#selectUserSelectUser', function() {
var selectedUsers = [];
var selectDepartmentUser = $('#selectUser').val().split(',');
for(var selectDepartmentUserIndex = 0, item = selectDepartmentUser[selectDepartmentUserIndex]; item = selectDepartmentUser[selectDepartmentUserIndex++];) {
var userInfo = item.split('|');
selectedUsers.push({
userId: userInfo[0],
departmentId: userInfo[1]
});
// 文件上传 start
function fileUpload() {
if($('#uploadFile').val() == '') {
return;
}
top.dialog.dialogData.selectedUsers = selectedUsers;
top.dialog.open({
url: 'approute/tree/treeuserrelease',
title: '选择组织部门人员',
width: '100%',
height: '100%',
onClose: function() {
var selectedUsers = top.dialog.dialogData.selectedDepartmentUsers;
if(selectedUsers != null && selectedUsers.length > 0) {
var selectedUsersVal = '';
var showSelectedUsersVal = '';
for(var j = 0, selectUser = selectedUsers[j]; selectUser = selectedUsers[j++];) {
if(selectedUsersVal.length > 0) {
selectedUsersVal += ',';
}
if(showSelectedUsersVal.length > 0) {
showSelectedUsersVal += ',';
}
selectedUsersVal += (selectUser.userId +'|'+ selectUser.departmentId +'|'+ selectUser.userName +'|'+ selectUser.userTitle);
showSelectedUsersVal += selectUser.userName;
}
$('#selectUser').val(selectedUsersVal);
$('#selectUserSelectUser').val(showSelectedUsersVal);
} else {
$('#selectUser').val('');
$('#selectUserSelectUser').val('');
}
var formData = new FormData(document.getElementById("uploadFileForm"));
top.restAjax.postFile(top.restAjax.path('app/file/uploadfile', []), formData, {
headers: {
token: token
}
}, function(code, data) {
var selectIds = $('#'+ currentUploadFileId).val();
if(selectIds != '') {
selectIds += ',';
}
selectIds += data.data;
initUploadFileList(currentUploadFileId, selectIds);
$('#uploadFile').val('');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
$(document).on('click', '.remove-file', function() {
var id = this.dataset.id;
var name = this.dataset.filename;
var selectIds = $('#'+ name).val();
selectIds = selectIds.replace(id, '');
selectIds = selectIds.replace(/\,+/g, ',');
if(selectIds.indexOf(',') == 0) {
selectIds = selectIds.substring(1);
}
if(selectIds.lastIndexOf(',') == selectIds.length - 1) {
selectIds = selectIds.substring(0, selectIds.length - 1);
}
initUploadFileList(name, selectIds);
});
// 选择部门
$(document).on('click', '#selectDepartmentSelectDepartment', function() {
var name = this.dataset.name;
var selectedNodes = [];
var selectDepartment = $('#selectDepartment').val().split(',');
for(var selectDepartmentIndex = 0, item = selectDepartment[selectDepartmentIndex]; item = selectDepartment[selectDepartmentIndex++];) {
var departmentInfo = item.split('|');
selectedNodes.push({
id: departmentInfo[0],
name: departmentInfo[1],
title: departmentInfo[1]
});
// 初始化上传文件列表
function initUploadFileList(name, selectIds) {
var selectIdArray = selectIds.split(',');
var fileItems = '';
for(var i = 0, item; item = selectIdArray[i++];) {
fileItems += '<div class="weui-cell file-upload"><div class="weui-cell__bd"><p>文件'+ i +'</p></div><div class="weui-cell__ft remove-file" style="font-size: unset;" data-id="'+ item +'" data-filename="'+ name +'">删除</div></div>';
}
top.dialog.tree({
title: '选择部门',
apiUri: 'app/department/listztreedepartmentrelease',
width: '100%',
height: '100%',
dataFilter: function(treeId, parentNode, childNodes) {
return childNodes;
},
check: {
enable: true,
selectType: 'checkbox',
checkboxType: {Y: 'ps', N: 'ps'},
radioType: 'level',
},
selectedNodes: selectedNodes,
onClose: function() {
var selectNodes = top.dialog.dialogTreeData.selectedNodes;
if(typeof(selectNodes) != 'undefined' && selectNodes != null) {
if(selectNodes.length > 0) {
var selectedDepartmentVal = '';
var showSelectedDepartmentsVal = '';
for(var j = 0, selectNode = selectNodes[j]; selectNode = selectNodes[j++];) {
if(selectedDepartmentVal.length > 0) {
selectedDepartmentVal += ',';
}
if(showSelectedDepartmentsVal.length > 0) {
showSelectedDepartmentsVal += ',';
}
selectedDepartmentVal += (selectNode.id +'|'+ selectNode.name);
showSelectedDepartmentsVal += selectNode.name;
$('#'+ name +'Box').html(fileItems);
$('#'+ name).val(selectIds);
}
// 文件上传end
$(function() {
for(var i = 0, item = formFieldList[i]; item = formFieldList[i++];) {
if(item.fieldType === 'date') {
initDate(item.fieldName, item.fieldExplain, 1960, 2060);
} else if(item.fieldType === 'datetime') {
initDateTime(item.fieldName, item.fieldExplain, '1960-12-12 00:00:00', '2060-12-12 23:59:59');
} else if(item.fieldType === 'select') {
var dataArray = [];
for(var j = 0, selectMap; selectMap = selectMapList[j++];) {
if(selectMap.name === item.fieldName) {
var dataArray = [];
for(var k = 0, map; map = selectMap.list[k++];) {
dataArray.push({
title: map.dictionaryName,
value: map.dictionaryId
})
}
$('#selectDepartment').val(selectedDepartmentVal);
$('#selectDepartmentSelectDepartment').val(showSelectedDepartmentsVal);
} else {
$('#selectDepartment').val('');
$('#selectDepartmentSelectDepartment').val('');
initSelect(item.fieldName, item.fieldExplain, dataArray);
break;
}
}
} else if(item.fieldType === 'richText') {
initRichEditor(item.fieldName);
} else if(item.fieldType === 'file') {
$(document).on('click', '#'+ item.fieldName +'UploadFile', function() {
currentUploadFileId = this.dataset.name;
$('#uploadFile').click();
});
} else if(item.fieldType === 'selectUser') {
$(document).on('click', '#'+ item.fieldName +'SelectUser', function() {
var selectedUsers = [];
var selectDepartmentUser = $('#'+ item.fieldName).val().split(',');
for(var selectDepartmentUserIndex = 0, item = selectDepartmentUser[selectDepartmentUserIndex]; item = selectDepartmentUser[selectDepartmentUserIndex++];) {
var userInfo = item.split('|');
selectedUsers.push({
userId: userInfo[0],
departmentId: userInfo[1]
});
}
top.dialog.dialogData.selectedUsers = selectedUsers;
top.dialog.open({
url: 'approute/tree/treeuser',
title: '选择组织部门人员',
width: '100%',
height: '100%',
onClose: function() {
var selectedUsers = top.dialog.dialogData.selectedDepartmentUsers;
if(selectedUsers != null && selectedUsers.length > 0) {
var selectedUsersVal = '';
var showSelectedUsersVal = '';
for(var j = 0, selectUser = selectedUsers[j]; selectUser = selectedUsers[j++];) {
if(selectedUsersVal.length > 0) {
selectedUsersVal += ',';
}
if(showSelectedUsersVal.length > 0) {
showSelectedUsersVal += ',';
}
selectedUsersVal += (selectUser.userId +'|'+ selectUser.departmentId +'|'+ selectUser.userName +'|'+ selectUser.userTitle);
showSelectedUsersVal += selectUser.userName;
}
$('#'+ item.fieldName).val(selectedUsersVal);
$('#'+ item.fieldName +'SelectUser').val(showSelectedUsersVal);
} else {
$('#'+ item.fieldName).val('');
$('#'+ item.fieldName +'SelectUser').val('');
}
}
});
});
} else if(item.fieldType === 'selectDepartment') {
$(document).on('click', '#'+ item.fieldName +'SelectDepartment', function() {
var name = this.dataset.name;
var selectedNodes = [];
var selectDepartment = $('#'+ item.fieldName).val().split(',');
for(var selectDepartmentIndex = 0, item = selectDepartment[selectDepartmentIndex]; item = selectDepartment[selectDepartmentIndex++];) {
var departmentInfo = item.split('|');
selectedNodes.push({
id: departmentInfo[0],
name: departmentInfo[1],
title: departmentInfo[1]
});
}
top.dialog.tree({
title: '选择部门',
apiUri: 'app/department/listztreedepartment',
width: '100%',
height: '100%',
dataFilter: function(treeId, parentNode, childNodes) {
return childNodes;
},
check: {
enable: true,
selectType: 'checkbox',
checkboxType: {Y: 'ps', N: 'ps'},
radioType: 'level',
},
selectedNodes: selectedNodes,
onClose: function() {
var selectNodes = top.dialog.dialogTreeData.selectedNodes;
if(typeof(selectNodes) != 'undefined' && selectNodes != null) {
if(selectNodes.length > 0) {
var selectedDepartmentVal = '';
var showSelectedDepartmentsVal = '';
for(var j = 0, selectNode = selectNodes[j]; selectNode = selectNodes[j++];) {
if(selectedDepartmentVal.length > 0) {
selectedDepartmentVal += ',';
}
if(showSelectedDepartmentsVal.length > 0) {
showSelectedDepartmentsVal += ',';
}
selectedDepartmentVal += (selectNode.id +'|'+ selectNode.name);
showSelectedDepartmentsVal += selectNode.name;
}
$('#'+ item.fieldName).val(selectedDepartmentVal);
$('#'+ item.fieldName +'SelectDepartment').val(showSelectedDepartmentsVal);
} else {
$('#'+ item.fieldName).val('');
$('#'+ item.fieldName +'SelectDepartment').val('');
}
}
}
});
});
} else if(item.fieldType === 'leftJoin' || item.fieldType === 'innerJoin' || item.fieldType === 'rightJoin') {
top.restAjax.get(top.restAjax.path('app/dynamicdata/listdynamicdata/{tableName}', [item.joinTable]), {}, {
fieldName: item.fieldName,
fieldExplain: item.fieldExplain,
joinTable: item.joinTable,
joinTableField: item.joinTableField,
joinTableFormShow: item.joinTableFormShow
}, function(code, data, args) {
var dataArray = [];
for(var j = 0, joinTable; joinTable = data[j++];) {
dataArray.push({
title: joinTable[args.joinTableFormShow],
value: joinTable[args.joinTableField]
});
}
initSelect(args.fieldName, args.fieldExplain, dataArray);
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
});
}
});
</script>
</body>

View File

@ -206,7 +206,6 @@
var wangEditorArray = [];
var formFieldList = [[${dynamicFormFormShowFieldDTOList}]];
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
@ -400,10 +399,8 @@
});
} else if(item.fieldType === 'leftJoin' || item.fieldType === 'innerJoin' || item.fieldType === 'rightJoin') {
top.restAjax.get(top.restAjax.path('api/dynamicdata/listdynamicdata/{tableName}', [item.joinTable]), {}, {fieldName: item.fieldName}, function(code, data, args) {
laytpl(document.getElementById(args.fieldName +'Template').innerHTML).render(data, function(html) {
document.getElementById(args.fieldName +'TemplateBox').innerHTML = html;
});
form.render('select', args.fieldName +'TemplateBox');
console.log(data);
console.log(args);
}, function(code, data) {
top.dialog.msg(data.msg);
});

View File

@ -115,5 +115,4 @@ public class FileController extends AbstractController {
return fileService.wangEditorImage(image, UploadTypeEnum.IMAGE, params);
}
}

View File

@ -1,5 +1,6 @@
package com.cm.common.plugin.controller.app.apis.file;
import com.alibaba.fastjson.JSONObject;
import com.cm.common.base.AbstractController;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.enums.UploadTypeEnum;
@ -12,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
/**
@ -80,6 +82,17 @@ public class FileAppController extends AbstractController {
return uploadSingle(token, audio, UploadTypeEnum.AUDIO, params);
}
@ApiOperation(value = "上传图片", notes = "上传图片接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "image", value = "文件name", paramType = "form")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("wangeditorimage")
public JSONObject wangEditorImage(MultipartFile image, HttpServletRequest request) {
Map<String, Object> params = requestParams();
return fileService.wangEditorImage(image, UploadTypeEnum.IMAGE, params);
}
/**
* 上传文件
*

View File

@ -55,6 +55,7 @@
var restAjax = layui.restajax;
var common = layui.common;
var selectedUsers = top.dialog.dialogData.selectedUsers;
var token = top.token;
var selectDepartmentUserArray = [];
function closeBox() {
@ -87,9 +88,13 @@
return;
}
var loadLayerIndex;
restAjax.post(restAjax.path('app/user/listdepartmentuserbyuserdepartmentidrelease', []), {
restAjax.post(restAjax.path('app/user/listdepartmentuserbyuserdepartmentid', []), {
selectedUsers: selectedUsers
}, null, function(code, data) {
}, {
headers: {
token: token
}
}, function(code, data) {
var nodes = zTree.transformToArray(zTree.getNodes());
for(var i = 0, node = nodes[i]; node = nodes[i++];) {
for(var j = 0, item = data[j]; item = data[j++]; ) {
@ -120,9 +125,10 @@
enable: true,
autoLoad: false,
type: 'get',
url: restAjax.path('app/department/listztreedepartmentwithuserrelease', []),
url: restAjax.path('app/department/listztreedepartmentwithuser', []),
autoParam:['id'],
otherParam:{},
headers: {token: token},
dataFilter: function(treeId, parentNode, childNodes) {
if (!childNodes) return null;
for (var i=0, l=childNodes.length; i<l; i++) {

View File

@ -48,6 +48,7 @@
var $ = layui.$;
var common = layui.common;
var selectTree = top.dialog.dialogTreeData;
var token = top.token;
var zTree;
var defaultNodes = selectTree.selectedNodes;
var selectedNodes = [];
@ -177,6 +178,9 @@
},
},
check: selectTree.check,
headers: {
token: token
},
callback: {
onClick: function(event, treeId, treeNode) {
if(!selectTree.check.enable) {

View File

@ -23,6 +23,7 @@ public class AppTokenUser {
private List<AppTokenUserRole> roles;
private List<AppTokenUserPosition> positions;
private List<AppTokenUserDepartment> departments;
private List<AppTokenUserGroup> groups;
public String getId() {
return id == null ? "" : id.trim();
@ -96,6 +97,14 @@ public class AppTokenUser {
this.departments = departments;
}
public List<AppTokenUserGroup> getGroups() {
return groups;
}
public void setGroups(List<AppTokenUserGroup> groups) {
this.groups = groups;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("{");
@ -117,6 +126,8 @@ public class AppTokenUser {
.append(positions);
sb.append(",\"departments\":")
.append(departments);
sb.append(",\"groups\":")
.append(groups);
sb.append('}');
return sb.toString();
}

View File

@ -0,0 +1,44 @@
package com.cm.common.token.app.entity;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: AppTokenUserGroup
* @Description: 用户组
* @Author: WangGeng
* @Date: 2020/2/10 9:33 下午
* @Version: 1.0
**/
public class AppTokenUserGroup {
private String groupId;
private String groupName;
public String getGroupId() {
return groupId == null ? "" : groupId.trim();
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public String getGroupName() {
return groupName == null ? "" : groupName.trim();
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("{");
sb.append("\"groupId\":")
.append("\"").append(groupId).append("\"");
sb.append(",\"groupName\":")
.append("\"").append(groupName).append("\"");
sb.append('}');
return sb.toString();
}
}