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