uni-data-checkbox.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857
  1. <template>
  2. <view class="uni-data-checklist" :style="{ 'margin-top': isTop + 'px' }">
  3. <template v-if="!isLocal">
  4. <view class="uni-data-loading">
  5. <uni-load-more v-if="!mixinDatacomErrorMessage" status="loading" iconType="snow" :iconSize="18"
  6. :content-text="contentText"></uni-load-more>
  7. <text v-else>{{ mixinDatacomErrorMessage }}</text>
  8. </view>
  9. </template>
  10. <template v-else>
  11. <checkbox-group v-if="multiple" class="checklist-group" :class="{ 'is-list': mode === 'list' || wrap }"
  12. @change="change">
  13. <label class="checklist-box"
  14. :class="['is--' + mode, item.selected ? 'is-checked' : '', (disabled || !!item.disabled) ? 'is-disable' : '', index !== 0 && mode === 'list' ? 'is-list-border' : '']"
  15. :style="item.styleBackgroud" v-for="(item, index) in dataList" :key="index">
  16. <checkbox class="hidden" hidden :disabled="disabled || !!item.disabled"
  17. :value="item[map.value] + ''" :checked="item.selected" />
  18. <view v-if="(mode !== 'tag' && mode !== 'list') || (mode === 'list' && icon === 'left')"
  19. class="checkbox__inner" :style="item.styleIcon">
  20. <view class="checkbox__inner-icon"></view>
  21. </view>
  22. <view class="checklist-content" :class="{ 'list-content': mode === 'list' && icon === 'left' }">
  23. <text class="checklist-text" :style="item.styleIconText">{{ item[map.text] }}</text>
  24. <view v-if="mode === 'list' && icon === 'right'" class="checkobx__list"
  25. :style="item.styleBackgroud"></view>
  26. </view>
  27. </label>
  28. </checkbox-group>
  29. <radio-group v-else class="checklist-group" :class="{ 'is-list': mode === 'list', 'is-wrap': wrap }"
  30. @change="change">
  31. <label class="checklist-box"
  32. :class="['is--' + mode, item.selected ? 'is-checked' : '', (disabled || !!item.disabled) ? 'is-disable' : '', index !== 0 && mode === 'list' ? 'is-list-border' : '']"
  33. :style="item.styleBackgroud" v-for="(item, index) in dataList" :key="index">
  34. <radio class="hidden" hidden :disabled="disabled || item.disabled" :value="item[map.value] + ''"
  35. :checked="item.selected" />
  36. <view v-if="(mode !== 'tag' && mode !== 'list') || (mode === 'list' && icon === 'left')"
  37. class="radio__inner" :style="item.styleBackgroud">
  38. <view class="radio__inner-icon" :style="item.styleIcon"></view>
  39. </view>
  40. <view class="checklist-content" :class="{ 'list-content': mode === 'list' && icon === 'left' }">
  41. <text class="checklist-text" :style="item.styleIconText">{{ item[map.text] }}</text>
  42. <view v-if="mode === 'list' && icon === 'right'" :style="item.styleRightIcon"
  43. class="checkobx__list"></view>
  44. </view>
  45. </label>
  46. </radio-group>
  47. </template>
  48. </view>
  49. </template>
  50. <script>
  51. /**
  52. * DataChecklist 数据选择器
  53. * @description 通过数据渲染 checkbox 和 radio
  54. * @tutorial https://ext.dcloud.net.cn/plugin?id=xxx
  55. * @property {String} mode = [default| list | button | tag] 显示模式
  56. * @value default 默认横排模式
  57. * @value list 列表模式
  58. * @value button 按钮模式
  59. * @value tag 标签模式
  60. * @property {Boolean} multiple = [true|false] 是否多选
  61. * @property {Array|String|Number} value 默认值
  62. * @property {Array} localdata 本地数据 ,格式 [{text:'',value:''}]
  63. * @property {Number|String} min 最小选择个数 ,multiple为true时生效
  64. * @property {Number|String} max 最大选择个数 ,multiple为true时生效
  65. * @property {Boolean} wrap 是否换行显示
  66. * @property {String} icon = [left|right] list 列表模式下icon显示位置
  67. * @property {Boolean} selectedColor 选中颜色
  68. * @property {Boolean} emptyText 没有数据时显示的文字 ,本地数据无效
  69. * @property {Boolean} selectedTextColor 选中文本颜色,如不填写则自动显示
  70. * @property {Object} map 字段映射, 默认 map={text:'text',value:'value'}
  71. * @value left 左侧显示
  72. * @value right 右侧显示
  73. * @event {Function} change 选中发生变化触发
  74. */
  75. export default {
  76. name: 'uniDataChecklist',
  77. mixins: [uniCloud.mixinDatacom || {}],
  78. emits: ['input', 'update:modelValue', 'change'],
  79. props: {
  80. mode: {
  81. type: String,
  82. default: 'default'
  83. },
  84. multiple: {
  85. type: Boolean,
  86. default: false
  87. },
  88. value: {
  89. type: [Array, String, Number],
  90. default() {
  91. return ''
  92. }
  93. },
  94. // TODO vue3
  95. modelValue: {
  96. type: [Array, String, Number],
  97. default() {
  98. return '';
  99. }
  100. },
  101. localdata: {
  102. type: Array,
  103. default() {
  104. return []
  105. }
  106. },
  107. min: {
  108. type: [Number, String],
  109. default: ''
  110. },
  111. max: {
  112. type: [Number, String],
  113. default: ''
  114. },
  115. wrap: {
  116. type: Boolean,
  117. default: false
  118. },
  119. icon: {
  120. type: String,
  121. default: 'left'
  122. },
  123. selectedColor: {
  124. type: String,
  125. default: ''
  126. },
  127. selectedTextColor: {
  128. type: String,
  129. default: ''
  130. },
  131. emptyText: {
  132. type: String,
  133. default: '暂无数据'
  134. },
  135. disabled: {
  136. type: Boolean,
  137. default: false
  138. },
  139. map: {
  140. type: Object,
  141. default() {
  142. return {
  143. text: 'text',
  144. value: 'value'
  145. }
  146. }
  147. }
  148. },
  149. watch: {
  150. localdata: {
  151. handler(newVal) {
  152. this.range = newVal
  153. this.dataList = this.getDataList(this.getSelectedValue(newVal))
  154. },
  155. deep: true
  156. },
  157. mixinDatacomResData(newVal) {
  158. this.range = newVal
  159. this.dataList = this.getDataList(this.getSelectedValue(newVal))
  160. },
  161. value(newVal) {
  162. this.dataList = this.getDataList(newVal)
  163. // fix by mehaotian is_reset 在 uni-forms 中定义
  164. // if(!this.is_reset){
  165. // this.is_reset = false
  166. // this.formItem && this.formItem.setValue(newVal)
  167. // }
  168. },
  169. modelValue(newVal) {
  170. this.dataList = this.getDataList(newVal);
  171. // if(!this.is_reset){
  172. // this.is_reset = false
  173. // this.formItem && this.formItem.setValue(newVal)
  174. // }
  175. }
  176. },
  177. data() {
  178. return {
  179. dataList: [],
  180. range: [],
  181. contentText: {
  182. contentdown: '查看更多',
  183. contentrefresh: '加载中',
  184. contentnomore: '没有更多'
  185. },
  186. isLocal: true,
  187. styles: {
  188. selectedColor: '#2979ff',
  189. selectedTextColor: '#666',
  190. },
  191. isTop: 0
  192. };
  193. },
  194. computed: {
  195. dataValue() {
  196. if (this.value === '') return this.modelValue
  197. if (this.modelValue === '') return this.value
  198. return this.value
  199. }
  200. },
  201. created() {
  202. // this.form = this.getForm('uniForms')
  203. // this.formItem = this.getForm('uniFormsItem')
  204. // this.formItem && this.formItem.setValue(this.value)
  205. // if (this.formItem) {
  206. // this.isTop = 6
  207. // if (this.formItem.name) {
  208. // // 如果存在name添加默认值,否则formData 中不存在这个字段不校验
  209. // if(!this.is_reset){
  210. // this.is_reset = false
  211. // this.formItem.setValue(this.dataValue)
  212. // }
  213. // this.rename = this.formItem.name
  214. // this.form.inputChildrens.push(this)
  215. // }
  216. // }
  217. if (this.localdata && this.localdata.length !== 0) {
  218. this.isLocal = true
  219. this.range = this.localdata
  220. this.dataList = this.getDataList(this.getSelectedValue(this.range))
  221. } else {
  222. if (this.collection) {
  223. this.isLocal = false
  224. this.loadData()
  225. }
  226. }
  227. },
  228. methods: {
  229. loadData() {
  230. this.mixinDatacomGet().then(res => {
  231. this.mixinDatacomResData = res.result.data
  232. if (this.mixinDatacomResData.length === 0) {
  233. this.isLocal = false
  234. this.mixinDatacomErrorMessage = this.emptyText
  235. } else {
  236. this.isLocal = true
  237. }
  238. }).catch(err => {
  239. this.mixinDatacomErrorMessage = err.message
  240. })
  241. },
  242. /**
  243. * 获取父元素实例
  244. */
  245. getForm(name = 'uniForms') {
  246. let parent = this.$parent;
  247. let parentName = parent.$options.name;
  248. while (parentName !== name) {
  249. parent = parent.$parent;
  250. if (!parent) return false
  251. parentName = parent.$options.name;
  252. }
  253. return parent;
  254. },
  255. change(e) {
  256. const values = e.detail.value
  257. let detail = {
  258. value: [],
  259. data: []
  260. }
  261. if (this.multiple) {
  262. this.range.forEach(item => {
  263. if (values.includes(item[this.map.value] + '')) {
  264. detail.value.push(item[this.map.value])
  265. detail.data.push(item)
  266. }
  267. })
  268. } else {
  269. const range = this.range.find(item => (item[this.map.value] + '') === values)
  270. if (range) {
  271. detail = {
  272. value: range[this.map.value],
  273. data: range
  274. }
  275. }
  276. }
  277. // this.formItem && this.formItem.setValue(detail.value)
  278. // TODO 兼容 vue2
  279. this.$emit('input', detail.value);
  280. // // TOTO 兼容 vue3
  281. this.$emit('update:modelValue', detail.value);
  282. this.$emit('change', {
  283. detail
  284. })
  285. if (this.multiple) {
  286. // 如果 v-model 没有绑定 ,则走内部逻辑
  287. // if (this.value.length === 0) {
  288. this.dataList = this.getDataList(detail.value, true)
  289. // }
  290. } else {
  291. this.dataList = this.getDataList(detail.value)
  292. }
  293. },
  294. /**
  295. * 获取渲染的新数组
  296. * @param {Object} value 选中内容
  297. */
  298. getDataList(value) {
  299. // 解除引用关系,破坏原引用关系,避免污染源数据
  300. let dataList = JSON.parse(JSON.stringify(this.range))
  301. let list = []
  302. if (this.multiple) {
  303. if (!Array.isArray(value)) {
  304. value = []
  305. }
  306. } else {
  307. if (Array.isArray(value) && value.length) {
  308. value = value[0]
  309. }
  310. }
  311. dataList.forEach((item, index) => {
  312. item.disabled = item.disable || item.disabled || false
  313. if (this.multiple) {
  314. if (value.length > 0) {
  315. let have = value.find(val => val === item[this.map.value])
  316. item.selected = have !== undefined
  317. } else {
  318. item.selected = false
  319. }
  320. } else {
  321. item.selected = value === item[this.map.value]
  322. }
  323. list.push(item)
  324. })
  325. return this.setRange(list)
  326. },
  327. /**
  328. * 处理最大最小值
  329. * @param {Object} list
  330. */
  331. setRange(list) {
  332. let selectList = list.filter(item => item.selected)
  333. let min = Number(this.min) || 0
  334. let max = Number(this.max) || ''
  335. list.forEach((item, index) => {
  336. if (this.multiple) {
  337. if (selectList.length <= min) {
  338. let have = selectList.find(val => val[this.map.value] === item[this.map.value])
  339. if (have !== undefined) {
  340. item.disabled = true
  341. }
  342. }
  343. if (selectList.length >= max && max !== '') {
  344. let have = selectList.find(val => val[this.map.value] === item[this.map.value])
  345. if (have === undefined) {
  346. item.disabled = true
  347. }
  348. }
  349. }
  350. this.setStyles(item, index)
  351. list[index] = item
  352. })
  353. return list
  354. },
  355. /**
  356. * 设置 class
  357. * @param {Object} item
  358. * @param {Object} index
  359. */
  360. setStyles(item, index) {
  361. // 设置自定义样式
  362. item.styleBackgroud = this.setStyleBackgroud(item)
  363. item.styleIcon = this.setStyleIcon(item)
  364. item.styleIconText = this.setStyleIconText(item)
  365. item.styleRightIcon = this.setStyleRightIcon(item)
  366. },
  367. /**
  368. * 获取选中值
  369. * @param {Object} range
  370. */
  371. getSelectedValue(range) {
  372. if (!this.multiple) return this.dataValue
  373. let selectedArr = []
  374. range.forEach((item) => {
  375. if (item.selected) {
  376. selectedArr.push(item[this.map.value])
  377. }
  378. })
  379. return this.dataValue.length > 0 ? this.dataValue : selectedArr
  380. },
  381. /**
  382. * 设置背景样式
  383. */
  384. setStyleBackgroud(item) {
  385. let styles = {}
  386. let selectedColor = this.selectedColor ? this.selectedColor : '#2979ff'
  387. if (this.selectedColor) {
  388. if (this.mode !== 'list') {
  389. styles['border-color'] = item.selected ? selectedColor : '#DCDFE6'
  390. }
  391. if (this.mode === 'tag') {
  392. styles['background-color'] = item.selected ? selectedColor : '#f5f5f5'
  393. }
  394. }
  395. let classles = ''
  396. for (let i in styles) {
  397. classles += `${i}:${styles[i]};`
  398. }
  399. return classles
  400. },
  401. setStyleIcon(item) {
  402. let styles = {}
  403. let classles = ''
  404. if (this.selectedColor) {
  405. let selectedColor = this.selectedColor ? this.selectedColor : '#2979ff'
  406. styles['background-color'] = item.selected ? selectedColor : '#fff'
  407. styles['border-color'] = item.selected ? selectedColor : '#DCDFE6'
  408. if (!item.selected && item.disabled) {
  409. styles['background-color'] = '#F2F6FC'
  410. styles['border-color'] = item.selected ? selectedColor : '#DCDFE6'
  411. }
  412. }
  413. for (let i in styles) {
  414. classles += `${i}:${styles[i]};`
  415. }
  416. return classles
  417. },
  418. setStyleIconText(item) {
  419. let styles = {}
  420. let classles = ''
  421. if (this.selectedColor) {
  422. let selectedColor = this.selectedColor ? this.selectedColor : '#2979ff'
  423. if (this.mode === 'tag') {
  424. styles.color = item.selected ? (this.selectedTextColor ? this.selectedTextColor : '#fff') : '#666'
  425. } else {
  426. styles.color = item.selected ? (this.selectedTextColor ? this.selectedTextColor : selectedColor) : '#666'
  427. }
  428. if (!item.selected && item.disabled) {
  429. styles.color = '#999'
  430. }
  431. }
  432. for (let i in styles) {
  433. classles += `${i}:${styles[i]};`
  434. }
  435. return classles
  436. },
  437. setStyleRightIcon(item) {
  438. let styles = {}
  439. let classles = ''
  440. if (this.mode === 'list') {
  441. styles['border-color'] = item.selected ? this.styles.selectedColor : '#DCDFE6'
  442. }
  443. for (let i in styles) {
  444. classles += `${i}:${styles[i]};`
  445. }
  446. return classles
  447. }
  448. }
  449. }
  450. </script>
  451. <style lang="scss">
  452. $uni-primary: #2979ff !default;
  453. $border-color: #DCDFE6;
  454. $disable: 0.4;
  455. @mixin flex {
  456. /* #ifndef APP-NVUE */
  457. display: flex;
  458. /* #endif */
  459. }
  460. .uni-data-loading {
  461. @include flex;
  462. flex-direction: row;
  463. justify-content: center;
  464. align-items: center;
  465. height: 36px;
  466. padding-left: 10px;
  467. color: var(--bs-heading-color);
  468. }
  469. .uni-data-checklist {
  470. position: relative;
  471. z-index: 0;
  472. flex: 1;
  473. // 多选样式
  474. .checklist-group {
  475. @include flex;
  476. flex-direction: row;
  477. flex-wrap: wrap;
  478. &.is-list {
  479. flex-direction: column;
  480. }
  481. .checklist-box {
  482. @include flex;
  483. flex-direction: row;
  484. align-items: center;
  485. position: relative;
  486. margin: 5px 0;
  487. margin-right: 25px;
  488. .hidden {
  489. position: absolute;
  490. opacity: 0;
  491. }
  492. // 文字样式
  493. .checklist-content {
  494. @include flex;
  495. flex: 1;
  496. flex-direction: row;
  497. align-items: center;
  498. justify-content: space-between;
  499. .checklist-text {
  500. font-size: 1rem;
  501. color: var(--bs-emphasis-color);
  502. margin-left: 5px;
  503. line-height: 14px;
  504. }
  505. .checkobx__list {
  506. border-right-width: 1px;
  507. border-right-color: #007aff;
  508. border-right-style: solid;
  509. border-bottom-width: 1px;
  510. border-bottom-color: #007aff;
  511. border-bottom-style: solid;
  512. height: 12px;
  513. width: 6px;
  514. left: -5px;
  515. transform-origin: center;
  516. transform: rotate(45deg);
  517. opacity: 0;
  518. }
  519. }
  520. // 多选样式
  521. .checkbox__inner {
  522. /* #ifndef APP-NVUE */
  523. flex-shrink: 0;
  524. box-sizing: border-box;
  525. /* #endif */
  526. position: relative;
  527. width: 1.4rem;
  528. height: 1.4rem;
  529. border: 1px solid $border-color;
  530. border-radius: 4px;
  531. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  532. z-index: 1;
  533. .checkbox__inner-icon {
  534. position: absolute;
  535. /* #ifdef APP-NVUE */
  536. top: 2px;
  537. /* #endif */
  538. /* #ifndef APP-NVUE */
  539. top: 1px;
  540. /* #endif */
  541. left: 0.4rem;
  542. height: 0.75rem;
  543. width: 0.5rem;
  544. border-right-width: 2px;
  545. border-right-color: #fff;
  546. border-right-style: solid;
  547. border-bottom-width: 2px;
  548. border-bottom-color: #fff;
  549. border-bottom-style: solid;
  550. opacity: 0;
  551. transform-origin: center;
  552. transform: rotate(40deg);
  553. }
  554. }
  555. // 单选样式
  556. .radio__inner {
  557. @include flex;
  558. /* #ifndef APP-NVUE */
  559. flex-shrink: 0;
  560. box-sizing: border-box;
  561. /* #endif */
  562. justify-content: center;
  563. align-items: center;
  564. position: relative;
  565. width: 16px;
  566. height: 16px;
  567. border: 1px solid $border-color;
  568. border-radius: 16px;
  569. background-color: var(--color-white);
  570. z-index: 1;
  571. .radio__inner-icon {
  572. width: 8px;
  573. height: 8px;
  574. border-radius: 10px;
  575. opacity: 0;
  576. }
  577. }
  578. // 默认样式
  579. &.is--default {
  580. // 禁用
  581. &.is-disable {
  582. /* #ifdef H5 */
  583. cursor: not-allowed;
  584. /* #endif */
  585. .checkbox__inner {
  586. background-color: #F2F6FC;
  587. border-color: $border-color;
  588. /* #ifdef H5 */
  589. cursor: not-allowed;
  590. /* #endif */
  591. }
  592. .radio__inner {
  593. background-color: #F2F6FC;
  594. border-color: $border-color;
  595. }
  596. .checklist-text {
  597. color: var(--bs-heading-color);
  598. }
  599. }
  600. // 选中
  601. &.is-checked {
  602. .checkbox__inner {
  603. border-color: $uni-primary;
  604. background-color: $uni-primary;
  605. .checkbox__inner-icon {
  606. opacity: 1;
  607. transform: rotate(45deg);
  608. }
  609. }
  610. .radio__inner {
  611. border-color: $uni-primary;
  612. .radio__inner-icon {
  613. opacity: 1;
  614. background-color: $uni-primary;
  615. }
  616. }
  617. .checklist-text {
  618. color: var(--bs-emphasis-color);
  619. }
  620. // 选中禁用
  621. &.is-disable {
  622. .checkbox__inner {
  623. opacity: $disable;
  624. }
  625. .checklist-text {
  626. opacity: $disable;
  627. }
  628. .radio__inner {
  629. opacity: $disable;
  630. }
  631. }
  632. }
  633. }
  634. // 按钮样式
  635. &.is--button {
  636. margin-right: 10px;
  637. padding: 5px 10px;
  638. border: 1px $border-color solid;
  639. border-radius: 3px;
  640. transition: border-color 0.2s;
  641. // 禁用
  642. &.is-disable {
  643. /* #ifdef H5 */
  644. cursor: not-allowed;
  645. /* #endif */
  646. border: 1px #eee solid;
  647. opacity: $disable;
  648. .checkbox__inner {
  649. background-color: #F2F6FC;
  650. border-color: $border-color;
  651. /* #ifdef H5 */
  652. cursor: not-allowed;
  653. /* #endif */
  654. }
  655. .radio__inner {
  656. background-color: #F2F6FC;
  657. border-color: $border-color;
  658. /* #ifdef H5 */
  659. cursor: not-allowed;
  660. /* #endif */
  661. }
  662. .checklist-text {
  663. color: var(--bs-heading-color);
  664. }
  665. }
  666. &.is-checked {
  667. border-color: $uni-primary;
  668. .checkbox__inner {
  669. border-color: $uni-primary;
  670. background-color: $uni-primary;
  671. .checkbox__inner-icon {
  672. opacity: 1;
  673. transform: rotate(45deg);
  674. }
  675. }
  676. .radio__inner {
  677. border-color: $uni-primary;
  678. .radio__inner-icon {
  679. opacity: 1;
  680. background-color: $uni-primary;
  681. }
  682. }
  683. .checklist-text {
  684. color: $uni-primary;
  685. }
  686. // 选中禁用
  687. &.is-disable {
  688. opacity: $disable;
  689. }
  690. }
  691. }
  692. // 标签样式
  693. &.is--tag {
  694. margin-right: 10px;
  695. padding: 5px 10px;
  696. border: 1px $border-color solid;
  697. border-radius: 3px;
  698. background-color: #f5f5f5;
  699. .checklist-text {
  700. margin: 0;
  701. color: var(--bs-heading-color);
  702. }
  703. // 禁用
  704. &.is-disable {
  705. /* #ifdef H5 */
  706. cursor: not-allowed;
  707. /* #endif */
  708. opacity: $disable;
  709. }
  710. &.is-checked {
  711. background-color: $uni-primary;
  712. border-color: $uni-primary;
  713. .checklist-text {
  714. color: #fff;
  715. }
  716. }
  717. }
  718. // 列表样式
  719. &.is--list {
  720. /* #ifndef APP-NVUE */
  721. display: flex;
  722. /* #endif */
  723. padding: 10px 15px;
  724. padding-left: 0;
  725. margin: 0;
  726. &.is-list-border {
  727. border-top: 1px #eee solid;
  728. }
  729. // 禁用
  730. &.is-disable {
  731. /* #ifdef H5 */
  732. cursor: not-allowed;
  733. /* #endif */
  734. .checkbox__inner {
  735. background-color: #F2F6FC;
  736. border-color: $border-color;
  737. /* #ifdef H5 */
  738. cursor: not-allowed;
  739. /* #endif */
  740. }
  741. .checklist-text {
  742. color: var(--bs-heading-color);
  743. }
  744. }
  745. &.is-checked {
  746. .checkbox__inner {
  747. border-color: $uni-primary;
  748. background-color: $uni-primary;
  749. .checkbox__inner-icon {
  750. opacity: 1;
  751. transform: rotate(45deg);
  752. }
  753. }
  754. .radio__inner {
  755. border-color: $uni-primary;
  756. .radio__inner-icon {
  757. opacity: 1;
  758. background-color: $uni-primary;
  759. }
  760. }
  761. .checklist-text {
  762. color: $uni-primary;
  763. }
  764. .checklist-content {
  765. .checkobx__list {
  766. opacity: 1;
  767. border-color: $uni-primary;
  768. }
  769. }
  770. // 选中禁用
  771. &.is-disable {
  772. .checkbox__inner {
  773. opacity: $disable;
  774. }
  775. .checklist-text {
  776. opacity: $disable;
  777. }
  778. }
  779. }
  780. }
  781. }
  782. }
  783. }
  784. </style>