| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- <template>
- <div>
- <div class="full-width flex flex-center flex-justify-between">
- <el-button
- type="primary"
- icon="el-icon-plus"
- @click="addTask"
- v-if="option.addBtn || option.addBtn === undefined"
- >新增任务
- </el-button>
- <div v-else></div>
- <el-button circle icon="Refresh" @click="refresh" />
- </div>
- <div class="header flex flex-justify-between full-width mt-10">
- <div
- v-for="(item, index) in option.column"
- :key="item.label"
- class="full-width"
- >
- <div
- v-if="index === 0"
- class="flex-child-shrink flex flex-justify-start first"
- :style="`width:` + item.width + 'px'"
- >
- 共 {{ total }}个任务
- </div>
- <div v-else class="flex-child-average">
- {{ item.label }}
- </div>
- </div>
- </div>
- <div class="content full-width">
- <div
- v-for="row in data"
- :key="row.id"
- class="flex flex-center full-width row"
- @click="rowClick(row)"
- >
- <div
- v-for="(column, index) in option.column"
- :key="column.label"
- class="full-width full-height"
- >
- <div
- v-if="index === 0"
- class="full-height flex flex-center flex-justify-start"
- :style="`width:` + column.width + 'px'"
- >
- <div
- class="full-width full-height flex flex-justify-start flex-align-center"
- >
- <div
- class="level"
- :style="
- `background-color:` +
- (row && row.currentLevel ? row.currentLevel.color : 'white')
- "
- ></div>
- <wt-tag
- :data="status"
- :status="row.taskStatus"
- :disabled="true"
- />
- {{ row[column.prop] }}
- </div>
- </div>
- <div v-else-if="index === 1" class="flex flex-center full-height">
- {{ row[column.prop] }}
- </div>
- <div
- v-else-if="index === 2"
- class="flex-child-average full-height full-width flex flex-center"
- >
- <div>
- <el-tag v-for="tag in row.tagsArray" :key="tag" class="mr-10"
- >{{ tag }}
- </el-tag>
- </div>
- </div>
- <div
- v-else-if="index === 3"
- class="flex-child-average full-height full-width flex flex-center"
- >
- <div>
- <div v-if="row.startTime.length > 0 && row.endTime.length === 0">
- {{ row.startTime.substring(5) }} 开始
- </div>
- <div
- v-else-if="row.startTime.length === 0 && row.endTime.length > 0"
- >
- {{ row.endTime.substring(5) }} 截止
- </div>
- <div v-else>
- {{ row.startTime.substring(5) }} 至
- {{ row.endTime.substring(5) }}
- </div>
- </div>
- </div>
- <div
- v-else
- class="flex-child-average full-height full-width flex flex-center"
- >
- <div v-if="row.users !== undefined" class="flex flex-center">
- <div v-for="i in row.users" :key="i.id" class="flex flex-center">
- <el-tooltip :content="i.name">
- <el-avatar
- class="ml-10 mr-10"
- :size="25"
- :src="
- i.avatar.length === 0
- ? 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'
- : i.avatar
- "
- ></el-avatar>
- </el-tooltip>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <task
- ref="task"
- :task="task"
- :project-id="projectId"
- @success="refresh"
- ></task>
- </div>
- </template>
- <script>
- import WtTag from '@/views/task/component/wt-tag.vue'
- import Task from '@/views/task/component/task.vue'
- export default {
- components: { Task, WtTag },
- props: {
- projectId: {
- type: String,
- default: ''
- },
- data: {
- type: Array,
- default: []
- },
- option: {
- type: Object,
- default: null
- },
- total: {
- type: Number,
- default: 0
- }
- },
- watch: {
- data: {
- handler(val) {
- val.forEach(item => {
- const tmp = this.level.find(ele => ele.value === item.level)
- item.currentLevel = tmp
- })
- },
- immediate: true
- }
- },
- data() {
- return {
- task: null,
- info: {
- taskStatus: ''
- },
- status: [
- {
- title: '待确认',
- value: 0,
- color: '#D7D7D7',
- checked: true
- },
- {
- title: '进行中',
- value: 1,
- color: '#47A6EA',
- checked: false
- },
- {
- title: '已提交',
- value: 2,
- color: '#ECAB56',
- checked: false
- },
- {
- title: '已完成',
- value: 3,
- color: '#80B336',
- checked: false
- },
- {
- title: '已取消',
- value: 4,
- color: '#C72A29',
- checked: false
- }
- ],
- level: [
- {
- title: 'P1',
- value: 0,
- color: '#C72A29',
- checked: true
- },
- {
- title: 'P2',
- value: 1,
- color: '#E89D42',
- checked: false
- },
- {
- title: 'P3',
- value: 2,
- color: '#47A6EA',
- checked: false
- },
- {
- title: 'P4',
- value: 3,
- color: '#A0A0A0',
- checked: false
- }
- ]
- }
- },
- methods: {
- fetchIndex(list, key) {
- const index = list.findIndex(ele => ele.value === key)
- if (index > -1) {
- list.map(ele => {
- ele.checked = false
- return ele
- })
- list[index].checked = true
- }
- return list
- },
- addTask() {
- this.task = null
- this.$refs.task.show(1)
- },
- rowClick(item) {
- this.getTaskInfo(item.id)
- this.$emit('rowClick', item)
- },
- getTaskInfo(id) {
- this.$api.task.taskInfo({ id }).then(res => {
- if (res.code === 200) {
- this.task = res.data
- this.$nextTick(() => {
- this.$refs.task.show(2)
- })
- } else {
- this.$message.error(res.msg)
- }
- })
- },
- refresh() {
- this.$emit('refresh')
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .header {
- border-bottom: #f7f8fa solid 1px;
- padding: 10px 0;
- }
- .first {
- width: 600px;
- }
- .row {
- height: 60px;
- border-bottom: #f7f8fa solid 1px;
- }
- .row:hover {
- height: 60px;
- background-color: #f7f9fc;
- }
- .level {
- width: 5px;
- height: 100%;
- margin-right: 10px;
- }
- </style>
|