This commit is contained in:
xd 2024-03-11 12:59:39 +08:00
parent b6d2fba181
commit 80ebfe6bf0
13 changed files with 906 additions and 16 deletions

View File

@ -1,3 +1,4 @@
/*
package com.ruoyi.web.Utils; package com.ruoyi.web.Utils;
import com.mchange.v2.c3p0.ComboPooledDataSource; import com.mchange.v2.c3p0.ComboPooledDataSource;
@ -6,12 +7,14 @@ import javax.sql.DataSource;
import java.beans.PropertyVetoException; import java.beans.PropertyVetoException;
import java.sql.Connection; import java.sql.Connection;
*/
/** /**
* 物流系统数据库操作 * 数据库操作
* *
* @author Administrator * @author Administrator
* *
*/ *//*
public class DataDBUtils { public class DataDBUtils {
private static DataSource ds; private static DataSource ds;
@ -57,3 +60,4 @@ public class DataDBUtils {
return con; return con;
} }
} }
*/

View File

@ -1,3 +1,4 @@
/*
package com.ruoyi.web.Utils; package com.ruoyi.web.Utils;
import com.ruoyi.system.domain.cost; import com.ruoyi.system.domain.cost;
@ -13,9 +14,11 @@ public class batchInsert extends JFrame {
public static PreparedStatement stmt; public static PreparedStatement stmt;
public static ResultSet rs; public static ResultSet rs;
*/
/** /**
* 对数据库进行批量插入数据操作 执行次数100万 * 对数据库进行批量插入数据操作 执行次数100万
*/ *//*
public static void insertMaterialBatch(List<material> list) throws Exception { public static void insertMaterialBatch(List<material> list) throws Exception {
// 思路将100万条数据分成n等份1等份为1000条数据 // 思路将100万条数据分成n等份1等份为1000条数据
// 如何实现 // 如何实现
@ -23,8 +26,10 @@ public class batchInsert extends JFrame {
// 2利用Statement接口中的如下三个方法addBatchclearBathexecuteBatch // 2利用Statement接口中的如下三个方法addBatchclearBathexecuteBatch
conn = DataDBUtils.getConnection(); conn = DataDBUtils.getConnection();
conn.setAutoCommit(false); conn.setAutoCommit(false);
*/
/*stmt = conn.prepareStatement( /*stmt = conn.prepareStatement(
"insert into [dbo].[sapcontract_test](uid,bh,type,custom,salesman,project,htje,startdate,enddate,remark,htzt) values (?,?,?,?,?,?,?,?,?,?,?)");*/ "insert into [dbo].[sapcontract_test](uid,bh,type,custom,salesman,project,htje,startdate,enddate,remark,htzt) values (?,?,?,?,?,?,?,?,?,?,?)");*//*
stmt = conn.prepareStatement( stmt = conn.prepareStatement(
"insert into c_material(material_id, material_xingh, material_guig, material_diany, material_dw,material_type_id) values (?,?,?,?,?,?)"); "insert into c_material(material_id, material_xingh, material_guig, material_diany, material_dw,material_type_id) values (?,?,?,?,?,?)");
int count = 0; int count = 0;
@ -52,9 +57,11 @@ public class batchInsert extends JFrame {
} }
*/
/** /**
* 对数据库进行批量插入数据操作 执行次数100万 * 对数据库进行批量插入数据操作 执行次数100万
*/ *//*
public static void insertCostBatch(List<cost> list) throws Exception { public static void insertCostBatch(List<cost> list) throws Exception {
// 思路将100万条数据分成n等份1等份为1000条数据 // 思路将100万条数据分成n等份1等份为1000条数据
// 如何实现 // 如何实现
@ -62,8 +69,10 @@ public class batchInsert extends JFrame {
// 2利用Statement接口中的如下三个方法addBatchclearBathexecuteBatch // 2利用Statement接口中的如下三个方法addBatchclearBathexecuteBatch
conn = DataDBUtils.getConnection(); conn = DataDBUtils.getConnection();
conn.setAutoCommit(false); conn.setAutoCommit(false);
*/
/*stmt = conn.prepareStatement( /*stmt = conn.prepareStatement(
"insert into [dbo].[sapcontract_test](uid,bh,type,custom,salesman,project,htje,startdate,enddate,remark,htzt) values (?,?,?,?,?,?,?,?,?,?,?)");*/ "insert into [dbo].[sapcontract_test](uid,bh,type,custom,salesman,project,htje,startdate,enddate,remark,htzt) values (?,?,?,?,?,?,?,?,?,?,?)");*//*
stmt = conn.prepareStatement( stmt = conn.prepareStatement(
"insert into c_material_cost(cost_id, cost_material_id, cost_cl_id, cost_cl_qty, cost_cl_qty_2) values (?,?,?,?,?)"); "insert into c_material_cost(cost_id, cost_material_id, cost_cl_id, cost_cl_qty, cost_cl_qty_2) values (?,?,?,?,?)");
int count = 0; int count = 0;
@ -106,3 +115,4 @@ public class batchInsert extends JFrame {
} }
} }
*/

