初始化

master
法外狂徒张三 2024-09-06 14:36:51 +08:00
parent bcfe310fb8
commit 2dc79397a8
2 changed files with 354 additions and 0 deletions

44
src/api/api/api.js 100644
View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询我的api列表
export function listApi(query) {
return request({
url: '/market/api/list',
method: 'get',
params: query
})
}
// 查询我的api详细
export function getApi(myId) {
return request({
url: '/market/api/' + myId,
method: 'get'
})
}
// 新增我的api
export function addApi(data) {
return request({
url: '/market/api',
method: 'post',
data: data
})
}
// 修改我的api
export function updateApi(data) {
return request({
url: '/market/api',
method: 'put',
data: data
})
}
// 删除我的api
export function delApi(myId) {
return request({
url: '/market/api/' + myId,
method: 'delete'
})
}

View File

@ -0,0 +1,310 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="用户ID" prop="userId">
<el-input
v-model="queryParams.userId"
placeholder="请输入用户ID"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="商品ID" prop="apiId">
<el-input
v-model="queryParams.apiId"
placeholder="请输入商品ID"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="剩余次数" prop="myNum">
<el-input
v-model="queryParams.myNum"
placeholder="请输入剩余次数"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="购买时间" prop="myTime">
<el-date-picker clearable
v-model="queryParams.myTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择购买时间">
</el-date-picker>
</el-form-item>
<el-form-item label="使用状态" prop="myStates">
<el-input
v-model="queryParams.myStates"
placeholder="请输入使用状态"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['api:api:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['api:api:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['api:api:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['api:api:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="apiList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="${comment}" align="center" prop="myId" />
<el-table-column label="用户ID" align="center" prop="userId" />
<el-table-column label="商品ID" align="center" prop="apiId" />
<el-table-column label="剩余次数" align="center" prop="myNum" />
<el-table-column label="购买时间" align="center" prop="myTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.myTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="使用状态" align="center" prop="myStates" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['api:api:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['api:api:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改我的api对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="用户ID" prop="userId">
<el-input v-model="form.userId" placeholder="请输入用户ID" />
</el-form-item>
<el-form-item label="商品ID" prop="apiId">
<el-input v-model="form.apiId" placeholder="请输入商品ID" />
</el-form-item>
<el-form-item label="剩余次数" prop="myNum">
<el-input v-model="form.myNum" placeholder="请输入剩余次数" />
</el-form-item>
<el-form-item label="购买时间" prop="myTime">
<el-date-picker clearable
v-model="form.myTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择购买时间">
</el-date-picker>
</el-form-item>
<el-form-item label="使用状态" prop="myStates">
<el-input v-model="form.myStates" placeholder="请输入使用状态" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listApi, getApi, delApi, addApi, updateApi } from "/src/api/api/api";
export default {
name: "Api",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
// api
apiList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
userId: null,
apiId: null,
myNum: null,
myTime: null,
myStates: null
},
//
form: {},
//
rules: {
}
};
},
created() {
this.getList();
},
methods: {
/** 查询我的api列表 */
getList() {
this.loading = true;
listApi(this.queryParams).then(response => {
this.apiList = response.data.rows;
this.total = response.data.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
myId: null,
userId: null,
apiId: null,
myNum: null,
myTime: null,
myStates: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.myId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加我的api";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const myId = row.myId || this.ids
getApi(myId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改我的api";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.myId != null) {
updateApi(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addApi(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const myIds = row.myId || this.ids;
this.$modal.confirm('是否确认删除我的api编号为"' + myIds + '"的数据项?').then(function() {
return delApi(myIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('api/api/export', {
...this.queryParams
}, `api_${new Date().getTime()}.xlsx`)
}
}
};
</script>