doum
8 天以前 5f9bf98779e2c3e69324d75849efdda00868da4f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<template>
    <GlobalWindow
        :title="title"
        width="60%"
        :visible.sync="visible"
        @confirm="confirm"
    >
        <div class="Analysis">
            <span>请根据使用习惯自定义常用功能,支持拖动排</span>
            <draggable v-model="filterList" chosenClass="chosen" forceFallback="true" group="people" animation="1000">
                <transition-group class="dra">
                    <div class="list" v-for="item in filterList" :key="item.path || item.id">
                        <div class="list_checkbox">
                            <el-checkbox v-model="item.checked"> </el-checkbox>
                        </div>
                        <img :src="item.icoPath" />
                        <div class="list_title">{{ item.name }}</div>
                    </div>
                </transition-group>
            </draggable>
        </div>
    </GlobalWindow>
</template>
 
<script>
  import BaseOpera from '@/components/base/BaseOpera'
  import GlobalWindow from '@/components/common/GlobalWindow'
  import { updMyYwQuickModel, getDefaultYwQuickList, getYwQuickList } from '@/api/ywWorkDesk'
  import draggable from 'vuedraggable'
  export default {
    name: 'commonFunctions',
    extends: BaseOpera,
    components: { GlobalWindow, draggable },
    data () {
      return {
        filterList: []
      }
    },
    methods: {
      open (title) {
        this.title = title
        Promise.all([getDefaultYwQuickList(), getYwQuickList()])
          .then(([allList, myList]) => {
            const selectedPaths = (myList || []).map(item => item.path)
            const pathOrder = new Map(selectedPaths.map((path, index) => [path, index]))
            const selected = []
            const unselected = []
            ;(allList || []).forEach(item => {
              const entry = { ...item, checked: selectedPaths.includes(item.path) }
              if (entry.checked) {
                selected.push(entry)
              } else {
                unselected.push(entry)
              }
            })
            selected.sort((a, b) => (pathOrder.get(a.path) || 0) - (pathOrder.get(b.path) || 0))
            this.filterList = [...selected, ...unselected]
            this.visible = true
          })
          .catch(e => this.$tip.apiFailed(e))
      },
      confirm () {
        this.isWorking = true
        let arr = this.filterList.filter(item => item.checked)
        updMyYwQuickModel(arr.map(item => item.id))
          .then(() => {
            this.visible = false
            this.$tip.apiSuccess('修改成功')
            this.$emit('success')
          })
          .finally(() => {
            this.isWorking = false
          })
      }
    }
  }
</script>
 
<style lang="scss" scoped>
    .Analysis {
        width: 100%;
        margin-top: 20px;
        display: flex;
        flex-direction: column;
        span {
            font-weight: 400;
            font-size: 14px;
            color: #333333;
            margin-bottom: 20px;
        }
        .dra {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
        }
        .list {
            cursor: pointer;
            display: flex;
            align-items: center;
            width: 24%;
            height: 80px;
            background: #FFFFFF;
            border-radius: 8px;
            border: 1px solid #DFE2E8;
            margin-bottom: 10px;
            padding: 0 20px;
            box-sizing: border-box;
            position: relative;
            .list_checkbox {
                position: absolute;
                right: 10px;
                top: 10px;
            }
            img {
                width: 40px;
                height: 40px;
                user-select: none;
                margin-right: 10px;
            }
            .list_title {
                width: 130px;
                font-size: 11px;
                user-select: none;
            }
        }
    }
</style>