Merge branch 'feature_day_1020' into 'main'

物种基本信息

See merge request likehai/ytr-god!11
This commit is contained in:
王燕 2023-10-20 18:52:57 +08:00
commit de1075a358
8 changed files with 1061 additions and 0 deletions

View File

@ -0,0 +1,98 @@
package com.god.web.controller.species;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.god.common.annotation.Log;
import com.god.common.core.controller.BaseController;
import com.god.common.core.domain.AjaxResult;
import com.god.common.enums.BusinessType;
import com.god.passenger.species.domain.BjdfSpeciesInfo;
import com.god.passenger.species.service.IBjdfSpeciesInfoService;
import com.god.common.utils.poi.ExcelUtil;
import com.god.common.core.page.TableDataInfo;
/**
* 物种基本信息Controller
*
* @author wangyan
* @date 2023-10-20
*/
@RestController
@RequestMapping("/species/info")
public class BjdfSpeciesInfoController extends BaseController {
@Autowired
private IBjdfSpeciesInfoService bjdfSpeciesInfoService;
/**
* 查询物种基本信息列表
*/
@PreAuthorize("@ss.hasPermi('species:info:list')")
@GetMapping("/list")
public TableDataInfo list(BjdfSpeciesInfo bjdfSpeciesInfo) {
startPage();
List<BjdfSpeciesInfo> list = bjdfSpeciesInfoService.selectBjdfSpeciesInfoList(bjdfSpeciesInfo);
return getDataTable(list);
}
/**
* 导出物种基本信息列表
*/
@PreAuthorize("@ss.hasPermi('species:info:export')")
@Log(title = "物种基本信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, BjdfSpeciesInfo bjdfSpeciesInfo) {
List<BjdfSpeciesInfo> list = bjdfSpeciesInfoService.selectBjdfSpeciesInfoList(bjdfSpeciesInfo);
ExcelUtil<BjdfSpeciesInfo> util = new ExcelUtil<BjdfSpeciesInfo>(BjdfSpeciesInfo.class);
util.exportExcel(response, list, "物种基本信息数据");
}
/**
* 获取物种基本信息详细信息
*/
@PreAuthorize("@ss.hasPermi('species:info:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id) {
return success(bjdfSpeciesInfoService.selectBjdfSpeciesInfoById(id));
}
/**
* 新增物种基本信息
*/
@PreAuthorize("@ss.hasPermi('species:info:add')")
@Log(title = "物种基本信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody BjdfSpeciesInfo bjdfSpeciesInfo) {
return toAjax(bjdfSpeciesInfoService.insertBjdfSpeciesInfo(bjdfSpeciesInfo));
}
/**
* 修改物种基本信息
*/
@PreAuthorize("@ss.hasPermi('species:info:edit')")
@Log(title = "物种基本信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody BjdfSpeciesInfo bjdfSpeciesInfo) {
return toAjax(bjdfSpeciesInfoService.updateBjdfSpeciesInfo(bjdfSpeciesInfo));
}
/**
* 删除物种基本信息
*/
@PreAuthorize("@ss.hasPermi('species:info:remove')")
@Log(title = "物种基本信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids) {
return toAjax(bjdfSpeciesInfoService.deleteBjdfSpeciesInfoByIds(ids));
}
}

View File