View File

@ -0,0 +1,104 @@
package com.ruoyi.web.controller.sapAccount;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sapAccount.domain.SapAccount;
import com.ruoyi.sapAccount.service.ISapAccountService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 业务账户Controller
*
* @author ruoyi
* @date 2024-03-11
*/
@RestController
@RequestMapping("/sapAccount/sapAccount")
public class SapAccountController extends BaseController
{
@Autowired
private ISapAccountService sapAccountService;
/**
* 查询业务账户列表
*/
@PreAuthorize("@ss.hasPermi('sapAccount:sapAccount:list')")
@GetMapping("/list")
public TableDataInfo list(SapAccount sapAccount)
{
startPage();
List<SapAccount> list = sapAccountService.selectSapAccountList(sapAccount);
return getDataTable(list);
}
/**
* 导出业务账户列表
*/
@PreAuthorize("@ss.hasPermi('sapAccount:sapAccount:export')")
@Log(title = "业务账户", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SapAccount sapAccount)
{
List<SapAccount> list = sapAccountService.selectSapAccountList(sapAccount);
ExcelUtil<SapAccount> util = new ExcelUtil<SapAccount>(SapAccount.class);
util.exportExcel(response, list, "业务账户数据");
}
/**
* 获取业务账户详细信息
*/
@PreAuthorize("@ss.hasPermi('sapAccount:sapAccount:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(sapAccountService.selectSapAccountById(id));
}
/**
* 新增业务账户
*/
@PreAuthorize("@ss.hasPermi('sapAccount:sapAccount:add')")
@Log(title = "业务账户", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SapAccount sapAccount)
{
return toAjax(sapAccountService.insertSapAccount(sapAccount));
}
/**
* 修改业务账户
*/
@PreAuthorize("@ss.hasPermi('sapAccount:sapAccount:edit')")
@Log(title = "业务账户", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SapAccount sapAccount)
{
return toAjax(sapAccountService.updateSapAccount(sapAccount));
}
/**
* 删除业务账户
*/
@PreAuthorize("@ss.hasPermi('sapAccount:sapAccount:remove')")
@Log(title = "业务账户", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(sapAccountService.deleteSapAccountByIds(ids));
}
}

View File

@ -1,22 +1,17 @@
package com.ruoyi.web.controller.system; package com.ruoyi.web.controller.system;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.annotation.DataSource; import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.constant.CacheConstants; import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.enums.DataSourceType; import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.system.domain.cost; import com.ruoyi.system.domain.cost;
import com.ruoyi.system.domain.material; import com.ruoyi.system.domain.material;
import com.ruoyi.system.domain.temp;
import com.ruoyi.system.service.*; import com.ruoyi.system.service.*;
import com.ruoyi.web.Utils.batchInsert;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;

View File

@ -179,7 +179,12 @@ magic-api:
username: admin username: admin
password: magic-api.S password: magic-api.S
web: /magic/web web: /magic/web
show-sql: true #配置打印SQL
show-url: false show-url: false
response-code:
success: 200 #执行成功的code值
invalid: 400 #参数验证未通过的code值
exception: 500 #执行出现异常的code值
#存储设置 #存储设置
resource: resource:
type: database # 配置接口存储方式,这里选择存在数据库中 type: database # 配置接口存储方式,这里选择存在数据库中

View File

