首頁>技術>

目標:

新增銷售單時,如果銷售數量大於庫存數量或銷售單價低於底價時不可提交;

實現環境:

白碼低程式碼開發平臺;

前期準備:

商品、商品規格、銷售訂單、銷售訂單明細資料表,並且有一些商品基礎資料;

實現步驟:

新建功能:新增銷售單;

①第一步新增資料,填寫銷售單基礎資料;

②第二步新增集合,新增銷售訂單明細;

function prepare($programStore, $form, vue) {    vue.$watch(() => { return programStore.getters["getFormValue"]("6021163ff027b63cc9a2fe30") },//監控銷售訂單明細步驟        function (value) {            let data = value.data || [];            if(data.length ==0){                return;            }            console.log(data);            for (let i = 0; i < data.length; i++) {//遍歷集合                let goodsid = data[i]["6021148ad611b43cc82ead48"];//商品id                let skuid = data[i]["60211490d611b43cc82ead49"];//規格id                let sales_num = data[i]["6021149ad611b43cc82ead4b"];//銷售數量                let sales_price = data[i]["60211496d611b43cc82ead4a"];//銷售單價                let goods_name = "";//商品名稱                vue.$store.dispatch("data/show", {//查詢商品資料                    dataset: "60211427f027b63cc9a2fe21",                    query: {                        query: {                            "_id": goodsid                        },                        empty: false,                        page: {                            index: 1,                            size: 100                        }                    }                }).then(res => {                    let good = res.data.data[0];//商品物件                    goods_name = good["6021142dd611b43cc82ead3a"];                    let stock = good["60211432d611b43cc82ead3b"];//商品庫存                    if(new Number(stock) < new Number(sales_num)){//如果銷售數量大於庫存                        $programStore.dispatch("error/setText",goods_name+"庫存不足");//禁止提交                        return;                    }                });                vue.$store.dispatch("data/show", {//查詢規格資料                    dataset: "6021143ed611b43cc82ead3d",                    query: {                        query: {                            "_id": skuid                        },                        empty: false,                        page: {                            index: 1,                            size: 100                        }                    }                }).then(res => {                    let sku = res.data.data[0];//規格物件                    let price = sku["6021144dd611b43cc82ead40"];//規格底價                    if(new Number(price) > new Number(sales_price)){//如果銷售單價低於底價                        $programStore.dispatch("error/setText",goods_name+"銷售單價低於底價");//禁止提交                        return;                    }                });                $programStore.dispatch("error/setText","");//可以提交            }        }    )}
測試效果:

4
  • BSA-TRITC(10mg/ml) TRITC-BSA 牛血清白蛋白改性標記羅丹明
  • 從零開始學點兒C++ 筆記(01)