uni-data-checkbox.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849
  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. }
  304. dataList.forEach((item, index) => {
  305. item.disabled = item.disable || item.disabled || false
  306. if (this.multiple) {
  307. if (value.length > 0) {
  308. let have = value.find(val => val === item[this.map.value])
  309. item.selected = have !== undefined
  310. } else {
  311. item.selected = false
  312. }
  313. } else {
  314. item.selected = value === item[this.map.value]
  315. }
  316. list.push(item)
  317. })
  318. return this.setRange(list)
  319. },
  320. /**
  321. * 处理最大最小值
  322. * @param {Object} list
  323. */
  324. setRange(list) {
  325. let selectList = list.filter(item => item.selected)
  326. let min = Number(this.min) || 0
  327. let max = Number(this.max) || ''
  328. list.forEach((item, index) => {
  329. if (this.multiple) {
  330. if (selectList.length <= min) {
  331. let have = selectList.find(val => val[this.map.value] === item[this.map.value])
  332. if (have !== undefined) {
  333. item.disabled = true
  334. }
  335. }
  336. if (selectList.length >= max && max !== '') {
  337. let have = selectList.find(val => val[this.map.value] === item[this.map.value])
  338. if (have === undefined) {
  339. item.disabled = true
  340. }
  341. }
  342. }
  343. this.setStyles(item, index)
  344. list[index] = item
  345. })
  346. return list
  347. },
  348. /**
  349. * 设置 class
  350. * @param {Object} item
  351. * @param {Object} index
  352. */
  353. setStyles(item, index) {
  354. // 设置自定义样式
  355. item.styleBackgroud = this.setStyleBackgroud(item)
  356. item.styleIcon = this.setStyleIcon(item)
  357. item.styleIconText = this.setStyleIconText(item)
  358. item.styleRightIcon = this.setStyleRightIcon(item)
  359. },
  360. /**
  361. * 获取选中值
  362. * @param {Object} range
  363. */
  364. getSelectedValue(range) {
  365. if (!this.multiple) return this.dataValue
  366. let selectedArr = []
  367. range.forEach((item) => {
  368. if (item.selected) {
  369. selectedArr.push(item[this.map.value])
  370. }
  371. })
  372. return this.dataValue.length > 0 ? this.dataValue : selectedArr
  373. },
  374. /**
  375. * 设置背景样式
  376. */
  377. setStyleBackgroud(item) {
  378. let styles = {}
  379. let selectedColor = this.selectedColor ? this.selectedColor : '#2979ff'
  380. if (this.selectedColor) {
  381. if (this.mode !== 'list') {
  382. styles['border-color'] = item.selected ? selectedColor : '#DCDFE6'
  383. }
  384. if (this.mode === 'tag') {
  385. styles['background-color'] = item.selected ? selectedColor : '#f5f5f5'
  386. }
  387. }
  388. let classles = ''
  389. for (let i in styles) {
  390. classles += `${i}:${styles[i]};`
  391. }
  392. return classles
  393. },
  394. setStyleIcon(item) {
  395. let styles = {}
  396. let classles = ''
  397. if (this.selectedColor) {
  398. let selectedColor = this.selectedColor ? this.selectedColor : '#2979ff'
  399. styles['background-color'] = item.selected ? selectedColor : '#fff'
  400. styles['border-color'] = item.selected ? selectedColor : '#DCDFE6'
  401. if (!item.selected && item.disabled) {
  402. styles['background-color'] = '#F2F6FC'
  403. styles['border-color'] = item.selected ? selectedColor : '#DCDFE6'
  404. }
  405. }
  406. for (let i in styles) {
  407. classles += `${i}:${styles[i]};`
  408. }
  409. return classles
  410. },
  411. setStyleIconText(item) {
  412. let styles = {}
  413. let classles = ''
  414. if (this.selectedColor) {
  415. let selectedColor = this.selectedColor ? this.selectedColor : '#2979ff'
  416. if (this.mode === 'tag') {
  417. styles.color = item.selected ? (this.selectedTextColor ? this.selectedTextColor : '#fff') : '#666'
  418. } else {
  419. styles.color = item.selected ? (this.selectedTextColor ? this.selectedTextColor : selectedColor) : '#666'
  420. }
  421. if (!item.selected && item.disabled) {
  422. styles.color = '#999'
  423. }
  424. }
  425. for (let i in styles) {
  426. classles += `${i}:${styles[i]};`
  427. }
  428. return classles
  429. },
  430. setStyleRightIcon(item) {
  431. let styles = {}
  432. let classles = ''
  433. if (this.mode === 'list') {
  434. styles['border-color'] = item.selected ? this.styles.selectedColor : '#DCDFE6'
  435. }
  436. for (let i in styles) {
  437. classles += `${i}:${styles[i]};`
  438. }
  439. return classles
  440. }
  441. }
  442. }
  443. </script>
  444. <style lang="scss">
  445. $uni-primary: #2979ff !default;
  446. $border-color: #DCDFE6;
  447. $disable: 0.4;
  448. @mixin flex {
  449. /* #ifndef APP-NVUE */
  450. display: flex;
  451. /* #endif */
  452. }
  453. .uni-data-loading {
  454. @include flex;
  455. flex-direction: row;
  456. justify-content: center;
  457. align-items: center;
  458. height: 36px;
  459. padding-left: 10px;
  460. color: #999;
  461. }
  462. .uni-data-checklist {
  463. position: relative;
  464. z-index: 0;
  465. flex: 1;
  466. // 多选样式
  467. .checklist-group {
  468. @include flex;
  469. flex-direction: row;
  470. flex-wrap: wrap;
  471. &.is-list {
  472. flex-direction: column;
  473. }
  474. .checklist-box {
  475. @include flex;
  476. flex-direction: row;
  477. align-items: center;
  478. position: relative;
  479. margin: 5px 0;
  480. margin-right: 25px;
  481. .hidden {
  482. position: absolute;
  483. opacity: 0;
  484. }
  485. // 文字样式
  486. .checklist-content {
  487. @include flex;
  488. flex: 1;
  489. flex-direction: row;
  490. align-items: center;
  491. justify-content: space-between;
  492. .checklist-text {
  493. font-size: 14px;
  494. color: #666;
  495. margin-left: 5px;
  496. line-height: 14px;
  497. }
  498. .checkobx__list {
  499. border-right-width: 1px;
  500. border-right-color: #007aff;
  501. border-right-style: solid;
  502. border-bottom-width: 1px;
  503. border-bottom-color: #007aff;
  504. border-bottom-style: solid;
  505. height: 12px;
  506. width: 6px;
  507. left: -5px;
  508. transform-origin: center;
  509. transform: rotate(45deg);
  510. opacity: 0;
  511. }
  512. }
  513. // 多选样式
  514. .checkbox__inner {
  515. /* #ifndef APP-NVUE */
  516. flex-shrink: 0;
  517. box-sizing: border-box;
  518. /* #endif */
  519. position: relative;
  520. width: 16px;
  521. height: 16px;
  522. border: 1px solid $border-color;
  523. border-radius: 4px;
  524. background-color: #fff;
  525. z-index: 1;
  526. .checkbox__inner-icon {
  527. position: absolute;
  528. /* #ifdef APP-NVUE */
  529. top: 2px;
  530. /* #endif */
  531. /* #ifndef APP-NVUE */
  532. top: 1px;
  533. /* #endif */
  534. left: 5px;
  535. height: 8px;
  536. width: 4px;
  537. border-right-width: 1px;
  538. border-right-color: #fff;
  539. border-right-style: solid;
  540. border-bottom-width: 1px;
  541. border-bottom-color: #fff;
  542. border-bottom-style: solid;
  543. opacity: 0;
  544. transform-origin: center;
  545. transform: rotate(40deg);
  546. }
  547. }
  548. // 单选样式
  549. .radio__inner {
  550. @include flex;
  551. /* #ifndef APP-NVUE */
  552. flex-shrink: 0;
  553. box-sizing: border-box;
  554. /* #endif */
  555. justify-content: center;
  556. align-items: center;
  557. position: relative;
  558. width: 16px;
  559. height: 16px;
  560. border: 1px solid $border-color;
  561. border-radius: 16px;
  562. background-color: #fff;
  563. z-index: 1;
  564. .radio__inner-icon {
  565. width: 8px;
  566. height: 8px;
  567. border-radius: 10px;
  568. opacity: 0;
  569. }
  570. }
  571. // 默认样式
  572. &.is--default {
  573. // 禁用
  574. &.is-disable {
  575. /* #ifdef H5 */
  576. cursor: not-allowed;
  577. /* #endif */
  578. .checkbox__inner {
  579. background-color: #F2F6FC;
  580. border-color: $border-color;
  581. /* #ifdef H5 */
  582. cursor: not-allowed;
  583. /* #endif */
  584. }
  585. .radio__inner {
  586. background-color: #F2F6FC;
  587. border-color: $border-color;
  588. }
  589. .checklist-text {
  590. color: #999;
  591. }
  592. }
  593. // 选中
  594. &.is-checked {
  595. .checkbox__inner {
  596. border-color: $uni-primary;
  597. background-color: $uni-primary;
  598. .checkbox__inner-icon {
  599. opacity: 1;
  600. transform: rotate(45deg);
  601. }
  602. }
  603. .radio__inner {
  604. border-color: $uni-primary;
  605. .radio__inner-icon {
  606. opacity: 1;
  607. background-color: $uni-primary;
  608. }
  609. }
  610. .checklist-text {
  611. color: $uni-primary;
  612. }
  613. // 选中禁用
  614. &.is-disable {
  615. .checkbox__inner {
  616. opacity: $disable;
  617. }
  618. .checklist-text {
  619. opacity: $disable;
  620. }
  621. .radio__inner {
  622. opacity: $disable;
  623. }
  624. }
  625. }
  626. }
  627. // 按钮样式
  628. &.is--button {
  629. margin-right: 10px;
  630. padding: 5px 10px;
  631. border: 1px $border-color solid;
  632. border-radius: 3px;
  633. transition: border-color 0.2s;
  634. // 禁用
  635. &.is-disable {
  636. /* #ifdef H5 */
  637. cursor: not-allowed;
  638. /* #endif */
  639. border: 1px #eee solid;
  640. opacity: $disable;
  641. .checkbox__inner {
  642. background-color: #F2F6FC;
  643. border-color: $border-color;
  644. /* #ifdef H5 */
  645. cursor: not-allowed;
  646. /* #endif */
  647. }
  648. .radio__inner {
  649. background-color: #F2F6FC;
  650. border-color: $border-color;
  651. /* #ifdef H5 */
  652. cursor: not-allowed;
  653. /* #endif */
  654. }
  655. .checklist-text {
  656. color: #999;
  657. }
  658. }
  659. &.is-checked {
  660. border-color: $uni-primary;
  661. .checkbox__inner {
  662. border-color: $uni-primary;
  663. background-color: $uni-primary;
  664. .checkbox__inner-icon {
  665. opacity: 1;
  666. transform: rotate(45deg);
  667. }
  668. }
  669. .radio__inner {
  670. border-color: $uni-primary;
  671. .radio__inner-icon {
  672. opacity: 1;
  673. background-color: $uni-primary;
  674. }
  675. }
  676. .checklist-text {
  677. color: $uni-primary;
  678. }
  679. // 选中禁用
  680. &.is-disable {
  681. opacity: $disable;
  682. }
  683. }
  684. }
  685. // 标签样式
  686. &.is--tag {
  687. margin-right: 10px;
  688. padding: 5px 10px;
  689. border: 1px $border-color solid;
  690. border-radius: 3px;
  691. background-color: #f5f5f5;
  692. .checklist-text {
  693. margin: 0;
  694. color: #666;
  695. }
  696. // 禁用
  697. &.is-disable {
  698. /* #ifdef H5 */
  699. cursor: not-allowed;
  700. /* #endif */
  701. opacity: $disable;
  702. }
  703. &.is-checked {
  704. background-color: $uni-primary;
  705. border-color: $uni-primary;
  706. .checklist-text {
  707. color: #fff;
  708. }
  709. }
  710. }
  711. // 列表样式
  712. &.is--list {
  713. /* #ifndef APP-NVUE */
  714. display: flex;
  715. /* #endif */
  716. padding: 10px 15px;
  717. padding-left: 0;
  718. margin: 0;
  719. &.is-list-border {
  720. border-top: 1px #eee solid;
  721. }
  722. // 禁用
  723. &.is-disable {
  724. /* #ifdef H5 */
  725. cursor: not-allowed;
  726. /* #endif */
  727. .checkbox__inner {
  728. background-color: #F2F6FC;
  729. border-color: $border-color;
  730. /* #ifdef H5 */
  731. cursor: not-allowed;
  732. /* #endif */
  733. }
  734. .checklist-text {
  735. color: #999;
  736. }
  737. }
  738. &.is-checked {
  739. .checkbox__inner {
  740. border-color: $uni-primary;
  741. background-color: $uni-primary;
  742. .checkbox__inner-icon {
  743. opacity: 1;
  744. transform: rotate(45deg);
  745. }
  746. }
  747. .radio__inner {
  748. border-color: $uni-primary;
  749. .radio__inner-icon {
  750. opacity: 1;
  751. background-color: $uni-primary;
  752. }
  753. }
  754. .checklist-text {
  755. color: $uni-primary;
  756. }
  757. .checklist-content {
  758. .checkobx__list {
  759. opacity: 1;
  760. border-color: $uni-primary;
  761. }
  762. }
  763. // 选中禁用
  764. &.is-disable {
  765. .checkbox__inner {
  766. opacity: $disable;
  767. }
  768. .checklist-text {
  769. opacity: $disable;
  770. }
  771. }
  772. }
  773. }
  774. }
  775. }
  776. }
  777. </style>