|
|
|
|
@ -17,9 +17,14 @@
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="form.customer_id"
|
|
|
|
|
v-load-more="customLoad"
|
|
|
|
|
filterable
|
|
|
|
|
placeholder="请选择客户"
|
|
|
|
|
style="width: 300px">
|
|
|
|
|
<el-option v-for="item in customers" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in customers"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
:label="item.name"
|
|
|
|
|
:value="Number(item.id)"></el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
@ -33,7 +38,7 @@
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
<el-select
|
|
|
|
|
:value="pickedProduct.name"
|
|
|
|
|
v-load-more="productLoad"
|
|
|
|
|
filterable
|
|
|
|
|
placeholder="请选择产品"
|
|
|
|
|
style="width: 300px"
|
|
|
|
|
@change="productPick">
|
|
|
|
|
@ -141,10 +146,14 @@
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="form.account_id"
|
|
|
|
|
v-load-more="productLoad"
|
|
|
|
|
filterable
|
|
|
|
|
placeholder="请选择结算对象"
|
|
|
|
|
style="width: 300px">
|
|
|
|
|
<el-option v-for="item in accounts" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in accountOptions"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
:label="item.name"
|
|
|
|
|
:value="Number(item.id)"></el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
@ -234,8 +243,9 @@ export default {
|
|
|
|
|
products: [],
|
|
|
|
|
productSelect: {
|
|
|
|
|
page: 1,
|
|
|
|
|
page_size: 10
|
|
|
|
|
page_size: 9999
|
|
|
|
|
},
|
|
|
|
|
accountOptions: [],
|
|
|
|
|
|
|
|
|
|
form: {
|
|
|
|
|
customer_id: '',
|
|
|
|
|
@ -296,6 +306,22 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
toNumberId(value) {
|
|
|
|
|
if (value === '' || value === null || value === undefined) {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
const id = Number(value)
|
|
|
|
|
return Number.isNaN(id) ? value : id
|
|
|
|
|
},
|
|
|
|
|
ensureSelectOption(list, item) {
|
|
|
|
|
if (!item || item.id == null || !Array.isArray(list)) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
const exists = list.some(i => Number(i.id) === Number(item.id))
|
|
|
|
|
if (!exists) {
|
|
|
|
|
list.unshift(item)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
customLoad() {
|
|
|
|
|
this.customSelect.page++
|
|
|
|
|
this.getCustomers()
|
|
|
|
|
@ -352,31 +378,36 @@ export default {
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.customers.push(...res.data.data)
|
|
|
|
|
res.data.data.forEach(item => {
|
|
|
|
|
const exists = this.customers.some(i => Number(i.id) === Number(item.id))
|
|
|
|
|
if (!exists) {
|
|
|
|
|
this.customers.push(item)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
productLoad() {
|
|
|
|
|
this.productSelect.page++
|
|
|
|
|
this.getProducts()
|
|
|
|
|
},
|
|
|
|
|
async getProducts() {
|
|
|
|
|
const res = await productList(this.productSelect, false)
|
|
|
|
|
if (res.data.length === 0) {
|
|
|
|
|
this.productSelect.page--
|
|
|
|
|
this.$message({
|
|
|
|
|
type: 'warning',
|
|
|
|
|
message: '没有跟多产品了'
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.products.push(...res.data)
|
|
|
|
|
const res = await productList({
|
|
|
|
|
page: 1,
|
|
|
|
|
page_size: 9999
|
|
|
|
|
}, false)
|
|
|
|
|
const list = Array.isArray(res.data) ? res.data : (res.data?.data || [])
|
|
|
|
|
this.products = list
|
|
|
|
|
this.ensureSelectOption(this.products, this.pickedProduct)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async getDetail(){
|
|
|
|
|
const res = await getForm(this.id)
|
|
|
|
|
this.$integrateData(this.form,res)
|
|
|
|
|
this.form.date = [res.start_date,res.end_date]
|
|
|
|
|
this.pickedProduct = res.product
|
|
|
|
|
this.form.customer_id = this.toNumberId(res.customer_id)
|
|
|
|
|
this.form.product_id = this.toNumberId(res.product_id)
|
|
|
|
|
this.form.product_type_id = this.toNumberId(res.product_type_id)
|
|
|
|
|
this.form.account_id = this.toNumberId(res.account_id)
|
|
|
|
|
this.pickedProduct = res.product || {}
|
|
|
|
|
this.ensureSelectOption(this.customers, res.customer)
|
|
|
|
|
this.ensureSelectOption(this.products, res.product)
|
|
|
|
|
this.ensureSelectOption(this.accountOptions, res.account)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
submit() {
|
|
|
|
|
@ -412,6 +443,8 @@ export default {
|
|
|
|
|
watch: {
|
|
|
|
|
isShow(val) {
|
|
|
|
|
if (val) {
|
|
|
|
|
this.customSelect.page = 1
|
|
|
|
|
this.accountOptions = [...(this.accounts || [])]
|
|
|
|
|
this.getCustomers()
|
|
|
|
|
this.getProducts()
|
|
|
|
|
|
|
|
|
|
@ -421,6 +454,7 @@ export default {
|
|
|
|
|
} else {
|
|
|
|
|
this.customers = []
|
|
|
|
|
this.products = []
|
|
|
|
|
this.accountOptions = []
|
|
|
|
|
this.id = ''
|
|
|
|
|
this.type = ''
|
|
|
|
|
this.$refs['dialog'].reset()
|
|
|
|
|
|