IDCDatasync-vue/src/views/task/index.vue
2025-05-09 12:39:06 +08:00

245 lines
7.3 KiB
Vue

<template>
<a-card :bordered="false">
<!-- 查询区域 -->
<div class="table-page-search-wrapper">
<a-form layout="inline">
<a-row :gutter="30">
<a-col :md="20" >
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
</span>
</a-col>
<a-col :md="4" style="margin-top:-65px; z-index: 12;">
<span style="float: right;overflow: hidden;" class="table-page-search-submitButtons">
<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
</span>
</a-col>
</a-row>
<a-row :gutter="24">
<a-col :md="6" :sm="8">
<a-form-item label="关键词">
<a-input placeholder="请输入搜索关键词" v-model="queryParam.name"></a-input>
</a-form-item>
</a-col>
<!-- <a-col :md="6" :sm="8">
<a-form-item label="任务状态">
<a-select placeholder="选择同步状态" option-filter-prop="children" size="large" v-model="queryParam.syncState">
<a-select-option key="">
全部
</a-select-option>
<a-select-option key="0">
未同步
</a-select-option>
<a-select-option key="1">
进行中
</a-select-option>
<a-select-option key="2">
已结束
</a-select-option>
</a-select>
</a-form-item>
</a-col> -->
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
<a-col :md="6" :sm="24" >
<a-button type="primary" style="left: 10px" @click="loadData" icon="search">查询</a-button>
</a-col>
</span>
</a-row>
</a-form>
</div>
<!-- table区域-begin -->
<div style="height:calc(100vh - 300px);overflow:hidden; background: #e6e9f1 !important;">
<div class="linese"></div>
<a-table
ref="table"
size="middle"
style="height:calc(100vh - 344px);"
bordered
rowKey="id"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading"
:rowSelection="{selectedRowKeys: selectedRowKeys,onChange: onSelectChange}"
@change="handleTableChange">
<!-- :locale="myLocale"-->
<!-- 字符串超长截取省略号显示-->
<span slot="name" slot-scope="text">
<j-ellipsis :value="text" :length="20" />
</span>
<span slot="describe" slot-scope="text">
<j-ellipsis :value="text" :length="20" />
</span>
<span slot="action" slot-scope="text, record">
<a @click="handleEdit(record)">编辑</a>
<a-divider type="vertical"/>
<a @click="handleDistribute(record)" >下发任务</a>
<a-divider type="vertical" />
<a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
<a>删除</a>
</a-popconfirm>
</span>
</a-table>
<div class="linese"></div>
</div>
<!-- table区域-end -->
<!-- 表单区域 -->
<taskModal ref="modalForm" @ok="modalFormOk"></taskModal>
</a-card>
</template>
<script>
import taskModal from './modules/taskModal'
import { shipModelPageList,
shipModeldeleteById } from '@/api/ship'
import { taskCreate,
taskUpdateById,
taskQueryById,
taskPageList,
taskDistributeTask,
taskDeleteById } from '@/api/task'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JEllipsis from "@/components/jeecg/JEllipsis";
import guaz from '@assets/guaz.png'
export default {
name: "tasklist",
mixins:[JeecgListMixin],
components: {
taskModal,
JEllipsis,
VNodes: {
functional: true,
render: (h, ctx) => ctx.props.vnodes,
},
},
data () {
return {
description: '任务规划管理',
dataSources: [],
guaz,
queryParam: {
pageNum :1,
pageSize:20
},
columns: [
{
title: '#',
dataIndex: '',
key:'id',
width:60,
align:"id",
customRender:function (t,r,index) {
return parseInt(index)+1;
}
},
{
title: '任务名称',
align:"name",
dataIndex: 'name',
},
{
title: '创建时间',
align:"createTime",
dataIndex: 'createTime'
},
{
title: '开始时间',
align:"startTime",
dataIndex: 'startTime'
},
{
title: '结束时间',
align:"endTime",
dataIndex: 'endTime',
},
{
title: '下发时间',
align:"issuingTime",
dataIndex: 'issuingTime',
},
{
title: '操作',
dataIndex: 'action',
align:"center",
width:180,
scopedSlots: { customRender: 'action' },
}
]
}
},
computed: {
},
created () {
this.loadData();
},
methods: {
//筛选需要重写handleTableChange
handleTableChange(pagination, filters, sorter) {
//分页、排序、筛选变化时触发
//TODO 筛选
if (Object.keys(sorter).length > 0) {
this.isorter.column = sorter.field;
this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
}
this.ipagination = pagination;
this.loadData();
},
loadData() {
taskPageList(this.queryParam).then((res) => {
if (res.success) {
this.dataSource = res.result.rows||res.result;
if(res.result.total)
{
this.ipagination.total = res.result.total;
}
} else {
this.$message.warning(res.message);
}
});
},
handleDelete: function (id) {
var that = this;
taskDeleteById({id: id}).then((res) => {
if (res.success) {
that.$message.success(res.message);
that.loadData();
} else {
that.$message.warning(res.message);
}
});
},
handleEdit: function (record) {
if(record.issuingTime != null){
this.$message.warning("任务已下发禁止编辑");
return;
}
this.$refs.modalForm.edit(record);
this.$refs.modalForm.title = "编辑";
},
handleDistribute:function (record) {
if(record.issuingTime != null){
this.$message.warning("任务已下发禁止重复下发");
return;
}
var that = this;
taskDistributeTask({id: record.id}).then((res) => {
if (res.success) {
that.$message.success(res.message);
that.loadData();
} else {
that.$message.warning(res.message);
}
});
},
handleAdd() {
this.$refs.modalForm.add();
this.$refs.modalForm.title = "新增";
},
}
}
</script>