basicInfo.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <!-- 基本信息 -->
  2. <template>
  3. <div>
  4. <div class="topTip">丰富详尽的企业介绍能提高求职者对贵企业的关注和了解,有助于达到更好的招聘效果</div>
  5. <CtForm ref="CtFormRef" :items="formItems" style="width: 900px;margin: 0 auto">
  6. <template #industryId="{ item }">
  7. <v-menu :close-delay="1" :open-delay="0" v-bind="$attrs" :close-on-content-click="true">
  8. <template v-slot:activator="{ props }">
  9. <TextInput
  10. v-model="item.value"
  11. :item="item"
  12. v-bind="props"
  13. ></TextInput>
  14. </template>
  15. <industryTypeCard :limit="1" :select="[query.industryId].filter(Boolean)" @handleClickIndustry="handleIndustry"></industryTypeCard>
  16. </v-menu>
  17. </template>
  18. <template #prepare="{ item }">
  19. <v-checkbox v-model="item.value" label="筹备中(如果贵企业正在筹备,请勾选)" color="primary"></v-checkbox>
  20. </template>
  21. </CtForm>
  22. <div class="text-center">
  23. <v-btn color="primary" class="buttons mt-3 mb-10" @click.stop="handleSave">{{ $t('common.save') }}</v-btn>
  24. </div>
  25. </div>
  26. </template>
  27. <script setup>
  28. defineOptions({name: 'informationSettingsComponents-basicInfo'})
  29. import { ref, reactive } from 'vue'
  30. import { getEnterpriseBaseInfo, updateEnterpriseBaseInfo } from '@/api/enterprise'
  31. import { getDict } from '@/hooks/web/useDictionaries'
  32. import { useI18n } from '@/hooks/web/useI18n'
  33. import industryTypeCard from '@/components/industryTypeCard'
  34. import Snackbar from '@/plugins/snackbar'
  35. import { useUserStore } from '@/store/user'
  36. const emit = defineEmits(['complete', 'preview'])
  37. const { t } = useI18n()
  38. const CtFormRef = ref()
  39. const query = reactive({})
  40. const user = useUserStore()
  41. const formItems = ref({
  42. options: [
  43. {
  44. type: 'text',
  45. key: 'name',
  46. value: '',
  47. col: 6,
  48. label: '企业全称 *',
  49. flexStyle: 'mr-3',
  50. slotName: 'name',
  51. rules: [v => !!v || '请输入企业全称']
  52. },
  53. {
  54. type: 'text',
  55. key: 'anotherName',
  56. value: '',
  57. col: 6,
  58. label: '企业展示名称 *',
  59. rules: [v => !!v || '请输入企业展示名称']
  60. },
  61. {
  62. type: 'text',
  63. key: 'website',
  64. value: '',
  65. col: 6,
  66. flexStyle: 'mr-3',
  67. label: '企业官网'
  68. },
  69. {
  70. type: 'text',
  71. key: 'contact',
  72. value: '',
  73. col: 6,
  74. label: '联系人'
  75. },
  76. {
  77. type: 'phoneNumber',
  78. key: 'phone',
  79. value: '',
  80. col: 6,
  81. flexStyle: 'mr-3',
  82. label: '联系电话'
  83. },
  84. {
  85. slotName: 'industryId',
  86. key: 'industryId',
  87. value: null,
  88. label: '所在行业 *',
  89. outlined: true,
  90. clearable: false,
  91. itemText: 'label',
  92. itemValue: 'value',
  93. col: 6,
  94. noParam: true,
  95. rules: [v => !!v || '请选择所在行业']
  96. },
  97. {
  98. type: 'autocomplete',
  99. key: 'scale',
  100. value: null,
  101. label: '企业规模 *',
  102. outlined: true,
  103. clearable: false,
  104. itemText: 'label',
  105. itemValue: 'value',
  106. dictTypeName: 'menduner_scale',
  107. rules: [v => !!v || '请选择企业规模'],
  108. items: []
  109. },
  110. {
  111. type: 'datePicker',
  112. mode: 'month',
  113. key: 'openTime',
  114. value: null,
  115. format: 'YYYY-MM',
  116. disabledDate: true,
  117. label: '开业时间',
  118. labelWidth: 120,
  119. col: 6,
  120. flexStyle: 'mr-3',
  121. },
  122. {
  123. slotName: 'prepare',
  124. key: 'prepare',
  125. value: true,
  126. col: 6
  127. },
  128. {
  129. type: 'textarea',
  130. key: 'introduce',
  131. value: null,
  132. counter: 2000,
  133. rows: 6,
  134. label: '企业介绍 *',
  135. outlined: true,
  136. rules: [v => !!v || '请输入企业介绍']
  137. },
  138. ]
  139. })
  140. const setValue = (key, value) => {
  141. formItems.value.options.find(e => e.key === key).value = value
  142. }
  143. // 行业列表
  144. const industryList = ref([])
  145. getDict('menduner_industry_type', {}, 'industryList').then(({ data }) => {
  146. data = data?.length && data || []
  147. industryList.value = data
  148. })
  149. // 获取基本信息
  150. const getBaseInfo = async () => {
  151. let completeCount = 0
  152. const totalCount = formItems.value.options?.length || 0
  153. const data = await getEnterpriseBaseInfo()
  154. if (!data || !Object.keys(data).length) return emit('complete', { totalCount, completeCount, id: 'basicInfo' }) // 完成度展示
  155. query.id = data.id
  156. formItems.value.options.forEach(item => {
  157. if (item.dictTypeName) {
  158. getDict(item.dictTypeName).then(({ data }) => {
  159. data = data?.length && data || []
  160. item.items = data
  161. })
  162. }
  163. query.industryId = data.industryId
  164. if (item.key === 'industryId') {
  165. item.value = industryList.value.find(e => e.id === data[item.key])?.nameCn
  166. } else if (item.key === 'openTime') {
  167. item.value = data[item.key] ? data[item.key] : item.default
  168. } else item.value = data[item.key]
  169. // 完成度展示
  170. if (!item.rules || (item.value !== undefined && item.value !== null && item.value !== '')) completeCount++
  171. })
  172. // 完成度展示
  173. emit('complete', { totalCount, completeCount, id: 'basicInfo' })
  174. }
  175. getBaseInfo()
  176. // 所在行业
  177. const handleIndustry = (list, arr) => {
  178. if (!list.length) return
  179. query.industryId = list[0]
  180. const str = arr.map(e => e.nameCn).join('、')
  181. setValue('industryId', str)
  182. }
  183. const handleSave = async () => {
  184. const { valid } = await CtFormRef.value.formRef.validate()
  185. if (!valid) return
  186. formItems.value.options.forEach(e => {
  187. if (e.noParam) return
  188. query[e.key] = e.value
  189. })
  190. await updateEnterpriseBaseInfo(query)
  191. Snackbar.success(t('common.saveMsg'))
  192. await user.getEnterpriseInfo()
  193. getBaseInfo()
  194. }
  195. </script>
  196. <style lang="scss" scoped>
  197. .topTip {
  198. background-color: #f7f8fa;
  199. color: #2f3640;
  200. padding: 12px 20px;
  201. margin: 10px 0 40px;
  202. font-size: 14px;
  203. }
  204. </style>