You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

423 lines
14 KiB

5 years ago
<template>
<div class="my-project-container">
<div class="filter-view">
5 years ago
<div>
<span @click="switchDataShowTypeHandle('gird')">
<font-icon
:class="{'show-view-type-icon-active':dataShowType=='gird'}"
4 years ago
class="fas fa-th-large show-view-type-icon "
5 years ago
/>
</span>
<span @click="switchDataShowTypeHandle('table')">
<font-icon
:class="{'show-view-type-icon-active':dataShowType=='table'}"
4 years ago
class="fas fa-th-list show-view-type-icon"
5 years ago
/>
</span>
</div>
<el-form ref="form" label-width="100px">
<el-form-item label="项目更新时间">
5 years ago
<el-date-picker
5 years ago
v-model="queryParams.beginDateTime"
4 years ago
placeholder="选择开始时间"
5 years ago
style="width: 20%;"
5 years ago
type="datetime"
4 years ago
value-format="yyyy-MM-dd HH:mm:ss"
5 years ago
/>
5 years ago
5 years ago
<el-date-picker
5 years ago
v-model="queryParams.endDateTime"
4 years ago
:default-time="'23:59:59'"
placeholder="选择结束时间"
5 years ago
style="width: 20%;"
5 years ago
type="datetime"
5 years ago
value-format="yyyy-MM-dd HH:mm:ss"
5 years ago
/>
5 years ago
<el-input
v-model="queryParams.name"
4 years ago
placeholder="请输入项目名称" style="width: 20%; margin-left: 20px;" type="text"
5 years ago
/>
4 years ago
<el-button class="ml-20" type="primary" @click="queryProjectPage">查询</el-button>
5 years ago
</el-form-item>
<el-form-item label="项目状态">
5 years ago
<el-radio-group v-model="queryParams.status" size="small" @change="()=>{
this.queryParams.current=0
this.queryProjectPage()
}"
>
5 years ago
<el-radio-button v-for="status in projectStatusList" :key="status.code" :label="status.code">
{{ status.name }}
</el-radio-button>
</el-radio-group>
5 years ago
</el-form-item>
</el-form>
5 years ago
</div>
5 years ago
<div v-if="dataShowType=='gird'" class="project-grid-container">
<div
5 years ago
v-if="projectList.length"
v-loading="projectListLoading"
5 years ago
class="project-grid-view"
>
5 years ago
<div v-for="p in projectList" :key="p.id" class="project-grid-item-view pointer">
4 years ago
<el-row align="middle" justify="center" type="flex">
<el-col :span="5">
<span
:style="getStatusColorStyle(p.status)"
class="project-grid-view-status"
/>
</el-col>
<el-col :span="19">
<el-tooltip :content="p.name" placement="top">
<p class="project-title">
{{ p.name }}
</p>
</el-tooltip>
</el-col>
</el-row>
5 years ago
<img class="project-grid-view-preimg"
4 years ago
src="https://oss.smileyi.top/static/pic%20(1).png"
5 years ago
>
<p class="project-grid-view-time">创建时间{{ p.createTime | formatDate }}</p>
<div class="gird-operating-btns">
4 years ago
<el-button type="text" @click="toProjectHandle(p.key,'editor')">
<i class="el-icon-edit" />
编辑
</el-button>
<span>
<el-button
4 years ago
v-if="p.status!=1" type="text" @click="toProjectHandle(p.key,'statistics')"
>
<i class="el-icon-data-analysis" />
统计
</el-button>
</span>
<el-popconfirm
v-if="p.status==2"
title="确定停止收集该项目吗?"
@confirm="stopProject(p.key)"
5 years ago
>
<el-button slot="reference"
class="pink-text-btn"
type="text"
>
<i class="el-icon-video-pause" />
停止
</el-button>
</el-popconfirm>
<el-popconfirm
v-if="p.status==3"
title="确定删除该项目吗?"
@confirm="deleteProject(p.key)"
>
<el-button slot="reference"
class="pink-text-btn"
type="text"
>
<i class="el-icon-delete" />
删除
</el-button>
</el-popconfirm>
</div>
5 years ago
</div>
</div>
4 years ago
<div v-if="!projectListLoading&&projectList.length==0">
5 years ago
<data-empty />
</div>
5 years ago
</div>
<div v-if="dataShowType=='table'" class="project-table-view">
<el-table
:data="projectList"
border
4 years ago
empty-text="暂无数据"
5 years ago
highlight-current-row
4 years ago
stripe
5 years ago
style="width: 100%;"
>
<el-table-column
align="center"
label="标题"
4 years ago
prop="name"
show-overflow-tooltip
5 years ago
/>
<el-table-column
align="center"
label="描述"
4 years ago
prop="describe"
show-overflow-tooltip
5 years ago
/>
<el-table-column
align="center"
label="状态"
>
<template slot-scope="scope">
<span v-for="status in projectStatusList" :key="status.code">
<span
v-if="status.code==scope.row.status"
>
{{ status.name }}
</span>
</span>
</template>
</el-table-column>
<el-table-column
align="center"
label="创建时间"
4 years ago
prop="createTime"
5 years ago
/>
<el-table-column
align="center"
label="更新时间"
4 years ago
prop="updateTime"
5 years ago
/>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button type="text"
4 years ago
@click="toProjectHandle(scope.row.key,'editor')"
5 years ago
>
编辑
</el-button>
<span>
<el-button
v-if="scope.row.status!=1"
class="green-text-btn"
4 years ago
type="text"
4 years ago
@click="toProjectHandle(scope.row.key,'statistics')"
>
统计
</el-button>
</span>
<el-popconfirm
v-if="scope.row.status==2"
title="确定停止收集该项目吗?"
@confirm="stopProject(scope.row.key)"
5 years ago
>
<el-button slot="reference"
class="pink-text-btn"
type="text"
>
停止
</el-button>
</el-popconfirm>
<el-popconfirm
v-if="scope.row.status==3"
title="确定删除该项目吗?"
@confirm="deleteProject(scope.row.key)"
>
<el-button slot="reference"
class="pink-text-btn"
type="text"
>
删除
</el-button>
</el-popconfirm>
5 years ago
</template>
</el-table-column>
</el-table>
5 years ago
</div>
<div class="project-page-view">
<el-pagination
v-if="total>10"
:current-page.sync="queryParams.current"
4 years ago
:page-size.sync="queryParams.size"
5 years ago
:total="total"
4 years ago
background
layout="total, prev, pager, next"
5 years ago
@current-change="queryProjectPage"
/>
</div>
</div>
</template>
<script>
import dayjs from 'dayjs'
5 years ago
let projectStatusList = [
{code: 1, name: '未发布', color: '#006EFF'},
{code: 2, name: '收集中', color: '#34C82A'},
{code: 3, name: '已结束', color: '#955A45'}
5 years ago
]
export default {
name: 'MyProject',
filters: {
formatDate(time) {
4 years ago
return dayjs(time).format('YYYY/MM/DD')
}
},
5 years ago
data() {
return {
5 years ago
dataShowType: 'gird',
5 years ago
total: 0,
queryParams: {
current: 1,
size: 10,
name: '',
5 years ago
beginDateTime: null,
endDateTime: null,
5 years ago
status: null
},
projectStatusList: projectStatusList,
projectList: [],
projectListLoading: true
5 years ago
}
},
computed: {
getStatusColorStyle() {
return function(code) {
let color = this.projectStatusList.find(item => item.code == code).color
return {
backgroundColor: color,
borderColor: color
}
}
}
},
5 years ago
created() {
this.queryProjectPage()
},
methods: {
5 years ago
switchDataShowTypeHandle(type) {
this.dataShowType = type
},
5 years ago
toProjectHandle(key, type) {
this.$router.push({path: `/project/form/${type}`, query: {key: key, active: type}})
5 years ago
},
deleteProject(key) {
this.$api.post('/user/project/delete', {'key': key}).then(res => {
if (res.data) {
this.msgSuccess('刪除成功')
this.queryProjectPage()
}
})
},
stopProject(key) {
this.$api.post('/user/project/stop', {'key': key}).then(res => {
if (res.data) {
this.msgSuccess('停止成功')
this.queryProjectPage()
}
})
},
5 years ago
queryProjectPage() {
this.$api.get('/user/project/page', {
params: this.queryParams
}).then(res => {
let {records, total, size} = res.data
this.projectList = records
this.total = total
this.queryParams.size = size
this.projectListLoading = false
5 years ago
})
}
}
}
</script>
<style lang="scss" scoped>
5 years ago
.my-project-container {
display: flex;
5 years ago
width: 100%;
5 years ago
height: 100%;
5 years ago
flex-direction: column;
align-items: center;
5 years ago
align-content: center;
5 years ago
}
.back-view {
display: flex;
width: 80%;
align-content: flex-start;
margin: 10px;
5 years ago
}
.filter-view {
5 years ago
margin-top: 20px;
5 years ago
display: flex;
flex-direction: row;
5 years ago
}
.show-view-type-icon {
color: white;
font-size: 18px;
-webkit-text-stroke: 0.5px #a8a8a8;
5 years ago
margin: 5px;
5 years ago
cursor: pointer;
5 years ago
}
.show-view-type-icon-active {
color: rgba(92, 155, 249, 100);
-webkit-text-stroke: 0.5px rgba(92, 155, 249, 100);
5 years ago
}
5 years ago
.project-grid-container {
5 years ago
margin-top: 20px;
5 years ago
display: flex;
width: 100%;
justify-content: center;
}
.project-grid-view {
display: flex;
width: 950px;
5 years ago
flex-direction: row;
flex-wrap: wrap;
}
.project-table-view {
margin-top: 20px;
width: 80%;
5 years ago
}
.project-grid-item-view {
width: 169px;
height: 199px;
line-height: 20px;
border-radius: 4px;
background-color: rgba(255, 255, 255, 100);
text-align: center;
margin: 10px;
position: relative;
4 years ago
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
.project-title {
color: rgba(16, 16, 16, 100);
font-size: 14px;
text-align: left;
line-height: 20px;
max-height: 20px;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.project-grid-view-status {
display: inline-block;
width: 7px;
height: 7px;
line-height: 20px;
background-color: rgba(0, 110, 255, 100);
text-align: center;
border: 1px solid rgba(0, 110, 255, 100);
border-radius: 20px;
}
5 years ago
}
.gird-operating-btns {
5 years ago
position: absolute;
width: 100%;
margin: 0;
padding: 0;
background-color: #f0f0f0;
bottom: 0;
display: none;
border: none;
}
.project-grid-item-view:hover .gird-operating-btns {
display: block;
5 years ago
}
.project-grid-view-preimg {
width: 143px;
height: 121px;
}
.project-grid-view-time {
color: rgba(144, 147, 153, 100);
font-size: 12px;
line-height: 20px;
text-align: center;
5 years ago
margin: 0;
}
.project-page-view {
margin-top: 30px;
}
</style>