middleground_code_v2/src/views/intergrationTask/index.vue

539 lines
14 KiB
Vue
Raw Normal View History

2024-03-26 11:18:19 +08:00
<template>
<div class="wraaap">
<div class="left">
<BaseMenuTree
2024-05-08 08:56:31 +08:00
:menuData="treeData"
:filterShow="true"
:Allshow="false"
:treeButton="false"
:filterButtonShow="false"
style="height: 100%"
:treeProps="treeProps"
@handleNodeClick="homeHandleNodeClick"
ref="menuTree"
@add="treeAddHandle"
@append="treeAppendHandle"
@revise="treeReviseHandle"
@remove="treeRemoveHandle"
2024-03-26 11:18:19 +08:00
></BaseMenuTree>
</div>
<div class="right">
<header style="background: #fff; padding: 20px">
<div class="search">
<BaseNewForm
2024-05-08 08:56:31 +08:00
:spanNumber="8"
refName="searchForm"
:formRow="SearchformRow"
:formRule="false"
:ruleForm="searchForm"
:newFlag="true"
:isFunBtn="false"
2024-03-26 11:18:19 +08:00
></BaseNewForm>
</div>
<div class="btn">
<el-button type="primary" @click="searchHandle">搜索</el-button>
<el-button @click="resizeSearchHandle">重置</el-button>
</div>
</header>
<main style="background: #fff; padding: 20px 20px 0">
<div style="margin: 0 0 30px 0">
<el-button type="primary" @click="newPage">新增</el-button>
</div>
<div>
<BaseTable
2024-05-08 08:56:31 +08:00
ref="mainTable"
:tableData="tableData"
:tableColumn="tableColumn"
:funData="funData"
:funWidth="funWidth"
:showIndex="true"
:tabLoading="mainTabLoading"
@onFunc="tableButtonHandle"
:tableHeight="'53vh'"
:border="false"
>
<template #taskStatus="{row}">
{{ row.taskStatus == 1 ? '启用' : '停用' }}
</template>
<template #taskPlugin="{row}">
{{ pluginDist[row.taskPlugin] }}
</template>
</BaseTable>
2024-03-26 11:18:19 +08:00
</div>
</main>
<footer>
<basePage
2024-05-08 08:56:31 +08:00
:pageModel="pageModel"
@update:pageModel="currentChangeHandle"
2024-03-26 11:18:19 +08:00
></basePage>
</footer>
</div>
<baseRightDialog
2024-05-08 08:56:31 +08:00
@handleConfirmClick="handleConfirmClick"
:dialogVisible="rightDialogSwitch"
:title="treeTitle"
@handleClose="rightDialogSwitch = false"
2024-03-26 11:18:19 +08:00
>
<div class="treeChunk" v-if="treeRuleForm.class_superiors_name">
<div class="text">上级节点</div>
<div class="input">
<el-input
2024-05-08 08:56:31 +08:00
:disabled="true"
v-model="treeRuleForm.class_superiors_name"
placeholder=""
2024-03-26 11:18:19 +08:00
></el-input>
</div>
</div>
<div class="treeChunk">
<div class="text">节点名</div>
<div class="input">
<el-input
2024-05-08 08:56:31 +08:00
v-model="treeRuleForm.class_name"
placeholder="请输入节点名"
2024-03-26 11:18:19 +08:00
></el-input>
</div>
</div>
</baseRightDialog>
</div>
</template>
<script>
2024-05-08 08:56:31 +08:00
import basePage from './compoments/basePage.vue'
import BaseMenuTree from './compoments/baseMenuTree'
import BaseNewForm from './compoments/baseNewForm'
import BaseTable from './compoments/baseTable'
import { getUserModuleApi } from '@/api/integrationOption/integrationOption.js'
import baseRightDialog from '@/components/base/baseRightDialog'
import { authApi } from '@/api/apis/auth'
2024-03-26 11:18:19 +08:00
export default {
data() {
return {
rightDialogSwitch: false, //右侧dialog
lookFlag: false, //是否打开查看模式
newFlag: false, //是否打开新增模式
pageModel: {
//页码控制
pageIndex: 1,
total: 10,
2024-05-08 08:56:31 +08:00
limit: 10
2024-03-26 11:18:19 +08:00
},
mainTabLoading: false, //表格loding控制
treeData: [
//左侧分类数据
{
2024-05-08 08:56:31 +08:00
label: '测试',
2024-03-26 11:18:19 +08:00
id: 1,
children: [
{
id: 3,
2024-05-08 08:56:31 +08:00
label: '哈哈'
}
]
}
2024-03-26 11:18:19 +08:00
],
2024-05-08 08:56:31 +08:00
treeForm: { class_name: '', class_superiors: '', class_code: '' },
2024-03-26 11:18:19 +08:00
searchForm: {}, //搜索框数据
SearchformRow: [
//搜索框数据
{
elCol: [
{
2024-05-08 08:56:31 +08:00
type: 'input',
title: '任务编码',
id: 'taskCode',
row: 8
2024-03-26 11:18:19 +08:00
},
{
2024-05-08 08:56:31 +08:00
type: 'input',
title: '任务名称',
id: 'taskName',
row: 8
2024-03-26 11:18:19 +08:00
},
2024-05-08 08:56:31 +08:00
{
type: 'radio',
title: '任务状态',
id: 'taskStatus',
row: 8,
options: [
{
label: '启用',
id: '1'
},
{
label: '停用',
id: '2'
}
]
}
]
}
,
{
elCol: [
{
type: 'select',
title: '插件',
id: 'taskPlugin',
row: 8,
options: []
}
]
}
2024-03-26 11:18:19 +08:00
],
funData: [
//table操作
{
2024-05-08 08:56:31 +08:00
type: 'edit',
text: '编辑',
color: '#5a9cf8'
2024-03-26 11:18:19 +08:00
},
{
2024-05-08 08:56:31 +08:00
type: 'view',
text: '查看',
color: '#5a9cf8'
2024-03-26 11:18:19 +08:00
},
{
2024-05-08 08:56:31 +08:00
type: 'dele',
text: '删除',
color: '#e47470'
}
2024-03-26 11:18:19 +08:00
],
2024-05-08 08:56:31 +08:00
tableData: [], //table主表数据
2024-03-26 11:18:19 +08:00
tableColumn: [
//数据咧数据
{
2024-05-08 08:56:31 +08:00
id: 'taskName',
title: '任务名称'
2024-03-26 11:18:19 +08:00
},
{
2024-05-08 08:56:31 +08:00
id: 'taskCode',
title: '任务编码'
2024-03-26 11:18:19 +08:00
},
{
2024-05-08 08:56:31 +08:00
id: 'taskStatus',
title: '任务状态'
2024-03-26 11:18:19 +08:00
},
{
2024-05-08 08:56:31 +08:00
id: 'taskPlugin',
title: '插件'
2024-03-26 11:18:19 +08:00
},
{
2024-05-08 08:56:31 +08:00
id: 'taskCron',
title: '任务策略'
}
2024-03-26 11:18:19 +08:00
],
treeProps: {
2024-05-08 08:56:31 +08:00
children: 'childClassifications',
label: 'name'
2024-03-26 11:18:19 +08:00
},
2024-05-08 08:56:31 +08:00
treeTitle: '',
2024-03-26 11:18:19 +08:00
treeRuleForm: {},
treeAddFlag: false,
2024-05-08 08:56:31 +08:00
appId: '',//左侧树id
pluginDist: {}//插件字典用于列表显示
}
2024-03-26 11:18:19 +08:00
},
methods: {
// 右dialog提交
async handleConfirmClick() {
if (!this.treeRuleForm.class_name) {
this.$message({
2024-05-08 08:56:31 +08:00
type: 'error',
message: '请输入树名称'
})
return
2024-03-26 11:18:19 +08:00
}
if (this.treeAddFlag) {
const res = await getUserModuleApi(
2024-05-08 08:56:31 +08:00
{
tl: 'integrationTaskClassificationService',
as: 'integrationTaskClassification',
dj: 'saveTaskClassification'
},
this.treeRuleForm
)
2024-03-26 11:18:19 +08:00
if (res.status == 200) {
this.$message({
2024-05-08 08:56:31 +08:00
type: 'success',
message: '保存成功'
})
this.rightDialogSwitch = false
this.initTreeData()
2024-03-26 11:18:19 +08:00
}
} else {
const res = await getUserModuleApi(
2024-05-08 08:56:31 +08:00
{
tl: 'integrationTaskClassificationService',
as: 'integrationTaskClassification',
dj: 'updateTaskClassification'
},
this.treeRuleForm
)
2024-03-26 11:18:19 +08:00
if (res.status == 200) {
this.$message({
2024-05-08 08:56:31 +08:00
type: 'success',
message: '保存成功'
})
this.rightDialogSwitch = false
this.initTreeData()
2024-03-26 11:18:19 +08:00
}
}
},
// 树初始化
async initTreeData() {
const res = await getUserModuleApi(
2024-05-08 08:56:31 +08:00
{
tl: 'sysApplicationService',
as: '',
dj: 'queryEntity'
},
{}
)
2024-03-26 11:18:19 +08:00
if (res.status == 200) {
2024-05-08 08:56:31 +08:00
console.log(res)
this.treeData = res.attribute
this.$nextTick(() => {
this.$refs.menuTree.clickFirst()
})
2024-03-26 11:18:19 +08:00
}
2024-05-08 08:56:31 +08:00
console.log(res, '🌲')
2024-03-26 11:18:19 +08:00
},
// 树添加
treeAppendHandle(data) {
2024-05-08 08:56:31 +08:00
this.treeRuleForm = {}
this.treeTitle = '子节点增加'
this.treeAddFlag = true
this.$set(this.treeRuleForm, 'class_superiors_name', data.class_name)
this.$set(this.treeRuleForm, 'class_superiors', data.id)
this.$set(this.treeRuleForm, 'class_code', data.class_code)
this.$set(this.treeRuleForm, 'lvl', String(data.lvl * 1 + 1))
this.rightDialogSwitch = true
2024-03-26 11:18:19 +08:00
},
treeReviseHandle(data) {
2024-05-08 08:56:31 +08:00
this.treeRuleForm = {}
this.treeAddFlag = false
this.rightDialogSwitch = true
this.$set(this.treeRuleForm, 'id', data.id)
this.$set(this.treeRuleForm, 'class_code', data.class_code)
this.$set(this.treeRuleForm, 'class_name', data.class_name)
this.$set(this.treeRuleForm, 'lvl', String(data.lvl))
this.treeTitle = '子节点编辑'
2024-03-26 11:18:19 +08:00
},
treeRemoveHandle(data) {
2024-05-08 08:56:31 +08:00
this.$confirm('确认删除?')
.then(async() => {
console.log(1)
const res = await getUserModuleApi(
{
tl: 'integrationTaskClassificationService',
as: 'integrationTaskClassification',
dj: 'updateTaskClassificationSts'
},
{
id: data.id //任务id
}
)
console.log(res)
if (res.status == 200) {
this.$nextTick(() => {
this.initTreeData()
})
2024-03-26 11:18:19 +08:00
}
2024-05-08 08:56:31 +08:00
})
.catch(() => {
})
2024-03-26 11:18:19 +08:00
},
// 左侧树加号点击事件
treeAddHandle() {
2024-05-08 08:56:31 +08:00
this.treeRuleForm = {}
this.treeAddFlag = true
this.rightDialogSwitch = true
this.treeTitle = '根节点增加'
this.$set(this.treeRuleForm, 'class_code', new Date().getTime())
this.$set(this.treeRuleForm, 'lvl', '0')
2024-03-26 11:18:19 +08:00
},
// 初始化表单
async initTableData(obj = {}) {
const res = await getUserModuleApi(
2024-05-08 08:56:31 +08:00
{
tl: 'integrationTaskService',
as: '',
dj: 'queryEntityPage'
},
{
pageNum: this.pageModel.pageIndex,
pageSize: this.pageModel.limit,
task_app: this.appId,
...obj,
}
)
console.log(res, 'tabledata')
2024-03-26 11:18:19 +08:00
if (res.status == 200) {
2024-05-08 08:56:31 +08:00
this.tableData = res.attribute.list
this.pageModel.total = res.attribute.total
2024-03-26 11:18:19 +08:00
}
},
// 搜索按钮
searchHandle() {
2024-05-08 08:56:31 +08:00
this.initTableData({ ...this.searchForm })
2024-03-26 11:18:19 +08:00
},
// 重置按钮
resizeSearchHandle() {
2024-05-08 08:56:31 +08:00
this.searchForm = {}
2024-03-26 11:18:19 +08:00
},
// 新建路由跳转
newPage() {
2024-05-08 08:56:31 +08:00
this.$router.push({ name: 'taskAdd' })
2024-03-26 11:18:19 +08:00
},
2024-05-08 08:56:31 +08:00
// 树点击事件
2024-03-26 11:18:19 +08:00
homeHandleNodeClick(data) {
2024-05-08 08:56:31 +08:00
console.log(data, 'data')
this.pageModel.pageIndex = 1
this.pageModel.total = 0
this.pageModel.limit = 10
this.appId = data.id
this.searchForm = {}
this.tableData = []
this.lookFlag = false
this.newFlag = false
//树点击完毕后调用插件查询接口
this.plugSelectInit()
//初始化表单
this.initTableData()
},
//查询条件下啦接口
async plugSelectInit() {
const res = await authApi('sysApplicationPluginService', '', 'queryEntity', '', {
appId: this.appId
})
if (res.status === '200') {
this.pluginDist = {}
res.attribute.forEach(item => {
item.label = item.pluginName
this.$set(this.pluginDist, item.id, item.label)
})
this.SearchformRow[1].elCol[0].options = res.attribute
console.log(this.SearchformRow[1].elCol[0], 'this.SearchformRow[1].elCol[0]')
}
console.log(res, '拿到插件列表')
2024-03-26 11:18:19 +08:00
},
// 页面
currentChangeHandle(pageModel) {
2024-05-08 08:56:31 +08:00
this.pageModel = pageModel
2024-03-26 11:18:19 +08:00
this.$nextTick(() => {
2024-05-08 08:56:31 +08:00
this.initTableData({ ...this.searchForm })
})
2024-03-26 11:18:19 +08:00
},
// 表格按钮
tableButtonHandle(val, item) {
2024-05-08 08:56:31 +08:00
if (item.type === 'view') {
2024-03-26 11:18:19 +08:00
this.$router.push({
2024-05-08 08:56:31 +08:00
name: 'taskAdd',
query: { id: val.id, lookFlag: true }
})
} else if (item.type === 'dele') {
console.log(111)
this.$confirm('确认删除?')
.then(async() => {
const res = await getUserModuleApi(
{
tl: 'integrationTaskService',
as: 'integrationTask',
dj: 'updateIntegrationTaskSts'
},
{
id: val.id //任务id
}
)
if (res.status == 200) {
if (
this.pageModel.total - 1 + this.pageModel.limit <=
this.pageModel.pageIndex * this.pageModel.limit
) {
this.pageModel.pageIndex--
}
this.$nextTick(() => {
this.initTableData({ ...this.searchForm })
})
2024-03-26 11:18:19 +08:00
}
2024-05-08 08:56:31 +08:00
})
.catch((err) => {
console.log(err)
})
} else if (item.type === 'edit') {
this.$router.push({ name: 'taskAdd', query: { id: val.id } })
2024-03-26 11:18:19 +08:00
}
2024-05-08 08:56:31 +08:00
}
2024-03-26 11:18:19 +08:00
},
components: {
BaseMenuTree,
BaseNewForm,
BaseTable,
basePage,
2024-05-08 08:56:31 +08:00
baseRightDialog
2024-03-26 11:18:19 +08:00
},
mounted() {
// this.$refs.menuTree.clickFirst();
2024-05-08 08:56:31 +08:00
// this.initTableData()
this.initTreeData()
2024-03-26 11:18:19 +08:00
},
computed: {
// 操作框的宽度
funWidth() {
2024-05-08 08:56:31 +08:00
return this.funData.length * 70
}
}
}
2024-03-26 11:18:19 +08:00
</script>
<style scoped lang="scss">
.treeChunk {
padding: 20px;
display: flex;
align-items: center;
2024-05-08 08:56:31 +08:00
2024-03-26 11:18:19 +08:00
> .text {
flex: 1;
}
2024-05-08 08:56:31 +08:00
2024-03-26 11:18:19 +08:00
> .input {
flex: 5;
}
}
2024-05-08 08:56:31 +08:00
2024-03-26 11:18:19 +08:00
.wraaap {
display: flex;
2024-05-08 08:56:31 +08:00
2024-03-26 11:18:19 +08:00
.right {
width: 85%;
margin-left: 20px;
border-radius: 20px !important;
}
2024-05-08 08:56:31 +08:00
2024-03-26 11:18:19 +08:00
.left {
border-radius: 20px;
width: 15%;
background-color: #fff;
}
2024-05-08 08:56:31 +08:00
2024-03-26 11:18:19 +08:00
.btn {
display: flex;
justify-content: flex-end;
}
2024-05-08 08:56:31 +08:00
2024-03-26 11:18:19 +08:00
main {
margin-top: 20px;
border-radius: 20px;
}
2024-05-08 08:56:31 +08:00
2024-03-26 11:18:19 +08:00
footer {
margin-top: 15px;
}
2024-05-08 08:56:31 +08:00
2024-03-26 11:18:19 +08:00
header {
border-radius: 20px;
}
}
2024-05-08 08:56:31 +08:00
</style>