uni-data-checkbox.vue 20 KB

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