feat: 移动端新增项目添加项目编码和项目类型字段
This commit is contained in:
parent
ff9f4d05ad
commit
f87ee0b51d
@ -4,6 +4,15 @@
|
|||||||
|
|
||||||
<van-form @submit="onSubmit">
|
<van-form @submit="onSubmit">
|
||||||
<van-cell-group inset>
|
<van-cell-group inset>
|
||||||
|
<van-field
|
||||||
|
v-model="form.projectCode"
|
||||||
|
name="projectCode"
|
||||||
|
label="项目编码"
|
||||||
|
placeholder="请输入项目编码"
|
||||||
|
:rules="[{ required: true, message: '请输入项目编码' }]"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
|
||||||
<van-field
|
<van-field
|
||||||
v-model="form.projectName"
|
v-model="form.projectName"
|
||||||
name="projectName"
|
name="projectName"
|
||||||
@ -20,20 +29,22 @@
|
|||||||
name="customer"
|
name="customer"
|
||||||
label="关联客户"
|
label="关联客户"
|
||||||
placeholder="请选择客户"
|
placeholder="请选择客户"
|
||||||
|
:rules="[{ required: true, message: '请选择客户' }]"
|
||||||
|
required
|
||||||
@click="showCustomerPicker = true"
|
@click="showCustomerPicker = true"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<van-field
|
<van-field
|
||||||
v-model="form.contractAmount"
|
v-model="projectTypeText"
|
||||||
name="contractAmount"
|
is-link
|
||||||
label="合同金额"
|
readonly
|
||||||
type="number"
|
name="projectType"
|
||||||
placeholder="请输入合同金额"
|
label="项目类型"
|
||||||
>
|
placeholder="请选择类型"
|
||||||
<template #button>
|
:rules="[{ required: true, message: '请选择项目类型' }]"
|
||||||
<span>元</span>
|
required
|
||||||
</template>
|
@click="showTypePicker = true"
|
||||||
</van-field>
|
/>
|
||||||
|
|
||||||
<van-field
|
<van-field
|
||||||
v-model="form.budgetAmount"
|
v-model="form.budgetAmount"
|
||||||
@ -58,23 +69,30 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<van-field
|
<van-field
|
||||||
v-model="statusText"
|
v-model="form.endDate"
|
||||||
is-link
|
is-link
|
||||||
readonly
|
readonly
|
||||||
name="status"
|
name="endDate"
|
||||||
label="项目状态"
|
label="结束日期"
|
||||||
placeholder="请选择状态"
|
placeholder="请选择日期"
|
||||||
@click="showStatusPicker = true"
|
@click="showEndPicker = true"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<van-field
|
<van-field
|
||||||
v-model="form.description"
|
v-model="form.projectManager"
|
||||||
name="description"
|
name="projectManager"
|
||||||
label="项目描述"
|
label="项目经理"
|
||||||
|
placeholder="请输入项目经理"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<van-field
|
||||||
|
v-model="form.remark"
|
||||||
|
name="remark"
|
||||||
|
label="备注"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
rows="2"
|
rows="2"
|
||||||
autosize
|
autosize
|
||||||
placeholder="请输入项目描述"
|
placeholder="请输入备注"
|
||||||
/>
|
/>
|
||||||
</van-cell-group>
|
</van-cell-group>
|
||||||
|
|
||||||
@ -85,6 +103,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</van-form>
|
</van-form>
|
||||||
|
|
||||||
|
<!-- 项目类型选择器 -->
|
||||||
|
<van-popup v-model:show="showTypePicker" position="bottom" round>
|
||||||
|
<van-picker
|
||||||
|
:columns="projectTypeOptions"
|
||||||
|
@confirm="onTypeConfirm"
|
||||||
|
@cancel="showTypePicker = false"
|
||||||
|
/>
|
||||||
|
</van-popup>
|
||||||
|
|
||||||
<!-- 开始日期选择器 -->
|
<!-- 开始日期选择器 -->
|
||||||
<van-popup v-model:show="showStartPicker" position="bottom" round>
|
<van-popup v-model:show="showStartPicker" position="bottom" round>
|
||||||
<van-date-picker
|
<van-date-picker
|
||||||
@ -94,12 +121,12 @@
|
|||||||
/>
|
/>
|
||||||
</van-popup>
|
</van-popup>
|
||||||
|
|
||||||
<!-- 状态选择器 -->
|
<!-- 结束日期选择器 -->
|
||||||
<van-popup v-model:show="showStatusPicker" position="bottom" round>
|
<van-popup v-model:show="showEndPicker" position="bottom" round>
|
||||||
<van-picker
|
<van-date-picker
|
||||||
:columns="statusOptions"
|
v-model="selectedEndDate"
|
||||||
@confirm="onStatusConfirm"
|
@confirm="onEndDateConfirm"
|
||||||
@cancel="showStatusPicker = false"
|
@cancel="showEndPicker = false"
|
||||||
/>
|
/>
|
||||||
</van-popup>
|
</van-popup>
|
||||||
|
|
||||||
@ -123,18 +150,21 @@ import { createProject, getCustomerList } from '@/api'
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const submitting = ref(false)
|
const submitting = ref(false)
|
||||||
const showStartPicker = ref(false)
|
const showStartPicker = ref(false)
|
||||||
const showStatusPicker = ref(false)
|
const showEndPicker = ref(false)
|
||||||
|
const showTypePicker = ref(false)
|
||||||
const showCustomerPicker = ref(false)
|
const showCustomerPicker = ref(false)
|
||||||
|
|
||||||
const form = ref({
|
const form = ref({
|
||||||
|
projectCode: '',
|
||||||
projectName: '',
|
projectName: '',
|
||||||
customerId: null as number | null,
|
customerId: null as number | null,
|
||||||
customerName: '',
|
customerName: '',
|
||||||
contractAmount: '',
|
projectType: '',
|
||||||
budgetAmount: '',
|
budgetAmount: '',
|
||||||
startDate: '',
|
startDate: '',
|
||||||
status: 'preparing',
|
endDate: '',
|
||||||
description: ''
|
projectManager: '',
|
||||||
|
remark: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
const selectedStartDate = ref([
|
const selectedStartDate = ref([
|
||||||
@ -143,29 +173,40 @@ const selectedStartDate = ref([
|
|||||||
new Date().getDate().toString().padStart(2, '0')
|
new Date().getDate().toString().padStart(2, '0')
|
||||||
])
|
])
|
||||||
|
|
||||||
const statusOptions = [
|
const selectedEndDate = ref([
|
||||||
{ text: '筹备中', value: 'preparing' },
|
new Date().getFullYear().toString(),
|
||||||
{ text: '进行中', value: 'ongoing' },
|
(new Date().getMonth() + 1).toString().padStart(2, '0'),
|
||||||
{ text: '已完成', value: 'completed' },
|
new Date().getDate().toString().padStart(2, '0')
|
||||||
{ text: '已归档', value: 'archived' },
|
])
|
||||||
{ text: '已取消', value: 'cancelled' }
|
|
||||||
|
const projectTypeOptions = [
|
||||||
|
{ text: '开发项目', value: '开发项目' },
|
||||||
|
{ text: '运维项目', value: '运维项目' },
|
||||||
|
{ text: '咨询项目', value: '咨询项目' },
|
||||||
|
{ text: '集成项目', value: '集成项目' },
|
||||||
|
{ text: '其他项目', value: '其他项目' }
|
||||||
]
|
]
|
||||||
|
|
||||||
const statusText = computed(() => {
|
const projectTypeText = computed(() => {
|
||||||
const item = statusOptions.find(s => s.value === form.value.status)
|
const item = projectTypeOptions.find(t => t.value === form.value.projectType)
|
||||||
return item?.text || ''
|
return item?.text || ''
|
||||||
})
|
})
|
||||||
|
|
||||||
const customerOptions = ref<{ text: string; value: number }[]>([])
|
const customerOptions = ref<{ text: string; value: number }[]>([])
|
||||||
|
|
||||||
|
const onTypeConfirm = ({ selectedOptions }: any) => {
|
||||||
|
form.value.projectType = selectedOptions[0].value
|
||||||
|
showTypePicker.value = false
|
||||||
|
}
|
||||||
|
|
||||||
const onStartDateConfirm = ({ selectedValues }: any) => {
|
const onStartDateConfirm = ({ selectedValues }: any) => {
|
||||||
form.value.startDate = selectedValues.join('-')
|
form.value.startDate = selectedValues.join('-')
|
||||||
showStartPicker.value = false
|
showStartPicker.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const onStatusConfirm = ({ selectedOptions }: any) => {
|
const onEndDateConfirm = ({ selectedValues }: any) => {
|
||||||
form.value.status = selectedOptions[0].value
|
form.value.endDate = selectedValues.join('-')
|
||||||
showStatusPicker.value = false
|
showEndPicker.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const onCustomerConfirm = ({ selectedOptions }: any) => {
|
const onCustomerConfirm = ({ selectedOptions }: any) => {
|
||||||
@ -187,21 +228,35 @@ const loadOptions = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
|
if (!form.value.projectCode) {
|
||||||
|
showFailToast('请输入项目编码')
|
||||||
|
return
|
||||||
|
}
|
||||||
if (!form.value.projectName) {
|
if (!form.value.projectName) {
|
||||||
showFailToast('请输入项目名称')
|
showFailToast('请输入项目名称')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (!form.value.customerId) {
|
||||||
|
showFailToast('请选择客户')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!form.value.projectType) {
|
||||||
|
showFailToast('请选择项目类型')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
submitting.value = true
|
submitting.value = true
|
||||||
try {
|
try {
|
||||||
await createProject({
|
await createProject({
|
||||||
|
projectCode: form.value.projectCode,
|
||||||
projectName: form.value.projectName,
|
projectName: form.value.projectName,
|
||||||
customerId: form.value.customerId,
|
customerId: form.value.customerId,
|
||||||
contractAmount: form.value.contractAmount ? parseFloat(form.value.contractAmount) : null,
|
projectType: form.value.projectType,
|
||||||
budgetAmount: form.value.budgetAmount ? parseFloat(form.value.budgetAmount) : null,
|
budgetAmount: form.value.budgetAmount ? parseFloat(form.value.budgetAmount) : null,
|
||||||
startDate: form.value.startDate || null,
|
startDate: form.value.startDate || null,
|
||||||
status: form.value.status,
|
endDate: form.value.endDate || null,
|
||||||
description: form.value.description
|
projectManager: form.value.projectManager || null,
|
||||||
|
remark: form.value.remark || null
|
||||||
})
|
})
|
||||||
showSuccessToast('提交成功')
|
showSuccessToast('提交成功')
|
||||||
router.back()
|
router.back()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user