Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | 7x 7x 7x 7x 7x | <template> <span :class="{ [$style.root]: true, [$style.active]: active }" @click="onClick" > <u-badge corner :value="total" :class="$style.badge"> <!-- <span :class="$style.notice"></span> --> <i-ico v-if="icon" :name="icon" :class="$style.taskicon" notext></i-ico> </u-badge> <u-popup :mode="false" trigger="manual" placement="bottom" :opened.sync="opened" > <u-linear-layout direction="vertical" :class="$style.content"> <h3 :class="$style.h3">待处理任务 ({{ total }})</h3> <u-list line hover striped> <u-list-item v-for="task in tasks" :key="task.id" @click.native="clickTask(task)"> <u-linear-layout type="flex" justify="space-between" alignment="center" :class="$style.line" > <span :class="$style.title">{{ task.name || task.processDefinitionName }}</span> <span :class="$style.time">{{ dateFormatter(task.createAt) }}</span> </u-linear-layout> </u-list-item> </u-list> <u-pagination v-if="total" :total="totalPages" simple @change="changePage"></u-pagination> </u-linear-layout> </u-popup> </span> </template> <script> import IIco from '../i-ico.vue'; export default { name: 'u-taskbox', component: { IIco, }, props: { icon: { type: String, default: '通知', }, size: { type: Number, default: 5, }, interval: { type: Number, default: 30, validator(value) { return value >= 5; }, }, }, data() { return { active: false, tasks: [], page: 1, total: 0, totalPages: 1, opened: false, timeout: null, }; }, async created() { await this.getTasks(); }, destroyed() { this.clearTime(); }, methods: { async getTasks() { // IDE 编辑状态不请求接口 if (this.$env.VUE_APP_DESIGNER) return; if (this.$process) { this.setTime(); const { Data = {} } = await this.$process.getTasks({ query: { pageNumber: this.page - 1, pageSize: this.size, }, }) || {}; const { content, totalElements = 0, totalPages = 1, list, total = 0 } = Data; if (Array.isArray(list) && total) { this.tasks = list; this.total = total; this.totalPages = Math.ceil(total / this.size); } else if (Array.isArray(content)) { this.tasks = content; this.total = totalElements; this.totalPages = totalPages; } // 刷新时可能数据变化造成分页过大,此时自动调整分页 if (this.totalPages > 0 && this.page > this.totalPages) { this.page = this.totalPages; } } }, async onClick() { this.opened = !this.opened; await this.getTasks(); }, async clickTask(task) { const { id } = task; await this.$process.claimTask({ path: { id }, }); const res = await this.$process.getDestinationUrl({ path: { id }, }); location.href = res.Data; }, dateFormatter(value) { // eslint-disable-next-line new-cap return this.$utils ? this.$utils.FormatDateTime(value) : value; }, changePage({ page }) { this.page = page; this.getTasks(); }, setTime() { this.clearTime(); const time = this.interval >= 3 ? this.interval : 3; this.timeout = setTimeout(this.getTasks, time * 1000); }, clearTime() { if (this.timeout) { clearTimeout(this.timeout); this.timeout = null; } }, }, }; </script> <style module> .root { display: inline-block; vertical-align: middle; width: 60px; text-align: center; cursor: pointer; } .active .notice::before, .root:hover .notice::before { color: var(--brand-primary); } .notice { display: inline-block; font-size: 22px; } .notice::before { icon-font: url('i-material-design.vue/assets/outlined/notifications.svg'); font-weight: bold; } .content { min-width: 360px; padding: 16px; } .h3 { margin: 0; color: var(--brand-primary); } .line { height: 32px; } .title { font-size: 14px; } .time { color: var(--color-lighter); font-size: 12px; } .taskicon { font-size: var(--taskbox-icon-font-size); } .taskicon [class^="i-ico_iconwrap"] { font-size: inherit; } .badge [class^="u-badge_value__"]{ box-shadow: var(--taskbox-badge-box-shadow); } </style> |