New file |
| | |
| | | package com.zy.crm.manager.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.core.domain.KeyValueVo; |
| | | import com.zy.crm.common.web.BaseController; |
| | | import com.zy.crm.manager.entity.Plan; |
| | | import com.zy.crm.manager.entity.Reimburse; |
| | | import com.zy.crm.manager.entity.ReimburseOnline; |
| | | import com.zy.crm.manager.service.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.core.io.ClassPathResource; |
| | | import org.springframework.util.ClassUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.*; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | public class ReimburseOnlineController extends BaseController { |
| | | |
| | | @Autowired |
| | | private ReimburseOnlineService reimburseOnlineService; |
| | | |
| | | @Autowired |
| | | private ReimburseService reimburseService; |
| | | |
| | | @Autowired |
| | | private PlanService planService; |
| | | |
| | | @RequestMapping(value = "/reimburseOnline/{id}/auth") |
| | | @ManagerAuth |
| | | public R get(@PathVariable("id") String id) { |
| | | return R.ok(reimburseOnlineService.selectById(String.valueOf(id))); |
| | | } |
| | | |
| | | @RequestMapping(value = "/reimburseOnline/viewCheck/{id}/auth") |
| | | @ManagerAuth |
| | | public R viewCheck(@PathVariable("id") String id) { |
| | | ReimburseOnline reimburseOnline = reimburseOnlineService.selectById(String.valueOf(id)); |
| | | if (Cools.isEmpty(reimburseOnline.getCheckData())) { |
| | | return R.error("请先上传询价"); |
| | | } |
| | | return R.ok(reimburseOnline); |
| | | } |
| | | |
| | | @RequestMapping(value = "/reimburseOnline/list/auth") |
| | | @ManagerAuth |
| | | public R list(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | @RequestParam(required = false)String orderByField, |
| | | @RequestParam(required = false)String orderByType, |
| | | @RequestParam(required = false)String condition, |
| | | @RequestParam Map<String, Object> param){ |
| | | EntityWrapper<ReimburseOnline> wrapper = new EntityWrapper<>(); |
| | | wrapper.setSqlSelect("id,title,create_time as createTime,filepath,item_id as itemId,order_num as orderNum,template_name as templateName,user_id as userId,dept_id as deptId,status,update_time as updateTime,check_data as checkData,update_user_id as updateUserId,member_id as memberId"); |
| | | wrapper.in("member_id", getUserRoleBelongsToUserId("allopen")); |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | | allLike(ReimburseOnline.class, param.keySet(), wrapper, condition); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} |
| | | return R.ok(reimburseOnlineService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ |
| | | Long deptId = getDeptId(); |
| | | boolean signUserId = false; |
| | | boolean signDeptId = false; |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | if (entry.getKey().equals("dept_id")){ |
| | | signDeptId = true; |
| | | } |
| | | } |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | String val = String.valueOf(entry.getValue()); |
| | | if (val.contains(RANGE_TIME_LINK)){ |
| | | String[] dates = val.split(RANGE_TIME_LINK); |
| | | wrapper.ge(entry.getKey(), DateUtils.convert(dates[0])); |
| | | wrapper.le(entry.getKey(), DateUtils.convert(dates[1])); |
| | | } else if (entry.getKey().equals("dept_id")){ |
| | | if (!val.equals("19")){ |
| | | wrapper.eq(entry.getKey(), val); |
| | | } |
| | | } else if (entry.getKey().equals("user_id") && !signDeptId){ |
| | | signUserId = true; |
| | | wrapper.eq(entry.getKey(), val); |
| | | } else { |
| | | wrapper.like(entry.getKey(), val); |
| | | } |
| | | } |
| | | if (!signUserId && !signDeptId){ |
| | | wrapper.eq("user_id", getUserId()); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/reimburseOnline/add/auth") |
| | | @ManagerAuth |
| | | public R add(@RequestBody Map<String,Object> map) { |
| | | //获取模板名称 |
| | | Reimburse reimburse = reimburseService.selectById(Integer.parseInt(map.get("priId").toString())); |
| | | if (reimburse.getStatus() == 0) { |
| | | return R.error("该模板已被禁用"); |
| | | } |
| | | |
| | | ReimburseOnline reimburseOnline = new ReimburseOnline(); |
| | | reimburseOnline.setCreateTime(new Date()); |
| | | reimburseOnline.setTitle(map.get("title").toString()); |
| | | reimburseOnline.setTemplateName(reimburse.getTitle()); |
| | | reimburseOnline.setSheetData(map.get("sheetData").toString()); |
| | | reimburseOnline.setItemId(Long.parseLong(map.get("itemId").toString())); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | reimburseOnline.setOrderNum(format.format(new Date())); |
| | | //创建人员 |
| | | reimburseOnline.setUserId(getUserId()); |
| | | //创建人员部门 |
| | | reimburseOnline.setDeptId(getDeptId()); |
| | | //更新时间 |
| | | reimburseOnline.setUpdateTime(new Date()); |
| | | //更新人员 |
| | | reimburseOnline.setUpdateUserId(getUserId()); |
| | | //状态,未完成 |
| | | reimburseOnline.setStatus(0); |
| | | //业务员 |
| | | // Item item = itemService.selectById(priOnline.getItemId()); |
| | | Plan plan = planService.selectById(reimburseOnline.getItemId()); |
| | | reimburseOnline.setMemberId(plan.getUserId()); |
| | | |
| | | |
| | | //设置项目流程 |
| | | plan.setStep(2); |
| | | planService.updateById(plan); |
| | | |
| | | reimburseOnlineService.insert(reimburseOnline); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/reimburseOnline/addOther/auth") |
| | | @ManagerAuth |
| | | public R addOther(@RequestBody Map<String,Object> map) { |
| | | ReimburseOnline online = reimburseOnlineService.selectById(Long.parseLong(map.get("id").toString())); |
| | | |
| | | ReimburseOnline reimburseOnline = new ReimburseOnline(); |
| | | reimburseOnline.setCreateTime(new Date()); |
| | | reimburseOnline.setTitle(map.get("title").toString()); |
| | | reimburseOnline.setTemplateName(online.getTemplateName()); |
| | | reimburseOnline.setSheetData(map.get("sheetData").toString()); |
| | | reimburseOnline.setItemId(online.getItemId()); |
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | reimburseOnline.setOrderNum(format.format(new Date())); |
| | | //创建人员 |
| | | reimburseOnline.setUserId(getUserId()); |
| | | //更新时间 |
| | | reimburseOnline.setUpdateTime(new Date()); |
| | | //更新人员 |
| | | reimburseOnline.setUpdateUserId(getUserId()); |
| | | //状态,未完成 |
| | | reimburseOnline.setStatus(0); |
| | | reimburseOnline.setDeptId(getDeptId()); |
| | | //业务员 |
| | | // Item item = itemService.selectById(priOnline.getItemId()); |
| | | Plan plan = planService.selectById(reimburseOnline.getItemId()); |
| | | reimburseOnline.setMemberId(plan.getUserId()); |
| | | |
| | | reimburseOnlineService.insert(reimburseOnline); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/reimburseOnline/update/auth") |
| | | @ManagerAuth |
| | | public R update(@RequestBody Map<String,Object> map){ |
| | | ReimburseOnline priOnline = reimburseOnlineService.selectById(Long.parseLong(map.get("id").toString())); |
| | | if (priOnline.getStatus() == 1) { |
| | | return R.error("核价已完成,禁止保存"); |
| | | } |
| | | priOnline.setTitle(map.get("title").toString()); |
| | | priOnline.setSheetData(map.get("sheetData").toString()); |
| | | //更新人员 |
| | | priOnline.setUpdateUserId(getUserId()); |
| | | //更新时间 |
| | | priOnline.setUpdateTime(new Date()); |
| | | reimburseOnlineService.updateById(priOnline); |
| | | return R.ok(); |
| | | } |
| | | |
| | | //更新状态 |
| | | @RequestMapping(value = "/reimburseOnline/updateForm/auth") |
| | | @ManagerAuth |
| | | public R updateForm(Long id,Integer status,String title,String templateName){ |
| | | ReimburseOnline priOnline = reimburseOnlineService.selectById(id); |
| | | priOnline.setStatus(status); |
| | | priOnline.setUpdateTime(new Date()); |
| | | priOnline.setTitle(title); |
| | | priOnline.setTemplateName(templateName); |
| | | reimburseOnlineService.updateById(priOnline); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/reimburseOnline/uploadCheck/auth") |
| | | @ManagerAuth |
| | | public R uploadCheck(@RequestParam("id") Integer id, |
| | | @RequestParam("checkData") String checkData, |
| | | @RequestParam("file") MultipartFile[] files){ |
| | | ReimburseOnline priOnline = reimburseOnlineService.selectById(id); |
| | | if (priOnline.getStatus() == 1) { |
| | | return R.error("核价已完成,禁止上传"); |
| | | } |
| | | priOnline.setCheckData(checkData); |
| | | |
| | | |
| | | MultipartFile file = files[0]; |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd_HHmmss"); |
| | | String path = ClassUtils.getDefaultClassLoader().getResource("excel/uploadCheckData").getPath(); |
| | | //文件后缀名 |
| | | String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); |
| | | //上传文件名 |
| | | String filename = format.format(new Date()) + suffix; |
| | | //最终文件路径 |
| | | String filepath = path + "/" + filename; |
| | | |
| | | |
| | | //服务器端保存的文件对象 |
| | | File serverFile = new File(filepath); |
| | | if(!serverFile.exists()) { |
| | | try { |
| | | //创建文件 |
| | | serverFile.createNewFile(); |
| | | //将上传的文件写入到服务器端文件内 |
| | | file.transferTo(serverFile); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | //保存文件名 |
| | | priOnline.setCheckDataFile(filename); |
| | | reimburseOnlineService.updateById(priOnline); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @GetMapping("/reimburseOnline/checkDataDownload/{filename}") |
| | | public void download(@PathVariable String filename, HttpServletResponse response) { |
| | | try { |
| | | ClassPathResource pathResource = new ClassPathResource("excel/uploadCheckData/" + filename); |
| | | File file = pathResource.getFile(); |
| | | InputStream inputStream = pathResource.getInputStream(); |
| | | //输出文件 |
| | | InputStream fis = new BufferedInputStream(inputStream); |
| | | byte[] buffer = new byte[fis.available()]; |
| | | fis.read(buffer); |
| | | fis.close(); |
| | | response.reset(); |
| | | |
| | | //获取文件的名字再浏览器下载页面 |
| | | String name = file.getName(); |
| | | response.addHeader("Content-Disposition", "attachment;filename=" + new String(name.getBytes(), "iso-8859-1")); |
| | | response.addHeader("Content-Length", "" + file.length()); |
| | | OutputStream out = new BufferedOutputStream(response.getOutputStream()); |
| | | response.setContentType("application/octet-stream"); |
| | | out.write(buffer); |
| | | out.flush(); |
| | | out.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/reimburseOnline/delete/auth") |
| | | @ManagerAuth |
| | | public R delete(Long[] ids){ |
| | | if (Cools.isEmpty(ids)){ |
| | | return R.error(); |
| | | } |
| | | reimburseOnlineService.deleteBatchIds(Arrays.asList(ids)); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/reimburseOnline/export/auth") |
| | | @ManagerAuth |
| | | public R export(@RequestBody JSONObject param){ |
| | | EntityWrapper<ReimburseOnline> wrapper = new EntityWrapper<>(); |
| | | List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); |
| | | Map<String, Object> map = excludeTrash(param.getJSONObject("priOnline")); |
| | | convert(map, wrapper); |
| | | List<ReimburseOnline> list = reimburseOnlineService.selectList(wrapper); |
| | | return R.ok(exportSupport(list, fields)); |
| | | } |
| | | |
| | | @RequestMapping(value = "/reimburseOnlineQuery/auth") |
| | | @ManagerAuth |
| | | public R query(String condition) { |
| | | EntityWrapper<ReimburseOnline> wrapper = new EntityWrapper<>(); |
| | | wrapper.like("order_num", condition); |
| | | wrapper.in("member_id", getUserRoleBelongsToUserId("allopen")); |
| | | Page<ReimburseOnline> page = reimburseOnlineService.selectPage(new Page<>(0, 10), wrapper); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (ReimburseOnline priOnline : page.getRecords()){ |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", priOnline.getId()); |
| | | map.put("value", priOnline.getOrderNum() + "/" + priOnline.getPlanId$() + "/" + priOnline.getMemberId$()); |
| | | result.add(map); |
| | | } |
| | | return R.ok(result); |
| | | } |
| | | |
| | | @RequestMapping(value = "/reimburseOnline/check/column/auth") |
| | | @ManagerAuth |
| | | public R query(@RequestBody JSONObject param) { |
| | | Wrapper<ReimburseOnline> wrapper = new EntityWrapper<ReimburseOnline>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val")); |
| | | if (null != reimburseOnlineService.selectOne(wrapper)){ |
| | | return R.parse(BaseRes.REPEAT).add(getComment(ReimburseOnline.class, String.valueOf(param.get("key")))); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping("/reimburseOnline/all/get/kv") |
| | | @ManagerAuth |
| | | public R getDataKV(@RequestParam(required = false) String condition) { |
| | | List<KeyValueVo> vos = new ArrayList<>(); |
| | | Wrapper<ReimburseOnline> wrapper = new EntityWrapper<ReimburseOnline>().andNew().like("id", condition).orderBy("create_time", false); |
| | | reimburseOnlineService.selectPage(new Page<>(1, 30), wrapper).getRecords().forEach(item -> vos.add(new KeyValueVo(String.valueOf(item.getId()), item.getId()))); |
| | | return R.ok().add(vos); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.crm.manager.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import com.core.common.Cools; |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.crm.manager.service.PlanService; |
| | | import com.zy.crm.system.entity.User; |
| | | import com.zy.crm.system.service.UserService; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.io.Serializable; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @TableName("man_reimburse_online") |
| | | public class ReimburseOnline implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * ID |
| | | */ |
| | | @ApiModelProperty(value= "ID") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * excel表标题 |
| | | */ |
| | | @ApiModelProperty(value= "excel表标题") |
| | | private String title; |
| | | |
| | | /** |
| | | * excel表数据 |
| | | */ |
| | | @ApiModelProperty(value= "excel表数据") |
| | | @TableField("sheet_data") |
| | | private String sheetData; |
| | | |
| | | @ApiModelProperty(value= "文件保存地址") |
| | | private String filepath; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @ApiModelProperty(value= "创建时间") |
| | | @TableField("create_time") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | | @ApiModelProperty(value= "项目id{man_item}") |
| | | @TableField("item_id") |
| | | private Long itemId; |
| | | |
| | | @ApiModelProperty(value= "订单号") |
| | | @TableField("order_num") |
| | | private String orderNum; |
| | | |
| | | @ApiModelProperty(value= "模板名") |
| | | @TableField("template_name") |
| | | private String templateName; |
| | | |
| | | @ApiModelProperty(value= "创建人员用户id") |
| | | @TableField("user_id") |
| | | private Long userId; |
| | | |
| | | @ApiModelProperty(value= "创建人员用户部门") |
| | | @TableField("dept_id") |
| | | private Long deptId; |
| | | |
| | | @ApiModelProperty(value= "状态{0:未完成,1:已完成}") |
| | | @TableField("status") |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty(value= "更新时间") |
| | | @TableField("update_time") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | private Date updateTime; |
| | | |
| | | @ApiModelProperty(value= "上传报价excel数据") |
| | | @TableField("check_data") |
| | | private String checkData; |
| | | |
| | | @ApiModelProperty(value= "更新人员") |
| | | @TableField("update_user_id") |
| | | private Long updateUserId; |
| | | |
| | | @ApiModelProperty(value= "业务员") |
| | | @TableField("member_id") |
| | | private Long memberId; |
| | | |
| | | @ApiModelProperty(value= "上传报价excel数据的原始文件地址") |
| | | @TableField("check_data_file") |
| | | private String checkDataFile; |
| | | |
| | | public ReimburseOnline() {} |
| | | |
| | | public ReimburseOnline(String title, String sheetData, Date createTime, String filepath) { |
| | | this.title = title; |
| | | this.sheetData = sheetData; |
| | | this.createTime = createTime; |
| | | this.filepath = filepath; |
| | | } |
| | | |
| | | // PriOnline priOnline = new PriOnline( |
| | | // null, // excel表标题 |
| | | // null, // excel表数据 |
| | | // null // 创建时间 |
| | | // ); |
| | | |
| | | public String getCreateTime$(){ |
| | | if (Cools.isEmpty(this.createTime)){ |
| | | return ""; |
| | | } |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.createTime); |
| | | } |
| | | |
| | | public String getUpdateTime$(){ |
| | | if (Cools.isEmpty(this.updateTime)){ |
| | | return ""; |
| | | } |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.updateTime); |
| | | } |
| | | |
| | | // public String getItemId$() { |
| | | // ItemService itemService = SpringUtils.getBean(ItemService.class); |
| | | // Item item = itemService.selectById(this.itemId); |
| | | // if (!Cools.isEmpty(item)){ |
| | | // return String.valueOf(item.getName()); |
| | | // } |
| | | // return null; |
| | | // } |
| | | |
| | | public String getPlanId$() { |
| | | PlanService planService = SpringUtils.getBean(PlanService.class); |
| | | Plan plan = planService.selectById(this.itemId); |
| | | if (!Cools.isEmpty(plan)){ |
| | | return String.valueOf(plan.getUuid()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getUser$() { |
| | | UserService userService = SpringUtils.getBean(UserService.class); |
| | | User user = userService.selectById(this.userId); |
| | | if (!Cools.isEmpty(user)){ |
| | | return String.valueOf(user.getNickname()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getUpdateUserId$() { |
| | | UserService userService = SpringUtils.getBean(UserService.class); |
| | | User user = userService.selectById(this.updateUserId); |
| | | if (!Cools.isEmpty(user)){ |
| | | return String.valueOf(user.getNickname()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getMemberId$() { |
| | | UserService userService = SpringUtils.getBean(UserService.class); |
| | | User user = userService.selectById(this.memberId); |
| | | if (!Cools.isEmpty(user)){ |
| | | return String.valueOf(user.getNickname()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getStatus$() { |
| | | if (null == this.status){ return null; } |
| | | switch (this.status){ |
| | | case 1: |
| | | return "已完成"; |
| | | case 0: |
| | | return "未完成"; |
| | | default: |
| | | return String.valueOf(this.status); |
| | | } |
| | | } |
| | | |
| | | public String getCheckDataStatus$() { |
| | | if (Cools.isEmpty(this.checkData)) { |
| | | return "未上传"; |
| | | } |
| | | return "已上传"; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.crm.manager.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.zy.crm.manager.entity.ReimburseOnline; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface ReimburseOnlineMapper extends BaseMapper<ReimburseOnline> { |
| | | |
| | | List<ReimburseOnline> listByPage(Page<ReimburseOnline> page, @Param("userIds") ArrayList<Long> userIds , @Param("condition") String condition); |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.crm.manager.service; |
| | | |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.zy.crm.manager.entity.ReimburseOnline; |
| | | |
| | | import java.util.ArrayList; |
| | | |
| | | public interface ReimburseOnlineService extends IService<ReimburseOnline> { |
| | | |
| | | Page<ReimburseOnline> listByPage(Page<ReimburseOnline> page, ArrayList<Long> userIds , String condition); |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.crm.manager.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.zy.crm.manager.entity.ReimburseOnline; |
| | | import com.zy.crm.manager.mapper.ReimburseOnlineMapper; |
| | | import com.zy.crm.manager.service.ReimburseOnlineService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | |
| | | @Service("reimburseOnlineService") |
| | | public class ReimburseOnlineServiceImpl extends ServiceImpl<ReimburseOnlineMapper, ReimburseOnline> implements ReimburseOnlineService { |
| | | |
| | | @Override |
| | | public Page<ReimburseOnline> listByPage(Page<ReimburseOnline> page, ArrayList<Long> userIds, String condition) { |
| | | return page.setRecords(this.baseMapper.listByPage(page, userIds, condition)); |
| | | } |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zy.crm.manager.mapper.ReimburseOnlineMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.zy.crm.manager.entity.ReimburseOnline"> |
| | | <id column="id" property="id" /> |
| | | <result column="title" property="title" /> |
| | | <result column="sheet_data" property="sheetData" /> |
| | | <result column="create_time" property="createTime" /> |
| | | <result column="filepath" property="filepath" /> |
| | | <result column="item_id" property="itemId" /> |
| | | <result column="order_num" property="orderNum" /> |
| | | <result column="template_name" property="templateName" /> |
| | | <result column="user_id" property="userId" /> |
| | | <result column="dept_id" property="deptId" /> |
| | | <result column="status" property="status" /> |
| | | <result column="update_time" property="updateTime" /> |
| | | <result column="check_data" property="checkData" /> |
| | | </resultMap> |
| | | |
| | | <!-- 查询结果不包含excel数据data,以免结果集过大 --> |
| | | <resultMap id="NoDataResultMap" type="com.zy.crm.manager.entity.ReimburseOnline"> |
| | | <id column="id" property="id" /> |
| | | <result column="title" property="title" /> |
| | | <result column="create_time" property="createTime" /> |
| | | <result column="filepath" property="filepath" /> |
| | | <result column="item_id" property="itemId" /> |
| | | <result column="order_num" property="orderNum" /> |
| | | <result column="template_name" property="templateName" /> |
| | | <result column="user_id" property="userId" /> |
| | | <result column="dept_id" property="deptId" /> |
| | | <result column="status" property="status" /> |
| | | <result column="update_time" property="updateTime" /> |
| | | </resultMap> |
| | | |
| | | <select id="listByPage" resultMap="NoDataResultMap"> |
| | | SELECT |
| | | * |
| | | FROM man_reimburse_online |
| | | WHERE 1=1 |
| | | <if test="userIds != null"> |
| | | and user_id in |
| | | <foreach collection="userIds" index="index" item="item" separator="," open="(" close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | <if test="condition != null and condition != ''"> |
| | | and ( |
| | | id like concat('%',#{condition},'%') |
| | | or title like concat('%',#{condition},'%') |
| | | or item_id like concat('%',#{condition},'%') |
| | | or order_num like concat('%',#{condition},'%') |
| | | or template_name like concat('%',#{condition},'%') |
| | | or user_id like concat('%',#{condition},'%') |
| | | ) |
| | | </if> |
| | | ORDER BY id DESC |
| | | </select> |
| | | |
| | | </mapper> |
New file |
| | |
| | | var pageCurr; |
| | | var admin; |
| | | var treeCond; |
| | | layui.config({ |
| | | base: baseUrl + "/static/layui/lay/modules/" |
| | | }).extend({ |
| | | cascader: 'cascader/cascader', |
| | | }).use(['table','laydate', 'form', 'admin', 'xmSelect', 'element', 'cascader', 'tree', 'dropdown'], function(){ |
| | | var table = layui.table; |
| | | var $ = layui.jquery; |
| | | var layer = layui.layer; |
| | | var layDate = layui.laydate; |
| | | var tree = layui.tree; |
| | | var form = layui.form; |
| | | var dropdown = layui.dropdown; |
| | | admin = layui.admin; |
| | | |
| | | $('#organization').html(localStorage.getItem('nickname') + ' <i class="layui-icon"></i>'); |
| | | |
| | | // 部门人员 筛选 |
| | | dropdown.render({ |
| | | elem: '#organization' |
| | | ,content: ['<div id="organizationTree" style="height: calc(100vh - 525px);border: none"></div>'].join('') |
| | | ,style: 'width: 370px; height: 350px; padding: 0 15px; box-shadow: 1px 1px 30px rgb(0 0 0 / 12%);' |
| | | ,ready: function(){ |
| | | loadTree(); |
| | | } |
| | | }); |
| | | |
| | | // 树形图 |
| | | var organizationTree; |
| | | window.loadTree = function(condition){ |
| | | var loadIndex = layer.load(2); |
| | | $.ajax({ |
| | | url: baseUrl+"/dept/user/tree/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: { |
| | | 'condition': condition |
| | | }, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.close(loadIndex); |
| | | if (res.code === 200){ |
| | | organizationTree = tree.render({ |
| | | elem: '#organizationTree', |
| | | id: 'organizationTree', |
| | | onlyIconControl: true, |
| | | data: res.data, |
| | | click: function (obj) { |
| | | treeCond = { |
| | | key: obj.data.key, |
| | | val: obj.data.id |
| | | } |
| | | $('#organization').html(obj.data.title + ' <i class="layui-icon"></i>'); |
| | | $('#organizationTree').find('.ew-tree-click').removeClass('ew-tree-click'); |
| | | $(obj.elem).children('.layui-tree-entry').addClass('ew-tree-click'); |
| | | clearFormVal($('#search-box')); |
| | | tableIns.reload({ |
| | | where: {[obj.data.key]: obj.data.id}, |
| | | page: {curr: 1} |
| | | }); |
| | | } |
| | | }); |
| | | treeData = res.data; |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg) |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | // 数据渲染 |
| | | tableIns = table.render({ |
| | | elem: '#reimburseOnline', |
| | | headers: {token: localStorage.getItem('token')}, |
| | | url: baseUrl+'/reimburseOnline/list/auth', |
| | | page: true, |
| | | limit: 16, |
| | | limits: [16, 30, 50, 100, 200, 500], |
| | | toolbar: '#toolbar', |
| | | cellMinWidth: 150, |
| | | cols: [[ |
| | | {type: 'checkbox', fixed: 'left'} |
| | | ,{field: 'id', title: 'ID', sort: true,align: 'center', fixed: 'left', width: 80,hide: true} |
| | | ,{field: 'templateName', align: 'center',title: '报销名',hide: false} |
| | | ,{field: 'orderNum', align: 'center',title: '报销单号'} |
| | | ,{field: 'planId$', align: 'center',title: '规划单号'} |
| | | ,{field: 'createTime$', align: 'center',title: '创建时间'} |
| | | ,{field: 'updateTime$', align: 'center',title: '更新时间'} |
| | | ,{field: 'status$', align: 'center',title: '状态'} |
| | | ,{field: 'memberId$', align: 'center',title: '业务员'} |
| | | ,{field: 'user$', align: 'center',title: '创建人员'} |
| | | ,{field: 'updateUserId$', align: 'center',title: '更新人员'} |
| | | ,{field: 'checkDataStatus$', align: 'center',title: '报价数据'} |
| | | ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:350} |
| | | ]], |
| | | request: { |
| | | pageName: 'curr', |
| | | pageSize: 'limit' |
| | | }, |
| | | parseData: function (res) { |
| | | return { |
| | | 'code': res.code, |
| | | 'msg': res.msg, |
| | | 'count': res.data.total, |
| | | 'data': res.data.records |
| | | } |
| | | }, |
| | | response: { |
| | | statusCode: 200 |
| | | }, |
| | | done: function(res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } |
| | | pageCurr=curr; |
| | | limit(); |
| | | } |
| | | }); |
| | | |
| | | // 监听排序事件 |
| | | table.on('sort(reimburseOnline)', function (obj) { |
| | | var searchData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | searchData['orderByField'] = obj.field; |
| | | searchData['orderByType'] = obj.type; |
| | | tableIns.reload({ |
| | | where: searchData, |
| | | page: { |
| | | curr: 1 |
| | | }, |
| | | done: function (res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } |
| | | pageCurr=curr; |
| | | limit(); |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | // 监听头工具栏事件 |
| | | table.on('toolbar(reimburseOnline)', function (obj) { |
| | | var checkStatus = table.checkStatus(obj.config.id); |
| | | switch(obj.event) { |
| | | case 'addBlank': |
| | | showEditModel(); |
| | | break; |
| | | case 'refreshData': |
| | | tableIns.reload({ |
| | | page: { |
| | | curr: pageCurr |
| | | } |
| | | }); |
| | | limit(); |
| | | break; |
| | | case 'deleteData': |
| | | var data = checkStatus.data; |
| | | var ids=[]; |
| | | data.map(function (track) { |
| | | ids.push(track.id); |
| | | }); |
| | | if (ids.length === 0){ |
| | | layer.msg('请选择数据'); |
| | | } else { |
| | | layer.confirm('确定删除'+(ids.length===1?'此':ids.length)+'条数据吗', function(){ |
| | | $.ajax({ |
| | | url: baseUrl+"/reimburseOnline/delete/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: {ids: ids}, |
| | | method: 'POST', |
| | | traditional:true, |
| | | success: function (res) { |
| | | if (res.code === 200){ |
| | | layer.closeAll(); |
| | | tableReload(false); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg) |
| | | } |
| | | } |
| | | }) |
| | | }); |
| | | } |
| | | break; |
| | | case 'exportData': |
| | | layer.confirm('确定导出Excel吗', {shadeClose: true}, function(){ |
| | | var titles=[]; |
| | | var fields=[]; |
| | | obj.config.cols[0].map(function (col) { |
| | | if (col.type === 'normal' && col.hide === false && col.toolbar == null) { |
| | | titles.push(col.title); |
| | | fields.push(col.field); |
| | | } |
| | | }); |
| | | var exportData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | exportData[this.name] = this.value; |
| | | }); |
| | | var param = { |
| | | 'config': exportData, |
| | | 'fields': fields |
| | | }; |
| | | $.ajax({ |
| | | url: baseUrl+"/reimburseOnline/export/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify(param), |
| | | dataType:'json', |
| | | contentType:'application/json;charset=UTF-8', |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.closeAll(); |
| | | if (res.code === 200) { |
| | | table.exportFile(titles,res.data,'xls'); |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg) |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | break; |
| | | } |
| | | }); |
| | | |
| | | // 监听行工具事件 |
| | | table.on('tool(reimburseOnline)', function(obj){ |
| | | var data = obj.data; |
| | | switch (obj.event) { |
| | | // 核价 |
| | | case 'check': |
| | | layer.open({ |
| | | type: 2, |
| | | title: '核价', |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: false, |
| | | content: 'reimburseOnline_detail.html?id=' + data.id, |
| | | success: function(layero, index){ |
| | | // layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"}); |
| | | } |
| | | }); |
| | | break; |
| | | case 'del': |
| | | layer.confirm('确定删除这条数据吗', function(){ |
| | | $.ajax({ |
| | | url: baseUrl+"/reimburseOnline/delete/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: {ids: data.id}, |
| | | method: 'POST', |
| | | traditional:true, |
| | | success: function (res) { |
| | | if (res.code === 200){ |
| | | layer.closeAll(); |
| | | tableReload(false); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg) |
| | | } |
| | | } |
| | | }) |
| | | }); |
| | | break; |
| | | case "edit": |
| | | showEditForm(data); |
| | | break; |
| | | case "upload": |
| | | $.ajax({ |
| | | type:"get", |
| | | url: baseUrl+"/reimburseOnline/viewCheck/" + data.id + "/auth", |
| | | dataType:"json", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | success:function(res) { |
| | | if (res.code == 200) { |
| | | layer.confirm('当前已存在数据,继续上传将会覆盖旧数据,是否上传?', function(){ |
| | | $("#uploadQuote").click() |
| | | }); |
| | | }else{ |
| | | $("#uploadQuote").click() |
| | | } |
| | | } |
| | | }); |
| | | |
| | | $("#uploadQuote").on("change",(evt) => { |
| | | var files = evt.target.files; |
| | | if(files==null || files.length==0){ |
| | | alert("No files wait for import"); |
| | | return; |
| | | } |
| | | |
| | | let name = files[0].name; |
| | | let suffixArr = name.split("."), suffix = suffixArr[suffixArr.length-1]; |
| | | if(suffix!="xlsx"){ |
| | | alert("Currently only supports the import of xlsx files"); |
| | | return; |
| | | } |
| | | LuckyExcel.transformExcelToLucky(files[0], function(exportJson, luckysheetfile){ |
| | | if(exportJson.sheets==null || exportJson.sheets.length==0){ |
| | | alert("Failed to read the content of the excel file, currently does not support xls files!"); |
| | | return; |
| | | } |
| | | |
| | | let formData = new FormData($("#uploadFile")[0]); |
| | | formData.append("id", data.id); |
| | | formData.append("checkData", zip(exportJson.sheets)); |
| | | $.ajax({ |
| | | url: baseUrl+"/reimburseOnline/uploadCheck/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: formData, |
| | | // data: JSON.stringify({ |
| | | // id: data.id, |
| | | // checkData: zip(exportJson.sheets) |
| | | // }), |
| | | // dataType: "json", |
| | | method: 'POST', |
| | | cache: false, |
| | | processData: false, |
| | | contentType: false, |
| | | // contentType:'application/json;charset=UTF-8', |
| | | success: function (res) { |
| | | if (res.code == 200) { |
| | | layer.msg('上传成功',{time:1000},() => { |
| | | parent.location.reload() |
| | | }) |
| | | }else{ |
| | | layer.msg(res.msg,{time:1000},() => { |
| | | parent.location.reload() |
| | | }) |
| | | } |
| | | } |
| | | }) |
| | | }); |
| | | }) |
| | | break; |
| | | case "viewCheck": |
| | | //查看询价 |
| | | $.ajax({ |
| | | type:"get", |
| | | url: baseUrl+"/reimburseOnline/viewCheck/" + data.id + "/auth", |
| | | dataType:"json", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | success:function(res) { |
| | | if (res.code == 200) { |
| | | layer.open({ |
| | | type: 2, |
| | | title: '查看询价', |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: false, |
| | | content: 'reimburseOnline_check.html?id=' + data.id, |
| | | success: function(layero, index){ |
| | | // layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"}); |
| | | } |
| | | }); |
| | | }else{ |
| | | layer.msg(res.msg,{time:1000}) |
| | | } |
| | | } |
| | | }); |
| | | break; |
| | | } |
| | | }); |
| | | |
| | | // 搜索 |
| | | form.on('submit(search)', function (data) { |
| | | pageCurr = 1; |
| | | pageCount = 0; |
| | | tableReload(); |
| | | }); |
| | | |
| | | /* 弹窗 - 新增、修改 */ |
| | | function showEditModel(mData) { |
| | | admin.open({ |
| | | type: 1, |
| | | area: '800px', |
| | | title: (mData ? '修改' : '添加') + '核价', |
| | | content: $('#editDialog').html(), |
| | | success: function (layero, dIndex) { |
| | | form.val('detail', mData); |
| | | form.on('submit(editSubmit)', function (data) { |
| | | var loadIndex = layer.load(2); |
| | | layer.close(loadIndex); |
| | | layer.close(dIndex); |
| | | layer.open({ |
| | | type: 2, |
| | | title: '新增', |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: false, |
| | | content: 'reimburseOnline_detail.html?item_id=' + data.field.planId + "&pri_id=" + data.field.priId, |
| | | success: function(layero, index){ |
| | | clearFormVal(layer.getChildFrame('#detail', index)); |
| | | // layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"}); |
| | | } |
| | | }); |
| | | return false; |
| | | }); |
| | | $(layero).children('.layui-layer-content').css('overflow', 'visible'); |
| | | layui.form.render('select'); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | //更新form |
| | | function showEditForm(mData) { |
| | | admin.open({ |
| | | type: 1, |
| | | area: '800px', |
| | | title: '核价信息编辑', |
| | | content: $('#editStatus').html(), |
| | | success: function (layero, dIndex) { |
| | | form.val('editStatusDetail', mData); |
| | | form.render('select') |
| | | form.on('submit(editSubmit)', function (data) { |
| | | var loadIndex = layer.load(2); |
| | | $.ajax({ |
| | | url: baseUrl+"/reimburseOnline/updateForm/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: data.field, |
| | | method: 'POST', |
| | | traditional:true, |
| | | success: function (res) { |
| | | if (res.code === 200){ |
| | | layer.closeAll(); |
| | | tableReload(false); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg) |
| | | } |
| | | } |
| | | }) |
| | | layer.close(loadIndex); |
| | | layer.close(dIndex); |
| | | return false; |
| | | }); |
| | | $(layero).children('.layui-layer-content').css('overflow', 'visible'); |
| | | layui.form.render('select'); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | }); |
| | | |
| | | // 关闭动作 |
| | | $(document).on('click','#data-detail-close', function () { |
| | | parent.layer.closeAll(); |
| | | }); |
| | | |
| | | function tableReload(child) { |
| | | var searchData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | (child ? parent.tableIns : tableIns).reload({ |
| | | where: searchData, |
| | | page: { |
| | | curr: pageCurr |
| | | }, |
| | | done: function (res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } |
| | | pageCurr=curr; |
| | | if (res.data.length === 0 && count !== 0) { |
| | | tableIns.reload({ |
| | | where: searchData, |
| | | page: { |
| | | curr: pageCurr-1 |
| | | } |
| | | }); |
| | | pageCurr -= 1; |
| | | } |
| | | limit(child); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | function setFormVal(el, data, showImg) { |
| | | for (var val in data) { |
| | | var find = el.find(":input[id='" + val + "']"); |
| | | find.val(data[val]); |
| | | if (showImg){ |
| | | var next = find.next(); |
| | | if (next.get(0)){ |
| | | if (next.get(0).localName === "img") { |
| | | find.hide(); |
| | | next.attr("src", data[val]); |
| | | next.show(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | function clearFormVal(el) { |
| | | $(':input', el) |
| | | .val('') |
| | | .removeAttr('checked') |
| | | .removeAttr('selected'); |
| | | } |
| | | |
| | | function detailScreen(index) { |
| | | var detail = layer.getChildFrame('#data-detail', index); |
| | | var height = detail.height()+60; |
| | | if (height > ($(window).height()*0.9)) { |
| | | height = ($(window).height()*0.9); |
| | | } |
| | | layer.style(index, { |
| | | top: (($(window).height()-height)/3)+"px", |
| | | height: height+'px' |
| | | }); |
| | | $(".layui-layer-shade").remove(); |
| | | } |
| | | |
| | | $('body').keydown(function () { |
| | | if (event.keyCode === 13) { |
| | | $("#search").click(); |
| | | } |
| | | }); |
| | | |
| | | // 压缩 |
| | | function zip(data) { |
| | | if (!data) return data |
| | | // 判断数据是否需要转为JSON |
| | | const dataJson = typeof data !== 'string' && typeof data !== 'number' ? JSON.stringify(data) : data |
| | | |
| | | // 使用Base64.encode处理字符编码,兼容中文 |
| | | const str = Base64.encode(dataJson) |
| | | let binaryString = pako.gzip(str); |
| | | let arr = Array.from(binaryString); |
| | | let s = ""; |
| | | arr.forEach((item, index) => { |
| | | s += String.fromCharCode(item) |
| | | }) |
| | | return btoa(s) |
| | | } |
New file |
| | |
| | | <!DOCTYPE html> |
| | | <html lang="en"> |
| | | <head> |
| | | <meta charset="utf-8"> |
| | | <title></title> |
| | | <meta name="renderer" content="webkit"> |
| | | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| | | <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> |
| | | <link rel="stylesheet" href="../../static/layui/css/layui.css" media="all"> |
| | | <link rel="stylesheet" href="../../static/css/admin.css?v=318" media="all"> |
| | | <link rel="stylesheet" href="../../static/css/cool.css" media="all"> |
| | | <link rel="stylesheet" href="../../static/css/tree.css" media="all"> |
| | | <link rel="stylesheet" href="../../static/layui/lay/modules/formDesigner/coolForm.css" /> |
| | | <style> |
| | | .nav-box { |
| | | position: absolute; |
| | | top: 1px; |
| | | left: 5px; |
| | | } |
| | | .nav-box-item { |
| | | display: inline-block; |
| | | vertical-align: middle; |
| | | margin-right: 5px; |
| | | } |
| | | |
| | | </style> |
| | | </head> |
| | | <body> |
| | | |
| | | <div class="layui-fluid"> |
| | | <div class="layui-card"> |
| | | <div class="layui-card-body"> |
| | | <div id="search-box" class="layui-form toolbar" style="display: flex;justify-content: flex-end;position: relative"> |
| | | <div class="nav-box"> |
| | | <div class="nav-box-item"> |
| | | <i class="layui-icon" style="color: #1890ff;font-weight: bold"></i> |
| | | </div> |
| | | <div class="nav-box-item"> |
| | | <button id="organization" style="border: none;padding-right: 35px;" class="layui-btn layui-btn-primary icon-btn"> |
| | | 未知 |
| | | </button> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <div class="layui-inline"> |
| | | <div class="layui-input-inline"> |
| | | <input class="layui-input" type="text" name="condition" placeholder="请输入" autocomplete="off" style="border-color: #e1e1e1"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline">  |
| | | <button class="layui-btn icon-btn layui-btn-sm" lay-filter="search" lay-submit> |
| | | <i class="layui-icon"></i>搜索 |
| | | </button> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <table class="layui-hide" id="reimburseOnline" lay-filter="reimburseOnline"></table> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | <script type="text/html" id="toolbar"> |
| | | <div class="layui-btn-container"> |
| | | <button class="layui-btn layui-btn-sm" lay-event="addBlank">新增报销</button> |
| | | <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="deleteData">删除</button> |
| | | </div> |
| | | </script> |
| | | |
| | | <form id="uploadFile" enctype="multipart/form-data" style="display: none;" > |
| | | <input type="file" name="file" id="uploadQuote"> |
| | | <input type="button" onclick="upload()" value="上传"/> |
| | | </form> |
| | | |
| | | |
| | | <script type="text/html" id="operate"> |
| | | <a class="layui-btn layui-btn-xs btn-edit" lay-event="approval">提交</a> |
| | | <a class="layui-btn layui-btn-xs btn-edit" lay-event="check">模板</a> |
| | | <a class="layui-btn layui-btn-primary layui-btn-xs btn-edit" lay-event="edit">编辑</a> |
| | | <!-- <a class="layui-btn layui-btn-primary layui-btn-xs btn-edit" lay-event="upload">上传询价</a>--> |
| | | <!-- <a class="layui-btn layui-btn-primary layui-btn-xs btn-edit" lay-event="viewCheck">查看询价</a>--> |
| | | <a class="layui-btn layui-btn-danger layui-btn-xs btn-edit" lay-event="del">删除</a> |
| | | </script> |
| | | |
| | | <script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script> |
| | | <script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/cool.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/luckysheet_js/luckyexcel.umd.js"></script> |
| | | <script type="text/javascript" src="../../static/js/luckysheet_js/pako.es5.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/luckysheet_js/base64.min.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/reimburseOnline/reimburseOnline.js" charset="utf-8"></script> |
| | | <!-- 表单弹窗 --> |
| | | <script type="text/html" id="editDialog"> |
| | | <div id="detail" lay-filter="detail" class="layui-form admin-form model-form"> |
| | | <input name="id" type="hidden"> |
| | | <div class="layui-row"> |
| | | <div class="layui-col-md12"> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label layui-form-required">项目名: </label> |
| | | <div class="layui-input-block cool-auto-complete"> |
| | | <input class="layui-input" name="planId" placeholder="请输入项目名" style="display: none" lay-verify="required"> |
| | | <input id="planId$" name="planId$" class="layui-input cool-auto-complete-div" onclick="autoShow(this.id)" type="text" placeholder="请输入项目名" onfocus=this.blur()> |
| | | <div class="cool-auto-complete-window"> |
| | | <input class="cool-auto-complete-window-input" data-key="planQueryNameBydirector" onkeyup="autoLoad(this.getAttribute('data-key'))"> |
| | | <select class="cool-auto-complete-window-select" data-key="planQueryNameBydirectorSelect" onchange="confirmed(this.getAttribute('data-key'))" multiple="multiple"> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label layui-form-required">报销模板名: </label> |
| | | <div class="layui-input-block cool-auto-complete"> |
| | | <input class="layui-input" name="priId" placeholder="请输入模板名" style="display: none" lay-verify="required"> |
| | | <input id="priId$" name="priId$" class="layui-input cool-auto-complete-div" onclick="autoShow(this.id)" type="text" placeholder="请输入模板名" onfocus=this.blur()> |
| | | <div class="cool-auto-complete-window"> |
| | | <input class="cool-auto-complete-window-input" data-key="reimburseQueryBypri" onkeyup="autoLoad(this.getAttribute('data-key'))"> |
| | | <select class="cool-auto-complete-window-select" data-key="reimburseQueryBypriSelect" onchange="confirmed(this.getAttribute('data-key'))" multiple="multiple"> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <hr class="layui-bg-gray"> |
| | | <div class="layui-form-item text-right"> |
| | | <button class="layui-btn" lay-filter="editSubmit" lay-submit="">保存</button> |
| | | <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button> |
| | | </div> |
| | | </div> |
| | | </script> |
| | | |
| | | <!-- 表单弹窗 --> |
| | | <script type="text/html" id="editStatus"> |
| | | <div id="editStatusDetail" lay-filter="editStatusDetail" class="layui-form admin-form model-form"> |
| | | <input name="id" type="hidden"> |
| | | <div class="layui-row"> |
| | | <div class="layui-col-md12"> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label layui-form-required">状态: </label> |
| | | <div class="layui-input-block"> |
| | | <select name="status" lay-vertype="tips" lay-verify="required"> |
| | | <option value="">请选择状态</option> |
| | | <option value="1">已完成</option> |
| | | <option value="0">未完成</option> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label layui-form-required">模板名: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="templateName" placeholder="请输入模板名" autocomplete="off" lay-verify="required"> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label layui-form-required">表格标题: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="title" placeholder="请输入表格标题" autocomplete="off" lay-verify="required"> |
| | | </div> |
| | | </div> |
| | | |
| | | </div> |
| | | </div> |
| | | <hr class="layui-bg-gray"> |
| | | <div class="layui-form-item text-right"> |
| | | <button class="layui-btn" lay-filter="editSubmit" lay-submit="">保存</button> |
| | | <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button> |
| | | </div> |
| | | </div> |
| | | </script> |
| | | </body> |
| | | </html> |
| | | |
| | | |
New file |
| | |
| | | <!DOCTYPE html> |
| | | <html> |
| | | <head> |
| | | <meta charset="utf-8"> |
| | | <title>excel</title> |
| | | <link rel="stylesheet" href="../../static/layui/css/layui.css" media="all"> |
| | | <link rel='stylesheet' href='../../static/plugins/css/pluginsCss.css' /> |
| | | <link rel='stylesheet' href='../../static/plugins/plugins.css' /> |
| | | <link rel='stylesheet' href='../../static/css/luckysheet.css' /> |
| | | <link rel='stylesheet' href='../../static/assets/iconfont/iconfont.css' /> |
| | | <script src="../../static/js/luckysheet_js/plugin.js"></script> |
| | | <script src="../../static/js/luckysheet_js/luckysheet.umd.js"></script> |
| | | <script src="../../static/js/luckysheet_js/luckyexcel.umd.js"></script> |
| | | <script src="../../static/js/luckysheet_js/exceljs.min.js"></script> |
| | | <script type="text/javascript" src="../../static/js/luckysheet_js/export.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/luckysheet_js/pako.es5.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/luckysheet_js/base64.min.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/luckysheet_js/print.min.js" charset="utf-8"></script> |
| | | </head> |
| | | <body> |
| | | <div style="display: flex;position: absolute;top: 20px;left:30px;z-index: 9999;"> |
| | | <!-- <div><button type="button" id="export">导出Execel</button></div>--> |
| | | <!-- <div><button type="button" id="save">保存到服务器</button></div>--> |
| | | <!-- <div><button type="button" id="otherSave">另保存到服务器</button></div>--> |
| | | <div><button type="button" class="layui-btn layui-btn-primary layui-btn-xs btn-edit" id="allprint">全部打印</button></div> |
| | | <div><button type="button" class="layui-btn layui-btn-primary layui-btn-xs btn-edit" id="print">选区打印</button></div> |
| | | <div><button type="button" class="layui-btn layui-btn-primary layui-btn-xs btn-edit" id="download">下载</button></div> |
| | | </div> |
| | | <div id="luckysheet" style="margin:0px;padding:0px;position:absolute;width:100%;height: 100vh;left: 0px;top: 0px;"></div> |
| | | <script> |
| | | $(function () { |
| | | var layer = layui.layer; |
| | | |
| | | //配置项 |
| | | var options = { |
| | | container: 'luckysheet' ,//luckysheet为容器id |
| | | title: '查看询价', //工作簿名称 |
| | | lang: 'zh', //设定表格语言 国际化设置,允许设置表格的语言,支持中文("zh")和英文("en") |
| | | allowEdit: true, //是否允许前台编辑 |
| | | sheetFormulaBar: true, //是否显示公式栏 |
| | | forceCalculation: true,//强制计算公式 |
| | | myFolderUrl: '' //左上角<返回按钮的链接 |
| | | } |
| | | |
| | | let checkDataFile = ""; |
| | | |
| | | if(getUrlParams('id') == false || getUrlParams('id') == undefined){ |
| | | //新增 |
| | | luckysheet.create(options) |
| | | $("#luckysheet_info_detail_update").hide() |
| | | $("#luckysheet_info_detail_save").hide() |
| | | $("#luckysheet_info_detail_title").hide() |
| | | }else{ |
| | | //修改 |
| | | $.ajax({ |
| | | type:"get", |
| | | url: baseUrl + "/reimburseOnline/viewCheck/" + getUrlParams('id') + "/auth", |
| | | dataType:"json", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | success:function(res) { |
| | | if (res.code == 200) { |
| | | checkDataFile = res.data.checkDataFile |
| | | options.data = unzip(res.data.checkData) |
| | | luckysheet.create(options) |
| | | $("#luckysheet_info_detail_update").hide() |
| | | $("#luckysheet_info_detail_save").hide() |
| | | $("#luckysheet_info_detail_title").hide() |
| | | }else { |
| | | layer.msg(res.msg,{time:1000}) |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | $("#export").on("click",() => { |
| | | console.log('export') |
| | | exportExcel(luckysheet.getluckysheetfile()).then((e) => { |
| | | saveFile(e,'file'); |
| | | }) |
| | | }) |
| | | |
| | | //保存到服务器 |
| | | $("#save").on("click",() => { |
| | | if(getUrlParams('id') == false || getUrlParams('id') == undefined){ |
| | | //新增 |
| | | $.ajax({ |
| | | url: baseUrl + "/reimburseOnline/add/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify({ |
| | | title: luckysheet.toJson().title, |
| | | sheetData: zip(luckysheet.getAllSheets()), |
| | | itemId: getUrlParams('item_id'), |
| | | priId: getUrlParams('pri_id') |
| | | }), |
| | | method: 'POST', |
| | | dataType: "json", |
| | | contentType:'application/json;charset=UTF-8', |
| | | success: function (res) { |
| | | if (res.code == 200) { |
| | | layer.msg('保存成功',{time:1000},() => { |
| | | parent.location.reload() |
| | | }) |
| | | }else{ |
| | | layer.msg(res.msg,{time:1000}) |
| | | } |
| | | } |
| | | }) |
| | | }else { |
| | | //修改 |
| | | $.ajax({ |
| | | url: baseUrl + "/reimburseOnline/update/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify({ |
| | | id: getUrlParams('id'), |
| | | title: luckysheet.toJson().title, |
| | | sheetData: zip(luckysheet.getAllSheets()) |
| | | }), |
| | | method: 'POST', |
| | | dataType: "json", |
| | | contentType:'application/json;charset=UTF-8', |
| | | success: function (res) { |
| | | if (res.code == 200) { |
| | | layer.msg('保存成功',{time:1000},() => { |
| | | parent.location.reload() |
| | | }) |
| | | }else{ |
| | | layer.msg(res.msg,{time:1000}) |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | $("#download").on("click",() => { |
| | | window.open(baseUrl + "/reimburseOnline/checkDataDownload/" +checkDataFile) |
| | | }) |
| | | |
| | | }) |
| | | |
| | | $("#allprint").on("click",() => { |
| | | printExcel() |
| | | }) |
| | | |
| | | $("#print").on("click",() => { |
| | | let src = luckysheet.getScreenshot(); // 生成base64图片 |
| | | const style = '@page {margin:0 10mm};' |
| | | printJS({ |
| | | printable: src, |
| | | type: 'image', |
| | | style: style |
| | | }) // Print.js插件 |
| | | }) |
| | | |
| | | // 获取表格中包含内容的row,column |
| | | function getExcelRowColumn() { |
| | | const sheetData = luckysheet.getSheetData(); |
| | | let objRowColumn = { |
| | | row: [null, null], //行 |
| | | column: [null, null], //列 |
| | | }; |
| | | sheetData.forEach((item, index) => { |
| | | //行数 |
| | | item.forEach((it, itemIndex) => { |
| | | if (it !== null) { |
| | | if (objRowColumn.row[0] == null) objRowColumn.row[0] = index; // row第一位 |
| | | objRowColumn.row[1] = index; //row第二位 |
| | | if (objRowColumn.column[0] == null) |
| | | objRowColumn.column[0] = itemIndex; //column第一位 |
| | | objRowColumn.column[1] = itemIndex; //column第二位 |
| | | } |
| | | }); |
| | | }); |
| | | return objRowColumn; |
| | | } |
| | | |
| | | function printExcel() { |
| | | let RowColumn = this.getExcelRowColumn() // 获取有值的行和列 |
| | | RowColumn.column[0] = 0 //因需要打印左边的边框,需重新设置 |
| | | luckysheet.setRangeShow(RowColumn) // 进行选区操作 |
| | | let src = luckysheet.getScreenshot(); // 生成base64图片 |
| | | const style = '@page {margin:0 10mm};' |
| | | printJS({ |
| | | printable: src, |
| | | type: 'image', |
| | | style: style |
| | | }) // Print.js插件 |
| | | } |
| | | |
| | | function getUrlParams(name) { |
| | | var url = window.location.search; |
| | | if (url.indexOf('?') == -1) { return false; } |
| | | url = url.substr(1); |
| | | url = url.split('&'); |
| | | var name = name || ''; |
| | | var nameres; |
| | | for (var i = 0; i < url.length; i++) { |
| | | var info = url[i].split('='); |
| | | var obj = {}; |
| | | obj[info[0]] = decodeURI(info[1]); |
| | | url[i] = obj; |
| | | } |
| | | if (name) { |
| | | for (var i = 0; i < url.length; i++) { |
| | | for (var key in url[i]) { |
| | | if (key == name) { |
| | | nameres = url[i][key]; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | nameres = url; |
| | | } |
| | | return nameres; |
| | | } |
| | | |
| | | // 压缩 |
| | | function zip(data) { |
| | | if (!data) return data |
| | | // 判断数据是否需要转为JSON |
| | | const dataJson = typeof data !== 'string' && typeof data !== 'number' ? JSON.stringify(data) : data |
| | | |
| | | // 使用Base64.encode处理字符编码,兼容中文 |
| | | const str = Base64.encode(dataJson) |
| | | let binaryString = pako.gzip(str); |
| | | let arr = Array.from(binaryString); |
| | | let s = ""; |
| | | arr.forEach((item, index) => { |
| | | s += String.fromCharCode(item) |
| | | }) |
| | | return btoa(s) |
| | | } |
| | | |
| | | // 解压 |
| | | function unzip(b64Data) { |
| | | let strData = atob(b64Data); |
| | | let charData = strData.split('').map(function (x) { |
| | | return x.charCodeAt(0); |
| | | }); |
| | | let binData = new Uint8Array(charData); |
| | | let data = pako.ungzip(binData); |
| | | |
| | | // ↓切片处理数据,防止内存溢出报错↓ |
| | | let str = ''; |
| | | const chunk = 8 * 1024 |
| | | let i; |
| | | for (i = 0; i < data.length / chunk; i++) { |
| | | str += String.fromCharCode.apply(null, data.slice(i * chunk, (i + 1) * chunk)); |
| | | } |
| | | str += String.fromCharCode.apply(null, data.slice(i * chunk)); |
| | | // ↑切片处理数据,防止内存溢出报错↑ |
| | | |
| | | const unzipStr = Base64.decode(str); |
| | | let result = '' |
| | | |
| | | // 对象或数组进行JSON转换 |
| | | try { |
| | | result = JSON.parse(unzipStr) |
| | | } catch (error) { |
| | | if (/Unexpected token o in JSON at position 0/.test(error)) { |
| | | // 如果没有转换成功,代表值为基本数据,直接赋值 |
| | | result = unzipStr |
| | | } |
| | | } |
| | | return result |
| | | } |
| | | </script> |
| | | </body> |
| | | </html> |
New file |
| | |
| | | <!DOCTYPE html> |
| | | <html> |
| | | <head> |
| | | <meta charset="utf-8"> |
| | | <title>excel</title> |
| | | <link rel="stylesheet" href="../../static/layui/css/layui.css" media="all"> |
| | | <link rel='stylesheet' href='../../static/plugins/css/pluginsCss.css' /> |
| | | <link rel='stylesheet' href='../../static/plugins/plugins.css' /> |
| | | <link rel='stylesheet' href='../../static/css/luckysheet.css' /> |
| | | <link rel='stylesheet' href='../../static/assets/iconfont/iconfont.css' /> |
| | | <script src="../../static/js/luckysheet_js/plugin.js"></script> |
| | | <script src="../../static/js/luckysheet_js/luckysheet.umd.js"></script> |
| | | <script src="../../static/js/luckysheet_js/luckyexcel.umd.js"></script> |
| | | <script src="../../static/js/luckysheet_js/exceljs.min.js"></script> |
| | | <script type="text/javascript" src="../../static/js/luckysheet_js/export.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/luckysheet_js/pako.es5.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/luckysheet_js/base64.min.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/luckysheet_js/print.min.js" charset="utf-8"></script> |
| | | </head> |
| | | <body> |
| | | <div style="display: flex;position: absolute;top: 20px;left:30px;z-index: 9999;"> |
| | | <!-- <div>上传Execel:<input type="file" id="Luckyexcel-demo-file" /></div>--> |
| | | <!-- <div><button type="button" id="export">导出Execel</button></div>--> |
| | | <div><button type="button" class="layui-btn layui-btn-primary layui-btn-xs btn-edit" id="save">保存</button></div> |
| | | <div><button type="button" class="layui-btn layui-btn-primary layui-btn-xs btn-edit" id="otherSave">另存为</button></div> |
| | | <div><button type="button" class="layui-btn layui-btn-primary layui-btn-xs btn-edit" id="allprint">全部打印</button></div> |
| | | <div><button type="button" class="layui-btn layui-btn-primary layui-btn-xs btn-edit" id="print">选区打印</button></div> |
| | | </div> |
| | | <div id="luckysheet" style="margin:0px;padding:0px;position:absolute;width:100%;height: 100vh;left: 0px;top: 0px;"></div> |
| | | <script> |
| | | $(function () { |
| | | var layer = layui.layer; |
| | | |
| | | //配置项 |
| | | var options = { |
| | | container: 'luckysheet' ,//luckysheet为容器id |
| | | title: '在线核价', //工作簿名称 |
| | | lang: 'zh', //设定表格语言 国际化设置,允许设置表格的语言,支持中文("zh")和英文("en") |
| | | allowEdit: true, //是否允许前台编辑 |
| | | sheetFormulaBar: true, //是否显示公式栏 |
| | | forceCalculation: true,//强制计算公式 |
| | | myFolderUrl: '' //左上角<返回按钮的链接 |
| | | } |
| | | |
| | | if(getUrlParams('id') == false || getUrlParams('id') == undefined){ |
| | | //新增 |
| | | if(getUrlParams('pri_id') == false || getUrlParams('pri_id') == undefined){ |
| | | luckysheet.create(options) |
| | | $("#luckysheet_info_detail_update").hide() |
| | | $("#luckysheet_info_detail_save").hide() |
| | | $("#luckysheet_info_detail_title").hide() |
| | | }else { |
| | | $.ajax({ |
| | | type:"get", |
| | | url: baseUrl + "/reimburse/" + getUrlParams('pri_id') + "/auth", |
| | | dataType:"json", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | success:function(res) { |
| | | options.data = unzip(res.data.sheetData) |
| | | options.title = res.data.title |
| | | luckysheet.create(options) |
| | | $("#luckysheet_info_detail_update").hide() |
| | | $("#luckysheet_info_detail_save").hide() |
| | | $("#luckysheet_info_detail_title").hide() |
| | | } |
| | | }); |
| | | } |
| | | }else{ |
| | | //修改 |
| | | $.ajax({ |
| | | type:"get", |
| | | url: baseUrl + "/reimburseOnline/" + getUrlParams('id') + "/auth", |
| | | dataType:"json", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | success:function(res) { |
| | | options.data = unzip(res.data.sheetData) |
| | | options.title = res.data.title |
| | | luckysheet.create(options) |
| | | $("#luckysheet_info_detail_update").hide() |
| | | $("#luckysheet_info_detail_save").hide() |
| | | $("#luckysheet_info_detail_title").hide() |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | $("#Luckyexcel-demo-file").on("change",(evt) => { |
| | | var files = evt.target.files; |
| | | if(files==null || files.length==0){ |
| | | alert("No files wait for import"); |
| | | return; |
| | | } |
| | | |
| | | let name = files[0].name; |
| | | let suffixArr = name.split("."), suffix = suffixArr[suffixArr.length-1]; |
| | | if(suffix!="xlsx"){ |
| | | alert("Currently only supports the import of xlsx files"); |
| | | return; |
| | | } |
| | | LuckyExcel.transformExcelToLucky(files[0], function(exportJson, luckysheetfile){ |
| | | |
| | | if(exportJson.sheets==null || exportJson.sheets.length==0){ |
| | | alert("Failed to read the content of the excel file, currently does not support xls files!"); |
| | | return; |
| | | } |
| | | window.luckysheet.destroy(); |
| | | |
| | | window.luckysheet.create({ |
| | | container: 'luckysheet', //luckysheet is the container id |
| | | data:exportJson.sheets, |
| | | title:exportJson.info.name, |
| | | userInfo:exportJson.info.name.creator, |
| | | lang: 'zh', //设定表格语言 国际化设置,允许设置表格的语言,支持中文("zh")和英文("en") |
| | | allowEdit: true, //是否允许前台编辑 |
| | | sheetFormulaBar: true, //是否显示公式栏 |
| | | forceCalculation: true,//强制计算公式 |
| | | }); |
| | | }); |
| | | }) |
| | | |
| | | $("#export").on("click",() => { |
| | | console.log('export') |
| | | exportExcel(luckysheet.getluckysheetfile()).then((e) => { |
| | | saveFile(e,'file'); |
| | | }) |
| | | }) |
| | | |
| | | //保存到服务器 |
| | | $("#save").on("click",() => { |
| | | if(getUrlParams('id') == false || getUrlParams('id') == undefined){ |
| | | //新增 |
| | | $.ajax({ |
| | | url: baseUrl + "/reimburseOnline/add/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify({ |
| | | title: luckysheet.toJson().title, |
| | | sheetData: zip(luckysheet.getAllSheets()), |
| | | itemId: getUrlParams('item_id'), |
| | | priId: getUrlParams('pri_id') |
| | | }), |
| | | method: 'POST', |
| | | dataType: "json", |
| | | contentType:'application/json;charset=UTF-8', |
| | | success: function (res) { |
| | | if (res.code == 200) { |
| | | layer.msg('保存成功',{time:1000},() => { |
| | | parent.location.reload() |
| | | }) |
| | | }else{ |
| | | layer.msg(res.msg,{time:1000}) |
| | | } |
| | | } |
| | | }) |
| | | }else { |
| | | //修改 |
| | | $.ajax({ |
| | | url: baseUrl + "/reimburseOnline/update/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify({ |
| | | id: getUrlParams('id'), |
| | | title: luckysheet.toJson().title, |
| | | sheetData: zip(luckysheet.getAllSheets()) |
| | | }), |
| | | method: 'POST', |
| | | dataType: "json", |
| | | contentType:'application/json;charset=UTF-8', |
| | | success: function (res) { |
| | | if (res.code == 200) { |
| | | layer.msg('保存成功',{time:1000},() => { |
| | | parent.location.reload() |
| | | }) |
| | | }else{ |
| | | layer.msg(res.msg,{time:1000}) |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | $("#otherSave").on("click",() => { |
| | | if(getUrlParams('id') == false || getUrlParams('id') == undefined){ |
| | | //新建文件 |
| | | $("#save").trigger("click") |
| | | }else { |
| | | //另存 |
| | | $.ajax({ |
| | | url: baseUrl + "/reimburseOnline/addOther/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify({ |
| | | id: getUrlParams('id'), |
| | | title: luckysheet.toJson().title, |
| | | sheetData: zip(luckysheet.getAllSheets()) |
| | | }), |
| | | method: 'POST', |
| | | dataType: "json", |
| | | contentType:'application/json;charset=UTF-8', |
| | | success: function (res) { |
| | | if (res.code == 200) { |
| | | layer.msg('另存成功',{time:1000},() => { |
| | | parent.location.reload() |
| | | }) |
| | | }else{ |
| | | layer.msg('保存失败',{time:1000}) |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | }) |
| | | |
| | | $("#allprint").on("click",() => { |
| | | printExcel() |
| | | }) |
| | | |
| | | $("#print").on("click",() => { |
| | | let src = luckysheet.getScreenshot(); // 生成base64图片 |
| | | const style = '@page {margin:0 10mm};' |
| | | printJS({ |
| | | printable: src, |
| | | type: 'image', |
| | | style: style |
| | | }) // Print.js插件 |
| | | }) |
| | | |
| | | // 获取表格中包含内容的row,column |
| | | function getExcelRowColumn() { |
| | | const sheetData = luckysheet.getSheetData(); |
| | | let objRowColumn = { |
| | | row: [null, null], //行 |
| | | column: [null, null], //列 |
| | | }; |
| | | sheetData.forEach((item, index) => { |
| | | //行数 |
| | | item.forEach((it, itemIndex) => { |
| | | if (it !== null) { |
| | | if (objRowColumn.row[0] == null) objRowColumn.row[0] = index; // row第一位 |
| | | objRowColumn.row[1] = index; //row第二位 |
| | | if (objRowColumn.column[0] == null) |
| | | objRowColumn.column[0] = itemIndex; //column第一位 |
| | | objRowColumn.column[1] = itemIndex; //column第二位 |
| | | } |
| | | }); |
| | | }); |
| | | return objRowColumn; |
| | | } |
| | | |
| | | function printExcel() { |
| | | let RowColumn = this.getExcelRowColumn() // 获取有值的行和列 |
| | | RowColumn.column[0] = 0 //因需要打印左边的边框,需重新设置 |
| | | luckysheet.setRangeShow(RowColumn) // 进行选区操作 |
| | | let src = luckysheet.getScreenshot(); // 生成base64图片 |
| | | const style = '@page {margin:0 10mm};' |
| | | printJS({ |
| | | printable: src, |
| | | type: 'image', |
| | | style: style |
| | | }) // Print.js插件 |
| | | } |
| | | |
| | | function getUrlParams(name) { |
| | | var url = window.location.search; |
| | | if (url.indexOf('?') == -1) { return false; } |
| | | url = url.substr(1); |
| | | url = url.split('&'); |
| | | var name = name || ''; |
| | | var nameres; |
| | | for (var i = 0; i < url.length; i++) { |
| | | var info = url[i].split('='); |
| | | var obj = {}; |
| | | obj[info[0]] = decodeURI(info[1]); |
| | | url[i] = obj; |
| | | } |
| | | if (name) { |
| | | for (var i = 0; i < url.length; i++) { |
| | | for (var key in url[i]) { |
| | | if (key == name) { |
| | | nameres = url[i][key]; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | nameres = url; |
| | | } |
| | | return nameres; |
| | | } |
| | | |
| | | // 压缩 |
| | | function zip(data) { |
| | | if (!data) return data |
| | | // 判断数据是否需要转为JSON |
| | | const dataJson = typeof data !== 'string' && typeof data !== 'number' ? JSON.stringify(data) : data |
| | | |
| | | // 使用Base64.encode处理字符编码,兼容中文 |
| | | const str = Base64.encode(dataJson) |
| | | let binaryString = pako.gzip(str); |
| | | let arr = Array.from(binaryString); |
| | | let s = ""; |
| | | arr.forEach((item, index) => { |
| | | s += String.fromCharCode(item) |
| | | }) |
| | | return btoa(s) |
| | | } |
| | | |
| | | // 解压 |
| | | function unzip(b64Data) { |
| | | let strData = atob(b64Data); |
| | | let charData = strData.split('').map(function (x) { |
| | | return x.charCodeAt(0); |
| | | }); |
| | | let binData = new Uint8Array(charData); |
| | | let data = pako.ungzip(binData); |
| | | |
| | | // ↓切片处理数据,防止内存溢出报错↓ |
| | | let str = ''; |
| | | const chunk = 8 * 1024 |
| | | let i; |
| | | for (i = 0; i < data.length / chunk; i++) { |
| | | str += String.fromCharCode.apply(null, data.slice(i * chunk, (i + 1) * chunk)); |
| | | } |
| | | str += String.fromCharCode.apply(null, data.slice(i * chunk)); |
| | | // ↑切片处理数据,防止内存溢出报错↑ |
| | | |
| | | const unzipStr = Base64.decode(str); |
| | | let result = '' |
| | | |
| | | // 对象或数组进行JSON转换 |
| | | try { |
| | | result = JSON.parse(unzipStr) |
| | | } catch (error) { |
| | | if (/Unexpected token o in JSON at position 0/.test(error)) { |
| | | // 如果没有转换成功,代表值为基本数据,直接赋值 |
| | | result = unzipStr |
| | | } |
| | | } |
| | | return result |
| | | } |
| | | </script> |
| | | </body> |
| | | </html> |