accountCheck.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <style>
  2. .checked {
  3. width: 100%;
  4. }
  5. .checked .ant-checkbox-wrapper {
  6. width: 20%;
  7. }
  8. </style>
  9. <template>
  10. <div>
  11. <a-modal title="账户选择" v-model="showEdit" @ok="handleOk" @cancel="close" width="60%">
  12. <a-checkbox :indeterminate="indeterminate" @change="onCheckAllChange" :checked="checkAll">全选</a-checkbox>
  13. <br />
  14. <a-checkbox-group :options="showList" v-model="dataValue" class="checked" @change="onChange" />
  15. </a-modal>
  16. </div>
  17. </template>
  18. <script>
  19. import { deleteAction, getAction } from '@/api/manage'
  20. // import lifting from './components/lifting'
  21. export default {
  22. name: 'modules',
  23. components: {},
  24. data: function() {
  25. return {
  26. showEdit: false,
  27. dataList: [],
  28. showList: null,
  29. dataValue: [],
  30. indeterminate: false,
  31. checkAll: false
  32. }
  33. },
  34. methods: {
  35. handleOk(e) {
  36. console.log(e)
  37. this.showEdit = false
  38. this.$emit('synchro', this.dataValue)
  39. },
  40. close() {
  41. this.showEdit = false
  42. this.dataList = []
  43. this.showList = null
  44. this.dataValue = []
  45. this.indeterminate = false
  46. this.checkAll = false
  47. },
  48. onCheckAllChange(e) {
  49. Object.assign(this, {
  50. dataValue: e.target.checked
  51. ? this.showList.map(item => {
  52. return item.value
  53. })
  54. : [],
  55. indeterminate: false,
  56. checkAll: e.target.checked
  57. })
  58. },
  59. onChange(checkedList) {
  60. this.indeterminate = !!this.dataValue.length && this.dataValue.length < this.showList.length
  61. this.checkAll = this.dataValue.length === this.showList.length
  62. },
  63. getData(url, item) {
  64. this.showEdit = true
  65. this.dataList = []
  66. this.showList = null
  67. this.dataValue = []
  68. this.indeterminate = false
  69. this.checkAll = false
  70. console.log(url, item)
  71. getAction(url, item).then(res => {
  72. if (res.code == 0) {
  73. this.showList = res.result.map(item => {
  74. return {
  75. label: item.authName,
  76. value: item.accountId
  77. }
  78. })
  79. }
  80. console.log(res)
  81. })
  82. }
  83. },
  84. computed: {}
  85. }
  86. </script>