Showing
8 changed files
with
798 additions
and
70 deletions
| @@ -193,4 +193,24 @@ export function getContractApi(id) { | @@ -193,4 +193,24 @@ export function getContractApi(id) { | ||
| 193 | region | 193 | region |
| 194 | }) | 194 | }) |
| 195 | } | 195 | } |
| 196 | +// 获取备注 | ||
| 197 | +export function getCustomerRemarks(customerId) { | ||
| 198 | + return request({ | ||
| 199 | + url: `${baseUrl}/contractDistributorStandard/getCustomerRemarks`, | ||
| 200 | + method: 'get', | ||
| 201 | + params: { customerId }, | ||
| 202 | + contentType: ContentTypeEnum.JSON, | ||
| 203 | + region | ||
| 204 | + }) | ||
| 205 | +} | ||
| 206 | +// 获取具体质量要求 | ||
| 207 | +export function getCustomerSpecificQualityRequirements(params) { | ||
| 208 | + return request({ | ||
| 209 | + url: `${baseUrl}/contractDistributorStandard/getCustomerSpecificQualityRequirements`, | ||
| 210 | + method: 'get', | ||
| 211 | + params, | ||
| 212 | + contentType: ContentTypeEnum.FORM_URLENCODED, | ||
| 213 | + region | ||
| 214 | + }) | ||
| 215 | +} | ||
| 196 | 216 |
| @@ -123,9 +123,15 @@ | @@ -123,9 +123,15 @@ | ||
| 123 | <uni-easyinput v-model="form.specialInstructions" placeholder="请输入特别说明" :inputBorder="false" /> | 123 | <uni-easyinput v-model="form.specialInstructions" placeholder="请输入特别说明" :inputBorder="false" /> |
| 124 | </template> | 124 | </template> |
| 125 | </uni-list-item> | 125 | </uni-list-item> |
| 126 | + <uni-list-item v-if="this.customerRemarks.length" class="select-item" :class="defaultRemark ? 'is-filled' : 'is-empty'" clickable | ||
| 127 | + @click="openSheet('historyRemarks')" :rightText="defaultRemark || '请选择'" showArrow> | ||
| 128 | + <template v-slot:body> | ||
| 129 | + <view class="item-title"><text>历史备注</text></view> | ||
| 130 | + </template> | ||
| 131 | + </uni-list-item> | ||
| 126 | <uni-list-item title="备注"> | 132 | <uni-list-item title="备注"> |
| 127 | <template v-slot:footer> | 133 | <template v-slot:footer> |
| 128 | - <uni-easyinput v-model="form.remarks" placeholder="请输入备注" :inputBorder="false" /> | 134 | + <uni-easyinput type="textarea" v-model="form.remarks" placeholder="请输入备注" :inputBorder="false" /> |
| 129 | </template> | 135 | </template> |
| 130 | </uni-list-item> | 136 | </uni-list-item> |
| 131 | <view class="quality"> | 137 | <view class="quality"> |
| @@ -134,32 +140,32 @@ | @@ -134,32 +140,32 @@ | ||
| 134 | </view> | 140 | </view> |
| 135 | <uni-list-item title="件重条头"> | 141 | <uni-list-item title="件重条头"> |
| 136 | <template v-slot:footer> | 142 | <template v-slot:footer> |
| 137 | - <uni-easyinput v-model="form.pieceWeightHead" placeholder="请输入" :inputBorder="false" /> | 143 | + <uni-easyinput type="textarea" v-model="form.pieceWeightHead" placeholder="请输入" :inputBorder="false" /> |
| 138 | </template> | 144 | </template> |
| 139 | </uni-list-item> | 145 | </uni-list-item> |
| 140 | <uni-list-item title="表面"> | 146 | <uni-list-item title="表面"> |
| 141 | <template v-slot:footer> | 147 | <template v-slot:footer> |
| 142 | - <uni-easyinput v-model="form.surface" placeholder="请输入" :inputBorder="false" /> | 148 | + <uni-easyinput type="textarea" v-model="form.surface" placeholder="请输入" :inputBorder="false" /> |
| 143 | </template> | 149 | </template> |
| 144 | </uni-list-item> | 150 | </uni-list-item> |
| 145 | <uni-list-item title="公差"> | 151 | <uni-list-item title="公差"> |
| 146 | <template v-slot:footer> | 152 | <template v-slot:footer> |
| 147 | - <uni-easyinput v-model="form.tolerance" placeholder="请输入" :inputBorder="false" /> | 153 | + <uni-easyinput type="textarea" v-model="form.tolerance" placeholder="请输入" :inputBorder="false" /> |
| 148 | </template> | 154 | </template> |
| 149 | </uni-list-item> | 155 | </uni-list-item> |
| 150 | <uni-list-item title="性能"> | 156 | <uni-list-item title="性能"> |
| 151 | <template v-slot:footer> | 157 | <template v-slot:footer> |
| 152 | - <uni-easyinput v-model="form.performance" placeholder="请输入" :inputBorder="false" /> | 158 | + <uni-easyinput type="textarea" v-model="form.performance" placeholder="请输入" :inputBorder="false" /> |
| 153 | </template> | 159 | </template> |
| 154 | </uni-list-item> | 160 | </uni-list-item> |
| 155 | <uni-list-item title="成分"> | 161 | <uni-list-item title="成分"> |
| 156 | <template v-slot:footer> | 162 | <template v-slot:footer> |
| 157 | - <uni-easyinput v-model="form.component" placeholder="请输入" :inputBorder="false" /> | 163 | + <uni-easyinput type="textarea" v-model="form.component" placeholder="请输入" :inputBorder="false" /> |
| 158 | </template> | 164 | </template> |
| 159 | </uni-list-item> | 165 | </uni-list-item> |
| 160 | <uni-list-item title="包装"> | 166 | <uni-list-item title="包装"> |
| 161 | <template v-slot:footer> | 167 | <template v-slot:footer> |
| 162 | - <uni-easyinput v-model="form.packaging" placeholder="请输入" :inputBorder="false" /> | 168 | + <uni-easyinput type="textarea" v-model="form.packaging" placeholder="请输入" :inputBorder="false" /> |
| 163 | </template> | 169 | </template> |
| 164 | </uni-list-item> | 170 | </uni-list-item> |
| 165 | </uni-list> | 171 | </uni-list> |
| @@ -210,7 +216,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | @@ -210,7 +216,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | ||
| 210 | import RelateSelectSheet from '@/components/relate-select/index.vue' | 216 | import RelateSelectSheet from '@/components/relate-select/index.vue' |
| 211 | import ProductRel from './productRel.vue' | 217 | import ProductRel from './productRel.vue' |
| 212 | import CitySelector from '@/components/city-selector/index.vue' | 218 | import CitySelector from '@/components/city-selector/index.vue' |
| 213 | -import { getRetailCodeApi, createContractApi } from '@/api/contract' | 219 | +import { getRetailCodeApi, createContractApi, getCustomerRemarks,getCustomerSpecificQualityRequirements } from '@/api/contract' |
| 214 | import { getDicByCodes } from '@/utils/dic' | 220 | import { getDicByCodes } from '@/utils/dic' |
| 215 | import { formatCurrencyToChinese } from '@/utils/common' | 221 | import { formatCurrencyToChinese } from '@/utils/common' |
| 216 | import { workshopQueryApi } from '@/api/devManage' | 222 | import { workshopQueryApi } from '@/api/devManage' |
| @@ -243,6 +249,13 @@ export default { | @@ -243,6 +249,13 @@ export default { | ||
| 243 | destinationLabel: '', | 249 | destinationLabel: '', |
| 244 | workshopIdName: '', | 250 | workshopIdName: '', |
| 245 | workshopId: '', | 251 | workshopId: '', |
| 252 | + remarks: '', | ||
| 253 | + component: '', | ||
| 254 | + packaging: '', | ||
| 255 | + performance: '', | ||
| 256 | + pieceWeightHead: '', | ||
| 257 | + surface: '', | ||
| 258 | + tolerance: '', | ||
| 246 | }, | 259 | }, |
| 247 | supplierList: [], | 260 | supplierList: [], |
| 248 | specialTermsList: [], | 261 | specialTermsList: [], |
| @@ -255,6 +268,8 @@ export default { | @@ -255,6 +268,8 @@ export default { | ||
| 255 | sumTotal: 0, | 268 | sumTotal: 0, |
| 256 | productLineList: [], | 269 | productLineList: [], |
| 257 | productList: [], | 270 | productList: [], |
| 271 | + customerRemarks: [], | ||
| 272 | + defaultRemark: '', | ||
| 258 | } | 273 | } |
| 259 | }, | 274 | }, |
| 260 | created() { | 275 | created() { |
| @@ -268,7 +283,85 @@ export default { | @@ -268,7 +283,85 @@ export default { | ||
| 268 | } | 283 | } |
| 269 | }) | 284 | }) |
| 270 | }, | 285 | }, |
| 286 | + watch: { | ||
| 287 | + 'form.buyer': { | ||
| 288 | + handler(newVal, oldVal) { | ||
| 289 | + if (newVal) { | ||
| 290 | + getCustomerRemarks(newVal).then(res => { | ||
| 291 | + const remarksData = res.data || []; | ||
| 292 | + this.customerRemarks = remarksData.map((item, index) => ({ | ||
| 293 | + label: `客户备注${index + 1}`, | ||
| 294 | + value: item, | ||
| 295 | + })); | ||
| 296 | + if (remarksData.length > 0) { | ||
| 297 | + this.defaultRemark = this.customerRemarks[0].label || ''; | ||
| 298 | + this.form.remarks = remarksData[0]; | ||
| 299 | + } else { | ||
| 300 | + this.form.remarks = ''; | ||
| 301 | + this.defaultRemark = ''; | ||
| 302 | + } | ||
| 303 | + }) | ||
| 304 | + this.getHistory() | ||
| 305 | + } | ||
| 306 | + } | ||
| 307 | + }, | ||
| 308 | + productLineList: { | ||
| 309 | + deep: true, | ||
| 310 | + handler(newVal, oldVal) { | ||
| 311 | + const n = Array.isArray(newVal) ? newVal : [] | ||
| 312 | + const o = Array.isArray(oldVal) ? oldVal : [] | ||
| 313 | + const changed = [] | ||
| 314 | + for (let i = 0; i < n.length; i++) { | ||
| 315 | + const ni = n[i] && n[i].productId | ||
| 316 | + const oi = o[i] && o[i].productId | ||
| 317 | + if (ni !== oi && ni !== undefined) changed.push(ni) | ||
| 318 | + } | ||
| 319 | + console.log('changed', changed) | ||
| 320 | + if (changed.length && this.form.buyer) { | ||
| 321 | + const id = changed.join('') | ||
| 322 | + this.fetchCustomerQualityRequirements(id) | ||
| 323 | + } | ||
| 324 | + } | ||
| 325 | + }, | ||
| 326 | + }, | ||
| 271 | methods: { | 327 | methods: { |
| 328 | + getHistory() { | ||
| 329 | + if (!this.productLineList.length || !this.productLineList[0].productId) { | ||
| 330 | + return; | ||
| 331 | + } | ||
| 332 | + const id = this.productLineList.map(it => it.productId).join('') | ||
| 333 | + this.fetchCustomerQualityRequirements(id) | ||
| 334 | + }, | ||
| 335 | + async fetchCustomerQualityRequirements(id) { | ||
| 336 | + if (!this.form.buyer || !id) { | ||
| 337 | + return; | ||
| 338 | + } | ||
| 339 | + try { | ||
| 340 | + const result = await getCustomerSpecificQualityRequirements({ | ||
| 341 | + customerId: this.form.buyer, | ||
| 342 | + productIdList:id, | ||
| 343 | + }); | ||
| 344 | + this.updateFormData(result.data || {}); | ||
| 345 | + } catch (error) { | ||
| 346 | + console.error('获取客户质量要求失败:', error); | ||
| 347 | + // 可以根据需要添加错误提示逻辑 | ||
| 348 | + this.$message.error('获取历史数据失败,请稍后重试'); | ||
| 349 | + } | ||
| 350 | + }, | ||
| 351 | + // 提取公共的字段更新方法 | ||
| 352 | + updateFormData(result) { | ||
| 353 | + const fields = [ | ||
| 354 | + 'component', | ||
| 355 | + 'packaging', | ||
| 356 | + 'performance', | ||
| 357 | + 'pieceWeightHead', | ||
| 358 | + 'surface', | ||
| 359 | + 'tolerance', | ||
| 360 | + ]; | ||
| 361 | + fields.forEach((field) => { | ||
| 362 | + this.form[field] = (this.form[field] || '') + (result[field] || ''); | ||
| 363 | + }); | ||
| 364 | + }, | ||
| 272 | onProductsChange(products) { | 365 | onProductsChange(products) { |
| 273 | const list = Array.isArray(products) ? products : [] | 366 | const list = Array.isArray(products) ? products : [] |
| 274 | const sumQ = list.reduce((acc, it) => acc + (parseFloat(it.quantity) || 0), 0) | 367 | const sumQ = list.reduce((acc, it) => acc + (parseFloat(it.quantity) || 0), 0) |
| @@ -356,14 +449,21 @@ export default { | @@ -356,14 +449,21 @@ export default { | ||
| 356 | setSheet('单价中是否已包含包装费', this.yesNoList) | 449 | setSheet('单价中是否已包含包装费', this.yesNoList) |
| 357 | } else if (field === 'includesTransportFee') { | 450 | } else if (field === 'includesTransportFee') { |
| 358 | setSheet('单价中是否已包含运费', this.yesNoList) | 451 | setSheet('单价中是否已包含运费', this.yesNoList) |
| 452 | + } else if (field === 'historyRemarks') { | ||
| 453 | + setSheet('历史备注', this.customerRemarks) | ||
| 359 | } | 454 | } |
| 360 | }, | 455 | }, |
| 361 | onSheetConfirm({ value, label }) { | 456 | onSheetConfirm({ value, label }) { |
| 362 | const field = this.sheet.field | 457 | const field = this.sheet.field |
| 363 | if (!field) return | 458 | if (!field) return |
| 364 | const v = (value === undefined || value === null) ? '' : value | 459 | const v = (value === undefined || value === null) ? '' : value |
| 365 | - this.form[field] = v | ||
| 366 | - this.form[field + 'Name'] = label || '' | 460 | + if (field === 'historyRemarks') { |
| 461 | + this.defaultRemark = label || '' | ||
| 462 | + this.form.remarks = v | ||
| 463 | + }else{ | ||
| 464 | + this.form[field] = v | ||
| 465 | + this.form[field + 'Name'] = label || '' | ||
| 466 | + } | ||
| 367 | }, | 467 | }, |
| 368 | openRelate(fieldKey) { | 468 | openRelate(fieldKey) { |
| 369 | let config = {} | 469 | let config = {} |
| @@ -123,9 +123,15 @@ | @@ -123,9 +123,15 @@ | ||
| 123 | <uni-easyinput v-model="form.specialInstructions" placeholder="请输入特别说明" :inputBorder="false" /> | 123 | <uni-easyinput v-model="form.specialInstructions" placeholder="请输入特别说明" :inputBorder="false" /> |
| 124 | </template> | 124 | </template> |
| 125 | </uni-list-item> | 125 | </uni-list-item> |
| 126 | + <uni-list-item v-if="this.customerRemarks.length" class="select-item" :class="defaultRemark ? 'is-filled' : 'is-empty'" clickable | ||
| 127 | + @click="openSheet('historyRemarks')" :rightText="defaultRemark || '请选择'" showArrow> | ||
| 128 | + <template v-slot:body> | ||
| 129 | + <view class="item-title"><text>历史备注</text></view> | ||
| 130 | + </template> | ||
| 131 | + </uni-list-item> | ||
| 126 | <uni-list-item title="备注"> | 132 | <uni-list-item title="备注"> |
| 127 | <template v-slot:footer> | 133 | <template v-slot:footer> |
| 128 | - <uni-easyinput v-model="form.remarks" placeholder="请输入备注" :inputBorder="false" /> | 134 | + <uni-easyinput type="textarea" v-model="form.remarks" placeholder="请输入备注" :inputBorder="false" /> |
| 129 | </template> | 135 | </template> |
| 130 | </uni-list-item> | 136 | </uni-list-item> |
| 131 | <view class="quality"> | 137 | <view class="quality"> |
| @@ -134,32 +140,32 @@ | @@ -134,32 +140,32 @@ | ||
| 134 | </view> | 140 | </view> |
| 135 | <uni-list-item title="件重条头"> | 141 | <uni-list-item title="件重条头"> |
| 136 | <template v-slot:footer> | 142 | <template v-slot:footer> |
| 137 | - <uni-easyinput v-model="form.pieceWeightHead" placeholder="请输入" :inputBorder="false" /> | 143 | + <uni-easyinput type="textarea" v-model="form.pieceWeightHead" placeholder="请输入" :inputBorder="false" /> |
| 138 | </template> | 144 | </template> |
| 139 | </uni-list-item> | 145 | </uni-list-item> |
| 140 | <uni-list-item title="表面"> | 146 | <uni-list-item title="表面"> |
| 141 | <template v-slot:footer> | 147 | <template v-slot:footer> |
| 142 | - <uni-easyinput v-model="form.surface" placeholder="请输入" :inputBorder="false" /> | 148 | + <uni-easyinput type="textarea" v-model="form.surface" placeholder="请输入" :inputBorder="false" /> |
| 143 | </template> | 149 | </template> |
| 144 | </uni-list-item> | 150 | </uni-list-item> |
| 145 | <uni-list-item title="公差"> | 151 | <uni-list-item title="公差"> |
| 146 | <template v-slot:footer> | 152 | <template v-slot:footer> |
| 147 | - <uni-easyinput v-model="form.tolerance" placeholder="请输入" :inputBorder="false" /> | 153 | + <uni-easyinput type="textarea" v-model="form.tolerance" placeholder="请输入" :inputBorder="false" /> |
| 148 | </template> | 154 | </template> |
| 149 | </uni-list-item> | 155 | </uni-list-item> |
| 150 | <uni-list-item title="性能"> | 156 | <uni-list-item title="性能"> |
| 151 | <template v-slot:footer> | 157 | <template v-slot:footer> |
| 152 | - <uni-easyinput v-model="form.performance" placeholder="请输入" :inputBorder="false" /> | 158 | + <uni-easyinput type="textarea" v-model="form.performance" placeholder="请输入" :inputBorder="false" /> |
| 153 | </template> | 159 | </template> |
| 154 | </uni-list-item> | 160 | </uni-list-item> |
| 155 | <uni-list-item title="成分"> | 161 | <uni-list-item title="成分"> |
| 156 | <template v-slot:footer> | 162 | <template v-slot:footer> |
| 157 | - <uni-easyinput v-model="form.component" placeholder="请输入" :inputBorder="false" /> | 163 | + <uni-easyinput type="textarea" v-model="form.component" placeholder="请输入" :inputBorder="false" /> |
| 158 | </template> | 164 | </template> |
| 159 | </uni-list-item> | 165 | </uni-list-item> |
| 160 | <uni-list-item title="包装"> | 166 | <uni-list-item title="包装"> |
| 161 | <template v-slot:footer> | 167 | <template v-slot:footer> |
| 162 | - <uni-easyinput v-model="form.packaging" placeholder="请输入" :inputBorder="false" /> | 168 | + <uni-easyinput type="textarea" v-model="form.packaging" placeholder="请输入" :inputBorder="false" /> |
| 163 | </template> | 169 | </template> |
| 164 | </uni-list-item> | 170 | </uni-list-item> |
| 165 | </uni-list> | 171 | </uni-list> |
| @@ -210,7 +216,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | @@ -210,7 +216,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | ||
| 210 | import RelateSelectSheet from '@/components/relate-select/index.vue' | 216 | import RelateSelectSheet from '@/components/relate-select/index.vue' |
| 211 | import ProductRel from './productRel.vue' | 217 | import ProductRel from './productRel.vue' |
| 212 | import CitySelector from '@/components/city-selector/index.vue' | 218 | import CitySelector from '@/components/city-selector/index.vue' |
| 213 | -import { getRetailCodeApi, createContractApi } from '@/api/contract' | 219 | +import { getRetailCodeApi, createContractApi, getCustomerSpecificQualityRequirements,getCustomerRemarks } from '@/api/contract' |
| 214 | import { getDicByCodes } from '@/utils/dic' | 220 | import { getDicByCodes } from '@/utils/dic' |
| 215 | import { formatCurrencyToChinese } from '@/utils/common' | 221 | import { formatCurrencyToChinese } from '@/utils/common' |
| 216 | import { workshopQueryApi } from '@/api/devManage' | 222 | import { workshopQueryApi } from '@/api/devManage' |
| @@ -243,6 +249,13 @@ export default { | @@ -243,6 +249,13 @@ export default { | ||
| 243 | destinationLabel: '', | 249 | destinationLabel: '', |
| 244 | workshopIdName: '', | 250 | workshopIdName: '', |
| 245 | workshopId: '', | 251 | workshopId: '', |
| 252 | + component: '', | ||
| 253 | + packaging: '', | ||
| 254 | + performance: '', | ||
| 255 | + pieceWeightHead: '', | ||
| 256 | + surface: '', | ||
| 257 | + tolerance: '', | ||
| 258 | + remarks: '', | ||
| 246 | }, | 259 | }, |
| 247 | supplierList: [], | 260 | supplierList: [], |
| 248 | specialTermsList: [], | 261 | specialTermsList: [], |
| @@ -255,6 +268,8 @@ export default { | @@ -255,6 +268,8 @@ export default { | ||
| 255 | sumTotal: 0, | 268 | sumTotal: 0, |
| 256 | productLineList: [], | 269 | productLineList: [], |
| 257 | productList: [], | 270 | productList: [], |
| 271 | + customerRemarks: [], | ||
| 272 | + defaultRemark: '', | ||
| 258 | } | 273 | } |
| 259 | }, | 274 | }, |
| 260 | created() { | 275 | created() { |
| @@ -268,7 +283,87 @@ export default { | @@ -268,7 +283,87 @@ export default { | ||
| 268 | } | 283 | } |
| 269 | }) | 284 | }) |
| 270 | }, | 285 | }, |
| 286 | + watch: { | ||
| 287 | + 'form.buyer': { | ||
| 288 | + handler(newVal, oldVal) { | ||
| 289 | + if (newVal) { | ||
| 290 | + getCustomerRemarks(newVal).then(res => { | ||
| 291 | + const remarksData = res.data || []; | ||
| 292 | + this.customerRemarks = remarksData.map((item, index) => ({ | ||
| 293 | + label: `客户备注${index + 1}`, | ||
| 294 | + value: item, | ||
| 295 | + })); | ||
| 296 | + if (remarksData.length > 0) { | ||
| 297 | + this.defaultRemark = this.customerRemarks[0].label || ''; | ||
| 298 | + this.form.remarks = remarksData[0]; | ||
| 299 | + } else { | ||
| 300 | + this.form.remarks = ''; | ||
| 301 | + this.defaultRemark = ''; | ||
| 302 | + } | ||
| 303 | + }) | ||
| 304 | + this.getHistory() | ||
| 305 | + } | ||
| 306 | + } | ||
| 307 | + }, | ||
| 308 | + productLineList: { | ||
| 309 | + deep: true, | ||
| 310 | + handler(newVal, oldVal) { | ||
| 311 | + const n = Array.isArray(newVal) ? newVal : [] | ||
| 312 | + const o = Array.isArray(oldVal) ? oldVal : [] | ||
| 313 | + const changed = [] | ||
| 314 | + for (let i = 0; i < n.length; i++) { | ||
| 315 | + const ni = n[i] && n[i].productId | ||
| 316 | + const oi = o[i] && o[i].productId | ||
| 317 | + if (ni !== oi && ni !== undefined) changed.push(ni) | ||
| 318 | + } | ||
| 319 | + console.log('changed', changed) | ||
| 320 | + if (changed.length && this.form.buyer) { | ||
| 321 | + const id = changed.join('') | ||
| 322 | + this.fetchCustomerQualityRequirements(id) | ||
| 323 | + } | ||
| 324 | + } | ||
| 325 | + }, | ||
| 326 | + }, | ||
| 271 | methods: { | 327 | methods: { |
| 328 | + getHistory() { | ||
| 329 | + console.log('this.productLineList', this.productLineList[0].productId) | ||
| 330 | + if (!this.productLineList.length || !this.productLineList[0].productId) { | ||
| 331 | + return; | ||
| 332 | + } | ||
| 333 | + const id = this.productLineList.map(it => it.productId).join('') | ||
| 334 | + this.fetchCustomerQualityRequirements(id) | ||
| 335 | + }, | ||
| 336 | + async fetchCustomerQualityRequirements(id) { | ||
| 337 | + if (!this.form.buyer || !id) { | ||
| 338 | + return; | ||
| 339 | + } | ||
| 340 | + try { | ||
| 341 | + const result = await getCustomerSpecificQualityRequirements({ | ||
| 342 | + customerId: this.form.buyer, | ||
| 343 | + productIdList:id, | ||
| 344 | + }); | ||
| 345 | + this.updateFormData(result.data || {}); | ||
| 346 | + } catch (error) { | ||
| 347 | + console.error('获取客户质量要求失败:', error); | ||
| 348 | + // 可以根据需要添加错误提示逻辑 | ||
| 349 | + this.$message.error('获取历史数据失败,请稍后重试'); | ||
| 350 | + } | ||
| 351 | + }, | ||
| 352 | + // 提取公共的字段更新方法 | ||
| 353 | + updateFormData(result) { | ||
| 354 | + console.log('result', result) | ||
| 355 | + const fields = [ | ||
| 356 | + 'component', | ||
| 357 | + 'packaging', | ||
| 358 | + 'performance', | ||
| 359 | + 'pieceWeightHead', | ||
| 360 | + 'surface', | ||
| 361 | + 'tolerance', | ||
| 362 | + ]; | ||
| 363 | + fields.forEach((field) => { | ||
| 364 | + this.form[field] = (this.form[field] || '') + (result[field] || ''); | ||
| 365 | + }); | ||
| 366 | + }, | ||
| 272 | onProductsChange(products) { | 367 | onProductsChange(products) { |
| 273 | const list = Array.isArray(products) ? products : [] | 368 | const list = Array.isArray(products) ? products : [] |
| 274 | const sumQ = list.reduce((acc, it) => acc + (parseFloat(it.quantity) || 0), 0) | 369 | const sumQ = list.reduce((acc, it) => acc + (parseFloat(it.quantity) || 0), 0) |
| @@ -356,14 +451,21 @@ export default { | @@ -356,14 +451,21 @@ export default { | ||
| 356 | setSheet('单价中是否已包含包装费', this.yesNoList) | 451 | setSheet('单价中是否已包含包装费', this.yesNoList) |
| 357 | } else if (field === 'includesTransportFee') { | 452 | } else if (field === 'includesTransportFee') { |
| 358 | setSheet('单价中是否已包含运费', this.yesNoList) | 453 | setSheet('单价中是否已包含运费', this.yesNoList) |
| 454 | + } else if (field === 'historyRemarks') { | ||
| 455 | + setSheet('历史备注', this.customerRemarks) | ||
| 359 | } | 456 | } |
| 360 | }, | 457 | }, |
| 361 | onSheetConfirm({ value, label }) { | 458 | onSheetConfirm({ value, label }) { |
| 362 | const field = this.sheet.field | 459 | const field = this.sheet.field |
| 363 | if (!field) return | 460 | if (!field) return |
| 364 | const v = (value === undefined || value === null) ? '' : value | 461 | const v = (value === undefined || value === null) ? '' : value |
| 365 | - this.form[field] = v | ||
| 366 | - this.form[field + 'Name'] = label || '' | 462 | + if (field === 'historyRemarks') { |
| 463 | + this.defaultRemark = label || '' | ||
| 464 | + this.form.remarks = v | ||
| 465 | + }else{ | ||
| 466 | + this.form[field] = v | ||
| 467 | + this.form[field + 'Name'] = label || '' | ||
| 468 | + } | ||
| 367 | }, | 469 | }, |
| 368 | openRelate(fieldKey) { | 470 | openRelate(fieldKey) { |
| 369 | let config = {} | 471 | let config = {} |
| @@ -123,9 +123,15 @@ | @@ -123,9 +123,15 @@ | ||
| 123 | <uni-easyinput v-model="form.specialInstructions" placeholder="请输入特别说明" :inputBorder="false" /> | 123 | <uni-easyinput v-model="form.specialInstructions" placeholder="请输入特别说明" :inputBorder="false" /> |
| 124 | </template> | 124 | </template> |
| 125 | </uni-list-item> | 125 | </uni-list-item> |
| 126 | + <uni-list-item v-if="this.customerRemarks.length" class="select-item" :class="defaultRemark ? 'is-filled' : 'is-empty'" clickable | ||
| 127 | + @click="openSheet('historyRemarks')" :rightText="defaultRemark || '请选择'" showArrow> | ||
| 128 | + <template v-slot:body> | ||
| 129 | + <view class="item-title"><text>历史备注</text></view> | ||
| 130 | + </template> | ||
| 131 | + </uni-list-item> | ||
| 126 | <uni-list-item title="备注"> | 132 | <uni-list-item title="备注"> |
| 127 | <template v-slot:footer> | 133 | <template v-slot:footer> |
| 128 | - <uni-easyinput v-model="form.remarks" placeholder="请输入备注" :inputBorder="false" /> | 134 | + <uni-easyinput type="textarea" v-model="form.remarks" placeholder="请输入备注" :inputBorder="false" /> |
| 129 | </template> | 135 | </template> |
| 130 | </uni-list-item> | 136 | </uni-list-item> |
| 131 | <view class="quality"> | 137 | <view class="quality"> |
| @@ -134,32 +140,32 @@ | @@ -134,32 +140,32 @@ | ||
| 134 | </view> | 140 | </view> |
| 135 | <uni-list-item title="件重条头"> | 141 | <uni-list-item title="件重条头"> |
| 136 | <template v-slot:footer> | 142 | <template v-slot:footer> |
| 137 | - <uni-easyinput v-model="form.pieceWeightHead" placeholder="请输入" :inputBorder="false" /> | 143 | + <uni-easyinput type="textarea" v-model="form.pieceWeightHead" placeholder="请输入" :inputBorder="false" /> |
| 138 | </template> | 144 | </template> |
| 139 | </uni-list-item> | 145 | </uni-list-item> |
| 140 | <uni-list-item title="表面"> | 146 | <uni-list-item title="表面"> |
| 141 | <template v-slot:footer> | 147 | <template v-slot:footer> |
| 142 | - <uni-easyinput v-model="form.surface" placeholder="请输入" :inputBorder="false" /> | 148 | + <uni-easyinput type="textarea" v-model="form.surface" placeholder="请输入" :inputBorder="false" /> |
| 143 | </template> | 149 | </template> |
| 144 | </uni-list-item> | 150 | </uni-list-item> |
| 145 | <uni-list-item title="公差"> | 151 | <uni-list-item title="公差"> |
| 146 | <template v-slot:footer> | 152 | <template v-slot:footer> |
| 147 | - <uni-easyinput v-model="form.tolerance" placeholder="请输入" :inputBorder="false" /> | 153 | + <uni-easyinput type="textarea" v-model="form.tolerance" placeholder="请输入" :inputBorder="false" /> |
| 148 | </template> | 154 | </template> |
| 149 | </uni-list-item> | 155 | </uni-list-item> |
| 150 | <uni-list-item title="性能"> | 156 | <uni-list-item title="性能"> |
| 151 | <template v-slot:footer> | 157 | <template v-slot:footer> |
| 152 | - <uni-easyinput v-model="form.performance" placeholder="请输入" :inputBorder="false" /> | 158 | + <uni-easyinput type="textarea" v-model="form.performance" placeholder="请输入" :inputBorder="false" /> |
| 153 | </template> | 159 | </template> |
| 154 | </uni-list-item> | 160 | </uni-list-item> |
| 155 | <uni-list-item title="成分"> | 161 | <uni-list-item title="成分"> |
| 156 | <template v-slot:footer> | 162 | <template v-slot:footer> |
| 157 | - <uni-easyinput v-model="form.component" placeholder="请输入" :inputBorder="false" /> | 163 | + <uni-easyinput type="textarea" v-model="form.component" placeholder="请输入" :inputBorder="false" /> |
| 158 | </template> | 164 | </template> |
| 159 | </uni-list-item> | 165 | </uni-list-item> |
| 160 | <uni-list-item title="包装"> | 166 | <uni-list-item title="包装"> |
| 161 | <template v-slot:footer> | 167 | <template v-slot:footer> |
| 162 | - <uni-easyinput v-model="form.packaging" placeholder="请输入" :inputBorder="false" /> | 168 | + <uni-easyinput type="textarea" v-model="form.packaging" placeholder="请输入" :inputBorder="false" /> |
| 163 | </template> | 169 | </template> |
| 164 | </uni-list-item> | 170 | </uni-list-item> |
| 165 | </uni-list> | 171 | </uni-list> |
| @@ -210,7 +216,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | @@ -210,7 +216,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | ||
| 210 | import RelateSelectSheet from '@/components/relate-select/index.vue' | 216 | import RelateSelectSheet from '@/components/relate-select/index.vue' |
| 211 | import ProductRel from './productRel.vue' | 217 | import ProductRel from './productRel.vue' |
| 212 | import CitySelector from '@/components/city-selector/index.vue' | 218 | import CitySelector from '@/components/city-selector/index.vue' |
| 213 | -import { getRetailCodeApi, createContractApi } from '@/api/contract' | 219 | +import { getRetailCodeApi, createContractApi, getCustomerRemarks,getCustomerSpecificQualityRequirements } from '@/api/contract' |
| 214 | import { getDicByCodes } from '@/utils/dic' | 220 | import { getDicByCodes } from '@/utils/dic' |
| 215 | import { formatCurrencyToChinese } from '@/utils/common' | 221 | import { formatCurrencyToChinese } from '@/utils/common' |
| 216 | import { workshopQueryApi } from '@/api/devManage' | 222 | import { workshopQueryApi } from '@/api/devManage' |
| @@ -243,6 +249,13 @@ export default { | @@ -243,6 +249,13 @@ export default { | ||
| 243 | destinationLabel: '', | 249 | destinationLabel: '', |
| 244 | workshopIdName: '', | 250 | workshopIdName: '', |
| 245 | workshopId: '', | 251 | workshopId: '', |
| 252 | + remarks: '', | ||
| 253 | + component: '', | ||
| 254 | + packaging: '', | ||
| 255 | + performance: '', | ||
| 256 | + pieceWeightHead: '', | ||
| 257 | + surface: '', | ||
| 258 | + tolerance: '', | ||
| 246 | }, | 259 | }, |
| 247 | supplierList: [], | 260 | supplierList: [], |
| 248 | specialTermsList: [], | 261 | specialTermsList: [], |
| @@ -255,6 +268,8 @@ export default { | @@ -255,6 +268,8 @@ export default { | ||
| 255 | sumTotal: 0, | 268 | sumTotal: 0, |
| 256 | productLineList: [], | 269 | productLineList: [], |
| 257 | productList: [], | 270 | productList: [], |
| 271 | + customerRemarks: [], | ||
| 272 | + defaultRemark: '', | ||
| 258 | } | 273 | } |
| 259 | }, | 274 | }, |
| 260 | created() { | 275 | created() { |
| @@ -268,7 +283,86 @@ export default { | @@ -268,7 +283,86 @@ export default { | ||
| 268 | } | 283 | } |
| 269 | }) | 284 | }) |
| 270 | }, | 285 | }, |
| 286 | + watch: { | ||
| 287 | + 'form.buyer': { | ||
| 288 | + handler(newVal, oldVal) { | ||
| 289 | + if (newVal) { | ||
| 290 | + getCustomerRemarks(newVal).then(res => { | ||
| 291 | + const remarksData = res.data || []; | ||
| 292 | + this.customerRemarks = remarksData.map((item, index) => ({ | ||
| 293 | + label: `客户备注${index + 1}`, | ||
| 294 | + value: item, | ||
| 295 | + })); | ||
| 296 | + if (remarksData.length > 0) { | ||
| 297 | + this.defaultRemark = this.customerRemarks[0].label || ''; | ||
| 298 | + this.form.remarks = remarksData[0]; | ||
| 299 | + } else { | ||
| 300 | + this.form.remarks = ''; | ||
| 301 | + this.defaultRemark = ''; | ||
| 302 | + } | ||
| 303 | + }) | ||
| 304 | + this.getHistory() | ||
| 305 | + } | ||
| 306 | + } | ||
| 307 | + }, | ||
| 308 | + productLineList: { | ||
| 309 | + deep: true, | ||
| 310 | + handler(newVal, oldVal) { | ||
| 311 | + const n = Array.isArray(newVal) ? newVal : [] | ||
| 312 | + const o = Array.isArray(oldVal) ? oldVal : [] | ||
| 313 | + const changed = [] | ||
| 314 | + for (let i = 0; i < n.length; i++) { | ||
| 315 | + const ni = n[i] && n[i].productId | ||
| 316 | + const oi = o[i] && o[i].productId | ||
| 317 | + if (ni !== oi && ni !== undefined) changed.push(ni) | ||
| 318 | + } | ||
| 319 | + if (changed.length && this.form.buyer) { | ||
| 320 | + const id = changed.join('') | ||
| 321 | + this.fetchCustomerQualityRequirements(id) | ||
| 322 | + } | ||
| 323 | + } | ||
| 324 | + }, | ||
| 325 | + }, | ||
| 271 | methods: { | 326 | methods: { |
| 327 | + getHistory() { | ||
| 328 | + console.log('this.productLineList', this.productLineList[0].productId) | ||
| 329 | + if (!this.productLineList.length || !this.productLineList[0].productId) { | ||
| 330 | + return; | ||
| 331 | + } | ||
| 332 | + const id = this.productLineList.map(it => it.productId).join('') | ||
| 333 | + this.fetchCustomerQualityRequirements(id) | ||
| 334 | + }, | ||
| 335 | + async fetchCustomerQualityRequirements(id) { | ||
| 336 | + if (!this.form.buyer || !id) { | ||
| 337 | + return; | ||
| 338 | + } | ||
| 339 | + try { | ||
| 340 | + const result = await getCustomerSpecificQualityRequirements({ | ||
| 341 | + customerId: this.form.buyer, | ||
| 342 | + productIdList:id, | ||
| 343 | + }); | ||
| 344 | + this.updateFormData(result.data || {}); | ||
| 345 | + } catch (error) { | ||
| 346 | + console.error('获取客户质量要求失败:', error); | ||
| 347 | + // 可以根据需要添加错误提示逻辑 | ||
| 348 | + this.$message.error('获取历史数据失败,请稍后重试'); | ||
| 349 | + } | ||
| 350 | + }, | ||
| 351 | + // 提取公共的字段更新方法 | ||
| 352 | + updateFormData(result) { | ||
| 353 | + console.log('result', result) | ||
| 354 | + const fields = [ | ||
| 355 | + 'component', | ||
| 356 | + 'packaging', | ||
| 357 | + 'performance', | ||
| 358 | + 'pieceWeightHead', | ||
| 359 | + 'surface', | ||
| 360 | + 'tolerance', | ||
| 361 | + ]; | ||
| 362 | + fields.forEach((field) => { | ||
| 363 | + this.form[field] = (this.form[field] || '') + (result[field] || ''); | ||
| 364 | + }); | ||
| 365 | + }, | ||
| 272 | onProductsChange(products) { | 366 | onProductsChange(products) { |
| 273 | const list = Array.isArray(products) ? products : [] | 367 | const list = Array.isArray(products) ? products : [] |
| 274 | const sumQ = list.reduce((acc, it) => acc + (parseFloat(it.quantity) || 0), 0) | 368 | const sumQ = list.reduce((acc, it) => acc + (parseFloat(it.quantity) || 0), 0) |
| @@ -356,14 +450,21 @@ export default { | @@ -356,14 +450,21 @@ export default { | ||
| 356 | setSheet('单价中是否已包含包装费', this.yesNoList) | 450 | setSheet('单价中是否已包含包装费', this.yesNoList) |
| 357 | } else if (field === 'includesTransportFee') { | 451 | } else if (field === 'includesTransportFee') { |
| 358 | setSheet('单价中是否已包含运费', this.yesNoList) | 452 | setSheet('单价中是否已包含运费', this.yesNoList) |
| 453 | + } else if (field === 'historyRemarks') { | ||
| 454 | + setSheet('历史备注', this.customerRemarks) | ||
| 359 | } | 455 | } |
| 360 | }, | 456 | }, |
| 361 | onSheetConfirm({ value, label }) { | 457 | onSheetConfirm({ value, label }) { |
| 362 | const field = this.sheet.field | 458 | const field = this.sheet.field |
| 363 | if (!field) return | 459 | if (!field) return |
| 364 | const v = (value === undefined || value === null) ? '' : value | 460 | const v = (value === undefined || value === null) ? '' : value |
| 365 | - this.form[field] = v | ||
| 366 | - this.form[field + 'Name'] = label || '' | 461 | + if (field === 'historyRemarks') { |
| 462 | + this.defaultRemark = label || '' | ||
| 463 | + this.form.remarks = v | ||
| 464 | + }else{ | ||
| 465 | + this.form[field] = v | ||
| 466 | + this.form[field + 'Name'] = label || '' | ||
| 467 | + } | ||
| 367 | }, | 468 | }, |
| 368 | openRelate(fieldKey) { | 469 | openRelate(fieldKey) { |
| 369 | let config = {} | 470 | let config = {} |
| @@ -123,9 +123,15 @@ | @@ -123,9 +123,15 @@ | ||
| 123 | <uni-easyinput v-model="form.specialInstructions" placeholder="请输入特别说明" :inputBorder="false" /> | 123 | <uni-easyinput v-model="form.specialInstructions" placeholder="请输入特别说明" :inputBorder="false" /> |
| 124 | </template> | 124 | </template> |
| 125 | </uni-list-item> | 125 | </uni-list-item> |
| 126 | + <uni-list-item v-if="this.customerRemarks.length" class="select-item" :class="defaultRemark ? 'is-filled' : 'is-empty'" clickable | ||
| 127 | + @click="openSheet('historyRemarks')" :rightText="defaultRemark || '请选择'" showArrow> | ||
| 128 | + <template v-slot:body> | ||
| 129 | + <view class="item-title"><text>历史备注</text></view> | ||
| 130 | + </template> | ||
| 131 | + </uni-list-item> | ||
| 126 | <uni-list-item title="备注"> | 132 | <uni-list-item title="备注"> |
| 127 | <template v-slot:footer> | 133 | <template v-slot:footer> |
| 128 | - <uni-easyinput v-model="form.remarks" placeholder="请输入备注" :inputBorder="false" /> | 134 | + <uni-easyinput type="textarea" v-model="form.remarks" placeholder="请输入备注" :inputBorder="false" /> |
| 129 | </template> | 135 | </template> |
| 130 | </uni-list-item> | 136 | </uni-list-item> |
| 131 | <view class="quality"> | 137 | <view class="quality"> |
| @@ -134,32 +140,32 @@ | @@ -134,32 +140,32 @@ | ||
| 134 | </view> | 140 | </view> |
| 135 | <uni-list-item title="件重条头"> | 141 | <uni-list-item title="件重条头"> |
| 136 | <template v-slot:footer> | 142 | <template v-slot:footer> |
| 137 | - <uni-easyinput v-model="form.pieceWeightHead" placeholder="请输入" :inputBorder="false" /> | 143 | + <uni-easyinput type="textarea" v-model="form.pieceWeightHead" placeholder="请输入" :inputBorder="false" /> |
| 138 | </template> | 144 | </template> |
| 139 | </uni-list-item> | 145 | </uni-list-item> |
| 140 | <uni-list-item title="表面"> | 146 | <uni-list-item title="表面"> |
| 141 | <template v-slot:footer> | 147 | <template v-slot:footer> |
| 142 | - <uni-easyinput v-model="form.surface" placeholder="请输入" :inputBorder="false" /> | 148 | + <uni-easyinput type="textarea" v-model="form.surface" placeholder="请输入" :inputBorder="false" /> |
| 143 | </template> | 149 | </template> |
| 144 | </uni-list-item> | 150 | </uni-list-item> |
| 145 | <uni-list-item title="公差"> | 151 | <uni-list-item title="公差"> |
| 146 | <template v-slot:footer> | 152 | <template v-slot:footer> |
| 147 | - <uni-easyinput v-model="form.tolerance" placeholder="请输入" :inputBorder="false" /> | 153 | + <uni-easyinput type="textarea" v-model="form.tolerance" placeholder="请输入" :inputBorder="false" /> |
| 148 | </template> | 154 | </template> |
| 149 | </uni-list-item> | 155 | </uni-list-item> |
| 150 | <uni-list-item title="性能"> | 156 | <uni-list-item title="性能"> |
| 151 | <template v-slot:footer> | 157 | <template v-slot:footer> |
| 152 | - <uni-easyinput v-model="form.performance" placeholder="请输入" :inputBorder="false" /> | 158 | + <uni-easyinput type="textarea" v-model="form.performance" placeholder="请输入" :inputBorder="false" /> |
| 153 | </template> | 159 | </template> |
| 154 | </uni-list-item> | 160 | </uni-list-item> |
| 155 | <uni-list-item title="成分"> | 161 | <uni-list-item title="成分"> |
| 156 | <template v-slot:footer> | 162 | <template v-slot:footer> |
| 157 | - <uni-easyinput v-model="form.component" placeholder="请输入" :inputBorder="false" /> | 163 | + <uni-easyinput type="textarea" v-model="form.component" placeholder="请输入" :inputBorder="false" /> |
| 158 | </template> | 164 | </template> |
| 159 | </uni-list-item> | 165 | </uni-list-item> |
| 160 | <uni-list-item title="包装"> | 166 | <uni-list-item title="包装"> |
| 161 | <template v-slot:footer> | 167 | <template v-slot:footer> |
| 162 | - <uni-easyinput v-model="form.packaging" placeholder="请输入" :inputBorder="false" /> | 168 | + <uni-easyinput type="textarea" v-model="form.packaging" placeholder="请输入" :inputBorder="false" /> |
| 163 | </template> | 169 | </template> |
| 164 | </uni-list-item> | 170 | </uni-list-item> |
| 165 | </uni-list> | 171 | </uni-list> |
| @@ -210,7 +216,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | @@ -210,7 +216,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | ||
| 210 | import RelateSelectSheet from '@/components/relate-select/index.vue' | 216 | import RelateSelectSheet from '@/components/relate-select/index.vue' |
| 211 | //import ProductRel from './productRel.vue' | 217 | //import ProductRel from './productRel.vue' |
| 212 | import CitySelector from '@/components/city-selector/index.vue' | 218 | import CitySelector from '@/components/city-selector/index.vue' |
| 213 | -import { getRetailCodeApi, createContractApi } from '@/api/contract' | 219 | +import { getRetailCodeApi, createContractApi, getCustomerRemarks,getCustomerSpecificQualityRequirements } from '@/api/contract' |
| 214 | import { getDicByCodes } from '@/utils/dic' | 220 | import { getDicByCodes } from '@/utils/dic' |
| 215 | import { formatCurrencyToChinese } from '@/utils/common' | 221 | import { formatCurrencyToChinese } from '@/utils/common' |
| 216 | import { workshopQueryApi } from '@/api/devManage' | 222 | import { workshopQueryApi } from '@/api/devManage' |
| @@ -243,6 +249,13 @@ export default { | @@ -243,6 +249,13 @@ export default { | ||
| 243 | destinationLabel: '', | 249 | destinationLabel: '', |
| 244 | workshopIdName: '', | 250 | workshopIdName: '', |
| 245 | workshopId: '', | 251 | workshopId: '', |
| 252 | + remarks: '', | ||
| 253 | + component: '', | ||
| 254 | + packaging: '', | ||
| 255 | + performance: '', | ||
| 256 | + pieceWeightHead: '', | ||
| 257 | + surface: '', | ||
| 258 | + tolerance: '', | ||
| 246 | }, | 259 | }, |
| 247 | supplierList: [], | 260 | supplierList: [], |
| 248 | specialTermsList: [], | 261 | specialTermsList: [], |
| @@ -256,6 +269,8 @@ export default { | @@ -256,6 +269,8 @@ export default { | ||
| 256 | productLineList: [], | 269 | productLineList: [], |
| 257 | productList: [], | 270 | productList: [], |
| 258 | rawToProdRatioList: [], | 271 | rawToProdRatioList: [], |
| 272 | + customerRemarks: [], | ||
| 273 | + defaultRemark: '', | ||
| 259 | } | 274 | } |
| 260 | }, | 275 | }, |
| 261 | created() { | 276 | created() { |
| @@ -269,7 +284,86 @@ export default { | @@ -269,7 +284,86 @@ export default { | ||
| 269 | } | 284 | } |
| 270 | }) | 285 | }) |
| 271 | }, | 286 | }, |
| 287 | + watch: { | ||
| 288 | + 'form.buyer': { | ||
| 289 | + handler(newVal, oldVal) { | ||
| 290 | + if (newVal) { | ||
| 291 | + getCustomerRemarks(newVal).then(res => { | ||
| 292 | + const remarksData = res.data || []; | ||
| 293 | + this.customerRemarks = remarksData.map((item, index) => ({ | ||
| 294 | + label: `客户备注${index + 1}`, | ||
| 295 | + value: item, | ||
| 296 | + })); | ||
| 297 | + if (remarksData.length > 0) { | ||
| 298 | + this.defaultRemark = this.customerRemarks[0].label || ''; | ||
| 299 | + this.form.remarks = remarksData[0]; | ||
| 300 | + } else { | ||
| 301 | + this.form.remarks = ''; | ||
| 302 | + this.defaultRemark = ''; | ||
| 303 | + } | ||
| 304 | + }) | ||
| 305 | + this.getHistory() | ||
| 306 | + } | ||
| 307 | + } | ||
| 308 | + }, | ||
| 309 | + productLineList: { | ||
| 310 | + deep: true, | ||
| 311 | + handler(newVal, oldVal) { | ||
| 312 | + const n = Array.isArray(newVal) ? newVal : [] | ||
| 313 | + const o = Array.isArray(oldVal) ? oldVal : [] | ||
| 314 | + const changed = [] | ||
| 315 | + for (let i = 0; i < n.length; i++) { | ||
| 316 | + const ni = n[i] && n[i].productId | ||
| 317 | + const oi = o[i] && o[i].productId | ||
| 318 | + if (ni !== oi && ni !== undefined) changed.push(ni) | ||
| 319 | + } | ||
| 320 | + if (changed.length && this.form.buyer) { | ||
| 321 | + const id = changed.join('') | ||
| 322 | + this.fetchCustomerQualityRequirements(id) | ||
| 323 | + } | ||
| 324 | + } | ||
| 325 | + }, | ||
| 326 | + }, | ||
| 272 | methods: { | 327 | methods: { |
| 328 | + getHistory() { | ||
| 329 | + console.log('this.productLineList', this.productLineList[0].productId) | ||
| 330 | + if (!this.productLineList.length || !this.productLineList[0].productId) { | ||
| 331 | + return; | ||
| 332 | + } | ||
| 333 | + const id = this.productLineList.map(it => it.productId).join('') | ||
| 334 | + this.fetchCustomerQualityRequirements(id) | ||
| 335 | + }, | ||
| 336 | + async fetchCustomerQualityRequirements(id) { | ||
| 337 | + if (!this.form.buyer || !id) { | ||
| 338 | + return; | ||
| 339 | + } | ||
| 340 | + try { | ||
| 341 | + const result = await getCustomerSpecificQualityRequirements({ | ||
| 342 | + customerId: this.form.buyer, | ||
| 343 | + productIdList:id, | ||
| 344 | + }); | ||
| 345 | + this.updateFormData(result.data || {}); | ||
| 346 | + } catch (error) { | ||
| 347 | + console.error('获取客户质量要求失败:', error); | ||
| 348 | + // 可以根据需要添加错误提示逻辑 | ||
| 349 | + this.$message.error('获取历史数据失败,请稍后重试'); | ||
| 350 | + } | ||
| 351 | + }, | ||
| 352 | + // 提取公共的字段更新方法 | ||
| 353 | + updateFormData(result) { | ||
| 354 | + console.log('result', result) | ||
| 355 | + const fields = [ | ||
| 356 | + 'component', | ||
| 357 | + 'packaging', | ||
| 358 | + 'performance', | ||
| 359 | + 'pieceWeightHead', | ||
| 360 | + 'surface', | ||
| 361 | + 'tolerance', | ||
| 362 | + ]; | ||
| 363 | + fields.forEach((field) => { | ||
| 364 | + this.form[field] = (this.form[field] || '') + (result[field] || ''); | ||
| 365 | + }); | ||
| 366 | + }, | ||
| 273 | onProductsChange(products) { | 367 | onProductsChange(products) { |
| 274 | const list = Array.isArray(products) ? products : [] | 368 | const list = Array.isArray(products) ? products : [] |
| 275 | const sumQ = list.reduce((acc, it) => acc + (parseFloat(it.quantity) || 0), 0) | 369 | const sumQ = list.reduce((acc, it) => acc + (parseFloat(it.quantity) || 0), 0) |
| @@ -360,14 +454,21 @@ export default { | @@ -360,14 +454,21 @@ export default { | ||
| 360 | setSheet('单价中是否已包含包装费', this.yesNoList) | 454 | setSheet('单价中是否已包含包装费', this.yesNoList) |
| 361 | } else if (field === 'includesTransportFee') { | 455 | } else if (field === 'includesTransportFee') { |
| 362 | setSheet('单价中是否已包含运费', this.yesNoList) | 456 | setSheet('单价中是否已包含运费', this.yesNoList) |
| 457 | + } else if (field === 'historyRemarks') { | ||
| 458 | + setSheet('历史备注', this.customerRemarks) | ||
| 363 | } | 459 | } |
| 364 | }, | 460 | }, |
| 365 | onSheetConfirm({ value, label }) { | 461 | onSheetConfirm({ value, label }) { |
| 366 | const field = this.sheet.field | 462 | const field = this.sheet.field |
| 367 | if (!field) return | 463 | if (!field) return |
| 368 | const v = (value === undefined || value === null) ? '' : value | 464 | const v = (value === undefined || value === null) ? '' : value |
| 369 | - this.form[field] = v | ||
| 370 | - this.form[field + 'Name'] = label || '' | 465 | + if (field === 'historyRemarks') { |
| 466 | + this.defaultRemark = label || '' | ||
| 467 | + this.form.remarks = v | ||
| 468 | + }else{ | ||
| 469 | + this.form[field] = v | ||
| 470 | + this.form[field + 'Name'] = label || '' | ||
| 471 | + } | ||
| 371 | }, | 472 | }, |
| 372 | openRelate(fieldKey) { | 473 | openRelate(fieldKey) { |
| 373 | let config = {} | 474 | let config = {} |
| @@ -122,10 +122,16 @@ | @@ -122,10 +122,16 @@ | ||
| 122 | <template v-slot:footer> | 122 | <template v-slot:footer> |
| 123 | <uni-easyinput v-model="form.specialInstructions" placeholder="请输入特别说明" :inputBorder="false" /> | 123 | <uni-easyinput v-model="form.specialInstructions" placeholder="请输入特别说明" :inputBorder="false" /> |
| 124 | </template> | 124 | </template> |
| 125 | + </uni-list-item> | ||
| 126 | + <uni-list-item v-if="this.customerRemarks.length" class="select-item" :class="defaultRemark ? 'is-filled' : 'is-empty'" clickable | ||
| 127 | + @click="openSheet('historyRemarks')" :rightText="defaultRemark || '请选择'" showArrow> | ||
| 128 | + <template v-slot:body> | ||
| 129 | + <view class="item-title"><text>历史备注</text></view> | ||
| 130 | + </template> | ||
| 125 | </uni-list-item> | 131 | </uni-list-item> |
| 126 | <uni-list-item title="备注"> | 132 | <uni-list-item title="备注"> |
| 127 | <template v-slot:footer> | 133 | <template v-slot:footer> |
| 128 | - <uni-easyinput v-model="form.remarks" placeholder="请输入备注" :inputBorder="false" /> | 134 | + <uni-easyinput type="textarea" v-model="form.remarks" placeholder="请输入备注" :inputBorder="false" /> |
| 129 | </template> | 135 | </template> |
| 130 | </uni-list-item> | 136 | </uni-list-item> |
| 131 | <view class="quality"> | 137 | <view class="quality"> |
| @@ -134,32 +140,32 @@ | @@ -134,32 +140,32 @@ | ||
| 134 | </view> | 140 | </view> |
| 135 | <uni-list-item title="件重条头"> | 141 | <uni-list-item title="件重条头"> |
| 136 | <template v-slot:footer> | 142 | <template v-slot:footer> |
| 137 | - <uni-easyinput v-model="form.pieceWeightHead" placeholder="请输入" :inputBorder="false" /> | 143 | + <uni-easyinput type="textarea" v-model="form.pieceWeightHead" placeholder="请输入" :inputBorder="false" /> |
| 138 | </template> | 144 | </template> |
| 139 | </uni-list-item> | 145 | </uni-list-item> |
| 140 | <uni-list-item title="表面"> | 146 | <uni-list-item title="表面"> |
| 141 | <template v-slot:footer> | 147 | <template v-slot:footer> |
| 142 | - <uni-easyinput v-model="form.surface" placeholder="请输入" :inputBorder="false" /> | 148 | + <uni-easyinput type="textarea" v-model="form.surface" placeholder="请输入" :inputBorder="false" /> |
| 143 | </template> | 149 | </template> |
| 144 | </uni-list-item> | 150 | </uni-list-item> |
| 145 | <uni-list-item title="公差"> | 151 | <uni-list-item title="公差"> |
| 146 | <template v-slot:footer> | 152 | <template v-slot:footer> |
| 147 | - <uni-easyinput v-model="form.tolerance" placeholder="请输入" :inputBorder="false" /> | 153 | + <uni-easyinput type="textarea" v-model="form.tolerance" placeholder="请输入" :inputBorder="false" /> |
| 148 | </template> | 154 | </template> |
| 149 | </uni-list-item> | 155 | </uni-list-item> |
| 150 | <uni-list-item title="性能"> | 156 | <uni-list-item title="性能"> |
| 151 | <template v-slot:footer> | 157 | <template v-slot:footer> |
| 152 | - <uni-easyinput v-model="form.performance" placeholder="请输入" :inputBorder="false" /> | 158 | + <uni-easyinput type="textarea" v-model="form.performance" placeholder="请输入" :inputBorder="false" /> |
| 153 | </template> | 159 | </template> |
| 154 | </uni-list-item> | 160 | </uni-list-item> |
| 155 | <uni-list-item title="成分"> | 161 | <uni-list-item title="成分"> |
| 156 | <template v-slot:footer> | 162 | <template v-slot:footer> |
| 157 | - <uni-easyinput v-model="form.component" placeholder="请输入" :inputBorder="false" /> | 163 | + <uni-easyinput type="textarea" v-model="form.component" placeholder="请输入" :inputBorder="false" /> |
| 158 | </template> | 164 | </template> |
| 159 | </uni-list-item> | 165 | </uni-list-item> |
| 160 | <uni-list-item title="包装"> | 166 | <uni-list-item title="包装"> |
| 161 | <template v-slot:footer> | 167 | <template v-slot:footer> |
| 162 | - <uni-easyinput v-model="form.packaging" placeholder="请输入" :inputBorder="false" /> | 168 | + <uni-easyinput type="textarea" v-model="form.packaging" placeholder="请输入" :inputBorder="false" /> |
| 163 | </template> | 169 | </template> |
| 164 | </uni-list-item> | 170 | </uni-list-item> |
| 165 | </uni-list> | 171 | </uni-list> |
| @@ -210,7 +216,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | @@ -210,7 +216,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | ||
| 210 | import RelateSelectSheet from '@/components/relate-select/index.vue' | 216 | import RelateSelectSheet from '@/components/relate-select/index.vue' |
| 211 | import ProductRel from './productRel.vue' | 217 | import ProductRel from './productRel.vue' |
| 212 | import CitySelector from '@/components/city-selector/index.vue' | 218 | import CitySelector from '@/components/city-selector/index.vue' |
| 213 | -import { getRetailCodeApi, createContractApi } from '@/api/contract' | 219 | +import { getRetailCodeApi, createContractApi, getCustomerRemarks,getCustomerSpecificQualityRequirements } from '@/api/contract' |
| 214 | import { getDicByCodes } from '@/utils/dic' | 220 | import { getDicByCodes } from '@/utils/dic' |
| 215 | import { formatCurrencyToChinese } from '@/utils/common' | 221 | import { formatCurrencyToChinese } from '@/utils/common' |
| 216 | import { workshopQueryApi } from '@/api/devManage' | 222 | import { workshopQueryApi } from '@/api/devManage' |
| @@ -243,6 +249,13 @@ export default { | @@ -243,6 +249,13 @@ export default { | ||
| 243 | destinationLabel: '', | 249 | destinationLabel: '', |
| 244 | workshopIdName: '', | 250 | workshopIdName: '', |
| 245 | workshopId: '', | 251 | workshopId: '', |
| 252 | + remarks: '', | ||
| 253 | + component: '', | ||
| 254 | + packaging: '', | ||
| 255 | + performance: '', | ||
| 256 | + pieceWeightHead: '', | ||
| 257 | + surface: '', | ||
| 258 | + tolerance: '', | ||
| 246 | }, | 259 | }, |
| 247 | supplierList: [], | 260 | supplierList: [], |
| 248 | specialTermsList: [], | 261 | specialTermsList: [], |
| @@ -255,6 +268,8 @@ export default { | @@ -255,6 +268,8 @@ export default { | ||
| 255 | sumTotal: 0, | 268 | sumTotal: 0, |
| 256 | productLineList: [], | 269 | productLineList: [], |
| 257 | productList: [], | 270 | productList: [], |
| 271 | + customerRemarks: [], | ||
| 272 | + defaultRemark: '', | ||
| 258 | } | 273 | } |
| 259 | }, | 274 | }, |
| 260 | created() { | 275 | created() { |
| @@ -268,7 +283,87 @@ export default { | @@ -268,7 +283,87 @@ export default { | ||
| 268 | } | 283 | } |
| 269 | }) | 284 | }) |
| 270 | }, | 285 | }, |
| 286 | + watch: { | ||
| 287 | + 'form.buyer': { | ||
| 288 | + handler(newVal, oldVal) { | ||
| 289 | + if (newVal) { | ||
| 290 | + getCustomerRemarks(newVal).then(res => { | ||
| 291 | + const remarksData = res.data || []; | ||
| 292 | + this.customerRemarks = remarksData.map((item, index) => ({ | ||
| 293 | + label: `客户备注${index + 1}`, | ||
| 294 | + value: item, | ||
| 295 | + })); | ||
| 296 | + if (remarksData.length > 0) { | ||
| 297 | + this.defaultRemark = this.customerRemarks[0].label || ''; | ||
| 298 | + this.form.remarks = remarksData[0]; | ||
| 299 | + } else { | ||
| 300 | + this.form.remarks = ''; | ||
| 301 | + this.defaultRemark = ''; | ||
| 302 | + } | ||
| 303 | + }) | ||
| 304 | + this.getHistory() | ||
| 305 | + } | ||
| 306 | + } | ||
| 307 | + }, | ||
| 308 | + productLineList: { | ||
| 309 | + deep: true, | ||
| 310 | + handler(newVal, oldVal) { | ||
| 311 | + const n = Array.isArray(newVal) ? newVal : [] | ||
| 312 | + const o = Array.isArray(oldVal) ? oldVal : [] | ||
| 313 | + const changed = [] | ||
| 314 | + for (let i = 0; i < n.length; i++) { | ||
| 315 | + const ni = n[i] && n[i].productId | ||
| 316 | + const oi = o[i] && o[i].productId | ||
| 317 | + if (ni !== oi && ni !== undefined) changed.push(ni) | ||
| 318 | + } | ||
| 319 | + console.log('changed', changed) | ||
| 320 | + if (changed.length && this.form.buyer) { | ||
| 321 | + const id = changed.join('') | ||
| 322 | + this.fetchCustomerQualityRequirements(id) | ||
| 323 | + } | ||
| 324 | + } | ||
| 325 | + }, | ||
| 326 | + }, | ||
| 271 | methods: { | 327 | methods: { |
| 328 | + getHistory() { | ||
| 329 | + console.log('this.productLineList', this.productLineList[0].productId) | ||
| 330 | + if (!this.productLineList.length || !this.productLineList[0].productId) { | ||
| 331 | + return; | ||
| 332 | + } | ||
| 333 | + const id = this.productLineList.map(it => it.productId).join('') | ||
| 334 | + this.fetchCustomerQualityRequirements(id) | ||
| 335 | + }, | ||
| 336 | + async fetchCustomerQualityRequirements(id) { | ||
| 337 | + if (!this.form.buyer || !id) { | ||
| 338 | + return; | ||
| 339 | + } | ||
| 340 | + try { | ||
| 341 | + const result = await getCustomerSpecificQualityRequirements({ | ||
| 342 | + customerId: this.form.buyer, | ||
| 343 | + productIdList:id, | ||
| 344 | + }); | ||
| 345 | + this.updateFormData(result.data || {}); | ||
| 346 | + } catch (error) { | ||
| 347 | + console.error('获取客户质量要求失败:', error); | ||
| 348 | + // 可以根据需要添加错误提示逻辑 | ||
| 349 | + this.$message.error('获取历史数据失败,请稍后重试'); | ||
| 350 | + } | ||
| 351 | + }, | ||
| 352 | + // 提取公共的字段更新方法 | ||
| 353 | + updateFormData(result) { | ||
| 354 | + console.log('result', result) | ||
| 355 | + const fields = [ | ||
| 356 | + 'component', | ||
| 357 | + 'packaging', | ||
| 358 | + 'performance', | ||
| 359 | + 'pieceWeightHead', | ||
| 360 | + 'surface', | ||
| 361 | + 'tolerance', | ||
| 362 | + ]; | ||
| 363 | + fields.forEach((field) => { | ||
| 364 | + this.form[field] = (this.form[field] || '') + (result[field] || ''); | ||
| 365 | + }); | ||
| 366 | + }, | ||
| 272 | onProductsChange(products) { | 367 | onProductsChange(products) { |
| 273 | const list = Array.isArray(products) ? products : [] | 368 | const list = Array.isArray(products) ? products : [] |
| 274 | const sumQ = list.reduce((acc, it) => acc + (parseFloat(it.quantity) || 0), 0) | 369 | const sumQ = list.reduce((acc, it) => acc + (parseFloat(it.quantity) || 0), 0) |
| @@ -356,14 +451,21 @@ export default { | @@ -356,14 +451,21 @@ export default { | ||
| 356 | setSheet('单价中是否已包含包装费', this.yesNoList) | 451 | setSheet('单价中是否已包含包装费', this.yesNoList) |
| 357 | } else if (field === 'includesTransportFee') { | 452 | } else if (field === 'includesTransportFee') { |
| 358 | setSheet('单价中是否已包含运费', this.yesNoList) | 453 | setSheet('单价中是否已包含运费', this.yesNoList) |
| 454 | + } else if (field === 'historyRemarks') { | ||
| 455 | + setSheet('历史备注', this.customerRemarks) | ||
| 359 | } | 456 | } |
| 360 | }, | 457 | }, |
| 361 | onSheetConfirm({ value, label }) { | 458 | onSheetConfirm({ value, label }) { |
| 362 | const field = this.sheet.field | 459 | const field = this.sheet.field |
| 363 | if (!field) return | 460 | if (!field) return |
| 364 | const v = (value === undefined || value === null) ? '' : value | 461 | const v = (value === undefined || value === null) ? '' : value |
| 365 | - this.form[field] = v | ||
| 366 | - this.form[field + 'Name'] = label || '' | 462 | + if (field === 'historyRemarks') { |
| 463 | + this.defaultRemark = label || '' | ||
| 464 | + this.form.remarks = v | ||
| 465 | + }else{ | ||
| 466 | + this.form[field] = v | ||
| 467 | + this.form[field + 'Name'] = label || '' | ||
| 468 | + } | ||
| 367 | }, | 469 | }, |
| 368 | openRelate(fieldKey) { | 470 | openRelate(fieldKey) { |
| 369 | let config = {} | 471 | let config = {} |
| @@ -123,9 +123,15 @@ | @@ -123,9 +123,15 @@ | ||
| 123 | <uni-easyinput v-model="form.specialInstructions" placeholder="请输入特别说明" :inputBorder="false" /> | 123 | <uni-easyinput v-model="form.specialInstructions" placeholder="请输入特别说明" :inputBorder="false" /> |
| 124 | </template> | 124 | </template> |
| 125 | </uni-list-item> | 125 | </uni-list-item> |
| 126 | + <uni-list-item v-if="this.customerRemarks.length" class="select-item" :class="defaultRemark ? 'is-filled' : 'is-empty'" clickable | ||
| 127 | + @click="openSheet('historyRemarks')" :rightText="defaultRemark || '请选择'" showArrow> | ||
| 128 | + <template v-slot:body> | ||
| 129 | + <view class="item-title"><text>历史备注</text></view> | ||
| 130 | + </template> | ||
| 131 | + </uni-list-item> | ||
| 126 | <uni-list-item title="备注"> | 132 | <uni-list-item title="备注"> |
| 127 | <template v-slot:footer> | 133 | <template v-slot:footer> |
| 128 | - <uni-easyinput v-model="form.remarks" placeholder="请输入备注" :inputBorder="false" /> | 134 | + <uni-easyinput type="textarea" v-model="form.remarks" placeholder="请输入备注" :inputBorder="false" /> |
| 129 | </template> | 135 | </template> |
| 130 | </uni-list-item> | 136 | </uni-list-item> |
| 131 | <view class="quality"> | 137 | <view class="quality"> |
| @@ -134,32 +140,32 @@ | @@ -134,32 +140,32 @@ | ||
| 134 | </view> | 140 | </view> |
| 135 | <uni-list-item title="件重条头"> | 141 | <uni-list-item title="件重条头"> |
| 136 | <template v-slot:footer> | 142 | <template v-slot:footer> |
| 137 | - <uni-easyinput v-model="form.pieceWeightHead" placeholder="请输入" :inputBorder="false" /> | 143 | + <uni-easyinput type="textarea" v-model="form.pieceWeightHead" placeholder="请输入" :inputBorder="false" /> |
| 138 | </template> | 144 | </template> |
| 139 | </uni-list-item> | 145 | </uni-list-item> |
| 140 | <uni-list-item title="表面"> | 146 | <uni-list-item title="表面"> |
| 141 | <template v-slot:footer> | 147 | <template v-slot:footer> |
| 142 | - <uni-easyinput v-model="form.surface" placeholder="请输入" :inputBorder="false" /> | 148 | + <uni-easyinput type="textarea" v-model="form.surface" placeholder="请输入" :inputBorder="false" /> |
| 143 | </template> | 149 | </template> |
| 144 | </uni-list-item> | 150 | </uni-list-item> |
| 145 | <uni-list-item title="公差"> | 151 | <uni-list-item title="公差"> |
| 146 | <template v-slot:footer> | 152 | <template v-slot:footer> |
| 147 | - <uni-easyinput v-model="form.tolerance" placeholder="请输入" :inputBorder="false" /> | 153 | + <uni-easyinput type="textarea" v-model="form.tolerance" placeholder="请输入" :inputBorder="false" /> |
| 148 | </template> | 154 | </template> |
| 149 | </uni-list-item> | 155 | </uni-list-item> |
| 150 | <uni-list-item title="性能"> | 156 | <uni-list-item title="性能"> |
| 151 | <template v-slot:footer> | 157 | <template v-slot:footer> |
| 152 | - <uni-easyinput v-model="form.performance" placeholder="请输入" :inputBorder="false" /> | 158 | + <uni-easyinput type="textarea" v-model="form.performance" placeholder="请输入" :inputBorder="false" /> |
| 153 | </template> | 159 | </template> |
| 154 | </uni-list-item> | 160 | </uni-list-item> |
| 155 | <uni-list-item title="成分"> | 161 | <uni-list-item title="成分"> |
| 156 | <template v-slot:footer> | 162 | <template v-slot:footer> |
| 157 | - <uni-easyinput v-model="form.component" placeholder="请输入" :inputBorder="false" /> | 163 | + <uni-easyinput type="textarea" v-model="form.component" placeholder="请输入" :inputBorder="false" /> |
| 158 | </template> | 164 | </template> |
| 159 | </uni-list-item> | 165 | </uni-list-item> |
| 160 | <uni-list-item title="包装"> | 166 | <uni-list-item title="包装"> |
| 161 | <template v-slot:footer> | 167 | <template v-slot:footer> |
| 162 | - <uni-easyinput v-model="form.packaging" placeholder="请输入" :inputBorder="false" /> | 168 | + <uni-easyinput type="textarea" v-model="form.packaging" placeholder="请输入" :inputBorder="false" /> |
| 163 | </template> | 169 | </template> |
| 164 | </uni-list-item> | 170 | </uni-list-item> |
| 165 | </uni-list> | 171 | </uni-list> |
| @@ -210,7 +216,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | @@ -210,7 +216,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | ||
| 210 | import RelateSelectSheet from '@/components/relate-select/index.vue' | 216 | import RelateSelectSheet from '@/components/relate-select/index.vue' |
| 211 | import ProductRel from './productRel.vue' | 217 | import ProductRel from './productRel.vue' |
| 212 | import CitySelector from '@/components/city-selector/index.vue' | 218 | import CitySelector from '@/components/city-selector/index.vue' |
| 213 | -import { getRetailCodeApi, createContractApi } from '@/api/contract' | 219 | +import { getRetailCodeApi, createContractApi,getCustomerRemarks,getCustomerSpecificQualityRequirements } from '@/api/contract' |
| 214 | import { getDicByCodes } from '@/utils/dic' | 220 | import { getDicByCodes } from '@/utils/dic' |
| 215 | import { formatCurrencyToChinese } from '@/utils/common' | 221 | import { formatCurrencyToChinese } from '@/utils/common' |
| 216 | import { workshopQueryApi } from '@/api/devManage' | 222 | import { workshopQueryApi } from '@/api/devManage' |
| @@ -243,6 +249,13 @@ export default { | @@ -243,6 +249,13 @@ export default { | ||
| 243 | destinationLabel: '', | 249 | destinationLabel: '', |
| 244 | workshopIdName: '', | 250 | workshopIdName: '', |
| 245 | workshopId: '', | 251 | workshopId: '', |
| 252 | + remarks: '', | ||
| 253 | + component: '', | ||
| 254 | + packaging: '', | ||
| 255 | + performance: '', | ||
| 256 | + pieceWeightHead: '', | ||
| 257 | + surface: '', | ||
| 258 | + tolerance: '', | ||
| 246 | }, | 259 | }, |
| 247 | supplierList: [], | 260 | supplierList: [], |
| 248 | specialTermsList: [], | 261 | specialTermsList: [], |
| @@ -255,6 +268,8 @@ export default { | @@ -255,6 +268,8 @@ export default { | ||
| 255 | sumTotal: 0, | 268 | sumTotal: 0, |
| 256 | productLineList: [], | 269 | productLineList: [], |
| 257 | productList: [], | 270 | productList: [], |
| 271 | + customerRemarks: [], | ||
| 272 | + defaultRemark: '', | ||
| 258 | } | 273 | } |
| 259 | }, | 274 | }, |
| 260 | created() { | 275 | created() { |
| @@ -268,7 +283,86 @@ export default { | @@ -268,7 +283,86 @@ export default { | ||
| 268 | } | 283 | } |
| 269 | }) | 284 | }) |
| 270 | }, | 285 | }, |
| 286 | + watch: { | ||
| 287 | + 'form.buyer': { | ||
| 288 | + handler(newVal, oldVal) { | ||
| 289 | + if (newVal) { | ||
| 290 | + getCustomerRemarks(newVal).then(res => { | ||
| 291 | + const remarksData = res.data || []; | ||
| 292 | + this.customerRemarks = remarksData.map((item, index) => ({ | ||
| 293 | + label: `客户备注${index + 1}`, | ||
| 294 | + value: item, | ||
| 295 | + })); | ||
| 296 | + if (remarksData.length > 0) { | ||
| 297 | + this.defaultRemark = this.customerRemarks[0].label || ''; | ||
| 298 | + this.form.remarks = remarksData[0]; | ||
| 299 | + } else { | ||
| 300 | + this.form.remarks = ''; | ||
| 301 | + this.defaultRemark = ''; | ||
| 302 | + } | ||
| 303 | + }) | ||
| 304 | + this.getHistory() | ||
| 305 | + } | ||
| 306 | + } | ||
| 307 | + }, | ||
| 308 | + productLineList: { | ||
| 309 | + deep: true, | ||
| 310 | + handler(newVal, oldVal) { | ||
| 311 | + const n = Array.isArray(newVal) ? newVal : [] | ||
| 312 | + const o = Array.isArray(oldVal) ? oldVal : [] | ||
| 313 | + const changed = [] | ||
| 314 | + for (let i = 0; i < n.length; i++) { | ||
| 315 | + const ni = n[i] && n[i].productId | ||
| 316 | + const oi = o[i] && o[i].productId | ||
| 317 | + if (ni !== oi && ni !== undefined) changed.push(ni) | ||
| 318 | + } | ||
| 319 | + if (changed.length && this.form.buyer) { | ||
| 320 | + const id = changed.join('') | ||
| 321 | + this.fetchCustomerQualityRequirements(id) | ||
| 322 | + } | ||
| 323 | + } | ||
| 324 | + }, | ||
| 325 | + }, | ||
| 271 | methods: { | 326 | methods: { |
| 327 | + getHistory() { | ||
| 328 | + console.log('this.productLineList', this.productLineList[0].productId) | ||
| 329 | + if (!this.productLineList.length || !this.productLineList[0].productId) { | ||
| 330 | + return; | ||
| 331 | + } | ||
| 332 | + const id = this.productLineList.map(it => it.productId).join('') | ||
| 333 | + this.fetchCustomerQualityRequirements(id) | ||
| 334 | + }, | ||
| 335 | + async fetchCustomerQualityRequirements(id) { | ||
| 336 | + if (!this.form.buyer || !id) { | ||
| 337 | + return; | ||
| 338 | + } | ||
| 339 | + try { | ||
| 340 | + const result = await getCustomerSpecificQualityRequirements({ | ||
| 341 | + customerId: this.form.buyer, | ||
| 342 | + productIdList:id, | ||
| 343 | + }); | ||
| 344 | + this.updateFormData(result.data || {}); | ||
| 345 | + } catch (error) { | ||
| 346 | + console.error('获取客户质量要求失败:', error); | ||
| 347 | + // 可以根据需要添加错误提示逻辑 | ||
| 348 | + this.$message.error('获取历史数据失败,请稍后重试'); | ||
| 349 | + } | ||
| 350 | + }, | ||
| 351 | + // 提取公共的字段更新方法 | ||
| 352 | + updateFormData(result) { | ||
| 353 | + console.log('result', result) | ||
| 354 | + const fields = [ | ||
| 355 | + 'component', | ||
| 356 | + 'packaging', | ||
| 357 | + 'performance', | ||
| 358 | + 'pieceWeightHead', | ||
| 359 | + 'surface', | ||
| 360 | + 'tolerance', | ||
| 361 | + ]; | ||
| 362 | + fields.forEach((field) => { | ||
| 363 | + this.form[field] = (this.form[field] || '') + (result[field] || ''); | ||
| 364 | + }); | ||
| 365 | + }, | ||
| 272 | onProductsChange(products) { | 366 | onProductsChange(products) { |
| 273 | const list = Array.isArray(products) ? products : [] | 367 | const list = Array.isArray(products) ? products : [] |
| 274 | const sumQ = list.reduce((acc, it) => acc + (parseFloat(it.quantity) || 0), 0) | 368 | const sumQ = list.reduce((acc, it) => acc + (parseFloat(it.quantity) || 0), 0) |
| @@ -356,14 +450,21 @@ export default { | @@ -356,14 +450,21 @@ export default { | ||
| 356 | setSheet('单价中是否已包含包装费', this.yesNoList) | 450 | setSheet('单价中是否已包含包装费', this.yesNoList) |
| 357 | } else if (field === 'includesTransportFee') { | 451 | } else if (field === 'includesTransportFee') { |
| 358 | setSheet('单价中是否已包含运费', this.yesNoList) | 452 | setSheet('单价中是否已包含运费', this.yesNoList) |
| 453 | + } else if (field === 'historyRemarks') { | ||
| 454 | + setSheet('历史备注', this.customerRemarks) | ||
| 359 | } | 455 | } |
| 360 | }, | 456 | }, |
| 361 | onSheetConfirm({ value, label }) { | 457 | onSheetConfirm({ value, label }) { |
| 362 | const field = this.sheet.field | 458 | const field = this.sheet.field |
| 363 | if (!field) return | 459 | if (!field) return |
| 364 | const v = (value === undefined || value === null) ? '' : value | 460 | const v = (value === undefined || value === null) ? '' : value |
| 365 | - this.form[field] = v | ||
| 366 | - this.form[field + 'Name'] = label || '' | 461 | + if (field === 'historyRemarks') { |
| 462 | + this.defaultRemark = label || '' | ||
| 463 | + this.form.remarks = v | ||
| 464 | + }else{ | ||
| 465 | + this.form[field] = v | ||
| 466 | + this.form[field + 'Name'] = label || '' | ||
| 467 | + } | ||
| 367 | }, | 468 | }, |
| 368 | openRelate(fieldKey) { | 469 | openRelate(fieldKey) { |
| 369 | let config = {} | 470 | let config = {} |
| @@ -123,9 +123,15 @@ | @@ -123,9 +123,15 @@ | ||
| 123 | <uni-easyinput v-model="form.specialInstructions" placeholder="请输入特别说明" :inputBorder="false" /> | 123 | <uni-easyinput v-model="form.specialInstructions" placeholder="请输入特别说明" :inputBorder="false" /> |
| 124 | </template> | 124 | </template> |
| 125 | </uni-list-item> | 125 | </uni-list-item> |
| 126 | + <uni-list-item v-if="this.customerRemarks.length" class="select-item" :class="defaultRemark ? 'is-filled' : 'is-empty'" clickable | ||
| 127 | + @click="openSheet('historyRemarks')" :rightText="defaultRemark || '请选择'" showArrow> | ||
| 128 | + <template v-slot:body> | ||
| 129 | + <view class="item-title"><text>历史备注</text></view> | ||
| 130 | + </template> | ||
| 131 | + </uni-list-item> | ||
| 126 | <uni-list-item title="备注"> | 132 | <uni-list-item title="备注"> |
| 127 | <template v-slot:footer> | 133 | <template v-slot:footer> |
| 128 | - <uni-easyinput v-model="form.remarks" placeholder="请输入备注" :inputBorder="false" /> | 134 | + <uni-easyinput type="textarea" v-model="form.remarks" placeholder="请输入备注" :inputBorder="false" /> |
| 129 | </template> | 135 | </template> |
| 130 | </uni-list-item> | 136 | </uni-list-item> |
| 131 | <view class="quality"> | 137 | <view class="quality"> |
| @@ -134,32 +140,32 @@ | @@ -134,32 +140,32 @@ | ||
| 134 | </view> | 140 | </view> |
| 135 | <uni-list-item title="件重条头"> | 141 | <uni-list-item title="件重条头"> |
| 136 | <template v-slot:footer> | 142 | <template v-slot:footer> |
| 137 | - <uni-easyinput v-model="form.pieceWeightHead" placeholder="请输入" :inputBorder="false" /> | 143 | + <uni-easyinput type="textarea" v-model="form.pieceWeightHead" placeholder="请输入" :inputBorder="false" /> |
| 138 | </template> | 144 | </template> |
| 139 | </uni-list-item> | 145 | </uni-list-item> |
| 140 | <uni-list-item title="表面"> | 146 | <uni-list-item title="表面"> |
| 141 | <template v-slot:footer> | 147 | <template v-slot:footer> |
| 142 | - <uni-easyinput v-model="form.surface" placeholder="请输入" :inputBorder="false" /> | 148 | + <uni-easyinput type="textarea" v-model="form.surface" placeholder="请输入" :inputBorder="false" /> |
| 143 | </template> | 149 | </template> |
| 144 | </uni-list-item> | 150 | </uni-list-item> |
| 145 | <uni-list-item title="公差"> | 151 | <uni-list-item title="公差"> |
| 146 | <template v-slot:footer> | 152 | <template v-slot:footer> |
| 147 | - <uni-easyinput v-model="form.tolerance" placeholder="请输入" :inputBorder="false" /> | 153 | + <uni-easyinput type="textarea" v-model="form.tolerance" placeholder="请输入" :inputBorder="false" /> |
| 148 | </template> | 154 | </template> |
| 149 | </uni-list-item> | 155 | </uni-list-item> |
| 150 | <uni-list-item title="性能"> | 156 | <uni-list-item title="性能"> |
| 151 | <template v-slot:footer> | 157 | <template v-slot:footer> |
| 152 | - <uni-easyinput v-model="form.performance" placeholder="请输入" :inputBorder="false" /> | 158 | + <uni-easyinput type="textarea" v-model="form.performance" placeholder="请输入" :inputBorder="false" /> |
| 153 | </template> | 159 | </template> |
| 154 | </uni-list-item> | 160 | </uni-list-item> |
| 155 | <uni-list-item title="成分"> | 161 | <uni-list-item title="成分"> |
| 156 | <template v-slot:footer> | 162 | <template v-slot:footer> |
| 157 | - <uni-easyinput v-model="form.component" placeholder="请输入" :inputBorder="false" /> | 163 | + <uni-easyinput type="textarea" v-model="form.component" placeholder="请输入" :inputBorder="false" /> |
| 158 | </template> | 164 | </template> |
| 159 | </uni-list-item> | 165 | </uni-list-item> |
| 160 | <uni-list-item title="包装"> | 166 | <uni-list-item title="包装"> |
| 161 | <template v-slot:footer> | 167 | <template v-slot:footer> |
| 162 | - <uni-easyinput v-model="form.packaging" placeholder="请输入" :inputBorder="false" /> | 168 | + <uni-easyinput type="textarea" v-model="form.packaging" placeholder="请输入" :inputBorder="false" /> |
| 163 | </template> | 169 | </template> |
| 164 | </uni-list-item> | 170 | </uni-list-item> |
| 165 | </uni-list> | 171 | </uni-list> |
| @@ -210,7 +216,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | @@ -210,7 +216,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | ||
| 210 | import RelateSelectSheet from '@/components/relate-select/index.vue' | 216 | import RelateSelectSheet from '@/components/relate-select/index.vue' |
| 211 | import ProductRel from './productRel.vue' | 217 | import ProductRel from './productRel.vue' |
| 212 | import CitySelector from '@/components/city-selector/index.vue' | 218 | import CitySelector from '@/components/city-selector/index.vue' |
| 213 | -import { getRetailCodeApi, createContractApi } from '@/api/contract' | 219 | +import { getRetailCodeApi, createContractApi, getCustomerRemarks,getCustomerSpecificQualityRequirements } from '@/api/contract' |
| 214 | import { getDicByCodes } from '@/utils/dic' | 220 | import { getDicByCodes } from '@/utils/dic' |
| 215 | import { formatCurrencyToChinese } from '@/utils/common' | 221 | import { formatCurrencyToChinese } from '@/utils/common' |
| 216 | import { workshopQueryApi } from '@/api/devManage' | 222 | import { workshopQueryApi } from '@/api/devManage' |
| @@ -243,6 +249,13 @@ export default { | @@ -243,6 +249,13 @@ export default { | ||
| 243 | destinationLabel: '', | 249 | destinationLabel: '', |
| 244 | workshopIdName: '', | 250 | workshopIdName: '', |
| 245 | workshopId: '', | 251 | workshopId: '', |
| 252 | + remarks: '', | ||
| 253 | + component: '', | ||
| 254 | + packaging: '', | ||
| 255 | + performance: '', | ||
| 256 | + pieceWeightHead: '', | ||
| 257 | + surface: '', | ||
| 258 | + tolerance: '', | ||
| 246 | }, | 259 | }, |
| 247 | supplierList: [], | 260 | supplierList: [], |
| 248 | specialTermsList: [], | 261 | specialTermsList: [], |
| @@ -255,6 +268,8 @@ export default { | @@ -255,6 +268,8 @@ export default { | ||
| 255 | sumTotal: 0, | 268 | sumTotal: 0, |
| 256 | productLineList: [], | 269 | productLineList: [], |
| 257 | productList: [], | 270 | productList: [], |
| 271 | + customerRemarks: [], | ||
| 272 | + defaultRemark: '', | ||
| 258 | } | 273 | } |
| 259 | }, | 274 | }, |
| 260 | created() { | 275 | created() { |
| @@ -268,7 +283,86 @@ export default { | @@ -268,7 +283,86 @@ export default { | ||
| 268 | } | 283 | } |
| 269 | }) | 284 | }) |
| 270 | }, | 285 | }, |
| 286 | + watch: { | ||
| 287 | + 'form.buyer': { | ||
| 288 | + handler(newVal, oldVal) { | ||
| 289 | + if (newVal) { | ||
| 290 | + getCustomerRemarks(newVal).then(res => { | ||
| 291 | + const remarksData = res.data || []; | ||
| 292 | + this.customerRemarks = remarksData.map((item, index) => ({ | ||
| 293 | + label: `客户备注${index + 1}`, | ||
| 294 | + value: item, | ||
| 295 | + })); | ||
| 296 | + if (remarksData.length > 0) { | ||
| 297 | + this.defaultRemark = this.customerRemarks[0].label || ''; | ||
| 298 | + this.form.remarks = remarksData[0]; | ||
| 299 | + } else { | ||
| 300 | + this.form.remarks = ''; | ||
| 301 | + this.defaultRemark = ''; | ||
| 302 | + } | ||
| 303 | + }) | ||
| 304 | + this.getHistory() | ||
| 305 | + } | ||
| 306 | + } | ||
| 307 | + }, | ||
| 308 | + productLineList: { | ||
| 309 | + deep: true, | ||
| 310 | + handler(newVal, oldVal) { | ||
| 311 | + const n = Array.isArray(newVal) ? newVal : [] | ||
| 312 | + const o = Array.isArray(oldVal) ? oldVal : [] | ||
| 313 | + const changed = [] | ||
| 314 | + for (let i = 0; i < n.length; i++) { | ||
| 315 | + const ni = n[i] && n[i].productId | ||
| 316 | + const oi = o[i] && o[i].productId | ||
| 317 | + if (ni !== oi && ni !== undefined) changed.push(ni) | ||
| 318 | + } | ||
| 319 | + if (changed.length && this.form.buyer) { | ||
| 320 | + const id = changed.join('') | ||
| 321 | + this.fetchCustomerQualityRequirements(id) | ||
| 322 | + } | ||
| 323 | + } | ||
| 324 | + }, | ||
| 325 | + }, | ||
| 271 | methods: { | 326 | methods: { |
| 327 | + getHistory() { | ||
| 328 | + console.log('this.productLineList', this.productLineList[0].productId) | ||
| 329 | + if (!this.productLineList.length || !this.productLineList[0].productId) { | ||
| 330 | + return; | ||
| 331 | + } | ||
| 332 | + const id = this.productLineList.map(it => it.productId).join('') | ||
| 333 | + this.fetchCustomerQualityRequirements(id) | ||
| 334 | + }, | ||
| 335 | + async fetchCustomerQualityRequirements(id) { | ||
| 336 | + if (!this.form.buyer || !id) { | ||
| 337 | + return; | ||
| 338 | + } | ||
| 339 | + try { | ||
| 340 | + const result = await getCustomerSpecificQualityRequirements({ | ||
| 341 | + customerId: this.form.buyer, | ||
| 342 | + productIdList:id, | ||
| 343 | + }); | ||
| 344 | + this.updateFormData(result.data || {}); | ||
| 345 | + } catch (error) { | ||
| 346 | + console.error('获取客户质量要求失败:', error); | ||
| 347 | + // 可以根据需要添加错误提示逻辑 | ||
| 348 | + this.$message.error('获取历史数据失败,请稍后重试'); | ||
| 349 | + } | ||
| 350 | + }, | ||
| 351 | + // 提取公共的字段更新方法 | ||
| 352 | + updateFormData(result) { | ||
| 353 | + console.log('result', result) | ||
| 354 | + const fields = [ | ||
| 355 | + 'component', | ||
| 356 | + 'packaging', | ||
| 357 | + 'performance', | ||
| 358 | + 'pieceWeightHead', | ||
| 359 | + 'surface', | ||
| 360 | + 'tolerance', | ||
| 361 | + ]; | ||
| 362 | + fields.forEach((field) => { | ||
| 363 | + this.form[field] = (this.form[field] || '') + (result[field] || ''); | ||
| 364 | + }); | ||
| 365 | + }, | ||
| 272 | onProductsChange(products) { | 366 | onProductsChange(products) { |
| 273 | const list = Array.isArray(products) ? products : [] | 367 | const list = Array.isArray(products) ? products : [] |
| 274 | const sumQ = list.reduce((acc, it) => acc + (parseFloat(it.quantity) || 0), 0) | 368 | const sumQ = list.reduce((acc, it) => acc + (parseFloat(it.quantity) || 0), 0) |
| @@ -356,14 +450,21 @@ export default { | @@ -356,14 +450,21 @@ export default { | ||
| 356 | setSheet('单价中是否已包含包装费', this.yesNoList) | 450 | setSheet('单价中是否已包含包装费', this.yesNoList) |
| 357 | } else if (field === 'includesTransportFee') { | 451 | } else if (field === 'includesTransportFee') { |
| 358 | setSheet('单价中是否已包含运费', this.yesNoList) | 452 | setSheet('单价中是否已包含运费', this.yesNoList) |
| 453 | + } else if (field === 'historyRemarks') { | ||
| 454 | + setSheet('历史备注', this.customerRemarks) | ||
| 359 | } | 455 | } |
| 360 | }, | 456 | }, |
| 361 | onSheetConfirm({ value, label }) { | 457 | onSheetConfirm({ value, label }) { |
| 362 | const field = this.sheet.field | 458 | const field = this.sheet.field |
| 363 | if (!field) return | 459 | if (!field) return |
| 364 | const v = (value === undefined || value === null) ? '' : value | 460 | const v = (value === undefined || value === null) ? '' : value |
| 365 | - this.form[field] = v | ||
| 366 | - this.form[field + 'Name'] = label || '' | 461 | + if (field === 'historyRemarks') { |
| 462 | + this.defaultRemark = label || '' | ||
| 463 | + this.form.remarks = v | ||
| 464 | + }else{ | ||
| 465 | + this.form[field] = v | ||
| 466 | + this.form[field + 'Name'] = label || '' | ||
| 467 | + } | ||
| 367 | }, | 468 | }, |
| 368 | openRelate(fieldKey) { | 469 | openRelate(fieldKey) { |
| 369 | let config = {} | 470 | let config = {} |