zjf
2023-02-24 3f9bad03f4fbca2d5c5be86e904ae832475634d8
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
<template>
  <div class="my-task">
    <slot name="searchInput"/>
    <div class="select-box">
      <!-- 筛选 -->
      <div
        v-if="listType === 'subtask'"
        class="select-group">
        <label>任务类型</label>
        <el-select
          v-model="fromData.type"
          placeholder="请选择"
          @change="selectChange">
          <el-option
            v-for="item in subordinateOption"
            :key="item.key"
            :label="item.label"
            :value="item.key"/>
        </el-select>
      </div>
      <div
        v-else
        class="select-group">
        <label>任务类型</label>
        <el-select
          v-model="fromData.type"
          placeholder="请选择"
          @change="selectChange">
          <el-option
            v-for="item in typeOptions"
            :key="item.key"
            :label="item.label"
            :value="item.key"/>
        </el-select>
      </div>
      <div class="select-group">
        <label>状态</label>
        <el-select
          v-model="fromData.status"
          placeholder="请选择"
          @change="selectChange">
          <el-option
            v-for="item in statusOptions"
            :key="item.key"
            :label="item.label"
            :value="item.key"/>
        </el-select>
      </div>
      <div class="select-group">
        <label>优先级</label>
        <el-select
          v-model="fromData.priority"
          placeholder="请选择"
          @change="selectChange">
          <el-option
            v-for="item in priorityOptions"
            :key="item.key"
            :label="item.label"
            :value="item.key"/>
        </el-select>
      </div>
      <div class="select-group">
        <label>截止时间</label>
        <el-select
          v-model="fromData.date"
          placeholder="请选择"
          @change="selectChange">
          <el-option
            v-for="item in timeOptions"
            :key="item.key"
            :label="item.label"
            :value="item.key"/>
        </el-select>
      </div>
      <div
        v-if="listType === 'subtask'"
        class="select-group">
        <label class="min-width">负责人</label>
        <el-select
          v-model="fromData.subUser"
          placeholder="请选择"
          @change="selectChange">
          <el-option
            v-for="item in subUserListData"
            :key="item.userId"
            :label="item.realname"
            :value="item.userId"/>
        </el-select>
      </div>
    </div>
    <div class="list-box-container">
      <div class="list-box">
        <task-cell
          v-for="(item, index) in list"
          :key="index"
          :data="item"
          :data-index="index"
          @on-handle="taskCellHandle"/>
      </div>
      <p class="load">
        <el-button
          :loading="loadMoreLoading"
          type="text">{{ loadMoreLoading ? '加载更多' : '没有更多了' }}</el-button>
      </p>
    </div>
    <!-- 详情 -->
    <particulars
      v-if="taskDetailShow"
      ref="particulars"
      :id="taskID"
      :detail-index="detailIndex"
      @on-handle="detailHandle"
      @close="closeBtn"/>
  </div>
</template>
 
<script>
import particulars from '../components/particulars'
import listTaskDetail from '../mixins/listTaskDetail.js'
import TaskCell from './taskCell'
 
export default {
  components: {
    TaskCell,
    particulars
  },
  mixins: [listTaskDetail],
  props: {
    listType: '',
    list: Array,
    // 负责人
    subUserListData: {
      type: Array,
      default: () => {
        return []
      }
    },
    loadMoreLoading: false
  },
  data () {
    return {
      fromData: {
        type: '0',
        status: '1',
        priority: '',
        date: '',
        subUser: ''
      },
      // 任务类型
      typeOptions: [
        { label: '全部', key: '0' },
        { label: '我负责的', key: '1' },
        { label: '我创建的', key: '2' },
        { label: '我参与的', key: '3' }
      ],
      // 下属任务类型
      subordinateOption: [
        { label: '全部', key: '0' },
        { label: '下属负责的', key: '1' },
        { label: '下属创建的', key: '2' },
        { label: '下属参与的', key: '3' }
      ],
      // 状态
      statusOptions: [
        { label: '全部', key: '' },
        { label: '正在进行', key: '1' },
        { label: '已完成', key: '5' }
      ],
      // 优先级
      priorityOptions: [
        { label: '全部', key: '' },
        { label: '高', key: '3' },
        { label: '中', key: '2' },
        { label: '低', key: '1' },
        { label: '无', key: '0' }
      ],
      // 截至时间
      timeOptions: [
        { label: '全部', key: '' },
        { label: '今天到期', key: '1' },
        { label: '明天到期', key: '2' },
        { label: '一周到期', key: '3' },
        { label: '一个月到期', key: '4' }
      ]
    }
  },
  mounted () {
    document
      .getElementById('workbench-main-container')
      .addEventListener('click', this.taskShowHandle, false)
  },
  methods: {
    selectChange (val, key) {
      this.$emit('selectChange', { type: this.listType, data: this.fromData })
    },
    // 点击空白处关闭详情
    taskShowHandle (e) {
      if (
        this.$refs.particulars &&
        !this.$refs.particulars.$el.contains(e.target)
      ) {
        let hidden = true
        const items = document.getElementsByClassName('list-box')
        for (let index = 0; index < items.length; index++) {
          const element = items[index]
          if (element.contains(e.target)) {
            hidden = false
            break
          }
        }
        this.taskDetailShow = !hidden
      }
    },
    taskCellHandle (data) {
      if (data.type === 'view') {
        this.showDetailView(data.data.item, data.data.index)
      }
    }
  }
}
</script>
 
<style scoped lang="scss">
.my-task {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: hidden;
  .wukong {
    vertical-align: middle;
  }
  .select-box {
    margin-top: 22px;
    margin-bottom: 20px;
    // margin-right: -33px;
    max-width: 855px;
    overflow: hidden;
    .select-group {
      margin-bottom: 12px;
      width: 190px;
      float: left;
      label {
        color: #999;
        margin-right: 10px;
      }
      .el-select /deep/ {
        width: 116px;
        .el-input__inner {
          height: 30px;
          line-height: 30px;
        }
      }
      .min-width {
        width: 56px;
        display: inline-block;
      }
    }
    .select-group:nth-child(2) {
      padding-left: 15px;
    }
    .select-submit {
      float: right;
      margin-right: 10px;
    }
  }
  .list-box-container {
    flex: 1;
    overflow-y: auto;
  }
}
 
.load {
  color: #999;
  font-size: 13px;
  margin: 0 auto 15px;
  text-align: center;
  .el-button,
  .el-button:focus {
    color: #ccc;
    cursor: auto;
  }
}
</style>