Merge branch 'gyq' of e.coding.net:g-cphe0354/yinshoukeguanliduan/management into dwb

This commit is contained in:
duan 2024-07-03 09:27:17 +08:00
commit 9dc307b031
3 changed files with 34 additions and 13 deletions

View File

@ -416,3 +416,20 @@ export function isPcBowser() {
}
}
}
/**
* 保留小数n位不进行四舍五入
* num你传递过来的数字,
* decimal你保留的几位,默认保留小数后两位
*/
export function formatDecimal(num, decimal = 2) {
num = num.toFixed(3).toString();
const index = num.indexOf(".");
if (index !== -1) {
num = num.substring(0, decimal + index + 1);
} else {
num = num.substring(0);
}
//截取后保留两位小数
return parseFloat(num).toFixed(decimal);
}

View File

@ -1,24 +1,27 @@
<!-- 新增库存盘点 -->
<template>
<el-dialog title="库存盘点" :visible.sync="dialogVisible">
<el-dialog title="库存盘点" :visible.sync="dialogVisible" width="80%" @open="form.note = ''">
<el-form ref="form" :model="form" :rules="rules" label-position="left" inline>
<el-form-item label="账存数量">
<el-input v-model="detail.stockNumber" readonly></el-input>
<el-input v-model="detail.stockNumber" readonly style="width: 180px;"></el-input>
</el-form-item>
<el-form-item label="实际数量" prop="stocktakinNum">
<el-input-number v-model="form.stocktakinNum"></el-input-number>
<el-form-item label="实际数量">
<el-input-number v-model="form.stocktakinNum" :min="0" :step="1" step-strictly
style="width: 180px;"></el-input-number>
</el-form-item>
<el-form-item label="盈亏数量">
<el-input v-model="profitNumber" readonly :class="{ lose: profitNumber < 0 }"></el-input>
<el-input v-model="profitNumber" readonly :class="{ lose: profitNumber < 0 }"
style="width: 180px;"></el-input>
</el-form-item>
<el-form-item label="单价">
<el-input v-model="detail.salePrice" readonly></el-input>
</el-form-item>
<el-form-item label="盈亏金额">
<el-input v-model="profitPrice" readonly :class="{ lose: profitNumber < 0 }"></el-input>
<el-input v-model="profitPrice" readonly :class="{ lose: profitNumber < 0 }"
style="width: 180px;"></el-input>
</el-form-item>
<el-form-item label="备注">
<el-input v-model="form.note" placeholder="请输入备注"></el-input>
<el-input v-model="form.note" placeholder="请输入备注" style="width: 300px;"></el-input>
</el-form-item>
<el-form-item>
<el-button @click="dialogVisible = false"> </el-button>
@ -44,14 +47,14 @@
{{ scope.row.price }}
</template>
</el-table-column>
<el-table-column label="库存" prop="stock"></el-table-column>
<el-table-column label="帐存库存" prop="stock"></el-table-column>
<el-table-column label="盈亏数量" prop="phaseNum"></el-table-column>
<el-table-column label="盈亏金额" prop="phasePrice">
<template v-slot="scope">
{{ scope.row.phasePrice }}
</template>
</el-table-column>
<el-table-column label="盘点数量" prop="inventoryStock"></el-table-column>
<el-table-column label="实际库存" prop="inventoryStock"></el-table-column>
<el-table-column label="盘点时间" prop="createTime"></el-table-column>
<el-table-column label="盘点备注" prop="note"></el-table-column>
</el-table>
@ -63,6 +66,7 @@
</template>
<script>
import { formatDecimal } from '@/utils'
import { tbProductStocktakin, tbProductStocktakinGet } from '@/api/invoicing'
export default {
data() {
@ -109,7 +113,7 @@ export default {
return this.form.stocktakinNum - this.detail.stockNumber
},
profitPrice() {
return (this.form.stocktakinNum - this.detail.stockNumber) * this.detail.salePrice
return formatDecimal((this.form.stocktakinNum - this.detail.stockNumber) * this.detail.salePrice)
}
},
methods: {
@ -130,7 +134,7 @@ export default {
});
this.getTableData()
} catch (error) {
this.dialogVisible = false
this.loading = false
console.log(error)
}
}
@ -168,7 +172,7 @@ export default {
name: this.searhForm.name,
skuId: this.searhForm.category,
productId: this.searhForm.productId,
sort: 'id',
sort: 'id,desc',
})
this.tableData.list = res.content
this.tableData.total = res.totalElements

View File

@ -117,7 +117,7 @@
</div>
</el-dialog>
<!-- 新增库存盘点 -->
<AddStockTakin ref="AddStockTakin" @success="getTableData" />
<AddStockTakin ref="AddStockTakin" @success="resetHandle" />
</div>
</template>