|
@@ -126,7 +126,9 @@
|
|
|
placeholder="请输入充值金额(元)"
|
|
|
controls-position="right"
|
|
|
style="width: 100%"
|
|
|
+ @input="chargeAmountInput"
|
|
|
/>
|
|
|
+ <span v-if="this.amountToTraffic" class="el-form-item__error"> 约充值 {{ this.amountToTraffic }}流量 </span>
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="备注" prop="remark">
|
|
@@ -149,7 +151,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { listTrafficRecords, rechargeTraffic } from "@/api/company/traffic";
|
|
|
+import { listTrafficRecords, rechargeTraffic, trafficConversion } from '@/api/company/traffic'
|
|
|
import { allList } from '@/api/company/company'
|
|
|
import { resetForm } from '@/utils/common'
|
|
|
import { delAdIqiyiAccount } from '@/api/ad/AdIqiyiAccount'
|
|
@@ -158,6 +160,7 @@ export default {
|
|
|
name: "CompanyTraffic",
|
|
|
data() {
|
|
|
return {
|
|
|
+ amountToTraffic: 0,
|
|
|
// 遮罩层
|
|
|
loading: true,
|
|
|
// 选中数组
|
|
@@ -232,6 +235,35 @@ export default {
|
|
|
this.loading = false;
|
|
|
});
|
|
|
},
|
|
|
+ /** 流量计算*/
|
|
|
+ chargeAmountInput() {
|
|
|
+ if(!this.rechargeForm.chargeAmount){
|
|
|
+ this.amountToTraffic = 0;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ trafficConversion({traffic:this.rechargeForm.chargeAmount}).then(
|
|
|
+ response => {
|
|
|
+ this.amountToTraffic = response.data;
|
|
|
+ //对流量值进行判断,换算成GB或TB
|
|
|
+ if(!this.amountToTraffic){
|
|
|
+ this.amountToTraffic = "0 KB";
|
|
|
+ }
|
|
|
+ if(this.amountToTraffic < 1024){
|
|
|
+ this.amountToTraffic = this.amountToTraffic + " KB";
|
|
|
+ }
|
|
|
+ else if(this.amountToTraffic < 1024 * 1024){
|
|
|
+ this.amountToTraffic = (this.amountToTraffic / 1024).toFixed(2) + " MB";
|
|
|
+ }
|
|
|
+ else if(this.amountToTraffic < 1024 * 1024 * 1024){
|
|
|
+ this.amountToTraffic = (this.amountToTraffic / (1024 * 1024)).toFixed(2) + " GB";
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ this.amountToTraffic = (this.amountToTraffic / (1024 * 1024 * 1024)).toFixed(2) + " TB";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+ ,
|
|
|
/** 搜索公司 */
|
|
|
searchCompanies( query) {
|
|
|
allList().then(response => {
|
|
@@ -263,20 +295,20 @@ export default {
|
|
|
formatBalance(row){
|
|
|
//对流量值进行判断,换算成GB或TB
|
|
|
if(!row.balance){
|
|
|
- return "0KB";
|
|
|
+ return "0 KB";
|
|
|
}
|
|
|
const absBalance = Math.abs(row.balance); // 获取绝对值
|
|
|
if(absBalance < 1024){
|
|
|
- return row.balance + "KB";
|
|
|
+ return row.balance + " KB";
|
|
|
}
|
|
|
else if(absBalance < 1024 * 1024){
|
|
|
- return (row.balance / 1024).toFixed(2) + "MB";
|
|
|
+ return (row.balance / 1024).toFixed(2) + " MB";
|
|
|
}
|
|
|
else if(absBalance < 1024 * 1024 * 1024){
|
|
|
- return (row.balance / (1024 * 1024)).toFixed(2) + "GB";
|
|
|
+ return (row.balance / (1024 * 1024)).toFixed(2) + " GB";
|
|
|
}
|
|
|
else{
|
|
|
- return (row.balance / (1024 * 1024 * 1024)).toFixed(2) + "TB";
|
|
|
+ return (row.balance / (1024 * 1024 * 1024)).toFixed(2) + " TB";
|
|
|
}
|
|
|
},
|
|
|
|