edit.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <div class="club-edit page-form-container">
  3. <el-tabs v-model="activeName">
  4. <el-tab-pane label="基础资料" name="first">
  5. <ClubBasicsInfo ref="ClubBasicsInfo" />
  6. </el-tab-pane>
  7. <el-tab-pane label="授权牌资料" name="second">
  8. <ClubAuthorizeBrand ref="ClubAuthorizeBrand" />
  9. </el-tab-pane>
  10. <el-tab-pane label="机构关联" name="third">
  11. <ClubAssociated ref="ClubAssociated" />
  12. </el-tab-pane>
  13. <el-tab-pane label="特殊属性" name="fourth">
  14. <ClubSpecialInfo ref="ClubSpecialInfo" />
  15. </el-tab-pane>
  16. </el-tabs>
  17. <!-- 表单提交 返回 -->
  18. <div class="control-box">
  19. <el-button type="primary" @click="submit">保存</el-button>
  20. <el-button type="warning" @click="navigateBack">返回</el-button>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. import { getAuthFormData, saveBrandAuth } from '@/api/auth'
  26. import { ClubAssociated, ClubBasicsInfo, ClubAuthorizeBrand, ClubSpecialInfo } from './components/index'
  27. import { formatDate } from '@/utils'
  28. import { mapGetters } from 'vuex'
  29. export default {
  30. name: 'ClubEdit',
  31. components: {
  32. ClubAssociated,
  33. ClubBasicsInfo,
  34. ClubAuthorizeBrand,
  35. ClubSpecialInfo
  36. },
  37. data() {
  38. return {
  39. editType: 'add',
  40. authId: '',
  41. activeName: 'first'
  42. }
  43. },
  44. computed: {
  45. ...mapGetters(['authUserId', 'proxyInfo'])
  46. },
  47. created() {
  48. this.editType = this.$route.query.type || 'add'
  49. this.authId = this.$route.query.id
  50. this.initFormData()
  51. this.fetchAuthTempUsed()
  52. },
  53. methods: {
  54. // 提交表单数据
  55. async submit() {
  56. // 验证表单
  57. const first = this.$refs.ClubBasicsInfo.validateForm()
  58. const second = this.$refs.ClubAuthorizeBrand.validateForm()
  59. const third = this.$refs.ClubAssociated.validateForm()
  60. const fourth = this.$refs.ClubSpecialInfo.validateForm()
  61. try {
  62. const formData = {}
  63. const result = await Promise.all([first, second, third, fourth])
  64. console.log(result)
  65. result.forEach((item) => Object.assign(formData, item))
  66. this.save(formData)
  67. } catch (error) {
  68. console.log(error)
  69. }
  70. },
  71. // 保存表单数据
  72. async save(formData) {
  73. console.log(formData)
  74. const params = Object.create(null)
  75. const [provinceId, cityId, townId] = formData.address
  76. params.authId = Number(this.authId)
  77. params.authParty = formData.authParty
  78. params.authUserId = this.authUserId
  79. params.createBy = this.authUserId
  80. params.provinceId = provinceId
  81. params.cityId = cityId
  82. params.townId = townId
  83. params.address = formData.fullAddress
  84. params.mobile = formData.mobile
  85. params.logo = formData.logo
  86. params.lngAndLat = formData.point
  87. params.remarks = formData.remarks
  88. params.customFlag = formData.customFlag
  89. params.empNum = formData.empNum
  90. params.firstClubType = formData.firstClubType
  91. params.secondClubType = formData.secondClubType
  92. params.medicalLicenseImage = formData.medicalLicenseImage
  93. params.userMobile = formData.userMobile
  94. params.authCode = formData.authCode
  95. params.authDate = formData.authDate ? formatDate(formData.authDate, 'yyyy.MM.DD') : ''
  96. params.authImageType = formData.authImageType
  97. params.authImageLogo = formData.authImageLogo
  98. params.authImage = formData.authImage
  99. params.linkMan = formData.linkMan
  100. params.linkMobile = formData.linkMobile
  101. params.relationId = formData.selectAssClubListAll.map((item) => item.authId).join(',')
  102. params.relationName = formData.selectAssClubListAll.map((item) => item.authParty).join(',')
  103. params.bannerList = formData.bannerList.map((item) => (item.response ? item.response.data : item.url))
  104. // 保存
  105. try {
  106. console.log(params)
  107. await saveBrandAuth(params)
  108. const h = this.$createElement
  109. this.$notify.success({
  110. title: `修改授权机构`,
  111. message: h('i', { style: 'color: #333' }, `已修改授权机构:"${params.authParty}"`),
  112. duration: 3000
  113. })
  114. this.$store.dispatch('tagsView/delView', this.$route)
  115. this.$router.push('/club/list')
  116. } catch (error) {
  117. console.log(error)
  118. }
  119. },
  120. // 初始化机构数据
  121. initFormData() {
  122. if (!this.authId) return
  123. getAuthFormData({ authId: this.authId }).then((res) => {
  124. this.$refs.ClubBasicsInfo.initForm(res.data)
  125. this.$refs.ClubAuthorizeBrand.initForm(res.data)
  126. this.$refs.ClubAssociated.initForm(res.data)
  127. this.$refs.ClubSpecialInfo.initForm(res.data)
  128. })
  129. },
  130. // 获取授权牌模板
  131. fetchAuthTempUsed() {}
  132. }
  133. }
  134. </script>
  135. <style lang="scss" scoped>
  136. .el-tab-pane {
  137. margin-top: 24px;
  138. }
  139. .page-form-container {
  140. padding: 60px 0;
  141. }
  142. </style>