CheckIcon.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. const template=`
  2. <component is="style">
  3. .chooseIcon .el-drawer__header{
  4. margin-bottom:0;
  5. }
  6. .chooseIcon .el-drawer__body{
  7. display:flex;
  8. flex-wrap: wrap;
  9. }
  10. .chooseIcon .li{
  11. width:41px;
  12. height:42px;
  13. line-height:42px;
  14. border:1px solid #efefef;
  15. padding:1px;
  16. margin:1px;
  17. text-align: center;
  18. font-size:18px;
  19. }
  20. .chooseIcon .li:hover{
  21. border:1px solid #2c3e50;
  22. cursor:pointer;
  23. }
  24. </component>
  25. <el-drawer
  26. v-model="show"
  27. class="chooseIcon"
  28. size="100%"
  29. :show-close="true"
  30. direction="rtl">
  31. <template #title>
  32. <el-input v-model="search" style="width: 100%">
  33. <template #prepend>搜索图标</template>
  34. </el-input>
  35. </template>
  36. <template v-for="i in iconlist">
  37. <div v-if="(search && i.indexOf(search)!=-1) || !search" class="li" @click="clickIcon('fa fa-'+i)">
  38. <i :class="'fa fa-'+i"></i>
  39. </div>
  40. </template>
  41. </el-drawer>
  42. `;
  43. export default {
  44. name: "CheckIcon",
  45. data: function () {
  46. return {
  47. show:false,
  48. iconlist:[],
  49. searchlist:[],
  50. search:''
  51. }
  52. },
  53. emits:['selected'],
  54. mounted:function (){
  55. let url=location.origin+'/assets/libs/font-awesome/less/variables.less'
  56. Yunqi.ajax.get(url,'',false,false,true).then(ret=>{
  57. var exp = /fa-var-(.*):/ig;
  58. var result;
  59. let iconlist=[];
  60. while ((result = exp.exec(ret)) != null) {
  61. iconlist.push(result[1]);
  62. }
  63. this.iconlist=iconlist;
  64. });
  65. },
  66. template:template,
  67. methods:{
  68. clickIcon:function (i){
  69. this.$emit('selected',i);
  70. this.show=false;
  71. },
  72. open:function (){
  73. this.show=true;
  74. }
  75. }
  76. };