|
@@ -35,7 +35,8 @@
|
|
|
</view>
|
|
|
|
|
|
<view v-if="serviceKeys.itemKeyname || serviceKeys.classKeyname">
|
|
|
- <view class="font-title">服务时长(<text class="activeColor">{{ serviceKeys.threeKeyname || serviceKeys.itemKeyname ||
|
|
|
+ <view class="font-title">服务时长(<text class="activeColor">{{ serviceKeys.threeKeyname ||
|
|
|
+ serviceKeys.itemKeyname ||
|
|
|
serviceKeys.classKeyname }}</text>)</view>
|
|
|
<view class="service-list">
|
|
|
<view v-for="item in timeList" :key="item.id" @click="serviceChange(item, 'time')"
|
|
@@ -43,15 +44,22 @@
|
|
|
{{ item.lable }}
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="font-title">服务价格(<text class="activeColor">{{ serviceKeys.threeKeyname || serviceKeys.itemKeyname ||
|
|
|
+ <view class="font-title">服务价格(<text class="activeColor">{{ serviceKeys.threeKeyname ||
|
|
|
+ serviceKeys.itemKeyname ||
|
|
|
serviceKeys.classKeyname }}</text>)</view>
|
|
|
- <view class="service-list">
|
|
|
- <up-input v-model="serviceKeys.price" placeholder="请设置服务价格">
|
|
|
+ <view class="service-list price-box">
|
|
|
+ <up-input v-model="serviceKeys.price"
|
|
|
+ :placeholder="min_max_price.minPrice && min_max_price.maxPrice ? `${min_max_price.minPrice}-${min_max_price.maxPrice}` : '请设置服务价格'"
|
|
|
+ @blur="validatePriceInput" class="price-input">
|
|
|
<template #suffix>
|
|
|
<text>元</text>
|
|
|
</template>
|
|
|
</up-input>
|
|
|
</view>
|
|
|
+
|
|
|
+ <view class="price-describe" v-if="min_max_price.minPrice && min_max_price.maxPrice">
|
|
|
+ 价格说明
|
|
|
+ </view>
|
|
|
</view>
|
|
|
|
|
|
|
|
@@ -68,8 +76,7 @@
|
|
|
|
|
|
|
|
|
<view v-for="item in updata_list" :key="item.key" class="updata-imgs">
|
|
|
- <UpdataImgs :fileList="file_url[item.key]" :data="item" ref="zsImg"
|
|
|
- @onSubmit="onChange" />
|
|
|
+ <UpdataImgs :fileList="file_url[item.key]" :data="item" ref="zsImg" @onSubmit="onChange" />
|
|
|
</view>
|
|
|
|
|
|
|
|
@@ -94,6 +101,11 @@ import { getTreeList } from '@/api/volunteer'
|
|
|
const userImg = ref(null);
|
|
|
const zsImg = ref(null);
|
|
|
|
|
|
+const min_max_price = ref({
|
|
|
+ minPrice: 10,
|
|
|
+ maxPrice: 100
|
|
|
+})
|
|
|
+
|
|
|
|
|
|
const updata_list = [
|
|
|
{
|
|
@@ -137,17 +149,6 @@ const details = ref({});//详情数据
|
|
|
const serviceOptions = ref([]);//服务类目
|
|
|
const serviceItems = ref([]);//服务项目
|
|
|
|
|
|
-// const serviceItems = computed(() => {
|
|
|
-// const row = handlerList(serviceOptions.value,serviceKeys.classKey)
|
|
|
-// console.log('服务项目',row);
|
|
|
-// return row.children || []
|
|
|
-// });
|
|
|
-
|
|
|
-// const serviceItems2 = computed(() => {
|
|
|
-// const row = handlerList(serviceOptions.value,serviceKeys.itemKey)
|
|
|
-// console.log('服务项目2',row);
|
|
|
-// return row.children || []
|
|
|
-// });
|
|
|
const serviceItems2 = ref([]);//服务小类目
|
|
|
|
|
|
|
|
@@ -182,9 +183,34 @@ const sex_status = {
|
|
|
'女': 1
|
|
|
}
|
|
|
|
|
|
+const validatePriceInput = (value) => {
|
|
|
+ console.log("TCL: validatePriceInput -> value", value)
|
|
|
+ // 确保输入是纯数字
|
|
|
+ if (!/^\d*$/.test(value)) {
|
|
|
+ serviceKeys.price = value.replace(/\D/g, ''); // 移除非数字字符
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const price = parseInt(serviceKeys.price, 10);
|
|
|
+
|
|
|
+ // 检查是否在允许的范围之内
|
|
|
+ if (min_max_price.value.minPrice !== undefined && min_max_price.value.maxPrice !== undefined) {
|
|
|
+ if (price >= min_max_price.value.minPrice && price <= min_max_price.value.maxPrice) {
|
|
|
+ serviceKeys.price = serviceKeys.price.toString();
|
|
|
+ } else {
|
|
|
+ serviceKeys.price = null;
|
|
|
+ uni.showToast({
|
|
|
+ title: '请输入价格区间内的价格',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ console.log("TCL: validatePriceInput -> error", value)
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
//根据类型获取表单item 值
|
|
|
const com_column = computed(() => {
|
|
|
- let column_list = data.value ?column : [];
|
|
|
+ let column_list = data.value ? column : [];
|
|
|
return column_list
|
|
|
})
|
|
|
|
|
@@ -200,7 +226,7 @@ function onSubmit() {
|
|
|
const element = updata_list[i];
|
|
|
|
|
|
|
|
|
- const type = element.required&& !file_url[element.key];
|
|
|
+ const type = element.required && !file_url[element.key];
|
|
|
|
|
|
if (type) {
|
|
|
uni.showToast({
|
|
@@ -211,7 +237,7 @@ function onSubmit() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!(serviceKeys.threeKeyname||serviceKeys.itemKeyname || serviceKeys.classKeyname)) {
|
|
|
+ if (!(serviceKeys.threeKeyname || serviceKeys.itemKeyname || serviceKeys.classKeyname)) {
|
|
|
uni.showToast({
|
|
|
title: '请选择服务',
|
|
|
icon: 'none'
|
|
@@ -236,7 +262,7 @@ function onSubmit() {
|
|
|
const parmas = {
|
|
|
serviceCategory: data.value.key,
|
|
|
...file_url,
|
|
|
- businessManagementId:serviceKeys.threeKey|| serviceKeys.itemKey || serviceKeys.classKey,
|
|
|
+ businessManagementId: serviceKeys.threeKey || serviceKeys.itemKey || serviceKeys.classKey,
|
|
|
businessPrice: serviceKeys.price,
|
|
|
businessDuration: serviceKeys.time
|
|
|
};
|
|
@@ -315,43 +341,43 @@ function handlerList(array, targetId, path = []) {
|
|
|
* @param {String} [childrenKey='children'] 子级字段名
|
|
|
* @returns {Object|null}
|
|
|
*/
|
|
|
- function findParentPath(data, targetId, idKey = 'id', childrenKey = 'children') {
|
|
|
- for (const node of data) {
|
|
|
- // 当前节点匹配
|
|
|
- if (node[idKey] == targetId) {
|
|
|
- return {
|
|
|
- parentIdPath: [node[idKey]],
|
|
|
- businessTierName: node.businessName || ''
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
- // 搜索子级
|
|
|
- const result = node[childrenKey]?.length > 0
|
|
|
- ? findParentPath(node[childrenKey], targetId, idKey, childrenKey)
|
|
|
- : null;
|
|
|
-
|
|
|
- if (result) {
|
|
|
- return {
|
|
|
- parentIdPath: [...result.parentIdPath, node[idKey]],
|
|
|
- businessTierName: `${result.businessTierName}-${node.businessName || ''}`
|
|
|
- };
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return null;
|
|
|
+function findParentPath(data, targetId, idKey = 'id', childrenKey = 'children') {
|
|
|
+ for (const node of data) {
|
|
|
+ // 当前节点匹配
|
|
|
+ if (node[idKey] == targetId) {
|
|
|
+ return {
|
|
|
+ parentIdPath: [node[idKey]],
|
|
|
+ businessTierName: node.businessName || ''
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ // 搜索子级
|
|
|
+ const result = node[childrenKey]?.length > 0
|
|
|
+ ? findParentPath(node[childrenKey], targetId, idKey, childrenKey)
|
|
|
+ : null;
|
|
|
+
|
|
|
+ if (result) {
|
|
|
+ return {
|
|
|
+ parentIdPath: [...result.parentIdPath, node[idKey]],
|
|
|
+ businessTierName: `${result.businessTierName}-${node.businessName || ''}`
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
}
|
|
|
function idToIndexs(targetId) {
|
|
|
- const res = findParentPath(serviceOptions.value, targetId);
|
|
|
- return res || {
|
|
|
- parentIdPath: [],
|
|
|
- businessTierName: ''
|
|
|
- };
|
|
|
+ const res = findParentPath(serviceOptions.value, targetId);
|
|
|
+ return res || {
|
|
|
+ parentIdPath: [],
|
|
|
+ businessTierName: ''
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
const backfill = {
|
|
|
- 2:'threeKey',
|
|
|
- 1:'itemKey',
|
|
|
- 0:'classKey',
|
|
|
+ 2: 'threeKey',
|
|
|
+ 1: 'itemKey',
|
|
|
+ 0: 'classKey',
|
|
|
}
|
|
|
//重新提交的服务信息回显
|
|
|
function servesInit() {
|
|
@@ -360,24 +386,24 @@ function servesInit() {
|
|
|
const ids = indexs.parentIdPath.reverse();
|
|
|
const obj = {};
|
|
|
for (let i = 0; i < names.length; i++) {
|
|
|
- obj[backfill[i]] = ids[i];
|
|
|
- obj[backfill[i]+'name'] = names[i];
|
|
|
+ obj[backfill[i]] = ids[i];
|
|
|
+ obj[backfill[i] + 'name'] = names[i];
|
|
|
}
|
|
|
- console.log('obj',obj,names,ids);
|
|
|
+ console.log('obj', obj, names, ids);
|
|
|
|
|
|
|
|
|
- console.log('indexs', indexs,names,ids);
|
|
|
+ console.log('indexs', indexs, names, ids);
|
|
|
// const indexs = idToIndexs(serviceOptions.value, details.value.businessManagementId + '')
|
|
|
// const names = indexs.businessTierName.split('-');
|
|
|
// console.log('indexs',indexs,names);
|
|
|
- if(obj.itemKey){
|
|
|
- const row = handlerList(serviceOptions.value,obj.classKey)
|
|
|
- console.log(1,row);
|
|
|
+ if (obj.itemKey) {
|
|
|
+ const row = handlerList(serviceOptions.value, obj.classKey)
|
|
|
+ console.log(1, row);
|
|
|
serviceItems.value = row.children;
|
|
|
}
|
|
|
- if(obj.threeKey){
|
|
|
- const row = handlerList(serviceOptions.value,obj.itemKey)
|
|
|
- console.log(2,row);
|
|
|
+ if (obj.threeKey) {
|
|
|
+ const row = handlerList(serviceOptions.value, obj.itemKey)
|
|
|
+ console.log(2, row);
|
|
|
serviceItems2.value = row.children;
|
|
|
}
|
|
|
Object.assign(serviceKeys, {
|
|
@@ -387,10 +413,10 @@ function servesInit() {
|
|
|
})
|
|
|
|
|
|
|
|
|
- handlerList(serviceOptions.value,serviceKeys.itemKey)
|
|
|
+ handlerList(serviceOptions.value, serviceKeys.itemKey)
|
|
|
+
|
|
|
+ console.log('serviceKeys', serviceKeys);
|
|
|
|
|
|
- console.log('serviceKeys',serviceKeys);
|
|
|
-
|
|
|
}
|
|
|
async function getRegister() {
|
|
|
|
|
@@ -431,6 +457,14 @@ async function getRegister() {
|
|
|
|
|
|
|
|
|
const serviceChange = (item, key) => {
|
|
|
+
|
|
|
+ console.log("TCL: serviceChange -> item", item)
|
|
|
+ if (item.maxPrice && item.minPrice) {
|
|
|
+ min_max_price.value = {
|
|
|
+ minPrice: item.minPrice,
|
|
|
+ maxPrice: item.maxPrice,
|
|
|
+ }
|
|
|
+ }
|
|
|
if (key === 'classKey') {
|
|
|
serviceItems.value = item.children;
|
|
|
serviceKeys['itemKey'] = '';
|
|
@@ -439,7 +473,7 @@ const serviceChange = (item, key) => {
|
|
|
serviceKeys['threeKeyname'] = '';
|
|
|
serviceItems2.value = [];
|
|
|
}
|
|
|
- if(key === 'itemKey'){
|
|
|
+ if (key === 'itemKey') {
|
|
|
serviceItems2.value = item.children;
|
|
|
serviceKeys['threeKey'] = '';
|
|
|
serviceKeys['threeKeyname'] = '';
|
|
@@ -566,4 +600,18 @@ onLoad((options) => {
|
|
|
.activeColor {
|
|
|
color: rgba(221, 94, 69, 1);
|
|
|
}
|
|
|
+
|
|
|
+.price-box {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
+
|
|
|
+.price-describe {
|
|
|
+ font-size: 24rpx;
|
|
|
+ font-weight: 500;
|
|
|
+ letter-spacing: 0rpx;
|
|
|
+ line-height: 34.76rpx;
|
|
|
+ color: rgba(153, 153, 153, 1);
|
|
|
+ margin-top: 16rpx;
|
|
|
+}
|
|
|
</style>
|