This commit is contained in:
mazhichao
2021-03-18 08:29:58 +08:00
5 changed files with 120 additions and 62 deletions
@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresRoles;
@@ -54,6 +56,7 @@ import java.util.*;
* @since 2018-12-28
*/
@RestController
@Api(tags = "字典控制器")
@RequestMapping("/sys/dict")
@Slf4j
public class SysDictController {
@@ -66,6 +69,7 @@ public class SysDictController {
public RedisTemplate<String, Object> redisTemplate;
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(value = "字典控制器-分页列表查询", notes = "字典控制器-分页列表查询")
public Result<IPage<SysDict>> queryPageList(SysDict sysDict, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) {
Result<IPage<SysDict>> result = new Result<IPage<SysDict>>();
@@ -90,6 +94,7 @@ public class SysDictController {
* @return
*/
@SuppressWarnings("unchecked")
@ApiOperation(value = "字典控制器-树形字典数据", notes = "字典控制器-树形字典数据")
@RequestMapping(value = "/treeList", method = RequestMethod.GET)
public Result<List<SysDictTree>> treeList(SysDict sysDict, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) {
@@ -117,6 +122,7 @@ public class SysDictController {
* @param dictCode 表名,文本字段,code字段 | 举例:sys_user,realname,id
* @return
*/
@ApiOperation(value = "字典控制器-根据字典编码获取字典数据", notes = "字典控制器-根据字典编码获取字典数据")
@RequestMapping(value = "/getDictItems/{dictCode}", method = RequestMethod.GET)
public Result<List<DictModel>> getDictItems(@PathVariable String dictCode, @RequestParam(value = "sign",required = false) String sign, HttpServletRequest request) {
log.info(" dictCode : "+ dictCode);
@@ -167,6 +173,7 @@ public class SysDictController {
*
* @return
*/
@ApiOperation(value = "字典控制器-获取全部字典数据", notes = "字典控制器-获取全部字典数据")
@RequestMapping(value = "/queryAllDictItems", method = RequestMethod.GET)
public Result<?> queryAllDictItems(HttpServletRequest request) {
Map<String, List<DictModel>> res = new HashMap<String, List<DictModel>>();
@@ -179,6 +186,7 @@ public class SysDictController {
* @param dictCode
* @return
*/
@ApiOperation(value = "字典控制器-通过字典code和字典值key获取字典数据", notes = "字典控制器-通过字典code和字典值key获取字典数据")
@RequestMapping(value = "/getDictText/{dictCode}/{key}", method = RequestMethod.GET)
public Result<String> getDictText(@PathVariable("dictCode") String dictCode, @PathVariable("key") String key) {
log.info(" dictCode : "+ dictCode);
@@ -201,6 +209,7 @@ public class SysDictController {
* @param dictCode
* @return
*/
@ApiOperation(value = "字典控制器-通过字典code获取字典数据", notes = "字典控制器-通过字典code获取字典数据")
@RequestMapping(value = "/loadDict/{dictCode}", method = RequestMethod.GET)
public Result<List<DictModel>> loadDict(@PathVariable String dictCode,
@RequestParam(name="keyword") String keyword,
@@ -239,6 +248,7 @@ public class SysDictController {
/**
* 根据字典code加载字典text 返回
*/
@ApiOperation(value = "字典控制器-根据字典code加载字典text", notes = "字典控制器-根据字典code加载字典text")
@RequestMapping(value = "/loadDictItem/{dictCode}", method = RequestMethod.GET)
public Result<List<String>> loadDictItem(@PathVariable String dictCode, @RequestParam(name="key") String keys, @RequestParam(value = "sign",required = false) String sign, HttpServletRequest request) {
Result<List<String>> result = new Result<>();
@@ -270,6 +280,7 @@ public class SysDictController {
* 根据表名——显示字段-存储字段 pid 加载树形数据
*/
@SuppressWarnings("unchecked")
@ApiOperation(value = "字典控制器-根据表名——显示字段-存储字段 pid 加载树形数据", notes = "字典控制器-根据表名——显示字段-存储字段 pid 加载树形数据")
@RequestMapping(value = "/loadTreeData", method = RequestMethod.GET)
public Result<List<TreeSelectModel>> loadTreeData(@RequestParam(name="pid") String pid, @RequestParam(name="pidField") String pidField,
@RequestParam(name="tableName") String tbname,
@@ -292,34 +303,12 @@ public class SysDictController {
return result;
}
/**
* 【APP接口】根据字典配置查询表字典数据(目前暂未找到调用的地方)
* @param query
* @param pageNo
* @param pageSize
* @return
*/
@Deprecated
@GetMapping("/queryTableData")
public Result<List<DictModel>> queryTableData(DictQuery query,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@RequestParam(value = "sign",required = false) String sign, HttpServletRequest request){
Result<List<DictModel>> res = new Result<List<DictModel>>();
// SQL注入漏洞 sign签名校验
String dictCode = query.getTable()+","+query.getText()+","+query.getCode();
SqlInjectionUtil.filterContent(dictCode);
List<DictModel> ls = this.sysDictService.queryDictTablePageList(query,pageSize,pageNo);
res.setResult(ls);
res.setSuccess(true);
return res;
}
/**
* @功能:新增
* @param sysDict
* @return
*/
@ApiOperation(value = "字典控制器-新增字典", notes = "字典控制器-新增字典")
@RequiresRoles({"admin"})
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Result<SysDict> add(@RequestBody SysDict sysDict) {
@@ -341,6 +330,7 @@ public class SysDictController {
* @param sysDict
* @return
*/
@ApiOperation(value = "字典控制器-编辑字典", notes = "字典控制器-编辑字典")
@RequiresRoles({"admin"})
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
public Result<SysDict> edit(@RequestBody SysDict sysDict) {
@@ -363,8 +353,9 @@ public class SysDictController {
* @param id
* @return
*/
@ApiOperation(value = "字典控制器-删除字典", notes = "字典控制器-删除字典")
@RequiresRoles({"admin"})
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
@DeleteMapping(value = "/delete")
@CacheEvict(value=CacheConstant.SYS_DICT_CACHE, allEntries=true)
public Result<SysDict> delete(@RequestParam(name="id",required=true) String id) {
Result<SysDict> result = new Result<SysDict>();
@@ -382,8 +373,9 @@ public class SysDictController {
* @param ids
* @return
*/
@ApiOperation(value = "字典控制器-批量字典", notes = "字典控制器-批量字典")
@RequiresRoles({"admin"})
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
@DeleteMapping(value = "/deleteBatch")
@CacheEvict(value= CacheConstant.SYS_DICT_CACHE, allEntries=true)
public Result<SysDict> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
Result<SysDict> result = new Result<SysDict>();
@@ -462,7 +454,7 @@ public class SysDictController {
* @return
*/
@RequiresRoles({"admin"})
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
@PostMapping(value = "/importExcel")
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
@@ -521,7 +513,7 @@ public class SysDictController {
* 查询被删除的列表
* @return
*/
@RequestMapping(value = "/deleteList", method = RequestMethod.GET)
@GetMapping(value = "/deleteList")
public Result<List<SysDict>> deleteList() {
Result<List<SysDict>> result = new Result<List<SysDict>>();
List<SysDict> list = this.sysDictService.queryDeleteList();
@@ -535,7 +527,7 @@ public class SysDictController {
* @param id
* @return
*/
@RequestMapping(value = "/deletePhysic/{id}", method = RequestMethod.DELETE)
@DeleteMapping(value = "/deletePhysic/{id}")
public Result<?> deletePhysic(@PathVariable String id) {
try {
sysDictService.deleteOneDictPhysically(id);
@@ -551,7 +543,7 @@ public class SysDictController {
* @param id
* @return
*/
@RequestMapping(value = "/back/{id}", method = RequestMethod.PUT)
@PutMapping(value = "/back/{id}")
public Result<?> back(@PathVariable String id) {
try {
sysDictService.updateDictDelFlag(0,id);
+76 -13
View File
@@ -1,14 +1,50 @@
<template>
<a-date-picker
dropdownClassName="j-date-picker"
:disabled="disabled || readOnly"
:placeholder="placeholder"
@change="handleDateChange"
:value="momVal"
:showTime="showTime"
:format="dateFormat"
:getCalendarContainer="getCalendarContainer"
/>
<div>
<!--YYYY-MM-DD HH:mm:ss-->
<a-date-picker
v-if="showType === 'time'"
dropdownClassName="j-date-picker"
:disabled="disabled || readOnly"
:placeholder="placeholder"
@change="handleDateChange"
:value="momVal"
:showTime="true"
:format="dateFormat"
:getCalendarContainer="getCalendarContainer"
/>
<!--YYYY-MM-DD-->
<a-date-picker
v-if="showType === 'day'"
dropdownClassName="j-date-picker"
:disabled="disabled || readOnly"
:placeholder="placeholder"
@change="handleDateChange"
:value="momVal"
:showTime="false"
:format="dateFormat"
:getCalendarContainer="getCalendarContainer"
/>
<!--YYYY-MM-->
<a-month-picker
v-if="showType === 'month'"
:placeholder="placeholder"
:value="momVal"
:disabled="disabled || readOnly"
:format="dateFormat"
@change="handleMonthChange"
/>
<!--YYYY-->
<a-date-picker
v-if="showType === 'year'"
mode="year"
:placeholder="placeholder"
:format="dateFormat"
v-model="addForm.all_plan_one"
:open='yearShowOne'
@openChange="openChangeOne"
@panelChange="panelChangeOne"
@change="handleYearChange"/>
</div>
</template>
<script>
import moment from 'moment'
@@ -45,10 +81,11 @@
required: false,
default: false
},
showTime:{
type: Boolean,
//控制选择时分秒
showType:{
type: String,
required: false,
default: false
default:'time'
},
getCalendarContainer: {
type: Function,
@@ -58,10 +95,17 @@
data () {
let dateStr = this.value;
return {
yearShowOne:false, //控制年份模态框的显示与否
addForm:{
all_plan_one:null,//开始年限
},
decorator:"",
momVal:!dateStr?null:moment(dateStr,this.dateFormat)
}
},
mounted(){
console.log(this.showTime)
},
watch: {
value (val) {
if(!val){
@@ -75,6 +119,25 @@
moment,
handleDateChange(mom,dateStr){
this.$emit('change', dateStr);
},
handleMonthChange(mom,dateStr){
this.$emit('change',dateStr)
},
// 弹出日历和关闭日历的回调
openChangeOne(status){
//status是打开或关闭的状态
if(status){
this.yearShowOne = true
}
},
// 得到年份选择器的值
panelChangeOne(value){
this.addForm.all_plan_one = value
this.yearShowOne = false
},
handleYearChange(mom,dateStr){
this.yearShowOne = false
this.$emit('change',dateStr)
}
},
//2.2新增 在组件内定义 指定父组件调用时候的传值属性和事件类型 这个牛逼
@@ -4,8 +4,7 @@
:placeholder="placeholder"
:value="arrayValue"
@change="onChange"
@search="search"
:filterOption="false"
option-filter-prop="children"
>
<a-select-option
v-for="(item,index) in newOptions"
@@ -75,22 +74,25 @@
this.newOptions = this.options
},
methods:{
search(val){
let newArr = []
this.newOptions = this.options
if (this.options && this.options.length > 0){
this.options.forEach((item,index)=>{
if (item.text.indexOf(val) != -1){
newArr.push(item)
}
})
this.$nextTick(()=>{
this.newOptions = newArr
})
}else {
this.newOptions = this.options
}
},
// search(val){
// let newArr = []
// this.newOptions = this.options
// if (this.options && this.options.length > 0){
// this.options.forEach((item,index)=>{
// if (item.text.indexOf(val) != -1){
// newArr.push(item)
// }
// })
// this.$nextTick(()=>{
// this.newOptions = newArr
// })
// }else {
// this.newOptions = this.options
// }
// },
// blur(){
// this.newOptions = this.options
// },
onChange (selectedValue) {
this.newOptions = this.options
if(this.triggerChange){
+2 -1
View File
@@ -2,6 +2,7 @@
<a-tree-select
allowClear
labelInValue
tree-node-filter-prop="title"
:getPopupContainer="(node) => node.parentNode"
style="width: 100%"
:disabled="disabled"
@@ -85,7 +86,6 @@
tableName:"",
text:"",
code:"",
}
},
watch: {
@@ -152,6 +152,7 @@
}
getAction(this.url,param).then(res=>{
if(res.success){
console.log(res)
for(let i of res.result){
i.value = i.key
if(i.leaf==false){
+1 -1
View File
@@ -158,7 +158,7 @@
<a-row :gutter="24">
<a-col :span="12">
<a-form-item label="日期选择框">
<j-date v-model="jdate.value" :showTime="true" dateFormat="YYYY-MM-DD HH:mm:ss"/>
<j-date v-model="jdate.value" :showType="'year'" dateFormat="YYYY"/>
</a-form-item>
</a-col>
<a-col :span="12">日期选择框(v-model){{ jdate.value }}</a-col>