uni-data-checkbox.vue 20 KB

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