gpt4 book ai didi

php - 如何使用angularjs在mysql中存储数学函数值?

转载 作者:行者123 更新时间:2023-11-28 23:25:43 24 4
gpt4 key购买 nike

我正在创建发票生成器。因为我想将总计、折扣和所有东西存储在我的数据库中。总计和折扣计算如下...

<tr ng-repeat="list in data">
<td>
<label class="clabel">Subtotal</label>
</td>
<td ng-model="subtotal">{{list.sale_price*list.quantity}}</td>
</tr>
<tr ng-repeat="list in data">
<td>
<label class="clabel">Tax(2%)</label>
</td>
<td ng-model="tax">{{((list.sale_price*list.quantity)*2)/100}}</td>
</tr>
<tr ng-repeat="list in data">
<td>
<label class="clabel">Discount(%)</label>
</td>
<td ng-model="discount">{{((list.sale_price*list.quantity)*list.discount)/100}}</td>
</tr>
<tr ng-repeat="list in data">
<td>
<label class="clabel">Total</label>
</td>
<td ng-model="total">{{((list.sale_price*list.quantity)+(((list.sale_price*list.quantity)*2)/100))-(((list.sale_price*list.quantity)*list.discount)/100)}}</td>
</tr>
<tr>
<td colspan="2">
<button class="btn btn-success" style="margin-left:400px;" ng-click="GenerateBill();updateAll()">Generate Invoice</button>
</td>
</tr>

现在我想将计算值保存在我的数据库中。这意味着我想存储 list.sale_price*list.quantity 的值。

js 部分在这里..

$scope.updateAll = function(){

data={
qnt:$scope.qnt,
subt:$scope.subtotal,
tax:$scope.tax,
dis:$scope.discount,
total:$scope.total
}
$http.post("../POS_System/widget/updateAll.php?barcode="+$scope.barcode,data).success(function(data){

});

请帮帮我...

最佳答案

你可以试试这个....

$scope.updateAll=function()
{
data={
subtotal:$scope.product.sale_prize*$scope.product.quantity,
tax:$scope.product.sale_prize * $scope.product.quantity*2/100,
discount:$scope.product.sale_prize * $scope.product.quantity*$scope.product.discount/100,
total:$scope.product.sale_prize * $scope.product.quantity+$scope.product.sale_prize * $scope.product.quantity*2/100-$scope.product.sale_prize *$scope.product.quantity* $scope.product.discount/100

}

$http.post("../pos_system/Widgets/updatedata.php?barc="+$scope.barc,data).success(function(data)
{
//do your stuff here;
});
}

在您的 HTML 部分进行此更改

<tr >
<td>
<label class="clabel">Subtotal</label>
</td>
<td><input type="text" class="cinput" placeholder="sale price" ng-value="list.sale_price*list.quantity" readonly="" />
</td>
</tr>
<tr >
<td>
<label class="clabel">Tax(2%)</label>
</td>
<td><input type="text" class="cinput" placeholder="sale price" ng-value="((list.sale_price*list.quantity)*2)/100" readonly="" />
</td>
</tr>
<tr>
<td>
<label class="clabel">Discount(%)</label>
</td>
<td>
<input type="text" class="cinput" placeholder="sale price" ng-value="((list.sale_price*list.quantity)*list.discount)/100" readonly="" />
</td>
</tr>
<tr >
<td>
<label class="clabel">Total</label>
</td>
<td >
<input type="text" class="cinput" placeholder="sale price" ng-value="((list.sale_price*list.quantity)+(((list.sale_price*list.quantity)*2)/100))-(((list.sale_price*list.quantity)*list.discount)/100)" readonly="" />
</td>
</tr>
<tr>
<td colspan="2">
<button class="btn btn-success" style="margin-left:400px;" ng-click="GenerateBill();updateAll()">Generate Invoice</button>
</td>
</tr>

关于php - 如何使用angularjs在mysql中存储数学函数值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39444679/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com