baseInfoItem.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <view
  3. v-if="field.formType === 'detail_table'"
  4. class="table-container">
  5. <template v-if="!$isEmpty(field.value)">
  6. <view
  7. v-for="(child, index) in field.value"
  8. :key="index">
  9. <view class="table-title">
  10. {{ field.name }}{{ index + 1 }}
  11. </view>
  12. <base-info-item
  13. v-for="(item, childIndex) in child"
  14. :key="childIndex"
  15. :field="item" />
  16. </view>
  17. </template>
  18. </view>
  19. <view
  20. v-else-if="field.formType !== 'desc_text'"
  21. class="info-item">
  22. <view class="info-item-label">
  23. {{ field.name }}
  24. </view>
  25. <view class="info-item-value">
  26. <template v-if="field.formType === 'file'">
  27. <view
  28. v-for="(file, childIndex) in field.value"
  29. :key="childIndex"
  30. class="file-item"
  31. @click="downloadFile(file)">
  32. {{ file.name }}
  33. </view>
  34. </template>
  35. <template v-else-if="field.formType === 'handwriting_sign'">
  36. <wk-signature-view :batch-id="field.value" />
  37. </template>
  38. <template v-else-if="field.formType === 'field_tag'">
  39. <view class="tag-wrapper">
  40. <text
  41. v-for="(tag, tagIndex) in (field.value || [])"
  42. :key="tagIndex"
  43. :style="{backgroundColor: tag.color}"
  44. class="tag-item">
  45. {{ tag.name }}
  46. </text>
  47. </view>
  48. </template>
  49. <template v-else-if="field.formType === 'field_attention'">
  50. <view class="attention-wrapper">
  51. <view
  52. v-for="(item, aIndex) in getAttenditonList(field.value)"
  53. :key="aIndex"
  54. :class="{active: item}"
  55. class="ft ft-focus-on star-icon" />
  56. </view>
  57. </template>
  58. <template v-else-if="isWebSite(field)">
  59. <text
  60. class="font-theme-color"
  61. @click="handlerWebsite(field)">
  62. {{ valueStr || '' }}
  63. </text>
  64. </template>
  65. <template v-else-if="isTel(field)">
  66. <text
  67. class="font-theme-color"
  68. @click="handlerCall(field)">
  69. {{ valueStr || '' }}
  70. </text>
  71. </template>
  72. <template v-else>
  73. {{ valueStr || '' }}
  74. </template>
  75. </view>
  76. <uni-popup
  77. v-if="isWebSite(field)"
  78. ref="popup"
  79. type="dialog">
  80. <uni-popup-dialog
  81. :content="dialogMsg"
  82. type="warning"
  83. @confirm="handleDialogConfirm" />
  84. </uni-popup>
  85. </view>
  86. <view
  87. v-else-if="field.formType === 'desc_text' && field.value"
  88. class="info-item desc_text">
  89. <rich-text :nodes="field.value" />
  90. </view>
  91. </template>
  92. <script>
  93. import { downloadFile } from '@/utils/file.js'
  94. import fieldValueMixins from '@/mixins/fieldValueMixins.js'
  95. import BaseInfoItem from './baseInfoItem.vue'
  96. export default {
  97. name: 'BaseInfoItem',
  98. components: {
  99. BaseInfoItem
  100. },
  101. mixins: [fieldValueMixins],
  102. props: {
  103. field: {
  104. type: Object,
  105. required: true
  106. },
  107. detailData: {
  108. type: Object,
  109. default: () => {}
  110. }
  111. },
  112. data() {
  113. return {
  114. dialogMsg: '',
  115. webUrl: ''
  116. }
  117. },
  118. computed: {
  119. valueStr() {
  120. return this.getFieldValue(this.field)
  121. }
  122. },
  123. methods: {
  124. /**
  125. * 打电话
  126. */
  127. handlerCall(item) {
  128. let tel = this.getFieldValue(item)
  129. if (!tel) return
  130. uni.makePhoneCall({
  131. phoneNumber: tel
  132. })
  133. },
  134. getAttenditonList(val) {
  135. // 主要是为了处理 v-for 循环数字报错问题
  136. let list = Array(5).fill(false)
  137. const num = Number(val) || 0
  138. if (num > 0) {
  139. const checked = Array(num).fill(true)
  140. list.splice(0, num, ...checked)
  141. }
  142. return list
  143. },
  144. downloadFile(file) {
  145. downloadFile(file)
  146. },
  147. handlerWebsite(item) {
  148. this.webUrl = this.getFieldValue(item)
  149. if (!this.webUrl) return
  150. if (
  151. !this.webUrl.startsWith('http://') ||
  152. !this.webUrl.startsWith('https://')
  153. ) {
  154. this.webUrl = `http://${this.webUrl}`
  155. }
  156. this.dialogMsg = `使用浏览器打开 ${this.webUrl} ?`
  157. this.$refs.popup.open()
  158. },
  159. handleDialogConfirm(next) {
  160. next()
  161. // #ifdef APP-PLUS
  162. plus.runtime.openURL(this.webUrl)
  163. // #endif
  164. // #ifdef H5
  165. window.open(this.webUrl, '_blank')
  166. // #endif
  167. }
  168. }
  169. }
  170. </script>
  171. <style scoped lang="scss">
  172. .font-theme-color {
  173. color: $theme-color;
  174. }
  175. .info-item {
  176. width: 100%;
  177. border-bottom: 1rpx solid #f9f9f9;
  178. padding: 0 52rpx;
  179. .info-item-label {
  180. font-size: 26rpx;
  181. color: $light;
  182. padding: 15rpx 0;
  183. }
  184. .info-item-value {
  185. width: 100%;
  186. min-height: 50rpx;
  187. font-size: 30rpx;
  188. color: $dark;
  189. .file-item {
  190. width: 100%;
  191. color: $theme-color;
  192. font-size: 28rpx;
  193. @include ellipsis;
  194. }
  195. .signaure-img {
  196. width: 100%;
  197. }
  198. .tag-wrapper {
  199. padding-bottom: 20rpx;
  200. .tag-item {
  201. font-size: $wk-font-mini;
  202. color: white;
  203. border-radius: 5rpx;
  204. margin: 10rpx;
  205. padding: 5rpx 10rpx;
  206. }
  207. }
  208. .attention-wrapper {
  209. padding-bottom: 10rpx;
  210. @include left;
  211. .star-icon {
  212. font-size: 42rpx;
  213. color: #D9D9D9;
  214. margin: 0 10rpx;
  215. &.active {
  216. color: #FAC23D;
  217. }
  218. }
  219. }
  220. }
  221. }
  222. .desc_text {
  223. font-size: $wk-font-base;
  224. border: 0 none;
  225. margin: 10rpx 0;
  226. }
  227. .table-container {
  228. margin: 0 20rpx;
  229. .table-title {
  230. width: 100%;
  231. font-weight: 500;
  232. font-size: $wk-font-medium;
  233. background-color: #ebeef1;
  234. border-radius: 10rpx;
  235. padding: 15rpx 32rpx;
  236. }
  237. .info-item {
  238. padding: 0 32rpx;
  239. }
  240. }
  241. </style>