|
@@ -57,23 +57,23 @@
|
|
|
bordered>
|
|
|
<!-- 售价 -->
|
|
|
<template slot="price" slot-scope="text, record">
|
|
|
- <a-input-number
|
|
|
+ <editable-cell
|
|
|
+ :text="record.price"
|
|
|
id="salesEdit-price"
|
|
|
- :value="record.price"
|
|
|
- :precision="0"
|
|
|
- :min="0"
|
|
|
:max="999999"
|
|
|
- placeholder="请输入" />
|
|
|
+ :min="0"
|
|
|
+ :precision="2"
|
|
|
+ @change="onCellChange(record.id, 'price', $event)" />
|
|
|
</template>
|
|
|
<!-- 销售数量 -->
|
|
|
<template slot="salesNums" slot-scope="text, record">
|
|
|
- <a-input-number
|
|
|
+ <editable-cell
|
|
|
+ :text="record.qty"
|
|
|
id="salesEdit-salesNums"
|
|
|
- :value="record.qty"
|
|
|
- :precision="0"
|
|
|
- :min="0"
|
|
|
:max="999999"
|
|
|
- placeholder="请输入" />
|
|
|
+ :min="1"
|
|
|
+ :precision="0"
|
|
|
+ @change="onCellChange(record.id, 'qty', $event)" />
|
|
|
</template>
|
|
|
<!-- 操作 -->
|
|
|
<template slot="action" slot-scope="text, record">
|
|
@@ -91,10 +91,11 @@ import { STable, VSelect } from '@/components'
|
|
|
import queryPart from './queryPart.vue'
|
|
|
import chooseCustomModal from './chooseCustomModal.vue'
|
|
|
import { salesDetail } from '@/api/sales'
|
|
|
+import EditableCell from '@/views/common/editInput.js'
|
|
|
import { salesDetailList, salesDetailInsert, salesDetailUpdatePrice, salesDetailUpdateQty, salesDetailDel, salesDetailDelAll } from '@/api/salesDetail'
|
|
|
export default {
|
|
|
name: 'SalesDetail',
|
|
|
- components: { STable, VSelect, queryPart, chooseCustomModal },
|
|
|
+ components: { STable, VSelect, queryPart, chooseCustomModal, EditableCell },
|
|
|
data () {
|
|
|
return {
|
|
|
orderId: null, // 销售单id
|
|
@@ -133,21 +134,45 @@ export default {
|
|
|
data.list[i].no = no + i + 1
|
|
|
}
|
|
|
this.disabled = false
|
|
|
+ this.dataSource = data.list
|
|
|
return data
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- onCellChange (key, dataIndex, value) {
|
|
|
- console.log(key, dataIndex, value)
|
|
|
- console.log(this.dataSource)
|
|
|
+ onCellChange (id, key, value) {
|
|
|
+ console.log(id, key, value)
|
|
|
const dataSource = [...this.dataSource]
|
|
|
- const target = dataSource.find(item => item.id === key)
|
|
|
- if (target) {
|
|
|
- target[dataIndex] = Number(value)
|
|
|
+ const row = dataSource.find(item => item.id === id)
|
|
|
+ if (row) {
|
|
|
+ row[key] = Number(value)
|
|
|
this.dataSource = dataSource
|
|
|
}
|
|
|
+ // 修改价格
|
|
|
+ if (key == 'price') {
|
|
|
+ salesDetailUpdatePrice({
|
|
|
+ salesBillSn: row.salesBillSn,
|
|
|
+ productSn: row.productSn,
|
|
|
+ price: row.price
|
|
|
+ }).then(res => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ this.$refs.table.refresh(true)
|
|
|
+ }
|
|
|
+ this.$message.info(res.message)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (key == 'qty') {
|
|
|
+ salesDetailUpdateQty({
|
|
|
+ id: row.id,
|
|
|
+ qty: row.qty
|
|
|
+ }).then(res => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ this.$refs.table.refresh(true)
|
|
|
+ }
|
|
|
+ this.$message.info(res.message)
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
handleSearch () {
|
|
|
|