diff --git a/src/views/merchant/List.vue b/src/views/merchant/List.vue index 1d2aaf6..89f4037 100644 --- a/src/views/merchant/List.vue +++ b/src/views/merchant/List.vue @@ -22,8 +22,9 @@ {{ formatDateTime(record.create_time) }} @@ -154,7 +155,7 @@ v-model:value="formState.longitude" :min="-180" :max="180" - style="width: 50%" + style="width: calc(100% - 8px); margin-right: 16px" placeholder="经度" disabled /> @@ -162,7 +163,7 @@ v-model:value="formState.latitude" :min="-90" :max="90" - style="width: 50%" + style="width: calc(100% - 8px)" placeholder="纬度" disabled /> @@ -298,7 +299,7 @@ v-model:value="editFormState.longitude" :min="-180" :max="180" - style="width: 50%" + style="width: calc(100% - 8px); margin-right: 16px" placeholder="经度" disabled /> @@ -306,7 +307,7 @@ v-model:value="editFormState.latitude" :min="-90" :max="90" - style="width: 50%" + style="width: calc(100% - 8px)" placeholder="纬度" disabled /> @@ -314,6 +315,36 @@ + + + +
+ + + +
+
@@ -400,6 +431,16 @@ export default defineComponent({ key: 'name', width: 200, }, + { + title: '买单赠送积分比例', + dataIndex: 'pay_gift_points_rate', + key: 'pay_gift_points_rate', + width: 150, + align: 'center', + customRender: ({ text }) => { + return `${text || 0}%` + } + }, { title: '营业时间', dataIndex: 'business_hours', @@ -436,7 +477,7 @@ export default defineComponent({ key: 'action', width: 200, fixed: 'right', - align: 'center', + align: 'center' } ] @@ -457,11 +498,14 @@ export default defineComponent({ const res = await request.get('/api/merchant', { params }) if (res.data) { - tableData.value = res.data.items || [] + tableData.value = (res.data.items || []).map(item => ({ + ...item, + pay_gift_points_rate: Number(item.pay_gift_points_rate || 0) + })) pagination.value.total = res.data.total || 0 } } catch (error) { - console.error('获取商家列表失败:', error) + } finally { loading.value = false } @@ -503,7 +547,7 @@ export default defineComponent({ title: record.name }) } catch (error) { - console.error('加载地图失败:', error) + message.error('加载地图失败') } } @@ -535,7 +579,7 @@ export default defineComponent({ longitude: null, latitude: null, phone: '', - brand_image_url: '' + brand_image_url: '', }) const rules = { @@ -558,7 +602,7 @@ export default defineComponent({ categories.value = res.data.items || [] } } catch (error) { - console.error('获取商家分类失败:', error) + message.error('获取商家分类失败') } } @@ -603,7 +647,7 @@ export default defineComponent({ }) } } catch (error) { - console.error('初始化地图失败:', error) + message.error('初始化地图失败') } } @@ -649,7 +693,7 @@ export default defineComponent({ }) }) } catch (error) { - console.error('搜索地址失败:', error) + searchLoading.value = false message.error('搜索地址失败') } @@ -692,7 +736,7 @@ export default defineComponent({ addModalVisible.value = false fetchData() } catch (error) { - console.error('添加商家失败:', error) + } finally { confirmLoading.value = false } @@ -711,7 +755,7 @@ export default defineComponent({ longitude: null, latitude: null, phone: '', - brand_image_url: '' + brand_image_url: '', } searchAddress.value = '' searchOptions.value = [] @@ -766,7 +810,7 @@ export default defineComponent({ longitude: null, latitude: null, phone: '', - brand_image_url: '' + brand_image_url: '', }) const editSearchAddress = ref('') const editMap = ref(null) @@ -841,7 +885,7 @@ export default defineComponent({ editMap.value.setCenter([lng, lat]) updateEditMarkerPosition(lng, lat) } catch (error) { - console.error('初始化地图失败:', error) + message.error('初始化地图失败') } } @@ -904,7 +948,7 @@ export default defineComponent({ throw new Error(res.message || '修改失败') } } catch (error) { - console.error('修改商家失败:', error) + message.error(error.message || '修改失败') } finally { editLoading.value = false @@ -924,7 +968,7 @@ export default defineComponent({ longitude: null, latitude: null, phone: '', - brand_image_url: '' + brand_image_url: '', } editSearchAddress.value = '' userOptions.value = [] @@ -956,7 +1000,7 @@ export default defineComponent({ userOptions.value = res.data.items || [] } } catch (error) { - console.error('搜索用户失败:', error) + message.error('搜索用户失败') } finally { userLoading.value = false @@ -1020,7 +1064,7 @@ export default defineComponent({ message.error('上传失败') } } catch (error) { - console.error('上传失败:', error) + onError() message.error('上传失败') } @@ -1037,6 +1081,42 @@ export default defineComponent({ } } + // 修改积分比例相关代码 + const pointsRateModalVisible = ref(false) + const currentRecord = ref(null) + const pointsRateValue = ref(0) + + const showPointsRateModal = (record) => { + currentRecord.value = record + pointsRateValue.value = Number(record.pay_gift_points_rate || 0) + pointsRateModalVisible.value = true + } + + const handlePointsRateSubmit = async () => { + try { + if (pointsRateValue.value < 0 || pointsRateValue.value > 100) { + message.error('积分比例必须在0-100之间') + return + } + + const res = await request.put(`/api/merchant/${currentRecord.value.id}`, { + user_id: currentRecord.value.user_id, + pay_gift_points_rate: pointsRateValue.value + }) + + if (res.code === 200) { + message.success('修改成功') + pointsRateModalVisible.value = false + fetchData() + } else { + throw new Error(res.message || '修改失败') + } + } catch (error) { + + message.error(error.message || '修改失败') + } + } + onMounted(() => { fetchData() }) @@ -1085,7 +1165,11 @@ export default defineComponent({ brandImageList, editBrandImageList, handleBrandImageUpload, - handleBrandImageRemove + handleBrandImageRemove, + pointsRateModalVisible, + pointsRateValue, + showPointsRateModal, + handlePointsRateSubmit } } }) @@ -1263,4 +1347,43 @@ export default defineComponent({ background: transparent; box-shadow: none; } + +.points-rate-cell { + display: flex; + align-items: center; + justify-content: center; + gap: 4px; +} + +.percent-sign { + color: rgba(0, 0, 0, 0.85); +} + +:deep(.ant-input-number) { + width: 80px !important; +} + +.points-rate-form { + padding: 0 24px; +} + +.points-rate-form :deep(.ant-form-item) { + margin-bottom: 0; +} + +.points-rate-form :deep(.ant-form-item-label) { + padding-bottom: 8px; +} + +.points-rate-form :deep(.ant-form-item-extra) { + margin-top: 8px; +} + +.points-rate-form :deep(.ant-input-number-group-wrapper) { + width: 100%; +} + +.points-rate-form :deep(.ant-input-number) { + width: 100% !important; +} \ No newline at end of file