uni-data-select.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  1. <template>
  2. <view class="uni-stat__select">
  3. <span v-if="label" class="uni-label-text hide-on-phone">{{ label + ':' }}</span>
  4. <view class="uni-stat-box" :class="{ 'uni-stat__actived': current }">
  5. <view class="uni-select"
  6. :class="{ 'uni-select--disabled': disabled, 'uni-select--wrap': shouldWrap, 'border-default': mode == 'default', 'border-bottom': mode == 'underline' }">
  7. <view class="uni-select__input-box" @click="toggleSelector"
  8. :class="{ 'uni-select__input-box--wrap': shouldWrap }">
  9. <view v-if="slotSelected" class="slot-content padding-top-bottom"
  10. :class="{ 'uni-select__input-text--wrap': shouldWrap }">
  11. <slot name="selected" :selectedItems="getSelectedItems()"></slot>
  12. </view>
  13. <template v-else>
  14. <view v-if="textShow" class="uni-select__input-text"
  15. :class="{ 'uni-select__input-text--wrap': shouldWrap }">
  16. <view class="padding-top-bottom" :class="'align-' + align">{{ textShow }}</view>
  17. </view>
  18. <view v-else class="uni-select__input-text uni-select__input-placeholder"
  19. :class="'align-' + align">{{ typePlaceholder }}</view>
  20. </template>
  21. <view key="clear-button" v-if="!hideRight && shouldShowClear && clear && !disabled"
  22. @click.stop="clearVal">
  23. <uni-icons type="clear" color="#c0c4cc" size="24" />
  24. </view>
  25. <view key="arrow-button" v-else-if="!hideRight">
  26. <uni-icons :type="showSelector ? 'top' : 'bottom'" size="14" color="#999" />
  27. </view>
  28. </view>
  29. <view class="uni-select--mask" v-if="showSelector" @click="toggleSelector" />
  30. <view class="uni-select__selector" :style="getOffsetByPlacement" v-if="showSelector">
  31. <view :class="placement == 'bottom' ? 'uni-popper__arrow_bottom' : 'uni-popper__arrow_top'"></view>
  32. <scroll-view scroll-y="true" class="uni-select__selector-scroll">
  33. <template v-if="slotEmpty && mixinDatacomResData.length === 0">
  34. <view class="uni-select__selector-empty">
  35. <slot name="empty" :empty="emptyTips"></slot>
  36. </view>
  37. </template>
  38. <template v-else>
  39. <view v-if="mixinDatacomResData.length === 0" class="uni-select__selector-empty">
  40. <text>{{ emptyTips }}</text>
  41. </view>
  42. </template>
  43. <template v-if="slotOption">
  44. <view v-for="(itemData, index) in mixinDatacomResData" :key="index"
  45. @click="change(itemData)">
  46. <slot name="option" :item="itemData"
  47. :itemSelected="multiple ? getCurrentValues().includes(itemData.value) : getCurrentValues() == itemData.value">
  48. </slot>
  49. </view>
  50. </template>
  51. <template v-else>
  52. <view v-if="!multiple && mixinDatacomResData.length > 0"
  53. :class="{ 'uni-select__selector-item': true, 'uni-select__selector-item--actived': item.value === modelValue }"
  54. class="" v-for="(item, index) in mixinDatacomResData" :key="index"
  55. @click="change(item)">
  56. <text :class="{ 'uni-select__selector__disabled': item.disable }">{{
  57. formatItemName(item) }}</text>
  58. </view>
  59. <view v-if="multiple && mixinDatacomResData.length > 0">
  60. <checkbox-group @change="checkBoxChange">
  61. <label class="uni-select__selector-item"
  62. v-for="(item, index) in mixinDatacomResData" :key="index">
  63. <checkbox :value="index + ''" :checked="getCurrentValues().includes(item.value)"
  64. :disabled="item.disable"></checkbox>
  65. <view :class="{ 'uni-select__selector__disabled': item.disable }">
  66. {{ formatItemName(item) }}</view>
  67. </label>
  68. </checkbox-group>
  69. </view>
  70. </template>
  71. </scroll-view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </template>
  77. <script>
  78. /**
  79. * DataChecklist 数据选择器
  80. * @description 通过数据渲染的下拉框组件
  81. * @tutorial https://uniapp.dcloud.io/component/uniui/uni-data-select
  82. * @property {String|Array} value 默认值,多选时为数组
  83. * @property {Array} localdata 本地数据 ,格式 [{text:'',value:''}]
  84. * @property {Boolean} clear 是否可以清空已选项
  85. * @property {Boolean} emptyText 没有数据时显示的文字 ,本地数据无效
  86. * @property {String} label 左侧标题
  87. * @property {String} placeholder 输入框的提示文字
  88. * @property {Boolean} disabled 是否禁用
  89. * @property {Boolean} multiple 是否多选模式
  90. * @property {Boolean} wrap 是否允许选中文本换行显示
  91. * @property {String} placement 弹出位置
  92. * @value top 顶部弹出
  93. * @value bottom 底部弹出(default)
  94. * @property {String} align 选择文字的位置
  95. * @value left 显示左侧
  96. * @value center 显示中间
  97. * @value right 显示 右侧
  98. * @property {Boolean} hideRight 是否隐藏右侧按钮
  99. * @property {String} mode 边框样式
  100. * @value default 四周边框
  101. * @value underline 下边框
  102. * @value none 无边框
  103. * @event {Function} change 选中发生变化触发
  104. * @event {Function} open 选择框开启时触发
  105. * @event {Function} close 选择框关闭时触发
  106. * @event {Function} clear 点击清除按钮之后触发
  107. */
  108. export default {
  109. name: "uni-data-select",
  110. mixins: [uniCloud.mixinDatacom || {}],
  111. emits: [
  112. 'open',
  113. 'close',
  114. 'update:modelValue',
  115. 'input',
  116. 'clear',
  117. 'change'
  118. ],
  119. model: {
  120. prop: 'modelValue',
  121. event: 'update:modelValue'
  122. },
  123. options: {
  124. // #ifdef MP-TOUTIAO
  125. virtualHost: false,
  126. // #endif
  127. // #ifndef MP-TOUTIAO
  128. virtualHost: true
  129. // #endif
  130. },
  131. props: {
  132. localdata: {
  133. type: Array,
  134. default() {
  135. return []
  136. }
  137. },
  138. value: {
  139. type: [String, Number, Array],
  140. default: ''
  141. },
  142. modelValue: {
  143. type: [String, Number, Array],
  144. default: ''
  145. },
  146. label: {
  147. type: String,
  148. default: ''
  149. },
  150. placeholder: {
  151. type: String,
  152. default: '请选择'
  153. },
  154. emptyTips: {
  155. type: String,
  156. default: '无选项'
  157. },
  158. clear: {
  159. type: Boolean,
  160. default: true
  161. },
  162. defItem: {
  163. type: Number,
  164. default: 0
  165. },
  166. disabled: {
  167. type: Boolean,
  168. default: false
  169. },
  170. // 格式化输出 用法 field="_id as value, version as text, uni_platform as label" format="{label} - {text}"
  171. format: {
  172. type: String,
  173. default: ''
  174. },
  175. placement: {
  176. type: String,
  177. default: 'bottom'
  178. },
  179. multiple: {
  180. type: Boolean,
  181. default: false
  182. },
  183. wrap: {
  184. type: Boolean,
  185. default: false
  186. },
  187. align: {
  188. type: String,
  189. default: "left"
  190. },
  191. hideRight: {
  192. type: Boolean,
  193. default: false
  194. },
  195. mode: {
  196. type: String,
  197. default: 'default'
  198. }
  199. },
  200. data() {
  201. return {
  202. showSelector: false,
  203. current: '',
  204. mixinDatacomResData: [],
  205. apps: [],
  206. channels: [],
  207. cacheKey: "uni-data-select-lastSelectedValue",
  208. };
  209. },
  210. created() {
  211. this.debounceGet = this.debounce(() => {
  212. this.query();
  213. }, 300);
  214. if (this.collection && !this.localdata.length) {
  215. this.debounceGet();
  216. }
  217. },
  218. computed: {
  219. typePlaceholder() {
  220. const text = {
  221. 'opendb-stat-app-versions': '版本',
  222. 'opendb-app-channels': '渠道',
  223. 'opendb-app-list': '应用'
  224. }
  225. const common = this.placeholder
  226. const placeholder = text[this.collection]
  227. return placeholder ?
  228. common + placeholder :
  229. common
  230. },
  231. valueCom() {
  232. if (this.value === '') return this.modelValue
  233. if (this.modelValue === '') return this.value
  234. return this.value
  235. },
  236. textShow() {
  237. // 长文本显示
  238. if (this.multiple) {
  239. const currentValues = this.getCurrentValues();
  240. if (Array.isArray(currentValues) && currentValues.length > 0) {
  241. const selectedItems = this.mixinDatacomResData.filter(item => currentValues.includes(item.value));
  242. return selectedItems.map(item => this.formatItemName(item)).join(', ');
  243. } else {
  244. return ''; // 空数组时返回空字符串,显示占位符
  245. }
  246. } else {
  247. return this.current;
  248. }
  249. },
  250. shouldShowClear() {
  251. if (this.multiple) {
  252. const currentValues = this.getCurrentValues();
  253. return Array.isArray(currentValues) && currentValues.length > 0;
  254. } else {
  255. return !!this.current;
  256. }
  257. },
  258. shouldWrap() {
  259. // 只有在多选模式、开启换行、且有内容时才应用换行样式
  260. return this.multiple && this.wrap && !!this.textShow;
  261. },
  262. getOffsetByPlacement() {
  263. switch (this.placement) {
  264. case 'top':
  265. return "bottom:calc(100% + 12px);";
  266. case 'bottom':
  267. return "top:calc(100% + 12px);";
  268. }
  269. },
  270. slotSelected() {
  271. // #ifdef VUE2
  272. return this.$scopedSlots ? this.$scopedSlots.selected : false
  273. // #endif
  274. // #ifdef VUE3
  275. return this.$slots ? this.$slots.selected : false
  276. // #endif
  277. },
  278. slotEmpty() {
  279. // #ifdef VUE2
  280. return this.$scopedSlots ? this.$scopedSlots.empty : false
  281. // #endif
  282. // #ifdef VUE3
  283. return this.$slots ? this.$slots.empty : false
  284. // #endif
  285. },
  286. slotOption() {
  287. // #ifdef VUE2
  288. return this.$scopedSlots ? this.$scopedSlots.option : false
  289. // #endif
  290. // #ifdef VUE3
  291. return this.$slots ? this.$slots.option : false
  292. // #endif
  293. }
  294. },
  295. watch: {
  296. showSelector: {
  297. handler(val, old) {
  298. val ? this.$emit('open') : this.$emit('close')
  299. }
  300. },
  301. localdata: {
  302. immediate: true,
  303. handler(val, old) {
  304. if (Array.isArray(val) && old !== val) {
  305. this.mixinDatacomResData = val
  306. }
  307. }
  308. },
  309. valueCom(val, old) {
  310. this.initDefVal()
  311. },
  312. mixinDatacomResData: {
  313. immediate: true,
  314. handler(val) {
  315. if (val.length) {
  316. this.initDefVal()
  317. }
  318. }
  319. },
  320. },
  321. methods: {
  322. getSelectedItems() {
  323. const currentValues = this.getCurrentValues();
  324. let _minxData = this.mixinDatacomResData
  325. // #ifdef MP-WEIXIN || MP-TOUTIAO
  326. _minxData = JSON.parse(JSON.stringify(this.mixinDatacomResData))
  327. // #endif
  328. if (this.multiple) {
  329. return _minxData.filter(item => currentValues.includes(item.value)) || [];
  330. } else {
  331. return _minxData.filter(item => item.value === currentValues) || [];
  332. }
  333. },
  334. debounce(fn, time = 100) {
  335. let timer = null
  336. return function (...args) {
  337. if (timer) clearTimeout(timer)
  338. timer = setTimeout(() => {
  339. fn.apply(this, args)
  340. }, time)
  341. }
  342. },
  343. // 检查项目是否已选中
  344. isSelected(item) {
  345. if (this.multiple) {
  346. const currentValues = this.getCurrentValues();
  347. return Array.isArray(currentValues) && currentValues.includes(item.value);
  348. } else {
  349. return this.getCurrentValues() === item.value;
  350. }
  351. },
  352. // 获取当前选中的值
  353. getCurrentValues() {
  354. if (this.multiple) {
  355. return Array.isArray(this.valueCom) ? this.valueCom : (this.valueCom ? [this.valueCom] : []);
  356. } else {
  357. return this.valueCom;
  358. }
  359. },
  360. // 执行数据库查询
  361. query() {
  362. this.mixinDatacomEasyGet();
  363. },
  364. // 监听查询条件变更事件
  365. onMixinDatacomPropsChange() {
  366. if (this.collection) {
  367. this.debounceGet();
  368. }
  369. },
  370. initDefVal() {
  371. let defValue = this.multiple ? [] : ''
  372. if ((this.valueCom || this.valueCom === 0) && !this.isDisabled(this.valueCom)) {
  373. defValue = this.valueCom
  374. } else {
  375. let strogeValue
  376. if (this.collection) {
  377. strogeValue = this.getCache()
  378. }
  379. if (strogeValue || strogeValue === 0) {
  380. defValue = strogeValue
  381. } else {
  382. let defItem = this.multiple ? [] : ''
  383. if (this.defItem > 0 && this.defItem <= this.mixinDatacomResData.length) {
  384. defItem = this.multiple ? [this.mixinDatacomResData[this.defItem - 1].value] : this.mixinDatacomResData[this.defItem - 1].value
  385. }
  386. defValue = defItem
  387. }
  388. if (defValue || defValue === 0 || (this.multiple && Array.isArray(defValue) && defValue.length > 0)) {
  389. this.emit(defValue)
  390. }
  391. }
  392. if (this.multiple) {
  393. const selectedValues = Array.isArray(defValue) ? defValue : (defValue ? [defValue] : []);
  394. const selectedItems = this.mixinDatacomResData.filter(item => selectedValues.includes(item.value));
  395. this.current = selectedItems.map(item => this.formatItemName(item));
  396. } else {
  397. const def = this.mixinDatacomResData.find(item => item.value === defValue)
  398. this.current = def ? this.formatItemName(def) : ''
  399. }
  400. },
  401. /**
  402. * @param {[String, Number, Array]} value
  403. * 判断用户给的 value 是否同时为禁用状态
  404. */
  405. isDisabled(value) {
  406. if (Array.isArray(value)) {
  407. // 对于数组,如果任意一个值被禁用,则认为整体被禁用
  408. return value.some(val => {
  409. return this.mixinDatacomResData.some(item => item.value === val && item.disable);
  410. });
  411. } else {
  412. let isDisabled = false;
  413. this.mixinDatacomResData.forEach(item => {
  414. if (item.value === value) {
  415. isDisabled = item.disable
  416. }
  417. })
  418. return isDisabled;
  419. }
  420. },
  421. clearVal() {
  422. const emptyValue = this.multiple ? [] : '';
  423. this.emit(emptyValue)
  424. this.current = this.multiple ? [] : ''
  425. if (this.collection) {
  426. this.removeCache()
  427. }
  428. this.$emit('clear')
  429. },
  430. checkBoxChange(res) {
  431. let range = res.detail.value
  432. let currentValues = range && range.length > 0 ? range.map((item) => {
  433. const index = parseInt(item, 10);
  434. if (isNaN(index)) {
  435. console.error(`无效索引: ${item}`);
  436. }
  437. if (index < 0 || index >= this.mixinDatacomResData.length) {
  438. console.error(`索引越界: ${index}`);
  439. }
  440. return this.mixinDatacomResData[index].value;
  441. }) : []
  442. const selectedItems = this.mixinDatacomResData.filter(dataItem => currentValues.includes(dataItem.value));
  443. this.current = selectedItems.map(dataItem => this.formatItemName(dataItem));
  444. this.emit(currentValues);
  445. },
  446. change(item) {
  447. if (!item.disable) {
  448. if (this.multiple) {
  449. // 多选模式
  450. let currentValues = this.getCurrentValues();
  451. if (!Array.isArray(currentValues)) {
  452. currentValues = currentValues ? [currentValues] : [];
  453. }
  454. const itemValue = item.value;
  455. const index = currentValues.indexOf(itemValue);
  456. if (index > -1) {
  457. currentValues.splice(index, 1);
  458. } else {
  459. currentValues.push(itemValue);
  460. }
  461. const selectedItems = this.mixinDatacomResData.filter(dataItem => currentValues.includes(dataItem.value));
  462. this.current = selectedItems.map(dataItem => this.formatItemName(dataItem));
  463. this.emit(currentValues);
  464. } else {
  465. // 单选模式
  466. this.showSelector = false
  467. this.current = this.formatItemName(item)
  468. this.emit(item.value)
  469. }
  470. }
  471. },
  472. emit(val) {
  473. this.$emit('input', val)
  474. this.$emit('update:modelValue', val)
  475. this.$emit('change', val)
  476. if (this.collection) {
  477. this.setCache(val);
  478. }
  479. },
  480. toggleSelector() {
  481. if (this.disabled) {
  482. return
  483. }
  484. this.showSelector = !this.showSelector
  485. },
  486. formatItemName(item) {
  487. let {
  488. text,
  489. value,
  490. channel_code
  491. } = item
  492. channel_code = channel_code ? `(${channel_code})` : ''
  493. if (this.format) {
  494. // 格式化输出
  495. let str = "";
  496. str = this.format;
  497. for (let key in item) {
  498. str = str.replace(new RegExp(`{${key}}`, "g"), item[key]);
  499. }
  500. return str;
  501. } else {
  502. return this.collection.indexOf('app-list') > 0 ?
  503. `${text}(${value})` :
  504. (
  505. text ?
  506. text :
  507. `未命名${channel_code}`
  508. )
  509. }
  510. },
  511. // 获取当前加载的数据
  512. getLoadData() {
  513. return this.mixinDatacomResData;
  514. },
  515. // 获取当前缓存key
  516. getCurrentCacheKey() {
  517. return this.collection;
  518. },
  519. // 获取缓存
  520. getCache(name = this.getCurrentCacheKey()) {
  521. let cacheData = uni.getStorageSync(this.cacheKey) || {};
  522. return cacheData[name];
  523. },
  524. // 设置缓存
  525. setCache(value, name = this.getCurrentCacheKey()) {
  526. let cacheData = uni.getStorageSync(this.cacheKey) || {};
  527. cacheData[name] = value;
  528. uni.setStorageSync(this.cacheKey, cacheData);
  529. },
  530. // 删除缓存
  531. removeCache(name = this.getCurrentCacheKey()) {
  532. let cacheData = uni.getStorageSync(this.cacheKey) || {};
  533. delete cacheData[name];
  534. uni.setStorageSync(this.cacheKey, cacheData);
  535. },
  536. }
  537. }
  538. </script>
  539. <style lang="scss">
  540. $uni-base-color: #6a6a6a !default;
  541. $uni-main-color: #333 !default;
  542. $uni-secondary-color: #909399 !default;
  543. $uni-border-3: #e5e5e5;
  544. $uni-primary: #2979ff !default;
  545. $uni-success: #4cd964 !default;
  546. $uni-warning: #f0ad4e !default;
  547. $uni-error: #dd524d !default;
  548. $uni-info: #909399 !default;
  549. /* #ifndef APP-NVUE */
  550. @media screen and (max-width: 500px) {
  551. .hide-on-phone {
  552. display: none;
  553. }
  554. }
  555. /* #endif */
  556. .uni-stat__select {
  557. display: flex;
  558. align-items: center;
  559. // padding: 15px;
  560. /* #ifdef H5 */
  561. cursor: pointer;
  562. /* #endif */
  563. width: 100%;
  564. flex: 1;
  565. box-sizing: border-box;
  566. }
  567. .uni-stat-box {
  568. background-color: var(--color-white);
  569. width: 100%;
  570. flex: 1;
  571. }
  572. .uni-stat__actived {
  573. width: 100%;
  574. flex: 1;
  575. // outline: 1px solid #2979ff;
  576. }
  577. .uni-label-text {
  578. font-size: 14px;
  579. font-weight: bold;
  580. color: $uni-base-color;
  581. margin: auto 0;
  582. margin-right: 5px;
  583. }
  584. .border-bottom {
  585. border-bottom: solid 1px $uni-border-3;
  586. }
  587. .border-default {
  588. border: 1px solid $uni-border-3;
  589. }
  590. .uni-select {
  591. font-size: 14px;
  592. box-sizing: border-box;
  593. border-radius: 4px;
  594. padding: 0 5px;
  595. padding-left: 10px;
  596. position: relative;
  597. /* #ifndef APP-NVUE */
  598. display: flex;
  599. user-select: none;
  600. /* #endif */
  601. flex-direction: row;
  602. align-items: center;
  603. width: 100%;
  604. flex: 1;
  605. min-height: 35px;
  606. &--disabled {
  607. background-color: #f5f7fa;
  608. cursor: not-allowed;
  609. }
  610. &--wrap {
  611. height: auto;
  612. min-height: 35px;
  613. // align-items: flex-start;
  614. }
  615. }
  616. .uni-select__label {
  617. font-size: 16px;
  618. // line-height: 22px;
  619. height: 35px;
  620. padding-right: 10px;
  621. color: $uni-secondary-color;
  622. }
  623. .uni-select__input-box {
  624. // height: 35px;
  625. width: 0px;
  626. position: relative;
  627. /* #ifndef APP-NVUE */
  628. display: flex;
  629. /* #endif */
  630. flex: 1;
  631. flex-direction: row;
  632. align-items: center;
  633. &--wrap {
  634. .uni-select__input-text {
  635. margin-right: 8px;
  636. }
  637. }
  638. .padding-top-bottom {
  639. padding-top: 5px;
  640. padding-bottom: 5px;
  641. }
  642. .slot-content {
  643. width: 100%;
  644. display: flex;
  645. flex-direction: row;
  646. flex-wrap: wrap;
  647. }
  648. }
  649. .uni-select__input {
  650. flex: 1;
  651. font-size: 14px;
  652. height: 22px;
  653. line-height: 22px;
  654. }
  655. .uni-select__input-plac {
  656. font-size: 14px;
  657. color: $uni-secondary-color;
  658. }
  659. .uni-select__selector {
  660. /* #ifndef APP-NVUE */
  661. box-sizing: border-box;
  662. /* #endif */
  663. position: absolute;
  664. left: 0;
  665. width: 100%;
  666. background-color: var(--color-white);
  667. border: 1px solid #EBEEF5;
  668. border-radius: 6px;
  669. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  670. z-index: 1111;
  671. padding: 4px 0;
  672. }
  673. .uni-select__selector-scroll {
  674. /* #ifndef APP-NVUE */
  675. max-height: 200px;
  676. box-sizing: border-box;
  677. /* #endif */
  678. }
  679. /* #ifdef H5 */
  680. @media (min-width: 768px) {
  681. .uni-select__selector-scroll {
  682. max-height: 600px;
  683. }
  684. }
  685. /* #endif */
  686. .uni-select__selector-empty,
  687. .uni-select__selector-item {
  688. /* #ifndef APP-NVUE */
  689. display: flex;
  690. cursor: pointer;
  691. /* #endif */
  692. flex-direction: row;
  693. align-items: center;
  694. line-height: 35px;
  695. font-size: 14px;
  696. /* border-bottom: solid 1px $uni-border-3; */
  697. padding: 0px 10px;
  698. }
  699. .uni-select__selector-item--actived {
  700. background-color: #f5f7fa;
  701. }
  702. .uni-select__selector-item-check {
  703. margin-left: auto;
  704. }
  705. .uni-select__selector-empty:last-child,
  706. .uni-select__selector-item:last-child {
  707. /* #ifndef APP-NVUE */
  708. border-bottom: none;
  709. /* #endif */
  710. }
  711. .uni-select__selector__disabled {
  712. opacity: 0.4;
  713. cursor: default;
  714. }
  715. /* picker 弹出层通用的指示小三角 */
  716. .uni-popper__arrow_bottom,
  717. .uni-popper__arrow_bottom::after,
  718. .uni-popper__arrow_top,
  719. .uni-popper__arrow_top::after {
  720. position: absolute;
  721. display: block;
  722. width: 0;
  723. height: 0;
  724. border-color: transparent;
  725. border-style: solid;
  726. border-width: 6px;
  727. }
  728. .uni-popper__arrow_bottom {
  729. filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03));
  730. top: -6px;
  731. left: 10%;
  732. margin-right: 3px;
  733. border-top-width: 0;
  734. border-bottom-color: #EBEEF5;
  735. }
  736. .uni-popper__arrow_bottom::after {
  737. content: " ";
  738. top: 1px;
  739. margin-left: -6px;
  740. border-top-width: 0;
  741. border-bottom-color: #fff;
  742. }
  743. .uni-popper__arrow_top {
  744. filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03));
  745. bottom: -6px;
  746. left: 10%;
  747. margin-right: 3px;
  748. border-bottom-width: 0;
  749. border-top-color: #EBEEF5;
  750. }
  751. .uni-popper__arrow_top::after {
  752. content: " ";
  753. bottom: 1px;
  754. margin-left: -6px;
  755. border-bottom-width: 0;
  756. border-top-color: #fff;
  757. }
  758. .uni-select__input-text {
  759. // width: 280px;
  760. width: 100%;
  761. color: $uni-main-color;
  762. white-space: nowrap;
  763. text-overflow: ellipsis;
  764. -o-text-overflow: ellipsis;
  765. overflow: hidden;
  766. &--wrap {
  767. white-space: normal;
  768. text-overflow: initial;
  769. -o-text-overflow: initial;
  770. overflow: visible;
  771. word-wrap: break-word;
  772. word-break: break-all;
  773. // line-height: 1.5;
  774. }
  775. }
  776. .uni-select__input-placeholder {
  777. color: $uni-base-color;
  778. font-size: 12px;
  779. margin: 1px 0;
  780. }
  781. .uni-select--mask {
  782. position: fixed;
  783. top: 0;
  784. bottom: 0;
  785. right: 0;
  786. left: 0;
  787. z-index: 2;
  788. }
  789. .align-left {
  790. text-align: left;
  791. }
  792. .align-center {
  793. text-align: center;
  794. }
  795. .align-right {
  796. text-align: right;
  797. }
  798. </style>