删除文件
This commit is contained in:
parent
b97a15015d
commit
668bfa765b
@ -1,173 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using SqlSugar;
|
|
||||||
using Infrastructure;
|
|
||||||
using Infrastructure.Attribute;
|
|
||||||
using Infrastructure.Enums;
|
|
||||||
using Infrastructure.Model;
|
|
||||||
using Mapster;
|
|
||||||
using ZR.Model.Dto;
|
|
||||||
using ZR.Model.Models;
|
|
||||||
using ZR.Service.Business;
|
|
||||||
using ZR.Admin.WebApi.Extensions;
|
|
||||||
using ZR.Admin.WebApi.Filters;
|
|
||||||
using ZR.Common;
|
|
||||||
using Infrastructure.Extensions;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace ZR.Admin.WebApi.Controllers
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 代码生成演示Controller
|
|
||||||
///
|
|
||||||
/// @author zr
|
|
||||||
/// @date 2021-12-01
|
|
||||||
/// </summary>
|
|
||||||
[Verify]
|
|
||||||
[Route("business/Gendemo")]
|
|
||||||
public class GendemoController : BaseController
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 代码生成演示接口
|
|
||||||
/// </summary>
|
|
||||||
private readonly IGendemoService _GendemoService;
|
|
||||||
|
|
||||||
public GendemoController(IGendemoService GendemoService)
|
|
||||||
{
|
|
||||||
_GendemoService = GendemoService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查询代码生成演示列表
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("list")]
|
|
||||||
[ActionPermissionFilter(Permission = "business:gendemo:list")]
|
|
||||||
public IActionResult QueryGendemo([FromQuery] GendemoQueryDto parm)
|
|
||||||
{
|
|
||||||
//开始拼装查询条件
|
|
||||||
var predicate = Expressionable.Create<Gendemo>();
|
|
||||||
|
|
||||||
//搜索条件查询语法参考Sqlsugar
|
|
||||||
//predicate = predicate.And(m => m.Name.Contains(parm.Name));
|
|
||||||
predicate = predicate.AndIF(parm.Id > 0, m => m.Id == parm.Id);
|
|
||||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.Name), m => m.Name.Contains(parm.Name));
|
|
||||||
predicate = predicate.AndIF(parm.ShowStatus > 0, m => m.ShowStatus == parm.ShowStatus);
|
|
||||||
predicate = predicate.AndIF(parm.BeginTime != null, it => it.AddTime >= parm.BeginTime);
|
|
||||||
predicate = predicate.AndIF(parm.EndTime != null, it => it.AddTime <= parm.EndTime);
|
|
||||||
|
|
||||||
var response = _GendemoService.GetPages(predicate.ToExpression(), parm, x => x.Sort, "desc");
|
|
||||||
return SUCCESS(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查询代码生成演示详情
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="Id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("{Id}")]
|
|
||||||
[ActionPermissionFilter(Permission = "business:gendemo:query")]
|
|
||||||
public IActionResult GetGendemo(int Id)
|
|
||||||
{
|
|
||||||
var response = _GendemoService.GetFirst(x => x.Id == Id);
|
|
||||||
|
|
||||||
return SUCCESS(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 添加代码生成演示
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost]
|
|
||||||
[ActionPermissionFilter(Permission = "business:gendemo:add")]
|
|
||||||
[Log(Title = "代码生成演示", BusinessType = BusinessType.INSERT)]
|
|
||||||
public IActionResult AddGendemo([FromBody] GendemoDto parm)
|
|
||||||
{
|
|
||||||
if (parm == null)
|
|
||||||
{
|
|
||||||
throw new CustomException("请求参数错误");
|
|
||||||
}
|
|
||||||
//从 Dto 映射到 实体
|
|
||||||
var model = parm.Adapt<Gendemo>().ToCreate(HttpContext);
|
|
||||||
|
|
||||||
return SUCCESS(_GendemoService.Insert(model, it => new
|
|
||||||
{
|
|
||||||
it.Name,
|
|
||||||
it.Icon,
|
|
||||||
it.ShowStatus,
|
|
||||||
it.AddTime,
|
|
||||||
it.Sex,
|
|
||||||
it.Sort,
|
|
||||||
it.BeginTime,
|
|
||||||
it.EndTime,
|
|
||||||
it.Remark,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 更新代码生成演示
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPut]
|
|
||||||
[ActionPermissionFilter(Permission = "business:gendemo:update")]
|
|
||||||
[Log(Title = "代码生成演示", BusinessType = BusinessType.UPDATE)]
|
|
||||||
public IActionResult UpdateGendemo([FromBody] GendemoDto parm)
|
|
||||||
{
|
|
||||||
if (parm == null)
|
|
||||||
{
|
|
||||||
throw new CustomException("请求实体不能为空");
|
|
||||||
}
|
|
||||||
//从 Dto 映射到 实体
|
|
||||||
var model = parm.Adapt<Gendemo>().ToUpdate(HttpContext);
|
|
||||||
|
|
||||||
var response = _GendemoService.Update(w => w.Id == model.Id, it => new Gendemo()
|
|
||||||
{
|
|
||||||
//Update 字段映射
|
|
||||||
Name = model.Name,
|
|
||||||
Icon = model.Icon,
|
|
||||||
ShowStatus = model.ShowStatus,
|
|
||||||
Sex = model.Sex,
|
|
||||||
Sort = model.Sort,
|
|
||||||
BeginTime = model.BeginTime,
|
|
||||||
EndTime = model.EndTime,
|
|
||||||
Remark = model.Remark,
|
|
||||||
});
|
|
||||||
|
|
||||||
return SUCCESS(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 删除代码生成演示
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpDelete("{ids}")]
|
|
||||||
[ActionPermissionFilter(Permission = "business:gendemo:delete")]
|
|
||||||
[Log(Title = "代码生成演示", BusinessType = BusinessType.DELETE)]
|
|
||||||
public IActionResult DeleteGendemo(string ids)
|
|
||||||
{
|
|
||||||
int[] idsArr = Tools.SpitIntArrary(ids);
|
|
||||||
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
|
|
||||||
|
|
||||||
var response = _GendemoService.Delete(idsArr);
|
|
||||||
|
|
||||||
return SUCCESS(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 代码生成演示导出
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[Log(BusinessType = BusinessType.EXPORT, IsSaveResponseData = false, Title = "代码生成演示")]
|
|
||||||
[HttpGet("export")]
|
|
||||||
[ActionPermissionFilter(Permission = "business:gendemo:export")]
|
|
||||||
public IActionResult Export()
|
|
||||||
{
|
|
||||||
var list = _GendemoService.GetAll();
|
|
||||||
|
|
||||||
string sFileName = ExportExcel(list, "Gendemo", "代码生成演示");
|
|
||||||
return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,38 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using ZR.Model.Dto;
|
|
||||||
using ZR.Model.Models;
|
|
||||||
|
|
||||||
namespace ZR.Model.Dto
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 代码生成演示输入对象
|
|
||||||
/// </summary>
|
|
||||||
public class GendemoDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public string Icon { get; set; }
|
|
||||||
public int ShowStatus { get; set; }
|
|
||||||
public DateTime? AddTime { get; set; }
|
|
||||||
public int? Sex { get; set; }
|
|
||||||
public int? Sort { get; set; }
|
|
||||||
public DateTime? BeginTime { get; set; }
|
|
||||||
public DateTime? EndTime { get; set; }
|
|
||||||
public string Remark { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 代码生成演示查询对象
|
|
||||||
/// </summary>
|
|
||||||
public class GendemoQueryDto : PagerInfo
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public int ShowStatus { get; set; }
|
|
||||||
public DateTime AddTime { get; set; }
|
|
||||||
|
|
||||||
public DateTime? BeginTime { get; set; }
|
|
||||||
public DateTime? EndTime { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,69 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using SqlSugar;
|
|
||||||
|
|
||||||
namespace ZR.Model.Models
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 代码生成演示,数据实体对象
|
|
||||||
///
|
|
||||||
/// @author zr
|
|
||||||
/// @date 2021-12-01
|
|
||||||
/// </summary>
|
|
||||||
[SugarTable("gen_demo")]
|
|
||||||
[Tenant("0")]
|
|
||||||
public class Gendemo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 描述 : 自增id
|
|
||||||
/// 空值 : false
|
|
||||||
/// </summary>
|
|
||||||
[SqlSugar.SugarColumn(IsPrimaryKey = false, IsIdentity = true)]
|
|
||||||
public int Id { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 描述 : 名称
|
|
||||||
/// 空值 : false
|
|
||||||
/// </summary>
|
|
||||||
public string Name { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 描述 : 图片
|
|
||||||
/// 空值 : true
|
|
||||||
/// </summary>
|
|
||||||
public string Icon { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 描述 : 显示状态
|
|
||||||
/// 空值 : false
|
|
||||||
/// </summary>
|
|
||||||
public int ShowStatus { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 描述 : 添加时间
|
|
||||||
/// 空值 : true
|
|
||||||
/// </summary>
|
|
||||||
public DateTime? AddTime { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 描述 : 用户性别
|
|
||||||
/// 空值 : true
|
|
||||||
/// </summary>
|
|
||||||
public int? Sex { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 描述 : 排序
|
|
||||||
/// 空值 : true
|
|
||||||
/// </summary>
|
|
||||||
public int? Sort { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 描述 : 开始时间
|
|
||||||
/// 空值 : true
|
|
||||||
/// </summary>
|
|
||||||
public DateTime? BeginTime { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 描述 : 结束时间
|
|
||||||
/// 空值 : true
|
|
||||||
/// </summary>
|
|
||||||
public DateTime? EndTime { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 描述 : 备注
|
|
||||||
/// 空值 : true
|
|
||||||
/// </summary>
|
|
||||||
public string Remark { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Infrastructure.Attribute;
|
|
||||||
using ZR.Repository.System;
|
|
||||||
using ZR.Model.Models;
|
|
||||||
|
|
||||||
namespace ZR.Repository
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 代码生成演示仓储
|
|
||||||
///
|
|
||||||
/// @author zr
|
|
||||||
/// @date 2021-12-01
|
|
||||||
/// </summary>
|
|
||||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
|
||||||
public class GendemoRepository : BaseRepository<Gendemo>
|
|
||||||
{
|
|
||||||
#region 业务逻辑代码
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using ZR.Model.Models;
|
|
||||||
|
|
||||||
namespace ZR.Service.Business
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 代码生成演示service接口
|
|
||||||
///
|
|
||||||
/// @author zr
|
|
||||||
/// @date 2021-12-01
|
|
||||||
/// </summary>
|
|
||||||
public interface IGendemoService: IBaseService<Gendemo>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
using System;
|
|
||||||
using ZR.Model.Models;
|
|
||||||
using ZR.Model.System;
|
|
||||||
|
|
||||||
namespace ZR.Service.System
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 参数配置service接口
|
|
||||||
///
|
|
||||||
/// @author zhaorui
|
|
||||||
/// @date 2021-09-29
|
|
||||||
/// </summary>
|
|
||||||
public interface ISysConfigService: IBaseService<SysConfig>
|
|
||||||
{
|
|
||||||
SysConfig GetSysConfigByKey(string key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,67 +0,0 @@
|
|||||||
import request from '@/utils/request'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 代码生成演示分页查询
|
|
||||||
* @param {查询条件} data
|
|
||||||
*/
|
|
||||||
export function listGendemo(query) {
|
|
||||||
return request({
|
|
||||||
url: 'business/Gendemo/list',
|
|
||||||
method: 'get',
|
|
||||||
params: query,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增代码生成演示
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
export function addGendemo(data) {
|
|
||||||
return request({
|
|
||||||
url: 'business/Gendemo',
|
|
||||||
method: 'post',
|
|
||||||
data: data,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改代码生成演示
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
export function updateGendemo(data) {
|
|
||||||
return request({
|
|
||||||
url: 'business/Gendemo',
|
|
||||||
method: 'PUT',
|
|
||||||
data: data,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取代码生成演示详情
|
|
||||||
* @param {Id}
|
|
||||||
*/
|
|
||||||
export function getGendemo(id) {
|
|
||||||
return request({
|
|
||||||
url: 'business/Gendemo/' + id,
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除代码生成演示
|
|
||||||
* @param {主键} pid
|
|
||||||
*/
|
|
||||||
export function delGendemo(pid) {
|
|
||||||
return request({
|
|
||||||
url: 'business/Gendemo/' + pid,
|
|
||||||
method: 'delete'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// 导出代码生成演示
|
|
||||||
export function exportGendemo(query) {
|
|
||||||
return request({
|
|
||||||
url: 'business/Gendemo/export',
|
|
||||||
method: 'get',
|
|
||||||
params: query
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@ -1,355 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="app-container">
|
|
||||||
<!-- :model属性用于表单验证使用 比如下面的el-form-item 的 prop属性用于对表单值进行验证操作 -->
|
|
||||||
<el-form :model="queryParams" label-position="left" inline ref="queryForm" :label-width="labelWidth" v-show="showSearch" @submit.native.prevent>
|
|
||||||
<el-form-item label="自增id" :label-width="labelWidth">
|
|
||||||
<el-input v-model.number="queryParams.id" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="名称" :label-width="labelWidth">
|
|
||||||
<el-input v-model="queryParams.name" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="显示状态" :label-width="labelWidth" prop="showStatus">
|
|
||||||
<el-select v-model="queryParams.showStatus">
|
|
||||||
<el-option v-for="item in showStatusOptions" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue"></el-option>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="时间">
|
|
||||||
<el-date-picker v-model="timeRange" size="small" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期"
|
|
||||||
end-placeholder="结束日期"></el-date-picker>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-row class="mb8" style="text-align:center">
|
|
||||||
<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-row>
|
|
||||||
</el-form>
|
|
||||||
|
|
||||||
<!-- 工具区域 -->
|
|
||||||
<el-row :gutter="10" class="mb8">
|
|
||||||
<el-col :span="1.5">
|
|
||||||
<el-button type="primary" v-hasPermi="['business:gendemo:add']" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="1.5">
|
|
||||||
<el-button type="success" :disabled="single" v-hasPermi="['business:gendemo:update']" plain icon="el-icon-edit" size="mini"
|
|
||||||
@click="handleUpdate">修改</el-button>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="1.5">
|
|
||||||
<el-button type="danger" :disabled="multiple" v-hasPermi="['business:gendemo:delete']" plain icon="el-icon-delete" size="mini"
|
|
||||||
@click="handleDelete">删除</el-button>
|
|
||||||
</el-col>
|
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<!-- 数据区域 -->
|
|
||||||
<el-table :data="dataList" ref="table" border @selection-change="handleSelectionChange">
|
|
||||||
<el-table-column type="selection" width="50" />
|
|
||||||
<el-table-column prop="id" label="自增id" align="center" />
|
|
||||||
<el-table-column prop="name" label="名称" align="center" :show-overflow-tooltip="true" />
|
|
||||||
<el-table-column prop="icon" label="图片">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<el-image class="table-td-thumb" :src="scope.row.icon" :preview-src-list="[scope.row.icon]"></el-image>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="showStatus" label="显示状态" align="center" :formatter="showStatusFormat" />
|
|
||||||
<el-table-column prop="addTime" label="添加时间" align="center" />
|
|
||||||
<el-table-column prop="sex" label="用户性别" align="center" :formatter="sexFormat" />
|
|
||||||
<el-table-column prop="sort" label="排序" align="center" />
|
|
||||||
<el-table-column prop="beginTime" label="开始时间" align="center" />
|
|
||||||
<el-table-column prop="endTime" label="结束时间" align="center" />
|
|
||||||
<el-table-column prop="remark" label="备注" align="center" :show-overflow-tooltip="true" />
|
|
||||||
|
|
||||||
<el-table-column label="操作" align="center" width="200">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<el-button v-hasPermi="['business:gendemo:update']" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">编辑</el-button>
|
|
||||||
<el-popconfirm title="确定删除吗?" @confirm="handleDelete(scope.row)" style="margin-left:10px">
|
|
||||||
<el-button slot="reference" v-hasPermi="['business:gendemo:delete']" type="text" icon="el-icon-delete">删除</el-button>
|
|
||||||
</el-popconfirm>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
<pagination class="mt10" background :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
|
||||||
|
|
||||||
<!-- 添加或修改菜单对话框 -->
|
|
||||||
<el-dialog :title="title" :lock-scroll="false" :visible.sync="open">
|
|
||||||
<el-form ref="form" :model="form" :rules="rules" :label-width="formLabelWidth">
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="名称" :label-width="labelWidth" prop="name">
|
|
||||||
<el-input v-model="form.name" placeholder="请输入名称" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="图片" :label-width="labelWidth" prop="icon">
|
|
||||||
<el-upload class="avatar-uploader" name="file" :action="uploadUrl" :show-file-list="false" :on-success="handleUploadIconSuccess"
|
|
||||||
:before-upload="beforeFileUpload">
|
|
||||||
<el-image v-if="form.icon" :src="form.icon" class="icon" />
|
|
||||||
<i v-else class="el-icon-plus uploader-icon"></i>
|
|
||||||
</el-upload>
|
|
||||||
<el-input v-model="form.icon" placeholder="请上传文件或手动输入文件地址"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="显示状态" :label-width="labelWidth" prop="showStatus">
|
|
||||||
<el-select v-model="form.showStatus">
|
|
||||||
<el-option v-for="item in showStatusOptions" :key="item.dictValue" :label="item.dictLabel" :value="parseInt(item.dictValue)">
|
|
||||||
</el-option>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="用户性别" :label-width="labelWidth" prop="sex">
|
|
||||||
<el-radio-group v-model="form.sex">
|
|
||||||
<el-radio v-for="item in sexOptions" :key="item.dictValue" :label="parseInt(item.dictValue)">{{item.dictLabel}}</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="排序" :label-width="labelWidth" prop="sort">
|
|
||||||
<el-input-number v-model.number="form.sort" placeholder="请输入排序" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="开始时间" :label-width="labelWidth" prop="beginTime">
|
|
||||||
<el-date-picker v-model="form.beginTime" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" type="datetime"
|
|
||||||
placeholder="选择日期时间"> </el-date-picker>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="结束时间" :label-width="labelWidth" prop="endTime">
|
|
||||||
<el-date-picker v-model="form.endTime" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" type="datetime"
|
|
||||||
placeholder="选择日期时间"> </el-date-picker>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="备注" :label-width="labelWidth" prop="remark">
|
|
||||||
<editor v-model="form.remark" :min-height="200" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
</el-row>
|
|
||||||
</el-form>
|
|
||||||
<div slot="footer" class="dialog-footer" v-if="btnSubmitVisible">
|
|
||||||
<el-button @click="cancel">取 消</el-button>
|
|
||||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
|
||||||
</div>
|
|
||||||
</el-dialog>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<script>
|
|
||||||
import {
|
|
||||||
listGendemo,
|
|
||||||
addGendemo,
|
|
||||||
delGendemo,
|
|
||||||
updateGendemo,
|
|
||||||
getGendemo,
|
|
||||||
} from "@/api/business/gendemo.js";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: "Gendemo",
|
|
||||||
components: {},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
labelWidth: "100px",
|
|
||||||
formLabelWidth: "100px",
|
|
||||||
// 选中id数组
|
|
||||||
ids: [],
|
|
||||||
// 非单个禁用
|
|
||||||
single: true,
|
|
||||||
// 非多个禁用
|
|
||||||
multiple: true,
|
|
||||||
// 遮罩层
|
|
||||||
loading: true,
|
|
||||||
// 显示搜索条件
|
|
||||||
showSearch: true,
|
|
||||||
// 查询参数
|
|
||||||
queryParams: {},
|
|
||||||
// 弹出层标题
|
|
||||||
title: "",
|
|
||||||
// 是否显示弹出层
|
|
||||||
open: false,
|
|
||||||
// 表单参数
|
|
||||||
form: {},
|
|
||||||
// 时间范围数组
|
|
||||||
timeRange: [],
|
|
||||||
// 显示状态选项列表
|
|
||||||
showStatusOptions: [],
|
|
||||||
// 用户性别选项列表
|
|
||||||
sexOptions: [],
|
|
||||||
//文件上传前判断方法
|
|
||||||
uploadUrl: process.env.VUE_APP_BASE_API + "upload/SaveFile",
|
|
||||||
|
|
||||||
// 数据列表
|
|
||||||
dataList: [],
|
|
||||||
// 总记录数
|
|
||||||
total: 0,
|
|
||||||
// 提交按钮是否显示
|
|
||||||
btnSubmitVisible: true,
|
|
||||||
// 表单校验
|
|
||||||
rules: {
|
|
||||||
id: [{ type: "number", message: "id必须为数字值", trigger: "blur" }],
|
|
||||||
name: [{ required: true, message: "请输入名称", trigger: "blur" }],
|
|
||||||
showStatus: [
|
|
||||||
{ required: true, message: "请输入显示状态", trigger: "blur" },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
// 列表数据查询
|
|
||||||
this.getList();
|
|
||||||
|
|
||||||
this.getDicts("sys_show_hide").then((response) => {
|
|
||||||
this.showStatusOptions = response.data;
|
|
||||||
});
|
|
||||||
this.getDicts("sys_user_sex").then((response) => {
|
|
||||||
this.sexOptions = response.data;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 查询数据
|
|
||||||
getList() {
|
|
||||||
console.log(JSON.stringify(this.queryParams));
|
|
||||||
listGendemo(this.addDateRange(this.queryParams, this.timeRange)).then(
|
|
||||||
(res) => {
|
|
||||||
if (res.code == 200) {
|
|
||||||
this.dataList = res.data.result;
|
|
||||||
this.total = res.data.totalNum;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
// 取消按钮
|
|
||||||
cancel() {
|
|
||||||
this.open = false;
|
|
||||||
this.reset();
|
|
||||||
},
|
|
||||||
// 重置数据表单
|
|
||||||
reset() {
|
|
||||||
this.form = {
|
|
||||||
name: undefined,
|
|
||||||
icon: undefined,
|
|
||||||
showStatus: undefined,
|
|
||||||
addTime: undefined,
|
|
||||||
sex: undefined,
|
|
||||||
sort: undefined,
|
|
||||||
beginTime: undefined,
|
|
||||||
endTime: undefined,
|
|
||||||
remark: undefined,
|
|
||||||
|
|
||||||
//TODO 根据实际内容调整
|
|
||||||
};
|
|
||||||
this.resetForm("form");
|
|
||||||
},
|
|
||||||
/** 重置查询操作 */
|
|
||||||
resetQuery() {
|
|
||||||
this.timeRange = [];
|
|
||||||
this.resetForm("queryForm");
|
|
||||||
this.queryParams = {
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 20,
|
|
||||||
//TODO 重置字段
|
|
||||||
};
|
|
||||||
this.handleQuery();
|
|
||||||
},
|
|
||||||
// 多选框选中数据
|
|
||||||
handleSelectionChange(selection) {
|
|
||||||
this.ids = selection.map((item) => item.id);
|
|
||||||
this.single = selection.length != 1;
|
|
||||||
this.multiple = !selection.length;
|
|
||||||
},
|
|
||||||
/** 搜索按钮操作 */
|
|
||||||
handleQuery() {
|
|
||||||
this.getList();
|
|
||||||
},
|
|
||||||
/** 新增按钮操作 */
|
|
||||||
handleAdd() {
|
|
||||||
this.reset();
|
|
||||||
this.open = true;
|
|
||||||
this.title = "添加";
|
|
||||||
},
|
|
||||||
/** 删除按钮操作 */
|
|
||||||
handleDelete(row) {
|
|
||||||
const ids = row.id || this.ids;
|
|
||||||
delGendemo(ids.toString()).then((res) => {
|
|
||||||
this.msgSuccess("删除成功");
|
|
||||||
this.handleQuery();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
/** 修改按钮操作 */
|
|
||||||
handleUpdate(row) {
|
|
||||||
this.reset();
|
|
||||||
const id = row.id || this.ids;
|
|
||||||
getGendemo(id).then((res) => {
|
|
||||||
if (res.code == 200) {
|
|
||||||
this.form = res.data;
|
|
||||||
this.open = true;
|
|
||||||
this.title = "修改数据";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
//文件上传成功方法
|
|
||||||
handleUploadIconSuccess(res, file) {
|
|
||||||
this.form.icon = res.data;
|
|
||||||
// this.form.icon = URL.createObjectURL(file.raw);
|
|
||||||
// this.$refs.upload.clearFiles();
|
|
||||||
},
|
|
||||||
// 显示状态字典翻译
|
|
||||||
showStatusFormat(row, column) {
|
|
||||||
return this.selectDictLabel(this.showStatusOptions, row.showStatus);
|
|
||||||
},
|
|
||||||
// 用户性别字典翻译
|
|
||||||
sexFormat(row, column) {
|
|
||||||
return this.selectDictLabel(this.sexOptions, row.sex);
|
|
||||||
},
|
|
||||||
//文件上传前判断方法
|
|
||||||
beforeFileUpload(file) {
|
|
||||||
const isJPG = file.type === "image/jpeg";
|
|
||||||
const isLt2M = file.size / 1024 / 1024 < 2;
|
|
||||||
if (!isJPG) {
|
|
||||||
this.msgError("上传图片只能是 JPG 格式!");
|
|
||||||
}
|
|
||||||
if (!isLt2M) {
|
|
||||||
this.msgError("上传图片大小不能超过 2MB!");
|
|
||||||
}
|
|
||||||
return isJPG && isLt2M;
|
|
||||||
},
|
|
||||||
|
|
||||||
/** 提交按钮 */
|
|
||||||
submitForm: function () {
|
|
||||||
this.$refs["form"].validate((valid) => {
|
|
||||||
if (valid) {
|
|
||||||
console.log(JSON.stringify(this.form));
|
|
||||||
|
|
||||||
if (this.form.id != undefined || this.title === "修改数据") {
|
|
||||||
updateGendemo(this.form).then((res) => {
|
|
||||||
if (!res.data) {
|
|
||||||
this.msgError("修改失败");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.msgSuccess("修改成功");
|
|
||||||
this.open = false;
|
|
||||||
this.getList();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
addGendemo(this.form).then((res) => {
|
|
||||||
if (!res.data) {
|
|
||||||
this.msgError("新增失败");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.msgSuccess("新增成功");
|
|
||||||
this.open = false;
|
|
||||||
this.getList();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<style scoped>
|
|
||||||
.table-td-thumb {
|
|
||||||
width: 80px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
Loading…
x
Reference in New Issue
Block a user