perf(views/frozen-sale): 下拉列表录入 & 自动填充信息
+ 支持下拉列表录入客户并根据选中信息自动填充其他关联信息
This commit is contained in:
@@ -99,7 +99,11 @@
|
||||
|
||||
<el-col :span="12">
|
||||
<el-form-item label="客户名称" prop="custName">
|
||||
<el-input v-model="form.custName" placeholder="请输入客户名称" />
|
||||
<!-- <el-input v-model="form.custName" placeholder="请输入客户名称" /> -->
|
||||
<el-select v-model="form.custName" placeholder="请选择客户" filterable clearable style="width: 100%"
|
||||
@change="handleCustomerChange">
|
||||
<el-option v-for="item in userDict" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
@@ -239,14 +243,14 @@
|
||||
|
||||
<script setup name="Sale">
|
||||
import { listSale, getSale, delSale, addSale, updateSale } from "@/api/frozen/sale"
|
||||
import { reactive } from "vue"
|
||||
import { onMounted, reactive } from "vue"
|
||||
import { ref } from "vue"
|
||||
import { getSaleCodeDict } from "../../../api/frozen/sale"
|
||||
import { computed } from "vue"
|
||||
import { listCustomer } from "../../../api/sale/customer/customer"
|
||||
import { computed } from 'vue'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { frozen_sale_item_type } = proxy.useDict('frozen_sale_item_type')
|
||||
|
||||
const saleList = ref([])
|
||||
const ddSaleItemList = ref([])
|
||||
const open = ref(false)
|
||||
@@ -316,6 +320,26 @@
|
||||
})
|
||||
}
|
||||
|
||||
// =============== 用户字典数据 =================
|
||||
const userDict = ref([])
|
||||
|
||||
const userMap = computed(() => {
|
||||
return new Map(userDict.value.map(u => [u.id, u]))
|
||||
})
|
||||
|
||||
const handleCustomerChange = (val) => {
|
||||
const user = userMap.value.get(val)
|
||||
|
||||
if (user) {
|
||||
form.value.custPhone = user.phone || ''
|
||||
form.value.custAddr = (user.province + user.city + user.district + user.address) || ''
|
||||
} else {
|
||||
form.value.custPhone = ''
|
||||
form.value.custAddr = ''
|
||||
}
|
||||
}
|
||||
|
||||
// =============== End =================
|
||||
// 取消按钮
|
||||
function cancel() {
|
||||
open.value = false
|
||||
@@ -465,4 +489,10 @@
|
||||
}, `sale_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
getList()
|
||||
onMounted(() => {
|
||||
// 加载客户列表
|
||||
listCustomer({ pageNum: 1, pageSize: 1000 }).then(r => {
|
||||
userDict.value = r.rows
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user