baseInfo.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <view v-if="showBaseInfo" class="detail-base-info">
  3. <view class="section">
  4. <view class="section-title">
  5. <text class="icon" />
  6. <text class="text">
  7. 基本信息
  8. </text>
  9. </view>
  10. <view class="section-body">
  11. <template v-for="item in baseInfo">
  12. <base-info-item
  13. :key="item.fieldId"
  14. :field="item"
  15. :detail-data="detailData" />
  16. </template>
  17. </view>
  18. </view>
  19. <template v-if="insertFields">
  20. <view
  21. v-for="(child, index) in insertFields"
  22. :key="index"
  23. class="section">
  24. <view class="section-title">
  25. <text class="icon" />
  26. <text class="text">
  27. {{ child.name }}
  28. </text>
  29. </view>
  30. <view class="section-body">
  31. <base-info-item
  32. v-for="item in child.list"
  33. :key="item.fieldId"
  34. :field="item"
  35. :detail-data="detailData" />
  36. </view>
  37. </view>
  38. </template>
  39. <view class="section">
  40. <view class="section-title">
  41. <text class="icon" />
  42. <text class="text">
  43. 系统信息
  44. </text>
  45. </view>
  46. <view class="section-body">
  47. <base-info-item
  48. v-for="item in sysInfo"
  49. :key="item.fieldId"
  50. :field="item"
  51. :detail-data="detailData" />
  52. </view>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import { InformationById as LeadsInformation } from 'API/crm/leads'
  58. import { InformationById as CustomerInformation } from 'API/crm/customer'
  59. import { InformationById as ContactsInformation } from 'API/crm/concat'
  60. import { InformationById as BusinessInformation } from 'API/crm/business'
  61. import { InformationById as ContractInformation } from 'API/crm/contract'
  62. import { InformationById as ReceivablesInformation } from 'API/crm/received'
  63. import { InformationById as ProductInformation } from 'API/crm/product'
  64. import { InformationById as InvoiceInformation } from 'API/crm/invoice'
  65. import BaseInfoItem from './baseInfoItem'
  66. export default {
  67. name: 'DetailBaseInfo',
  68. components: {
  69. BaseInfoItem
  70. },
  71. props: {
  72. detailId: {
  73. type: [String, Number],
  74. required: true
  75. },
  76. detailData: {
  77. type: Object,
  78. default: () => {}
  79. },
  80. type: {
  81. type: String,
  82. required: true
  83. },
  84. poolId: {
  85. type: [String, Number],
  86. default: null
  87. },
  88. insertFields: {
  89. type: Array,
  90. default: null
  91. }
  92. },
  93. data() {
  94. return {
  95. baseInfo: [],
  96. sysInfo: [],
  97. dialogMsg: '',
  98. webUrl: '',
  99. reqMap: {
  100. crm_leads: LeadsInformation,
  101. crm_customer: CustomerInformation,
  102. crm_pool: CustomerInformation,
  103. crm_contacts: ContactsInformation,
  104. crm_business: BusinessInformation,
  105. crm_contract: ContractInformation,
  106. crm_receivables: ReceivablesInformation,
  107. crm_product: ProductInformation,
  108. crm_invoice: InvoiceInformation
  109. },
  110. showBaseInfo: true
  111. }
  112. },
  113. wkActivated() {
  114. this.showBaseInfo = false
  115. this.$nextTick(function() {
  116. this.showBaseInfo = true
  117. })
  118. },
  119. mounted() {
  120. this.getFieldList()
  121. },
  122. methods: {
  123. /**
  124. * 获取自定义字段信息
  125. */
  126. getFieldList() {
  127. const request = this.reqMap[this.type]
  128. if (!request) {
  129. this.baseInfo = []
  130. this.sysInfo = []
  131. }
  132. const params = { id: this.detailId }
  133. if (this.type === 'crm_pool') {
  134. params.poolId = this.poolId
  135. params.types = 2
  136. }
  137. request(params).then(res => {
  138. const list = []
  139. const _arr = []
  140. res = res.filter(o => o.formType !== 'product')
  141. if (this.type === 'crm_invoice') {
  142. const findRes = res.find(o => o.fieldName === 'invoiceType')
  143. if (findRes) {
  144. findRes.setting = [
  145. { name: '增值税专用发票', value: 1 },
  146. { name: '增值税普通发票', value: 2 },
  147. { name: '国税通用机打发票', value: 3 },
  148. { name: '地税通用机打发票', value: 4 },
  149. { name: '收据', value: 5 }
  150. ]
  151. }
  152. }
  153. res.filter(o => o.sysInformation !== 1).forEach(o => {
  154. if (o.formType === 'detail_table') {
  155. // 把明细表格字段放到最后
  156. _arr.push(o)
  157. } else {
  158. list.push(o)
  159. }
  160. })
  161. this.baseInfo = list.concat(_arr)
  162. this.sysInfo = res.filter(o => o.sysInformation === 1)
  163. }).catch(() => {
  164. this.baseInfo = []
  165. this.sysInfo = []
  166. })
  167. }
  168. }
  169. }
  170. </script>
  171. <style scoped lang="scss">
  172. .detail-base-info {
  173. .section {
  174. width: 100%;
  175. background-color: white;
  176. padding: 32rpx 0 20rpx;
  177. margin-bottom: 15rpx;
  178. &:first-child {
  179. border-radius: 18rpx 18rpx 0 0;
  180. }
  181. .section-title {
  182. padding: 0 25rpx;
  183. .icon {
  184. width: 15rpx;
  185. height: 15rpx;
  186. vertical-align: middle;
  187. background-color: #333333;
  188. border-radius: 50%;
  189. display: inline-block;
  190. margin-right: 15rpx;
  191. }
  192. .text {
  193. color: #212121;
  194. font-size: 28rpx;
  195. }
  196. }
  197. .section-body {
  198. }
  199. }
  200. }
  201. </style>