edit.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <script setup lang="ts">
  2. import route from "@/route"
  3. import appStore from "@/stores"
  4. import apis from "@/api"
  5. import type { AlumnusProfile } from "@/core/types"
  6. //import { areaList } from "@vant/area-data"
  7. import { areaList, useCascaderAreaData } from "@/core/config/area-data"
  8. import { industryList, useCascaderIndustryData } from "@/core/config/industry-data"
  9. const isAudit = computed(() => {
  10. return appStore.authStore.getAuditStatus() == 1 || form.value.auditStatus == 1
  11. })
  12. const progress = computed(() => {
  13. return appStore.amProfileStore.getProfileProgress() || 0
  14. })
  15. const formRef = ref()
  16. const form = ref<AlumnusProfile>({
  17. gender: "0",
  18. type: "0",
  19. province: "江苏省",
  20. city: "盐城市",
  21. district: "亭湖区",
  22. amPublic: "0",
  23. } as AlumnusProfile)
  24. const birthday = ref()
  25. const area = ref()
  26. const industry = ref()
  27. const amTypeItems = [
  28. { text: "我是校友", value: "0" },
  29. { text: "我是教职工", value: "1" },
  30. { text: "我是校友,也是教职工", value: "2" },
  31. ]
  32. const formatOrgList = (data: any) => {
  33. const orgColumns: any = []
  34. if (data.length > 0) {
  35. data.forEach((v: any) => {
  36. if (v.parentId == 100) {
  37. orgColumns.push({ text: v.orgName, value: v.orgId })
  38. }
  39. })
  40. }
  41. return orgColumns
  42. }
  43. const yearColumns = computed(() => {
  44. const cols = []
  45. for (let i = new Date().getFullYear(); i >= 1950; i--) {
  46. cols.push({ text: i + "年", value: i })
  47. }
  48. return cols
  49. })
  50. const yearMonthColumns = computed(() => {
  51. const colList: any = [],
  52. cols1 = [],
  53. cols2 = []
  54. for (let i = new Date().getFullYear(); i >= 1950; i--) {
  55. let val = i + ""
  56. cols1.push({ text: val + "年", value: val })
  57. }
  58. for (let i = 1; i <= 12; i++) {
  59. let val = i + ""
  60. if (i < 10) {
  61. val = "0" + val
  62. }
  63. cols2.push({ text: val + "月", value: val })
  64. }
  65. colList.push(cols1)
  66. colList.push(cols2)
  67. return colList
  68. })
  69. const classColumns = computed(() => {
  70. const cols = []
  71. for (let i = 1; i <= 50; i++) {
  72. cols.push({ text: i + "班", value: i + "班" })
  73. }
  74. return cols
  75. })
  76. const areaColumns = [useCascaderAreaData()]
  77. const industryColumns = [useCascaderIndustryData()]
  78. const nativePlaceColumns = computed(() => {
  79. const arr = ["亭湖区", "盐都区", "大丰区", "东台市", "响水县", "滨海县", "阜宁县", "射阳县", "建湖县", "其他"]
  80. const cols: any[] = []
  81. arr.forEach((v) => {
  82. cols.push({ text: v, value: v })
  83. })
  84. return cols
  85. })
  86. const educationColumns = computed(() => {
  87. const arr = ["初中", "高中", "大专", "本科", "硕士", "博士", "博士后", "其他"]
  88. const cols: any[] = []
  89. arr.forEach((v) => {
  90. cols.push({ text: v, value: v })
  91. })
  92. return cols
  93. })
  94. const amPublicItems = [
  95. { text: "不公开个人隐私资料", value: "0" },
  96. { text: "公开个人隐私资料", value: "1" },
  97. { text: "对好友公开个人隐私资料", value: "2" },
  98. ]
  99. function onOrgConfirm(v: string, data: any) {
  100. form.value.orgName = data.text
  101. }
  102. function onBirthdayConfirm(v: any) {
  103. form.value.birthday = v.join("-") + "-01"
  104. console.log("onBirthdayConfirm", v, form.value.birthday)
  105. }
  106. function onEnrolYearConfirm(v: any) {
  107. //console.log("onEnrolYearConfirm", v)
  108. if (new Date().getFullYear() - v > 3) {
  109. form.value.graduateYear = v + 3
  110. }
  111. }
  112. function onEnrolGraduateYearHide(v1: any, v2: Ref<boolean>) {
  113. v2.value = true
  114. if (form.value.enrolYear && form.value.graduateYear && form.value.graduateYear < form.value.enrolYear) {
  115. message.alert("毕业年份不能小于入学年份")
  116. v2.value = false
  117. }
  118. }
  119. function onAreaConfirm(v: any, data: any) {
  120. form.value.province = data[0].text
  121. form.value.city = data[1].text
  122. form.value.district = data[2].text
  123. }
  124. function onIndustryConfirm(v: any, data: any) {
  125. form.value.industry = data[0].text
  126. form.value.industryArea = data[1].text
  127. }
  128. function onBack() {
  129. if (appStore.authStore.getAuditStatus() != 1) {
  130. appStore.authStore.loadUserInfo().then(() => {
  131. route.reLaunch("welcome")
  132. })
  133. } else {
  134. route.back()
  135. }
  136. }
  137. function onSubmit() {
  138. formRef.value.validate().then(() => {
  139. console.log("values", form.value)
  140. appStore.amProfileStore.updateProfile(form.value)
  141. })
  142. }
  143. function loadProfile() {
  144. appStore.amProfileStore.loadProfile().then((res: any) => {
  145. form.value = reactive(Object.assign({}, form, res))
  146. if (!form.value.province) {
  147. form.value.province = "江苏省"
  148. form.value.city = "盐城市"
  149. form.value.district = "亭湖区"
  150. }
  151. formatArea()
  152. if (form.value.industry) {
  153. formatIndustry()
  154. }
  155. if (form.value.birthday) {
  156. const date = new Date(form.value.birthday)
  157. birthday.value = [date.getFullYear(), date.getMonth() + 1]
  158. }
  159. })
  160. }
  161. function formatArea() {
  162. const arr = []
  163. const val1 = Object.keys(areaList.province_list).find((p) => {
  164. return areaList.province_list[p] === form.value.province
  165. })
  166. const val2 = Object.keys(areaList.city_list).find((p) => {
  167. return areaList.city_list[p] === form.value.city
  168. })
  169. const val3 = Object.keys(areaList.county_list).find((p) => {
  170. return areaList.county_list[p] === form.value.district
  171. })
  172. arr.push(val1, val2, val3)
  173. area.value = arr
  174. }
  175. function formatIndustry() {
  176. const arr = []
  177. const val1 = Object.keys(industryList.industry_list).find((p) => {
  178. return industryList.industry_list[p] === form.value.industry
  179. })
  180. arr.push(val1)
  181. if (form.value.industryArea) {
  182. const val2 = Object.keys(industryList.area_list).find((p) => {
  183. return industryList.area_list[p] === form.value.industryArea
  184. })
  185. arr.push(val2)
  186. }
  187. industry.value = arr
  188. }
  189. onLoad(() => {
  190. loadProfile()
  191. })
  192. </script>
  193. <template>
  194. <view class="page-container">
  195. <view v-if="!isAudit" class="text-danger" style="text-align: center; margin: 5px 0">完善资料,等待后台审核...</view>
  196. <view style="margin: 15px 0">
  197. <vb-progress :progress="progress" />
  198. </view>
  199. <uni-forms ref="formRef" :modelValue="form" :label-width="75" border validate-trigger="blur">
  200. <vb-cell-group outset>
  201. <uni-data-checkbox
  202. mode="list"
  203. icon="right"
  204. v-model="form.type"
  205. :localdata="amTypeItems"
  206. selectedColor="var(--vb-color)"
  207. selectedTextColor="var(--vb-color)"
  208. ></uni-data-checkbox>
  209. </vb-cell-group>
  210. <vb-cell-group outset>
  211. <uni-forms-item
  212. required
  213. label="校友会"
  214. name="orgId"
  215. :rules="[{ required: true, errorMessage: '请选择校友会' }]"
  216. >
  217. <vb-picker
  218. v-model="form.orgId"
  219. label="校友会"
  220. :columnsFun="apis.system.orgApi.listOrg"
  221. :formatter="formatOrgList"
  222. @confirm="onOrgConfirm"
  223. ></vb-picker>
  224. </uni-forms-item>
  225. <uni-forms-item required label="手机号码" name="phonenumber">
  226. <uni-easyinput
  227. type="text"
  228. v-model="form.phonenumber"
  229. disabled
  230. :inputBorder="false"
  231. placeholder="请输入手机号码"
  232. />
  233. </uni-forms-item>
  234. <uni-forms-item
  235. required
  236. label="用户姓名"
  237. name="name"
  238. :rules="[{ required: true, errorMessage: '请填写用户姓名' }]"
  239. >
  240. <uni-easyinput type="text" v-model="form.name" :inputBorder="false" placeholder="请填写真实姓名" />
  241. </uni-forms-item>
  242. <uni-forms-item required label="用户性别" name="gender">
  243. <uni-data-checkbox
  244. v-model="form.gender"
  245. :localdata="[
  246. { value: '0', text: '男' },
  247. { value: '1', text: '女' },
  248. ]"
  249. selectedColor="var(--vb-color)"
  250. selectedTextColor="var(--vb-color)"
  251. ></uni-data-checkbox>
  252. </uni-forms-item>
  253. <uni-forms-item
  254. required
  255. label="出生年月"
  256. name="birthday"
  257. :rules="[{ required: true, errorMessage: '请选择出生年月' }]"
  258. >
  259. <vb-picker-m
  260. v-model="birthday"
  261. label="出生年月"
  262. :columns="yearMonthColumns"
  263. @confirm="onBirthdayConfirm"
  264. splitString=""
  265. ></vb-picker-m>
  266. </uni-forms-item>
  267. <uni-forms-item
  268. required
  269. label="入学年份"
  270. name="enrolYear"
  271. :rules="[{ required: true, errorMessage: '请选择入学年份' }]"
  272. >
  273. <vb-picker
  274. v-model="form.enrolYear"
  275. label="入学年份"
  276. :columns="yearColumns"
  277. @confirm="onEnrolYearConfirm"
  278. @hide="onEnrolGraduateYearHide"
  279. ></vb-picker>
  280. </uni-forms-item>
  281. <uni-forms-item
  282. required
  283. label="毕业年份"
  284. name="graduateYear"
  285. :rules="[{ required: true, errorMessage: '请选择毕业年份' }]"
  286. >
  287. <vb-picker
  288. v-model="form.graduateYear"
  289. label="毕业年份"
  290. :columns="yearColumns"
  291. @hide="onEnrolGraduateYearHide"
  292. ></vb-picker>
  293. </uni-forms-item>
  294. <uni-forms-item
  295. required
  296. label="所在班级"
  297. name="amClass"
  298. :rules="[{ required: true, errorMessage: '请选择班级' }]"
  299. >
  300. <vb-picker v-model="form.amClass" label="班级" :columns="classColumns"></vb-picker>
  301. </uni-forms-item>
  302. <uni-forms-item
  303. required
  304. label="用户籍贯"
  305. name="nativePlace"
  306. :rules="[{ required: true, errorMessage: '请选择用户籍贯' }]"
  307. >
  308. <vb-picker v-model="form.nativePlace" label="用户籍贯" :columns="nativePlaceColumns"></vb-picker>
  309. </uni-forms-item>
  310. <uni-forms-item required label="所在地区" name="area">
  311. <vb-picker-m
  312. v-model="area"
  313. label="省市区"
  314. isCascade
  315. :columns="areaColumns"
  316. @confirm="onAreaConfirm"
  317. ></vb-picker-m>
  318. </uni-forms-item>
  319. <uni-forms-item required label="所在行业" name="area">
  320. <vb-picker-m
  321. v-model="industry"
  322. label="行业领域"
  323. isCascade
  324. :columns-size="2"
  325. :columns="industryColumns"
  326. @confirm="onIndustryConfirm"
  327. ></vb-picker-m>
  328. </uni-forms-item>
  329. <uni-forms-item
  330. required
  331. label="最高学历"
  332. name="education"
  333. :rules="[{ required: true, errorMessage: '请选择最高学历' }]"
  334. >
  335. <vb-picker v-model="form.education" label="最高学历" :columns="educationColumns"></vb-picker>
  336. </uni-forms-item>
  337. </vb-cell-group>
  338. <vb-cell-group outset>
  339. <uni-data-checkbox
  340. mode="list"
  341. icon="right"
  342. v-model="form.amPublic"
  343. :localdata="amPublicItems"
  344. selectedColor="var(--vb-color)"
  345. selectedTextColor="var(--vb-color)"
  346. ></uni-data-checkbox>
  347. <uni-forms-item label="电子邮箱" name="email">
  348. <uni-easyinput type="text" v-model="form.email" :inputBorder="false" placeholder="请输入电子邮箱" />
  349. </uni-forms-item>
  350. <uni-forms-item label="QQ" name="qq">
  351. <uni-easyinput type="text" v-model="form.qq" :inputBorder="false" placeholder="请输入QQ" />
  352. </uni-forms-item>
  353. <uni-forms-item label="微信" name="wechat">
  354. <uni-easyinput type="text" v-model="form.wechat" :inputBorder="false" placeholder="请输入微信" />
  355. </uni-forms-item>
  356. <uni-forms-item label="工作单位" name="workUnit">
  357. <uni-easyinput type="text" v-model="form.workUnit" :inputBorder="false" placeholder="请输入工作单位" />
  358. </uni-forms-item>
  359. <uni-forms-item label="岗位职务" name="position">
  360. <uni-easyinput type="text" v-model="form.position" :inputBorder="false" placeholder="请输入岗位职务" />
  361. </uni-forms-item>
  362. </vb-cell-group>
  363. </uni-forms>
  364. <uni-forms label-position="top">
  365. <vb-cell-group outset>
  366. <uni-forms-item label="自我介绍" name="selfIntroduction">
  367. <uni-easyinput
  368. type="textarea"
  369. autoHeight
  370. v-model="form.selfIntroduction"
  371. :inputBorder="false"
  372. placeholder="请输入自己的详细介绍"
  373. />
  374. </uni-forms-item>
  375. </vb-cell-group>
  376. <vb-cell-group outset>
  377. <uni-forms-item label="我的资源" label-position="top" name="resources">
  378. <uni-easyinput
  379. type="textarea"
  380. autoHeight
  381. v-model="form.resources"
  382. :inputBorder="false"
  383. placeholder="请输入能提供的资源"
  384. />
  385. </uni-forms-item>
  386. </vb-cell-group>
  387. </uni-forms>
  388. <view class="d-flex">
  389. <view style="width: 50%; margin-right: 10px">
  390. <vb-button v-if="isAudit" block plain @click="onBack">返回</vb-button>
  391. </view>
  392. <view style="width: 50%">
  393. <vb-button block @click="onSubmit">提交</vb-button>
  394. </view>
  395. </view>
  396. </view>
  397. </template>