model run+---

This commit is contained in:
ryanmao 2020-09-30 20:26:50 +08:00
parent bf36db90d1
commit d6f6993b98
27 changed files with 828 additions and 57 deletions

10
comm/const.go Normal file
View File

@ -0,0 +1,10 @@
package comm
const (
TimeZero = -62135596800
TimeFmt = "2006-01-02 15:04:05"
TimeFmts = "2006-01-02"
TimeFmtm = "2006-01"
TimeFmtt = "20060102150405"
TimeFmtpck = "2006-01-02T15:04:05.999999999Z"
)

View File

@ -40,11 +40,28 @@ const sqls = `
Target Server Version : 3030001
File Encoding : 65001
Date: 30/09/2020 15:39:55
Date: 30/09/2020 20:03:44
*/
PRAGMA foreign_keys = false;
-- ----------------------------
-- Table structure for sys_param
-- ----------------------------
DROP TABLE IF EXISTS "sys_param";
CREATE TABLE "sys_param" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"key" varchar,
"cont" blob,
"times" datetime
);
-- ----------------------------
-- Records of sys_param
-- ----------------------------
BEGIN;
COMMIT;
-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
@ -127,32 +144,35 @@ BEGIN;
COMMIT;
-- ----------------------------
-- Table structure for t_plungin
-- Table structure for t_plugin
-- ----------------------------
DROP TABLE IF EXISTS "t_plungin";
CREATE TABLE "t_plungin" (
DROP TABLE IF EXISTS "t_plugin";
CREATE TABLE "t_plugin" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"tid" integer NOT NULL,
"title" text,
"type" integer DEFAULT 0,
"para" text,
"cont" text,
"times" datetime
"times" datetime,
"sort" integer DEFAULT 100,
"del" integer DEFAULT 0
);
-- ----------------------------
-- Records of t_plungin
-- Records of t_plugin
-- ----------------------------
BEGIN;
COMMIT;
-- ----------------------------
-- Table structure for t_plungin_run
-- Table structure for t_plugin_run
-- ----------------------------
DROP TABLE IF EXISTS "t_plungin_run";
CREATE TABLE "t_plungin_run" (
DROP TABLE IF EXISTS "t_plugin_run";
CREATE TABLE "t_plugin_run" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"pid" integer,
"mid" integer,
"tid" integer,
"times" datetime,
"timesd" datetime,
@ -162,11 +182,23 @@ CREATE TABLE "t_plungin_run" (
);
-- ----------------------------
-- Records of t_plungin_run
-- Records of t_plugin_run
-- ----------------------------
BEGIN;
COMMIT;
-- ----------------------------
-- Auto increment value for sys_param
-- ----------------------------
-- ----------------------------
-- Indexes structure for table sys_param
-- ----------------------------
CREATE INDEX "main"."key"
ON "sys_param" (
"key" ASC
);
-- ----------------------------
-- Indexes structure for table sys_user
-- ----------------------------
@ -205,11 +237,11 @@ ON "t_output" (
);
-- ----------------------------
-- Auto increment value for t_plungin
-- Auto increment value for t_plugin
-- ----------------------------
-- ----------------------------
-- Auto increment value for t_plungin_run
-- Auto increment value for t_plugin_run
-- ----------------------------
PRAGMA foreign_keys = true;

View File

@ -1,6 +1,23 @@
package core
import (
"math/rand"
"time"
)
var (
JwtKey = ""
JwtCookiePath = "/"
)
// RandomString 随机生成字符串
func RandomString(l int) string {
str := "0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz"
bts := []byte(str)
var result []byte
r := rand.New(rand.NewSource(time.Now().UnixNano()))
for i := 0; i < l; i++ {
result = append(result, bts[r.Intn(len(bts))])
}
return string(result)
}

Binary file not shown.

View File

@ -10,11 +10,28 @@
Target Server Version : 3030001
File Encoding : 65001
Date: 30/09/2020 15:39:55
Date: 30/09/2020 20:03:44
*/
PRAGMA foreign_keys = false;
-- ----------------------------
-- Table structure for sys_param
-- ----------------------------
DROP TABLE IF EXISTS "sys_param";
CREATE TABLE "sys_param" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"key" varchar,
"cont" blob,
"times" datetime
);
-- ----------------------------
-- Records of sys_param
-- ----------------------------
BEGIN;
COMMIT;
-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
@ -97,32 +114,35 @@ BEGIN;
COMMIT;
-- ----------------------------
-- Table structure for t_plungin
-- Table structure for t_plugin
-- ----------------------------
DROP TABLE IF EXISTS "t_plungin";
CREATE TABLE "t_plungin" (
DROP TABLE IF EXISTS "t_plugin";
CREATE TABLE "t_plugin" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"tid" integer NOT NULL,
"title" text,
"type" integer DEFAULT 0,
"para" text,
"cont" text,
"times" datetime
"times" datetime,
"sort" integer DEFAULT 100,
"del" integer DEFAULT 0
);
-- ----------------------------
-- Records of t_plungin
-- Records of t_plugin
-- ----------------------------
BEGIN;
COMMIT;
-- ----------------------------
-- Table structure for t_plungin_run
-- Table structure for t_plugin_run
-- ----------------------------
DROP TABLE IF EXISTS "t_plungin_run";
CREATE TABLE "t_plungin_run" (
DROP TABLE IF EXISTS "t_plugin_run";
CREATE TABLE "t_plugin_run" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"pid" integer,
"mid" integer,
"tid" integer,
"times" datetime,
"timesd" datetime,
@ -132,11 +152,23 @@ CREATE TABLE "t_plungin_run" (
);
-- ----------------------------
-- Records of t_plungin_run
-- Records of t_plugin_run
-- ----------------------------
BEGIN;
COMMIT;
-- ----------------------------
-- Auto increment value for sys_param
-- ----------------------------
-- ----------------------------
-- Indexes structure for table sys_param
-- ----------------------------
CREATE INDEX "main"."key"
ON "sys_param" (
"key" ASC
);
-- ----------------------------
-- Indexes structure for table sys_user
-- ----------------------------
@ -175,11 +207,11 @@ ON "t_output" (
);
-- ----------------------------
-- Auto increment value for t_plungin
-- Auto increment value for t_plugin
-- ----------------------------
-- ----------------------------
-- Auto increment value for t_plungin_run
-- Auto increment value for t_plugin_run
-- ----------------------------
PRAGMA foreign_keys = true;

15
main.go
View File

@ -1,13 +1,16 @@
package main
import (
"github.com/gin-gonic/gin"
ruisUtil "github.com/mgr9525/go-ruisutil"
"gokins/comm"
"gokins/core"
"gokins/route"
"gokins/service/dbService"
"net/http"
"os"
"path/filepath"
"github.com/gin-gonic/gin"
ruisUtil "github.com/mgr9525/go-ruisutil"
)
func init() {
@ -53,6 +56,14 @@ func main() {
println("InitDb err:" + err.Error())
return
}
jwtKey := dbService.GetParam("jwt-key")
jkey := jwtKey.GetString("key")
if jkey == "" {
jkey = core.RandomString(32)
jwtKey.Set("key", jkey)
dbService.SetParam("jwt-key", jwtKey)
}
core.JwtKey = jkey
comm.Gin.Any("/test", func(c *gin.Context) {
data := ruisUtil.NewMap()
data.Set("cont", "你好啊world!")

12
model/sys_param.go Normal file
View File

@ -0,0 +1,12 @@
package model
import (
"time"
)
type SysParam struct {
Id int `xorm:"pk autoincr"`
Key string
Cont []byte
Times time.Time
}

14
model/t_model_run.go Normal file
View File

@ -0,0 +1,14 @@
package model
import (
"time"
)
type TModelRun struct {
Id int `xorm:"pk autoincr"`
Tid int
Uid string
Times time.Time
Timesd time.Time
State int
}

17
model/t_plugin.go Normal file
View File

@ -0,0 +1,17 @@
package model
import (
"time"
)
type TPlugin struct {
Id int `xorm:"pk autoincr"`
Tid int
Type int
Title string
Para string
Cont string
Times time.Time
Sort int
Del int
}

41
models/model_run.go Normal file
View File

@ -0,0 +1,41 @@
package models
import (
"gokins/comm"
"gokins/service/dbService"
"time"
)
type ModelRun struct {
Id int `xorm:"pk autoincr"`
Tid int
Uid string
Times time.Time
Timesd time.Time
State int
Nick string `xorm:"-"`
Times1 string `xorm:"-"`
Times2 string `xorm:"-"`
}
func (ModelRun) TableName() string {
return "t_model_run"
}
func (c *ModelRun) Add() error {
c.State = 0
c.Times = time.Now()
_, err := comm.Db.Insert(c)
return err
}
func (c *ModelRun) ToUI() {
c.Times1 = c.Times.Format(comm.TimeFmt)
if !c.Timesd.IsZero() {
c.Times2 = c.Timesd.Format(comm.TimeFmt)
}
usr := dbService.FindUser(c.Uid)
if usr != nil {
c.Nick = usr.Nick
}
}

42
models/plug.go Normal file
View File

@ -0,0 +1,42 @@
package models
import (
"errors"
"gokins/comm"
"gokins/model"
"time"
)
type Plugin struct {
Id int `xorm:"pk autoincr"`
Tid int
Type int
Title string
Para string
Cont string
Times time.Time
Sort int
}
func (Plugin) TableName() string {
return "t_plugin"
}
func (c *Plugin) Save() error {
var err error
if c.Id > 0 {
_, err = comm.Db.Cols("type", "title", "para", "cont", "sort").Where("id=?", c.Id).Update(c)
} else {
if c.Tid <= 0 {
return errors.New("what?")
}
c.Times = time.Now()
_, err = comm.Db.Insert(c)
}
return err
}
func (c *Plugin) Del(id int) error {
m := &model.TPlugin{Del: 1}
_, err := comm.Db.Cols("del").Where("id=?", id).Update(m)
return err
}

View File

@ -21,4 +21,12 @@ func Init() {
gpModel.Any("/list", core.GinHandler(server.ModelList))
gpModel.Any("/edit", core.GinHandler(server.ModelEdit))
gpModel.Any("/del", core.GinHandler(server.ModelDel))
gpModel.Any("/runs", core.GinHandler(server.ModelRuns))
gpModel.Any("/run", core.GinHandler(server.ModelRun))
gpPlug := comm.Gin.Group("/plug")
gpPlug.Use(utilService.MidNeedLogin)
gpPlug.Any("/list", core.GinHandler(server.PlugList))
gpPlug.Any("/edit", core.GinHandler(server.PlugEdit))
gpPlug.Any("/del", core.GinHandler(server.PlugDel))
}

View File

@ -1,14 +1,14 @@
package server
import (
"gokins/service/sysService"
"gokins/service/dbService"
"github.com/gin-gonic/gin"
ruisUtil "github.com/mgr9525/go-ruisutil"
)
func CommInfo(c *gin.Context) {
root := sysService.FindUser("admin")
root := dbService.FindUser("admin")
info := ruisUtil.NewMap()
info.Set("need_install", root.Pass == "")
c.JSON(200, info)

View File

@ -3,7 +3,7 @@ package server
import (
"gokins/comm"
"gokins/core"
"gokins/service/sysService"
"gokins/service/dbService"
"gokins/service/utilService"
"time"
@ -39,7 +39,7 @@ func Login(c *gin.Context) {
c.String(500, "param err!")
return
}
usr := sysService.FindUserName(name)
usr := dbService.FindUserName(name)
if usr == nil {
c.String(511, "未找到用户!")
return
@ -70,7 +70,7 @@ func Install(c *gin.Context) {
c.String(500, "param err!")
return
}
usr := sysService.FindUser("admin")
usr := dbService.FindUser("admin")
if usr == nil {
c.String(511, "未找到用户!")
return

View File

@ -29,7 +29,7 @@ func ModelList(c *gin.Context, req *ruisUtil.Map) {
}
func ModelEdit(c *gin.Context, req *models.Model) {
if req.Title == "" {
c.String(511, "参数错误")
c.String(500, "param err")
return
}
lguser := utilService.CurrMUser(c)
@ -53,3 +53,39 @@ func ModelDel(c *gin.Context, req *ruisUtil.Map) {
}
c.String(200, fmt.Sprintf("%d", m.Id))
}
func ModelRuns(c *gin.Context, req *ruisUtil.Map) {
pg, _ := req.GetInt("page")
tid, err := req.GetInt("tid")
if err != nil || tid <= 0 {
c.String(500, "param err")
return
}
ls := make([]*models.ModelRun, 0)
ses := comm.Db.Where("tid=?", tid).OrderBy("id DESC")
page, err := core.XormFindPage(ses, &ls, pg, 20)
if err != nil {
c.String(500, "find err:"+err.Error())
return
}
for _, v := range ls {
v.ToUI()
}
c.JSON(200, page)
}
func ModelRun(c *gin.Context, req *ruisUtil.Map) {
id, err := req.GetInt("id")
if err != nil || id <= 0 {
c.String(500, "param err")
return
}
lgusr := utilService.CurrMUser(c)
m := &models.ModelRun{}
m.Tid = int(id)
m.Uid = lgusr.Xid
if err := m.Add(); err != nil {
c.String(500, "add err:"+err.Error())
return
}
c.String(200, fmt.Sprintf("%d", m.Id))
}

51
route/server/plugin.go Normal file
View File

@ -0,0 +1,51 @@
package server
import (
"fmt"
"gokins/comm"
"gokins/model"
"gokins/models"
"github.com/gin-gonic/gin"
ruisUtil "github.com/mgr9525/go-ruisutil"
)
func PlugList(c *gin.Context, req *ruisUtil.Map) {
tid, err := req.GetInt("tid")
if err != nil || tid <= 0 {
c.String(500, "param err")
return
}
ls := make([]*model.TPlugin, 0)
ses := comm.Db.Where("del!='1' and tid=?", tid).OrderBy("sort ASC,id ASC")
err = ses.Find(&ls)
if err != nil {
c.String(500, "find err:"+err.Error())
return
}
c.JSON(200, ls)
}
func PlugEdit(c *gin.Context, req *models.Plugin) {
if req.Title == "" || req.Tid <= 0 {
c.String(500, "param err")
return
}
if err := req.Save(); err != nil {
c.String(500, "save err:"+err.Error())
return
}
c.String(200, fmt.Sprintf("%d", req.Id))
}
func PlugDel(c *gin.Context, req *ruisUtil.Map) {
id, err := req.GetInt("id")
if err != nil || id <= 0 {
c.String(500, "param err")
return
}
m := &models.Plugin{}
if err := m.Del(int(id)); err != nil {
c.String(500, "save err:"+err.Error())
return
}
c.String(200, fmt.Sprintf("%d", m.Id))
}

View File

@ -0,0 +1,21 @@
package dbService
import (
"gokins/comm"
"gokins/model"
)
func GetModel(id int) *model.TModel {
if id <= 0 {
return nil
}
e := new(model.TModel)
ok, err := comm.Db.Where("id=?", id).Get(e)
if err != nil {
return nil
}
if ok {
return e
}
return nil
}

View File

@ -0,0 +1,58 @@
package dbService
import (
"gokins/comm"
"gokins/model"
"time"
ruisUtil "github.com/mgr9525/go-ruisutil"
)
func FindParam(key string) *model.SysParam {
if key == "" {
return nil
}
e := new(model.SysParam)
ok, err := comm.Db.Where("`key`=?", key).Get(e)
if err != nil {
return nil
}
if ok {
return e
}
return nil
}
var mkey = []byte("QXQBPH1X6RRUWNRQ")
var miv = []byte("832S6MU5LTG0A20K")
func GetParam(key string) *ruisUtil.Map {
ret := ruisUtil.NewMap()
v := FindParam(key)
if v != nil {
bts, err := ruisUtil.AESDecrypt(v.Cont, mkey, miv)
if err == nil {
ret = ruisUtil.NewMapo(bts)
}
}
return ret
}
func SetParam(key string, v *ruisUtil.Map) error {
bts, err := ruisUtil.AESEncrypt(v.ToBytes(), mkey, miv)
if err != nil {
return err
}
para := FindParam(key)
if para == nil {
para = &model.SysParam{}
para.Key = key
para.Cont = bts
para.Times = time.Now()
_, err := comm.Db.Insert(para)
return err
} else {
para.Cont = bts
_, err := comm.Db.Where("id=?", para.Id).Update(para)
return err
}
}

View File

@ -1,4 +1,4 @@
package sysService
package dbService
import (
"gokins/comm"

View File

@ -3,7 +3,7 @@ package utilService
import (
"gokins/core"
"gokins/model"
"gokins/service/sysService"
"gokins/service/dbService"
"github.com/gin-gonic/gin"
)
@ -17,7 +17,7 @@ func CurrUser(c *gin.Context) *model.SysUser {
if !ok || xid == "" {
return nil
}
return sysService.FindUser(xid)
return dbService.FindUser(xid)
}
func CurrMUser(c *gin.Context) *model.SysUser {
tu, ok := c.Get("lguser")

View File

@ -23,6 +23,8 @@ let routes = [
iconCls: 'el-icon-message',//图标样式class
children: [
{ path: '/models', component: require('@/views/ruis/ModelList'), name: '流水线' },
{ path: '/models/info', component: require('@/views/ruis/PlugList'), name: '流水线详情', hidden: true },
{ path: '/models/runs', component: require('@/views/ruis/RunList'), name: '流水线运行', hidden: true },
]
},
/*{

View File

@ -79,20 +79,8 @@
},*/formSubmit(){
this.$refs.formd.validate((valid) => {
if (valid) {
var regd=/[^\d\,]/;
if(regd.test(this.formData.phone)){
this.$message({
message: '手机号码列表错误,只能是数字和逗号(,)',
type: 'error'
});
return;
}
var params=this.formData;
params['params']=conts;
params['phones']=this.formData.phone.split(',');
this.formLoading = true;
this.$post('/api/',params).then(res=>{
this.$post('/api/',this.formData).then(res=>{
console.log(res);
this.$emit('submitOK');
this.formLoading = false;

View File

@ -42,13 +42,12 @@
Title: '',
Desc: '',
}
if(e){
if(e)
this.formData={
Id:e.Id,
Title: e.Title,
Desc: e.Desc,
}
}
},/*handleSelect:function(id){
this.tmpltCont='';
if(id==''){

View File

@ -10,22 +10,23 @@
<el-button type="primary" v-on:click="getList">查询</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="$refs.ModelForm.show()">新增</el-button>
<el-button type="primary" @click="$refs.editor.show()">新增</el-button>
</el-form-item>
</el-form>
</el-col>
<!--列表-->
<el-table :data="listdata" highlight-current-row v-loading="loading" @selection-change="selsChange" style="width: 100%;">
<el-table-column type="selection" width="55">
</el-table-column>
<!-- <el-table-column type="selection" width="55">
</el-table-column> -->
<el-table-column type="index" width="60">
</el-table-column>
<el-table-column label="名称" sortable>
<template slot-scope="{row}">
<div class="wxmpTit">
<el-link type="primary" @click="$router.push({path:'/models/runs?id='+row.Id})">
<img :src="row.Avat"/>
<span>{{ row.Title }}</span>
{{ row.Title }}</el-link>
</div>
</template>
</el-table-column>
@ -39,7 +40,8 @@
</el-table-column>
<el-table-column label="操作" width="150">
<template slot-scope="{row}">
<el-button size="small" @click="$refs.ModelForm.show(row)">编辑</el-button>
<el-button size="small" @click="$refs.editor.show(row)">编辑</el-button>
<el-button size="small" @click="$router.push({path:'/models/info?id='+row.Id})">插件</el-button>
<el-popconfirm title="确定要删除吗?" @onConfirm="handleDel(row)">
<el-button type="danger" size="small" slot="reference">删除</el-button>
</el-popconfirm>
@ -49,11 +51,11 @@
<!--工具条-->
<el-col :span="24" class="toolbar">
<el-button type="danger" @click="batchRemove" :disabled="this.sels.length===0">批量删除</el-button>
<!-- <el-button type="danger" @click="batchRemove" :disabled="this.sels.length===0">批量删除</el-button> -->
<el-pagination layout="prev, pager, next" :current-page.sync="filters.page" :total="total" :page-size="limit" @current-change="getList" style="float:right;">
</el-pagination>
</el-col>
<ModelForm ref="ModelForm" @submitOK="getList()"/>
<ModelForm ref="editor" @submitOK="getList()"/>
</section>
</template>

View File

@ -0,0 +1,124 @@
<template>
<el-dialog title="插件编辑" :visible.sync="formVisible" :close-on-click-modal="false">
<el-col :span="24" style="margin-bottom: 20px;">
<el-form :model="formData" label-width="80px" :rules="formRules" ref="formd">
<el-form-item label="名称" prop="Title">
<el-input v-model="formData.Title" auto-complete="off"></el-input>
</el-form-item>
<el-form-item label="类型" prop="Type">
<!-- <el-input v-model="formData.Type" auto-complete="off"></el-input> -->
Shell
</el-form-item>
<el-form-item label="内容" prop="Cont">
<el-input type="textarea" v-model="formData.Cont" auto-complete="off" :rows="20"></el-input>
</el-form-item>
<el-form-item label="排序" prop="Sort">
<el-input v-model="formData.Sort" auto-complete="off"></el-input>
</el-form-item>
</el-form>
</el-col>
<!--工具条-->
<div slot="footer" class="dialog-footer">
<el-button @click.native="formVisible = false">取消</el-button>
<el-button type="primary" @click.native="formSubmit" :loading="formLoading">确认</el-button>
</div>
</el-dialog>
</template>
<script>
export default {
data() {
return {
formVisible:false,
formLoading: false,
formRules: {
Title: [
{ required: true, message: '请输入参数' }
],Type: [
{ required: true, message: '请输入参数' }
],Cont: [
{ required: true, message: '请输入参数' }
],Sort: [
{ required: true, message: '请输入参数' }
]
},
//
formData: {}
}
},
methods: {
show(tid,e){
this.formVisible=true;
this.formData={
Id:'',
Tid:tid,
Type:1,
Title: '',
Para: '',
Cont: '',
Sort: '',
}
if(e)
this.formData={
Id:e.Id,
Tid:e.Tid,
Type:e.Type,
Title: e.Title,
Para: e.Para,
Cont: e.Cont,
Sort: e.Sort,
}
},/*handleSelect:function(id){
this.tmpltCont='';
if(id==''){
return
}
let it=this.tmplatdatas[id];
if(it==null){
return
}
//console.log("123",this.tmplatdatas[id]);
this.tmpltCont=it.Content;
this.tmpltmapls=[];
SmsTmpltKeys(id).then(res=>{
for(let i in res.data){
this.tmpltmapls.push({
key:res.data[i],value:''
});
}
});
},*/formSubmit(){
this.$refs.formd.validate((valid) => {
if (valid) {
this.formLoading = true;
this.$post('/plug/edit',this.formData).then(res=>{
console.log(res);
this.$emit('submitOK');
this.formLoading = false;
this.formVisible = false;
//this.$message('');
}).catch(err=>{
this.$emit('submitErr',err);
this.formLoading = false;
//this.formVisible = false;
this.$message({
message: err.response?err.response.data||'服务器错误':'网络错误',
type: 'error'
});
});
}
});
}
}
};
</script>
<style scoped>
.tmpdesc{
margin-left: 10px;
color:#d0d0d0;
}
</style>

View File

@ -0,0 +1,126 @@
<template>
<section>
<!--工具条-->
<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
<el-form :inline="true">
<el-form-item>
<el-button type="primary" v-on:click="getList">查询</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="$refs.editor.show(tid)">新增</el-button>
</el-form-item>
</el-form>
</el-col>
<!--列表-->
<el-table :data="listdata" highlight-current-row v-loading="loading" @selection-change="selsChange" style="width: 100%;">
<el-table-column type="index" width="60">
</el-table-column>
<el-table-column label="名称" sortable>
<template slot-scope="{row}">
<span>{{ row.Title }}</span>
</template>
</el-table-column>
<el-table-column prop="Sort" label="排序" width="100" sortable>
</el-table-column>
<el-table-column label="状态" width="80">
<template slot-scope="{row}">
<span v-if="row.Cancel" style="color:red">取消授权</span>
<span v-if="!row.Cancel" style="color:green">正常</span>
</template>
</el-table-column>
<el-table-column label="操作" width="150">
<template slot-scope="{row}">
<el-button size="small" @click="$refs.editor.show(tid,row)">编辑</el-button>
<el-popconfirm title="确定要删除吗?" @onConfirm="handleDel(row)">
<el-button type="danger" size="small" slot="reference">删除</el-button>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
<!--工具条-->
<!-- <el-col :span="24" class="toolbar">
<el-button type="danger" @click="batchRemove" :disabled="this.sels.length===0">批量删除</el-button>
</el-col> -->
<PlugForm ref="editor" @submitOK="getList()"/>
</section>
</template>
<script>
import PlugForm from './PlugForm'
//import NProgress from 'nprogress'
export default {
components:{PlugForm},
data() {
return {
tid:'',
loading: false,
total:0,
limit:0,
listdata: [],
sels: [],//
}
},
mounted() {
this.tid=this.$route.query.id;
if(this.tid==null||this.tid==''){
this.$router.push({ path: '/' });
return
}
this.getList();
},
methods: {
//
getList() {
this.loading = true;
//NProgress.start();
this.$post('/plug/list',{tid:this.tid}).then((res) => {
console.log(res);
this.loading = false;
this.listdata = res.data;
//NProgress.done();
}).catch(err=>{
this.$message({
message: err.response.data||'服务器错误',
type: 'error'
});
});
},selsChange(sels) {
this.sels = sels;
},handleAdd(){
},handleEdit(){
},handleDel(et){
this.$post('/plug/del',{id:et.Id}).then(res=>{
//this.$message('');
this.getList();
}).catch(err=>{
this.$message({
message: err.response?err.response.data||'服务器错误':'网络错误',
type: 'error'
});
});
},batchRemove(){
}
}
}
</script>
<style scoped>
.wxmpTit{
line-height: 60px;
margin-top: 5px;
margin-bottom: 5px;
}
.wxmpTit img{
width: 60px;
height: 60px;
float: left;
margin-right: 10px;
}
</style>

View File

@ -0,0 +1,128 @@
<template>
<section>
<!--工具条-->
<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
<el-form :inline="true">
<el-form-item>
<el-button type="primary" v-on:click="getList">刷新</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleRun">运行</el-button>
</el-form-item>
</el-form>
</el-col>
<!--列表-->
<el-table :data="listdata" highlight-current-row v-loading="loading" @selection-change="selsChange" style="width: 100%;">
<el-table-column type="index" width="60">
</el-table-column>
<el-table-column prop="Times1" label="运行时间" width="200" sortable>
</el-table-column>
<el-table-column prop="Times2" label="结束时间" width="200" sortable>
</el-table-column>
<el-table-column prop="Nick" label="执行人" sortable>
</el-table-column>
<el-table-column label="状态" width="80">
<template slot-scope="{row}">
<span v-if="row.State==-1" style="color:red">已停止</span>
<span v-if="row.State==0" style="color:red">等待中</span>
<span v-if="row.State==1" style="color:green">运行中</span>
<span v-if="row.State==2" style="color:green">运行失败</span>
<span v-if="row.State==4" style="color:green">运行成功</span>
</template>
</el-table-column>
<el-table-column label="操作" width="100">
<template scope="{row}">
<el-button type="danger" size="small" @click="handleDel(row)" v-if="row.State==0||row.State==1">停止</el-button>
</template>
</el-table-column>
</el-table>
<!--工具条-->
<el-col :span="24" class="toolbar">
<!-- <el-button type="danger" @click="batchRemove" :disabled="this.sels.length===0">批量删除</el-button> -->
<el-pagination layout="prev, pager, next" :current-page.sync="page" :total="total" :page-size="limit" @current-change="getList" style="float:right;">
</el-pagination>
</el-col>
</section>
</template>
<script>
//import NProgress from 'nprogress'
export default {
data() {
return {
tid:'',
page: 1,
loading: false,
total:0,
limit:0,
listdata: [],
sels: [],//
}
},
mounted() {
this.tid=this.$route.query.id;
if(this.tid==null||this.tid==''){
this.$router.push({ path: '/' });
return
}
this.getList();
},
methods: {
//
getList() {
this.loading = true;
//NProgress.start();
this.$post('/model/runs',{tid:this.tid,page:this.page}).then((res) => {
console.log(res);
this.loading = false;
this.listdata = res.data.Data;
this.total = res.data.Total;
this.limit = res.data.Size;
this.page=res.data.Page;
//NProgress.done();
}).catch(err=>{
this.$message({
message: err.response.data||'服务器错误',
type: 'error'
});
});
},selsChange(sels) {
this.sels = sels;
},handleRun(){
this.$post('/model/run',{id:this.tid}).then(res=>{
//this.$message('');
this.getList();
}).catch(err=>{
this.$message({
message: err.response?err.response.data||'服务器错误':'网络错误',
type: 'error'
});
});
},handleEdit(){
},handleDel(){
},batchRemove(){
}
}
}
</script>
<style scoped>
.wxmpTit{
line-height: 60px;
margin-top: 5px;
margin-bottom: 5px;
}
.wxmpTit img{
width: 60px;
height: 60px;
float: left;
margin-right: 10px;
}
</style>