businessInformation.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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: null,
  58. label: '成立时间 *',
  59. format: 'YYYY-MM-DD',
  60. labelWidth: 120,
  61. col: 6,
  62. flexStyle: 'mr-3'
  63. },
  64. {
  65. type: 'text',
  66. key: 'registeredCapital',
  67. value: '',
  68. col: 6,
  69. suffix: '万元',
  70. label: '注册资金 *',
  71. rules: [v => !!v || '请输入注册资金']
  72. },
  73. {
  74. type: 'text',
  75. key: 'approvalTime',
  76. value: '',
  77. col: 6,
  78. flexStyle: 'mr-3',
  79. label: '核准日期 *',
  80. rules: [v => !!v || '请输入核准日期']
  81. },
  82. {
  83. type: 'text',
  84. key: 'registrationAuthority',
  85. value: '',
  86. col: 6,
  87. label: '注册机关 *',
  88. rules: [v => !!v || '请输入注册机关']
  89. },
  90. {
  91. type: 'text',
  92. key: 'businessStatus',
  93. value: '',
  94. col: 6,
  95. flexStyle: 'mr-3',
  96. label: '经营状态 *',
  97. rules: [v => !!v || '请输入经营状态']
  98. },
  99. {
  100. type: 'text',
  101. key: 'businessTerm',
  102. value: null,
  103. col: 6,
  104. class: 'mb-3',
  105. label: '营业期限(示例:2020-03-13 至 2030-03-13) *',
  106. rules: [v => !!v || '请填写营业期限']
  107. },
  108. {
  109. type: 'text',
  110. key: 'area',
  111. value: '',
  112. col: 6,
  113. flexStyle: 'mr-3',
  114. label: '所属地区 *',
  115. rules: [v => !!v || '请输入所属地区']
  116. },
  117. {
  118. type: 'text',
  119. key: 'formerName',
  120. value: '',
  121. col: 6,
  122. label: '曾用名',
  123. },
  124. {
  125. type: 'text',
  126. key: 'address',
  127. value: '',
  128. label: '注册地址 *',
  129. rules: [v => !!v || '请输入注册地址']
  130. },
  131. {
  132. type: 'textarea',
  133. key: 'businessScope',
  134. value: null,
  135. resize: true,
  136. counter: 1600,
  137. rows: 5,
  138. label: '经营范围 *',
  139. outlined: true,
  140. rules: [v => !!v || '请输入经营范围']
  141. },
  142. ]
  143. })
  144. const CtFormRef = ref()
  145. const query = reactive({})
  146. const handleSave = async () => {
  147. const { valid } = await CtFormRef.value.formRef.validate()
  148. if (!valid) return
  149. formItems.value.options.forEach(e => {
  150. if (e.noParam) return
  151. query[e.key] = e.value
  152. })
  153. if (!query.establishmentTime) return Snackbar.warning('请选择成立时间')
  154. await updateEnterpriseBusiness(query)
  155. Snackbar.success('编辑成功')
  156. getBaseInfo()
  157. }
  158. let completeStatus = false
  159. // 获取基本信息
  160. const getBaseInfo = async () => {
  161. try {
  162. const data = await getEnterpriseBusiness()
  163. emit('complete', { status: data && Object.keys(data).length ? true : false, id: 'businessInformation' })
  164. if (!data) return
  165. query.id = data.id
  166. completeStatus = true
  167. formItems.value.options.forEach(item => {
  168. item.value = data[item.key]
  169. // 完成度展示
  170. if (item.key !== 'formerName') {
  171. if (item.value === undefined || item.value === null || item.value === '') completeStatus = false
  172. }
  173. })
  174. // 完成度展示
  175. emit('complete', { status: completeStatus, id: 'businessInformation' })
  176. } catch (error) {
  177. emit('complete', { status: completeStatus, id: 'businessInformation' })
  178. }
  179. }
  180. getBaseInfo()
  181. </script>
  182. <style lang="scss" scoped>
  183. </style>