selectComponentKS.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <div>
  3. <div v-for="(item,index) in customFields" :key="index">
  4. <div class="leibie">
  5. <p class="leiName">{{item.title}}</p>
  6. <!-- <span class="jutixiang">
  7. <a-checkbox
  8. :value="index"
  9. name="type"
  10. @change="isSelectAll($event,index)"
  11. :checked="item.checkall"
  12. >全选</a-checkbox>
  13. </span> -->
  14. <!-- {{item.form}} -->
  15. <a-checkbox-group v-model="item.form" >
  16. <span class="jutixiang" v-for="(zhi,num) in item.specificFields " :key="num">
  17. <a-checkbox :value="zhi.dataIndex" :disabled="zhi.disabled" name="type" @change="checkboxClick(zhi)">
  18. <a-tooltip
  19. class="select-component"
  20. placement="top"
  21. :title="zhi.tip"
  22. :overlayClassName="tooltipShow"
  23. >{{zhi.title}}</a-tooltip>
  24. </a-checkbox>
  25. </span>
  26. </a-checkbox-group>
  27. </div>
  28. </div>
  29. </div>
  30. </template>
  31. <script>
  32. import {TTcustomFields ,KScustomFields} from '../../columnConst/accountConst'
  33. // let customFields=customFields
  34. export default {
  35. props: ['showCol','fixedCol','mediaType'],
  36. data() {
  37. return {
  38. // customFields,
  39. customFields:[],
  40. quanxuanflag: [],
  41. hovered: false,
  42. tooltipShow: 'tooltipShow',
  43. toParentArr: []
  44. }
  45. },
  46. watch: {
  47. showCol(n) {
  48. // console.log(n)
  49. //
  50. if (this.showCol.length == this.fixedCol.length) {
  51. for (let i = 0; i < this.customFields.length; i++) {
  52. this.customFields[i].form=[]
  53. }
  54. this.showCol.map((item, index) => {
  55. this.customFields.map((it, ind) => {
  56. it.specificFields.map((i, d) => {
  57. if (i.dataIndex === item.dataIndex) {
  58. it.form.push(item.dataIndex)
  59. }else{
  60. }
  61. })
  62. })
  63. })
  64. } else {
  65. for (let i = 0; i < this.customFields.length; i++) {
  66. this.customFields[i].form=[]
  67. }
  68. n.map((item, index) => {
  69. this.customFields.map((it, ind) => {
  70. it.specificFields.map((i, d) => {
  71. if (i.dataIndex === item.dataIndex) {
  72. it.form.push(item.dataIndex)
  73. }else{
  74. }
  75. })
  76. })
  77. })
  78. }
  79. // console.log(this.form)
  80. },
  81. },
  82. mounted() {
  83. if(this.mediaType==1){
  84. //头条自定义列
  85. this.customFields=TTcustomFields
  86. }else if(this.mediaType==2){
  87. //快手自定义列
  88. this.customFields=KScustomFields
  89. }
  90. for (let i = 0; i < this.customFields.length; i++) {
  91. this.customFields[i].form=[]
  92. }
  93. // console.log(1)
  94. this.showCol.map((item, index) => {
  95. this.customFields.map((it, ind) => {
  96. it.specificFields.map((i, d) => {
  97. if (i.dataIndex === item.dataIndex) {
  98. it.form.push(item.dataIndex)
  99. }
  100. })
  101. })
  102. })
  103. this.fixedCol.map((item, index) => {
  104. this.customFields.map((it, ind) => {
  105. it.specificFields.map((i, d) => {
  106. if (i.dataIndex === item.dataIndex) {
  107. i.disabled=true;
  108. }
  109. })
  110. })
  111. })
  112. // console.log(this.customFields);
  113. },
  114. methods: {
  115. hide() {
  116. this.clicked = false
  117. this.hovered = false
  118. },
  119. handleHoverChange(visible) {
  120. this.clicked = false
  121. this.hovered = visible
  122. },
  123. getPopupContainer() {
  124. console.log(this)
  125. },
  126. //全选框 判断是否全选
  127. isSelectAll(e, val) {
  128. //像父元素传递
  129. console.log(e, val)
  130. let arr=JSON.parse(JSON.stringify(this.customFields[val].specificFields))
  131. let valArr={
  132. flag:true,
  133. arr
  134. }
  135. this.customFields[val].checkall = e.target.checked
  136. console.log(this.customFields[val].checkall)
  137. if (this.customFields[val].checkall) {
  138. this.customFields[val].form=[]
  139. this.customFields[val].specificFields.map((item, index) => {
  140. this.customFields[val].form.push(item.dataIndex)
  141. })
  142. valArr.flag=true;
  143. this.$emit('getshowlist', valArr)
  144. } else {
  145. console.log(this.customFields[val])
  146. this.customFields[val].form=[];
  147. valArr.flag=false;
  148. console.log(this.customFields[val].form=[])
  149. this.$emit('getshowlist', valArr)
  150. }
  151. console.log(this.form[val])
  152. },
  153. onChange(){
  154. },
  155. //复选框的点击事件
  156. checkboxClick(val) {
  157. // console.log(val)
  158. // this.$emit('update:count',)
  159. this.$emit('getshowlist', val)
  160. // console.log(val,this.customFields[0].form)
  161. // this.customFields[val].checkall=!this.customFields[val].checkall
  162. // for (let i = 0; i < this.customFields.length; i++) {
  163. // // console.log(this.customFields[0].form,this.customFields[i].specificFields.length)
  164. // if(this.customFields[i].form.length==this.customFields[i].specificFields.length-1){
  165. // this.customFields[i].checkall=true;
  166. // }else{
  167. // this.customFields[i].checkall=false;
  168. // }
  169. // }
  170. }
  171. }
  172. }
  173. </script>
  174. <style>
  175. .tooltipShow {
  176. max-width: 30%;
  177. }
  178. .tooltipShow .ant-tooltip-content .ant-tooltip-inner {
  179. background: white;
  180. font-size: 10px;
  181. color: #333;
  182. }
  183. .ant-tooltip-content .ant-tooltip-arrow::before {
  184. background-color: white;
  185. }
  186. </style>
  187. <style lang="scss" scoped>
  188. .leibie {
  189. width: 100%;
  190. margin-bottom: 10px;
  191. .leiName {
  192. font-size: 20px;
  193. text-align: left;
  194. margin-bottom: 5px;
  195. margin-top: 0px;
  196. }
  197. }
  198. .jutixiang {
  199. display: inline-block;
  200. width: 32%;
  201. box-sizing: border-box;
  202. padding: 8px 3px;
  203. height: 30px;
  204. overflow: hidden;
  205. text-overflow: ellipsis;
  206. }
  207. .ant-tooltip-content .tooltipShow {
  208. background: #eee;
  209. font-size: 10px;
  210. color: #333;
  211. }
  212. .ant-checkbox-group {
  213. width: 100%;
  214. }
  215. </style>