Commit da8838c0 by 李伟康

修复BUG

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