su-data-checkbox.vue 24 KB

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