fix: 移动端新增客户表单与后端字段对齐
- 新增联系人(contact)字段,设为必填 - 客户编码(customerCode)设为必填 - 移除后端不支持的字段:简称、客户等级、所属行业 - 表单字段与后端CustomerCreateDTO保持一致
This commit is contained in:
parent
965d98cab5
commit
011a6bfb3f
@ -9,6 +9,8 @@
|
|||||||
name="customerCode"
|
name="customerCode"
|
||||||
label="客户编码"
|
label="客户编码"
|
||||||
placeholder="请输入客户编码"
|
placeholder="请输入客户编码"
|
||||||
|
:rules="[{ required: true, message: '请输入客户编码' }]"
|
||||||
|
required
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<van-field
|
<van-field
|
||||||
@ -21,10 +23,12 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<van-field
|
<van-field
|
||||||
v-model="form.customerShort"
|
v-model="form.contact"
|
||||||
name="customerShort"
|
name="contact"
|
||||||
label="简称"
|
label="联系人"
|
||||||
placeholder="请输入客户简称"
|
placeholder="请输入联系人"
|
||||||
|
:rules="[{ required: true, message: '请输入联系人' }]"
|
||||||
|
required
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<van-field
|
<van-field
|
||||||
@ -43,23 +47,6 @@
|
|||||||
placeholder="请输入邮箱"
|
placeholder="请输入邮箱"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<van-field
|
|
||||||
v-model="levelText"
|
|
||||||
is-link
|
|
||||||
readonly
|
|
||||||
name="level"
|
|
||||||
label="客户等级"
|
|
||||||
placeholder="请选择等级"
|
|
||||||
@click="showLevelPicker = true"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<van-field
|
|
||||||
v-model="form.industry"
|
|
||||||
name="industry"
|
|
||||||
label="所属行业"
|
|
||||||
placeholder="请输入所属行业"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<van-field
|
<van-field
|
||||||
v-model="form.address"
|
v-model="form.address"
|
||||||
name="address"
|
name="address"
|
||||||
@ -84,73 +71,50 @@
|
|||||||
</van-button>
|
</van-button>
|
||||||
</div>
|
</div>
|
||||||
</van-form>
|
</van-form>
|
||||||
|
|
||||||
<!-- 等级选择器 -->
|
|
||||||
<van-popup v-model:show="showLevelPicker" position="bottom" round>
|
|
||||||
<van-picker
|
|
||||||
:columns="levelOptions"
|
|
||||||
@confirm="onLevelConfirm"
|
|
||||||
@cancel="showLevelPicker = false"
|
|
||||||
/>
|
|
||||||
</van-popup>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { showFailToast, showSuccessToast } from 'vant'
|
import { showFailToast, showSuccessToast } from 'vant'
|
||||||
import { createCustomer } from '@/api'
|
import { createCustomer } from '@/api'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const submitting = ref(false)
|
const submitting = ref(false)
|
||||||
const showLevelPicker = ref(false)
|
|
||||||
|
|
||||||
const form = ref({
|
const form = ref({
|
||||||
customerCode: '',
|
customerCode: '',
|
||||||
customerName: '',
|
customerName: '',
|
||||||
customerShort: '',
|
contact: '',
|
||||||
phone: '',
|
phone: '',
|
||||||
email: '',
|
email: '',
|
||||||
level: 'C',
|
|
||||||
industry: '',
|
|
||||||
address: '',
|
address: '',
|
||||||
remark: ''
|
remark: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
const levelOptions = [
|
|
||||||
{ text: 'A类(重点客户)', value: 'A' },
|
|
||||||
{ text: 'B类(一般客户)', value: 'B' },
|
|
||||||
{ text: 'C类(普通客户)', value: 'C' },
|
|
||||||
{ text: 'D类(潜在客户)', value: 'D' }
|
|
||||||
]
|
|
||||||
|
|
||||||
const levelText = computed(() => {
|
|
||||||
const item = levelOptions.find(l => l.value === form.value.level)
|
|
||||||
return item?.text || ''
|
|
||||||
})
|
|
||||||
|
|
||||||
const onLevelConfirm = ({ selectedOptions }: any) => {
|
|
||||||
form.value.level = selectedOptions[0].value
|
|
||||||
showLevelPicker.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
|
if (!form.value.customerCode) {
|
||||||
|
showFailToast('请输入客户编码')
|
||||||
|
return
|
||||||
|
}
|
||||||
if (!form.value.customerName) {
|
if (!form.value.customerName) {
|
||||||
showFailToast('请输入客户名称')
|
showFailToast('请输入客户名称')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (!form.value.contact) {
|
||||||
|
showFailToast('请输入联系人')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
submitting.value = true
|
submitting.value = true
|
||||||
try {
|
try {
|
||||||
await createCustomer({
|
await createCustomer({
|
||||||
customerCode: form.value.customerCode,
|
customerCode: form.value.customerCode,
|
||||||
customerName: form.value.customerName,
|
customerName: form.value.customerName,
|
||||||
customerShort: form.value.customerShort,
|
contact: form.value.contact,
|
||||||
phone: form.value.phone,
|
phone: form.value.phone,
|
||||||
email: form.value.email,
|
email: form.value.email,
|
||||||
level: form.value.level,
|
|
||||||
industry: form.value.industry,
|
|
||||||
address: form.value.address,
|
address: form.value.address,
|
||||||
remark: form.value.remark
|
remark: form.value.remark
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user