You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.5 KiB

  1. <template>
  2. <div>
  3. <el-row>
  4. <el-col :span="20">
  5. <el-transfer v-model="outputListTemp" :data="inputList" :props="alias" target-order="push" @right-check-change="rightCheck"></el-transfer>
  6. </el-col>
  7. <el-col :span="4" style="margin-top: 95px;">
  8. <div style="margin-bottom: 10px;">
  9. <el-button icon="el-icon-arrow-up" circle :disabled="upDownDisable" @click="upData"></el-button>
  10. </div>
  11. <div>
  12. <el-button icon="el-icon-arrow-down" circle :disabled="upDownDisable" @click="downData"></el-button>
  13. </div>
  14. </el-col>
  15. </el-row>
  16. </div>
  17. </template>
  18. <script>
  19. import {
  20. Message,
  21. Notification
  22. } from 'element-ui';
  23. export default {
  24. name: 'myTransfer',
  25. props: [
  26. 'value',
  27. 'inputList',
  28. 'alias'
  29. ],
  30. data() {
  31. return {
  32. upDownDisable:true,
  33. tempSelectionKeys:[],
  34. outputListTemp:[]
  35. }
  36. },
  37. watch: {
  38. value(val) {
  39. this.outputListTemp = val;
  40. },
  41. outputListTemp(val){
  42. this.$emit('input', val);
  43. }
  44. },
  45. mounted() {
  46. },
  47. methods: {
  48. rightCheck(selectionKeys, changeKeys){
  49. this.tempSelectionKeys = selectionKeys;
  50. if(selectionKeys.length > 0){
  51. this.upDownDisable = false;
  52. }else{
  53. this.upDownDisable = true;
  54. }
  55. },
  56. upData(){
  57. if(this.tempSelectionKeys.length > 1){
  58. this.$message({
  59. type: 'warning',
  60. message: '仅支持单选调顺序'
  61. });
  62. return ;
  63. }
  64. let indexNum = 0;
  65. for(let i=0; i<this.tempSelectionKeys.length; i++){
  66. indexNum = this.outputListTemp.indexOf(this.tempSelectionKeys[i])
  67. if(indexNum > 0){
  68. this.outputListTemp.splice(indexNum - 1, 0, this.tempSelectionKeys[i]);
  69. this.outputListTemp.splice(indexNum + 1, 1);
  70. }
  71. }
  72. },
  73. downData(){
  74. if(this.tempSelectionKeys.length > 1){
  75. this.$message({
  76. type: 'warning',
  77. message: '仅支持单选调顺序'
  78. });
  79. return ;
  80. }
  81. let indexNum = 0;
  82. for(let i=0; i<this.tempSelectionKeys.length; i++){
  83. indexNum = this.outputListTemp.indexOf(this.tempSelectionKeys[i]);
  84. if(indexNum > -1 && indexNum != this.outputListTemp.length - 1){
  85. this.outputListTemp.splice(indexNum + 2, 0, this.tempSelectionKeys[i]);
  86. this.outputListTemp.splice(indexNum, 1);
  87. }
  88. }
  89. }
  90. }
  91. }
  92. </script>
  93. <style type="text/css">
  94. </style>