feat(mes): 新增 MES 客户表 DDL、字典、菜单权限与测试数据
- 建表 mes_md_client(含逻辑删除、多租户字段) - 字典 mes_client_type:企业客户(1)、个人(2) - 菜单权限 5140~5146:查询/创建/更新/删除/导出/导入 - 测试数据:比亚迪、博世、德力西pull/871/MERGE
parent
5153adf1cf
commit
15d64fe772
|
|
@ -0,0 +1,73 @@
|
||||||
|
import request from '@/config/axios'
|
||||||
|
|
||||||
|
// MES 客户 VO
|
||||||
|
export interface MdClientVO {
|
||||||
|
id: number // 客户编号
|
||||||
|
code: string // 客户编码
|
||||||
|
name: string // 客户名称
|
||||||
|
nickname: string // 客户简称
|
||||||
|
englishName: string // 客户英文名称
|
||||||
|
description: string // 客户简介
|
||||||
|
logo: string // 客户LOGO地址
|
||||||
|
type: number // 客户类型
|
||||||
|
address: string // 客户地址
|
||||||
|
website: string // 客户官网地址
|
||||||
|
email: string // 客户邮箱地址
|
||||||
|
telephone: string // 客户电话
|
||||||
|
contact1Name: string // 联系人1
|
||||||
|
contact1Telephone: string // 联系人1-电话
|
||||||
|
contact1Email: string // 联系人1-邮箱
|
||||||
|
contact2Name: string // 联系人2
|
||||||
|
contact2Telephone: string // 联系人2-电话
|
||||||
|
contact2Email: string // 联系人2-邮箱
|
||||||
|
creditCode: string // 统一社会信用代码
|
||||||
|
attribute1: string // 预留字段1
|
||||||
|
attribute2: string // 预留字段2
|
||||||
|
attribute3: number // 预留字段3
|
||||||
|
attribute4: number // 预留字段4
|
||||||
|
status: number // 状态
|
||||||
|
remark: string // 备注
|
||||||
|
}
|
||||||
|
|
||||||
|
// MES 客户 API
|
||||||
|
export const MdClientApi = {
|
||||||
|
// 查询客户分页
|
||||||
|
getClientPage: async (params: any) => {
|
||||||
|
return await request.get({ url: `/mes/md-client/page`, params })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 查询客户精简列表
|
||||||
|
getClientSimpleList: async () => {
|
||||||
|
return await request.get({ url: `/mes/md-client/simple-list` })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 查询客户详情
|
||||||
|
getClient: async (id: number) => {
|
||||||
|
return await request.get({ url: `/mes/md-client/get?id=` + id })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 新增客户
|
||||||
|
createClient: async (data: MdClientVO) => {
|
||||||
|
return await request.post({ url: `/mes/md-client/create`, data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 修改客户
|
||||||
|
updateClient: async (data: MdClientVO) => {
|
||||||
|
return await request.put({ url: `/mes/md-client/update`, data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 删除客户
|
||||||
|
deleteClient: async (id: number) => {
|
||||||
|
return await request.delete({ url: `/mes/md-client/delete?id=` + id })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 导出客户 Excel
|
||||||
|
exportClient: async (params: any) => {
|
||||||
|
return await request.download({ url: `/mes/md-client/export-excel`, params })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 下载客户导入模板
|
||||||
|
importTemplate: async () => {
|
||||||
|
return await request.download({ url: `/mes/md-client/get-import-template` })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -253,5 +253,6 @@ export enum DICT_TYPE {
|
||||||
IOT_MODBUS_FRAME_FORMAT = 'iot_modbus_frame_format', // IoT Modbus 帧格式
|
IOT_MODBUS_FRAME_FORMAT = 'iot_modbus_frame_format', // IoT Modbus 帧格式
|
||||||
|
|
||||||
// ========== MES - 制造执行系统模块 ==========
|
// ========== MES - 制造执行系统模块 ==========
|
||||||
MES_CLIENT_TYPE = 'mes_client_type' // MES 客户类型
|
MES_CLIENT_TYPE = 'mes_client_type', // MES 客户类型
|
||||||
|
MES_VENDOR_LEVEL = 'mes_vendor_level' // MES 供应商级别
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,315 @@
|
||||||
|
<template>
|
||||||
|
<Dialog :title="dialogTitle" v-model="dialogVisible" width="960px">
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
:rules="formRules"
|
||||||
|
label-width="120px"
|
||||||
|
v-loading="formLoading"
|
||||||
|
>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="客户编码" prop="code">
|
||||||
|
<el-input v-model="formData.code" placeholder="请输入客户编码">
|
||||||
|
<template #append>
|
||||||
|
<el-button @click="generateCode" :disabled="formType === 'update'">
|
||||||
|
生成
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="客户名称" prop="name">
|
||||||
|
<el-input v-model="formData.name" placeholder="请输入客户名称" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="客户简称" prop="nickname">
|
||||||
|
<el-input v-model="formData.nickname" placeholder="请输入客户简称" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="客户英文名称" prop="englishName">
|
||||||
|
<el-input v-model="formData.englishName" placeholder="请输入客户英文名称" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="客户类型" prop="type">
|
||||||
|
<el-select v-model="formData.type" placeholder="请选择客户类型" class="!w-1/1">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in getIntDictOptions(DICT_TYPE.MES_CLIENT_TYPE)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="客户简介" prop="description">
|
||||||
|
<el-input v-model="formData.description" type="textarea" placeholder="请输入客户简介" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="客户地址" prop="address">
|
||||||
|
<el-input v-model="formData.address" type="textarea" placeholder="请输入客户地址" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="客户官网地址" prop="website">
|
||||||
|
<el-input v-model="formData.website" placeholder="请输入客户官网地址" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="客户邮箱地址" prop="email">
|
||||||
|
<el-input v-model="formData.email" placeholder="请输入客户邮箱地址" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="客户电话" prop="telephone">
|
||||||
|
<el-input v-model="formData.telephone" placeholder="请输入客户电话" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="客户LOGO" prop="logo">
|
||||||
|
<el-input v-model="formData.logo" placeholder="请输入客户LOGO地址" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="联系人1" prop="contact1Name">
|
||||||
|
<el-input v-model="formData.contact1Name" placeholder="请输入联系人1" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="联系人1-电话" prop="contact1Telephone">
|
||||||
|
<el-input v-model="formData.contact1Telephone" placeholder="请输入联系人1电话" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="联系人1-邮箱" prop="contact1Email">
|
||||||
|
<el-input v-model="formData.contact1Email" placeholder="请输入联系人1邮箱" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="联系人2" prop="contact2Name">
|
||||||
|
<el-input v-model="formData.contact2Name" placeholder="请输入联系人2" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="联系人2-电话" prop="contact2Telephone">
|
||||||
|
<el-input v-model="formData.contact2Telephone" placeholder="请输入联系人2电话" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="联系人2-邮箱" prop="contact2Email">
|
||||||
|
<el-input v-model="formData.contact2Email" placeholder="请输入联系人2邮箱" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="社会信用代码" prop="creditCode">
|
||||||
|
<el-input v-model="formData.creditCode" placeholder="请输入统一社会信用代码" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="状态" prop="status">
|
||||||
|
<el-radio-group v-model="formData.status">
|
||||||
|
<el-radio
|
||||||
|
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||||
|
:key="dict.value"
|
||||||
|
:value="dict.value"
|
||||||
|
>
|
||||||
|
{{ dict.label }}
|
||||||
|
</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="formData.remark" type="textarea" placeholder="请输入备注" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
<!-- 编辑时显示关联数据 tab -->
|
||||||
|
<el-tabs v-if="formType === 'update'" v-model="activeTab" class="mt-10px">
|
||||||
|
<el-tab-pane label="产品清单" name="item">
|
||||||
|
<!-- TODO @芋艿:客户详情-产品清单 tab,依赖物料模块按客户查询 -->
|
||||||
|
<el-empty description="功能开发中,敬请期待" />
|
||||||
|
</el-tab-pane>
|
||||||
|
<el-tab-pane label="销售记录" name="salesRecord">
|
||||||
|
<!-- TODO @芋艿:客户详情-销售记录 tab,依赖 WM 销售出库模块 -->
|
||||||
|
<el-empty description="功能开发中,敬请期待" />
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||||
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||||
|
import { MdClientApi, MdClientVO } from '@/api/mes/md/client'
|
||||||
|
import { CommonStatusEnum } from '@/utils/constants'
|
||||||
|
import { generateRandomStr } from '@/utils'
|
||||||
|
|
||||||
|
defineOptions({ name: 'MdClientForm' })
|
||||||
|
|
||||||
|
const { t } = useI18n() // 国际化
|
||||||
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||||
|
const dialogTitle = ref('') // 弹窗的标题
|
||||||
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||||
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||||
|
const activeTab = ref('item') // 当前激活的 tab
|
||||||
|
const formData = ref({
|
||||||
|
id: undefined,
|
||||||
|
code: undefined,
|
||||||
|
name: undefined,
|
||||||
|
nickname: undefined,
|
||||||
|
englishName: undefined,
|
||||||
|
description: undefined,
|
||||||
|
logo: undefined,
|
||||||
|
type: undefined,
|
||||||
|
address: undefined,
|
||||||
|
website: undefined,
|
||||||
|
email: undefined,
|
||||||
|
telephone: undefined,
|
||||||
|
contact1Name: undefined,
|
||||||
|
contact1Telephone: undefined,
|
||||||
|
contact1Email: undefined,
|
||||||
|
contact2Name: undefined,
|
||||||
|
contact2Telephone: undefined,
|
||||||
|
contact2Email: undefined,
|
||||||
|
creditCode: undefined,
|
||||||
|
status: CommonStatusEnum.ENABLE,
|
||||||
|
remark: undefined
|
||||||
|
})
|
||||||
|
const formRules = reactive({
|
||||||
|
code: [{ required: true, message: '客户编码不能为空', trigger: 'blur' }],
|
||||||
|
name: [
|
||||||
|
{ required: true, message: '客户名称不能为空', trigger: 'blur' },
|
||||||
|
{ max: 100, message: '客户名称不能超过100个字符', trigger: 'blur' }
|
||||||
|
],
|
||||||
|
type: [{ required: true, message: '客户类型不能为空', trigger: 'change' }],
|
||||||
|
status: [{ required: true, message: '状态不能为空', trigger: 'blur' }],
|
||||||
|
email: [
|
||||||
|
{
|
||||||
|
type: 'email',
|
||||||
|
message: '请输入正确的邮箱地址',
|
||||||
|
trigger: ['blur', 'change']
|
||||||
|
}
|
||||||
|
],
|
||||||
|
contact1Email: [
|
||||||
|
{
|
||||||
|
type: 'email',
|
||||||
|
message: '请输入正确的邮箱地址',
|
||||||
|
trigger: ['blur', 'change']
|
||||||
|
}
|
||||||
|
],
|
||||||
|
contact2Email: [
|
||||||
|
{
|
||||||
|
type: 'email',
|
||||||
|
message: '请输入正确的邮箱地址',
|
||||||
|
trigger: ['blur', 'change']
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
const formRef = ref() // 表单 Ref
|
||||||
|
|
||||||
|
/** 生成客户编码 */
|
||||||
|
const generateCode = () => {
|
||||||
|
// TODO @芋艿:后续对接后端编码生成接口
|
||||||
|
formData.value.code = 'CL' + generateRandomStr(12)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 打开弹窗 */
|
||||||
|
const open = async (type: string, id?: number) => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
dialogTitle.value = t('action.' + type)
|
||||||
|
formType.value = type
|
||||||
|
resetForm()
|
||||||
|
// 修改时,设置数据
|
||||||
|
if (id) {
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
formData.value = await MdClientApi.getClient(id)
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
|
/** 提交表单 */
|
||||||
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||||
|
const submitForm = async () => {
|
||||||
|
// 校验表单
|
||||||
|
await formRef.value.validate()
|
||||||
|
// 提交请求
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
const data = formData.value as unknown as MdClientVO
|
||||||
|
if (formType.value === 'create') {
|
||||||
|
await MdClientApi.createClient(data)
|
||||||
|
message.success(t('common.createSuccess'))
|
||||||
|
} else {
|
||||||
|
await MdClientApi.updateClient(data)
|
||||||
|
message.success(t('common.updateSuccess'))
|
||||||
|
}
|
||||||
|
dialogVisible.value = false
|
||||||
|
// 发送操作成功的事件
|
||||||
|
emit('success')
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置表单 */
|
||||||
|
const resetForm = () => {
|
||||||
|
formData.value = {
|
||||||
|
id: undefined,
|
||||||
|
code: undefined,
|
||||||
|
name: undefined,
|
||||||
|
nickname: undefined,
|
||||||
|
englishName: undefined,
|
||||||
|
description: undefined,
|
||||||
|
logo: undefined,
|
||||||
|
type: undefined,
|
||||||
|
address: undefined,
|
||||||
|
website: undefined,
|
||||||
|
email: undefined,
|
||||||
|
telephone: undefined,
|
||||||
|
contact1Name: undefined,
|
||||||
|
contact1Telephone: undefined,
|
||||||
|
contact1Email: undefined,
|
||||||
|
contact2Name: undefined,
|
||||||
|
contact2Telephone: undefined,
|
||||||
|
contact2Email: undefined,
|
||||||
|
creditCode: undefined,
|
||||||
|
status: CommonStatusEnum.ENABLE,
|
||||||
|
remark: undefined
|
||||||
|
}
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,138 @@
|
||||||
|
<template>
|
||||||
|
<Dialog v-model="dialogVisible" title="客户导入" width="400">
|
||||||
|
<el-upload
|
||||||
|
ref="uploadRef"
|
||||||
|
v-model:file-list="fileList"
|
||||||
|
:action="importUrl + '?updateSupport=' + updateSupport"
|
||||||
|
:auto-upload="false"
|
||||||
|
:disabled="formLoading"
|
||||||
|
:headers="uploadHeaders"
|
||||||
|
:limit="1"
|
||||||
|
:on-error="submitFormError"
|
||||||
|
:on-exceed="handleExceed"
|
||||||
|
:on-success="submitFormSuccess"
|
||||||
|
accept=".xlsx, .xls"
|
||||||
|
drag
|
||||||
|
>
|
||||||
|
<Icon icon="ep:upload" />
|
||||||
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||||
|
<template #tip>
|
||||||
|
<div class="el-upload__tip text-center">
|
||||||
|
<div class="el-upload__tip">
|
||||||
|
<el-checkbox v-model="updateSupport" />
|
||||||
|
是否更新已经存在的客户数据
|
||||||
|
</div>
|
||||||
|
<span>仅允许导入 xls、xlsx 格式文件。</span>
|
||||||
|
<el-link
|
||||||
|
:underline="false"
|
||||||
|
style="font-size: 12px; vertical-align: baseline"
|
||||||
|
type="primary"
|
||||||
|
@click="importTemplate"
|
||||||
|
>
|
||||||
|
下载模板
|
||||||
|
</el-link>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-upload>
|
||||||
|
<template #footer>
|
||||||
|
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { MdClientApi } from '@/api/mes/md/client'
|
||||||
|
import { getAccessToken, getTenantId } from '@/utils/auth'
|
||||||
|
import download from '@/utils/download'
|
||||||
|
|
||||||
|
defineOptions({ name: 'MdClientImportForm' })
|
||||||
|
|
||||||
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||||
|
const formLoading = ref(false) // 表单的加载中
|
||||||
|
const uploadRef = ref()
|
||||||
|
const importUrl =
|
||||||
|
import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + '/mes/md-client/import'
|
||||||
|
const uploadHeaders = ref() // 上传 Header 头
|
||||||
|
const fileList = ref([]) // 文件列表
|
||||||
|
const updateSupport = ref(0) // 是否更新已经存在的客户数据
|
||||||
|
|
||||||
|
/** 打开弹窗 */
|
||||||
|
const open = () => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
updateSupport.value = 0
|
||||||
|
fileList.value = []
|
||||||
|
resetForm()
|
||||||
|
}
|
||||||
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
|
/** 提交表单 */
|
||||||
|
const submitForm = async () => {
|
||||||
|
if (fileList.value.length == 0) {
|
||||||
|
message.error('请上传文件')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 提交请求
|
||||||
|
uploadHeaders.value = {
|
||||||
|
Authorization: 'Bearer ' + getAccessToken(),
|
||||||
|
'tenant-id': getTenantId()
|
||||||
|
}
|
||||||
|
formLoading.value = true
|
||||||
|
uploadRef.value!.submit()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 文件上传成功 */
|
||||||
|
const emits = defineEmits(['success'])
|
||||||
|
const submitFormSuccess = (response: any) => {
|
||||||
|
if (response.code !== 0) {
|
||||||
|
message.error(response.msg)
|
||||||
|
resetForm()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 拼接提示语
|
||||||
|
const data = response.data
|
||||||
|
let text = '上传成功数量:' + data.createCodes.length + ';'
|
||||||
|
for (let code of data.createCodes) {
|
||||||
|
text += '< ' + code + ' >'
|
||||||
|
}
|
||||||
|
text += '更新成功数量:' + data.updateCodes.length + ';'
|
||||||
|
for (const code of data.updateCodes) {
|
||||||
|
text += '< ' + code + ' >'
|
||||||
|
}
|
||||||
|
text += '更新失败数量:' + Object.keys(data.failureCodes).length + ';'
|
||||||
|
for (const code in data.failureCodes) {
|
||||||
|
text += '< ' + code + ': ' + data.failureCodes[code] + ' >'
|
||||||
|
}
|
||||||
|
message.alert(text)
|
||||||
|
formLoading.value = false
|
||||||
|
dialogVisible.value = false
|
||||||
|
// 发送操作成功的事件
|
||||||
|
emits('success')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 上传错误提示 */
|
||||||
|
const submitFormError = (): void => {
|
||||||
|
message.error('上传失败,请您重新上传!')
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置表单 */
|
||||||
|
const resetForm = async (): Promise<void> => {
|
||||||
|
// 重置上传状态和文件
|
||||||
|
formLoading.value = false
|
||||||
|
await nextTick()
|
||||||
|
uploadRef.value?.clearFiles()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 文件数超出提示 */
|
||||||
|
const handleExceed = (): void => {
|
||||||
|
message.error('最多只能上传一个文件!')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 下载模板操作 */
|
||||||
|
const importTemplate = async () => {
|
||||||
|
const res = await MdClientApi.importTemplate()
|
||||||
|
download.excel(res, '客户导入模板.xls')
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,248 @@
|
||||||
|
<template>
|
||||||
|
<ContentWrap>
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
|
<el-form
|
||||||
|
class="-mb-15px"
|
||||||
|
:model="queryParams"
|
||||||
|
ref="queryFormRef"
|
||||||
|
:inline="true"
|
||||||
|
label-width="68px"
|
||||||
|
>
|
||||||
|
<el-form-item label="客户编码" prop="code">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.code"
|
||||||
|
placeholder="请输入客户编码"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="客户名称" prop="name">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.name"
|
||||||
|
placeholder="请输入客户名称"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="客户简称" prop="nickname">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.nickname"
|
||||||
|
placeholder="请输入客户简称"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="客户类型" prop="type">
|
||||||
|
<el-select v-model="queryParams.type" placeholder="请选择客户类型" clearable class="!w-240px">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in getIntDictOptions(DICT_TYPE.MES_CLIENT_TYPE)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态" prop="status">
|
||||||
|
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable class="!w-240px">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||||
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
@click="openForm('create')"
|
||||||
|
v-hasPermi="['mes:md-client:create']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
plain
|
||||||
|
@click="handleImport"
|
||||||
|
v-hasPermi="['mes:md-client:import']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:upload" class="mr-5px" /> 导入
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
@click="handleExport"
|
||||||
|
:loading="exportLoading"
|
||||||
|
v-hasPermi="['mes:md-client:export']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<ContentWrap>
|
||||||
|
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||||
|
<el-table-column label="客户编码" align="center" prop="code" />
|
||||||
|
<el-table-column label="客户名称" align="center" prop="name" width="150" />
|
||||||
|
<el-table-column label="客户简称" align="center" prop="nickname" />
|
||||||
|
<el-table-column label="客户类型" align="center" prop="type">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :type="DICT_TYPE.MES_CLIENT_TYPE" :value="scope.row.type" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="客户电话" align="center" prop="telephone" />
|
||||||
|
<el-table-column label="联系人1" align="center" prop="contact1Name" />
|
||||||
|
<el-table-column label="联系人1-电话" align="center" prop="contact1Telephone" />
|
||||||
|
<el-table-column label="状态" align="center" prop="status">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="创建时间"
|
||||||
|
align="center"
|
||||||
|
prop="createTime"
|
||||||
|
:formatter="dateFormatter"
|
||||||
|
width="180px"
|
||||||
|
/>
|
||||||
|
<el-table-column label="操作" align="center" width="150">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
@click="openForm('update', scope.row.id)"
|
||||||
|
v-hasPermi="['mes:md-client:update']"
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="danger"
|
||||||
|
@click="handleDelete(scope.row.id)"
|
||||||
|
v-hasPermi="['mes:md-client:delete']"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<!-- 分页 -->
|
||||||
|
<Pagination
|
||||||
|
:total="total"
|
||||||
|
v-model:page="queryParams.pageNo"
|
||||||
|
v-model:limit="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<!-- 表单弹窗:添加/修改 -->
|
||||||
|
<MdClientForm ref="formRef" @success="getList" />
|
||||||
|
<!-- 客户导入对话框 -->
|
||||||
|
<MdClientImportForm ref="importFormRef" @success="getList" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
|
import download from '@/utils/download'
|
||||||
|
import { MdClientApi, MdClientVO } from '@/api/mes/md/client'
|
||||||
|
import MdClientForm from './MdClientForm.vue'
|
||||||
|
import MdClientImportForm from './MdClientImportForm.vue'
|
||||||
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||||
|
|
||||||
|
defineOptions({ name: 'MesMdClient' })
|
||||||
|
|
||||||
|
const message = useMessage() // 消息弹窗
|
||||||
|
const { t } = useI18n() // 国际化
|
||||||
|
|
||||||
|
const loading = ref(true) // 列表的加载中
|
||||||
|
const list = ref<MdClientVO[]>([]) // 列表的数据
|
||||||
|
const total = ref(0) // 列表的总页数
|
||||||
|
const queryParams = reactive({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
code: undefined,
|
||||||
|
name: undefined,
|
||||||
|
nickname: undefined,
|
||||||
|
type: undefined,
|
||||||
|
status: undefined
|
||||||
|
})
|
||||||
|
const queryFormRef = ref() // 搜索的表单
|
||||||
|
const exportLoading = ref(false) // 导出的加载中
|
||||||
|
|
||||||
|
/** 查询列表 */
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const data = await MdClientApi.getClientPage(queryParams)
|
||||||
|
list.value = data.list
|
||||||
|
total.value = data.total
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
const handleQuery = () => {
|
||||||
|
queryParams.pageNo = 1
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
const resetQuery = () => {
|
||||||
|
queryFormRef.value.resetFields()
|
||||||
|
handleQuery()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 添加/修改操作 */
|
||||||
|
const formRef = ref()
|
||||||
|
const openForm = (type: string, id?: number) => {
|
||||||
|
formRef.value.open(type, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 客户导入 */
|
||||||
|
const importFormRef = ref()
|
||||||
|
const handleImport = () => {
|
||||||
|
importFormRef.value.open()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
const handleDelete = async (id: number) => {
|
||||||
|
try {
|
||||||
|
// 删除的二次确认
|
||||||
|
await message.delConfirm()
|
||||||
|
// 发起删除
|
||||||
|
await MdClientApi.deleteClient(id)
|
||||||
|
message.success(t('common.delSuccess'))
|
||||||
|
// 刷新列表
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
const handleExport = async () => {
|
||||||
|
try {
|
||||||
|
// 导出的二次确认
|
||||||
|
await message.exportConfirm()
|
||||||
|
// 发起导出
|
||||||
|
exportLoading.value = true
|
||||||
|
const data = await MdClientApi.exportClient(queryParams)
|
||||||
|
download.excel(data, '客户.xls')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
exportLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 初始化 **/
|
||||||
|
onMounted(() => {
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,138 @@
|
||||||
|
<template>
|
||||||
|
<Dialog v-model="dialogVisible" title="物料导入" width="400">
|
||||||
|
<el-upload
|
||||||
|
ref="uploadRef"
|
||||||
|
v-model:file-list="fileList"
|
||||||
|
:action="importUrl + '?updateSupport=' + updateSupport"
|
||||||
|
:auto-upload="false"
|
||||||
|
:disabled="formLoading"
|
||||||
|
:headers="uploadHeaders"
|
||||||
|
:limit="1"
|
||||||
|
:on-error="submitFormError"
|
||||||
|
:on-exceed="handleExceed"
|
||||||
|
:on-success="submitFormSuccess"
|
||||||
|
accept=".xlsx, .xls"
|
||||||
|
drag
|
||||||
|
>
|
||||||
|
<Icon icon="ep:upload" />
|
||||||
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||||
|
<template #tip>
|
||||||
|
<div class="el-upload__tip text-center">
|
||||||
|
<div class="el-upload__tip">
|
||||||
|
<el-checkbox v-model="updateSupport" />
|
||||||
|
是否更新已经存在的物料数据
|
||||||
|
</div>
|
||||||
|
<span>仅允许导入 xls、xlsx 格式文件。</span>
|
||||||
|
<el-link
|
||||||
|
:underline="false"
|
||||||
|
style="font-size: 12px; vertical-align: baseline"
|
||||||
|
type="primary"
|
||||||
|
@click="importTemplate"
|
||||||
|
>
|
||||||
|
下载模板
|
||||||
|
</el-link>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-upload>
|
||||||
|
<template #footer>
|
||||||
|
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { MdItemApi } from '@/api/mes/md/item'
|
||||||
|
import { getAccessToken, getTenantId } from '@/utils/auth'
|
||||||
|
import download from '@/utils/download'
|
||||||
|
|
||||||
|
defineOptions({ name: 'MdItemImportForm' })
|
||||||
|
|
||||||
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||||
|
const formLoading = ref(false) // 表单的加载中
|
||||||
|
const uploadRef = ref()
|
||||||
|
const importUrl =
|
||||||
|
import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + '/mes/md/item/import'
|
||||||
|
const uploadHeaders = ref() // 上传 Header 头
|
||||||
|
const fileList = ref([]) // 文件列表
|
||||||
|
const updateSupport = ref(0) // 是否更新已经存在的物料数据
|
||||||
|
|
||||||
|
/** 打开弹窗 */
|
||||||
|
const open = () => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
updateSupport.value = 0
|
||||||
|
fileList.value = []
|
||||||
|
resetForm()
|
||||||
|
}
|
||||||
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
|
/** 提交表单 */
|
||||||
|
const submitForm = async () => {
|
||||||
|
if (fileList.value.length == 0) {
|
||||||
|
message.error('请上传文件')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 提交请求
|
||||||
|
uploadHeaders.value = {
|
||||||
|
Authorization: 'Bearer ' + getAccessToken(),
|
||||||
|
'tenant-id': getTenantId()
|
||||||
|
}
|
||||||
|
formLoading.value = true
|
||||||
|
uploadRef.value!.submit()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 文件上传成功 */
|
||||||
|
const emits = defineEmits(['success'])
|
||||||
|
const submitFormSuccess = (response: any) => {
|
||||||
|
if (response.code !== 0) {
|
||||||
|
message.error(response.msg)
|
||||||
|
resetForm()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 拼接提示语
|
||||||
|
const data = response.data
|
||||||
|
let text = '上传成功数量:' + data.createCodes.length + ';'
|
||||||
|
for (let code of data.createCodes) {
|
||||||
|
text += '< ' + code + ' >'
|
||||||
|
}
|
||||||
|
text += '更新成功数量:' + data.updateCodes.length + ';'
|
||||||
|
for (const code of data.updateCodes) {
|
||||||
|
text += '< ' + code + ' >'
|
||||||
|
}
|
||||||
|
text += '更新失败数量:' + Object.keys(data.failureCodes).length + ';'
|
||||||
|
for (const code in data.failureCodes) {
|
||||||
|
text += '< ' + code + ': ' + data.failureCodes[code] + ' >'
|
||||||
|
}
|
||||||
|
message.alert(text)
|
||||||
|
formLoading.value = false
|
||||||
|
dialogVisible.value = false
|
||||||
|
// 发送操作成功的事件
|
||||||
|
emits('success')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 上传错误提示 */
|
||||||
|
const submitFormError = (): void => {
|
||||||
|
message.error('上传失败,请您重新上传!')
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置表单 */
|
||||||
|
const resetForm = async (): Promise<void> => {
|
||||||
|
// 重置上传状态和文件
|
||||||
|
formLoading.value = false
|
||||||
|
await nextTick()
|
||||||
|
uploadRef.value?.clearFiles()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 文件数超出提示 */
|
||||||
|
const handleExceed = (): void => {
|
||||||
|
message.error('最多只能上传一个文件!')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 下载模板操作 */
|
||||||
|
const importTemplate = async () => {
|
||||||
|
const res = await MdItemApi.importTemplate()
|
||||||
|
download.excel(res, '物料导入模板.xls')
|
||||||
|
}
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue