Procházet zdrojové kódy

feat: 服务项目

chenjj před 4 týdny
rodič
revize
700ce4ec70

+ 11 - 1
api/volunteer.js

@@ -80,4 +80,14 @@ export function getVolunteerAccount(volunteerAccountId) {
         url: `/core/volunteer/account/${volunteerAccountId}`,
         method: 'get',
     })
-}
+}
+
+
+//查询所有业务列表(树形结构)
+export function getTreeList(query) {
+    return request({
+      url: '/core/business/management/getTreeList',
+      method: 'get',
+      params: query
+    })
+  }

+ 29 - 65
components/cust-form/index.vue

@@ -94,7 +94,7 @@
         <CcSelectDity :province="cityData.province" :city="cityData.city" :area="cityData.area" :show="cityShow"
             @sureSelectArea="onsetCity" @hideShow="onCityShow"></CcSelectDity>
 
-        <Picker :columnData="pickerData" ref="pickerRef" @submit="ActionSheetSelect" />
+        <Picker :columnData="options[actions.optionKey]" ref="pickerRef" @submit="ActionSheetSelect" />
     </view>
 </template>
 <script setup>
@@ -130,60 +130,15 @@ const form_ref = ref(null);
 
 const showSex = ref(false);
 const actions = ref({
-    option: []
+    option: [],
+    optionKey:'businessManagementOption'
 });
-const pickerData = ref([
-    {
-        businessName: '家庭教育',
-        id: '1',
-        children: [
-            {
-                businessName: '语文',
-                id: '2',
-                children: [
-                    {
-                        businessName: '一年级',
-                        id: '4',
-                    },
-                    {
-                        businessName: '二年级',
-                        id: '5',
-                    }
-                ]
-            },
-            {
-                businessName: '数学',
-                id: '3',
-            }
-        ]
-    },
-    {
-        businessName: '家庭清洁',
-        id: '6',
-        children: [
-            {
-                businessName: '清洁1',
-                id: '7',
-                children: [
-                    {
-                        businessName: '清洁11',
-                        id: '8',
-                    },
-                    {
-                        businessName: '清洁22',
-                        id: '9',
-                    }
-                ]
-            },
-            {
-                businessName: '清洁3',
-                id: '10',
-            }
-        ]
-    }
-])
 const pickerRef = ref(null)
 
+const options = reactive({
+    businessManagementOption: []
+})
+
 const cityData = reactive({
     province: "广东省",
     city: "广州市",
@@ -234,9 +189,9 @@ function ActionSheetSelect(e) {
     Object.assign(formData, {
         [actions.value.key]: e.key || e.name
     })
-    if(actions.value.type === 'cascader'){
+    if (actions.value.type === 'cascader') {
         Object.assign(formData, {
-            [actions.value.key + 'key' ]: e.value
+            [actions.value.key + 'key']: e.value
         })
     }
     console.log('formData.value', formData);
@@ -277,17 +232,19 @@ function setData(data) {
     console.log('setData=>data', data);
     for (let i = 0; i < props.column.length; i++) {
         const element = props.column[i];
-        
-        if(element.type === 'cascader') {
-            const key = "5"
-            const lable =  pickerRef.value.piceInit(key);
-            console.log('element.type',lable,key);
+
+        if (element.type === 'cascader') {
+            const key = data[element.key]
+            // const key ='7'
+
+            const lable = pickerRef.value.piceInit(key);
+            console.log('element.type', lable, key);
             Object.assign(formData, {
-                    [element.key]: lable,
-                    [element.key+'key']: key
-                })
+                [element.key]: lable,
+                [element.key + 'key']: key
+            })
         }
-        
+
     }
 
     Object.assign(formData, {
@@ -322,10 +279,17 @@ function clickPick(row) {
 }
 
 
-onMounted(() => {
+onMounted(async () => {
     const rules = {};
     for (let i = 0; i < props.column.length; i++) {
-        rules[props.column[i].key] = props.column[i].rules
+        rules[props.column[i].key] = props.column[i].rules;
+        if (props.column[i].type === 'cascader') {
+            const res = await props.column[i].apifun();
+            Object.assign(options, {
+                [props.column[i].optionKey]: res
+            })
+            console.log('onMounted9999', options);
+        }
     }
     form_ref.value && form_ref.value.setRules(rules)
     console.log('uni=====>', uni);

+ 12 - 5
components/picker/index.vue

@@ -1,5 +1,5 @@
 <template>
-  <up-picker :show="show" :defaultIndex="pickValue.indexs" ref="uPickerRef" valueKey="id" :columns="columns" @confirm="confirm" @change="changeHandler"></up-picker>
+  <up-picker :show="show" :defaultIndex="pickValue.indexs" ref="uPickerRef" valueKey="id" @cancel="cancel" :columns="columns" @confirm="confirm" @change="changeHandler"></up-picker>
 </template>
 
 <script setup>
@@ -19,10 +19,9 @@ const emit = defineEmits(['submit']);
 const show = ref(false);
 
 const pickValue = ref({
-  indexs: [0, 0, 1],
+  indexs: [0, 0, 0],
 });
 
-const cate = ref(5);
 
 /**
  * 
@@ -142,15 +141,23 @@ function indexsToNames(indexs){
     return names;
         }
 const piceInit = (id) => {
-  console.log('piceInit-id',id);
+  try {
+    console.log('piceInit-id',props.columnData,id);
   const indexs =  idToIndexs(props.columnData,id)
+  console.log('piceInit-indexs',indexs);
   const names = indexsToNames(indexs)
-  console.log('piceInit-indexs', indexs,names,names.join('/'));
   pickValue.value.indexs = indexs;
 
   return names.join('/')
+  } catch (error) {
+      console.log('piceInit-error',error);
+      
+  }
 }
 
+const cancel = () => {
+  show.value = false;
+};
 defineExpose({
   show() {
     show.value = true;

+ 11 - 1
pages_home/pages/register/data.js

@@ -1,3 +1,5 @@
+import { getTreeList } from '@/api/volunteer'
+
 const sex_option = [
     {
         name: '男',
@@ -190,7 +192,15 @@ const education = [
         type: "cascader",
         cascaderKey:'0',
         rules: rules.businessManagementId,
-        required:true
+        required:true,
+        apifun: ()=>{
+            return new Promise((resolve, reject) => {
+                getTreeList({ parentId: "2" }).then(res => {
+                    resolve(res.data)
+                })
+            })
+        },
+        optionKey:'businessManagementOption'
     },
     {
         label: "证件号",

+ 1 - 1
pages_home/pages/register/index.vue

@@ -137,7 +137,7 @@ function onSubmit() {
 
 			console.log('提交', parmas);
 
-			return;
+			// return;
 			// 提交接口,注册人员
 			const submit_res = await add(parmas);
 			if (submit_res.code == 200) {