SetTableCols.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <el-dialog
  3. title="自定义列"
  4. :visible.sync="show"
  5. :modal-append-to-body="false"
  6. :close-on-click-modal="false"
  7. :center="true"
  8. v-dialogDrag
  9. custom-class="dialogclass"
  10. width="550px"
  11. @close="handleClose"
  12. >
  13. <draggable
  14. v-model="list"
  15. class="list-wrap"
  16. animation="300"
  17. tag="div"
  18. handle=".drag"
  19. >
  20. <div class="list-item" v-for="item in list" :key="item.ColumnKey">
  21. <el-checkbox v-model="item.checked" :disabled="item.IsMust===1">
  22. <span class="name" :style="{color:item.IsMust===1?'#C0C4CC':''}">{{item.ColumnName}}</span>
  23. </el-checkbox>
  24. <img class="drag" src="~@/assets/img/data_m/move_ico2.png" alt="">
  25. </div>
  26. </draggable>
  27. <div style="text-align:center;margin:30px 0">
  28. <el-button type="primary" plain @click="handleClose">取消</el-button>
  29. <el-button type="primary" @click="handleSave">确定</el-button>
  30. </div>
  31. </el-dialog>
  32. </template>
  33. <script>
  34. import draggable from 'vuedraggable';
  35. import {apiDataSource} from '@/api/modules/dataSource'
  36. export default {
  37. components:{draggable},
  38. model:{
  39. prop:"show",
  40. event:'close'
  41. },
  42. props:{
  43. show:{
  44. type:Boolean,
  45. default:false
  46. },
  47. ColumnType:{//1数据源明细表,2数据源统计表,3删除指标列表,4指标信息变更表"
  48. type:Number,
  49. default:0
  50. }
  51. },
  52. watch: {
  53. show(n){
  54. if(n){
  55. this.getTableColOpts()
  56. }
  57. }
  58. },
  59. data() {
  60. return {
  61. list:[]
  62. }
  63. },
  64. methods: {
  65. // 获取表格列配置项
  66. getTableColOpts(){
  67. apiDataSource.GLTableColOpts({ColumnType:this.ColumnType}).then(res=>{
  68. if(res.Ret===200){
  69. const arr=res.Data.List||[]
  70. this.list=arr.map(item=>{
  71. return {
  72. ...item,
  73. checked:item.IsShow===1?true:false
  74. }
  75. })
  76. }
  77. })
  78. },
  79. handleSave(){
  80. const list=this.list.map(item=>{
  81. return {
  82. Id:item.Id,
  83. IsShow:item.checked?1:0
  84. }
  85. })
  86. apiDataSource.GLTableColEdit({
  87. list:list
  88. }).then(res=>{
  89. if(res.Ret===200){
  90. this.$message.success('保存成功')
  91. this.$emit('change')
  92. this.handleClose()
  93. }
  94. })
  95. },
  96. handleClose(){
  97. this.$emit('close', false)
  98. }
  99. },
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. .list-wrap{
  104. .list-item{
  105. padding: 10px 0;
  106. border-bottom: 1px solid #000;
  107. display: flex;
  108. justify-content: space-between;
  109. .name{
  110. font-size: 16px;
  111. color: #000;
  112. }
  113. .drag{
  114. cursor: move;
  115. }
  116. }
  117. }
  118. </style>