parent
10f00542d5
commit
a99ccb3643
@ -0,0 +1,81 @@
|
||||
syntax = "proto3";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
// import "validate/validate.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
|
||||
package api.v1;
|
||||
|
||||
option go_package = "moredoc/api/v1;v1";
|
||||
option java_multiple_files = true;
|
||||
option java_package = "api.v1";
|
||||
|
||||
message Attachment {
|
||||
int64 id = 1;
|
||||
string hash = 2;
|
||||
int64 user_id = 3;
|
||||
int64 type_id = 4;
|
||||
int32 type = 5;
|
||||
int32 is_approved = 6;
|
||||
string path = 7;
|
||||
string name = 8;
|
||||
int64 size = 9;
|
||||
int64 width = 10;
|
||||
int64 height = 11;
|
||||
string ext = 12;
|
||||
string ip = 13;
|
||||
string username = 16; // 用户名称
|
||||
string type_name = 17; // 附件类型名称
|
||||
google.protobuf.Timestamp created_at = 14 [ (gogoproto.stdtime) = true ];
|
||||
google.protobuf.Timestamp updated_at = 15 [ (gogoproto.stdtime) = true ];
|
||||
}
|
||||
|
||||
message DeleteAttachmentRequest { repeated int64 id = 1; }
|
||||
|
||||
message GetAttachmentRequest { int64 id = 1; }
|
||||
|
||||
message ListAttachmentRequest {
|
||||
int64 page = 1;
|
||||
int64 size = 2;
|
||||
string wd = 3; // 搜索关键字
|
||||
repeated int64 is_approved = 4;
|
||||
repeated int64 user_id = 5; // 用户ID
|
||||
repeated int64 type = 6; // 类型
|
||||
string ext = 7; // 扩展名
|
||||
}
|
||||
|
||||
message ListAttachmentReply {
|
||||
int64 total = 1;
|
||||
repeated Attachment attachment = 2;
|
||||
}
|
||||
|
||||
// 附件服务。只有管理员才有权限操作
|
||||
service AttachmentAPI {
|
||||
rpc UpdateAttachment(Attachment) returns (Attachment) {
|
||||
option (google.api.http) = {
|
||||
put : '/api/v1/attachment',
|
||||
body : '*',
|
||||
};
|
||||
}
|
||||
|
||||
rpc DeleteAttachment(DeleteAttachmentRequest)
|
||||
returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
delete : '/api/v1/attachment',
|
||||
};
|
||||
}
|
||||
|
||||
rpc GetAttachment(GetAttachmentRequest) returns (Attachment) {
|
||||
option (google.api.http) = {
|
||||
get : '/api/v1/attachment',
|
||||
};
|
||||
}
|
||||
|
||||
rpc ListAttachment(ListAttachmentRequest) returns (ListAttachmentReply) {
|
||||
option (google.api.http) = {
|
||||
get : '/api/v1/attachment/list',
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,149 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
pb "moredoc/api/v1"
|
||||
"moredoc/middleware/auth"
|
||||
"moredoc/model"
|
||||
"moredoc/util"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
)
|
||||
|
||||
type AttachmentAPIService struct {
|
||||
pb.UnimplementedAttachmentAPIServer
|
||||
dbModel *model.DBModel
|
||||
logger *zap.Logger
|
||||
}
|
||||
|
||||
func NewAttachmentAPIService(dbModel *model.DBModel, logger *zap.Logger) (service *AttachmentAPIService) {
|
||||
return &AttachmentAPIService{dbModel: dbModel, logger: logger.Named("AttachmentAPIService")}
|
||||
}
|
||||
|
||||
// checkPermission 检查用户权限
|
||||
func (s *AttachmentAPIService) checkPermission(ctx context.Context) (userClaims *auth.UserClaims, err error) {
|
||||
var ok bool
|
||||
userClaims, ok = ctx.Value(auth.CtxKeyUserClaims).(*auth.UserClaims)
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.Unauthenticated, ErrorMessageInvalidToken)
|
||||
}
|
||||
|
||||
fullMethod, _ := ctx.Value(auth.CtxKeyFullMethod).(string)
|
||||
if yes := s.dbModel.CheckPermissionByUserId(userClaims.UserId, fullMethod); !yes {
|
||||
return nil, status.Errorf(codes.PermissionDenied, ErrorMessagePermissionDenied)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *AttachmentAPIService) UpdateAttachment(ctx context.Context, req *pb.Attachment) (*pb.Attachment, error) {
|
||||
return &pb.Attachment{}, nil
|
||||
}
|
||||
|
||||
func (s *AttachmentAPIService) DeleteAttachment(ctx context.Context, req *pb.DeleteAttachmentRequest) (*emptypb.Empty, error) {
|
||||
_, err := s.checkPermission(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = s.dbModel.DeleteAttachment(req.Id)
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
return &emptypb.Empty{}, nil
|
||||
}
|
||||
|
||||
func (s *AttachmentAPIService) GetAttachment(ctx context.Context, req *pb.GetAttachmentRequest) (*pb.Attachment, error) {
|
||||
return &pb.Attachment{}, nil
|
||||
}
|
||||
|
||||
func (s *AttachmentAPIService) ListAttachment(ctx context.Context, req *pb.ListAttachmentRequest) (*pb.ListAttachmentReply, error) {
|
||||
_, err := s.checkPermission(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
opt := &model.OptionGetAttachmentList{
|
||||
Page: int(req.Page),
|
||||
Size: int(req.Size_),
|
||||
WithCount: true,
|
||||
QueryIn: make(map[string][]interface{}),
|
||||
}
|
||||
|
||||
if len(req.UserId) > 0 {
|
||||
opt.QueryIn["user_id"] = util.Slice2Interface(req.UserId)
|
||||
}
|
||||
|
||||
if len(req.IsApproved) > 0 {
|
||||
opt.QueryIn["is_approved"] = util.Slice2Interface(req.IsApproved)
|
||||
}
|
||||
|
||||
if len(req.Type) > 0 {
|
||||
opt.QueryIn["type"] = util.Slice2Interface(req.Type)
|
||||
}
|
||||
|
||||
req.Wd = strings.TrimSpace(req.Wd)
|
||||
if req.Wd != "" {
|
||||
wd := "%" + req.Wd + "%"
|
||||
opt.QueryLike = map[string][]interface{}{"name": {wd}}
|
||||
}
|
||||
|
||||
attachments, total, err := s.dbModel.GetAttachmentList(opt)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
var pbAttachments []*pb.Attachment
|
||||
util.CopyStruct(&attachments, &pbAttachments)
|
||||
|
||||
var (
|
||||
userIds []interface{}
|
||||
userIdIndexMap = make(map[int64][]int)
|
||||
)
|
||||
|
||||
for idx, attchment := range pbAttachments {
|
||||
attchment.TypeName = s.dbModel.GetAttachmentTypeName(int(attchment.Type))
|
||||
userIds = append(userIds, attchment.UserId)
|
||||
userIdIndexMap[attchment.UserId] = append(userIdIndexMap[attchment.UserId], idx)
|
||||
pbAttachments[idx] = attchment
|
||||
}
|
||||
|
||||
if size := len(userIds); size > 0 {
|
||||
users, _, _ := s.dbModel.GetUserList(&model.OptionGetUserList{Ids: userIds, Page: 1, Size: size, SelectFields: []string{"id", "username"}})
|
||||
s.logger.Debug("GetUserList", zap.Any("users", users))
|
||||
for _, user := range users {
|
||||
if indexes, ok := userIdIndexMap[user.Id]; ok {
|
||||
for _, idx := range indexes {
|
||||
pbAttachments[idx].Username = user.Username
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return &pb.ListAttachmentReply{Total: total, Attachment: pbAttachments}, nil
|
||||
}
|
||||
|
||||
// 上传头像
|
||||
func (s *AttachmentAPIService) UploadAvatar() {
|
||||
|
||||
}
|
||||
|
||||
// 上传横幅
|
||||
func (s *AttachmentAPIService) UploadBanner() {
|
||||
|
||||
}
|
||||
|
||||
// 上传文档
|
||||
func (s *AttachmentAPIService) UploadDocument() {
|
||||
|
||||
}
|
||||
|
||||
// 上传文档分类封面
|
||||
func (s *AttachmentAPIService) UploadCategoryCover() {
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
import service from '~/utils/request'
|
||||
|
||||
export const updateAttachment = (data) => {
|
||||
return service({
|
||||
url: '/api/v1/attachment',
|
||||
method: 'put',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
export const deleteAttachment = (params) => {
|
||||
return service({
|
||||
url: '/api/v1/attachment',
|
||||
method: 'delete',
|
||||
params,
|
||||
})
|
||||
}
|
||||
|
||||
export const getAttachment = (params) => {
|
||||
return service({
|
||||
url: '/api/v1/attachment',
|
||||
method: 'get',
|
||||
params,
|
||||
})
|
||||
}
|
||||
|
||||
export const listAttachment = (params) => {
|
||||
return service({
|
||||
url: '/api/v1/attachment/list',
|
||||
method: 'get',
|
||||
params,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,232 @@
|
||||
<template>
|
||||
<div>{{ $route.name }}</div>
|
||||
<div>
|
||||
<el-card shadow="never" class="search-card">
|
||||
<FormSearch
|
||||
:fields="searchFormFields"
|
||||
:loading="loading"
|
||||
:show-create="false"
|
||||
:show-delete="true"
|
||||
:disabled-delete="selectedRow.length === 0"
|
||||
@onSearch="onSearch"
|
||||
@onDelete="batchDelete"
|
||||
/>
|
||||
</el-card>
|
||||
<el-card shadow="never" class="mgt-20px">
|
||||
<TableList
|
||||
:table-data="listData"
|
||||
:fields="tableListFields"
|
||||
:show-actions="true"
|
||||
:show-view="false"
|
||||
:show-edit="true"
|
||||
:show-delete="true"
|
||||
:show-select="true"
|
||||
@selectRow="selectRow"
|
||||
@editRow="editRow"
|
||||
@deleteRow="deleteRow"
|
||||
/>
|
||||
</el-card>
|
||||
<el-card shadow="never" class="mgt-20px">
|
||||
<div class="text-right">
|
||||
<el-pagination
|
||||
background
|
||||
:current-page="search.page"
|
||||
:page-sizes="[10, 20, 50, 100, 200]"
|
||||
:page-size="search.size"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="total"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handlePageChange"
|
||||
>
|
||||
</el-pagination>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-dialog
|
||||
:title="friendlink.id ? '编辑附件' : '新增附件'"
|
||||
:visible.sync="formVisible"
|
||||
>
|
||||
<FormFriendlink
|
||||
ref="friendlinkForm"
|
||||
:init-friendlink="friendlink"
|
||||
@success="formFriendlinkSuccess"
|
||||
/>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listAttachment, deleteAttachment } from '~/api/attachment'
|
||||
import TableList from '~/components/TableList.vue'
|
||||
import FormSearch from '~/components/FormSearch.vue'
|
||||
import FormFriendlink from '~/components/FormFriendlink.vue'
|
||||
import { attachmentTypeOptions } from '~/utils/enum'
|
||||
export default {
|
||||
components: { TableList, FormSearch, FormFriendlink },
|
||||
layout: 'admin',
|
||||
created() {},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
formVisible: false,
|
||||
search: {
|
||||
wd: '',
|
||||
page: 1,
|
||||
status: [],
|
||||
size: 10,
|
||||
},
|
||||
listData: [],
|
||||
total: 0,
|
||||
searchFormFields: [],
|
||||
tableListFields: [],
|
||||
selectedRow: [],
|
||||
friendlink: { id: 0 },
|
||||
attachmentTypeOptions,
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
this.initSearchForm()
|
||||
this.initTableListFields()
|
||||
await this.listAttachment()
|
||||
},
|
||||
methods: {
|
||||
async listAttachment() {
|
||||
this.loading = true
|
||||
const res = await listAttachment(this.search)
|
||||
if (res.status === 200) {
|
||||
this.listData = res.data.attachment
|
||||
this.total = res.data.total
|
||||
} else {
|
||||
this.$message.error(res.data.message)
|
||||
}
|
||||
this.loading = false
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.search.size = val
|
||||
this.listAttachment()
|
||||
},
|
||||
handlePageChange(val) {
|
||||
this.search.page = val
|
||||
this.listAttachment()
|
||||
},
|
||||
onSearch(search) {
|
||||
this.search = { ...this.search, page: 1, ...search }
|
||||
this.listAttachment()
|
||||
},
|
||||
onCreate() {
|
||||
this.friendlink = { id: 0 }
|
||||
this.formVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.friendlinkForm.reset()
|
||||
})
|
||||
},
|
||||
editRow(row) {
|
||||
this.formVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.friendlinkForm.clearValidate()
|
||||
this.friendlink = row
|
||||
})
|
||||
},
|
||||
formFriendlinkSuccess() {
|
||||
this.formVisible = false
|
||||
this.listAttachment()
|
||||
},
|
||||
batchDelete() {
|
||||
this.$confirm(
|
||||
`您确定要删除选中的【${this.selectedRow.length}个】附件吗?删除之后不可恢复!`,
|
||||
'温馨提示',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}
|
||||
)
|
||||
.then(async () => {
|
||||
const ids = this.selectedRow.map((item) => item.id)
|
||||
const res = await deleteAttachment({ id: ids })
|
||||
if (res.status === 200) {
|
||||
this.$message.success('删除成功')
|
||||
this.listAttachment()
|
||||
} else {
|
||||
this.$message.error(res.data.message)
|
||||
}
|
||||
})
|
||||
.catch(() => {})
|
||||
},
|
||||
deleteRow(row) {
|
||||
this.$confirm(
|
||||
`您确定要删除附件【${row.name}】吗?删除之后不可恢复!`,
|
||||
'温馨提示',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}
|
||||
)
|
||||
.then(async () => {
|
||||
const res = await deleteAttachment({ id: row.id })
|
||||
if (res.status === 200) {
|
||||
this.$message.success('删除成功')
|
||||
this.listAttachment()
|
||||
} else {
|
||||
this.$message.error(res.data.message)
|
||||
}
|
||||
})
|
||||
.catch(() => {})
|
||||
},
|
||||
selectRow(rows) {
|
||||
this.selectedRow = rows
|
||||
},
|
||||
initSearchForm() {
|
||||
this.searchFormFields = [
|
||||
{
|
||||
type: 'text',
|
||||
label: '关键字',
|
||||
name: 'wd',
|
||||
placeholder: '请输入关键字',
|
||||
},
|
||||
{
|
||||
type: 'select',
|
||||
label: '附件类型',
|
||||
name: 'type',
|
||||
placeholder: '请选择附件类型',
|
||||
multiple: true,
|
||||
options: this.attachmentTypeOptions,
|
||||
},
|
||||
{
|
||||
type: 'select',
|
||||
label: '是否合法',
|
||||
name: 'is_approved',
|
||||
placeholder: '请选择是否合法',
|
||||
multiple: true,
|
||||
options: [
|
||||
{ label: '是', value: 1 },
|
||||
{ label: '否', value: 0 },
|
||||
],
|
||||
},
|
||||
]
|
||||
},
|
||||
initTableListFields() {
|
||||
this.tableListFields = [
|
||||
{ prop: 'id', label: 'ID', width: 80, type: 'number', fixed: 'left' },
|
||||
{ prop: 'type_name', label: '类型', width: 80, fixed: 'left' },
|
||||
{ prop: 'name', label: '名称', minWidth: 150, fixed: 'left' },
|
||||
{
|
||||
prop: 'is_approved',
|
||||
label: '是否合法',
|
||||
width: 80,
|
||||
type: 'bool',
|
||||
},
|
||||
{ prop: 'hash', label: 'HASH', width: 150 },
|
||||
{ prop: 'username', label: '上传者', width: 120 },
|
||||
{ prop: 'size', label: '大小', width: 80, type: 'number' },
|
||||
{ prop: 'width', label: '宽', width: 80 },
|
||||
{ prop: 'height', label: '高', width: 80 },
|
||||
{ prop: 'ext', label: '扩展', width: 80 },
|
||||
{ prop: 'ip', label: 'IP', width: 120 },
|
||||
{ prop: 'created_at', label: '创建时间', width: 160, type: 'datetime' },
|
||||
{ prop: 'updated_at', label: '更新时间', width: 160, type: 'datetime' },
|
||||
]
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style></style>
|
||||
|
@ -1,10 +1,223 @@
|
||||
<template>
|
||||
<div>{{ $route.name }}</div>
|
||||
<div>
|
||||
<el-card shadow="never" class="search-card">
|
||||
<FormSearch
|
||||
:fields="searchFormFields"
|
||||
:loading="loading"
|
||||
:show-create="true"
|
||||
:show-delete="true"
|
||||
:disabled-delete="selectedRow.length === 0"
|
||||
@onSearch="onSearch"
|
||||
@onCreate="onCreate"
|
||||
@onDelete="batchDelete"
|
||||
/>
|
||||
</el-card>
|
||||
<el-card shadow="never" class="mgt-20px">
|
||||
<TableList
|
||||
:table-data="friendlinks"
|
||||
:fields="tableListFields"
|
||||
:show-actions="true"
|
||||
:show-view="false"
|
||||
:show-edit="true"
|
||||
:show-delete="true"
|
||||
:show-select="true"
|
||||
@selectRow="selectRow"
|
||||
@editRow="editRow"
|
||||
@deleteRow="deleteRow"
|
||||
/>
|
||||
</el-card>
|
||||
<el-card shadow="never" class="mgt-20px">
|
||||
<div class="text-right">
|
||||
<el-pagination
|
||||
background
|
||||
:current-page="search.page"
|
||||
:page-sizes="[10, 20, 50, 100, 200]"
|
||||
:page-size="search.size"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="total"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handlePageChange"
|
||||
>
|
||||
</el-pagination>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-dialog
|
||||
:title="friendlink.id ? '编辑友链' : '新增友链'"
|
||||
:visible.sync="formFriendlinkVisible"
|
||||
>
|
||||
<FormFriendlink
|
||||
ref="friendlinkForm"
|
||||
:init-friendlink="friendlink"
|
||||
@success="formFriendlinkSuccess"
|
||||
/>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listFriendlink, deleteFriendlink } from '~/api/friendlink'
|
||||
import TableList from '~/components/TableList.vue'
|
||||
import FormSearch from '~/components/FormSearch.vue'
|
||||
import FormFriendlink from '~/components/FormFriendlink.vue'
|
||||
export default {
|
||||
components: { TableList, FormSearch, FormFriendlink },
|
||||
layout: 'admin',
|
||||
created() {},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
formFriendlinkVisible: false,
|
||||
search: {
|
||||
wd: '',
|
||||
page: 1,
|
||||
status: [],
|
||||
size: 10,
|
||||
},
|
||||
friendlinks: [],
|
||||
total: 0,
|
||||
searchFormFields: [],
|
||||
tableListFields: [],
|
||||
selectedRow: [],
|
||||
friendlink: { id: 0 },
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
this.initSearchForm()
|
||||
this.initTableListFields()
|
||||
await this.listFriendlink()
|
||||
},
|
||||
methods: {
|
||||
async listFriendlink() {
|
||||
this.loading = true
|
||||
const res = await listFriendlink(this.search)
|
||||
if (res.status === 200) {
|
||||
this.friendlinks = res.data.friendlink
|
||||
this.total = res.data.total
|
||||
} else {
|
||||
this.$message.error(res.data.message)
|
||||
}
|
||||
this.loading = false
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.search.size = val
|
||||
this.listFriendlink()
|
||||
},
|
||||
handlePageChange(val) {
|
||||
this.search.page = val
|
||||
this.listFriendlink()
|
||||
},
|
||||
onSearch(search) {
|
||||
this.search = { ...this.search, page: 1, ...search }
|
||||
this.listFriendlink()
|
||||
},
|
||||
onCreate() {
|
||||
this.friendlink = { id: 0 }
|
||||
this.formFriendlinkVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.friendlinkForm.reset()
|
||||
})
|
||||
},
|
||||
editRow(row) {
|
||||
this.formFriendlinkVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.friendlinkForm.clearValidate()
|
||||
this.friendlink = row
|
||||
})
|
||||
},
|
||||
formFriendlinkSuccess() {
|
||||
this.formFriendlinkVisible = false
|
||||
this.listFriendlink()
|
||||
},
|
||||
batchDelete() {
|
||||
this.$confirm(
|
||||
`您确定要删除选中的【${this.selectedRow.length}条】友链吗?删除之后不可恢复!`,
|
||||
'温馨提示',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}
|
||||
)
|
||||
.then(async () => {
|
||||
const ids = this.selectedRow.map((item) => item.id)
|
||||
const res = await deleteFriendlink({ id: ids })
|
||||
if (res.status === 200) {
|
||||
this.$message.success('删除成功')
|
||||
this.listFriendlink()
|
||||
} else {
|
||||
this.$message.error(res.data.message)
|
||||
}
|
||||
})
|
||||
.catch(() => {})
|
||||
},
|
||||
deleteRow(row) {
|
||||
this.$confirm(
|
||||
`您确定要删除友链【${row.title}】吗?删除之后不可恢复!`,
|
||||
'温馨提示',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}
|
||||
)
|
||||
.then(async () => {
|
||||
const res = await deleteFriendlink({ id: row.id })
|
||||
if (res.status === 200) {
|
||||
this.$message.success('删除成功')
|
||||
this.listFriendlink()
|
||||
} else {
|
||||
this.$message.error(res.data.message)
|
||||
}
|
||||
})
|
||||
.catch(() => {})
|
||||
},
|
||||
selectRow(rows) {
|
||||
this.selectedRow = rows
|
||||
},
|
||||
initSearchForm() {
|
||||
this.searchFormFields = [
|
||||
{
|
||||
type: 'text',
|
||||
label: '关键字',
|
||||
name: 'wd',
|
||||
placeholder: '请输入关键字',
|
||||
},
|
||||
{
|
||||
type: 'select',
|
||||
label: '状态',
|
||||
name: 'status',
|
||||
placeholder: '请选择状态',
|
||||
multiple: true,
|
||||
options: [
|
||||
{ label: '启用', value: 0 },
|
||||
{ label: '禁用', value: 1 },
|
||||
],
|
||||
},
|
||||
]
|
||||
},
|
||||
initTableListFields() {
|
||||
this.tableListFields = [
|
||||
{ prop: 'id', label: 'ID', width: 80, type: 'number', fixed: 'left' },
|
||||
{
|
||||
prop: 'status',
|
||||
label: '状态',
|
||||
width: 80,
|
||||
type: 'enum',
|
||||
enum: {
|
||||
1: { label: '禁用', type: 'danger' },
|
||||
0: { label: '启用', type: 'success' },
|
||||
},
|
||||
fixed: 'left',
|
||||
},
|
||||
{ prop: 'title', label: '名称', minWidth: 150, fixed: 'left' },
|
||||
{ prop: 'link', label: '链接', minWidth: 250 },
|
||||
{ prop: 'sort', label: '排序', width: 80, type: 'number' },
|
||||
{ prop: 'description', label: '描述', minWidth: 250 },
|
||||
{ prop: 'created_at', label: '创建时间', width: 160, type: 'datetime' },
|
||||
{ prop: 'updated_at', label: '更新时间', width: 160, type: 'datetime' },
|
||||
]
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style></style>
|
||||
|
Loading…
Reference in new issue