puzhibing
2024-02-02 e14a6debcb17348164f703fcb2a7b9b1c3608352
meiya-admin/src/main/webapp/static/modular/mall/mallGroupSpec/mallGroupSpec_info.js
@@ -42,10 +42,16 @@
 * 收集数据
 */
MallGroupSpecInfoDlg.collectData = function() {
    let goodsSkuJson = MallGroupSpecInfoDlg.getGoodsSkuJson(1);
    if (goodsSkuJson == 'ERROR') {
        return false;
    }
    this
    .set('id')
    .set('specName')
    .set('goodsIds', Feng.getMultipleSelectVal("goodsIds"))
    .set('goodsSkuJson', goodsSkuJson)
    .set('goodsNames')
    .set('classifyIdOne')
    .set('classifyIdTwo')
@@ -59,13 +65,83 @@
    .set('isDelete')
    .set('provinceCode')
    .set('provinceName', $('#provinceCode option:selected').text());
    return true;
};
MallGroupSpecInfoDlg.getGoodsSkuJson = function(isCheck) {
    let result = '';
    let goodsSkuJson = [];
    $(".goods_sku_json").each(function() {
        let inputs = $(this).find("input"); // 找到当前<td>元素中的所有输入框
        let input1Value = $(inputs[0]).val(); // 获取第一个输入框的内容-商品id
        let input2Value = $(inputs[1]).val(); // 获取第二个输入框的内容-输入数量
        let input3Value = $(inputs[2]).val(); // 获取第三个输入框的内容-库存
        // 是否需要验证
        if(isCheck == 1) {
            if(input3Value - input2Value < 0) {
                Feng.error("数量不能大于商品库存");
                // 错误标记
                result = "ERROR";
                // 中断each()循环
                return false;
            }
            if(input2Value == 0) {
                Feng.error("数量不能小于1");
                // 错误标记
                result = "ERROR";
                // 中断each()循环
                return false;
            }
        }
        let json = {
            "goodsId": input1Value,
            "goodsNum": input2Value
        };
        goodsSkuJson.push(json);
    });
    if (result == '') {
        result = JSON.stringify(goodsSkuJson);
    }
    return result;
}
MallGroupSpecInfoDlg.chooseGoods = function() {
    // $.ajax({
    //     url : Feng.ctxPath + "/mallGoods/goodsByIdsList",
    //     type : "get",
    //     data : {"ids": Feng.getMultipleSelectVal("goodsIds")},
    //     dataType : "json",
    //     success : function (list) {
    //         let goodsSelectTbodyStr = '';
    //         $.each(list, function(i, item) {
    //             goodsSelectTbodyStr += "<tr>"
    //                 + "<td> " + item.goodsNo + " </td>"
    //                 + "<td> " + item.goodsName + " </td>"
    //                 + "<td> " + item.price + " </td>"
    //                 + "<td> " + item.priceSale + " </td>"
    //                 + "<td> " + item.stock + " </td>"
    //                 + "<td style='text-align: center;' class='goods_sku_json'>" +
    //                     "<input type='hidden' value='" + item.goodsNo + "'>" +
    //                     "<input type='text' value='0'>" +
    //                 "</td>"
    //             + "</tr>"
    //         });
    //
    //         $("#goodsSelectTbody").html(goodsSelectTbodyStr);
    //     }
    // });
    $.ajax({
        url : Feng.ctxPath + "/mallGoods/goodsByIdsList",
        url : Feng.ctxPath + "/mallGoods/goodsByGoodsSpecId",
        type : "get",
        data : {"ids": Feng.getMultipleSelectVal("goodsIds")},
        data : {
            "goodsIds": Feng.getMultipleSelectVal("goodsIds"),
            "groupSpecId": $("#id").val(),
            "oldGoodsSkuJson": MallGroupSpecInfoDlg.getGoodsSkuJson(0)
        },
        dataType : "json",
        success : function (list) {
            let goodsSelectTbodyStr = '';
@@ -76,6 +152,11 @@
                    + "<td> " + item.price + " </td>"
                    + "<td> " + item.priceSale + " </td>"
                    + "<td> " + item.stock + " </td>"
                    + "<td style='text-align: center;' class='goods_sku_json'>" +
                        "<input type='hidden' value='" + item.id + "'>" +
                        "<input type='text' value='" + item.goodsNum + "'>" +
                        "<input type='hidden' value='" + item.stock + "'>" +
                    "</td>"
                + "</tr>"
            });
@@ -90,7 +171,10 @@
 */
MallGroupSpecInfoDlg.addSubmit = function() {
    this.clearData();
    this.collectData();
    let checkForm = this.collectData();
    if (!checkForm) {
        return;
    }
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/mallGroupSpec/add", function(data){
@@ -113,7 +197,10 @@
 */
MallGroupSpecInfoDlg.editSubmit = function() {
    this.clearData();
    this.collectData();
    let checkForm = this.collectData();
    if (!checkForm) {
        return;
    }
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/mallGroupSpec/update", function(data){