fix:项目初始化
This commit is contained in:
@@ -0,0 +1,144 @@
|
||||
<template>
|
||||
<el-dialog :title="title" :visible.sync="Visible" width="780px" center class="ac-dialog" :close-on-click-modal="false" @close="close">
|
||||
<el-form :inline="true" :model="form" :rules="rules" ref="form" class="demo-form-inline" label-width="120px" label-position="right">
|
||||
<el-row :gutter="24">
|
||||
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
|
||||
<el-form-item label="应用图标">
|
||||
<UploadImg @changeImgUrl="changeimgUrl" :img="form.avatar"></UploadImg>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
|
||||
<el-form-item label="应用名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入应用名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
|
||||
<el-form-item label="排序参数" prop="rank">
|
||||
<el-input v-model.number="form.rank" placeholder="请输入排序" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
|
||||
<el-form-item label="是否开启" prop="status">
|
||||
<el-switch v-model="form.status" active-color="#13ce66" inactive-color="#ff4949"></el-switch>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="24">
|
||||
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
|
||||
<el-form-item label="下载地址" prop="download_url">
|
||||
<el-input v-model="form.download_url" placeholder="请输入下载地址" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
|
||||
<el-form-item label="应用标签" prop="created_id">
|
||||
<el-select placeholder="请选择应用标签" clearable v-model="form.tag" @clear="onClear('tag')" style="width: 163px">
|
||||
<el-option v-for="item in changeAppList" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="24">
|
||||
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
|
||||
<el-form-item label="应用描述" prop="desc">
|
||||
<el-input v-model="form.desc" placeholder="请输入应用描述" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="Visible = false"> 取 消 </el-button>
|
||||
<el-button type="primary" @click="submit('form')"> 确 定 </el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script>
|
||||
import UploadImg from '@/components/UploadImg/index'
|
||||
import { changeAppList } from '@/filters/appManagement/appList'
|
||||
import { AppInfoAdd, AppInfoUpdate } from '@/api/appManagement/appList'
|
||||
export default {
|
||||
name: 'AddOrEdit',
|
||||
props: ['data'],
|
||||
components: {
|
||||
UploadImg,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
changeAppList: changeAppList(),
|
||||
Visible: true,
|
||||
title: '',
|
||||
time: [],
|
||||
// 表单数据备份
|
||||
formData: {},
|
||||
// 表单数据
|
||||
form: {
|
||||
avatar: undefined, // 头像
|
||||
rank: 0, // 排序
|
||||
tag: undefined, // 标签
|
||||
name: undefined, // 应用名称
|
||||
download_url: undefined, // 下载地址
|
||||
desc: undefined, // 描述
|
||||
status: false, // 开启状态
|
||||
},
|
||||
rules: {},
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.title = this.data.title
|
||||
if (this.title === '编辑') {
|
||||
this.form = { ...this.data.data }
|
||||
this.formData = Object.assign({}, this.form)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
//TODO:新增应用列表数据
|
||||
add(data) {
|
||||
AppInfoAdd(data).then((res) => {
|
||||
if (res.code === 200) {
|
||||
this.Visible = false
|
||||
this.$message.success('新增成功')
|
||||
} else {
|
||||
this.Visible = false
|
||||
this.$message.error('新增失败')
|
||||
}
|
||||
})
|
||||
},
|
||||
//TODO:编辑应用列表数据
|
||||
update(data) {
|
||||
AppInfoUpdate(data).then((res) => {
|
||||
if (res && res.code === 200) {
|
||||
this.Visible = false
|
||||
this.$message.success('更新成功')
|
||||
} else {
|
||||
this.Visible = false
|
||||
this.$message.error('更新失败')
|
||||
}
|
||||
})
|
||||
},
|
||||
// 提交按钮
|
||||
submit(formName) {
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.title === '新增') {
|
||||
this.add(this.form)
|
||||
} else if (this.title === '编辑') {
|
||||
this.update(this.form)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 关闭编辑
|
||||
close() {
|
||||
this.$emit('close')
|
||||
},
|
||||
// 切换图片
|
||||
changeimgUrl(data) {
|
||||
this.form.avatar = data
|
||||
},
|
||||
onClear(data) {
|
||||
this.form[data] = undefined
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
<template>
|
||||
<div class="pf-warpper avlist">
|
||||
<el-row class="table-form">
|
||||
<el-form :inline="true" :model="searchData.param" class="form-inline" size="mini">
|
||||
<el-form-item>
|
||||
<el-input clearable placeholder="请输入应用名称" v-model="searchData.name" @clear="onClear('app_name')" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-input clearable placeholder="请输入发布者ID" v-model.number="searchData.publicer" @clear="onClear('publicer')" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-date-picker :default-time="['00:00:00', '23:59:59']" end-placeholder="结束日期" range-separator="至" start-placeholder="开始日期" type="datetimerange" v-model="time" value-format="yyyy-MM-ddTHH:mm:ss+08:00" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="onSearch" icon="el-icon-search" plain type="primary">搜索</el-button>
|
||||
<el-button @click="add" icon="el-icon-circle-plus-outline" plain type="success">新增</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col>
|
||||
<el-table :data="resData" element-loading-text="拼命加载中" border height="750" highlight-current-row style="width: 100%" v-loading="loading">
|
||||
<el-table-column align="center" label="排序">
|
||||
<template slot-scope="scope">{{ scope.row.rank }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="应用ID">
|
||||
<template slot-scope="scope">{{ scope.row.id }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="应用名称">
|
||||
<template slot-scope="scope">{{ scope.row.name }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="应用描述">
|
||||
<template slot-scope="scope">{{ scope.row.desc }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="下载地址">
|
||||
<template slot-scope="scope">{{ scope.row.download_url }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="所属标签">
|
||||
<template slot-scope="scope">{{ scope.row.tag | changeAppTagType}}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="是否开启">
|
||||
<template slot-scope="scope">
|
||||
<el-button :type="scope.row.status ? 'success':'error'" plain size="mini">{{ scope.row.status ? '开启' : '关闭' }}</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="发布者ID">
|
||||
<template slot-scope="scope">{{ scope.row.created_id }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="最后更新者ID">
|
||||
<template slot-scope="scope">{{ scope.row.updated_id }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" width="100" label="应用图标">
|
||||
<template slot-scope="scope">
|
||||
<ShowImg style="width:70px; height: 70px; margin: 0 auto" :urls="scope.row.avatar"></ShowImg>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="创建时间" width="180">
|
||||
<template slot-scope="scope">{{
|
||||
scope.row.createdAt | BeiJingTime
|
||||
}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="更新时间" width="180">
|
||||
<template slot-scope="scope">{{
|
||||
scope.row.updatedAt | BeiJingTime
|
||||
}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" fixed="right" label="操作" width="200">
|
||||
<template slot-scope="scope">
|
||||
<el-button @click="handleEdit(scope.$index, scope.row)" size="mini" type="primary">编辑</el-button>
|
||||
<el-button @click="handleDelete(scope.$index, scope.row)" size="mini" type="danger">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<div class="table-pagination">
|
||||
<el-pagination :current-page="searchData.pageNum" :page-size="searchData.pageSize" :page-sizes="[10, 20, 30, 50, 100]" :total="total" @current-change="handleCurrentChange" @size-change="handleSizeChange" layout="total, sizes, prev, pager, next, jumper" />
|
||||
</div>
|
||||
<!-- 新增及编辑 -->
|
||||
<Edit :data="editData" v-if="editVisible" @close="closeEdit" />
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
// 引入模块
|
||||
import Edit from './components/AddOrEdit'
|
||||
import ShowImg from '@/components/ShowImg/index.vue'
|
||||
import { AppInfoDel, AppInfoSearch } from '@/api/appManagement/appList'
|
||||
export default {
|
||||
name: 'AppList',
|
||||
components: {
|
||||
Edit,
|
||||
ShowImg,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 请求列表参数
|
||||
searchData: {
|
||||
name: undefined,
|
||||
end_time: undefined, // 搜索结束时间
|
||||
start_time: undefined, // 搜索开始时间
|
||||
publicer: undefined, // 发布者ID
|
||||
tag: undefined,
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
time: undefined,
|
||||
resData: [], // el-table表格数据
|
||||
editVisible: false, // 新增或编辑弹出框
|
||||
total: 0, // 数据总条数
|
||||
loading: true, // 列表加载状态
|
||||
// 编辑数据
|
||||
editData: {
|
||||
title: '新增',
|
||||
data: {},
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.getGameInfo()
|
||||
},
|
||||
methods: {
|
||||
//TODO:请求应用列表数据
|
||||
getGameInfo() {
|
||||
if (this.time) {
|
||||
this.searchData.start_time = this.time[0]
|
||||
this.searchData.end_time = this.time[1]
|
||||
} else {
|
||||
this.searchData.start_time = undefined
|
||||
this.searchData.end_time = undefined
|
||||
}
|
||||
AppInfoSearch(this.searchData).then((res) => {
|
||||
if (res.code === 200) {
|
||||
this.resData = res.data.list
|
||||
this.total = res.data.total
|
||||
} else {
|
||||
this.resData = []
|
||||
this.total = 0
|
||||
this.$message.error('请求列表失败!')
|
||||
}
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
//TODO:删除应用列表数据
|
||||
handleDelete(index, row) {
|
||||
this.$confirm('确定删除?', '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(() => {
|
||||
AppInfoDel({ id: row.id }).then((res) => {
|
||||
if (res.code === 200) {
|
||||
this.getGameInfo()
|
||||
this.$message.success('成功删除!')
|
||||
} else {
|
||||
this.$message.error('操作失败')
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
onSearch() {
|
||||
this.searchData.pageNum = 1
|
||||
this.searchData.pageSize = 10
|
||||
this.getGameInfo()
|
||||
},
|
||||
|
||||
// 切换每页数据量
|
||||
handleSizeChange(val) {
|
||||
this.searchData.pageSize = val
|
||||
this.getGameInfo()
|
||||
},
|
||||
// 切换页数
|
||||
handleCurrentChange(val) {
|
||||
this.searchData.pageNum = val
|
||||
this.getGameInfo()
|
||||
},
|
||||
|
||||
// 新增按钮
|
||||
add() {
|
||||
this.editVisible = true
|
||||
},
|
||||
|
||||
// 编辑按钮
|
||||
handleEdit(index, row) {
|
||||
this.editVisible = true
|
||||
this.editData = {
|
||||
title: '编辑',
|
||||
data: row,
|
||||
}
|
||||
},
|
||||
|
||||
// 关闭编辑弹窗
|
||||
closeEdit() {
|
||||
this.editData = {
|
||||
title: '新增',
|
||||
data: {},
|
||||
}
|
||||
this.editVisible = false
|
||||
this.getGameInfo()
|
||||
},
|
||||
|
||||
// 清空某一项筛选列表
|
||||
onClear(key) {
|
||||
this.searchData[key] = undefined
|
||||
this.getGameInfo()
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user