From 20484c10f1bcf7806dd78079f976b963572c3643 Mon Sep 17 00:00:00 2001
From: LSH
Date: 星期三, 16 八月 2023 14:39:45 +0800
Subject: [PATCH] #报销模板
---
src/main/java/com/zy/crm/manager/entity/Reimburse.java | 119 ++++
src/main/java/com/zy/crm/manager/controller/ReimburseController.java | 186 +++++++
src/main/java/com/zy/crm/manager/service/ReimburseService.java | 8
src/main/webapp/static/js/reimburse/reimburse.js | 376 +++++++++++++++
src/main/webapp/views/reimburse/reimburse.html | 98 ++++
src/main/webapp/views/reimburse/reimburse_use.html | 269 +++++++++++
src/main/java/com/zy/crm/manager/mapper/ReimburseMapper.java | 12
src/main/resources/mapper/ReimburseMapper.xml | 14
src/main/java/com/zy/crm/manager/entity/PriQuote.java | 6
src/main/webapp/views/reimburse/css/loading.gif | 0
src/main/webapp/views/reimburse/reimburse_template.html | 304 ++++++++++++
src/main/java/com/zy/crm/manager/service/impl/ReimburseServiceImpl.java | 12
12 files changed, 1,401 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/zy/crm/manager/controller/ReimburseController.java b/src/main/java/com/zy/crm/manager/controller/ReimburseController.java
new file mode 100644
index 0000000..371aa0d
--- /dev/null
+++ b/src/main/java/com/zy/crm/manager/controller/ReimburseController.java
@@ -0,0 +1,186 @@
+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.Reimburse;
+import com.zy.crm.manager.service.ReimburseService;
+import com.zy.crm.system.entity.User;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.*;
+
+@RestController
+public class ReimburseController extends BaseController {
+
+ @Autowired
+ private ReimburseService reimburseService;
+
+ @RequestMapping(value = "/reimburse/{id}/auth")
+ @ManagerAuth
+ public R get(@PathVariable("id") String id) {
+ return R.ok(reimburseService.selectById(String.valueOf(id)));
+ }
+
+ @RequestMapping(value = "/reimburse/getSheetData/{id}/auth")
+ @ManagerAuth
+ public String getSheetData(@PathVariable("id") String id) {
+ return reimburseService.selectById(String.valueOf(id)).getSheetData();
+ }
+
+ @RequestMapping(value = "/reimburse/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<Reimburse> wrapper = new EntityWrapper<>();
+ wrapper.setSqlSelect("id,title,create_time as createTime,filepath,user_id as userId,status,update_time as updateTime");
+ excludeTrash(param);
+ convert(param, wrapper);
+ allLike(Reimburse.class, param.keySet(), wrapper, condition);
+ if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
+ return R.ok(reimburseService.selectPage(new Page<>(curr, limit), wrapper));
+ }
+
+ private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){
+ 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 {
+ wrapper.like(entry.getKey(), val);
+ }
+ }
+ }
+
+ @RequestMapping(value = "/reimburse/add/auth")
+ @ManagerAuth
+ public R add(@RequestBody Map<String,Object> map) {
+ User user = getUser();
+ if(!user.getRoleCode().equals("boss") && !user.getDeptName().equals("鏍镐环缁�")){
+ return R.error("鏉冮檺涓嶈冻锛岀姝㈡柊澧炴ā鏉�");
+ }
+
+ Reimburse reimburse = new Reimburse();
+ reimburse.setTitle(map.get("title").toString());
+ reimburse.setSheetData(map.get("sheetData").toString());
+ reimburse.setCreateTime(new Date());
+ reimburse.setUpdateTime(new Date());
+ reimburse.setUserId(getUserId());
+ reimburse.setStatus(1);
+// if (!pri.getSheetData().isEmpty()) {
+// //淇濆瓨excel鏂囦欢
+// String filepath = ExcelUtils.saveExcelFile(pri.getTitle(), pri.getSheetData());
+// pri.setFilepath(filepath);
+// }
+ reimburseService.insert(reimburse);
+ return R.ok();
+ }
+
+ @RequestMapping(value = "/reimburse/update/auth")
+ @ManagerAuth
+ public R update(@RequestBody Map<String,Object> map){
+ User user = getUser();
+ if(!user.getRoleCode().equals("boss") && !user.getDeptName().equals("鏍镐环缁�")){
+ return R.error("鏉冮檺涓嶈冻锛岀姝㈡洿鏂版ā鏉�");
+ }
+
+ Reimburse reimburse = reimburseService.selectById(Long.parseLong(map.get("id").toString()));
+ reimburse.setTitle(map.get("title").toString());
+ reimburse.setSheetData(map.get("sheetData").toString());
+ reimburse.setUpdateTime(new Date());
+ reimburseService.updateById(reimburse);
+ return R.ok();
+ }
+
+ @RequestMapping(value = "/reimburse/updateStatus/auth")
+ @ManagerAuth
+ public R update(Long id,Integer status){
+ User user = getUser();
+ if(!user.getRoleCode().equals("boss") && !user.getDeptName().equals("鏍镐环缁�")){
+ return R.error("鏉冮檺涓嶈冻锛岀姝㈡洿鏂版ā鏉�");
+ }
+
+ Reimburse reimburse = reimburseService.selectById(id);
+ reimburse.setStatus(status);
+ reimburse.setUpdateTime(new Date());
+ reimburseService.updateById(reimburse);
+ return R.ok();
+ }
+
+ @RequestMapping(value = "/reimburse/delete/auth")
+ @ManagerAuth
+ public R delete(Long[] ids){
+ User user = getUser();
+ if(!user.getRoleCode().equals("boss") && !user.getDeptName().equals("鏍镐环缁�")){
+ return R.error("鏉冮檺涓嶈冻锛岀姝㈠垹闄ゆā鏉�");
+ }
+
+ if (Cools.isEmpty(ids)){
+ return R.error();
+ }
+ reimburseService.deleteBatchIds(Arrays.asList(ids));
+ return R.ok();
+ }
+
+ @RequestMapping(value = "/reimburse/export/auth")
+ @ManagerAuth
+ public R export(@RequestBody JSONObject param){
+ EntityWrapper<Reimburse> wrapper = new EntityWrapper<>();
+ List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class);
+ Map<String, Object> map = excludeTrash(param.getJSONObject("pri"));
+ convert(map, wrapper);
+ List<Reimburse> list = reimburseService.selectList(wrapper);
+ return R.ok(exportSupport(list, fields));
+ }
+
+ @RequestMapping(value = "/reimburseQuery/auth")
+ @ManagerAuth
+ public R query(String condition) {
+ EntityWrapper<Reimburse> wrapper = new EntityWrapper<>();
+ wrapper.like("id", condition);
+ Page<Reimburse> page = reimburseService.selectPage(new Page<>(0, 10), wrapper);
+ List<Map<String, Object>> result = new ArrayList<>();
+ for (Reimburse pri : page.getRecords()){
+ Map<String, Object> map = new HashMap<>();
+ map.put("id", pri.getId());
+ map.put("value", pri.getTitle());
+ result.add(map);
+ }
+ return R.ok(result);
+ }
+
+ @RequestMapping(value = "/reimburse/check/column/auth")
+ @ManagerAuth
+ public R query(@RequestBody JSONObject param) {
+ Wrapper<Reimburse> wrapper = new EntityWrapper<Reimburse>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val"));
+ if (null != reimburseService.selectOne(wrapper)){
+ return R.parse(BaseRes.REPEAT).add(getComment(Reimburse.class, String.valueOf(param.get("key"))));
+ }
+ return R.ok();
+ }
+
+ @RequestMapping("/reimburse/all/get/kv")
+ @ManagerAuth
+ public R getDataKV(@RequestParam(required = false) String condition) {
+ List<KeyValueVo> vos = new ArrayList<>();
+ Wrapper<Reimburse> wrapper = new EntityWrapper<Reimburse>().andNew().like("id", condition).orderBy("create_time", false);
+ reimburseService.selectPage(new Page<>(1, 30), wrapper).getRecords().forEach(item -> vos.add(new KeyValueVo(String.valueOf(item.getId()), item.getId())));
+ return R.ok().add(vos);
+ }
+
+}
diff --git a/src/main/java/com/zy/crm/manager/entity/PriQuote.java b/src/main/java/com/zy/crm/manager/entity/PriQuote.java
index 96515e0..66bff35 100644
--- a/src/main/java/com/zy/crm/manager/entity/PriQuote.java
+++ b/src/main/java/com/zy/crm/manager/entity/PriQuote.java
@@ -126,11 +126,11 @@
if (null == this.settle){ return null; }
switch (this.settle){
case 1:
- return "绛夊緟缁勯暱瀹℃牳";
- case 2:
return "绛夊緟閮ㄩ棬缁忕悊纭";
- case 3:
+ case 2:
return "绛夊緟鎬昏鍔炲鏍�";
+ case 3:
+ return "绛夊緟涓氬姟鍛樼‘璁�";
case 4:
return "瀹℃壒閫氳繃";
default:
diff --git a/src/main/java/com/zy/crm/manager/entity/Reimburse.java b/src/main/java/com/zy/crm/manager/entity/Reimburse.java
new file mode 100644
index 0000000..f573b96
--- /dev/null
+++ b/src/main/java/com/zy/crm/manager/entity/Reimburse.java
@@ -0,0 +1,119 @@
+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.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")
+public class Reimburse implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * ID
+ */
+ @ApiModelProperty(value= "ID")
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ /**
+ * 妯℃澘excel鐨剆heet鏁版嵁
+ */
+ @ApiModelProperty(value= "妯℃澘excel鐨剆heet鏁版嵁")
+ @TableField("sheet_data")
+ private String sheetData;
+
+ /**
+ * 妯℃澘excel鏍囬
+ */
+ @ApiModelProperty(value= "妯℃澘excel鏍囬")
+ private String title;
+
+ @ApiModelProperty(value= "鏂囦欢淇濆瓨鍦板潃")
+ private String filepath;
+
+ @ApiModelProperty(value= "鍒涘缓浜哄憳鐢ㄦ埛id")
+ @TableField("user_id")
+ private Long userId;
+
+ @ApiModelProperty(value= "鐘舵�亄0锛氱姝紝1锛氭甯竲")
+ @TableField("status")
+ private Integer status;
+
+ /**
+ * 鍒涘缓鏃堕棿
+ */
+ @ApiModelProperty(value= "鍒涘缓鏃堕棿")
+ @TableField("create_time")
+ @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+ private Date createTime;
+
+ @ApiModelProperty(value= "鏇存柊鏃堕棿")
+ @TableField("update_time")
+ @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+ private Date updateTime;
+
+ public Reimburse() {}
+
+ public Reimburse(String sheetData, String title, Date createTime, String filepath) {
+ this.sheetData = sheetData;
+ this.title = title;
+ this.createTime = createTime;
+ this.filepath = filepath;
+ }
+
+// Pri pri = new Pri(
+// null, // 妯℃澘excel鐨剆heet鏁版嵁[闈炵┖]
+// 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 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 getStatus$() {
+ if (null == this.status){ return null; }
+ switch (this.status){
+ case 1:
+ return "姝e父";
+ case 0:
+ return "绂佺敤";
+ default:
+ return String.valueOf(this.status);
+ }
+ }
+
+ public String getUpdateTime$(){
+ if (Cools.isEmpty(this.updateTime)){
+ return "";
+ }
+ return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.updateTime);
+ }
+
+}
diff --git a/src/main/java/com/zy/crm/manager/mapper/ReimburseMapper.java b/src/main/java/com/zy/crm/manager/mapper/ReimburseMapper.java
new file mode 100644
index 0000000..908ecc8
--- /dev/null
+++ b/src/main/java/com/zy/crm/manager/mapper/ReimburseMapper.java
@@ -0,0 +1,12 @@
+package com.zy.crm.manager.mapper;
+
+import com.baomidou.mybatisplus.mapper.BaseMapper;
+import com.zy.crm.manager.entity.Reimburse;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+@Mapper
+@Repository
+public interface ReimburseMapper extends BaseMapper<Reimburse> {
+
+}
diff --git a/src/main/java/com/zy/crm/manager/service/ReimburseService.java b/src/main/java/com/zy/crm/manager/service/ReimburseService.java
new file mode 100644
index 0000000..cc67e35
--- /dev/null
+++ b/src/main/java/com/zy/crm/manager/service/ReimburseService.java
@@ -0,0 +1,8 @@
+package com.zy.crm.manager.service;
+
+import com.baomidou.mybatisplus.service.IService;
+import com.zy.crm.manager.entity.Reimburse;
+
+public interface ReimburseService extends IService<Reimburse> {
+
+}
diff --git a/src/main/java/com/zy/crm/manager/service/impl/ReimburseServiceImpl.java b/src/main/java/com/zy/crm/manager/service/impl/ReimburseServiceImpl.java
new file mode 100644
index 0000000..dcdc67c
--- /dev/null
+++ b/src/main/java/com/zy/crm/manager/service/impl/ReimburseServiceImpl.java
@@ -0,0 +1,12 @@
+package com.zy.crm.manager.service.impl;
+
+import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.zy.crm.manager.entity.Reimburse;
+import com.zy.crm.manager.mapper.ReimburseMapper;
+import com.zy.crm.manager.service.ReimburseService;
+import org.springframework.stereotype.Service;
+
+@Service("reimburseService")
+public class ReimburseServiceImpl extends ServiceImpl<ReimburseMapper, Reimburse> implements ReimburseService {
+
+}
diff --git a/src/main/resources/mapper/ReimburseMapper.xml b/src/main/resources/mapper/ReimburseMapper.xml
new file mode 100644
index 0000000..50de23c
--- /dev/null
+++ b/src/main/resources/mapper/ReimburseMapper.xml
@@ -0,0 +1,14 @@
+<?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.ReimburseMapper">
+
+ <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 -->
+ <resultMap id="BaseResultMap" type="com.zy.crm.manager.entity.Reimburse">
+ <id column="id" property="id" />
+ <result column="sheet_data" property="sheetData" />
+ <result column="title" property="title" />
+ <result column="create_time" property="createTime" />
+
+ </resultMap>
+
+</mapper>
diff --git a/src/main/webapp/static/js/reimburse/reimburse.js b/src/main/webapp/static/js/reimburse/reimburse.js
new file mode 100644
index 0000000..d7f7d8c
--- /dev/null
+++ b/src/main/webapp/static/js/reimburse/reimburse.js
@@ -0,0 +1,376 @@
+var pageCurr;
+var admin;
+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 form = layui.form;
+ admin = layui.admin;
+
+ // 鏁版嵁娓叉煋
+ tableIns = table.render({
+ elem: '#reimburse',
+ headers: {token: localStorage.getItem('token')},
+ url: baseUrl+'/reimburse/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}
+ ,{field: 'title', align: 'center',title: '妯℃澘鍚�'}
+ ,{field: 'createTime$', align: 'center',title: '鍒涘缓鏃堕棿'}
+ ,{field: 'updateTime$', align: 'center',title: '鏇存柊鏃堕棿'}
+ ,{field: 'user$', align: 'center',title: '鍒涘缓浜哄憳'}
+ ,{field: 'status$', align: 'center',title: '鐘舵��'}
+ ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:220}
+ ]],
+ 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(reimburse)', 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(reimburse)', function (obj) {
+ var checkStatus = table.checkStatus(obj.config.id);
+ switch(obj.event) {
+ case 'addData':
+ layer.open({
+ type: 2,
+ title: '鏂板',
+ maxmin: true,
+ area: [top.detailWidth, top.detailHeight],
+ shadeClose: false,
+ content: 'reimburse_template.html',
+ success: function(layero, index){
+ // layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"});
+ }
+ });
+ 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+"/reimburse/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+"/reimburse/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(reimburse)', function(obj){
+ var data = obj.data;
+ switch (obj.event) {
+ // 缂栬緫
+ case 'edit':
+ layer.open({
+ type: 2,
+ title: '淇敼',
+ maxmin: true,
+ area: [top.detailWidth, top.detailHeight],
+ shadeClose: false,
+ content: 'reimburse_template.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 'use':
+ showEditModel(data.id,data.title);
+ break;
+ case 'status':
+ showEditStatus(data);
+ break;
+ case 'del':
+ layer.confirm('纭畾鍒犻櫎杩欐潯鏁版嵁鍚�', function(){
+ $.ajax({
+ url: baseUrl+"/reimburse/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;
+ }
+ });
+
+ //鏇存柊鐘舵��
+ function showEditStatus(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+"/reimburse/updateStatus/auth",
+ headers: {'token': localStorage.getItem('token')},
+ data: {
+ id: data.field.id,
+ status: data.field.status
+ },
+ 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');
+ }
+ });
+ }
+
+ /* 寮圭獥 - 鏂板銆佷慨鏀� */
+ function showEditModel(id,title) {
+ admin.open({
+ type: 1,
+ area: '800px',
+ title: '浣跨敤鏍镐环妯℃澘',
+ content: $('#editDialog').html(),
+ success: function (layero, dIndex) {
+ 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: 'reimburse_use.html?id=' + id + '&item_id=' + data.field.itemId + "&title=" + title,
+ success: function(layero, 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');
+ }
+ });
+ }
+
+});
+
+// 鍏抽棴鍔ㄤ綔
+$(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();
+ }
+});
diff --git a/src/main/webapp/views/reimburse/css/loading.gif b/src/main/webapp/views/reimburse/css/loading.gif
new file mode 100644
index 0000000..7980d81
--- /dev/null
+++ b/src/main/webapp/views/reimburse/css/loading.gif
Binary files differ
diff --git a/src/main/webapp/views/reimburse/reimburse.html b/src/main/webapp/views/reimburse/reimburse.html
new file mode 100644
index 0000000..4986fed
--- /dev/null
+++ b/src/main/webapp/views/reimburse/reimburse.html
@@ -0,0 +1,98 @@
+<!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">
+</head>
+<body>
+
+<div class="layui-fluid">
+ <div class="layui-card">
+ <div class="layui-card-body">
+
+ <table class="layui-hide" id="reimburse" lay-filter="reimburse"></table>
+ </div>
+ </div>
+</div>
+
+<script type="text/html" id="toolbar">
+ <div class="layui-btn-container">
+ <button class="layui-btn layui-btn-sm" lay-event="addData">鏂板</button>
+ <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="deleteData">鍒犻櫎</button>
+ </div>
+</script>
+
+<script type="text/html" id="operate">
+ <a class="layui-btn layui-btn-xs btn-edit" lay-event="edit">妯℃澘</a>
+ <a class="layui-btn layui-btn-primary layui-btn-xs btn-edit" lay-event="use">浣跨敤</a>
+ <a class="layui-btn layui-btn-primary layui-btn-xs btn-edit" lay-event="status">鐘舵��</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/reimburse/reimburse.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="itemId" placeholder="璇疯緭鍏ラ」鐩悕" style="display: none" lay-verify="required">
+ <input id="itemId$" name="itemId$" 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="itemQueryBydirector" onkeyup="autoLoad(this.getAttribute('data-key'))">
+ <select class="cool-auto-complete-window-select" data-key="itemQueryBydirectorSelect" 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">姝e父</option>
+ <option value="0">绂佹</option>
+ </select>
+ </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>
+
diff --git a/src/main/webapp/views/reimburse/reimburse_template.html b/src/main/webapp/views/reimburse/reimburse_template.html
new file mode 100644
index 0000000..73a6f98
--- /dev/null
+++ b/src/main/webapp/views/reimburse/reimburse_template.html
@@ -0,0 +1,304 @@
+<!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>
+ <input type="file" style="display: none;" id="uploadFile">
+ <button type="button" class="layui-btn layui-btn-xs" id="upload-button">
+ <i class="layui-icon"></i>涓婁紶妯℃澘
+ </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="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涓哄鍣╥d
+ title: '鏍镐环妯℃澘', //宸ヤ綔绨垮悕绉�
+ lang: 'zh', //璁惧畾琛ㄦ牸璇█ 鍥介檯鍖栬缃紝鍏佽璁剧疆琛ㄦ牸鐨勮瑷�锛屾敮鎸佷腑鏂�("zh")鍜岃嫳鏂�("en")
+ allowEdit: true, //鏄惁鍏佽鍓嶅彴缂栬緫
+ sheetFormulaBar: true, //鏄惁鏄剧ず鍏紡鏍�
+ forceCalculation: true,//寮哄埗璁$畻鍏紡
+ myFolderUrl: '' //宸︿笂瑙�<杩斿洖鎸夐挳鐨勯摼鎺�
+ }
+
+ if(getUrlParams('id') == false){
+ //鏂板
+ 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('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()
+ }
+ });
+
+ }
+
+ //鐐瑰嚮涓婁紶
+ $("#upload-button").on("click",() => {
+ $("#uploadFile").click()
+ })
+
+ //鍝嶅簲涓婁紶
+ $("#uploadFile").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",async () => {
+ if (getUrlParams('id') == false) {
+ //鏂板
+ $.ajax({
+ url: baseUrl + "/reimburse/add/auth",
+ headers: {'token': localStorage.getItem('token')},
+ data: JSON.stringify({
+ 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})
+ }
+ }
+ });
+ } else {
+ //淇敼
+ $.ajax({
+ url: baseUrl + "/reimburse/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})
+ }
+ }
+ })
+ }
+ })
+
+ })
+
+ $("#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锛宑olumn
+ 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
+ // 鍒ゆ柇鏁版嵁鏄惁闇�瑕佽浆涓篔SON
+ 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)
+ }
+
+ // 瑙e帇
+ 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 = ''
+
+ // 瀵硅薄鎴栨暟缁勮繘琛孞SON杞崲
+ 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>
\ No newline at end of file
diff --git a/src/main/webapp/views/reimburse/reimburse_use.html b/src/main/webapp/views/reimburse/reimburse_use.html
new file mode 100644
index 0000000..98e247d
--- /dev/null
+++ b/src/main/webapp/views/reimburse/reimburse_use.html
@@ -0,0 +1,269 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>execel</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="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涓哄鍣╥d
+ title: 'Excel琛ㄦ牸DEMO', //宸ヤ綔绨垮悕绉�
+ lang: 'zh', //璁惧畾琛ㄦ牸璇█ 鍥介檯鍖栬缃紝鍏佽璁剧疆琛ㄦ牸鐨勮瑷�锛屾敮鎸佷腑鏂�("zh")鍜岃嫳鏂�("en")
+ allowEdit: true, //鏄惁鍏佽鍓嶅彴缂栬緫
+ sheetFormulaBar: true, //鏄惁鏄剧ず鍏紡鏍�
+ forceCalculation: true,//寮哄埗璁$畻鍏紡
+ myFolderUrl: '' //宸︿笂瑙�<杩斿洖鎸夐挳鐨勯摼鎺�
+ }
+
+ 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 + "/reimburse/" + 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",() => {
+ //闇�瑕佸帇缂╂暟鎹啀涓婁紶
+ $.ajax({
+ url: baseUrl + "/reimburseOnline/add/auth",
+ headers: {'token': localStorage.getItem('token')},
+ data: JSON.stringify({
+ title: getUrlParams('title'),
+ sheetData: zip(luckysheet.getAllSheets()),
+ itemId: getUrlParams('item_id'),
+ priId: getUrlParams('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})
+ }
+ }
+ })
+ })
+
+ })
+
+ $("#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锛宑olumn
+ 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
+ // 鍒ゆ柇鏁版嵁鏄惁闇�瑕佽浆涓篔SON
+ 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)
+ }
+
+ // 瑙e帇
+ 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 = ''
+
+ // 瀵硅薄鎴栨暟缁勮繘琛孞SON杞崲
+ 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>
\ No newline at end of file
--
Gitblit v1.9.1