7
7
:rules =" formRules"
8
8
label-width =" 110px"
9
9
>
10
+ <el-row >
11
+ <el-col :span =" 12" >
12
+ <el-form-item label =" 还款期数" prop =" period" >
13
+ <el-input disabled v-model =" formData.period" placeholder =" 保存时自动生成" />
14
+ </el-form-item >
15
+ </el-col >
16
+ <el-col :span =" 12" >
17
+ <el-form-item label =" 负责人" prop =" ownerUserId" >
18
+ <el-select
19
+ v-model =" formData.ownerUserId"
20
+ :disabled =" formType !== 'create'"
21
+ class =" w-1/1"
22
+ >
23
+ <el-option
24
+ v-for =" item in userOptions"
25
+ :key =" item.id"
26
+ :label =" item.nickname"
27
+ :value =" item.id"
28
+ />
29
+ </el-select >
30
+ </el-form-item >
31
+ </el-col >
32
+ </el-row >
10
33
<el-row >
11
34
<el-col :span =" 12" >
12
35
<el-form-item label =" 客户名称" prop =" customerId" >
13
- <el-select v-model =" formData.customerId" class =" w-1/1" placeholder =" 请选择客户" >
36
+ <el-select
37
+ v-model =" formData.customerId"
38
+ :disabled =" formType !== 'create'"
39
+ class =" w-1/1"
40
+ filterable
41
+ @change =" handleCustomerChange"
42
+ placeholder =" 请选择客户"
43
+ >
14
44
<el-option
15
45
v-for =" item in customerList"
16
46
:key =" item.id"
24
54
<el-form-item label =" 合同名称" prop =" contractId" >
25
55
<el-select
26
56
v-model =" formData.contractId"
27
- :disabled =" !formData.customerId"
28
- class =" !w-100%"
57
+ :disabled =" formType !== 'create' || !formData.customerId"
58
+ class =" w-1/1"
59
+ filterable
29
60
placeholder =" 请选择合同"
30
61
>
31
62
<el-option
37
68
</el-select >
38
69
</el-form-item >
39
70
</el-col >
40
- <el-col :span =" 12" >
41
- <el-form-item label =" 负责人" prop =" ownerUserId" >
42
- <el-select v-model =" formData.ownerUserId" clearable placeholder =" 请输入负责人" >
43
- <el-option
44
- v-for =" item in userList"
45
- :key =" item.id"
46
- :label =" item.nickname"
47
- :value =" item.id"
48
- />
49
- </el-select >
50
- </el-form-item >
51
- </el-col >
71
+ </el-row >
72
+ <el-row >
52
73
<el-col :span =" 12" >
53
74
<el-form-item label =" 计划回款金额" prop =" price" >
54
75
<el-input-number
55
76
v-model =" formData.price"
56
77
class =" !w-100%"
57
78
controls-position =" right"
58
79
placeholder =" 请输入计划回款金额"
80
+ :min =" 0.01"
81
+ :precision =" 2"
59
82
/>
60
83
</el-form-item >
61
84
</el-col >
69
92
/>
70
93
</el-form-item >
71
94
</el-col >
95
+ </el-row >
96
+ <el-row >
72
97
<el-col :span =" 12" >
73
98
<el-form-item label =" 提前几天提醒" prop =" remindDays" >
74
99
<el-input-number
80
105
</el-form-item >
81
106
</el-col >
82
107
<el-col :span =" 12" >
83
- <el-form-item label =" 提醒日期" prop =" remindTime" >
84
- <el-date-picker
85
- v-model =" formData.remindTime"
86
- placeholder =" 选择提醒日期"
87
- type =" date"
88
- value-format =" x"
89
- />
108
+ <el-form-item label =" 回款方式" prop =" returnType" >
109
+ <el-select v-model =" formData.returnType" class =" w-1/1" placeholder =" 请选择回款方式" >
110
+ <el-option
111
+ v-for =" dict in getIntDictOptions(DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE)"
112
+ :key =" dict.value"
113
+ :label =" dict.label"
114
+ :value =" dict.value"
115
+ />
116
+ </el-select >
90
117
</el-form-item >
91
118
</el-col >
92
119
<el-col :span =" 24" >
93
120
<el-form-item label =" 备注" prop =" remark" >
94
- <el-input
95
- v-model =" formData.remark"
96
- :rows =" 3"
97
- placeholder =" 请输入备注"
98
- type =" textarea"
99
- />
121
+ <el-input v-model =" formData.remark" placeholder =" 请输入备注" type =" textarea" />
100
122
</el-form-item >
101
123
</el-col >
102
124
</el-row >
@@ -113,10 +135,11 @@ import * as UserApi from '@/api/system/user'
113
135
import * as CustomerApi from ' @/api/crm/customer'
114
136
import * as ContractApi from ' @/api/crm/contract'
115
137
import { useUserStore } from ' @/store/modules/user'
138
+ import { DICT_TYPE , getIntDictOptions } from ' @/utils/dict'
116
139
117
140
const { t } = useI18n () // 国际化
118
141
const message = useMessage () // 消息弹窗
119
- const userList = ref <UserApi .UserVO []>([]) // 用户列表
142
+ const userOptions = ref <UserApi .UserVO []>([]) // 用户列表
120
143
const dialogVisible = ref (false ) // 弹窗的是否展示
121
144
const dialogTitle = ref (' ' ) // 弹窗的标题
122
145
const formLoading = ref (false ) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
@@ -125,14 +148,14 @@ const formData = ref<ReceivablePlanApi.ReceivablePlanVO>({} as ReceivablePlanApi
125
148
const formRules = reactive ({
126
149
price: [{ required: true , message: ' 计划回款金额不能为空' , trigger: ' blur' }],
127
150
returnTime: [{ required: true , message: ' 计划回款日期不能为空' , trigger: ' blur' }],
128
- remindTime: [{ required: true , message: ' 提醒日期不能为空' , trigger: ' blur' }],
129
151
customerId: [{ required: true , message: ' 客户编号不能为空' , trigger: ' blur' }],
130
152
contractId: [{ required: true , message: ' 合同编号不能为空' , trigger: ' blur' }],
131
153
ownerUserId: [{ required: true , message: ' 负责人不能为空' , trigger: ' blur' }]
132
154
})
133
155
const formRef = ref () // 表单 Ref
134
156
const customerList = ref <CustomerApi .CustomerVO []>([]) // 客户列表
135
157
const contractList = ref <ContractApi .ContractVO []>([]) // 合同列表
158
+
136
159
/** 打开弹窗 */
137
160
const open = async (type : string , id ? : number ) => {
138
161
dialogVisible .value = true
@@ -148,9 +171,8 @@ const open = async (type: string, id?: number) => {
148
171
formLoading .value = false
149
172
}
150
173
}
151
-
152
174
// 获得用户列表
153
- userList .value = await UserApi .getSimpleUserList ()
175
+ userOptions .value = await UserApi .getSimpleUserList ()
154
176
// 获得客户列表
155
177
customerList .value = await CustomerApi .getCustomerSimpleList ()
156
178
// 默认新建时选中自己
@@ -160,22 +182,6 @@ const open = async (type: string, id?: number) => {
160
182
}
161
183
defineExpose ({ open }) // 提供 open 方法,用于打开弹窗
162
184
163
- const getContractList = async (customerId : number ) => {
164
- contractList .value = await ContractApi .getCrmContractSimpleListByCustomerId (customerId )
165
- }
166
- watch (
167
- () => formData .value .customerId ,
168
- (newVal ) => {
169
- if (! newVal ) {
170
- return
171
- }
172
- getContractList (newVal )
173
- },
174
- {
175
- immediate: true
176
- }
177
- )
178
-
179
185
/** 提交表单 */
180
186
const emit = defineEmits ([' success' ]) // 定义 success 事件,用于操作成功后的回调
181
187
const submitForm = async () => {
@@ -207,4 +213,15 @@ const resetForm = () => {
207
213
formData .value = {} as ReceivablePlanApi .ReceivablePlanVO
208
214
formRef .value ?.resetFields ()
209
215
}
216
+
217
+ /** 处理切换客户 */
218
+ const handleCustomerChange = async (customerId : number ) => {
219
+ // 重置合同编号
220
+ formData .value .contractId = undefined
221
+ // 获得合同列表
222
+ if (customerId ) {
223
+ contractList .value = []
224
+ contractList .value = await ContractApi .getContractSimpleList (customerId )
225
+ }
226
+ }
210
227
</script >
0 commit comments