Selaa lähdekoodia

学校信息编辑

Xiao_123 2 kuukautta sitten
vanhempi
commit
e3bf65312e

+ 77 - 69
src/views/recruit/teacher/teacherCertification/schoolInfo.vue

@@ -1,100 +1,63 @@
 <template>
-	<div>
-		<CtForm ref="CtFormRef" :items="formItems" style="width: 900px;margin: 0 auto"></CtForm>
+	<div class="d-flex flex-column align-center">
+		<CtForm ref="CtFormRef" :items="formItems" style="width: 900px;margin: 0 auto">
+      <template #photos="{ item }">
+        <div>
+					<p class="color-primary">*请上传学校环境图片(最多可上传9张图片)</p>
+					<p class="mb-3 color-primary">*只支持JPG、JPEG、PNG类型的图片</p>
+					<Imgs v-model="item.value" :showTips="false" limit="9"></Imgs>
+				</div>
+      </template>
+    </CtForm>
+    <v-btn class="buttons my-10" color="primary" @click.stop="handleSubmit">{{ $t('common.save') }}</v-btn>
 	</div>
+
+  <Loading :visible="overlay"></Loading>
 </template>
 
 <script setup>
 defineOptions({ name: 'schoolInfo' })
-import { ref } from 'vue'
+import { ref, onMounted } from 'vue'
+import { useI18n } from '@/hooks/web/useI18n'
+import { useUserStore } from '@/store/user'
+import Snackbar from '@/plugins/snackbar'
+import { cloneDeep } from 'lodash'
+import { schoolBaseInfoEdit } from '@/api/school'
 
+const overlay = ref(false)
 const CtFormRef = ref()
 const formItems = ref({
   options: [
     {
       type: 'text',
-      key: 'name',
+      key: 'schoolName',
       value: '',
       col: 6,
-      label: '称 *',
+      label: '学校名称 *',
       flexStyle: 'mr-3',
-      slotName: 'name',
-      rules: [v => !!v || '请输入您的昵称']
+      rules: [v => !!v || '请输入您所在的学校名称']
     },
     {
       type: 'text',
-      key: 'anotherName',
+      key: 'email',
       value: '',
       col: 6,
-      label: '企业展示名称 *',
-      rules: [v => !!v || '请输入企业展示名称']
+      label: '学校邮箱'
     },
     {
       type: 'text',
-      key: 'website',
+      key: 'site',
       value: '',
       col: 6,
       flexStyle: 'mr-3',
-      label: '企业官网'
+      label: '学校官网'
     },
     {
       type: 'text',
-      key: 'contact',
-      value: '',
-      col: 6,
-      label: '联系人'
-    },
-    {
-      type: 'phoneNumber',
-      key: 'phone',
+      key: 'schoolAdderss',
       value: '',
       col: 6,
-      flexStyle: 'mr-3',
-      label: '联系电话'
-    },
-    {
-      slotName: 'industryId',
-      key: 'industryId',
-      value: null,
-      label: '所在行业 *',
-      outlined: true,
-      clearable: false,
-      itemText: 'label',
-      itemValue: 'value',
-      col: 6,
-      noParam: true,
-      rules: [v => !!v || '请选择所在行业']
-    },
-    {
-      type: 'autocomplete',
-      key: 'scale',
-      value: null,
-      label: '企业规模 *',
-      outlined: true,
-      clearable: false,
-      itemText: 'label',
-      itemValue: 'value',
-      dictTypeName: 'menduner_scale',
-      rules: [v => !!v || '请选择企业规模'],
-      items: []
-    },
-    {
-      type: 'datePicker',
-      mode: 'month',
-      key: 'openTime',
-      value: null,
-      format: 'YYYY-MM',
-      disabledDate: true,
-      label: '开业时间',
-      labelWidth: 120,
-      col: 6,
-      flexStyle: 'mr-3',
-    },
-    {
-      slotName: 'prepare',
-      key: 'prepare',
-      value: true,
-      col: 6
+      label: '学校地址'
     },
     {
       type: 'textarea',
@@ -102,12 +65,57 @@ const formItems = ref({
       value: null,
       counter: 2000,
       rows: 6,
-      label: '企业介绍 *',
-      outlined: true,
-      rules: [v => !!v || '请输入企业介绍']
+      label: '学校简介',
+      outlined: true
     },
+    {
+      slotName: 'photos',
+      key: 'photos',
+      value: []
+    }
   ]
 })
+
+const { t } = useI18n()
+const userStore = useUserStore()
+const schoolInfo = ref(localStorage.getItem('schoolInfo') ? JSON.parse(localStorage.getItem('schoolInfo')) : {})
+// 监听store变化
+userStore.$subscribe((mutation, state) => {
+  schoolInfo.value = state.schoolInfo
+})
+
+onMounted(async () => {
+	await userStore.getSchoolInfo()
+
+	formItems.value.options.forEach(item => {
+		item.value = schoolInfo.value?.school[item.key]
+	})
+})
+
+// 保存
+const handleSubmit = async () => {
+  const { valid } = await CtFormRef.value.formRef.validate()
+  if (!valid) return
+
+  overlay.value = true
+
+  let obj = cloneDeep(schoolInfo.value?.school)
+	formItems.value.options.forEach(item => {
+		obj[item.key] = item.value
+	})
+
+  try {
+		await schoolBaseInfoEdit(obj)
+
+		setTimeout(async () => {
+			await userStore.getSchoolInfo()
+			Snackbar.success(t('common.saveMsg'))
+			overlay.value = false
+		}, 1000)
+	} catch {
+		overlay.value = false
+	}
+}
 </script>
 
 <style scoped lang="scss">

+ 7 - 1
src/views/recruit/teacher/teacherCertification/teacherInfo.vue

@@ -85,8 +85,14 @@ const formItems = ref({
       key: 'teacherNickname',
       value: '',
       label: '昵称 *',
-      slotName: 'teacherNickname',
       rules: [v => !!v || '请输入您的昵称']
+    },
+		{
+      type: 'phoneNumber',
+      key: 'phone',
+      value: '',
+      label: '联系电话 *',
+      rules: [v => !!v || '请输入您的联系电话']
     },
     {
 			slotName: 'department',