@ -38,7 +38,7 @@ import com.ruoyi.generator.service.IGenTableService;
*/ */
@RestController @RestController
@RequestMapping("/tool/gen") @RequestMapping("/tool/gen")
@DataSource(value = DataSourceType.QUOT) /*@DataSource(value = DataSourceType.QUOT)*/
public class GenController extends BaseController public class GenController extends BaseController
{ {
@Autowired @Autowired

View File

@ -0,0 +1,107 @@
package com.ruoyi.sapAccount.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 业务账户对象 sap_account
*
* @author ruoyi
* @date 2024-03-11
*/
public class SapAccount extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** */
private Long id;
/** 账号 */
@Excel(name = "账号")
private String userName;
/** 姓名 */
@Excel(name = "姓名")
private String nickName;
/** 账户 */
@Excel(name = "账户")
private String sapBm;
/** 账户名 */
@Excel(name = "账户名")
private String sapName;
/** 片区 */
@Excel(name = "片区")
private String sapArea;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setUserName(String userName)
{
this.userName = userName;
}
public String getUserName()
{
return userName;
}
public void setNickName(String nickName)
{
this.nickName = nickName;
}
public String getNickName()
{
return nickName;
}
public void setSapBm(String sapBm)
{
this.sapBm = sapBm;
}
public String getSapBm()
{
return sapBm;
}
public void setSapName(String sapName)
{
this.sapName = sapName;
}
public String getSapName()
{
return sapName;
}
public void setSapArea(String sapArea)
{
this.sapArea = sapArea;
}
public String getSapArea()
{
return sapArea;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("userName", getUserName())
.append("nickName", getNickName())
.append("sapBm", getSapBm())
.append("sapName", getSapName())
.append("sapArea", getSapArea())
.toString();
}
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.sapAccount.mapper;
import java.util.List;
import com.ruoyi.sapAccount.domain.SapAccount;
/**
* 业务账户Mapper接口
*
* @author ruoyi
* @date 2024-03-11
*/
public interface SapAccountMapper
{
/**
* 查询业务账户
*
* @param id 业务账户主键
* @return 业务账户
*/
public SapAccount selectSapAccountById(Long id);
/**
* 查询业务账户列表
*
* @param sapAccount 业务账户
* @return 业务账户集合
*/
public List<SapAccount> selectSapAccountList(SapAccount sapAccount);
/**
* 新增业务账户
*
* @param sapAccount 业务账户
* @return 结果
*/
public int insertSapAccount(SapAccount sapAccount);
/**
* 修改业务账户
*
* @param sapAccount 业务账户
* @return 结果
*/
public int updateSapAccount(SapAccount sapAccount);
/**
* 删除业务账户
*
* @param id 业务账户主键
* @return 结果
*/
public int deleteSapAccountById(Long id);
/**
* 批量删除业务账户
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteSapAccountByIds(Long[] ids);
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.sapAccount.service;
import java.util.List;
import com.ruoyi.sapAccount.domain.SapAccount;
/**
* 业务账户Service接口
*
* @author ruoyi
* @date 2024-03-11
*/
public interface ISapAccountService
{
/**
* 查询业务账户
*
* @param id 业务账户主键
* @return 业务账户
*/
public SapAccount selectSapAccountById(Long id);
/**
* 查询业务账户列表
*
* @param sapAccount 业务账户
* @return 业务账户集合
*/
public List<SapAccount> selectSapAccountList(SapAccount sapAccount);
/**
* 新增业务账户
*
* @param sapAccount 业务账户
* @return 结果
*/
public int insertSapAccount(SapAccount sapAccount);
/**
* 修改业务账户
*
* @param sapAccount 业务账户
* @return 结果
*/
public int updateSapAccount(SapAccount sapAccount);
/**
* 批量删除业务账户
*
* @param ids 需要删除的业务账户主键集合
* @return 结果
*/
public int deleteSapAccountByIds(Long[] ids);
/**
* 删除业务账户信息
*
* @param id 业务账户主键
* @return 结果
*/
public int deleteSapAccountById(Long id);
}

View File

@ -0,0 +1,93 @@
package com.ruoyi.sapAccount.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.sapAccount.mapper.SapAccountMapper;
import com.ruoyi.sapAccount.domain.SapAccount;
import com.ruoyi.sapAccount.service.ISapAccountService;
/**
* 业务账户Service业务层处理
*
* @author ruoyi
* @date 2024-03-11
*/
@Service
public class SapAccountServiceImpl implements ISapAccountService
{
@Autowired
private SapAccountMapper sapAccountMapper;
/**
* 查询业务账户
*
* @param id 业务账户主键
* @return 业务账户
*/
@Override
public SapAccount selectSapAccountById(Long id)
{
return sapAccountMapper.selectSapAccountById(id);
}
/**
* 查询业务账户列表
*
* @param sapAccount 业务账户
* @return 业务账户
*/
@Override
public List<SapAccount> selectSapAccountList(SapAccount sapAccount)
{
return sapAccountMapper.selectSapAccountList(sapAccount);
}
/**
* 新增业务账户
*
* @param sapAccount 业务账户
* @return 结果
*/
@Override
public int insertSapAccount(SapAccount sapAccount)
{
return sapAccountMapper.insertSapAccount(sapAccount);
}
/**
* 修改业务账户
*
* @param sapAccount 业务账户
* @return 结果
*/
@Override
public int updateSapAccount(SapAccount sapAccount)
{
return sapAccountMapper.updateSapAccount(sapAccount);
}
/**
* 批量删除业务账户
*
* @param ids 需要删除的业务账户主键
* @return 结果
*/
@Override
public int deleteSapAccountByIds(Long[] ids)
{
return sapAccountMapper.deleteSapAccountByIds(ids);
}
/**
* 删除业务账户信息
*
* @param id 业务账户主键
* @return 结果
*/
@Override
public int deleteSapAccountById(Long id)
{
return sapAccountMapper.deleteSapAccountById(id);
}
}

View File

@ -0,0 +1,76 @@
<?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.ruoyi.sapAccount.mapper.SapAccountMapper">
<resultMap type="SapAccount" id="SapAccountResult">
<result property="id" column="id" />
<result property="userName" column="user_name" />
<result property="nickName" column="nick_name" />
<result property="sapBm" column="sap_bm" />
<result property="sapName" column="sap_name" />
<result property="sapArea" column="sap_area" />
</resultMap>
<sql id="selectSapAccountVo">
select id, user_name, nick_name, sap_bm, sap_name, sap_area from sap_account
</sql>
<select id="selectSapAccountList" parameterType="SapAccount" resultMap="SapAccountResult">
<include refid="selectSapAccountVo"/>
<where>
<if test="userName != null and userName != ''"> and user_name = #{userName}</if>
<if test="nickName != null and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
<if test="sapBm != null and sapBm != ''"> and sap_bm = #{sapBm}</if>
<if test="sapName != null and sapName != ''"> and sap_name like concat('%', #{sapName}, '%')</if>
<if test="sapArea != null and sapArea != ''"> and sap_area = #{sapArea}</if>
</where>
</select>
<select id="selectSapAccountById" parameterType="Long" resultMap="SapAccountResult">
<include refid="selectSapAccountVo"/>
where id = #{id}
</select>
<insert id="insertSapAccount" parameterType="SapAccount" useGeneratedKeys="true" keyProperty="id">
insert into sap_account
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userName != null and userName != ''">user_name,</if>
<if test="nickName != null and nickName != ''">nick_name,</if>
<if test="sapBm != null and sapBm != ''">sap_bm,</if>
<if test="sapName != null and sapName != ''">sap_name,</if>
<if test="sapArea != null and sapArea != ''">sap_area,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userName != null and userName != ''">#{userName},</if>
<if test="nickName != null and nickName != ''">#{nickName},</if>
<if test="sapBm != null and sapBm != ''">#{sapBm},</if>
<if test="sapName != null and sapName != ''">#{sapName},</if>
<if test="sapArea != null and sapArea != ''">#{sapArea},</if>
</trim>
</insert>
<update id="updateSapAccount" parameterType="SapAccount">
update sap_account
<trim prefix="SET" suffixOverrides=",">
<if test="userName != null and userName != ''">user_name = #{userName},</if>
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
<if test="sapBm != null and sapBm != ''">sap_bm = #{sapBm},</if>
<if test="sapName != null and sapName != ''">sap_name = #{sapName},</if>
<if test="sapArea != null and sapArea != ''">sap_area = #{sapArea},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteSapAccountById" parameterType="Long">
delete from sap_account where id = #{id}
</delete>
<delete id="deleteSapAccountByIds" parameterType="String">
delete from sap_account 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 listSapAccount(query) {
return request({
url: '/sapAccount/sapAccount/list',
method: 'get',
params: query
})
}
// 查询业务账户详细
export function getSapAccount(id) {
return request({
url: '/sapAccount/sapAccount/' + id,
method: 'get'
})
}
// 新增业务账户
export function addSapAccount(data) {
return request({
url: '/sapAccount/sapAccount',
method: 'post',
data: data
})
}
// 修改业务账户
export function updateSapAccount(data) {
return request({
url: '/sapAccount/sapAccount',
method: 'put',
data: data
})
}
// 删除业务账户
export function delSapAccount(id) {
return request({
url: '/sapAccount/sapAccount/' + id,
method: 'delete'
})
}

View File

@ -0,0 +1,330 @@
<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="userName">
<el-input
v-model="queryParams.userName"
placeholder="请输入账号"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="姓名" prop="nickName">
<el-input
v-model="queryParams.nickName"
placeholder="请输入姓名"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="账户" prop="sapBm">
<el-input
v-model="queryParams.sapBm"
placeholder="请输入账户"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="账户名" prop="sapName">
<el-input
v-model="queryParams.sapName"
placeholder="请输入账户名"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="片区" prop="sapArea">
<el-select v-model="queryParams.sapArea" placeholder="请选择片区" clearable>
<el-option
v-for="dict in dict.type.sap_area"
:key="dict.value"
:label="dict.label"
:value="dict.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="['sapAccount:sapAccount: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="['sapAccount:sapAccount: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="['sapAccount:sapAccount: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="['sapAccount:sapAccount:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="sapAccountList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label=" " align="center" prop="id" v-if="false"/>
<el-table-column label="账号" align="center" prop="userName" />
<el-table-column label="姓名" align="center" prop="nickName" />
<el-table-column label="账户" align="center" prop="sapBm" />
<el-table-column label="账户名" align="center" prop="sapName" />
<el-table-column label="片区" align="center" prop="sapArea">
<template slot-scope="scope">
<dict-tag :options="dict.type.sap_area" :value="scope.row.sapArea"/>
</template>
</el-table-column>
<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="['sapAccount:sapAccount:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['sapAccount:sapAccount: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="userName">
<el-input v-model="form.userName" placeholder="请输入账号" />
</el-form-item>
<el-form-item label="姓名" prop="nickName">
<el-input v-model="form.nickName" placeholder="请输入姓名" />
</el-form-item>
<el-form-item label="账户" prop="sapBm">
<el-input v-model="form.sapBm" placeholder="请输入账户" />
</el-form-item>
<el-form-item label="账户名" prop="sapName">
<el-input v-model="form.sapName" placeholder="请输入账户名" />
</el-form-item>
<el-form-item label="片区" prop="sapArea">
<el-select v-model="form.sapArea" placeholder="请选择片区">
<el-option
v-for="dict in dict.type.sap_area"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</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 { listSapAccount, getSapAccount, delSapAccount, addSapAccount, updateSapAccount } from "@/api/sapAccount/sapAccount";
export default {
name: "SapAccount",
dicts: ['sap_area'],
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
sapAccountList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
userName: null,
nickName: null,
sapBm: null,
sapName: null,
sapArea: null
},
//
form: {},
//
rules: {
userName: [
{ required: true, message: "账号不能为空", trigger: "blur" }
],
nickName: [
{ required: true, message: "姓名不能为空", trigger: "blur" }
],
sapBm: [
{ required: true, message: "账户不能为空", trigger: "blur" }
],
sapName: [
{ required: true, message: "账户名不能为空", trigger: "blur" }
],
sapArea: [
{ required: true, message: "片区不能为空", trigger: "change" }
]
}
};
},
created() {
this.getList();
},
methods: {
/** 查询业务账户列表 */
getList() {
this.loading = true;
listSapAccount(this.queryParams).then(response => {
this.sapAccountList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
userName: null,
nickName: null,
sapBm: null,
sapName: null,
sapArea: 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 = "添加业务账户";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getSapAccount(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) {
updateSapAccount(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addSapAccount(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 delSapAccount(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('sapAccount/sapAccount/export', {
...this.queryParams
}, `sapAccount_${new Date().getTime()}.xlsx`)
}
}
};
</script>