field-pane-ccf.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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
  6. v-if="(item.field === 'id') || (item.field === 'label') || (item.field === 'enterpriseUserId') || (item.field === 'buyerId')"
  7. >
  8. </view>
  9. <view v-else-if="item.field === 'birthday'">
  10. <view class="item">
  11. <template>
  12. <view
  13. class="input-wrapper" :style="{
  14. 'flex-direction': item.type === 'textarea' ? 'column' : '',
  15. 'align-items': item.type === 'textarea' ? 'flex-start' : ''
  16. }"
  17. >
  18. <view class="sub-title">{{ item.label }}</view>
  19. <view v-if="item.type === 'time' && item.field === 'birthday'" class="input">
  20. <input
  21. :value="form[item.field]" :disabled="true" type="text"
  22. :placeholder="item.placeholder"
  23. @click="$refs.dateTimeTradeB[0].show()"
  24. />
  25. <tui-datetime
  26. ref="dateTimeTradeB" :type="2" radius
  27. @confirm="handleInput(item.field, $event)"
  28. ></tui-datetime>
  29. </view>
  30. </view>
  31. </template>
  32. </view>
  33. </view>
  34. <view v-else-if="item.field === 'styleId'">
  35. <view class="item">
  36. <view
  37. class="input-wrapper" :style="{
  38. 'flex-direction': item.type === 'textarea' ? 'column' : '',
  39. 'align-items': item.type === 'textarea' ? 'flex-start' : ''
  40. }"
  41. >
  42. <view class="sub-title">{{ item.label }}</view>
  43. <view
  44. v-if="item.type === 'select' && item.field === 'styleId'" style="flex: 1" :style="{
  45. color: form.styleId ? '' : '#999'
  46. }" @click="isShowStyleListSelect = true"
  47. >
  48. {{ styleName || (form.styleId ? `已选样式:${form.styleId}` : "请选择样式") }}
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <view
  54. v-else-if="(item.field === 'enterpriseName') || (item.field === 'enterpriseDuties') || (item.field === 'enterpriseDepartment')"
  55. >
  56. <view v-if="form.isEnterprise === 'true'">
  57. <view class="item">
  58. <template>
  59. <view
  60. class="input-wrapper" :style="{
  61. 'flex-direction': item.type === 'textarea' ? 'column' : '',
  62. 'align-items': item.type === 'textarea' ? 'flex-start' : ''
  63. }"
  64. >
  65. <view class="sub-title">{{ item.label }}</view>
  66. <input
  67. v-if="item.type === 'input'" :value="form[item.field]" class="input" :disabled="false"
  68. :type="item.field === 'phone' ? 'number' : 'text'" :placeholder="item.placeholder"
  69. @input="handleInput(item.field, $event)"
  70. />
  71. </view>
  72. </template>
  73. </view>
  74. </view>
  75. <view v-else></view>
  76. </view>
  77. <view v-else class="item">
  78. <template>
  79. <view
  80. class="input-wrapper" :style="{
  81. 'flex-direction': item.type === 'textarea' ? 'column' : '',
  82. 'align-items': item.type === 'textarea' ? 'flex-start' : ''
  83. }"
  84. >
  85. <view class="sub-title">{{ item.label }}</view>
  86. <input
  87. v-if="item.type === 'input'" :value="form[item.field]" class="input" :disabled="false"
  88. :type="item.field === 'phone' ? 'number' : 'text'" :placeholder="item.placeholder"
  89. @input="handleInput(item.field, $event)"
  90. />
  91. <textarea
  92. v-if="item.type === 'textarea'" :value="form[item.field]" class="textarea"
  93. :placeholder="item.placeholder" @input="handleInput(item.field, $event)"
  94. ></textarea>
  95. <tui-radio-group
  96. v-if="(item.type === 'radio') && (item.field === 'sex')" v-model="form[item.field]"
  97. @change="handleInput(item.field, $event)"
  98. >
  99. <view style="display: flex;">
  100. <tui-label v-for="(part, index) in [{ name: '男', value: '1' }, { name: '女', value: '2' }]" :key="index">
  101. <tui-list-cell padding="16rpx">
  102. <view>
  103. <tui-radio :checked="false" :value="part.value" color="#07c160" border-color="#999">
  104. </tui-radio>
  105. <text>{{ part.name }}</text>
  106. </view>
  107. </tui-list-cell>
  108. </tui-label>
  109. </view>
  110. </tui-radio-group>
  111. <tui-radio-group
  112. v-else-if="item.type === 'radio'" v-model="form[item.field]" style="display: flex;"
  113. @change="(e) => { }"
  114. >
  115. <view style="display: flex;">
  116. <tui-label v-for="(part, index) in [{ name: '是', value: 'true' }, { name: '否', value: 'false' }]" :key="index">
  117. <tui-list-cell padding="16rpx">
  118. <view>
  119. <tui-radio :checked="false" :value="part.value" color="#07c160" border-color="#999">
  120. </tui-radio>
  121. <text>{{ part.name }}</text>
  122. </view>
  123. </tui-list-cell>
  124. </tui-label>
  125. </view>
  126. </tui-radio-group>
  127. </view>
  128. </template>
  129. </view>
  130. </view>
  131. <!-- 样式 -->
  132. <tui-select
  133. :list="styleList" reverse :show="isShowStyleListSelect" @confirm="handleSelectStyleList"
  134. @close="isShowStyleListSelect = false"
  135. ></tui-select>
  136. </view>
  137. </template>
  138. <script>
  139. export default {
  140. name: 'FieldPaneCCF',
  141. props: {
  142. fields: {
  143. type: Array,
  144. required: true
  145. },
  146. value: {
  147. type: Object,
  148. required: true
  149. },
  150. title: String
  151. },
  152. data() {
  153. return {
  154. form: {},
  155. styleList: [],
  156. isShowStyleListSelect: false,
  157. styleName: ''
  158. }
  159. },
  160. watch: {
  161. fields: {
  162. handler(value) {
  163. if (value) {
  164. const form = {}
  165. for (const item of value) {
  166. form[item.field] = this.value[item.field]
  167. if (item.type === 'select' && item.field === 'styleId') this.getStyleList()
  168. }
  169. this.form = form
  170. }
  171. },
  172. immediate: true,
  173. deep: true
  174. },
  175. form: {
  176. handler(value) {
  177. this.$emit('input', value)
  178. },
  179. immediate: true,
  180. deep: true
  181. }
  182. },
  183. methods: {
  184. getStyleList() {
  185. // getxxxApi({})
  186. // .then((res) => {
  187. this.styleList = [{ styleId: 1, value: 1, text: '样式一' }, { styleId: 2, value: 2, text: '样式二' }, { styleId: 3, value: 3, text: '样式三' }]
  188. // })
  189. // .catch(() => {
  190. // this.$showToast('样式列表获取失败')
  191. // })
  192. },
  193. handleSelectStyleList(e) {
  194. this.isShowStyleListSelect = false
  195. this.styleName = e.options.text
  196. this.form.styleId = e.options.styleId
  197. },
  198. handleInput(field, e) {
  199. console.log(field, e)
  200. if (field === 'birthday') {
  201. this.form[field] = e.result
  202. } else {
  203. this.form[field] = e.detail.value
  204. }
  205. }
  206. }
  207. }
  208. </script>
  209. <style lang="less" scoped>
  210. .field-pane-container {
  211. margin-top: 30rpx;
  212. .title {
  213. font-size: 28rpx;
  214. color: #fa5151;
  215. font-weight: bold;
  216. }
  217. .item {
  218. padding: 20rpx 0;
  219. border-bottom: 1rpx solid #d8d8d8;
  220. margin-top: 20rpx;
  221. .input-wrapper {
  222. display: flex;
  223. align-items: center;
  224. justify-content: space-between;
  225. font-size: 24rpx;
  226. color: #3d3d3d;
  227. .sub-title {
  228. margin-right: 20rpx;
  229. }
  230. /deep/ .uni-input-placeholder,
  231. /deep/ .uni-textarea-placeholder {
  232. font-size: 24rpx;
  233. color: #999;
  234. }
  235. .input {
  236. flex: 1;
  237. font-size: 24rpx;
  238. }
  239. .textarea {
  240. margin-top: 20rpx;
  241. width: 100%;
  242. height: 100px;
  243. font-size: 24rpx;
  244. }
  245. }
  246. }
  247. }
  248. </style>