@ -0,0 +1,202 @@
package com.god.passenger.species.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.god.common.annotation.Excel;
import com.god.common.core.domain.BaseEntity;
/**
* 物种基本信息对象 bjdf_species_info
*
* @author wangyan
* @date 2023-10-20
*/
public class BjdfSpeciesInfo extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private String id;
/**
* 物种名称
*/
@Excel(name = "物种名称")
private String speciesName;
/**
* 物种分类
*/
@Excel(name = "物种分类")
private String classification;
/**
* 分布范围
*/
@Excel(name = "分布范围")
private String distribution;
/**
* 环境特征
*/
@Excel(name = "环境特征")
private String environment;
/**
* 生活习性
*/
@Excel(name = "生活习性")
private String habits;
/**
* 保护等级
*/
@Excel(name = "保护等级")
private String levelInfo;
/**
* 身长大小
*/
@Excel(name = "身长大小")
private String height;
/**
* 繁殖方式
*/
@Excel(name = "繁殖方式")
private String reproduction;
/**
* 数据类型
*/
@Excel(name = "数据类型")
private String dataType;
/**
* 添加时间
*/
@Excel(name = "添加时间")
private String addTime;
/**
* 添加人
*/
@Excel(name = "添加人")
private String addPerson;
public void setId(String id) {
this.id = id;
}
public String getId() {
return id;
}
public void setSpeciesName(String speciesName) {
this.speciesName = speciesName;
}
public String getSpeciesName() {
return speciesName;
}
public void setClassification(String classification) {
this.classification = classification;
}
public String getClassification() {
return classification;
}
public void setDistribution(String distribution) {
this.distribution = distribution;
}
public String getDistribution() {
return distribution;
}
public void setEnvironment(String environment) {
this.environment = environment;
}
public String getEnvironment() {
return environment;
}
public void setHabits(String habits) {
this.habits = habits;
}
public String getHabits() {
return habits;
}
public void setLevelInfo(String levelInfo) {
this.levelInfo = levelInfo;
}
public String getLevelInfo() {
return levelInfo;
}
public void setHeight(String height) {
this.height = height;
}
public String getHeight() {
return height;
}
public void setReproduction(String reproduction) {
this.reproduction = reproduction;
}
public String getReproduction() {
return reproduction;
}
public void setDataType(String dataType) {
this.dataType = dataType;
}
public String getDataType() {
return dataType;
}
public void setAddTime(String addTime) {
this.addTime = addTime;
}
public String getAddTime() {
return addTime;
}
public void setAddPerson(String addPerson) {
this.addPerson = addPerson;
}
public String getAddPerson() {
return addPerson;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("speciesName", getSpeciesName())
.append("classification", getClassification())
.append("distribution", getDistribution())
.append("environment", getEnvironment())
.append("habits", getHabits())
.append("levelInfo", getLevelInfo())
.append("height", getHeight())
.append("reproduction", getReproduction())
.append("remark", getRemark())
.append("dataType", getDataType())
.append("addTime", getAddTime())
.append("addPerson", getAddPerson())
.toString();
}
}

View File

