自动化立体仓库 - WMS系统
skyouc
3 天以前 85b89465f4de41f9a7fea136f2f0897b1da790fa
新增订单excel导入功能
2个文件已添加
5个文件已修改
944 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/OrderController.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/entity/OrderDetl.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/utils/OrderExcelListener.java 127 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/entity/OrderExcel.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/common.js 252 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/order/order.js 310 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/order/order.html 178 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/OrderController.java
@@ -1,5 +1,7 @@
package com.zy.asrs.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
@@ -12,14 +14,23 @@
import com.zy.asrs.entity.result.WrkTraceVo;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.MatExcelListener;
import com.zy.asrs.utils.OrderExcelListener;
import com.zy.common.entity.MatExcel;
import com.zy.common.entity.OrderExcel;
import com.zy.common.model.DetlDto;
import com.zy.common.web.BaseController;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.*;
import javax.servlet.http.HttpServletResponse;
@RestController
public class OrderController extends BaseController {
@@ -357,6 +368,41 @@
        }
    }
    /**
     * excel导入模板下载
     */
    @RequestMapping(value = "/orders/excel/import/mould")
    public void matExcelImportMould(HttpServletResponse response) throws IOException {
        List<OrderExcel> excels = new ArrayList<>();
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        String fileName = URLEncoder.encode("单据Excel导入模板", "UTF-8");
        response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
        EasyExcel.write(response.getOutputStream(), OrderExcel.class)
                .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                .sheet("sheet1")
                .doWrite(excels);
    }
    /**
     * 单据导入
     * @author Ryan
     * @date 2026/1/8 17:17
     * @param file
     * @return com.core.common.R
     */
    @PostMapping(value = "/orders/excel/import/auth")
    @ManagerAuth(memo = "单据导入")
    @Transactional
    public R matExcelImport(MultipartFile file) throws IOException {
        OrderExcelListener listener = new OrderExcelListener(getUserId());
        EasyExcel.read(file.getInputStream(), OrderExcel.class, listener).sheet().doRead();
        return R.ok("成功同步" + listener.getTotal() + "条商品数据");
    }
    @RequestMapping(value = "/order/update/auth")
    @ManagerAuth
    public R update(Order order){
src/main/java/com/zy/asrs/entity/OrderDetl.java
@@ -1,5 +1,6 @@
package com.zy.asrs.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
@@ -48,6 +49,7 @@
     * 单据编号
     */
    @ApiModelProperty(value= "单据编号")
    @ExcelProperty(index = 0, value = "单号")
    @TableField("order_no")
    private String orderNo;
@@ -56,6 +58,7 @@
     * 数量
     */
    @ApiModelProperty(value= "数量")
    @ExcelProperty(value = "数量")
    private Double anfme;
    /**
@@ -81,30 +84,35 @@
     * 商品编码
     */
    @ApiModelProperty(value= "商品编码")
    @ExcelProperty(value = "商品编码")
    private String matnr;
    /**
     * 商品名称
     */
    @ApiModelProperty(value= "商品名称")
    @ExcelProperty(value = "商品名称")
    private String maktx;
    /**
     * 批号
     */
    @ApiModelProperty(value= "批号")
    @ExcelProperty(value = "批号")
    private String batch;
    /**
     * 规格
     */
    @ApiModelProperty(value= "规格")
    @ExcelProperty(value = "规格")
    private String specs;
    /**
     * 型号
     */
    @ApiModelProperty(value= "型号")
    @ExcelProperty(value = "型号")
    private String model;
    /**
@@ -117,12 +125,14 @@
     * 品牌
     */
    @ApiModelProperty(value= "品牌")
    @ExcelProperty(value = "品牌")
    private String brand;
    /**
     * 单位
     */
    @ApiModelProperty(value= "单位")
    @ExcelProperty(value = "单位")
    private String unit;
    /**
@@ -147,6 +157,7 @@
     * 条码
     */
    @ApiModelProperty(value= "条码")
    @ExcelProperty(value = "SN码")
    private String barcode;
    /**
@@ -180,6 +191,7 @@
     */
    @ApiModelProperty(value= "安全库存量")
    @TableField("safe_qty")
    @ExcelProperty(value = "归零阀值")
    private Double safeQty;
    /**
@@ -199,6 +211,7 @@
     * 体积
     */
    @ApiModelProperty(value= "体积")
    @ExcelProperty(value = "km/cm")
    private Double volume;
    /**
src/main/java/com/zy/asrs/utils/OrderExcelListener.java
New file
@@ -0,0 +1,127 @@
package com.zy.asrs.utils;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.SpringUtils;
import com.core.exception.CoolException;
import com.zy.asrs.entity.DocType;
import com.zy.asrs.entity.Mat;
import com.zy.asrs.entity.Order;
import com.zy.asrs.entity.OrderDetl;
import com.zy.asrs.service.DocTypeService;
import com.zy.asrs.service.MatService;
import com.zy.asrs.service.OrderDetlService;
import com.zy.asrs.service.OrderService;
import com.zy.common.entity.OrderExcel;
import lombok.extern.slf4j.Slf4j;
import java.util.*;
import org.springframework.transaction.annotation.Transactional;
@Slf4j
public class OrderExcelListener  extends AnalysisEventListener<OrderExcel> {
    private int total = 0;
    private Long userId;
    public OrderExcelListener(Long userId) {
        this.userId = userId;
    }
    /**
     * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收
     */
    private static final int BATCH_COUNT = 50;
    private final List<OrderExcel> list = new ArrayList<>();
    /**
     * 这里会一行行的返回头
     */
    @Override
    public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
    }
    /**
     * 单据导入实现
     * @author Ryan
     * @date 2026/1/8 17:25
     * @param data
     * @param context
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void invoke(OrderExcel data, AnalysisContext context) {
        OrderService orderService = (OrderService) SpringUtils.getBean(OrderService.class);
        OrderDetlService detlService = (OrderDetlService) SpringUtils.getBean(OrderDetlService.class);
        MatService matService = SpringUtils.getBean(MatService.class);
        DocTypeService docTypeService = SpringUtils.getBean(DocTypeService.class);
        Date now = new Date();
        if (Objects.isNull(data)) {
            throw new CoolException("参数不能为空!!");
        }
        if (Objects.isNull(data.getOrderNo())) {
            throw new CoolException("订单已创建,不可以重复创建!!");
        }
        if (Objects.isNull(data.getDocType())) {
            throw new CoolException("单据类型不能为空!");
        }
        DocType docType = docTypeService.selectOne(new EntityWrapper<DocType>().eq("doc_name", data.getDocType()));
        if (Objects.isNull(docType)) {
            throw new CoolException("单据类型[" + data.getDocType() + "]不存在!!");
        }
        Order order = new Order();
        order.setOrderNo(data.getOrderNo());
        order.setDocType(docType.getDocId());
        order.setCreateTime(now);
        order.setUpdateTime(now);
        order.setSettle(1L);
        order.setStatus(1);
        order.setCreateBy(userId);
        order.setUpdateBy(userId);
        order.setPakinPakoutStatus(docType.getPakin() == 1 ? 1 : 2);
        if (!orderService.insert(order)) {
            throw new CoolException("订单创建失败!!");
        }
        if (Objects.isNull(data.getMatnr())) {
            throw new CoolException("物料编码不能为空!");
        }
        Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", data.getMatnr()));
        if (Objects.isNull(mat)) {
            throw new CoolException("物料[" + data.getMatnr() + "]不存在!!");
        }
        OrderDetl detl = new OrderDetl();
        detl.setOrderNo(data.getOrderNo());
        detl.setOrderId(order.getId());
        detl.setMatnr(data.getMatnr());
        detl.setMaktx(mat.getMaktx());
        detl.setQty(data.getQty());
        detl.setBatch(data.getBatch());
        detl.setVolume(data.getVolume());
        detl.setSafeQty(mat.getSafeQty());
        detl.setAnfme(data.getAnfme());
        detl.setBarcode(data.getBarcode());
        detl.setUpdateTime(now);
        detl.setCreateTime(now);
        detl.setUpdateBy(userId);
        detl.setCreateBy(userId);
        if (!detlService.insert(detl)) {
            throw new CoolException("订单详情创建失败!!");
        }
    }
    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
        log.info("新增{}条物料信息!", total);
    }
    public int getTotal() {
        return total;
    }
}
src/main/java/com/zy/common/entity/OrderExcel.java
New file
@@ -0,0 +1,18 @@
package com.zy.common.entity;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.zy.asrs.entity.OrderDetl;
import lombok.Data;
@Data
@ExcelIgnoreUnannotated
public class OrderExcel extends OrderDetl {
    @ExcelProperty(index = 1, value = "单据类型")
    private String docType;
}
src/main/webapp/static/js/common.js
@@ -6,7 +6,7 @@
var detailWidth = '90%';
// 非空判断
function isEmpty(obj){
function isEmpty(obj) {
    return typeof obj == "undefined" || obj == null || obj === "";
}
@@ -34,7 +34,7 @@
        if (p < 10) {
            p = "00" + p;
        }
        if (p <  100) {
        if (p < 100) {
            p = "0" + p;
        }
        return y + "-" + M + "-" + d + " " + h + ":" + m + ":" + s + "," + p;
@@ -54,7 +54,7 @@
// 清理对象null值
function reObject(data) {
    for (var obj in data) {
        if (data[obj]===null){
        if (data[obj] === null) {
            delete data[obj];
        }
    }
@@ -71,26 +71,26 @@
}
// 权限
function limit(child){
    if (child == null){
function limit(child) {
    if (child == null) {
        child = false;
    }
    var param = (child?parent.window:window).location.href.split("?")[1];
    var param = (child ? parent.window : window).location.href.split("?")[1];
    if (null != param) {
        var resourceId = param.split("=")[1];
        $.ajax({
            url: baseUrl+"/power/menu/"+resourceId+"/auth",
            headers: {'token': localStorage.getItem('token')},
            url: baseUrl + "/power/menu/" + resourceId + "/auth",
            headers: { 'token': localStorage.getItem('token') },
            method: 'GET',
            async: false,
            success: function (res) {
                if (res.code === 200){
                    for(var i = 0, len = res.data.length; i < len; i++) {
                        (child?parent:window).$('#'+res.data[i].code).css("display", "inline-block");
                        (child?parent:window).$('.'+res.data[i].code).css("display", "inline-block");
                if (res.code === 200) {
                    for (var i = 0, len = res.data.length; i < len; i++) {
                        (child ? parent : window).$('#' + res.data[i].code).css("display", "inline-block");
                        (child ? parent : window).$('.' + res.data[i].code).css("display", "inline-block");
                    }
                } else if (res.code === 403){
                    top.location.href = baseUrl+"/";
                } else if (res.code === 403) {
                    top.location.href = baseUrl + "/";
                } else {
                    layer.msg(res.msg)
                }
@@ -113,15 +113,15 @@
                url: url,
                data: data,
                dataType: 'json',
                header: {'token': localStorage.getItem('token')},
                header: { 'token': localStorage.getItem('token') },
                timeout: 10000,
                cache: false,
                success: function (res) {
                    if (res.code === 200){
                    if (res.code === 200) {
                        callback(res);
                    } else if (res.code === 403){
                        top.location.href = baseUrl+"/";
                    }  else {
                    } else if (res.code === 403) {
                        top.location.href = baseUrl + "/";
                    } else {
                        layer.msg(res.msg);
                    }
                },
@@ -134,9 +134,9 @@
        post: function (url, param, callback, type) {
            var headerType;
            if (type === 'json') {
                headerType = {'Content-Type': 'application/json'}
                headerType = { 'Content-Type': 'application/json' }
            } else {
                headerType = {'Content-Type': 'application/x-www-form-urlencoded'}
                headerType = { 'Content-Type': 'application/x-www-form-urlencoded' }
            }
            headerType['token'] = localStorage.getItem('token');
            http.toAjax({
@@ -148,11 +148,11 @@
                timeout: 10000,
                cache: false,
                success: function (res) {
                    if (res.code === 200){
                    if (res.code === 200) {
                        callback(res);
                    } else if (res.code === 403){
                        top.location.href = baseUrl+"/";
                    }  else {
                    } else if (res.code === 403) {
                        top.location.href = baseUrl + "/";
                    } else {
                        layer.msg(res.msg);
                    }
                },
@@ -172,126 +172,144 @@
/*************************************************************************************************************/
function arrRemove(arr, key, val) {
    for(var i=arr.length-1; i>=0; i--){
        if(arr[i][key] === val){
            arr.splice(i,1);
    for (var i = arr.length - 1; i >= 0; i--) {
        if (arr[i][key] === val) {
            arr.splice(i, 1);
        }
    }
}
var matCols = [
    {field: 'matnr', align: 'center',title: '商品编号(品号)', width: 180}
    { field: 'matnr', align: 'center', title: '商品编号(品号)', width: 180 }
    // {field: 'id', align: 'center',title: 'ID'}
    // ,{field: 'uuid', align: 'center',title: '编号'}
    ,{field: 'maktx', align: 'center',title: '商品名称(品名)', width: 200}
    ,{field: 'specs', align: 'center',title: '规格'}
    ,{field: 'safeQty', align: 'center',title: '归零阀值'}
    ,{field: 'model', align: 'center',title: '代码', hide: true}
    ,{field: 'color', align: 'center',title: '颜色', hide: true}
    ,{field: 'brand', align: 'center',title: '品牌', hide: true}
    ,{field: 'upQty', align: 'center',title: '组托上限', hide: true}
    ,{field: 'unit', align: 'center',title: '单位', hide: false}
    ,{field: 'price', align: 'center',title: '单价', hide: true}
    ,{field: 'sku', align: 'center',title: 'sku', hide: true}
    ,{field: 'units', align: 'center',title: '单位量', hide: true}
    ,{field: 'barcode', align: 'center',title: '条码', hide: true}
    ,{field: 'origin', align: 'center',title: '产地', hide: true}
    ,{field: 'manu', align: 'center',title: '厂家', hide: true}
    ,{field: 'manuDate', align: 'center',title: '生产日期', hide: true}
    ,{field: 'itemNum', align: 'center',title: '品项数', hide: true}
    ,{field: 'weight', align: 'center',title: '单箱净重', hide: true}
    ,{field: 'length', align: 'center',title: '单箱毛重', hide: true}
    ,{field: 'volume', align: 'center',title: '单箱体积', hide: true}
    ,{field: 'threeCode', align: 'center',title: '箱子尺寸', hide: true}
    ,{field: 'supp', align: 'center',title: '供应商', hide: true}
    ,{field: 'suppCode', align: 'center',title: '供应商编码', hide: true}
    ,{field: 'beBatch$', align: 'center',title: '是否批次', hide: true}
    ,{field: 'deadTime', align: 'center',title: '保质期', hide: true}
    ,{field: 'deadWarn', align: 'center',title: '预警天数', hide: true}
    ,{field: 'source$', align: 'center',title: '制购', hide: true}
    ,{field: 'check$', align: 'center',title: '要求检验', hide: true}
    ,{field: 'danger$', align: 'center',title: '危险品', hide: true}
    , { field: 'maktx', align: 'center', title: '商品名称(品名)', width: 200 }
    , { field: 'specs', align: 'center', title: '规格' }
    , { field: 'safeQty', align: 'center', title: '归零阀值' , templet: function (d) {
            var raw = d.safeQty;
            if (raw === null || raw === undefined) return '';
            if (typeof raw === 'string' && raw.trim() === '') return '';
            var num = Number(raw);
            if (!isFinite(num)) return '';
            return num.toFixed(2);
        }}
    , { field: 'model', align: 'center', title: '代码', hide: true }
    , { field: 'color', align: 'center', title: '颜色', hide: true }
    , { field: 'brand', align: 'center', title: '品牌', hide: true }
    , { field: 'upQty', align: 'center', title: '组托上限', hide: true }
    , { field: 'unit', align: 'center', title: '单位', hide: false }
    , { field: 'price', align: 'center', title: '单价', hide: true }
    , { field: 'sku', align: 'center', title: 'sku', hide: true }
    , { field: 'units', align: 'center', title: '单位量', hide: true }
    , { field: 'barcode', align: 'center', title: '条码', hide: true }
    , { field: 'origin', align: 'center', title: '产地', hide: true }
    , { field: 'manu', align: 'center', title: '厂家', hide: true }
    , { field: 'manuDate', align: 'center', title: '生产日期', hide: true }
    , { field: 'itemNum', align: 'center', title: '品项数', hide: true }
    , { field: 'weight', align: 'center', title: '单箱净重', hide: true }
    , { field: 'length', align: 'center', title: '单箱毛重', hide: true }
    , {
        field: 'volume', align: 'center', title: 'kg/cm', templet: function (d) {
            var raw = d.volume;
            if (raw === null || raw === undefined) return '';
            if (typeof raw === 'string' && raw.trim() === '') return '';
            var num = Number(raw);
            if (!isFinite(num)) return '';
            return num.toFixed(2);
        }
    }
    , { field: 'threeCode', align: 'center', title: '箱子尺寸', hide: true }
    , { field: 'supp', align: 'center', title: '供应商', hide: true }
    , { field: 'suppCode', align: 'center', title: '供应商编码', hide: true }
    , { field: 'beBatch$', align: 'center', title: '是否批次', hide: true }
    , { field: 'deadTime', align: 'center', title: '保质期', hide: true }
    , { field: 'deadWarn', align: 'center', title: '预警天数', hide: true }
    , { field: 'source$', align: 'center', title: '制购', hide: true }
    , { field: 'check$', align: 'center', title: '要求检验', hide: true }
    , { field: 'danger$', align: 'center', title: '危险品', hide: true }
    // ,{field: 'status$', align: 'center',title: '状态'}
    // ,{field: 'createBy$', align: 'center',title: '添加人员'}
    // ,{field: 'createTime$', align: 'center',title: '添加时间'}
    ,{field: 'updateBy$', align: 'center',title: '修改人员', hide: true}
    ,{field: 'updateTime$', align: 'center',title: '修改时间', hide: true}
    ,{field: 'memo', align: 'center',title: '备注', hide: true}
    , { field: 'updateBy$', align: 'center', title: '修改人员', hide: true }
    , { field: 'updateTime$', align: 'center', title: '修改时间', hide: true }
    , { field: 'memo', align: 'center', title: '备注', hide: true }
]
var cacheCols = [
    {field: 'matnr', align: 'center',title: '商品编号(品号)', sort:true}
    ,{field: 'maktx', align: 'center',title: '商品名称(品名)', sort:true}
    ,{field: 'anfme', align: 'center',title: '数量', hide: false}
    ,{field: 'specs', align: 'center',title: '规格', hide: false}
    ,{field: 'model', align: 'center',title: '代码', hide: true}
    ,{field: 'color', align: 'center',title: '颜色', hide: true}
    ,{field: 'brand', align: 'center',title: '品牌', hide: true}
    ,{field: 'unit', align: 'center',title: '单位', hide: false}
    ,{field: 'batch', align: 'center',title: '货品特征', sort:true}
    ,{field: 'frozen$', align: 'center',title: '冻结否',hide: true,
        templet: function(d) {
    { field: 'matnr', align: 'center', title: '商品编号(品号)', sort: true }
    , { field: 'maktx', align: 'center', title: '商品名称(品名)', sort: true }
    , { field: 'anfme', align: 'center', title: '数量', hide: false }
    , { field: 'specs', align: 'center', title: '规格', hide: false }
    , { field: 'model', align: 'center', title: '代码', hide: true }
    , { field: 'color', align: 'center', title: '颜色', hide: true }
    , { field: 'brand', align: 'center', title: '品牌', hide: true }
    , { field: 'unit', align: 'center', title: '单位', hide: false }
    , { field: 'batch', align: 'center', title: '货品特征', sort: true }
    , {
        field: 'frozen$', align: 'center', title: '冻结否', hide: true,
        templet: function (d) {
            // 根据条件判断字体颜色
            if (d.frozen$ === '已冻结') {
                return '<span style="color: #34a8de;">' +d.frozen$ + '</span>';
                return '<span style="color: #34a8de;">' + d.frozen$ + '</span>';
            } else {
                return '<span">' +d.frozen$ + '</span>';
                return '<span">' + d.frozen$ + '</span>';
            }
        }}
        }
    }
]
var detlCols = [
    {field: 'matnr', align: 'center',title: '商品编号(品号)', sort:true}
    ,{field: 'maktx', align: 'center',title: '商品名称(品名)', sort:true}
    ,{field: 'orderNo', align: 'center',title: '单据编号', hide: false}
    ,{field: 'batch', align: 'center',title: '货品特征', sort:true}
    ,{field: 'anfme', align: 'center',title: '数量', hide: false}
    ,{field: 'zpallet', align: 'center',title: '托盘条码', hide: false}
    ,{field: 'specs', align: 'center',title: '规格', hide: false}
    ,{field: 'model', align: 'center',title: '代码', hide: true}
    ,{field: 'color', align: 'center',title: '颜色', hide: true}
    ,{field: 'brand', align: 'center',title: '品牌', hide: true}
    ,{field: 'unit', align: 'center',title: '单位', hide: false}
    ,{field: 'price', align: 'center',title: '单价', hide: true}
    ,{field: 'sku', align: 'center',title: 'sku', hide: true}
    ,{field: 'units', align: 'center',title: '单位量', hide: true}
    ,{field: 'barcode', align: 'center',title: '条码', hide: true}
    ,{field: 'origin', align: 'center',title: '产地', hide: true}
    ,{field: 'manu', align: 'center',title: '厂家', hide: true}
    ,{field: 'manuDate', align: 'center',title: '生产日期', hide: true}
    ,{field: 'itemNum', align: 'center',title: '品项数', hide: true}
    ,{field: 'safeQty', align: 'center',title: '安全库存量', hide: true}
    ,{field: 'weight', align: 'center',title: '单箱净重', hide: true}
    ,{field: 'length', align: 'center',title: '单箱毛重', hide: true}
    ,{field: 'volume', align: 'center',title: '单箱体积', hide: true}
    ,{field: 'threeCode', align: 'center',title: '箱子尺寸', hide: true}
    ,{field: 'supp', align: 'center',title: '供应商', hide: true}
    ,{field: 'suppCode', align: 'center',title: '供应商编码', hide: true}
    ,{field: 'beBatch$', align: 'center',title: '是否批次', hide: true}
    ,{field: 'deadTime', align: 'center',title: '保质期', hide: true}
    ,{field: 'deadWarn', align: 'center',title: '预警天数', hide: true}
    ,{field: 'source$', align: 'center',title: '制购', hide: true}
    ,{field: 'check$', align: 'center',title: '要求检验', hide: true}
    ,{field: 'danger$', align: 'center',title: '危险品', hide: true}
    ,{field: 'frozen$', align: 'center',title: '冻结否',hide: true,
        templet: function(d) {
    { field: 'matnr', align: 'center', title: '商品编号(品号)', sort: true }
    , { field: 'maktx', align: 'center', title: '商品名称(品名)', sort: true }
    , { field: 'orderNo', align: 'center', title: '单据编号', hide: false }
    , { field: 'batch', align: 'center', title: '货品特征', sort: true }
    , { field: 'anfme', align: 'center', title: '数量', hide: false }
    , { field: 'zpallet', align: 'center', title: '托盘条码', hide: false }
    , { field: 'specs', align: 'center', title: '规格', hide: false }
    , { field: 'model', align: 'center', title: '代码', hide: true }
    , { field: 'color', align: 'center', title: '颜色', hide: true }
    , { field: 'brand', align: 'center', title: '品牌', hide: true }
    , { field: 'unit', align: 'center', title: '单位', hide: false }
    , { field: 'price', align: 'center', title: '单价', hide: true }
    , { field: 'sku', align: 'center', title: 'sku', hide: true }
    , { field: 'units', align: 'center', title: '单位量', hide: true }
    , { field: 'barcode', align: 'center', title: '条码', hide: true }
    , { field: 'origin', align: 'center', title: '产地', hide: true }
    , { field: 'manu', align: 'center', title: '厂家', hide: true }
    , { field: 'manuDate', align: 'center', title: '生产日期', hide: true }
    , { field: 'itemNum', align: 'center', title: '品项数', hide: true }
    , { field: 'safeQty', align: 'center', title: '安全库存量', hide: true }
    , { field: 'weight', align: 'center', title: '单箱净重', hide: true }
    , { field: 'length', align: 'center', title: '单箱毛重', hide: true }
    , { field: 'volume', align: 'center', title: '单箱体积', hide: true }
    , { field: 'threeCode', align: 'center', title: '箱子尺寸', hide: true }
    , { field: 'supp', align: 'center', title: '供应商', hide: true }
    , { field: 'suppCode', align: 'center', title: '供应商编码', hide: true }
    , { field: 'beBatch$', align: 'center', title: '是否批次', hide: true }
    , { field: 'deadTime', align: 'center', title: '保质期', hide: true }
    , { field: 'deadWarn', align: 'center', title: '预警天数', hide: true }
    , { field: 'source$', align: 'center', title: '制购', hide: true }
    , { field: 'check$', align: 'center', title: '要求检验', hide: true }
    , { field: 'danger$', align: 'center', title: '危险品', hide: true }
    , {
        field: 'frozen$', align: 'center', title: '冻结否', hide: true,
        templet: function (d) {
            // 根据条件判断字体颜色
            if (d.frozen$ === '已冻结') {
                return '<span style="color: #34a8de;">' +d.frozen$ + '</span>';
                return '<span style="color: #34a8de;">' + d.frozen$ + '</span>';
            } else {
                return '<span">' +d.frozen$ + '</span>';
                return '<span">' + d.frozen$ + '</span>';
            }
        }}
        }
    }
]
function getQueryVariable(variable)
{
function getQueryVariable(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i=0;i<vars.length;i++) {
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if(pair[0] == variable){return pair[1];}
        if (pair[0] == variable) { return pair[1]; }
    }
    return(false);
    return (false);
}
src/main/webapp/static/js/order/order.js
@@ -1,4 +1,5 @@
var insTbCount = 0;
var admin;
layui.config({
    base: baseUrl + "/static/layui/lay/modules/"
}).use(['layer', 'form', 'table', 'util', 'admin', 'xmSelect', 'laydate'], function () {
@@ -7,28 +8,28 @@
    var form = layui.form;
    var table = layui.table;
    var util = layui.util;
    var admin = layui.admin;
    admin = layui.admin;
    var xmSelect = layui.xmSelect;
    var layDate = layui.laydate;
    var laytpl = layui.laytpl;
    // 渲染搜索模板
    $.ajax({
        url: baseUrl+"/docType/list/auth",
        headers: {'token': localStorage.getItem('token')},
        url: baseUrl + "/docType/list/auth",
        headers: { 'token': localStorage.getItem('token') },
        data: {
            limit: 9999
        },
        method: 'POST',
        success: function (res) {
            if (res.code === 200){
            if (res.code === 200) {
                let template = Handlebars.compile($('#docTypeTpl').html());
                $('#docType-query').html(template(res.data));
                layui.form.render('select');
            } else if (res.code === 403){
                top.location.href = baseUrl+"/";
            } else if (res.code === 403) {
                top.location.href = baseUrl + "/";
            } else {
                layer.msg(res.msg, {icon: 2})
                layer.msg(res.msg, { icon: 2 })
            }
        }
    })
@@ -36,19 +37,20 @@
    // 渲染表格
    var insTb = table.render({
        elem: '#order',
        url: baseUrl+'/order/head/page/auth',
        headers: {token: localStorage.getItem('token')},
        url: baseUrl + '/order/head/page/auth',
        headers: { token: localStorage.getItem('token') },
        page: true,
        toolbar: '#toolbar',
        cellMinWidth: 100,
        cols: [[
            {type: 'numbers'},
            {field: 'orderNo', title: '单据编号', templet: '#orderNoTpl'},
            {field: 'docType$', align: 'center', title: '类型',  minWidth: 160, width: 160},
            {align: 'center', title: '明细', toolbar: '#tbLook', minWidth: 160, width: 160},
            {field: 'createTime$', title: '创建时间', minWidth: 200, width: 200},
            {field: 'settle$', align: 'center', title: '状态', templet: '#settleTpl',  minWidth: 160, width: 160},
            {field: 'memo', align: 'center',title: '备注', hide: true},
            {align: 'center', title: '操作', toolbar: '#operate', width: 180}
            { type: 'numbers' },
            { field: 'orderNo', title: '单据编号', templet: '#orderNoTpl' },
            { field: 'docType$', align: 'center', title: '类型', minWidth: 160, width: 160 },
            { align: 'center', title: '明细', toolbar: '#tbLook', minWidth: 160, width: 160 },
            { field: 'createTime$', title: '创建时间', minWidth: 200, width: 200 },
            { field: 'settle$', align: 'center', title: '状态', templet: '#settleTpl', minWidth: 160, width: 160 },
            { field: 'memo', align: 'center', title: '备注', hide: true },
            { align: 'center', title: '操作', toolbar: '#operate', width: 180 }
        ]],
        request: {
            pageName: 'curr',
@@ -68,7 +70,7 @@
        done: function (res, curr, count) {
            limit();
            if (res.code === 403) {
                top.location.href = baseUrl+"/";
                top.location.href = baseUrl + "/";
            }
            insTbCount = count;
        }
@@ -76,7 +78,7 @@
    // 搜索
    form.on('submit(tbSearch)', function (data) {
        insTb.reload({where: data.field, page: {curr: 1}});
        insTb.reload({ where: data.field, page: { curr: 1 } });
    });
    // 添加
@@ -113,22 +115,22 @@
                success: function (layero) {
                    table.render({
                        elem: '#lookSSXMTable',
                        headers: {token: localStorage.getItem('token')},
                        url: baseUrl+'/orderDetl/list/auth',
                        headers: { token: localStorage.getItem('token') },
                        url: baseUrl + '/orderDetl/list/auth',
                        where: {
                            order_id: data.id
                        },
                        page: true,
                        cellMinWidth: 100,
                        cols: [[
                            {type: 'numbers'},
                            {field: 'matnr', title: '商品编码', width: 160},
                            {field: 'maktx', title: '商品名称', width: 160},
                            {field: 'specs', title: '规格'},
                            {field: 'batch', title: '批号'},
                            {field: 'anfme', title: '待完结数量'},
                            {field: 'qty', title: '待上报数量', style: 'font-weight: bold'},
                            {field: 'workQty', title: '已上报数量'},
                            { type: 'numbers' },
                            { field: 'matnr', title: '商品编码', width: 160 },
                            { field: 'maktx', title: '商品名称', width: 160 },
                            { field: 'specs', title: '规格' },
                            { field: 'batch', title: '批号' },
                            { field: 'anfme', title: '待完结数量' },
                            { field: 'qty', title: '待上报数量', style: 'font-weight: bold' },
                            { field: 'workQty', title: '已上报数量' },
                            // {field: 'unit', title: '单位'},
                            // {
                            //     field: 'createTime$', title: '创建时间', sort: true, templet: function (d) {
@@ -182,42 +184,42 @@
                form.on('submit(orderEditSubmit)', function (data) {
                    // 组装数据
                    if (xxDataList.length <= 0) {
                        layer.tips('请添加单据明细', '#matAddBtnComment', {tips: [1, '#ff4c4c']});
                        layer.tips('请添加单据明细', '#matAddBtnComment', { tips: [1, '#ff4c4c'] });
                        return false;
                    }
                    let nList = admin.util.deepClone(xxDataList);
                    for (let xi = 0; xi < nList.length; xi++) {
                        if (nList[xi].anfme <= 0){
                            layer.msg('明细修改数量不合法', {icon: 2});
                        if (nList[xi].anfme <= 0) {
                            layer.msg('明细修改数量不合法', { icon: 2 });
                            return false;
                        }
                        if (nList[xi].anfme < nList[xi].workQty){
                            layer.msg('数量不能小于已作业数量', {icon: 2});
                        if (nList[xi].anfme < nList[xi].workQty) {
                            layer.msg('数量不能小于已作业数量', { icon: 2 });
                            return false;
                        }
                    }
                    layer.load(2);
                    $.ajax({
                        url: baseUrl+"/order/form/" + (isExpAdd?"add":"modify") + "/auth",
                        headers: {'token': localStorage.getItem('token')},
                        url: baseUrl + "/order/form/" + (isExpAdd ? "add" : "modify") + "/auth",
                        headers: { 'token': localStorage.getItem('token') },
                        data: JSON.stringify({
                            orderId: Number(data.field.id),
                            docType: Number(data.field.docType),
                            orderNo: data.field.orderNo,
                            orderDetlList: nList
                        }),
                        contentType:'application/json;charset=UTF-8',
                        contentType: 'application/json;charset=UTF-8',
                        method: 'POST',
                        success: function (res) {
                            layer.closeAll('loading');
                            if (res.code === 200){
                            if (res.code === 200) {
                                layer.close(dIndex);
                                $(".layui-laypage-btn")[0].click();
                                layer.msg(res.msg, {icon: 1});
                            } else if (res.code === 403){
                                top.location.href = baseUrl+"/";
                            }else {
                                layer.msg(res.msg, {icon: 2});
                                layer.msg(res.msg, { icon: 1 });
                            } else if (res.code === 403) {
                                top.location.href = baseUrl + "/";
                            } else {
                                layer.msg(res.msg, { icon: 2 });
                            }
                        }
                    })
@@ -227,22 +229,22 @@
                var xxDataList = [];
                var tbOptions = {
                    elem: '#formSSXMTable',
                    headers: {token: localStorage.getItem('token')},
                    headers: { token: localStorage.getItem('token') },
                    data: xxDataList,
                    page: true,
                    height: '350px;',
                    cellMinWidth: 100,
                    cols: [[
                        {type: 'numbers', title: '#'},
                        {field: 'matnr', title: '商品编码', width: 160},
                        {field: 'maktx', title: '商品名称', width: 200},
                        {field: 'batch', title: '批号', edit: true},
                        {field: 'specs', title: '规格'},
                        {field: 'anfme', title: '数量(修改)', style: 'color: blue;font-weight: bold', edit: true, minWidth: 110, width: 110},
                        {field: 'workQty', title: '作业数量',  minWidth: 100, width: 100},
                        { type: 'numbers', title: '#' },
                        { field: 'matnr', title: '商品编码', width: 160 },
                        { field: 'maktx', title: '商品名称', width: 200 },
                        { field: 'batch', title: '批号', edit: true },
                        { field: 'specs', title: '规格' },
                        { field: 'anfme', title: '数量(修改)', style: 'color: blue;font-weight: bold', edit: true, minWidth: 110, width: 110 },
                        { field: 'workQty', title: '作业数量', minWidth: 100, width: 100 },
                        // {field: 'unit', title: '单位', width: 80},
                        {field: 'memo', title: '备注' , edit: true},
                        {align: 'center', title: '操作', toolbar: '#formSSXMTableBar', minWidth: 80, width: 80, fixed: 'right'}
                        { field: 'memo', title: '备注', edit: true },
                        { align: 'center', title: '操作', toolbar: '#formSSXMTableBar', minWidth: 80, width: 80, fixed: 'right' }
                    ]],
                    done: function (res) {
                        $(layero).find('.layui-table-view').css('margin', '0');
@@ -251,18 +253,18 @@
                };
                if (!isExpAdd) {
                    $.ajax({
                        url: baseUrl+"/order/detl/all/auth?orderId=" + expTpe.id,
                        headers: {'token': localStorage.getItem('token')},
                        url: baseUrl + "/order/detl/all/auth?orderId=" + expTpe.id,
                        headers: { 'token': localStorage.getItem('token') },
                        method: 'GET',
                        async: false,
                        success: function (res) {
                            if (res.code === 200){
                            if (res.code === 200) {
                                xxDataList = res.data;
                                tbOptions.data = xxDataList;
                            } else if (res.code === 403){
                                top.location.href = baseUrl+"/";
                            }else {
                                layer.msg(res.msg, {icon: 2})
                            } else if (res.code === 403) {
                                top.location.href = baseUrl + "/";
                            } else {
                                layer.msg(res.msg, { icon: 2 })
                            }
                        }
                    })
@@ -275,8 +277,8 @@
                    if (layEvent === 'edit') {
                        showEditModel2(data);
                    } else if (layEvent === 'del') {
                        if(data.workQty > 0){
                            layer.msg("已存在作业数量,不能删除", {icon: 2});
                        if (data.workQty > 0) {
                            layer.msg("已存在作业数量,不能删除", { icon: 2 });
                            return;
                        }
                        layer.confirm('确定要删除吗?', {
@@ -290,7 +292,7 @@
                                    break;
                                }
                            }
                            insTbSSXM.reload({data: xxDataList, page: {curr: 1}});
                            insTbSSXM.reload({ data: xxDataList, page: { curr: 1 } });
                        });
                    }
                });
@@ -298,20 +300,20 @@
                table.on('edit(formSSXMTable)', function (obj) {
                    let index = obj.tr.attr("data-index");
                    let data = xxDataList[index];
                    if (obj.field === 'anfme'){
                    if (obj.field === 'anfme') {
                        let vle = Number(obj.value);
                        if (isNaN(vle)) {
                            layer.msg("请输入数字", {icon: 2});
                            layer.msg("请输入数字", { icon: 2 });
                            return false;
                        } else {
                            if (vle <= 0) {
                                layer.msg("数量必须大于零", {icon: 2});
                                layer.msg("数量必须大于零", { icon: 2 });
                                // data[obj.field] = 0;
                                // insTbSSXM.reload({data: xxDataList});
                                return false;
                            }
                            if(obj.value < data.workQty){
                                layer.msg("输入数量不能小于作业中数量", {icon: 2});
                            if (obj.value < data.workQty) {
                                layer.msg("输入数量不能小于作业中数量", { icon: 2 });
                                // data[obj.field] = 0;
                                // insTbSSXM.reload({data: xxDataList});
                                return false;
@@ -319,7 +321,7 @@
                        }
                    }
                    data[obj.field] = obj.value;
                    insTbSSXM.reload({data: xxDataList});
                    insTbSSXM.reload({ data: xxDataList });
                });
                $('#matAddBtnComment').click(function () {
@@ -340,22 +342,22 @@
                            // 表单提交事件
                            form.on('submit(matEditSubmit)', function (data) {
                                let selectList = matXmSelect.getValue();
                                for (let i = 0; i<selectList.length; i++) {
                                for (let i = 0; i < selectList.length; i++) {
                                    let item = selectList[i];
                                    // 查询物料详情
                                    $.ajax({
                                        url: baseUrl+"/mat/covert/"+item.value+"/auth",
                                        headers: {'token': localStorage.getItem('token')},
                                        url: baseUrl + "/mat/covert/" + item.value + "/auth",
                                        headers: { 'token': localStorage.getItem('token') },
                                        method: 'GET',
                                        async: false,
                                        success: function (res) {
                                            if (res.code === 200){
                                            if (res.code === 200) {
                                                xxDataList.push(res.data);
                                                insTbSSXM.reload({data: xxDataList, page: {curr: 1}});
                                            } else if (res.code === 403){
                                                top.location.href = baseUrl+"/";
                                            }else {
                                                layer.msg(res.msg, {icon: 2})
                                                insTbSSXM.reload({ data: xxDataList, page: { curr: 1 } });
                                            } else if (res.code === 403) {
                                                top.location.href = baseUrl + "/";
                                            } else {
                                                layer.msg(res.msg, { icon: 2 })
                                            }
                                        }
                                    })
@@ -373,20 +375,20 @@
                                toolbar: { show: true },
                                filterable: true,
                                remoteSearch: true,
                                remoteMethod: function(val, cb, show){
                                remoteMethod: function (val, cb, show) {
                                    $.ajax({
                                        url: baseUrl+"/mat/all/get/kv",
                                        headers: {'token': localStorage.getItem('token')},
                                        url: baseUrl + "/mat/all/get/kv",
                                        headers: { 'token': localStorage.getItem('token') },
                                        data: {
                                            condition: val
                                        },
                                        method: 'POST',
                                        success: function (res) {
                                            if (res.code === 200){
                                            if (res.code === 200) {
                                                cb(res.data)
                                            } else {
                                                cb([]);
                                                layer.msg(res.msg, {icon: 2});
                                                layer.msg(res.msg, { icon: 2 });
                                            }
                                        }
                                    });
@@ -412,25 +414,25 @@
            layer.close(i);
            layer.load(2);
            $.ajax({
                url: baseUrl+"/order/delete/auth",
                headers: {'token': localStorage.getItem('token')},
                url: baseUrl + "/order/delete/auth",
                headers: { 'token': localStorage.getItem('token') },
                data: {
                    orderId: orderId
                },
                method: 'POST',
                success: function (res) {
                    layer.closeAll('loading');
                    if (res.code === 200){
                    if (res.code === 200) {
                        if (insTbCount === 0) {
                            insTb.reload({page: {curr: 1}});
                            insTb.reload({ page: { curr: 1 } });
                        } else {
                            $(".layui-laypage-btn")[0].click();
                        }
                        layer.msg(res.msg, {icon: 1});
                    } else if (res.code === 403){
                        top.location.href = baseUrl+"/";
                    }else {
                        layer.msg(res.msg, {icon: 2});
                        layer.msg(res.msg, { icon: 1 });
                    } else if (res.code === 403) {
                        top.location.href = baseUrl + "/";
                    } else {
                        layer.msg(res.msg, { icon: 2 });
                    }
                }
            })
@@ -448,8 +450,8 @@
            console.log(orderId);
            console.log(settle);
            $.ajax({
                url: baseUrl+"/order/update/auth",
                headers: {'token': localStorage.getItem('token')},
                url: baseUrl + "/order/update/auth",
                headers: { 'token': localStorage.getItem('token') },
                data: {
                    id: orderId,
                    orderNo: orderNo,
@@ -458,17 +460,17 @@
                method: 'POST',
                success: function (res) {
                    layer.closeAll('loading');
                    if (res.code === 200){
                    if (res.code === 200) {
                        if (insTbCount === 0) {
                            insTb.reload({page: {curr: 1}});
                            insTb.reload({ page: { curr: 1 } });
                        } else {
                            $(".layui-laypage-btn")[0].click();
                        }
                        layer.msg(res.msg, {icon: 1});
                    } else if (res.code === 403){
                        top.location.href = baseUrl+"/";
                    }else {
                        layer.msg(res.msg, {icon: 2});
                        layer.msg(res.msg, { icon: 1 });
                    } else if (res.code === 403) {
                        top.location.href = baseUrl + "/";
                    } else {
                        layer.msg(res.msg, { icon: 2 });
                    }
                }
            })
@@ -477,17 +479,17 @@
    // 任务追溯
    function showWrkTrace(orderId) {
        let loadIndex = layer.msg('请求中...', {icon: 16, shade: 0.01, time: false});
        let loadIndex = layer.msg('请求中...', { icon: 16, shade: 0.01, time: false });
        $.ajax({
            url: baseUrl+"/order/wrk/trace/auth",
            headers: {'token': localStorage.getItem('token')},
            url: baseUrl + "/order/wrk/trace/auth",
            headers: { 'token': localStorage.getItem('token') },
            data: {
                orderId: orderId
            },
            method: 'POST',
            success: function (res) {
                layer.close(loadIndex);
                if (res.code === 200){
                if (res.code === 200) {
                    laytpl(wrkTraceDialog.innerHTML).render(res.data, function (html) {
                        admin.open({
                            type: 1,
@@ -502,26 +504,26 @@
                                var traceOptions = {
                                    title: {
                                        text: '作业/完结/上报', x: 'center', y: '38%',
                                        textStyle: {fontSize: 18, color: '#262626', fontWeight: 'normal'},
                                        subtextStyle: {fontSize: 36, color: '#10B4E8'},
                                        textStyle: { fontSize: 18, color: '#262626', fontWeight: 'normal' },
                                        subtextStyle: { fontSize: 36, color: '#10B4E8' },
                                        itemGap: 20
                                    },
                                    color: ['#10B4E8', '#E0E0E0', '#FF0000'],
                                    tooltip: {trigger: 'item'},
                                    series: [{name: '数量', type: 'pie', radius: ['75%', '80%'], label: {normal: {show: false}}}]
                                    tooltip: { trigger: 'item' },
                                    series: [{ name: '数量', type: 'pie', radius: ['75%', '80%'], label: { normal: { show: false } } }]
                                };
                                traceCharts.setOption(traceOptions);
                                // 赋值
                                traceCharts.setOption({
                                    title: {
                                        subtext: res.data.totalQty+"/"+res.data.wrkQty+"/"+res.data.endQty
                                        subtext: res.data.totalQty + "/" + res.data.wrkQty + "/" + res.data.endQty
                                    },
                                    series: [
                                        {
                                            data: [
                                                {name: '已作业', value: res.data.wrkQty},
                                                {name: '未作业', value: res.data.totalQty-res.data.wrkQty-res.data.lackQty},
                                                {name: '库存不足', value: res.data.lackQty},
                                                { name: '已作业', value: res.data.wrkQty },
                                                { name: '未作业', value: res.data.totalQty - res.data.wrkQty - res.data.lackQty },
                                                { name: '库存不足', value: res.data.lackQty },
                                            ]
                                        }
                                    ]
@@ -529,10 +531,10 @@
                            }
                        });
                    });
                } else if (res.code === 403){
                    top.location.href = baseUrl+"/";
                }else {
                    layer.msg(res.msg, {icon: 2});
                } else if (res.code === 403) {
                    top.location.href = baseUrl + "/";
                } else {
                    layer.msg(res.msg, { icon: 2 });
                }
            }
        })
@@ -540,7 +542,77 @@
    layDate.render({
        elem: '.layui-laydate-range'
        ,type: 'datetime'
        ,range: true
        , type: 'datetime'
        , range: true
    });
});
// excel导入模板下载
function excelMouldDownload() {
    layer.load(1, { shade: [0.1, '#fff'] });
    location.href = baseUrl + "/orders/excel/import/mould";
    layer.closeAll('loading');
}
// excel导入
function importExcel() {
    $("#importExcel").trigger("click");
}
// excel导入模板下载
function excelMouldDownload() {
    layer.load(1, {shade: [0.1, '#fff']});
    location.href = baseUrl + "/mat/excel/import/mould";
    layer.closeAll('loading');
}
// excel导入
function importExcel() {
    $("#importExcel").trigger("click");
}
function upload(obj) {
    if (!obj.files) {
        return;
    }
    var file = obj.files[0];
    admin.confirm('确认同步 [' + file.name + '] 文件吗?', function (index) {
        layer.load(1, {shade: [0.1, '#fff']});
        var url = baseUrl + "/orders/excel/import/auth";
        var form = new FormData();
        form.append("file", file);
        xhr = new XMLHttpRequest();
        xhr.open("post", url, true); //post方式,url为服务器请求地址,true 该参数规定请求是否异步处理。
        xhr.setRequestHeader('token', localStorage.getItem('token'));
        xhr.onload = uploadComplete; //请求完成
        xhr.onerror = uploadFailed; //请求失败
        xhr.onloadend = function () { // // 上传完成重置文件流
            layer.closeAll('loading');
            $("#importExcel").val("");
        };
        // xhr.upload.onprogress = progressFunction;//【上传进度调用方法实现】
        xhr.upload.onloadstart = function () {//上传开始执行方法
            ot = new Date().getTime();   //设置上传开始时间
            oloaded = 0;//设置上传开始时,以上传的文件大小为0
        };
        xhr.send(form);
    }, function (index) {
        $("#importExcel").val("");
    });
}
function uploadComplete(evt) {
    var res = JSON.parse(evt.target.responseText);
    if (res.code === 200) {
        layer.msg(res.msg, {icon: 1});
        loadTree("");
    } else {
        layer.msg(res.msg, {icon: 2});
    }
}
function uploadFailed(evt) {
    var res = JSON.parse(evt.target.responseText);
    layer.msg(res.msg, {icon: 2});
}
src/main/webapp/views/order/order.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title></title>
@@ -25,77 +26,100 @@
        .layui-timeline:first-child .layui-timeline-item {
            margin-top: 30px;
        }
        .btn-add {
            display: none;
        }
        .btn-edit {
            display: none;
        }
        .btn-complete {
            display: none;
        }
        .btn-delete {
            display: none;
        }
    </style>
</head>
<body>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <!-- 表格顶部工具栏 -->
            <div class="layui-form toolbar">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <div class="layui-input-inline mr0">
                            <input name="order_no" class="layui-input" type="text" placeholder="输入单据编号"/>
<body>
    <!-- 正文开始 -->
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 表格顶部工具栏 -->
                <div class="layui-form toolbar">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <div class="layui-input-inline mr0">
                                <input name="order_no" class="layui-input" type="text" placeholder="输入单据编号" />
                            </div>
                        </div>
                    </div>
                    <div class="layui-inline" style="width: 300px">
                        <div class="layui-input-inline">
                            <input class="layui-input layui-laydate-range" name="create_time" type="text" placeholder="起始时间 - 终止时间" autocomplete="off" style="width: 300px">
                        <div class="layui-inline" style="width: 300px">
                            <div class="layui-input-inline">
                                <input class="layui-input layui-laydate-range" name="create_time" type="text"
                                    placeholder="起始时间 - 终止时间" autocomplete="off" style="width: 300px">
                            </div>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <select name="doc_type" id="docType-query">
                            </select>
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <select name="doc_type" id="docType-query">
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <select name="settle">
                                <option value="">选择状态</option>
                                <option value="1">待处理</option>
                                <option value="2">作业中</option>
                                <option value="4">已完成</option>
                                <option value="6">上报完成</option>
                            </select>
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <select name="settle">
                                    <option value="">选择状态</option>
                                    <option value="1">待处理</option>
                                    <option value="2">作业中</option>
                                    <option value="4">已完成</option>
                                    <option value="6">上报完成</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn icon-btn" lay-filter="tbSearch" lay-submit>
                            <i class="layui-icon">&#xe615;</i>搜索
                        </button>
                        <button id="orderAddBtn" class="layui-btn icon-btn btn-add"><i class="layui-icon">&#xe654;</i>添加
                        </button>
                        <div class="layui-inline">
                            <button class="layui-btn icon-btn" lay-filter="tbSearch" lay-submit>
                                <i class="layui-icon">&#xe615;</i>搜索
                            </button>
                            <button id="orderAddBtn" class="layui-btn icon-btn btn-add"><i
                                    class="layui-icon">&#xe654;</i>添加
                            </button>
                        </div>
                    </div>
                </div>
                <table id="order" lay-filter="order"></table>
            </div>
            <table id="order" lay-filter="order"></table>
        </div>
        <div class="layui-card">
            <div class="layui-card-body">
                入库通知单:由ERP提供单据编号、类型、单据时间及物料明细,生成入库作业单,为维护系统高可用,用户可自行添加入库通知单数据,完成独立的入库作业。
                <span class="text-danger">手动添加时,请检查单据编号是否在ERP系统中已存在,避免发生数据错误问题。</span>
            </div>
        </div>
    </div>
    <div class="layui-card">
        <div class="layui-card-body">
            入库通知单:由ERP提供单据编号、类型、单据时间及物料明细,生成入库作业单,为维护系统高可用,用户可自行添加入库通知单数据,完成独立的入库作业。
            <span class="text-danger">手动添加时,请检查单据编号是否在ERP系统中已存在,避免发生数据错误问题。</span>
    <script type="text/html" id="toolbar">
        <div class="layui-btn-container">
            <!-- 商品/物料 数据中心 -->
            <div class="dropdown-menu" style="float: right">
                <button class="layui-btn layui-btn-primary layui-border-black icon-btn layui-btn-sm">&nbsp;Excel模板 <i class="layui-icon layui-icon-drop"></i></button>
                <ul class="dropdown-menu-nav dark">
                    <div class="dropdown-anchor"></div>
                    <li class="title">1st menu</li>
                    <li><a onclick="excelMouldDownload()" style="font-size: 12px"><i class="layui-icon layui-icon-template-1"></i>模板下载</a></li>
                    <li><a onclick="importExcel()" style="font-size: 12px"><i class="layui-icon layui-icon-upload"></i>导入 Excel</a></li>
                    <li style="display: none"><input id="importExcel" type="file" onchange="upload(this)" ></li>
                </ul>
            </div>
        </div>
    </div>
</div>
<!-- 表格操作列 -->
<script type="text/html" id="operate">
    </script>
    <!-- 表格操作列 -->
    <script type="text/html" id="operate">
    {{# if (d.settle == 0 || d.settle == 1) { }}
        <a class="layui-btn layui-btn-primary layui-btn-xs btn-edit" lay-event="edit">修改</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs btn-delete" lay-event="del">删除</a>
@@ -104,26 +128,22 @@
    <a class="layui-btn layui-btn-primary layui-border-blue layui-btn-xs btn-complete" lay-event="complete">完结</a>
    {{# } }}
</script>
<!-- 表格操作列 -->
<script type="text/html" id="tbLook">
    <!-- 表格操作列 -->
    <script type="text/html" id="tbLook">
    <span class="layui-text">
        <a href="javascript:;" lay-event="look">
            <i class="layui-icon" style="font-size: 12px;">&#xe61a;</i> 查看单据明细
        </a>
    </span>
</script>
<script type="text/html" id="orderNoTpl">
    <script type="text/html" id="orderNoTpl">
    {{d.orderNo}}
    {{# if(d.settle > 1 && d.settle !== 3){ }}
    {{# } }}
    <i class="layui-icon layui-icon-about wrk-trace" lay-tips="查看任务追溯" lay-direction="2" lay-offset="-10px,0px" lay-event="wrkTrace"></i>
</script>
<!--<script type="text/html" id="settleTpl">-->
<!--    <span name="settle" class="layui-badge layui-badge-gray">{{d.settle$}}</span>-->
<!--</script>-->
<script type="text/html" id="settleTpl">
    <script type="text/html" id="settleTpl">
    <span name="settle"
          {{# if( d.settle === 1){ }}
          class="layui-badge layui-badge-red"
@@ -140,8 +160,8 @@
          {{# } }}
    >{{d.settle$}}</span>
</script>
<!-- 表单弹窗 -->
<script type="text/html" id="editDialog">
    <!-- 表单弹窗 -->
    <script type="text/html" id="editDialog">
    <form id="editForm" lay-filter="editForm" class="layui-form model-form">
        <input name="id" type="hidden"/>
        <div class="layui-form-item">
@@ -179,13 +199,13 @@
        </div>
    </form>
</script>
<!-- 表格操作列 -->
<script type="text/html" id="formSSXMTableBar">
    <!-- 表格操作列 -->
    <script type="text/html" id="formSSXMTableBar">
    <!--    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>-->
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<!-- 表单弹窗 -->
<script type="text/html" id="matEditDialog">
    </script>
    <!-- 表单弹窗 -->
    <script type="text/html" id="matEditDialog">
    <form id="matEditForm" lay-filter="matEditForm" class="layui-form model-form">
        <input name="experimentId" type="hidden"/>
        <div class="layui-form-item" style="float: left">
@@ -201,8 +221,8 @@
        </div>
    </form>
</script>
<!-- 订单任务追溯 -->
<script id="wrkTraceDialog" type="text/html" style="position: relative">
    <!-- 订单任务追溯 -->
    <script id="wrkTraceDialog" type="text/html" style="position: relative">
    <div style="position: absolute; top: 0; left: 0;">
        <div class="layui-card" style="overflow: hidden;">
            <div class="layui-card-header" style="text-align: center;width: 80%;font-weight: inherit;font-size: 18px">{{ d.orderNo }}</div>
@@ -298,18 +318,27 @@
            {{#  } }}
        </div>
    </div>
</script>
<script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../../static/js/handlebars/handlebars-v4.5.3.js"></script>
<script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="../../static/js/echarts/echarts.min.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/order/order.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="../../static/js/handlebars/handlebars-v4.5.3.js"></script>
    <script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../static/js/echarts/echarts.min.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/order/order.js" charset="utf-8"></script>
    <script>
        layui.config({
            base: baseUrl + "/static/layui/lay/modules/"
        }).extend({
            dropdown: 'dropdown/dropdown'
        }).use(['dropdown'], function () {
            var dropdown = layui.dropdown;
            dropdown.init();
            dropdown.openClickNavClose();
        });
    </script>
<script type="text/template" id="docTypeTpl">
    <script type="text/template" id="docTypeTpl">
    <option value="">选择类型</option>
    {{#each records}}
    <option value="{{docId}}">{{docName}}</option>
@@ -317,5 +346,4 @@
</script>
</body>
</html>
</html>