uni-data-select.vue 22 KB

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