基本数据管理-机床客户管理

This commit is contained in:
xusd 2024-08-28 16:37:40 +08:00
parent 092d7682b3
commit 5d59bbe803
13 changed files with 881 additions and 0 deletions

View File

@ -164,5 +164,6 @@ public interface ErrorCodeConstants {
// ========== 基础信息模块 ========== // ========== 基础信息模块 ==========
ErrorCode MODEL_INFO_NOT_EXISTS = new ErrorCode(1_002_028_000, "未获取到机床型号信息"); ErrorCode MODEL_INFO_NOT_EXISTS = new ErrorCode(1_002_028_000, "未获取到机床型号信息");
ErrorCode CUSTOMER_INFO_NOT_EXISTS = new ErrorCode(1_002_028_000, "未获取到机床客户信息");
} }

View File

@ -0,0 +1,119 @@
package com.inspur.module.system.controller.baseData;
import cn.hutool.core.util.StrUtil;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.ip.core.utils.AreaUtils;
import com.inspur.module.system.controller.baseData.vo.CustomerInfoPageReqVO;
import com.inspur.module.system.controller.baseData.vo.CustomerInfoRespVO;
import com.inspur.module.system.controller.baseData.vo.CustomerInfoSaveReqVO;
import com.inspur.module.system.dal.dataobject.baseData.CustomerInfoDO;
import com.inspur.module.system.service.baseData.CustomerInfoService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.*;
import javax.servlet.http.*;
import java.io.IOException;
import java.util.List;
import java.util.Objects;
import com.inspur.framework.common.pojo.PageParam;
import com.inspur.framework.common.pojo.CommonResult;
import com.inspur.framework.common.util.object.BeanUtils;
import static com.inspur.framework.common.pojo.CommonResult.success;
import com.inspur.framework.excel.core.util.ExcelUtils;
import com.inspur.framework.apilog.core.annotation.ApiAccessLog;
import static com.inspur.framework.apilog.core.enums.OperateTypeEnum.*;
@Tag(name = "管理后台 - 机床客户信息")
@RestController
@RequestMapping("/admin-api/baseData/customerInfo")
@Validated
public class CustomerInfoController {
@Resource
private CustomerInfoService customerInfoService;
@PostMapping("/create")
@Operation(summary = "创建机床客户信息")
@PreAuthorize("@ss.hasPermission('imt:customer-info:create')")
public CommonResult<String> createCustomerInfo(@Valid @RequestBody CustomerInfoSaveReqVO createReqVO) {
return success(customerInfoService.createCustomerInfo(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新机床客户信息")
@PreAuthorize("@ss.hasPermission('imt:customer-info:update')")
public CommonResult<Boolean> updateCustomerInfo(@Valid @RequestBody CustomerInfoSaveReqVO updateReqVO) {
customerInfoService.updateCustomerInfo(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除机床客户信息")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('imt:customer-info:delete')")
public CommonResult<Boolean> deleteCustomerInfo(@RequestParam("id") String id) {
customerInfoService.deleteCustomerInfo(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得机床客户信息")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('imt:customer-info:query')")
public CommonResult<CustomerInfoRespVO> getCustomerInfo(@RequestParam("id") String id) {
CustomerInfoDO customerInfo = customerInfoService.getCustomerInfo(id);
CustomerInfoRespVO bean = BeanUtils.toBean(customerInfo, CustomerInfoRespVO.class);
if (Objects.nonNull(bean.getDistrict())){
Integer[] test = {bean.getProvinceCode(),bean.getCityCode(),bean.getDistrict()};
bean.setDistrictArray(test);
}
return success(bean);
}
@GetMapping("/page")
@Operation(summary = "获得机床客户信息分页")
@PreAuthorize("@ss.hasPermission('imt:customer-info:query')")
public CommonResult<PageResult<CustomerInfoRespVO>> getCustomerInfoPage(@Valid CustomerInfoPageReqVO pageReqVO) {
PageResult<CustomerInfoDO> pageResult = customerInfoService.getCustomerInfoPage(pageReqVO);
PageResult<CustomerInfoRespVO> bean = BeanUtils.toBean(pageResult, CustomerInfoRespVO.class);
List<CustomerInfoRespVO> list = bean.getList();
list.forEach(item->{
if (Objects.nonNull(item.getDistrict())){
String districtName =
AreaUtils.getArea(item.getProvinceCode()).getName() + "-" +
AreaUtils.getArea(item.getCityCode()).getName() + "-" +
AreaUtils.getArea(item.getDistrict()).getName();
item.setDistrictName(districtName);
}
});
bean.setList(list);
return success(bean);
}
@GetMapping("/export-excel")
@Operation(summary = "导出机床客户信息 Excel")
@PreAuthorize("@ss.hasPermission('imt:customer-info:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportCustomerInfoExcel(@Valid CustomerInfoPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<CustomerInfoDO> list = customerInfoService.getCustomerInfoPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "机床客户信息.xls", "数据", CustomerInfoRespVO.class,
BeanUtils.toBean(list, CustomerInfoRespVO.class));
}
}

View File

@ -0,0 +1,24 @@
package com.inspur.module.system.controller.baseData.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.inspur.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.inspur.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 机床客户信息分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CustomerInfoPageReqVO extends PageParam {
@Schema(description = "客户名称", example = "张三")
private String customerName;
@Schema(description = "所属行业", example = "2")
private Integer industryType;
}

View File

@ -0,0 +1,64 @@
package com.inspur.module.system.controller.baseData.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import com.alibaba.excel.annotation.*;
import com.inspur.framework.excel.core.annotations.DictFormat;
import com.inspur.framework.excel.core.convert.DictConvert;
@Schema(description = "管理后台 - 机床客户信息 Response VO")
@Data
@ExcelIgnoreUnannotated
public class CustomerInfoRespVO {
/**
* 机床客户信息id
*/
private String customerId;
@Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
@ExcelProperty("客户名称")
private String customerName;
@Schema(description = "省编号")
private Integer provinceCode;
@Schema(description = "市编号")
private Integer cityCode;
@Schema(description = "区县编号")
private Integer district;
@ExcelProperty("地区")
private String districtName;
private Integer[] districtArray;
@Schema(description = "详细地址")
@ExcelProperty("详细地址")
private String address;
@Schema(description = "所属行业", example = "2")
@ExcelProperty(value = "所属行业", converter = DictConvert.class)
@DictFormat("industry_type") // TODO 代码优化建议设置到对应的 DictTypeConstants 枚举类中
private Integer industryType;
@Schema(description = "联系人姓名")
@ExcelProperty("联系人姓名")
private String contactPerson;
@Schema(description = "联系人电话")
@ExcelProperty("联系人电话")
private String contactPhone;
@Schema(description = "状态", example = "1")
@ExcelProperty(value = "状态", converter = DictConvert.class)
@DictFormat("common_status") // TODO 代码优化建议设置到对应的 DictTypeConstants 枚举类中
private String status;
@Schema(description = "备注", example = "你猜")
@ExcelProperty("备注")
private String remark;
}

View File

@ -0,0 +1,51 @@
package com.inspur.module.system.controller.baseData.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 机床客户信息新增/修改 Request VO")
@Data
public class CustomerInfoSaveReqVO {
@Schema(description = "机床客户信息id", requiredMode = Schema.RequiredMode.REQUIRED, example = "2573")
private String customerId;
@Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
@NotBlank(message = "客户名称不能为空")
@Size(message = "客户名称最大不允许超过50个字符", max = 50)
private String customerName;
@Schema(description = "省编号")
private Integer provinceCode;
@Schema(description = "市编号")
private Integer cityCode;
@Schema(description = "区县编号")
private Integer district;
@Schema(description = "详细地址")
@Size(message = "详细地址最大不允许超过200个字符", max = 200)
private String address;
@Schema(description = "所属行业", example = "2")
@NotNull(message = "所属行业不能为空")
private Integer industryType;
@Schema(description = "联系人姓名")
@Size(message = "联系人姓名最大不允许超过20个字符", max = 20)
private String contactPerson;
@Schema(description = "联系人电话")
@Size(message = "联系人电话最大不允许超过20个字符", max = 20)
private String contactPhone;
@Schema(description = "状态", example = "1")
private String status;
@Schema(description = "备注", example = "你猜")
@Size(message = "备注最大不允许超过500个字符", max = 500)
private String remark;
}

View File

@ -0,0 +1,74 @@
package com.inspur.module.system.dal.dataobject.baseData;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import com.inspur.framework.mybatis.core.dataobject.BaseDO;
/**
* 机床客户信息 DO
*
* @author xusd
*/
@TableName("imt_customer_info")
@KeySequence("imt_customer_info_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CustomerInfoDO extends BaseDO {
/**
* 机床客户信息id
*/
@TableId(type = IdType.ASSIGN_UUID)
private String customerId;
/**
* 客户名称
*/
private String customerName;
/**
* 省编号
*/
private Integer provinceCode;
/**
* 市编号
*/
private Integer cityCode;
/**
* 区县编号
*/
private Integer district;
/**
* 详细地址
*/
private String address;
/**
* 所属行业
*
* 枚举 {@link TODO industry_type 对应的类}
*/
private Integer industryType;
/**
* 联系人姓名
*/
private String contactPerson;
/**
* 联系人电话
*/
private String contactPhone;
/**
* 状态
*
*/
private String status;
/**
* 备注
*/
private String remark;
}

View File

@ -0,0 +1,25 @@
package com.inspur.module.system.dal.mysql.baseData;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.mybatis.core.mapper.BaseMapperX;
import com.inspur.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.inspur.module.system.controller.baseData.vo.CustomerInfoPageReqVO;
import com.inspur.module.system.dal.dataobject.baseData.CustomerInfoDO;
import org.apache.ibatis.annotations.Mapper;
/**
* 机床客户信息 Mapper
*
* @author xusd
*/
@Mapper
public interface CustomerInfoMapper extends BaseMapperX<CustomerInfoDO> {
default PageResult<CustomerInfoDO> selectPage(CustomerInfoPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<CustomerInfoDO>()
.likeIfPresent(CustomerInfoDO::getCustomerName, reqVO.getCustomerName())
.eqIfPresent(CustomerInfoDO::getIndustryType, reqVO.getIndustryType())
.orderByDesc(CustomerInfoDO::getCustomerId));
}
}

View File

@ -0,0 +1,55 @@
package com.inspur.module.system.service.baseData;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.module.system.controller.baseData.vo.CustomerInfoPageReqVO;
import com.inspur.module.system.controller.baseData.vo.CustomerInfoSaveReqVO;
import com.inspur.module.system.dal.dataobject.baseData.CustomerInfoDO;
import javax.validation.*;
/**
* 机床客户信息 Service 接口
*
* @author xusd
*/
public interface CustomerInfoService {
/**
* 创建机床客户信息
*
* @param createReqVO 创建信息
* @return 编号
*/
String createCustomerInfo(@Valid CustomerInfoSaveReqVO createReqVO);
/**
* 更新机床客户信息
*
* @param updateReqVO 更新信息
*/
void updateCustomerInfo(@Valid CustomerInfoSaveReqVO updateReqVO);
/**
* 删除机床客户信息
*
* @param id 编号
*/
void deleteCustomerInfo(String id);
/**
* 获得机床客户信息
*
* @param id 编号
* @return 机床客户信息
*/
CustomerInfoDO getCustomerInfo(String id);
/**
* 获得机床客户信息分页
*
* @param pageReqVO 分页查询
* @return 机床客户信息分页
*/
PageResult<CustomerInfoDO> getCustomerInfoPage(CustomerInfoPageReqVO pageReqVO);
}

View File

@ -0,0 +1,70 @@
package com.inspur.module.system.service.baseData;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.module.system.controller.baseData.vo.CustomerInfoPageReqVO;
import com.inspur.module.system.controller.baseData.vo.CustomerInfoSaveReqVO;
import com.inspur.module.system.dal.dataobject.baseData.CustomerInfoDO;
import com.inspur.module.system.dal.mysql.baseData.CustomerInfoMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import com.inspur.framework.common.util.object.BeanUtils;
import static com.inspur.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.inspur.module.system.enums.ErrorCodeConstants.CUSTOMER_INFO_NOT_EXISTS;
/**
* 机床客户信息 Service 实现类
*
* @author xusd
*/
@Service
@Validated
public class CustomerInfoServiceImpl implements CustomerInfoService {
@Resource
private CustomerInfoMapper customerInfoMapper;
@Override
public String createCustomerInfo(CustomerInfoSaveReqVO createReqVO) {
// 插入
CustomerInfoDO customerInfo = BeanUtils.toBean(createReqVO, CustomerInfoDO.class);
customerInfoMapper.insert(customerInfo);
// 返回
return customerInfo.getCustomerId();
}
@Override
public void updateCustomerInfo(CustomerInfoSaveReqVO updateReqVO) {
// 校验存在
validateCustomerInfoExists(updateReqVO.getCustomerId());
// 更新
CustomerInfoDO updateObj = BeanUtils.toBean(updateReqVO, CustomerInfoDO.class);
customerInfoMapper.updateById(updateObj);
}
@Override
public void deleteCustomerInfo(String id) {
// 校验存在
validateCustomerInfoExists(id);
// 删除
customerInfoMapper.deleteById(id);
}
private void validateCustomerInfoExists(String id) {
if (customerInfoMapper.selectById(id) == null) {
throw exception(CUSTOMER_INFO_NOT_EXISTS);
}
}
@Override
public CustomerInfoDO getCustomerInfo(String id) {
return customerInfoMapper.selectById(id);
}
@Override
public PageResult<CustomerInfoDO> getCustomerInfoPage(CustomerInfoPageReqVO pageReqVO) {
return customerInfoMapper.selectPage(pageReqVO);
}
}

View File

@ -0,0 +1,53 @@
import request from '@/utils/request'
// 创建机床客户信息
export function createCustomerInfo(data) {
return request({
url: '/baseData/customerInfo/create',
method: 'post',
data: data
})
}
// 更新机床客户信息
export function updateCustomerInfo(data) {
return request({
url: '/baseData/customerInfo/update',
method: 'put',
data: data
})
}
// 删除机床客户信息
export function deleteCustomerInfo(id) {
return request({
url: '/baseData/customerInfo/delete?id=' + id,
method: 'delete'
})
}
// 获得机床客户信息
export function getCustomerInfo(id) {
return request({
url: '/baseData/customerInfo/get?id=' + id,
method: 'get'
})
}
// 获得机床客户信息分页
export function getCustomerInfoPage(params) {
return request({
url: '/baseData/customerInfo/page',
method: 'get',
params
})
}
// 导出机床客户信息 Excel
export function exportCustomerInfoExcel(params) {
return request({
url: '/baseData/customerInfo/export-excel',
method: 'get',
params,
responseType: 'blob'
})
}

View File

@ -12,6 +12,7 @@ export const DICT_TYPE = {
//========== imt 模块 ========== //========== imt 模块 ==========
MACHINE_TYPE: 'machine_type', MACHINE_TYPE: 'machine_type',
INDUSTRY_TYPE: 'industry_type',
// ========== SYSTEM 模块 ========== // ========== SYSTEM 模块 ==========
SYSTEM_USER_SEX: 'system_user_sex', SYSTEM_USER_SEX: 'system_user_sex',

View File

@ -0,0 +1,181 @@
<template>
<div class="app-container">
<!-- 对话框(添加 / 修改) -->
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="45%" v-dialogDrag append-to-body>
<el-form ref="formRef" :model="formData" :rules="formRules" v-loading="formLoading" label-width="100px">
<el-form-item label="客户名称" prop="customerName">
<el-input v-model="formData.customerName" placeholder="请输入客户名称"/>
</el-form-item>
<el-form-item label="地区" prop="districtName">
<el-cascader v-model="areaTreeData" :options="areaTree" clearable
:props="{ value: 'id',label: 'name',children: 'children'}"
@change="areaTreeChange"></el-cascader>
</el-form-item>
<el-form-item label="详细地址" prop="address">
<el-input v-model="formData.address" placeholder="请输入详细地址"/>
</el-form-item>
<el-form-item label="所属行业" prop="industryType">
<el-select v-model="formData.industryType" placeholder="请选择所属行业">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.INDUSTRY_TYPE)"
:key="dict.value" :label="dict.label" :value="parseInt(dict.value)"/>
</el-select>
</el-form-item>
<el-form-item label="联系人姓名" prop="contactPerson">
<el-input v-model="formData.contactPerson" placeholder="请输入联系人姓名"/>
</el-form-item>
<el-form-item label="联系人电话" prop="contactPhone">
<el-input v-model="formData.contactPhone" placeholder="请输入联系人电话"/>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-radio-group v-model="formData.status">
<el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)"
:key="dict.value" :label="dict.value">{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="formData.remark" type="textarea" placeholder="请输入内容"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import * as CustomerInfoApi from '@/api/system/baseData/customerInfo';
import {getAreaTree} from "@/api/system/area";
export default {
name: "CustomerInfoForm",
components: {},
data() {
return {
areaTree: [],
areaTreeData: [],
//
dialogTitle: "",
//
dialogVisible: false,
// 12
formLoading: false,
//
formData: {
customerId: undefined,
customerName: undefined,
provinceCode: undefined,
cityCode: undefined,
district: undefined,
address: undefined,
industryType: undefined,
contactPerson: undefined,
contactPhone: undefined,
status: undefined,
remark: undefined,
districtArray: [],
},
//
formRules: {
customerName: [{required: true, message: '客户名称不能为空', trigger: 'blur'}],
industryType: [{ required: true, message: '请选择所属行业', trigger: 'change' }],
},
};
},
mounted() {
getAreaTree().then(res => {
const list = res.data;
this.areaTree = this.handleTreeList(list);
})
},
methods: {
areaTreeChange(value) {
console.log(value)
},
handleTreeList(list) { // children
for (var i = 0; i < list.length; i++) {
if (list[i].children.length < 1) { // children
list[i].children = undefined
} else {
this.handleTreeList(list[i].children)
}
}
return list
},
/** 打开弹窗 */
async open(id) {
this.dialogVisible = true;
this.reset();
//
if (id) {
this.formLoading = true;
try {
const res = await CustomerInfoApi.getCustomerInfo(id);
this.formData = res.data;
this.dialogTitle = "修改机床客户信息";
this.areaTreeData = this.formData.districtArray;
} finally {
this.formLoading = false;
}
return;
}
this.dialogTitle = "新增机床客户信息";
},
/** 提交按钮 */
async submitForm() {
//
await this.$refs["formRef"].validate();
this.formLoading = true;
try {
const data = this.formData;
//
if (data.customerId) {
if (this.areaTreeData[2] != null && this.areaTreeData[2] !== undefined){
data.provinceCode = this.areaTreeData[0];
data.cityCode = this.areaTreeData[1];
data.district = this.areaTreeData[2];
}
await CustomerInfoApi.updateCustomerInfo(data);
this.$modal.msgSuccess("修改成功");
this.dialogVisible = false;
this.$emit('success');
return;
}
//
if (this.areaTreeData[2] != null && this.areaTreeData[2] !== undefined){
data.provinceCode = this.areaTreeData[0];
data.cityCode = this.areaTreeData[1];
data.district = this.areaTreeData[2];
}
await CustomerInfoApi.createCustomerInfo(data);
this.$modal.msgSuccess("新增成功");
this.dialogVisible = false;
this.$emit('success');
} finally {
this.formLoading = false;
}
},
/** 表单重置 */
reset() {
this.formData = {
customerId: undefined,
customerName: undefined,
provinceCode: undefined,
cityCode: undefined,
district: undefined,
address: undefined,
industryType: undefined,
contactPerson: undefined,
contactPhone: undefined,
status: undefined,
remark: undefined,
districtArray: [],
};
this.areaTreeData = [];
this.resetForm("formRef");
}
}
};
</script>

View File

@ -0,0 +1,163 @@
<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="customerName">
<el-input v-model="queryParams.customerName" placeholder="请输入客户名称" clearable
@keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="所属行业" prop="industryType">
<el-select v-model="queryParams.industryType" placeholder="请选择所属行业" clearable size="small">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.INDUSTRY_TYPE)"
: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" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" @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="openForm(undefined)"
v-hasPermi="['imt:customer-info:create']">新增
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
:loading="exportLoading"
v-hasPermi="['imt:customer-info:export']">导出
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="客户名称" align="center" prop="customerName"/>
<el-table-column label="地区" align="center" prop="districtName"/>
<el-table-column label="详细地址" align="center" prop="address"/>
<el-table-column label="所属行业" align="center" prop="industryType">
<template v-slot="scope">
<dict-tag :type="DICT_TYPE.INDUSTRY_TYPE" :value="scope.row.industryType"/>
</template>
</el-table-column>
<el-table-column label="联系人姓名" align="center" prop="contactPerson"/>
<el-table-column label="联系人电话" align="center" prop="contactPhone"/>
<el-table-column label="状态" align="center" prop="status">
<template v-slot="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template v-slot="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="openForm(scope.row.customerId)"
v-hasPermi="['imt:customer-info:update']">修改
</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
v-hasPermi="['imt:customer-info:delete']">删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页组件 -->
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
@pagination="getList"/>
<!-- 对话框(添加 / 修改) -->
<CustomerInfoForm ref="formRef" @success="getList"/>
</div>
</template>
<script>
import * as CustomerInfoApi from '@/api/system/baseData/customerInfo';
import CustomerInfoForm from './CustomerInfoForm.vue';
export default {
name: "CustomerInfo",
components: {
CustomerInfoForm,
},
data() {
return {
//
loading: true,
//
exportLoading: false,
//
showSearch: true,
//
total: 0,
//
list: [],
//
isExpandAll: true,
//
refreshTable: true,
//
currentRow: {},
//
queryParams: {
pageNo: 1,
pageSize: 10,
customerName: null,
industryType: null,
},
};
},
created() {
this.getList();
},
methods: {
/** 查询列表 */
async getList() {
try {
this.loading = true;
const res = await CustomerInfoApi.getCustomerInfoPage(this.queryParams);
this.list = res.data.list;
this.total = res.data.total;
} finally {
this.loading = false;
}
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNo = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 添加/修改操作 */
openForm(id) {
this.$refs["formRef"].open(id);
},
/** 删除按钮操作 */
async handleDelete(row) {
const customerId = row.customerId;
await this.$modal.confirm('是否确认删除机床客户信息编号为"' + customerId + '"的数据项?')
try {
await CustomerInfoApi.deleteCustomerInfo(customerId);
await this.getList();
this.$modal.msgSuccess("删除成功");
} catch {
}
},
/** 导出按钮操作 */
async handleExport() {
await this.$modal.confirm('是否确认导出所有机床客户信息数据项?');
try {
this.exportLoading = true;
const data = await CustomerInfoApi.exportCustomerInfoExcel(this.queryParams);
this.$download.excel(data, '机床客户信息.xls');
} catch {
} finally {
this.exportLoading = false;
}
},
}
};
</script>