selectForm.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <view class="container_input">
  3. <view class="container_input_item" v-for="(item, index) in platformClassification" :key="index" @click="selectItem(item)" v-if="!item.DoNotShow">
  4. <view class="select_and_input" v-if="item.type == 'select' || item.type == 'input' || item.type == 'switch'">
  5. <view class="container_input_item_label">
  6. <text class="select_check" :class="{ select: item.select }" @click.stop="selectRadio(item)" v-if="Object.keys(item).indexOf('select') != -1">
  7. <text v-if="item.select" class="iconfont">&#xe646;</text>
  8. </text>
  9. <text class="select_label line1">{{ item.label }}</text>
  10. </view>
  11. <view class="container_input_item_value greyColor" v-if="item.type == 'select'">
  12. <text v-if="item.value" class="text">{{ item.value }}</text>
  13. <text v-else>{{ item.holder }}</text>
  14. <text class="iconfont">&#xe6bd;</text>
  15. </view>
  16. <view class="container_input_item_value" v-if="item.type == 'input'">
  17. <input v-model="formData[item.model]" type="text" value="" :placeholder="item.holder" placeholder-class="inputPlaceHolder" />
  18. </view>
  19. <view class="container_input_item_value" v-if="item.type == 'switch'">
  20. <switch :checked="formData[item.model] == 1" color="#E93323" style="transform:scale(0.8)" @change="switchChange($event, item)" />
  21. </view>
  22. </view>
  23. <view class="radio" v-if="item.type == 'radio' || item.type == 'check'">
  24. <view class="container_input_item_label">{{ item.label }}</view>
  25. <view class="container_input_item_value flex_start" v-if="item.type == 'radio'">
  26. <radio-group class="select_group" @change="radioChange($event, item)">
  27. <label class="container_input_item_value_select" v-for="(val, i) in item.radioList" :key="val.value">
  28. <view>
  29. <radio :value="val.value" :checked="val.value == item.inforValue" />
  30. </view>
  31. <view>{{ val.name }}</view>
  32. </label>
  33. </radio-group>
  34. </view>
  35. <view class="container_input_item_value flex_start" v-if="item.type == 'check'">
  36. <checkbox-group class="select_group" @change="checkChange($event, item)">
  37. <label class="container_input_item_value_select" v-for="(val, i) in item.checkList" :key="val.value">
  38. <view>
  39. <checkbox class="chenk_list" :value="val.value" :checked="val.value == item.inforValue" />
  40. </view>
  41. <view>{{ val.name }}</view>
  42. </label>
  43. </checkbox-group>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. // +----------------------------------------------------------------------
  51. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  52. // +----------------------------------------------------------------------
  53. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  54. // +----------------------------------------------------------------------
  55. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  56. // +----------------------------------------------------------------------
  57. // | Author: CRMEB Team <admin@crmeb.com>
  58. // +----------------------------------------------------------------------
  59. /*
  60. item参数
  61. id:
  62. type: select
  63. label: '标题'
  64. jumpLogic: 是否自定义跳转逻辑
  65. select 有此key值时,可进行选择逻辑
  66. */
  67. export default {
  68. props: {
  69. platformClassification: {
  70. type: Array,
  71. default() {
  72. return [];
  73. }
  74. },
  75. form: {
  76. type: Object,
  77. default: () => {
  78. return {};
  79. }
  80. }
  81. },
  82. data() {
  83. return {
  84. value: '',
  85. formData: this.form
  86. };
  87. },
  88. watch: {
  89. formData: {
  90. handler(val) {
  91. this.$emit('input',val)
  92. },
  93. deep: true
  94. },
  95. form: {
  96. handler(val) {
  97. this.formData = val
  98. },
  99. deep: true
  100. }
  101. },
  102. created() {
  103. this.platformClassification.forEach(item => {
  104. if(item.inforValue) {
  105. this.$emit('formInitData', item.inforValue, item.model);
  106. }
  107. });
  108. },
  109. methods: {
  110. selectItem(item) {
  111. if(item.jumpLogic) {
  112. // 执行跳转新界面逻辑暴露的方法
  113. this.$emit('handleJumpLogic', item);
  114. return;
  115. }
  116. this.$emit('handleSelectItem', item);
  117. },
  118. radioChange(e, item) {
  119. this.$emit('radioChange', e.detail.value, item);
  120. },
  121. // switch组件切换
  122. switchChange(e, item) {
  123. this.$emit('switchChange', e.detail.value, item);
  124. },
  125. // 可选择条框模式
  126. // 选择事件
  127. selectRadio(item) {
  128. item.select = !item.select;
  129. },
  130. // 多选按钮
  131. checkChange(e, item) {
  132. this.$emit('checkChange', e.detail.value, item);
  133. }
  134. }
  135. };
  136. </script>
  137. <style lang="scss" scoped>
  138. .container_input {
  139. background: #fff;
  140. padding: 0 20rpx;
  141. width: 710rpx;
  142. margin: auto;
  143. margin-top: 31rpx;
  144. border-radius: 10rpx;
  145. &_item {
  146. .select_and_input {
  147. height: 106rpx;
  148. display: flex;
  149. align-items: center;
  150. justify-content: space-between;
  151. .greyColor {
  152. color: #bbbbbb;
  153. }
  154. }
  155. .radio {
  156. padding: 30rpx 0;
  157. }
  158. &_label {
  159. padding-left: 10rpx;
  160. color: #333333;
  161. font-size: 30rpx;
  162. display: flex;
  163. align-items: center;
  164. .select_label{
  165. max-width: 520rpx;
  166. }
  167. .select_check {
  168. display: flex;
  169. align-items: center;
  170. justify-content: center;
  171. width: 40rpx;
  172. height: 40rpx;
  173. border: 1px solid #cccccc;
  174. border-radius: 50%;
  175. margin-right: 20rpx;
  176. .iconfont {
  177. font-size: 24rpx;
  178. }
  179. }
  180. .select {
  181. background: #e93323;
  182. border: none;
  183. .iconfont {
  184. color: #fff;
  185. }
  186. }
  187. }
  188. &_value {
  189. padding-right: 10rpx;
  190. flex: 1;
  191. display: flex;
  192. align-items: center;
  193. justify-content: flex-end;
  194. > span:nth-child(1) {
  195. display: inline-block;
  196. margin-right: 15rpx;
  197. }
  198. .text {
  199. color: #000;
  200. display: inline-block;
  201. max-width: 400rpx;
  202. overflow: hidden;
  203. white-space: nowrap;
  204. text-overflow: ellipsis;
  205. }
  206. input {
  207. text-align: right;
  208. }
  209. .select_group {
  210. display: flex;
  211. }
  212. &_select {
  213. display: flex;
  214. margin-right: 110rpx;
  215. }
  216. }
  217. .flex_start {
  218. padding: 0 10rpx;
  219. margin-top: 40rpx;
  220. justify-content: flex-start;
  221. }
  222. }
  223. > view:not(:last-child) {
  224. border-bottom: 1px solid #eeeeee;
  225. }
  226. }
  227. .inputPlaceHolder {
  228. color: #bbbbbb;
  229. }
  230. </style>