businessInformation.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <!-- 工商信息 -->
  2. <template>
  3. <div>
  4. <CtForm ref="CtFormRef" class="mt-3" :items="formItems" style="width: 900px;margin: 0 auto"></CtForm>
  5. <div class="text-center">
  6. <v-btn color="primary" class="buttons mt-3 mb-10" @click="handleSave">{{ $t('common.save') }}</v-btn>
  7. </div>
  8. </div>
  9. </template>
  10. <script setup>
  11. import CtForm from '@/components/CtForm'
  12. import { getEnterpriseBusiness, updateEnterpriseBusiness } from '@/api/enterprise'
  13. import Snackbar from '@/plugins/snackbar'
  14. import { reactive, ref } from 'vue'
  15. // import { getDict } from '@/hooks/web/useDictionaries'
  16. const emit = defineEmits(['complete'])
  17. defineOptions({name: 'informationSettingsComponents-businessInformation'})
  18. const formItems = ref({
  19. options: [
  20. {
  21. type: 'text',
  22. key: 'name',
  23. value: '',
  24. col: 6,
  25. flexStyle: 'mr-3',
  26. label: '企业名称 *',
  27. rules: [v => !!v || '请输入企业名称']
  28. },
  29. {
  30. type: 'text',
  31. key: 'representative',
  32. value: '',
  33. col: 6,
  34. label: '法定代表人 *',
  35. rules: [v => !!v || '请输入法定代表人']
  36. },
  37. {
  38. type: 'text',
  39. key: 'code',
  40. value: '',
  41. col: 6,
  42. flexStyle: 'mr-3',
  43. label: '统一社会信用代码 *',
  44. rules: [v => !!v || '请输入统一社会信用代码']
  45. },
  46. {
  47. type: 'text',
  48. key: 'type',
  49. value: '',
  50. col: 6,
  51. label: '企业类型 *',
  52. rules: [v => !!v || '请输入企业类型']
  53. },
  54. {
  55. type: 'datePicker',
  56. key: 'establishmentTime',
  57. value: '2010-01-01',
  58. label: '成立时间 *',
  59. format: 'YYYY-MM-DD',
  60. defaultValue: new Date(2010, 1, 1),
  61. labelWidth: 120,
  62. col: 6,
  63. flexStyle: 'mr-3'
  64. },
  65. {
  66. type: 'text',
  67. key: 'registeredCapital',
  68. value: '',
  69. col: 6,
  70. // suffix: '万元',
  71. label: '注册资金 *',
  72. rules: [v => !!v || '请输入注册资金']
  73. },
  74. {
  75. type: 'text',
  76. key: 'approvalTime',
  77. value: '',
  78. col: 6,
  79. flexStyle: 'mr-3',
  80. label: '核准日期 *',
  81. rules: [v => !!v || '请输入核准日期']
  82. },
  83. {
  84. type: 'text',
  85. key: 'registrationAuthority',
  86. value: '',
  87. col: 6,
  88. label: '注册机关 *',
  89. rules: [v => !!v || '请输入注册机关']
  90. },
  91. {
  92. type: 'text',
  93. key: 'businessStatus',
  94. value: '',
  95. col: 6,
  96. flexStyle: 'mr-3',
  97. label: '经营状态 *',
  98. rules: [v => !!v || '请输入经营状态']
  99. },
  100. {
  101. type: 'text',
  102. key: 'businessTerm',
  103. value: null,
  104. col: 6,
  105. class: 'mb-3',
  106. label: '营业期限(示例:2020-03-13 至 2030-03-13) *',
  107. rules: [v => !!v || '请填写营业期限']
  108. },
  109. {
  110. type: 'text',
  111. key: 'area',
  112. value: '',
  113. col: 6,
  114. flexStyle: 'mr-3',
  115. label: '所属地区 *',
  116. rules: [v => !!v || '请输入所属地区']
  117. },
  118. {
  119. type: 'text',
  120. key: 'formerName',
  121. value: '',
  122. col: 6,
  123. label: '曾用名',
  124. },
  125. {
  126. type: 'text',
  127. key: 'address',
  128. value: '',
  129. label: '注册地址 *',
  130. rules: [v => !!v || '请输入注册地址']
  131. },
  132. {
  133. type: 'textarea',
  134. key: 'businessScope',
  135. value: null,
  136. resize: true,
  137. counter: 1600,
  138. rows: 5,
  139. label: '经营范围 *',
  140. outlined: true,
  141. rules: [v => !!v || '请输入经营范围']
  142. },
  143. ]
  144. })
  145. const CtFormRef = ref()
  146. const query = reactive({})
  147. const handleSave = async () => {
  148. const { valid } = await CtFormRef.value.formRef.validate()
  149. if (!valid) return
  150. formItems.value.options.forEach(e => {
  151. if (e.noParam) return
  152. query[e.key] = e.value
  153. })
  154. if (!query.establishmentTime) return Snackbar.warning('请选择成立时间')
  155. await updateEnterpriseBusiness(query)
  156. Snackbar.success('编辑成功')
  157. getBaseInfo()
  158. }
  159. // 完成度展示
  160. const completeFun = (completeCount = 0) => {
  161. const totalCount = formItems.value.options?.length || 0
  162. emit('complete', { totalCount, completeCount, id: 'businessInformation' })
  163. }
  164. // 获取基本信息
  165. const getBaseInfo = async () => {
  166. let completeCount = 0
  167. try {
  168. const data = await getEnterpriseBusiness()
  169. if (data && Object.keys(data).length) completeFun(completeCount)
  170. if (!data) return
  171. query.id = data.id
  172. formItems.value.options.forEach(item => {
  173. item.value = data[item.key]
  174. // 完成度展示
  175. if (item.key !== 'formerName') {
  176. if (item.value === undefined || item.value === null || item.value === '') completeCount++
  177. }
  178. })
  179. // 完成度展示
  180. completeFun(completeCount)
  181. } catch (error) {
  182. completeFun(completeCount)
  183. }
  184. }
  185. getBaseInfo()
  186. </script>
  187. <style lang="scss" scoped>
  188. </style>