Commit da8838c0 by 李伟康

修复BUG

1 parent c45537b0
......@@ -25,33 +25,33 @@
slot="IMG"
slot-scope="scope"
>
<el-popover
placement="top"
trigger="hover"
<el-popover
placement="top"
trigger="hover"
>
<img
class="img-plus"
:src="scope.scope.aliasUrl"
/>
<div
slot="reference"
class="img"
>
<img
class="img-plus"
:src="scope.scope.aliasUrl"
/>
<div
slot="reference"
class="img"
>
<img :src="scope.scope.aliasUrl">
<div class="mask">
<img
src="@/assets/images/icon-edit.png"
class="icon"
>
<input
type="file"
:ref="`file-${scope.scope.id}`"
accept="image/png, image/jpeg, image/gif, image/jpg"
@change="uploadImg($event, scope.scope)"
/>
</div>
<img :src="scope.scope.aliasUrl">
<div class="mask">
<img
src="@/assets/images/icon-edit.png"
class="icon"
>
<input
type="file"
:ref="`file-${scope.scope.id}`"
accept="image/png, image/jpeg, image/gif, image/jpg"
@change="uploadImg($event, scope.scope)"
/>
</div>
</el-popover>
</div>
</el-popover>
</template>
<template
......@@ -59,9 +59,10 @@
slot-scope="scope"
>
<el-input
v-model="scope.scope.salesPrice"
v-model="scope.scope.InputPrice"
size="small"
@blur="handleBlur(scope.scope)"
maxlength="6"
></el-input>
</template>
<template
......@@ -136,8 +137,10 @@ export default {
},
{
label: '库存',
prop: 'stock',
minWidth: 100
minWidth: 100,
formatter: cellValue => {
return cellValue.stock - cellValue.usedStock
}
},
{
label: '销售量',
......@@ -173,7 +176,9 @@ export default {
...searchForm
}) || {}
list && list.map(e => {
e.salesPrice = e.salesPrice ? NP.divide(e.salesPrice, 100).toFixed(2) : ''
let price = e.salesPrice ? NP.divide(e.salesPrice, 100).toFixed(2) : ''
e.InputPrice = price
e.salesPrice = price
})
this.tableData = list || []
this.tableTotal = total || 0
......@@ -188,6 +193,10 @@ export default {
},
handleReset () {
this.searchForm = this.$options.data.call(this).searchForm
this.$refs.listRef.page = {
pageNum: 1,
pageSize: 10
}
this.handleSearch()
},
async change (e, row) {
......@@ -202,22 +211,25 @@ export default {
})
},
handleBlur (row) {
let val = row.salesPrice?.trim().replace(/^0+/, '')
if (val) {
if (!/^\d+(\.\d+)?$/.test(val)) val = ''
val = `${Math.abs(val)}`
if (val.startsWith('.')) row.salesPrice = '0' + val
if (val < Number(row.sellPrice)) val = `${row.sellPrice}`
if (val > 1000) val = '999.99'
const [integerPart, decimalPart] = val.split('.')
if (decimalPart && decimalPart.length > 2) row.salesPrice = `${integerPart || '0'}.${decimalPart.slice(0, 2)}`
else row.salesPrice = val
} else row.salesPrice = ''
if (row.salesPrice) this.update({
type: 1,
id: row.id,
salesPrice: NP.times(row.salesPrice, 100)
})
let { salesPrice, InputPrice, sellPrice } = row
if (!InputPrice) return
try {
if (InputPrice) {
if (InputPrice.startsWith('.')) InputPrice = '0' + InputPrice
if (Number(InputPrice) < Number(sellPrice)) throw '销售价需大于等于成本价'
if (InputPrice > 1000) InputPrice = 999.99
InputPrice = Number(InputPrice).toFixed(2)
} else throw '销售价需大于等于成本价'
if(!/^\d+(\.\d+)?$/.test(InputPrice)) throw '请输入数字'
if (InputPrice != Number(salesPrice)) this.update({
type: 1,
id: row.id,
salesPrice: NP.times(InputPrice, 100)
})
} catch (error) {
row.InputPrice = salesPrice ? salesPrice : ''
if (error) this.$message.error(error)
}
},
async uploadImg (e, target) {
const { url } = await uploadImg(e, this)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!