field-pane-clf.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <view class="field-pane-container">
  3. <view class="title">{{ title }}</view>
  4. <view v-for="item in fields" :key="item.label">
  5. <view v-if="item.field === 'id'"></view>
  6. <view v-else-if="(item.field === 'labelId') || (item.field === 'createTime')">
  7. <view v-if="form[item.field]" class="item">
  8. <view
  9. class="input-wrapper" :style="{
  10. 'flex-direction': item.type === 'textarea' ? 'column' : '',
  11. 'align-items': item.type === 'textarea' ? 'flex-start' : ''
  12. }"
  13. >
  14. <view class="sub-title">{{ item.label }}</view>
  15. <input
  16. v-if="item.type === 'input'" :value="form[item.field]" class="input" disabled
  17. type="text"
  18. :placeholder="item.placeholder"
  19. />
  20. </view>
  21. </view>
  22. </view>
  23. <view v-else class="item">
  24. <template>
  25. <view
  26. class="input-wrapper" :style="{
  27. 'flex-direction': item.type === 'textarea' ? 'column' : '',
  28. 'align-items': item.type === 'textarea' ? 'flex-start' : ''
  29. }"
  30. >
  31. <view class="sub-title">{{ item.label }}</view>
  32. <input
  33. v-if="item.type === 'input'" :value="form[item.field]" class="input"
  34. :disabled="item.field === 'enterpriseUserId'" :type="item.field === 'enterpriseUserId' ? 'number' : 'text'"
  35. :placeholder="item.placeholder" @input="handleInput(item.field, $event)"
  36. />
  37. </view>
  38. </template>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. name: 'FieldPaneCLF',
  46. props: {
  47. fields: {
  48. type: Array,
  49. required: true
  50. },
  51. value: {
  52. type: Object,
  53. required: true
  54. },
  55. title: String
  56. },
  57. data() {
  58. return {
  59. form: {}
  60. }
  61. },
  62. watch: {
  63. fields: {
  64. handler(value) {
  65. if (value) {
  66. const form = {}
  67. for (const item of value) {
  68. form[item.field] = this.value[item.field]
  69. }
  70. this.form = form
  71. }
  72. },
  73. immediate: true,
  74. deep: true
  75. },
  76. form: {
  77. handler(value) {
  78. this.$emit('input', value)
  79. },
  80. immediate: true,
  81. deep: true
  82. }
  83. },
  84. created() {
  85. },
  86. mounted() {
  87. // console.log(this.$refs)
  88. },
  89. methods: {
  90. handleInput(field, e) {
  91. console.log(field, e)
  92. if (field === 'labelName') {
  93. this.form[field] = e.detail.value
  94. }
  95. }
  96. }
  97. }
  98. </script>
  99. <style lang="less" scoped>
  100. .field-pane-container {
  101. margin-top: 30rpx;
  102. .title {
  103. font-size: 28rpx;
  104. color: #fa5151;
  105. font-weight: bold;
  106. }
  107. .item {
  108. padding: 20rpx 0;
  109. border-bottom: 1rpx solid #d8d8d8;
  110. margin-top: 20rpx;
  111. .input-wrapper {
  112. display: flex;
  113. align-items: center;
  114. justify-content: space-between;
  115. font-size: 24rpx;
  116. color: #3d3d3d;
  117. .sub-title {
  118. margin-right: 20rpx;
  119. }
  120. /deep/ .uni-input-placeholder,
  121. /deep/ .uni-textarea-placeholder {
  122. font-size: 24rpx;
  123. color: #999;
  124. }
  125. .input {
  126. flex: 1;
  127. font-size: 24rpx;
  128. }
  129. .textarea {
  130. margin-top: 20rpx;
  131. width: 100%;
  132. height: 100px;
  133. font-size: 24rpx;
  134. }
  135. }
  136. }
  137. }
  138. </style>