@ -0,0 +1,61 @@
package com.god.passenger.species.mapper;
import java.util.List;
import com.god.passenger.species.domain.BjdfSpeciesInfo;
/**
* 物种基本信息Mapper接口
*
* @author wangyan
* @date 2023-10-20
*/
public interface BjdfSpeciesInfoMapper {
/**
* 查询物种基本信息
*
* @param id 物种基本信息主键
* @return 物种基本信息
*/
public BjdfSpeciesInfo selectBjdfSpeciesInfoById(String id);
/**
* 查询物种基本信息列表
*
* @param bjdfSpeciesInfo 物种基本信息
* @return 物种基本信息集合
*/
public List<BjdfSpeciesInfo> selectBjdfSpeciesInfoList(BjdfSpeciesInfo bjdfSpeciesInfo);
/**
* 新增物种基本信息
*
* @param bjdfSpeciesInfo 物种基本信息
* @return 结果
*/
public int insertBjdfSpeciesInfo(BjdfSpeciesInfo bjdfSpeciesInfo);
/**
* 修改物种基本信息
*
* @param bjdfSpeciesInfo 物种基本信息
* @return 结果
*/
public int updateBjdfSpeciesInfo(BjdfSpeciesInfo bjdfSpeciesInfo);
/**
* 删除物种基本信息
*
* @param id 物种基本信息主键
* @return 结果
*/
public int deleteBjdfSpeciesInfoById(String id);
/**
* 批量删除物种基本信息
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteBjdfSpeciesInfoByIds(String[] ids);
}

View File

@ -0,0 +1,61 @@
package com.god.passenger.species.service;
import java.util.List;
import com.god.passenger.species.domain.BjdfSpeciesInfo;
/**
* 物种基本信息Service接口
*
* @author wangyan
* @date 2023-10-20
*/
public interface IBjdfSpeciesInfoService
{
/**
* 查询物种基本信息
*
* @param id 物种基本信息主键
* @return 物种基本信息
*/
public BjdfSpeciesInfo selectBjdfSpeciesInfoById(String id);
/**
* 查询物种基本信息列表
*
* @param bjdfSpeciesInfo 物种基本信息
* @return 物种基本信息集合
*/
public List<BjdfSpeciesInfo> selectBjdfSpeciesInfoList(BjdfSpeciesInfo bjdfSpeciesInfo);
/**
* 新增物种基本信息
*
* @param bjdfSpeciesInfo 物种基本信息
* @return 结果
*/
public int insertBjdfSpeciesInfo(BjdfSpeciesInfo bjdfSpeciesInfo);
/**
* 修改物种基本信息
*
* @param bjdfSpeciesInfo 物种基本信息
* @return 结果
*/
public int updateBjdfSpeciesInfo(BjdfSpeciesInfo bjdfSpeciesInfo);
/**
* 批量删除物种基本信息
*
* @param ids 需要删除的物种基本信息主键集合
* @return 结果
*/
public int deleteBjdfSpeciesInfoByIds(String[] ids);
/**
* 删除物种基本信息信息
*
* @param id 物种基本信息主键
* @return 结果
*/
public int deleteBjdfSpeciesInfoById(String id);
}

View File

@ -0,0 +1,92 @@
package com.god.passenger.species.service.impl;
import java.util.List;
import com.god.common.utils.StringUtils;
import com.god.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.god.passenger.species.mapper.BjdfSpeciesInfoMapper;
import com.god.passenger.species.domain.BjdfSpeciesInfo;
import com.god.passenger.species.service.IBjdfSpeciesInfoService;
/**
* 物种基本信息Service业务层处理
*
* @author wangyan
* @date 2023-10-20
*/
@Service
public class BjdfSpeciesInfoServiceImpl implements IBjdfSpeciesInfoService {
@Autowired
private BjdfSpeciesInfoMapper bjdfSpeciesInfoMapper;
/**
* 查询物种基本信息
*
* @param id 物种基本信息主键
* @return 物种基本信息
*/
@Override
public BjdfSpeciesInfo selectBjdfSpeciesInfoById(String id) {
return bjdfSpeciesInfoMapper.selectBjdfSpeciesInfoById(id);
}
/**
* 查询物种基本信息列表
*
* @param bjdfSpeciesInfo 物种基本信息
* @return 物种基本信息
*/
@Override
public List<BjdfSpeciesInfo> selectBjdfSpeciesInfoList(BjdfSpeciesInfo bjdfSpeciesInfo) {
return bjdfSpeciesInfoMapper.selectBjdfSpeciesInfoList(bjdfSpeciesInfo);
}
/**
* 新增物种基本信息
*
* @param bjdfSpeciesInfo 物种基本信息
* @return 结果
*/
@Override
public int insertBjdfSpeciesInfo(BjdfSpeciesInfo bjdfSpeciesInfo) {
if (StringUtils.isBlank(bjdfSpeciesInfo.getId())) {
bjdfSpeciesInfo.setId(IdUtils.fastSimpleUUID());
}
return bjdfSpeciesInfoMapper.insertBjdfSpeciesInfo(bjdfSpeciesInfo);
}
/**
* 修改物种基本信息
*
* @param bjdfSpeciesInfo 物种基本信息
* @return 结果
*/
@Override
public int updateBjdfSpeciesInfo(BjdfSpeciesInfo bjdfSpeciesInfo) {
return bjdfSpeciesInfoMapper.updateBjdfSpeciesInfo(bjdfSpeciesInfo);
}
/**
* 批量删除物种基本信息
*
* @param ids 需要删除的物种基本信息主键
* @return 结果
*/
@Override
public int deleteBjdfSpeciesInfoByIds(String[] ids) {
return bjdfSpeciesInfoMapper.deleteBjdfSpeciesInfoByIds(ids);
}
/**
* 删除物种基本信息信息
*
* @param id 物种基本信息主键
* @return 结果
*/
@Override
public int deleteBjdfSpeciesInfoById(String id) {
return bjdfSpeciesInfoMapper.deleteBjdfSpeciesInfoById(id);
}
}

View File

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.god.passenger.species.mapper.BjdfSpeciesInfoMapper">
<resultMap type="BjdfSpeciesInfo" id="BjdfSpeciesInfoResult">
<result property="id" column="id" />
<result property="speciesName" column="species_name" />
<result property="classification" column="classification" />
<result property="distribution" column="distribution" />
<result property="environment" column="environment" />
<result property="habits" column="habits" />
<result property="levelInfo" column="level_info" />
<result property="height" column="height" />
<result property="reproduction" column="reproduction" />
<result property="remark" column="remark" />
<result property="dataType" column="data_type" />
<result property="addTime" column="add_time" />
<result property="addPerson" column="add_person" />
</resultMap>
<sql id="selectBjdfSpeciesInfoVo">
select id, species_name, classification, distribution, environment, habits, level_info, height, reproduction, remark, data_type, add_time, add_person from bjdf_species_info
</sql>
<select id="selectBjdfSpeciesInfoList" parameterType="BjdfSpeciesInfo" resultMap="BjdfSpeciesInfoResult">
<include refid="selectBjdfSpeciesInfoVo"/>
<where>
<if test="speciesName != null and speciesName != ''"> and species_name like concat('%', #{speciesName}, '%')</if>
<if test="classification != null and classification != ''"> and classification like concat('%', #{classification}, '%')</if>
<if test="distribution != null and distribution != ''"> and distribution like concat('%', #{distribution}, '%')</if>
<if test="environment != null and environment != ''"> and environment like concat('%', #{environment}, '%')</if>
<if test="habits != null and habits != ''"> and habits like concat('%', #{habits}, '%')</if>
<if test="levelInfo != null and levelInfo != ''"> and level_info like concat('%', #{levelInfo}, '%')</if>
<if test="height != null and height != ''"> and height like concat('%', #{height}, '%')</if>
<if test="reproduction != null and reproduction != ''"> and reproduction like concat('%', #{reproduction}, '%')</if>
<if test="dataType != null and dataType != ''"> and data_type like concat('%', #{dataType}, '%')</if>
<if test="addTime != null and addTime != ''"> and add_time &gt;= #{addTime}</if>
<if test="addPerson != null and addPerson != ''"> and add_person like concat('%', #{addPerson}, '%')</if>
</where>
</select>
<select id="selectBjdfSpeciesInfoById" parameterType="String" resultMap="BjdfSpeciesInfoResult">
<include refid="selectBjdfSpeciesInfoVo"/>
where id = #{id}
</select>
<insert id="insertBjdfSpeciesInfo" parameterType="BjdfSpeciesInfo">
insert into bjdf_species_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="speciesName != null">species_name,</if>
<if test="classification != null">classification,</if>
<if test="distribution != null">distribution,</if>
<if test="environment != null">environment,</if>
<if test="habits != null">habits,</if>
<if test="levelInfo != null">level_info,</if>
<if test="height != null">height,</if>
<if test="reproduction != null">reproduction,</if>
<if test="remark != null">remark,</if>
<if test="dataType != null">data_type,</if>
<if test="addTime != null">add_time,</if>
<if test="addPerson != null">add_person,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="speciesName != null">#{speciesName},</if>
<if test="classification != null">#{classification},</if>
<if test="distribution != null">#{distribution},</if>
<if test="environment != null">#{environment},</if>
<if test="habits != null">#{habits},</if>
<if test="levelInfo != null">#{levelInfo},</if>
<if test="height != null">#{height},</if>
<if test="reproduction != null">#{reproduction},</if>
<if test="remark != null">#{remark},</if>
<if test="dataType != null">#{dataType},</if>
<if test="addTime != null">#{addTime},</if>
<if test="addPerson != null">#{addPerson},</if>
</trim>
</insert>
<update id="updateBjdfSpeciesInfo" parameterType="BjdfSpeciesInfo">
update bjdf_species_info
<trim prefix="SET" suffixOverrides=",">
<if test="speciesName != null">species_name = #{speciesName},</if>
<if test="classification != null">classification = #{classification},</if>
<if test="distribution != null">distribution = #{distribution},</if>
<if test="environment != null">environment = #{environment},</if>
<if test="habits != null">habits = #{habits},</if>
<if test="levelInfo != null">level_info = #{levelInfo},</if>
<if test="height != null">height = #{height},</if>
<if test="reproduction != null">reproduction = #{reproduction},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="dataType != null">data_type = #{dataType},</if>
<if test="addTime != null">add_time = #{addTime},</if>
<if test="addPerson != null">add_person = #{addPerson},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteBjdfSpeciesInfoById" parameterType="String">
delete from bjdf_species_info where id = #{id}
</delete>
<delete id="deleteBjdfSpeciesInfoByIds" parameterType="String">
delete from bjdf_species_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询物种基本信息列表
export function listInfo(query) {
return request({
url: '/species/info/list',
method: 'get',
params: query
})
}
// 查询物种基本信息详细
export function getInfo(id) {
return request({
url: '/species/info/' + id,
method: 'get'
})
}
// 新增物种基本信息
export function addInfo(data) {
return request({
url: '/species/info',
method: 'post',
data: data
})
}
// 修改物种基本信息
export function updateInfo(data) {
return request({
url: '/species/info',
method: 'put',
data: data
})
}
// 删除物种基本信息
export function delInfo(id) {
return request({
url: '/species/info/' + id,
method: 'delete'
})
}

View File

@ -0,0 +1,391 @@
<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="物种名称" prop="speciesName">
<el-input
v-model="queryParams.speciesName"
placeholder="请输入物种名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="物种分类" prop="classification">
<el-input
v-model="queryParams.classification"
placeholder="请输入物种分类"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="分布范围" prop="distribution">
<el-input
v-model="queryParams.distribution"
placeholder="请输入分布范围"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<!-- <el-form-item label="环境特征" prop="environment">-->
<!-- <el-input-->
<!-- v-model="queryParams.environment"-->
<!-- placeholder="请输入环境特征"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="生活习性" prop="habits">-->
<!-- <el-input-->
<!-- v-model="queryParams.habits"-->
<!-- placeholder="请输入生活习性"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<el-form-item label="保护等级" prop="levelInfo">
<el-input
v-model="queryParams.levelInfo"
placeholder="请输入保护等级"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<!-- <el-form-item label="身长大小" prop="height">-->
<!-- <el-input-->
<!-- v-model="queryParams.height"-->
<!-- placeholder="请输入身长大小"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<el-form-item label="繁殖方式" prop="reproduction">
<el-input
v-model="queryParams.reproduction"
placeholder="请输入繁殖方式"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="添加时间" prop="addTime">
<el-date-picker clearable
v-model="queryParams.addTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择添加时间">
</el-date-picker>
</el-form-item>
<el-form-item label="添加人" prop="addPerson">
<el-input
v-model="queryParams.addPerson"
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="['species:info: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="['species:info: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="['species:info: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="['species:info:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="infoList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="物种名称" align="center" prop="speciesName" />
<el-table-column label="物种分类" align="center" prop="classification" />
<el-table-column label="分布范围" align="center" prop="distribution" :show-overflow-tooltip="true"/>
<el-table-column label="环境特征" align="center" prop="environment" />
<el-table-column label="生活习性" align="center" prop="habits" :show-overflow-tooltip="true"/>
<el-table-column label="保护等级" align="center" prop="levelInfo" />
<el-table-column label="身长大小" align="center" prop="height" :show-overflow-tooltip="true"/>
<el-table-column label="繁殖方式" align="center" prop="reproduction" />
<!-- <el-table-column label="备注" align="center" prop="remark" />-->
<!-- <el-table-column label="数据类型" align="center" prop="dataType" />-->
<el-table-column label="添加时间" align="center" prop="addTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.addTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="添加人" align="center" prop="addPerson" />
<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="['species:info:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['species:info: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-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="物种名称" prop="speciesName">
<el-input v-model="form.speciesName" placeholder="请输入物种名称" />
</el-form-item>
<el-form-item label="物种分类" prop="classification">
<el-input v-model="form.classification" placeholder="请输入物种分类" />
</el-form-item>
<el-form-item label="分布范围" prop="distribution">
<el-input v-model="form.distribution" placeholder="请输入分布范围" />
</el-form-item>
<el-form-item label="环境特征" prop="environment">
<el-input v-model="form.environment" placeholder="请输入环境特征" />
</el-form-item>
<el-form-item label="生活习性" prop="habits">
<el-input v-model="form.habits" placeholder="请输入生活习性" />
</el-form-item>
<el-form-item label="保护等级" prop="levelInfo">
<el-input v-model="form.levelInfo" placeholder="请输入保护等级" />
</el-form-item>
<el-form-item label="身长大小" prop="height">
<el-input v-model="form.height" placeholder="请输入身长大小" />
</el-form-item>
<el-form-item label="繁殖方式" prop="reproduction">
<el-input v-model="form.reproduction" placeholder="请输入繁殖方式" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
<el-form-item label="数据类型" prop="dataType">
<el-input v-model="form.dataType" placeholder="请输入数据类型" />
</el-form-item>
<el-form-item label="添加时间" prop="addTime">
<el-date-picker clearable
v-model="form.addTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择添加时间">
</el-date-picker>
</el-form-item>
<el-form-item label="添加人" prop="addPerson">
<el-input v-model="form.addPerson" 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 { listInfo, getInfo, delInfo, addInfo, updateInfo } from "@/api/species/info";
export default {
name: "SpeciesInfo",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
infoList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
speciesName: null,
classification: null,
distribution: null,
environment: null,
habits: null,
levelInfo: null,
height: null,
reproduction: null,
dataType: "基本信息",
addTime: null,
addPerson: null
},
//
form: {},
//
rules: {
}
};
},
created() {
this.getList();
},
methods: {
/** 查询物种基本信息列表 */
getList() {
this.loading = true;
listInfo(this.queryParams).then(response => {
this.infoList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
speciesName: null,
classification: null,
distribution: null,
environment: null,
habits: null,
levelInfo: null,
height: null,
reproduction: null,
remark: null,
dataType: null,
addTime: null,
addPerson: 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.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加物种基本信息";
this.form.dataType = "基本信息";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getInfo(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改物种基本信息";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateInfo(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addInfo(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 delInfo(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('species/info/export', {
...this.queryParams
}, `info_${new Date().getTime()}.xlsx`)
}
}
};
</script>