<template>
|
<div class="installation viewWrap">
|
<h2>安装运维任务计划管理</h2>
|
<!-- 搜索功能区 -->
|
<div class="wrap">
|
<div class="searchWrap">
|
<div class="searchItem">
|
<span class="searchTitle">开始日期</span>
|
<el-date-picker v-model="startDate" value-format="yyyy-MM-dd" type="date" style="width:220px;"
|
placeholder="选择日期">
|
</el-date-picker>
|
</div>
|
<div class="searchItem">
|
<span class="searchTitle">结束日期</span>
|
<el-date-picker v-model="endDate" value-format="yyyy-MM-dd" type="date" style="width:220px;"
|
placeholder="选择日期">
|
</el-date-picker>
|
</div>
|
<div class="searchButton">
|
<el-button type="primary" @click="onGetSearchData">查询</el-button>
|
<el-button @click="onClearSearchData">清空</el-button>
|
</div>
|
</div>
|
</div>
|
|
<!-- 数据功能按钮区 -->
|
<el-button type="primary" icon="el-icon-plus" style="width: 100px; margin-top: 20px;"
|
@click="handleFormDataAdd">添加</el-button>
|
|
<!-- 数据表格区 -->
|
<el-table stripe :data="tableData" height="0" style="margin-top: 20px;">
|
<el-table-column type="index" label="序号" fixed> </el-table-column>
|
<el-table-column prop="name" label="名称" fixed> </el-table-column>
|
<el-table-column prop="status" label="状态" width="100">
|
<template slot-scope="scope">
|
<el-tag v-if="scope.row.status == 1" type="success">
|
<i class="iconfont icon-kaishi" style="font-size: 12px;"></i>
|
执行中
|
</el-tag>
|
<el-tag v-if="scope.row.status == 0" type="warning">
|
<i class="iconfont icon-zanting" style="font-size: 12px;"></i>
|
暂停
|
</el-tag>
|
<el-tag v-if="scope.row.status == -1" type="danger">
|
<i class="iconfont icon-jieshu" style="font-size: 12px;"></i>
|
结束
|
</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column prop="creatorName" label="创建人" width="100">
|
</el-table-column>
|
<el-table-column prop="dt" label="创建时间" width="170">
|
</el-table-column>
|
<el-table-column prop="startDate" label="开始日期" width="110">
|
</el-table-column>
|
<el-table-column prop="endDate" label="结束日期" width="110">
|
</el-table-column>
|
<el-table-column prop="content" label="作业内容"> </el-table-column>
|
<el-table-column label="操作" width="200" fixed="right">
|
<template slot-scope="scope">
|
<el-button icon="el-icon-edit" @click.native.prevent="handleFormDataEdit(scope.row)" type="text" size="small">
|
编辑
|
</el-button>
|
<el-button v-if="scope.row.status != 0" @click.native.prevent="handleStatus(scope.row, 0, '暂停')" type="text"
|
size="small">
|
<i class="iconfont icon-zanting" style="font-size: 12px;"></i>
|
暂停
|
</el-button>
|
<el-button v-if="scope.row.status != 1" @click.native.prevent="handleStatus(scope.row, 1, '执行')" type="text"
|
size="small">
|
<i class="iconfont icon-kaishi" style="font-size: 12px;"></i>
|
执行
|
</el-button>
|
<el-button v-if="scope.row.status != -1" @click.native.prevent="handleStatus(scope.row, -1, '结束')" type="text"
|
size="small">
|
<i class="iconfont icon-jieshu" style="font-size: 12px;"></i>
|
结束
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<!-- 分页组件 -->
|
<el-pagination style="margin-top: 20px;" @size-change="onGetTableData" @current-change="onGetTableData"
|
:current-page.sync="pageCurr" :page-size.sync="pageSize" :page-sizes="[10, 20, 50, 100]"
|
layout="total, sizes, prev, pager, next, jumper" :total="total">
|
</el-pagination>
|
|
<!-- 表单 -->
|
<el-dialog :title="dialogTitle" :visible.sync="showFromData" width="600px" :before-close="handleFormDataClose">
|
<el-form :model="formData" :rules="formRules" ref="formData" label-width="140px">
|
<el-form-item label="ID" prop="id" style="display: none;">
|
<el-input style="width:220px" v-model="formData.id" disabled></el-input>
|
</el-form-item>
|
<el-form-item label="名称" prop="name">
|
<el-input style="width:220px" v-model="formData.name" clearable></el-input>
|
</el-form-item>
|
<el-form-item label="状态" prop="status">
|
<el-select v-model="formData.status" placeholder="请选择" style="width:220px;" clearable>
|
<el-option label="执行中" :value="1"></el-option>
|
<el-option label="暂停" :value="0"></el-option>
|
<el-option label="停止" :value="-1"></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="作业内容" prop="content">
|
<el-input style="width:220px" v-model="formData.content" clearable></el-input>
|
</el-form-item>
|
<el-form-item label="开始日期" prop="status">
|
<el-date-picker v-model="formData.startDate" value-format="yyyy-MM-dd" type="date" placeholder="选择日期">
|
</el-date-picker>
|
</el-form-item>
|
<el-form-item label="结束日期" prop="endDate">
|
<el-date-picker v-model="formData.endDate" value-format="yyyy-MM-dd" type="date" placeholder="选择日期">
|
</el-date-picker>
|
</el-form-item>
|
</el-form>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="handleFormDataClose">取 消</el-button>
|
<el-button type="primary" @click="handleFormDataSubmit">确 定</el-button>
|
</span>
|
</el-dialog>
|
</div>
|
</template>
|
|
<style lang="less" scoped>
|
.installation {
|
padding: 20px;
|
}
|
</style>
|
|
<script>
|
export default {
|
name: "installation",
|
components: {},
|
data() {
|
return {
|
startDate: null,
|
endDate: null,
|
pageSize: 10,
|
pageCurr: 1,
|
total: 0,
|
tableData: [],
|
showFromData: false,
|
formData: {
|
id: null,
|
name: null,
|
content: null,
|
startDate: null,
|
endDate: null,
|
status: null,
|
},
|
formRules: {
|
name: [{ required: true, message: "必填项", trigger: "blur" }],
|
content: [{ required: true, message: "必填项", trigger: "blur" }],
|
startDate: [{ required: true, message: "必填项", trigger: "blur" }],
|
endDate: [{ required: true, message: "必填项", trigger: "blur" }],
|
status: [{ required: true, message: "必填项", trigger: "blur" }],
|
},
|
dialogTitle: null,
|
};
|
},
|
computed: {},
|
mounted() {
|
this.onGetTableData();
|
},
|
methods: {
|
// 执行条件查询
|
onGetSearchData: function () {
|
this.pageCurr = 1;
|
this.onGetTableData();
|
},
|
// 清空查询条件
|
onClearSearchData: function () {
|
this.startDate = null;
|
this.endDate = null;
|
this.pageCurr = 1;
|
this.onGetTableData();
|
},
|
// 获取表格数据
|
onGetTableData: function () {
|
var that = this;
|
var data = {
|
startDate: this.startDate,
|
endDate: this.endDate,
|
pageSize: this.pageSize,
|
pageCurr: this.pageCurr,
|
};
|
that
|
.$axiosAdmin({
|
method: "post",
|
url: "production/devOps/some",
|
data: JSON.stringify(data),
|
})
|
.then((res) => {
|
if (res.success == true) {
|
that.tableData = res.content.obj;
|
that.total = res.content.itemTotal;
|
} else {
|
that.$alert(res.content, "提示", {
|
confirmButtonText: "确定",
|
});
|
}
|
})
|
.catch((err) => {
|
console.log(err);
|
});
|
},
|
handleFormDataAdd: function () {
|
this.formData.id = null;
|
this.formData.name = null;
|
this.formData.content = null;
|
this.formData.startDate = null;
|
this.formData.endDate = null;
|
this.formData.status = null;
|
this.showFromData = true;
|
this.dialogTitle = "添加安装运维任务计划";
|
},
|
// 关闭
|
handleFormDataClose: function () {
|
this.formData.id = null;
|
this.formData.name = null;
|
this.formData.content = null;
|
this.formData.startDate = null;
|
this.formData.endDate = null;
|
this.formData.status = null;
|
this.showFromData = false;
|
this.dialogTitle = null;
|
this.$refs["formData"].resetFields();
|
},
|
// 编辑
|
handleFormDataEdit: function (row) {
|
this.formData.id = row.id;
|
this.formData.name = row.name;
|
this.formData.content = row.content;
|
this.formData.startDate = row.startDate;
|
this.formData.endDate = row.endDate;
|
this.formData.status = row.status;
|
this.showFromData = true;
|
this.dialogTitle = "编辑安装运维任务计划";
|
},
|
// 提交数据确认
|
handleFormDataSubmit: function () {
|
this.$confirm(`此操作将保存并更新数据, 是否继续?`, "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(() => {
|
this.onFormDataSubmit();
|
})
|
.catch(() => {
|
this.$message({
|
type: "info",
|
message: "已取消",
|
});
|
});
|
},
|
// 提交数据
|
onFormDataSubmit: function () {
|
var that = this;
|
var url, data;
|
if (this.formData.id) {
|
url = "production/devOps/update";
|
data = {
|
id: this.formData.id,
|
name: this.formData.name,
|
content: this.formData.content,
|
startDate: this.formData.startDate,
|
endDate: this.formData.endDate,
|
status: this.formData.status,
|
};
|
} else {
|
url = "production/devOps/save";
|
data = {
|
name: this.formData.name,
|
content: this.formData.content,
|
startDate: this.formData.startDate,
|
endDate: this.formData.endDate,
|
status: this.formData.status,
|
};
|
}
|
that
|
.$axiosAdmin({
|
method: "post",
|
url: url,
|
data: JSON.stringify(data),
|
})
|
.then((res) => {
|
if (res.success == true) {
|
that.$message({
|
type: "success",
|
message: "已成功",
|
});
|
that.handleFormDataClose();
|
that.onGetTableData();
|
} else {
|
that.$alert(res.content, "提示", {
|
confirmButtonText: "确定",
|
});
|
}
|
})
|
.catch((err) => {
|
console.log(err);
|
});
|
},
|
// 状态变更确认
|
handleStatus(row, status, msg) {
|
this.$confirm(`此操作将 ${msg} 该任务, 是否继续?`, "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(() => {
|
this.onStatus(row, status);
|
})
|
.catch(() => {
|
this.onGetTableData();
|
this.$message({
|
type: "info",
|
message: "已取消",
|
});
|
});
|
},
|
// 执行状态变更
|
onStatus: function (row, status) {
|
var that = this;
|
var data = {
|
id: row.id,
|
status: status,
|
};
|
that
|
.$axiosAdmin({
|
method: "post",
|
url: "production/devOps/updateStatus",
|
data: JSON.stringify(data),
|
})
|
.then((res) => {
|
if (res.success == true) {
|
that.$message({
|
type: "success",
|
message: "已成功",
|
});
|
} else {
|
that.$alert(res.content, "提示", {
|
confirmButtonText: "确定",
|
});
|
}
|
that.onGetTableData();
|
})
|
.catch((err) => {
|
console.log(err);
|
that.onGetTableData();
|
});
|
},
|
},
|
};
|
</script>
|