excel.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <div class="excelData" :style="{ height: height, overflow: 'auto' }">
  3. <el-empty v-if="!data.length" :image="nodata" image-size="100" description="暂无数据,敬请期待" />
  4. <el-checkbox-group size="small" v-model="excelCheckIds" v-if="showCheckbox" @change="funCheckChange">
  5. <el-checkbox size="small" class="excelDatahaveCheck" :class="theme ? 'excelW' : 'excelB'" :label="item.id"
  6. v-for="item in data" :key="item.name"
  7. :style="!theme && showCC ? 'background: rgba(0,70,199,0.35)' : ''">
  8. <span @click.stop="funExcelChange(item)">
  9. <img :src="CSV_C" alt="" v-if="isshowC(item)">
  10. <img :src="CSV" alt="" v-else>
  11. <span class="excelName">{{ item.name }}</span>
  12. </span>
  13. </el-checkbox>
  14. </el-checkbox-group>
  15. <div v-else>
  16. <div class="excelDataNoCheck" :class="theme ? 'excelW' : 'excelB'" v-for="item in data" :key="item.name"
  17. @click="funExcelChange(item)"
  18. :style="!theme && currentId === item.id ? 'background: rgba(0,70,199,0.35)' : ''">
  19. <!-- <el-icon>
  20. <Document />
  21. </el-icon> -->
  22. <img :src="CSV_C" alt="" v-if="currentId === item.id">
  23. <img :src="CSV" alt="" v-else>
  24. <span class="excelName" :style="excelSpanSty(item)">{{ item.name }}</span>
  25. </div>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. import CSV from '@/assets/menuImg/CSV.png'
  31. import CSV_C from '@/assets/menuImg/CSV_C.png'
  32. import nodata from '@/assets/images/noData.png'
  33. export default {
  34. props: {
  35. data: {
  36. type: Array,
  37. default: () => {
  38. return [];
  39. },
  40. },
  41. height: {
  42. type: String,
  43. default: () => {
  44. return '';
  45. },
  46. },
  47. showCheckbox: {
  48. type: Boolean,
  49. default: () => {
  50. return false;
  51. },
  52. },
  53. checkIds: {
  54. type: Array,
  55. default: () => {
  56. return [];
  57. },
  58. },
  59. theme: {
  60. type: Boolean,
  61. default: () => {
  62. return false;
  63. },
  64. },
  65. },
  66. data() {
  67. return {
  68. CSV: CSV,
  69. CSV_C: CSV_C,
  70. nodata: nodata,
  71. showCC: null,
  72. excelCheckIds: [],
  73. currentId: ''
  74. }
  75. },
  76. watch: {
  77. checkIds(newVal, oldVal) {
  78. this.excelCheckIds = newVal
  79. },
  80. data(newVal, oldVal) {
  81. if (newVal.length > 0) {
  82. this.currentId = newVal[0].id
  83. } else {
  84. this.currentId = ''
  85. }
  86. }
  87. },
  88. methods: {
  89. isshowC(item) {
  90. this.showCC = false
  91. this.excelCheckIds.forEach(it => {
  92. if (it === item.id) {
  93. this.showCC = true
  94. }
  95. })
  96. return this.showCC
  97. },
  98. excelSpanSty(item) {
  99. if (this.theme) {
  100. if (this.currentId === item.id) {
  101. return 'color: #5473E8'
  102. } else {
  103. return 'color:#000'
  104. }
  105. } else {
  106. if (this.currentId === item.id) {
  107. return 'color: #fff'
  108. } else {
  109. return 'color:#C3C3C4'
  110. }
  111. }
  112. },
  113. funExcelChange(obj) {
  114. this.currentId = obj.id
  115. this.$emit('excelChange', obj)
  116. },
  117. funCheckChange(checkArr, b) {
  118. this.$emit('checkChange', {
  119. checkArr,
  120. data: this.data
  121. }) //抛出当前选择checkIds, 和当前的childs数据项
  122. }
  123. }
  124. }
  125. </script>
  126. <style lang="less">
  127. .excelData {
  128. .excelDatahaveCheck {
  129. line-height: 25px;
  130. height: 25px;
  131. width: calc(100% - 10px);
  132. font-size: 14px;
  133. color: #b7b7b7;
  134. margin-bottom: 5px;
  135. border: 1px solid rgba(203, 204, 209, 0.5);
  136. cursor: pointer;
  137. img {
  138. width: 20px;
  139. height: 20px;
  140. position: relative;
  141. top: 3px;
  142. }
  143. .excelName {
  144. position: relative;
  145. top: -2px;
  146. margin-left: 3px;
  147. }
  148. .el-checkbox__input {
  149. right: -90%;
  150. }
  151. .is-checked {}
  152. .el-checkbox__label {
  153. position: relative;
  154. left: -15px;
  155. top: -2px;
  156. }
  157. }
  158. .excelDataNoCheck {
  159. line-height: 25px;
  160. height: 25px;
  161. width: calc(100% - 10px);
  162. font-size: 14px;
  163. color: #b7b7b7;
  164. margin-bottom: 5px;
  165. border: 1px solid rgba(203, 204, 209, 0.5);
  166. cursor: pointer;
  167. .el-icon {
  168. margin-right: 5px;
  169. color: #504bb5;
  170. }
  171. img {
  172. width: 20px;
  173. height: 20px;
  174. position: relative;
  175. top: 3px;
  176. }
  177. .excelName {
  178. position: relative;
  179. top: -2px;
  180. margin-left: 3px;
  181. }
  182. }
  183. .excelW {
  184. background: #fff;
  185. }
  186. .excelB {
  187. background: #181A1E;
  188. }
  189. }
  190. </style>