| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 | 
							- <template>
 
-   <el-form-item label="排序">
 
-     <!-- <draggable v-model="orderByStrs" :group="{name: 'orderBy',pull: false, put: false}" style="display: inline-block;">
 
-       <el-tag v-for="(item,index) in orderByStrs" :key="index" closable size="small" @close="handleCloseOrderBy">
 
-         {{ item }}
 
-       </el-tag>
 
-     </draggable> -->
 
-     <draggable v-model="orderByStrs" :group="{name: 'orderBy',pull: false, put: false}" style="display: inline-block;">
 
-       <el-tag v-for="(item,index) in orderByStrs" :key="index" closable size="small" @close="handleCloseOrderBy" style="display:none">
 
-         {{ item }}
 
-       </el-tag>
 
-       <el-tag v-for="(item,index) in orderByStrs1" :key="index" closable size="small" @close="handleCloseOrderBy">
 
-         {{ item }}
 
-       </el-tag>
 
-     </draggable>
 
-     <el-cascader v-model="orderBy" :options="orderByOption" :disabled="orderByOption.length===0" size="mini" :placeholder="$t('chart.selectOrderBy')" style="width: 150px;" @change="handleOrderByChange" />
 
-   </el-form-item>
 
- </template>
 
- <script>
 
- import draggable from 'vuedraggable'
 
- import store from '../store'
 
- export default {
 
-   components: { draggable },
 
-   props: {
 
-     value: {
 
-       required: true,
 
-       type: Array
 
-     }
 
-   },
 
-   data() {
 
-     return {
 
-       orderBy: [],
 
-       orderBy1: [],
 
-       orderByStrs1: []
 
-     }
 
-   },
 
-   computed: {
 
-     allSelected() {
 
-       return store.state.caculCols.concat(store.state.dimensions)
 
-     },
 
-     orderByStrs: {
 
-       set(value) {
 
-         this.$emit('input', value)
 
-       },
 
-       get() {
 
-         return this.value
 
-       }
 
-     },
 
-     orderByOption() {
 
-       return this.allSelected.map(col => {
 
-         return {
 
-           value: col.Column,
 
-           label: col.Comment,
 
-           children: [{
 
-             value: 'desc',
 
-             label: '降序'
 
-           }, {
 
-             value: 'asc',
 
-             label: '正序'
 
-           }]
 
-         }
 
-       })
 
-     }
 
-   },
 
-   watch: {
 
-     'store.state.dimensions': function (value) {
 
-       this.watchHandler(value)
 
-     },
 
-     'store.state.caculCols': function (value) {
 
-       this.watchHandler(value)
 
-     }
 
-   },
 
-   methods: {
 
-     watchHandler(cols) {
 
-       console.log("cols", cols)
 
-       this.orderByStrs.forEach((orderByStr, index) => {
 
-         console.log('orderByStr', orderByStr)
 
-         const colName = orderByStr.split(' ')[0]
 
-         console.log('colName', colName)
 
-         if (!cols.findIndex(col => col.Column === colName)) {
 
-           this.orderByStrs.splice(index, 1)
 
-         }
 
-       })
 
-     },
 
-     // handleOrderByChange(value) {
 
-     //   console.log('handleOrderByChange:', value)
 
-     //   this.orderBy = []
 
-     //   const index = this.orderByStrs.findIndex(orderBy => orderBy.indexOf(value[0]) >= 0)
 
-     //   if (index >= 0) {
 
-     //     this.orderByStrs.splice(index, 1, `${value[0]} ${value[1]}`)
 
-     //   } else {
 
-     //     this.orderByStrs.push(`${value[0]} ${value[1]}`)
 
-     //   }
 
-     //   console.log('handleOrderByChange:', value)
 
-     //   console.log('this.orderByStrs', this.orderByStrs)
 
-     // },
 
-     handleOrderByChange(value) {
 
-       console.log('handleOrderByChange:', value)
 
-       console.log('orderBy:', this.orderBy)
 
-       console.log('orderByOption:', this.orderByOption)
 
-       var china_value = ""
 
-       this.orderByOption.forEach(function (i, j) {
 
-         if (i.value == value[0]) {
 
-           china_value = i.label
 
-         }
 
-       })
 
-       console.log('china_value:', china_value)
 
-       this.orderBy = []
 
-       const index = this.orderByStrs.findIndex(orderBy => orderBy.indexOf(value[0]) >= 0)
 
-       if (index >= 0) {
 
-         this.orderByStrs.splice(index, 1, `${value[0]} ${value[1]}`)
 
-       } else {
 
-         this.orderByStrs.push(`${value[0]} ${value[1]}`)
 
-       }
 
-       this.orderBy1 = []
 
-       if (value[1] == 'desc') {
 
-         var sort = '降序'
 
-       } else {
 
-         var sort = '正序'
 
-       }
 
-       const index1 = this.orderByStrs1.findIndex(orderBy1 => orderBy1.indexOf(china_value) >= 0)
 
-       if (index1 >= 0) {
 
-         this.orderByStrs1.splice(index1, 1, `${china_value} ${sort}`)
 
-       } else {
 
-         this.orderByStrs1.push(`${china_value} ${sort}`)
 
-       }
 
-       console.log('handleOrderByChange:', value)
 
-       console.log('this.orderByStrs', this.orderByStrs)
 
-       console.log('this.orderByStrs1', this.orderByStrs1)
 
-     },
 
-     handleCloseOrderBy(value) {
 
-       this.orderByStrs.splice(this.orderByStrs.indexOf(value), 1)
 
-       this.orderByStrs1.splice(this.orderByStrs1.indexOf(value), 1)
 
-     }
 
-   }
 
- }
 
- </script>
 
 
  |