|
@@ -23,8 +23,19 @@
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
+
|
|
|
|
+ <view v-if="serviceKeys.classKey && serviceItems2 && serviceItems2.length > 0">
|
|
|
|
+ <view class="font-title">服务项</view>
|
|
|
|
+ <view class="service-list">
|
|
|
|
+ <view v-for="item in serviceItems2" :key="item.id" @click="serviceChange(item, 'threeKey')"
|
|
|
|
+ :class="serviceKeys.threeKey === item.id ? 'servicetab classActive' : 'servicetab'">
|
|
|
|
+ {{ item.businessName }}
|
|
|
|
+ </view>
|
|
|
|
+ </view>
|
|
|
|
+ </view>
|
|
|
|
+
|
|
<view v-if="serviceKeys.itemKeyname || serviceKeys.classKeyname">
|
|
<view v-if="serviceKeys.itemKeyname || serviceKeys.classKeyname">
|
|
- <view class="font-title">服务时长(<text class="activeColor">{{ serviceKeys.itemKeyname ||
|
|
|
|
|
|
+ <view class="font-title">服务时长(<text class="activeColor">{{ serviceKeys.threeKeyname || serviceKeys.itemKeyname ||
|
|
serviceKeys.classKeyname }}</text>)</view>
|
|
serviceKeys.classKeyname }}</text>)</view>
|
|
<view class="service-list">
|
|
<view class="service-list">
|
|
<view v-for="item in timeList" :key="item.id" @click="serviceChange(item, 'time')"
|
|
<view v-for="item in timeList" :key="item.id" @click="serviceChange(item, 'time')"
|
|
@@ -32,7 +43,7 @@
|
|
{{ item.lable }}
|
|
{{ item.lable }}
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
- <view class="font-title">服务价格(<text class="activeColor">{{ serviceKeys.itemKeyname ||
|
|
|
|
|
|
+ <view class="font-title">服务价格(<text class="activeColor">{{ serviceKeys.threeKeyname || serviceKeys.itemKeyname ||
|
|
serviceKeys.classKeyname }}</text>)</view>
|
|
serviceKeys.classKeyname }}</text>)</view>
|
|
<view class="service-list">
|
|
<view class="service-list">
|
|
<up-input v-model="serviceKeys.price" placeholder="请设置服务价格">
|
|
<up-input v-model="serviceKeys.price" placeholder="请设置服务价格">
|
|
@@ -126,11 +137,27 @@ const details = ref({});//详情数据
|
|
const serviceOptions = ref([]);//服务类目
|
|
const serviceOptions = ref([]);//服务类目
|
|
const serviceItems = 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([]);//服务小类目
|
|
|
|
+
|
|
|
|
+
|
|
const serviceKeys = reactive({
|
|
const serviceKeys = reactive({
|
|
classKey: '',//服务类别
|
|
classKey: '',//服务类别
|
|
classKeyname: '',
|
|
classKeyname: '',
|
|
itemKey: '',//服务项目
|
|
itemKey: '',//服务项目
|
|
itemKeyname: '',
|
|
itemKeyname: '',
|
|
|
|
+ threeKey: '',//服务项
|
|
|
|
+ threeKeyname: '',
|
|
time: '',//时间
|
|
time: '',//时间
|
|
price: '',//价格
|
|
price: '',//价格
|
|
})
|
|
})
|
|
@@ -184,7 +211,7 @@ function onSubmit() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (!(serviceKeys.itemKeyname || serviceKeys.classKeyname)) {
|
|
|
|
|
|
+ if (!(serviceKeys.threeKeyname||serviceKeys.itemKeyname || serviceKeys.classKeyname)) {
|
|
uni.showToast({
|
|
uni.showToast({
|
|
title: '请选择服务',
|
|
title: '请选择服务',
|
|
icon: 'none'
|
|
icon: 'none'
|
|
@@ -209,7 +236,7 @@ function onSubmit() {
|
|
const parmas = {
|
|
const parmas = {
|
|
serviceCategory: data.value.key,
|
|
serviceCategory: data.value.key,
|
|
...file_url,
|
|
...file_url,
|
|
- businessManagementId: serviceKeys.itemKey || serviceKeys.classKey,
|
|
|
|
|
|
+ businessManagementId:serviceKeys.threeKey|| serviceKeys.itemKey || serviceKeys.classKey,
|
|
businessPrice: serviceKeys.price,
|
|
businessPrice: serviceKeys.price,
|
|
businessDuration: serviceKeys.time
|
|
businessDuration: serviceKeys.time
|
|
};
|
|
};
|
|
@@ -260,7 +287,7 @@ function onChange({ key, url }) {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
-function idToIndexs(array, targetId, path = []) {
|
|
|
|
|
|
+function handlerList(array, targetId, path = []) {
|
|
|
|
|
|
for (let i = 0; i < array.length; i++) {
|
|
for (let i = 0; i < array.length; i++) {
|
|
const item = array[i];
|
|
const item = array[i];
|
|
@@ -271,7 +298,7 @@ function idToIndexs(array, targetId, path = []) {
|
|
}
|
|
}
|
|
|
|
|
|
if (item.children) {
|
|
if (item.children) {
|
|
- const result = idToIndexs(item.children, targetId, currentPath);
|
|
|
|
|
|
+ const result = handlerList(item.children, targetId, currentPath);
|
|
if (result) {
|
|
if (result) {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@@ -280,18 +307,90 @@ function idToIndexs(array, targetId, path = []) {
|
|
|
|
|
|
return null; // 如果没有找到对应的项,返回 null
|
|
return null; // 如果没有找到对应的项,返回 null
|
|
}
|
|
}
|
|
|
|
+/**
|
|
|
|
+ * 根据目标id查找所有父级路径
|
|
|
|
+ * @param {Array} data 树形数据源(如 serviceOptions.value)
|
|
|
|
+ * @param {String|Number} targetId 要查找的目标id
|
|
|
|
+ * @param {String} [idKey='id'] id字段名
|
|
|
|
+ * @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 idToIndexs(targetId) {
|
|
|
|
+ const res = findParentPath(serviceOptions.value, targetId);
|
|
|
|
+ return res || {
|
|
|
|
+ parentIdPath: [],
|
|
|
|
+ businessTierName: ''
|
|
|
|
+ };
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const backfill = {
|
|
|
|
+ 2:'threeKey',
|
|
|
|
+ 1:'itemKey',
|
|
|
|
+ 0:'classKey',
|
|
|
|
+}
|
|
//重新提交的服务信息回显
|
|
//重新提交的服务信息回显
|
|
function servesInit() {
|
|
function servesInit() {
|
|
- const indexs = idToIndexs(serviceOptions.value, details.value.businessManagementId + '')
|
|
|
|
- const names = indexs.businessTierName.split('-');
|
|
|
|
|
|
+ const indexs = idToIndexs(details.value.businessManagementId + '');
|
|
|
|
+ const names = indexs.businessTierName.split('-').reverse();
|
|
|
|
+ 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];
|
|
|
|
+ }
|
|
|
|
+ console.log('obj',obj,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);
|
|
|
|
+ serviceItems.value = row.children;
|
|
|
|
+ }
|
|
|
|
+ if(obj.threeKey){
|
|
|
|
+ const row = handlerList(serviceOptions.value,obj.itemKey)
|
|
|
|
+ console.log(2,row);
|
|
|
|
+ serviceItems2.value = row.children;
|
|
|
|
+ }
|
|
Object.assign(serviceKeys, {
|
|
Object.assign(serviceKeys, {
|
|
- classKey: String(indexs.parentId) === String(data.value.key) ? indexs.id : indexs.parentId,//服务类别
|
|
|
|
- classKeyname: names[1],
|
|
|
|
- itemKey: indexs.id,//服务项目
|
|
|
|
- itemKeyname: indexs.businessName,
|
|
|
|
time: details.value.businessDuration,//时间
|
|
time: details.value.businessDuration,//时间
|
|
price: details.value.businessPrice,//价格
|
|
price: details.value.businessPrice,//价格
|
|
|
|
+ ...obj
|
|
})
|
|
})
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ handlerList(serviceOptions.value,serviceKeys.itemKey)
|
|
|
|
+
|
|
|
|
+ console.log('serviceKeys',serviceKeys);
|
|
|
|
+
|
|
}
|
|
}
|
|
async function getRegister() {
|
|
async function getRegister() {
|
|
|
|
|
|
@@ -335,6 +434,15 @@ const serviceChange = (item, key) => {
|
|
if (key === 'classKey') {
|
|
if (key === 'classKey') {
|
|
serviceItems.value = item.children;
|
|
serviceItems.value = item.children;
|
|
serviceKeys['itemKey'] = '';
|
|
serviceKeys['itemKey'] = '';
|
|
|
|
+ serviceKeys['itemKeyname'] = '';
|
|
|
|
+ serviceKeys['threeKey'] = '';
|
|
|
|
+ serviceKeys['threeKeyname'] = '';
|
|
|
|
+ serviceItems2.value = [];
|
|
|
|
+ }
|
|
|
|
+ if(key === 'itemKey'){
|
|
|
|
+ serviceItems2.value = item.children;
|
|
|
|
+ serviceKeys['threeKey'] = '';
|
|
|
|
+ serviceKeys['threeKeyname'] = '';
|
|
}
|
|
}
|
|
Object.assign(serviceKeys, {
|
|
Object.assign(serviceKeys, {
|
|
[key]: serviceKeys[key] === item.id ? '' : item.id,
|
|
[key]: serviceKeys[key] === item.id ? '' : item.id,
|