8 changed files with 395 additions and 11 deletions
@ -0,0 +1,54 @@ |
|||
import request from '@/utils/request' |
|||
|
|||
// 查询类型分页列表
|
|||
export function listType(data) { |
|||
return request({ |
|||
url: '/img/img/type/page', |
|||
method: 'post', |
|||
data: data |
|||
}) |
|||
} |
|||
|
|||
// 新增类型
|
|||
export function addType(data) { |
|||
return request({ |
|||
url: '/img/img/type/insert', |
|||
method: 'post' , |
|||
data: data |
|||
}) |
|||
} |
|||
|
|||
// 修改类型
|
|||
export function editType(data) { |
|||
return request({ |
|||
url: '/img/img/type/update', |
|||
method: 'post' , |
|||
data: data |
|||
}) |
|||
} |
|||
|
|||
// 删除类型
|
|||
export function delType(ids) { |
|||
return request({ |
|||
url: '/img/img/type/delete/' + ids, |
|||
method: 'delete' |
|||
}) |
|||
} |
|||
|
|||
// 获取类型详情
|
|||
export function getTypeDetails(id) { |
|||
return request({ |
|||
url: '/img/img/type/details/' + id, |
|||
method: 'get' |
|||
}) |
|||
} |
|||
|
|||
// 变更类型显示状态
|
|||
export function changeStatus(data) { |
|||
return request({ |
|||
url: '/img/img/type/changeStatus', |
|||
method: 'post' , |
|||
data: data |
|||
}) |
|||
} |
|||
|
|||
@ -0,0 +1,315 @@ |
|||
<template> |
|||
<div class="app-container"> |
|||
<el-row :gutter="20"> |
|||
<!--类型搜索数据--> |
|||
<el-col :span="20" :xs="24"> |
|||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> |
|||
<el-form-item label="类型名称" prop="typeName"> |
|||
<el-input |
|||
v-model="queryParams.typeName" |
|||
placeholder="请输入类型名称" |
|||
clearable |
|||
style="width: 240px" |
|||
@keyup.enter.native="handleQuery" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item label="是否显示" prop="isShow"> |
|||
<el-select v-model="queryParams.isShow" placeholder="是否显示" clearable> |
|||
<el-option |
|||
v-for="item in isShow" |
|||
:key="item.value" |
|||
:label="item.label" |
|||
:value="item.value" |
|||
/> |
|||
</el-select> |
|||
</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="['img:type:add']" |
|||
>新增</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="['img:type:remove']" |
|||
>删除</el-button> |
|||
</el-col> |
|||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar> |
|||
</el-row> |
|||
|
|||
<el-table v-loading="loading" :data="typeList" @selection-change="handleSelectionChange"> |
|||
<el-table-column type="selection" width="50" align="center" /> |
|||
<el-table-column label="编号" align="center" key="id" prop="id" v-if="columns[0].visible" /> |
|||
<el-table-column label="类型名称" align="center" key="typeName" prop="typeName" v-if="columns[1].visible" :show-overflow-tooltip="true" /> |
|||
<el-table-column label="是否显示" align="center" key="isShow" v-if="columns[2].visible"> |
|||
<template slot-scope="scope"> |
|||
<el-switch |
|||
v-model="scope.row.isShow" |
|||
active-value="1" |
|||
inactive-value="0" |
|||
@change="handleStatusChange(scope.row)" |
|||
></el-switch> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column label="排序" align="center" key="sort" prop="sort" v-if="columns[3].visible"/> |
|||
<el-table-column label="创建时间" align="center" prop="createTime" v-if="columns[4].visible" width="160"> |
|||
<template slot-scope="scope"> |
|||
<span>{{ parseTime(scope.row.createTime) }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column label="更新时间" align="center" prop="updateTime" v-if="columns[5].visible" width="160"> |
|||
<template slot-scope="scope"> |
|||
<span>{{ parseTime(scope.row.updateTime) }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column |
|||
label="操作" |
|||
align="center" |
|||
width="160" |
|||
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="['img:type:edit']" |
|||
>修改</el-button> |
|||
<el-button |
|||
size="mini" |
|||
type="text" |
|||
icon="el-icon-delete" |
|||
@click="handleDelete(scope.row)" |
|||
v-hasPermi="['img:type: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" |
|||
/> |
|||
</el-col> |
|||
</el-row> |
|||
|
|||
<!-- 添加或修改图片类型对话框 --> |
|||
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body> |
|||
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> |
|||
<el-row> |
|||
<el-col :span="12"> |
|||
<el-form-item label="类型名称" prop="typeName"> |
|||
<el-input v-model="form.typeName" placeholder="请输入类型名称" maxlength="30" /> |
|||
</el-form-item> |
|||
</el-col> |
|||
</el-row> |
|||
</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 { listType, addType, editType, delType, getTypeDetails, changeStatus } from "@/api/img/type"; |
|||
|
|||
export default { |
|||
name: "Type", |
|||
data() { |
|||
return { |
|||
// 遮罩层 |
|||
loading: true, |
|||
// 选中数组 |
|||
ids: [], |
|||
// 非单个禁用 |
|||
single: true, |
|||
// 非多个禁用 |
|||
multiple: true, |
|||
// 显示搜索条件 |
|||
showSearch: true, |
|||
// 总条数 |
|||
total: 0, |
|||
// 图片类型列表数据 |
|||
typeList: null, |
|||
// 弹出层标题 |
|||
title: "", |
|||
// 是否显示弹出层 |
|||
open: false, |
|||
// 日期范围 |
|||
dateRange: [], |
|||
// 表单参数 |
|||
form: {}, |
|||
defaultProps: { |
|||
children: "children", |
|||
label: "label" |
|||
}, |
|||
isShow: [ |
|||
{ value: 0, label: `否`}, |
|||
{ value: 1, label: `是`} |
|||
], |
|||
// 查询参数 |
|||
queryParams: { |
|||
pageNum: 1, |
|||
pageSize: 10, |
|||
typeName: undefined, |
|||
isShow: undefined |
|||
}, |
|||
// 列信息 |
|||
columns: [ |
|||
{ key: 0, label: `编号`, visible: true }, |
|||
{ key: 1, label: `类型名称`, visible: true }, |
|||
{ key: 2, label: `是否显示`, visible: true }, |
|||
{ key: 3, label: `排序`, visible: true }, |
|||
{ key: 4, label: `创建时间`, visible: true }, |
|||
{ key: 5, label: `更新时间`, visible: true } |
|||
], |
|||
// 表单校验 |
|||
rules: { |
|||
typeName: [ |
|||
{ required: true, message: "类型名称不能为空", trigger: "blur" }, |
|||
{ min: 2, max: 20, message: '类型名称长度必须介于 2 和 20 之间', trigger: 'blur' } |
|||
] |
|||
} |
|||
}; |
|||
}, |
|||
created() { |
|||
this.getList(); |
|||
}, |
|||
methods: { |
|||
/** 查询类型列表 */ |
|||
getList() { |
|||
this.loading = true; |
|||
listType(this.addDateRange(this.queryParams, this.dateRange)).then(response => { |
|||
this.typeList = response.rows; |
|||
this.total = response.total; |
|||
this.loading = false; |
|||
} |
|||
); |
|||
}, |
|||
// 筛选节点 |
|||
filterNode(value, data) { |
|||
if (!value) return true; |
|||
return data.label.indexOf(value) !== -1; |
|||
}, |
|||
// 节点单击事件 |
|||
handleNodeClick(data) { |
|||
this.queryParams.deptId = data.id; |
|||
this.handleQuery(); |
|||
}, |
|||
// 显示状态修改 |
|||
handleStatusChange(row) { |
|||
let text = row.isShow === "1" ? "启用" : "停用"; |
|||
this.$modal.confirm('确认要"' + text + '"id为:"' + row.id + '"类型吗?').then(function() { |
|||
let data = { |
|||
id: row.id, |
|||
status: row.isShow |
|||
} |
|||
return changeStatus(data); |
|||
}).then(() => { |
|||
this.$modal.msgSuccess(text + "成功"); |
|||
}).catch(function() { |
|||
row.isShow = row.isShow === "0" ? "1" : "0"; |
|||
}); |
|||
}, |
|||
// 取消按钮 |
|||
cancel() { |
|||
this.open = false; |
|||
this.reset(); |
|||
}, |
|||
// 表单重置 |
|||
reset() { |
|||
this.form = { |
|||
typeName: undefined, |
|||
isShow: "1" |
|||
}; |
|||
this.resetForm("form"); |
|||
}, |
|||
/** 搜索按钮操作 */ |
|||
handleQuery() { |
|||
this.queryParams.pageNum = 1; |
|||
this.getList(); |
|||
}, |
|||
/** 重置按钮操作 */ |
|||
resetQuery() { |
|||
this.dateRange = []; |
|||
this.resetForm("queryForm"); |
|||
this.handleQuery(); |
|||
}, |
|||
// 多选框选中数据 |
|||
handleSelectionChange(selection) { |
|||
this.ids = selection.map(item => item.id); |
|||
this.single = selection.length != 1; |
|||
this.multiple = !selection.length; |
|||
}, |
|||
/** 新增按钮操作 */ |
|||
handleAdd() { |
|||
this.reset(); |
|||
this.open = true; |
|||
this.title = "添加类型"; |
|||
}, |
|||
/** 修改按钮操作 */ |
|||
handleUpdate(row) { |
|||
this.reset(); |
|||
const id = row.id || this.ids; |
|||
getTypeDetails(id).then(response => { |
|||
this.form = response.data; |
|||
this.open = true; |
|||
this.title = "修改类型"; |
|||
}); |
|||
}, |
|||
/** 提交按钮 */ |
|||
submitForm: function() { |
|||
this.$refs["form"].validate(valid => { |
|||
if (valid) { |
|||
if (this.form.id != undefined) { |
|||
editType(this.form).then(response => { |
|||
this.$modal.msgSuccess("修改成功"); |
|||
this.open = false; |
|||
this.getList(); |
|||
}); |
|||
} else { |
|||
addType(this.form).then(response => { |
|||
this.$modal.msgSuccess("新增成功"); |
|||
this.open = false; |
|||
this.getList(); |
|||
}); |
|||
} |
|||
} |
|||
}); |
|||
}, |
|||
/** 删除按钮操作 */ |
|||
handleDelete(row) { |
|||
const ids = row.id || this.ids; |
|||
this.$modal.confirm('是否确认删除类型编号为"' + ids + '"的数据项?').then(function() { |
|||
return delType(ids); |
|||
}).then(() => { |
|||
this.getList(); |
|||
this.$modal.msgSuccess("删除成功"); |
|||
}).catch(() => {}); |
|||
} |
|||
} |
|||
}; |
|||
</script> |
|||
Loading…
Reference in new issue