const validateorderPrice = (rule, value, callback) => { //必須包含大小寫字母、數字、特殊字符長度再9-16位之間 var regex = new RegExp("(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^0-9]).{8,16}"); if (value === "") { callback(new Error("請輸入服務費,不能爲空")); }else { //銷售價不能超過(-5% < 服務費 < +15%) getSalePrice(this.carProduct.id,this.formCar.carBasicInfo.id,this.carProduct.canalId,this.carProduct.insurerId).then(response => { if(response.data!=undefined){ var maxSalesPrice = response.data.salesPrice*1.15; var minSalesPrice = response.data.salesPrice*0.95; if(value>maxSalesPrice || value < minSalesPrice){ console.log("銷售價不能超過(-5% < 服務費 < +15%)"); callback(new Error('服務費不能超過['+maxSalesPrice+'],且不能低於['+minSalesPrice+']')) } } }); //callback(); } }; orderPrice: [ //{required: true, message: "服務費不能爲空", trigger: "blur"}, {required: true, validator: validateorderPrice, trigger: "blur" } ],
orderPrice: [ //{required: true, message: "服務費不能爲空", trigger: "blur"}, {required: true, validator: validateorderPrice, trigger: "blur" } ],