10 files added
1 files modified
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.system.domain; |
| | | |
| | | import lombok.Data; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import cn.hutool.core.bean.copier.CopyOptions; |
| | | import me.zhengjie.base.BaseEntity; |
| | | |
| | | import javax.persistence.*; |
| | | import javax.validation.constraints.*; |
| | | import java.sql.Timestamp; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author wcd |
| | | * @date 2022-12-12 |
| | | **/ |
| | | @Entity |
| | | @Data |
| | | @Table(name="sys_config_holiday") |
| | | public class SysConfigHoliday extends BaseEntity implements Serializable { |
| | | |
| | | @Id |
| | | @GeneratedValue(strategy = GenerationType.IDENTITY) |
| | | @Column(name = "`id`") |
| | | @ApiModelProperty(value = "ID") |
| | | private Long id; |
| | | |
| | | @Column(name = "`holiday_date`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "节日日期") |
| | | private Timestamp holidayDate; |
| | | |
| | | @Column(name = "`name`",nullable = false) |
| | | @NotBlank |
| | | @ApiModelProperty(value = "名称") |
| | | private String name; |
| | | |
| | | @Column(name = "`date_type`",nullable = false) |
| | | @NotBlank |
| | | @ApiModelProperty(value = "日期类型") |
| | | private String dateType; |
| | | |
| | | @Column(name = "`remarks`") |
| | | @ApiModelProperty(value = "备注") |
| | | private String remarks; |
| | | |
| | | |
| | | public void copy(SysConfigHoliday source){ |
| | | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.system.repository; |
| | | |
| | | import me.zhengjie.modules.system.domain.SysConfigHoliday; |
| | | import org.springframework.data.jpa.repository.JpaRepository; |
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2022-12-12 |
| | | **/ |
| | | public interface SysConfigHolidayRepository extends JpaRepository<SysConfigHoliday, Long>, JpaSpecificationExecutor<SysConfigHoliday> { |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.system.rest; |
| | | |
| | | import me.zhengjie.annotation.Log; |
| | | import me.zhengjie.modules.system.domain.SysConfigHoliday; |
| | | import me.zhengjie.modules.system.service.SysConfigHolidayService; |
| | | import me.zhengjie.modules.system.service.dto.SysConfigHolidayQueryCriteria; |
| | | import org.springframework.data.domain.Pageable; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import io.swagger.annotations.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2022-12-12 |
| | | **/ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "节日配置管理") |
| | | @RequestMapping("/api/sysConfigHoliday") |
| | | public class SysConfigHolidayController { |
| | | |
| | | private final SysConfigHolidayService sysConfigHolidayService; |
| | | |
| | | @Log("导出数据") |
| | | @ApiOperation("导出数据") |
| | | @GetMapping(value = "/download") |
| | | @PreAuthorize("@el.check('sysConfigHoliday:list')") |
| | | public void exportSysConfigHoliday(HttpServletResponse response, SysConfigHolidayQueryCriteria criteria) throws IOException { |
| | | sysConfigHolidayService.download(sysConfigHolidayService.queryAll(criteria), response); |
| | | } |
| | | |
| | | @GetMapping |
| | | @Log("查询节日配置") |
| | | @ApiOperation("查询节日配置") |
| | | @PreAuthorize("@el.check('sysConfigHoliday:list')") |
| | | public ResponseEntity<Object> querySysConfigHoliday(SysConfigHolidayQueryCriteria criteria, Pageable pageable){ |
| | | return new ResponseEntity<>(sysConfigHolidayService.queryAll(criteria,pageable),HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Log("新增节日配置") |
| | | @ApiOperation("新增节日配置") |
| | | @PreAuthorize("@el.check('sysConfigHoliday:add')") |
| | | public ResponseEntity<Object> createSysConfigHoliday(@Validated @RequestBody SysConfigHoliday resources){ |
| | | return new ResponseEntity<>(sysConfigHolidayService.create(resources),HttpStatus.CREATED); |
| | | } |
| | | |
| | | @PutMapping |
| | | @Log("修改节日配置") |
| | | @ApiOperation("修改节日配置") |
| | | @PreAuthorize("@el.check('sysConfigHoliday:edit')") |
| | | public ResponseEntity<Object> updateSysConfigHoliday(@Validated @RequestBody SysConfigHoliday resources){ |
| | | sysConfigHolidayService.update(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @Log("删除节日配置") |
| | | @ApiOperation("删除节日配置") |
| | | @PreAuthorize("@el.check('sysConfigHoliday:del')") |
| | | public ResponseEntity<Object> deleteSysConfigHoliday(@RequestBody Long[] ids) { |
| | | sysConfigHolidayService.deleteAll(ids); |
| | | return new ResponseEntity<>(HttpStatus.OK); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.system.service; |
| | | |
| | | import me.zhengjie.modules.system.domain.SysConfigHoliday; |
| | | import me.zhengjie.modules.system.service.dto.SysConfigHolidayDto; |
| | | import me.zhengjie.modules.system.service.dto.SysConfigHolidayQueryCriteria; |
| | | import org.springframework.data.domain.Pageable; |
| | | import java.util.Map; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务接口 |
| | | * @author wcd |
| | | * @date 2022-12-12 |
| | | **/ |
| | | public interface SysConfigHolidayService { |
| | | |
| | | /** |
| | | * 查询数据分页 |
| | | * @param criteria 条件 |
| | | * @param pageable 分页参数 |
| | | * @return Map<String,Object> |
| | | */ |
| | | Map<String,Object> queryAll(SysConfigHolidayQueryCriteria criteria, Pageable pageable); |
| | | |
| | | /** |
| | | * 查询所有数据不分页 |
| | | * @param criteria 条件参数 |
| | | * @return List<SysConfigHolidayDto> |
| | | */ |
| | | List<SysConfigHolidayDto> queryAll(SysConfigHolidayQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * @param id ID |
| | | * @return SysConfigHolidayDto |
| | | */ |
| | | SysConfigHolidayDto findById(Long id); |
| | | |
| | | /** |
| | | * 创建 |
| | | * @param resources / |
| | | * @return SysConfigHolidayDto |
| | | */ |
| | | SysConfigHolidayDto create(SysConfigHoliday resources); |
| | | |
| | | /** |
| | | * 编辑 |
| | | * @param resources / |
| | | */ |
| | | void update(SysConfigHoliday resources); |
| | | |
| | | /** |
| | | * 多选删除 |
| | | * @param ids / |
| | | */ |
| | | void deleteAll(Long[] ids); |
| | | |
| | | /** |
| | | * 导出数据 |
| | | * @param all 待导出的数据 |
| | | * @param response / |
| | | * @throws IOException / |
| | | */ |
| | | void download(List<SysConfigHolidayDto> all, HttpServletResponse response) throws IOException; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.system.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import me.zhengjie.base.BaseDTO; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author wcd |
| | | * @date 2022-12-12 |
| | | **/ |
| | | @Data |
| | | public class SysConfigHolidayDto extends BaseDTO implements Serializable { |
| | | |
| | | /** ID */ |
| | | private Long id; |
| | | |
| | | /** 节日日期 */ |
| | | private Timestamp holidayDate; |
| | | |
| | | /** 名称 */ |
| | | private String name; |
| | | |
| | | /** 日期类型 */ |
| | | private String dateType; |
| | | |
| | | /** 备注 */ |
| | | private String remarks; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.system.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import java.util.List; |
| | | import me.zhengjie.annotation.Query; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2022-12-12 |
| | | **/ |
| | | @Data |
| | | public class SysConfigHolidayQueryCriteria{ |
| | | |
| | | /** 精确 */ |
| | | @Query |
| | | private String holidayDate; |
| | | |
| | | /** 模糊 */ |
| | | @Query(type = Query.Type.INNER_LIKE) |
| | | private String name; |
| | | |
| | | /** 精确 */ |
| | | @Query |
| | | private String dateType; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.system.service.impl; |
| | | |
| | | import me.zhengjie.modules.system.domain.SysConfigHoliday; |
| | | import me.zhengjie.modules.system.domain.User; |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | | import me.zhengjie.utils.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.zhengjie.modules.system.repository.SysConfigHolidayRepository; |
| | | import me.zhengjie.modules.system.service.SysConfigHolidayService; |
| | | import me.zhengjie.modules.system.service.dto.SysConfigHolidayDto; |
| | | import me.zhengjie.modules.system.service.dto.SysConfigHolidayQueryCriteria; |
| | | import me.zhengjie.modules.system.service.mapstruct.SysConfigHolidayMapper; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.Pageable; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @author wcd |
| | | * @date 2022-12-12 |
| | | **/ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class SysConfigHolidayServiceImpl implements SysConfigHolidayService { |
| | | |
| | | private final SysConfigHolidayRepository sysConfigHolidayRepository; |
| | | private final SysConfigHolidayMapper sysConfigHolidayMapper; |
| | | private final UserRepository userRepository; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(SysConfigHolidayQueryCriteria criteria, Pageable pageable){ |
| | | Page<SysConfigHoliday> page = sysConfigHolidayRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); |
| | | return PageUtil.toPage(page.map(sysConfigHolidayMapper::toDto)); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysConfigHolidayDto> queryAll(SysConfigHolidayQueryCriteria criteria){ |
| | | return sysConfigHolidayMapper.toDto(sysConfigHolidayRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public SysConfigHolidayDto findById(Long id) { |
| | | SysConfigHoliday sysConfigHoliday = sysConfigHolidayRepository.findById(id).orElseGet(SysConfigHoliday::new); |
| | | ValidationUtil.isNull(sysConfigHoliday.getId(),"SysConfigHoliday","id",id); |
| | | return sysConfigHolidayMapper.toDto(sysConfigHoliday); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public SysConfigHolidayDto create(SysConfigHoliday resources) { |
| | | return sysConfigHolidayMapper.toDto(sysConfigHolidayRepository.save(resources)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void update(SysConfigHoliday resources) { |
| | | SysConfigHoliday sysConfigHoliday = sysConfigHolidayRepository.findById(resources.getId()).orElseGet(SysConfigHoliday::new); |
| | | ValidationUtil.isNull( sysConfigHoliday.getId(),"SysConfigHoliday","id",resources.getId()); |
| | | sysConfigHoliday.copy(resources); |
| | | sysConfigHolidayRepository.save(sysConfigHoliday); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteAll(Long[] ids) { |
| | | for (Long id : ids) { |
| | | sysConfigHolidayRepository.deleteById(id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void download(List<SysConfigHolidayDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (SysConfigHolidayDto sysConfigHoliday : all) { |
| | | Map<String,Object> map = new LinkedHashMap<>(); |
| | | map.put("节日日期", sysConfigHoliday.getHolidayDate()); |
| | | map.put("名称", sysConfigHoliday.getName()); |
| | | map.put("日期类型", sysConfigHoliday.getDateType()); |
| | | map.put("备注", sysConfigHoliday.getRemarks()); |
| | | map.put("创建者", sysConfigHoliday.getCreateBy()); |
| | | map.put("创建时间", sysConfigHoliday.getCreateTime()); |
| | | map.put("更新者", sysConfigHoliday.getUpdateBy()); |
| | | map.put("更新时间", sysConfigHoliday.getUpdateTime()); |
| | | list.add(map); |
| | | } |
| | | FileUtil.downloadExcel(list, response); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.system.service.mapstruct; |
| | | |
| | | import me.zhengjie.base.BaseMapper; |
| | | import me.zhengjie.modules.system.domain.SysConfigHoliday; |
| | | import me.zhengjie.modules.system.service.dto.SysConfigHolidayDto; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.ReportingPolicy; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2022-12-12 |
| | | **/ |
| | | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) |
| | | public interface SysConfigHolidayMapper extends BaseMapper<SysConfigHolidayDto, SysConfigHoliday> { |
| | | |
| | | } |
| New file |
| | |
| | | import request from '@/utils/request' |
| | | |
| | | export function add(data) { |
| | | return request({ |
| | | url: 'api/sysConfigHoliday', |
| | | method: 'post', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export function del(ids) { |
| | | return request({ |
| | | url: 'api/sysConfigHoliday/', |
| | | method: 'delete', |
| | | data: ids |
| | | }) |
| | | } |
| | | |
| | | export function edit(data) { |
| | | return request({ |
| | | url: 'api/sysConfigHoliday', |
| | | method: 'put', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export default { add, edit, del } |
| | |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | /** |
| | | * 日期格式化 |
| | | * @param {Object} timestamp 时间戳 |
| | | */ |
| | | toDate(timestamp) { |
| | | if (timestamp == null) { |
| | | return |
| | | } else { |
| | | const system = new Date(timestamp) |
| | | const year = system.getFullYear() |
| | | const month = system.getMonth() + 1 < 10 ? '0' + (system.getMonth() + 1) : system.getMonth() + 1 |
| | | const date = system.getDate() < 10 ? '0' + system.getDate() : system.getDate() |
| | | return year + '-' + month + '-' + date |
| | | } |
| | | }, |
| | | /** |
| | | * 时间格式化 |
| | | * @param {Object} timestamp |
| | | */ |
| | | toTime(timestamp) { |
| | | if (timestamp == null) { |
| | | return |
| | | } else { |
| | | const system = new Date(timestamp) |
| | | const hours = system.getHours() < 10 ? '0' + system.getHours() : system.getHours() |
| | | const minutes = system.getMinutes() < 10 ? '0' + system.getMinutes() : system.getMinutes() |
| | | const seconds = system.getSeconds() < 10 ? '0' + system.getSeconds() : system.getSeconds() |
| | | return hours + ':' + minutes + ':' + seconds |
| | | } |
| | | }, |
| | | /** |
| | | * 金额格式 |
| | | * @param {Object} num |
| | | */ |
| | | toMoney(num) { |
| | | let sign = '' |
| | | let cents = 0 |
| | | if (num != null) { num = num.toString().replace(/\$|\,/g, '') } |
| | | if (isNaN(num) || num == null) { num = '0' } |
| | | sign = (Number(num) === (num = Math.abs(num))) |
| | | num = Math.floor(num * 100 + 0.50000000001) |
| | | cents = num % 100 |
| | | num = Math.floor(num / 100).toString() |
| | | if (cents < 10) { cents = '0' + cents } |
| | | for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++) { num = num.substring(0, num.length - (4 * i + 3)) + ',' + num.substring(num.length - (4 * i + 3)) } |
| | | return (((sign) ? '' : '-') + num + '.' + cents) |
| | | } |
| | | } |
| | | const crud = Object.assign({}, data) |
| New file |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <div class="head-container"> |
| | | <div> |
| | | <el-input |
| | | v-model="query.name" |
| | | clearable |
| | | placeholder="请输入姓名" |
| | | style="width: 200px" |
| | | class="filter-item" |
| | | @keyup.enter.native="crud.toQuery" |
| | | /> |
| | | <el-date-picker |
| | | v-model="query.holidayDate" |
| | | class="filter-item" |
| | | value-format="yyyy-MM-dd" |
| | | placeholder="请选择日期" |
| | | /> |
| | | <el-select v-model="query.dateType" placeholder="请选择日期类型" class="filter-item" style="width: 200px;"> |
| | | <el-option |
| | | v-for="item in dict.date_type" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | <rrOperation /> |
| | | </div> |
| | | <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'--> |
| | | <crudOperation :permission="permission" /> |
| | | <!--表单组件--> |
| | | <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px"> |
| | | <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px"> |
| | | <el-form-item label="节日日期" prop="holidayDate"> |
| | | <el-date-picker v-model="form.holidayDate" style="width: 370px;" type="date" placeholder="选择日期" /> |
| | | </el-form-item> |
| | | <el-form-item label="名称" prop="name"> |
| | | <el-input v-model="form.name" style="width: 370px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="日期类型" prop="dateType"> |
| | | <el-select v-model="form.dateType" style="width: 370px;"> |
| | | <el-option |
| | | v-for="item in dict.date_type" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="备注" prop="remarks"> |
| | | <el-input v-model="form.remarks" type="textarea" maxlength="1000" style="width: 370px;" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button type="text" @click="crud.cancelCU">取消</el-button> |
| | | <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | <!--表格渲染--> |
| | | <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler"> |
| | | <el-table-column type="selection" width="55" /> |
| | | <el-table-column prop="holidayDate" label="节日日期"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toDate(scope.row.holidayDate) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="name" label="名称" show-overflow-tooltip /> |
| | | <el-table-column prop="dateType" label="日期类型"> |
| | | <template slot-scope="scope"> |
| | | {{ dict.label.date_type[scope.row.dateType] }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="remarks" label="备注" show-overflow-tooltip /> |
| | | <el-table-column prop="createTime" label="创建时间" /> |
| | | <el-table-column v-if="checkPer(['admin','sysConfigHoliday:edit','sysConfigHoliday:del'])" label="操作" width="150px" align="center"> |
| | | <template slot-scope="scope"> |
| | | <udOperation |
| | | :data="scope.row" |
| | | :permission="permission" |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <!--分页组件--> |
| | | <pagination /> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import crudConfigHoliday from '@/api/configHoliday' |
| | | import CRUD, { presenter, header, form, crud } from '@crud/crud' |
| | | import rrOperation from '@crud/RR.operation' |
| | | import crudOperation from '@crud/CRUD.operation' |
| | | import udOperation from '@crud/UD.operation' |
| | | import pagination from '@crud/Pagination' |
| | | |
| | | const defaultForm = { id: null, holidayDate: null, name: null, dateType: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | export default { |
| | | name: 'ConfigHoliday', |
| | | components: { pagination, crudOperation, rrOperation, udOperation }, |
| | | mixins: [presenter(), header(), form(defaultForm), crud()], |
| | | cruds() { |
| | | return CRUD({ title: '节日配置', url: 'api/sysConfigHoliday', idField: 'id', sort: 'id,desc', crudMethod: { ...crudConfigHoliday }}) |
| | | }, |
| | | // 数据字典 |
| | | dicts: ['date_type'], |
| | | data() { |
| | | return { |
| | | permission: { |
| | | add: ['admin', 'sysConfigHoliday:add'], |
| | | edit: ['admin', 'sysConfigHoliday:edit'], |
| | | del: ['admin', 'sysConfigHoliday:del'] |
| | | }, |
| | | rules: { |
| | | holidayDate: [ |
| | | { required: true, message: '节日日期不能为空', trigger: 'blur' } |
| | | ], |
| | | name: [ |
| | | { required: true, message: '名称不能为空', trigger: 'blur' }, |
| | | { min: 1, max: 100, message: '长度不超过100个字符', trigger: 'blur' } |
| | | ], |
| | | dateType: [ |
| | | { required: true, message: '日期类型不能为空', trigger: 'change' } |
| | | ], |
| | | createBy: [ |
| | | { required: true, message: '创建者不能为空', trigger: 'blur' } |
| | | ], |
| | | createTime: [ |
| | | { required: true, message: '创建时间不能为空', trigger: 'blur' } |
| | | ], |
| | | remarks: [ |
| | | { min: 1, max: 1000, message: '长度不超过1000个字符', trigger: 'blur' } |
| | | ] |
| | | }} |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | return true |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | </style> |