Commit 5a94c44f by 金民

Merge remote-tracking branch 'origin/weiqiao-vue3' into weiqiao-vue3

parents 72f71591 aa32be0a
# 是否开启mock数据,关闭时需要自行对接后台接口
VITE_USE_MOCK=false
VITE_USE_MOCK = false
# 资源公共路径,需要以 /开头和结尾
VITE_PUBLIC_PATH=/
VITE_PUBLIC_PATH = /
# 本地开发代理(解决跨域)
# 所有匹配前缀的请求将被代理到目标服务器
VITE_PROXY=[["/system","http://localhost:8080"],["/language","http://localhost:8080"],["/api","http://localhost:8080"]]
# 本地开发代理,可以解决跨域及多地址代理
# 如果接口地址匹配到,则会转发到http://localhost:3000,防止本地出现跨域问题
# 可以有多个,注意多个不能换行,否则代理将会失效
# VITE_PROXY = [["/basic-api","http://localhost:3000"],["/upload","http://localhost:3300/upload"]]
# VITE_PROXY=[["/api","https://vvbin.cn/test"]]
# 是否删除Console.log
VITE_DROP_CONSOLE=false
VITE_DROP_CONSOLE = false
# 接口地址(用于代码中生成 baseURL)
# 接口地址
# 如果没有跨域问题,直接在这里配置即可
# VITE_GLOB_API_URL=http://192.168.8.73:8080
VITE_GLOB_API_URL=http://localhost:8080
# 文件上传接口
VITE_GLOB_UPLOAD_URL=/system/oss/upload
# 文件上传接口 可选
VITE_GLOB_UPLOAD_URL = /system/oss/upload
# 文件预览接口
VITE_GLOB_UPLOAD_PREVIEW=http://114.116.210.204:8013/onlinePreview?url=
# 文件预览接口 可选
VITE_GLOB_UPLOAD_PREVIEW = http://114.116.210.204:8013/onlinePreview?url=
# 外部url地址
VITE_GLOB_OUT_LINK_URL=http://localhost:4100
#外部url地址
VITE_GLOB_OUT_LINK_URL = http://localhost:4100
# 打印项目地址
VITE_GLOB_PRINT_BASE_URL=http://vue.xjrsoft.com:3300
#打印项目地址
VITE_GLOB_PRINT_BASE_URL = http://vue.xjrsoft.com:3300
# IM URL 地址
VITE_GLOB_IM_LINK_URL=http://localhost:8827
#IM URL 地址
VITE_GLOB_IM_LINK_URL = http://localhost:8827
# 调查问卷地址
VITE_GLOB_QN_LINK_URL=http://localhost:3100
#调查问卷地址
VITE_GLOB_QN_LINK_URL = http://localhost:3100
# 接口地址前缀(如统一加 /prefix)
VITE_GLOB_API_URL_PREFIX=
# 接口地址前缀,有些系统所有接口地址都有前缀,可以在这里统一加,方便切换
VITE_GLOB_API_URL_PREFIX =
# 是否启用官网代码
VITE_GLOB_PRODUCTION=false
VITE_GLOB_PRODUCTION = false
......@@ -29,21 +29,6 @@ export async function getMesCollectionItemPage(params: MesCollectionItemPagePara
}
/**
* @description: 查询MesCollectionItem列表(不分页)
*/
export async function getMesCollectionItemList(params?: MesCollectionItemPageParams, mode: ErrorMessageMode = 'modal') {
return defHttp.get<MesCollectionItemPageModel[]>(
{
url: Api.List,
params,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 获取MesCollectionItem信息
*/
export async function getMesCollectionItem(id: String, mode: ErrorMessageMode = 'modal') {
......
......@@ -4,33 +4,173 @@ import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';
* @description: RokeRouting分页参数 模型
*/
export interface RokeRoutingPageParams extends BasicPageParams {
code: string;
companyId: string;
name: string;
lotRuleId: string;
}
internalCode: string;
/**
* @description: RokeRouting分页返回值模型
*/
export interface RokeRoutingPageModel {
id: string;
deductionBasis: string;
code: string;
note: string;
companyId: string;
name: string;
lotRuleId: string;
}
/**
* @description: RokeRouting分页返回值模
* @description: RokeRouting表类
*/
export interface RokeRoutingPageModel {
export interface RokeRoutingModel {
id: string;
messageMainAttachmentId: string;
name: string;
code: string;
internalCode: string;
active: string;
note: string;
companyId: string;
lotRuleId: string;
autoDeduction: string;
deductionAutoConfirm: string;
deductionMoment: string;
deductionBasis: string;
note: string;
deductionWorkCenter: string;
documentId: string;
productId: string;
routingQualityMode: string;
deleteMark: string;
createDate: string;
createUserId: string;
modifyDate: string;
modifyUserId: string;
rokeRoutingProcessList?: RokeRoutingProcessModel;
}
0;
/**
* @description: RokeRoutingProcess表类型
*/
export interface RokeRoutingProcessModel {
id: string;
deleteMark: string;
name: string;
code: string;
categoryId: string;
processType: string;
internalCode: string;
active: string;
withoutWoProduce: string;
note: string;
ratedWorkingHours: string;
companyId: string;
isPress: string;
prepareWorkHours: string;
collectionSchemeId: string;
qualityMode: string;
qcSchemeId: string;
isQuality: string;
salaryType: string;
baseQty: string;
salaryUnit: string;
salary: string;
salaryCode: string;
qcSalaryBasis: string;
qcSalaryType: string;
qcBaseQty: string;
qcSalaryUnit: string;
qcSalary: string;
qcSalaryCode: string;
defaultReporter: string;
collectionItem: string;
inspectionCollectionItem: string;
inspectionScheme: string;
inspectionDepartment: string;
inspectionStaff: string;
defectProcessing: string;
createDate: string;
createUserId: string;
modifyDate: string;
modifyUserId: string;
zyzdFile: string;
zyzdtpFile: string;
routingId: string;
processId: string;
}
/**
* @description: RokeRouting分页返回值结构
......
......@@ -6,19 +6,25 @@ import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';
export interface RokeEmployeePageParams extends BasicPageParams {
name: string;
code: string;
phone: string;
skillLevelId: string;
jobNumber: string;
positionId: string;
gender: string;
departmentId: string;
phone: string;
gender: string;
idNumber: string;
note: string;
isOnJob: string;
companyId: string;
}
/**
......@@ -33,15 +39,7 @@ export interface RokeEmployeePageModel {
positionId: string;
gender: string;
departmentId: string;
phone: string;
age: string;
note: string;
}
0;
......
import { MesBaseBomPageModel, MesBaseBomPageParams, MesBaseBomPageResult } from './model/WlqdModel';
import { defHttp } from '/@/utils/http/axios';
import { ErrorMessageMode } from '/#/axios';
enum Api {
Page = '/jcsj/wlqd/page',
List = '/jcsj/wlqd/list',
Info = '/jcsj/wlqd/info',
MesBaseBom = '/jcsj/wlqd',
}
/**
* @description: 查询MesBaseBom分页列表
*/
export async function getMesBaseBomPage(params: MesBaseBomPageParams, mode: ErrorMessageMode = 'modal') {
return defHttp.get<MesBaseBomPageResult>(
{
url: Api.Page,
params,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 获取MesBaseBom信息
*/
export async function getMesBaseBom(id: String, mode: ErrorMessageMode = 'modal') {
return defHttp.get<MesBaseBomPageModel>(
{
url: Api.Info,
params: { id },
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 新增MesBaseBom
*/
export async function addMesBaseBom(mesBaseBom: Recordable, mode: ErrorMessageMode = 'modal') {
return defHttp.post<boolean>(
{
url: Api.MesBaseBom,
params: mesBaseBom,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 更新MesBaseBom
*/
export async function updateMesBaseBom(mesBaseBom: Recordable, mode: ErrorMessageMode = 'modal') {
return defHttp.put<boolean>(
{
url: Api.MesBaseBom,
params: mesBaseBom,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 删除MesBaseBom(批量删除)
*/
export async function deleteMesBaseBom(ids: string[], mode: ErrorMessageMode = 'modal') {
return defHttp.delete<boolean>(
{
url: Api.MesBaseBom,
data: ids,
},
{
errorMessageMode: mode,
},
);
}
import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';
/**
* @description: MesBaseBom分页参数 模型
*/
export interface MesBaseBomPageParams extends BasicPageParams {
bommc: string;
bomsl: string;
bombb: string;
cpid: string;
cpbh: string;
cpmc: string;
cpgg: string;
cpxh: string;
sfyy: string;
bz: string;
}
/**
* @description: MesBaseBom分页返回值模型
*/
export interface MesBaseBomPageModel {
id: string;
bommc: string;
bomsl: string;
bombb: string;
cpid: string;
sfyy: string;
cpbh: string;
cpmc: string;
cpgg: string;
cpxh: string;
bz: string;
}
/**
* @description: MesBaseBom表类型
*/
export interface MesBaseBomModel {
id: string;
deleteMark: string;
cpid: string;
bommc: string;
bomsl: string;
sfyy: string;
cpbh: string;
cpmc: string;
bombb: string;
bz: string;
cpgg: string;
cpxh: string;
p1: string;
p2: string;
p3: string;
p4: string;
p5: string;
p6: string;
p7: string;
p8: string;
p9: string;
p10: string;
createDate: string;
createUserId: string;
modifyDate: string;
modifyUserId: string;
mesBaseBomItemList?: MesBaseBomItemModel;
}
/**
* @description: MesBaseBomItem表类型
*/
export interface MesBaseBomItemModel {
id: string;
deleteMark: string;
bomid: string;
wlbh: string;
wlmc: string;
wlsl: string;
wlkcl: string;
khbz: string;
nkbz: string;
sftl: string;
p1: string;
p2: string;
p3: string;
p4: string;
p5: string;
p6: string;
p7: string;
p8: string;
p9: string;
p10: string;
createDate: string;
createUserId: string;
modifyDate: string;
modifyUserId: string;
bz: string;
}
/**
* @description: MesBaseBom分页返回值结构
*/
export type MesBaseBomPageResult = BasicFetchResult<MesBaseBomPageModel>;
......@@ -1667,21 +1667,12 @@
localStorage.setItem('tableColumnShowSetting', JSON.stringify(obj));
}
// 获取采集项表单API(用于采集方案页面)
const collectionItemFormApi = inject('collectionItemFormApi', null);
function customClick(executeButton, record?, index?) {
curRecord.value = index;
curButtonModalConfig.value = executeButton.modal;
// 特殊处理:如果是选择采集项按钮,直接调用provide的方法
if (executeButton.key === 'selectCollectionItem' && collectionItemFormApi) {
if (collectionItemFormApi.openCollectionItemSelect) {
collectionItemFormApi.openCollectionItemSelect();
}
return;
}
let obj = {
selectedRows: selectedRowsData.value,
tableDatas: data.value,
......
<template>
<BasicModal
v-bind="$attrs"
@register="registerModal"
title="选择采集项"
width="800"
@ok="handleSubmit"
@cancel="handleCancel"
:destroyOnClose="true"
>
<BasicTable @register="registerTable" />
</BasicModal>
</template>
<script lang="ts" setup>
import { ref, nextTick } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicTable, useTable } from '/@/components/Table';
import { getMesCollectionItemPage } from '/@/api/jcsj/cjx';
import { columns } from './collectionItemColumns';
import { useMessage } from '/@/hooks/web/useMessage';
const emit = defineEmits(['success']);
const { createMessage } = useMessage();
const contentType = ref<string>('');
const getExistingItemIds = ref<(() => string[]) | null>(null); // 获取已存在的采集项ID列表的函数
// 表格配置:不再维护外部 selection 状态
const [registerTable, {
reload,
clearSelectedRowKeys,
getSelectRows,
getDataSource,
setTableData
}] = useTable({
title: '采集项列表',
rowSelection: {
type: 'checkbox',
},
api: async (params) => {
if (!contentType.value) {
createMessage.warning('请先选择采集内容');
return { list: [], total: 0 };
}
const ctParam = String(contentType.value || '');
if (!ctParam) return { list: [], total: 0 };
const queryParams = {
...params,
contentType: ctParam,
size: Math.min(params.pageSize || 50, 100),
};
try {
const result = await getMesCollectionItemPage(queryParams);
// 兼容多种返回格式
if (Array.isArray(result)) {
return { list: result, total: result.length };
}
if (result?.list) {
return { list: result.list, total: result.total ?? result.list.length };
}
if (result?.records) {
return { list: result.records, total: result.total ?? result.records.length };
}
// 泛型兼容:找第一个数组字段
for (const key in result) {
if (Array.isArray(result[key])) {
return { list: result[key], total: result.total ?? result[key].length };
}
}
} catch (error: any) {
console.error('获取采集项失败:', error);
createMessage.error(error?.message || '请求失败');
}
return { list: [], total: 0 };
},
columns,
pagination: { pageSize: 50 },
rowKey: 'id',
canResize: false,
showIndexColumn: false,
useSearchForm: false,
});
// 弹窗注册
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
// 先重置所有状态,确保按钮可用
setModalProps({
confirmLoading: false,
destroyOnClose: true,
});
// 提取 contentType
let ctValue = data?.contentType;
if (Array.isArray(ctValue)) ctValue = ctValue[0];
contentType.value = ctValue ? String(ctValue) : '';
// 保存获取已存在采集项ID列表的函数
getExistingItemIds.value = typeof data?.getExistingItemIds === 'function'
? data.getExistingItemIds
: null;
if (!contentType.value) {
createMessage.warning('请先选择采集内容');
closeModal();
return;
}
// 等待 DOM 更新
await nextTick();
// 清除可能遗留的选中状态和数据
if (clearSelectedRowKeys) {
clearSelectedRowKeys();
}
if (setTableData) {
setTableData([]);
}
// 重新加载对应类型的数据
await reload();
// 再次确保选中已清空
await nextTick();
if (clearSelectedRowKeys) {
clearSelectedRowKeys();
}
// 确保按钮状态正确
setModalProps({
confirmLoading: false,
});
});
// 提交处理:直接从表格获取选中行
async function handleSubmit() {
try {
// 设置加载状态,防止重复点击
setModalProps({ confirmLoading: true });
const selectedRows = getSelectRows();
console.log('handleSubmit - selectedRows:', selectedRows);
if (!selectedRows || selectedRows.length === 0) {
createMessage.warning('请至少选择一个采集项');
setModalProps({ confirmLoading: false });
return;
}
// 在提交时实时获取最新的采集项列表,检查是否重复
let currentExistingItemIds: string[] = [];
if (getExistingItemIds.value) {
try {
const ids = getExistingItemIds.value();
currentExistingItemIds = Array.isArray(ids)
? ids.map(id => String(id)).filter(Boolean)
: [];
} catch (error) {
console.error('获取已存在的采集项列表失败:', error);
}
}
// 检查是否与已存在的采集项重复
const duplicateItems: any[] = [];
selectedRows.forEach((item: any) => {
const itemId = String(item.id || '');
if (currentExistingItemIds.includes(itemId)) {
duplicateItems.push(item);
}
});
if (duplicateItems.length > 0) {
const names = duplicateItems.map(item => item.name || item.code || item.id).join('、');
createMessage.warning(`以下采集项已存在,不可重复选择:${names}`);
setModalProps({ confirmLoading: false });
return;
}
// 触发成功事件
emit('success', selectedRows);
// 重置加载状态
setModalProps({ confirmLoading: false });
// 清空所有数据和状态(这些操作即使失败也不应该影响成功流程)
try {
if (clearSelectedRowKeys) {
clearSelectedRowKeys();
}
if (setTableData) {
setTableData([]);
}
} catch (cleanupError) {
console.warn('清空数据时出错(不影响提交):', cleanupError);
}
// 使用 nextTick 确保状态更新后再关闭
await nextTick();
closeModal();
} catch (error) {
console.error('提交失败:', error);
createMessage.error('提交失败,请重试');
setModalProps({ confirmLoading: false });
}
}
// 取消处理
function handleCancel() {
// 确保按钮状态正确
setModalProps({ confirmLoading: false });
// 清空所有数据和状态
if (clearSelectedRowKeys) {
clearSelectedRowKeys();
}
if (setTableData) {
setTableData([]);
}
closeModal();
}
</script>
<template>
<BasicModal
v-bind="$attrs"
@register="registerModal"
title="选择采集项"
@ok="handleSubmit"
@visible-change="handleVisibleChange"
@cancel="handleCancel"
width="800px"
:height="600"
>
<BasicTable @register="registerTable" />
</BasicModal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicTable, useTable } from '/@/components/Table';
import { FormSchema } from '/@/components/Form';
import { BasicColumn } from '/@/components/Table';
import { getMesCollectionItemPage } from '/@/api/jcsj/cjx';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n();
const emit = defineEmits(['success', 'register']);
const contentType = ref<string>('');
const searchFormSchema: FormSchema[] = [
{
field: 'code',
label: '编码',
component: 'Input',
colProps: { span: 8 },
},
{
field: 'name',
label: '名称',
component: 'Input',
colProps: { span: 8 },
},
];
const columns: BasicColumn[] = [
{
title: '编码',
dataIndex: 'code',
width: 150,
},
{
title: '名称',
dataIndex: 'name',
width: 200,
},
{
title: '采集内容',
dataIndex: 'contentType',
width: 150,
},
{
title: '备注',
dataIndex: 'note',
width: 200,
},
];
const [registerTable, { getSelectRows, reload, clearSelectedRowKeys, getForm }] = useTable({
title: '采集项列表',
api: getMesCollectionItemPage,
rowKey: 'id',
columns,
formConfig: {
labelWidth: 70,
schemas: searchFormSchema,
},
rowSelection: {
type: 'checkbox',
},
useSearchForm: true,
showTableSetting: false,
bordered: true,
pagination: {
pageSize: 10,
},
beforeFetch: (params) => {
// 根据选择的采集内容过滤
if (contentType.value) {
params.contentType = contentType.value;
}
return params;
},
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
contentType.value = data?.contentType || '';
setModalProps({ confirmLoading: false });
await reload();
});
// 清空弹窗内的操作
function clearModalOperations() {
// 清空表格选中项
clearSelectedRowKeys();
// 重置搜索表单
const form = getForm();
if (form) {
form.resetFields();
}
}
// 处理弹窗可见性变化
function handleVisibleChange(visible: boolean) {
// 当弹窗关闭时,清空操作
if (!visible) {
clearModalOperations();
}
}
// 处理取消事件
function handleCancel() {
clearModalOperations();
}
const handleSubmit = () => {
const selectedRows = getSelectRows();
if (selectedRows.length === 0) {
return;
}
emit('success', selectedRows);
closeModal();
};
</script>
import { BasicColumn } from '/@/components/Table';
export const columns: BasicColumn[] = [
{
title: '编码',
dataIndex: 'code',
width: 150,
},
{
title: '名称',
dataIndex: 'name',
width: 200,
},
{
title: '数据类型',
dataIndex: 'dataType',
width: 120,
},
{
title: '备注',
dataIndex: 'note',
width: 200,
},
];
......@@ -409,7 +409,7 @@ export const formProps: FormProps = {
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: (record: any) => record?._isFromSelect === true,
disabled: true,
allowClear: false,
showLabel: true,
required: false,
......@@ -440,7 +440,7 @@ export const formProps: FormProps = {
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: (record: any) => record?._isFromSelect === true,
disabled: true,
allowClear: false,
showLabel: true,
required: false,
......@@ -468,7 +468,7 @@ export const formProps: FormProps = {
showSearch: false,
isMultiple: false,
clearable: false,
disabled: (record: any) => record?._isFromSelect === true,
disabled: true,
staticOptions: [
{ key: 1, label: 'Option 1', value: 'Option 1' },
{ key: 2, label: 'Option 2', value: 'Option 2' },
......@@ -510,7 +510,7 @@ export const formProps: FormProps = {
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: (record: any) => record?._isFromSelect === true,
disabled: true,
allowClear: false,
showLabel: true,
required: false,
......@@ -567,7 +567,7 @@ export const formProps: FormProps = {
buttonName: '选择数据',
showLabel: true,
showComponentBorder: true,
showBorder: true,
showBorder: false,
bordercolor: '#f0f0f0',
bordershowtype: [true, true, true, true],
borderwidth: 1,
......@@ -603,20 +603,12 @@ export const formProps: FormProps = {
checked: false,
},
],
isShowAdd: false,
isShowAdd: true,
isShowDelete: true,
hasCheckedCol: true,
events: {},
showPagenation: true,
showColunmSet: false,
topButtonList: [
{
key: 'selectCollectionItem',
label: '新增',
style: 'primary',
icon: 'ant-design:plus-outlined',
},
],
},
},
],
......
......@@ -133,7 +133,7 @@
//展示在列表内的按钮
const actionButtons = ref<string[]>(["view","edit","delete"]);
const buttonConfigs = computed(()=>{
const list = [{"isUse":true,"name":"查看","code":"view","icon":"ant-design:eye-outlined","isDefault":true},{"isUse":true,"name":"新增","code":"add","icon":"ant-design:plus-outlined","isDefault":true},{"isUse":true,"name":"编辑","code":"edit","icon":"ant-design:form-outlined","isDefault":true,"isEnableLock":true},{"isUse":true,"name":"删除","code":"delete","icon":"ant-design:delete-outlined","isDefault":true}]
const list = [{"buttonId":"2006195708167311360","name":"查看","code":"view","icon":"ant-design:eye-outlined","isDefault":true,"isUse":true},{"buttonId":"2006195708171505664","name":"新增","code":"add","icon":"ant-design:plus-outlined","isDefault":true,"isUse":true},{"buttonId":"2006195708171505665","name":"编辑","code":"edit","icon":"ant-design:form-outlined","isDefault":true,"isUse":true,"isEnableLock":true},{"buttonId":"2006195708171505666","name":"删除","code":"delete","icon":"ant-design:delete-outlined","isDefault":true,"isUse":true}]
return filterButtonAuth(list);
})
......@@ -382,4 +382,4 @@
</style>
\ No newline at end of file
</style>
......@@ -51,21 +51,20 @@ export const permissionList = [
defaultValue: 1,
},
{
required: true,
required: false,
view: true,
edit: true,
disabled: false,
edit: false,
disabled: true,
isSaveTable: false,
tableName: '',
fieldName: '编号',
fieldId: 'code',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'bae97ad7fefb4f8aa692e678934e8f97',
type: 'auto-code',
key: '552fd440728b449eb2e2ed15bf8eb068',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
......@@ -74,14 +73,15 @@ export const permissionList = [
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '班组',
fieldId: 'teamId',
fieldName: '电话',
fieldId: 'phone',
isSubTable: false,
showChildren: true,
type: 'select',
key: 'b8f4cac721c84e4e8202cc66b54a6795',
type: 'input',
key: '488d22332deb4f2abf4a9423122d98f7',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
......@@ -107,15 +107,14 @@ export const permissionList = [
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '工号',
fieldId: 'jobNumber',
fieldName: '技能等级',
fieldId: 'skillLevelId',
isSubTable: false,
showChildren: true,
type: 'input',
key: '1ef1b726c6f34f4fa0d704afac0aac7a',
type: 'select',
key: '7126b5787dc647bda9c3b05d626a2cf2',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
......@@ -124,14 +123,15 @@ export const permissionList = [
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '职位',
fieldId: 'positionId',
fieldName: '工号',
fieldId: 'jobNumber',
isSubTable: false,
showChildren: true,
type: 'select',
key: 'ea8630c3055b4a28a85ef1fbefadfc75',
type: 'input',
key: '1ef1b726c6f34f4fa0d704afac0aac7a',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
......@@ -140,12 +140,12 @@ export const permissionList = [
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '性别',
fieldId: 'gender',
fieldName: '职位',
fieldId: 'positionId',
isSubTable: false,
showChildren: true,
type: 'select',
key: 'b5eb1855dc6d409280dbb7c4a333ae07',
key: 'ea8630c3055b4a28a85ef1fbefadfc75',
children: [],
options: {},
},
......@@ -172,31 +172,14 @@ export const permissionList = [
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '技能等级',
fieldId: 'skillLevelId',
fieldName: '性别',
fieldId: 'gender',
isSubTable: false,
showChildren: true,
type: 'select',
key: '7126b5787dc647bda9c3b05d626a2cf2',
children: [],
options: {},
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '电话',
fieldId: 'phone',
isSubTable: false,
showChildren: true,
type: 'input',
key: '488d22332deb4f2abf4a9423122d98f7',
key: 'b5eb1855dc6d409280dbb7c4a333ae07',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
......@@ -239,14 +222,15 @@ export const permissionList = [
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '公司',
fieldId: 'companyId',
fieldName: '年龄',
fieldId: 'age',
isSubTable: false,
showChildren: true,
type: 'select',
key: 'dfb0639d444c4449b11f26cf210feac5',
type: 'input',
key: '8c0ea91bdee24d40aa94110ab9f19eae',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
......@@ -255,15 +239,14 @@ export const permissionList = [
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '年龄',
fieldId: 'age',
fieldName: '在职情况',
fieldId: 'isOnJob',
isSubTable: false,
showChildren: true,
type: 'input',
key: '8c0ea91bdee24d40aa94110ab9f19eae',
type: 'select',
key: 'a1494eb3af92444bb256d4781a46a52c',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
......@@ -272,12 +255,12 @@ export const permissionList = [
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '在职情况',
fieldId: 'isOnJob',
fieldName: '公司',
fieldId: 'companyId',
isSubTable: false,
showChildren: true,
type: 'select',
key: 'a1494eb3af92444bb256d4781a46a52c',
key: 'dfb0639d444c4449b11f26cf210feac5',
children: [],
options: {},
},
......
<template>
<div class="pt-4">
<SimpleForm
ref="systemFormRef"
:formProps="data.formDataProps"
:formModel="state.formModel"
:isWorkFlow="props.fromPage!=FromPageType.MENU"
:isCamelCase="true"
@model-change="handleChange"
/>
</div>
</template>
<script lang="ts" setup>
import { reactive, ref, onMounted, nextTick, watch } from 'vue';
import { formProps, formEventConfigs } from './config';
import SimpleForm from '/@/components/SimpleForm/src/SimpleForm.vue';
import { addMesBaseBom, getMesBaseBom, updateMesBaseBom } from '/@/api/jcsj/wlqd';
import { cloneDeep, isString } from 'lodash-es';
import { FormDataProps } from '/@/components/Designer/src/types';
import { usePermission } from '/@/hooks/web/usePermission';
import CustomButtonModal from '/@/components/Form/src/components/CustomButtonModal.vue';
import { FromPageType } from '/@/enums/workflowEnum';
import { createFormEvent, getFormDataEvent, loadFormEvent, submitFormEvent,} from '/@/hooks/web/useFormEvent';
import { changeWorkFlowForm, changeSchemaDisabled } from '/@/hooks/web/useWorkFlowForm';
import { WorkFlowFormParams } from '/@/model/workflow/bpmnConfig';
import { useRouter } from 'vue-router';
const { filterFormSchemaAuth } = usePermission();
const RowKey = 'id';
const emits = defineEmits(['changeUploadComponentIds','loadingCompleted', 'update:value']);
const props = defineProps({
fromPage: {
type: Number,
default: FromPageType.MENU,
},
});
const systemFormRef = ref();
const data: { formDataProps: FormDataProps } = reactive({
formDataProps: cloneDeep(formProps),
});
const state = reactive({
formModel: {},
formInfo:{formId:'',formName:''}
});
const { currentRoute } = useRouter();
watch(
() => state.formModel,
(val) => {
emits('update:value', val);
},
{
deep: true,
},
);
onMounted(async () => {
try {
if (props.fromPage == FromPageType.MENU) {
setMenuPermission();
if(currentRoute.value.meta){
state.formInfo.formName = currentRoute.value.meta.title&&isString(currentRoute.value.meta.title)?currentRoute.value.meta.title:'';
state.formInfo.formId = currentRoute.value.meta.formId&&isString(currentRoute.value.meta.formId)?currentRoute.value.meta.formId:'';
}
await createFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:初始化表单
await nextTick();
await loadFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:加载表单
} else if (props.fromPage == FromPageType.FLOW) {
emits('loadingCompleted'); //告诉系统表单已经加载完毕
// loadingCompleted后 工作流页面直接利用Ref调用setWorkFlowForm方法
} else if (props.fromPage == FromPageType.PREVIEW) {
// 预览 无需权限,表单事件也无需执行
} else if (props.fromPage == FromPageType.DESKTOP) {
// 桌面设计 表单事件需要执行
emits('loadingCompleted'); //告诉系统表单已经加载完毕
await createFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:初始化表单
await loadFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:加载表单
}
} catch (error) {}
});
// 根据菜单页面权限,设置表单属性(必填,禁用,显示)
function setMenuPermission() {
data.formDataProps.schemas = filterFormSchemaAuth(data.formDataProps.schemas!);
}
// 校验form 通过返回表单数据
async function validate() {
let values = [];
try {
values = await systemFormRef.value?.validate();
//添加隐藏组件
if (data.formDataProps.hiddenComponent?.length) {
data.formDataProps.hiddenComponent.forEach((component) => {
values[component.bindField] = component.value;
});
}
} finally {
}
return values;
}
// 根据行唯一ID查询行数据,并设置表单数据 【编辑】
async function setFormDataFromId(rowId) {
try {
const record = await getMesBaseBom(rowId);
setFieldsValue(record);
state.formModel = record;
await getFormDataEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:获取表单数据
} catch (error) {
}
}
// 辅助返回表单数据
async function getFieldsValue() {
let values = [];
try {
values = await systemFormRef.value?.getFieldsValue();
//添加隐藏组件
if (data.formDataProps.hiddenComponent?.length) {
data.formDataProps.hiddenComponent.forEach((component) => {
values[component.bindField] = component.value;
});
}
} finally {
}
return values;
}
// 辅助设置表单数据
function setFieldsValue(record) {
systemFormRef.value.setFieldsValue(record);
}
// 重置表单数据
async function resetFields() {
await systemFormRef.value.resetFields();
}
// 设置表单数据全部为Disabled 【查看】
async function setDisabledForm( ) {
data.formDataProps.schemas = changeSchemaDisabled(cloneDeep(data.formDataProps.schemas));
}
// 获取行键值
function getRowKey() {
return RowKey;
}
// 更新api表单数据
async function update({ values, rowId }) {
try {
values[RowKey] = rowId;
state.formModel = values;
let saveVal = await updateMesBaseBom(values);
await submitFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:提交表单
return saveVal;
} catch (error) {}
}
// 新增api表单数据
async function add(values) {
try {
state.formModel = values;
let saveVal = await addMesBaseBom(values);
await submitFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:提交表单
return saveVal;
} catch (error) {}
}
// 根据工作流页面权限,设置表单属性(必填,禁用,显示)
async function setWorkFlowForm(obj: WorkFlowFormParams) {
try {
if (obj.formId) state.formInfo.formId = obj.formId;
if (obj.formName) state.formInfo.formName = obj.formName;
let flowData = await changeWorkFlowForm(cloneDeep(formProps), obj);
let { buildOptionJson, uploadComponentIds, formModels, isViewProcess } = flowData;
data.formDataProps = buildOptionJson;
emits('changeUploadComponentIds', uploadComponentIds); //工作流中必须保存上传组件id【附件汇总需要】
if (isViewProcess) {
setDisabledForm(); //查看
}
state.formModel = formModels;
setFieldsValue(formModels);
} catch (error) {}
await createFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:初始化表单
await loadFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:加载表单
}
function handleChange(val) {
emits('update:value', val);
}
async function sendMessageForAllIframe() {
try {
if (systemFormRef.value && systemFormRef.value.sendMessageForAllIframe) {
systemFormRef.value.sendMessageForAllIframe();
}
} catch (error) {}
}
defineExpose({
setFieldsValue,
resetFields,
validate,
add,
update,
setFormDataFromId,
setDisabledForm,
setMenuPermission,
setWorkFlowForm,
getRowKey,
getFieldsValue,
sendMessageForAllIframe
});
</script>
\ No newline at end of file
<template>
<BasicModal
:height="1080"
v-bind="$attrs" @register="registerModal" :title="getTitle"
@ok="handleSubmit" @cancel="handleClose" >
<ModalForm ref="formRef" v-model:value="state.formModel" :fromPage="FromPageType.MENU" />
<template #footer v-if=" !state.isView">
<template v-for="(item, index) in sortBy(formButtons, 'index')" :key="item.key">
<template v-if="item.isShow">
<CustomButtonModal v-if="item.type == CustomButtonModalType.Modal" :info="item" />
<a-button
:type="item.style"
v-else
:style="{ marginLeft: index > 0 ? '10px' : 0 }"
@click="customClick(item)"
>
{{ t(item.name) }}
</a-button>
</template>
</template>
</template>
</BasicModal>
</template>
<script lang="ts" setup>
import { ref, computed, reactive, provide, Ref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { CustomButtonModalType } from '/@/enums/userEnum';
import CustomButtonModal from '/@/components/Form/src/components/CustomButtonModal.vue';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { formProps ,formButtons } from './config';
import ModalForm from './Form.vue';
import { FromPageType } from '/@/enums/workflowEnum';
import { sortBy } from 'lodash-es';
import { executeCurFormEvent } from '/@/utils/event/data';
const emit = defineEmits(['success', 'register']);
const { notification } = useMessage();
const formRef = ref();
const isCopy = ref<boolean>(false)
const state = reactive({
formModel: {},
isUpdate: true,
isView: false,
rowId: '',
});
provide<Ref<boolean>>('isCopy', isCopy);
const { t } = useI18n();
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
await handleInner(data);
});
const getTitle = computed(() => (state.isView ? '查看' : state.isUpdate ? '编辑' : isCopy.value ? '复制数据' : '新增'));
async function handleInner(data){
state.isUpdate = !!data?.isUpdate;
state.isView = !!data?.isView;
isCopy.value = !!data?.isCopy;
setModalProps({
destroyOnClose: true,
maskClosable: false,
showCancelBtn: false,
showOkBtn: false,
canFullscreen: true,
width: 1920,
footer: state.isView ? null : undefined,defaultFullscreen:true,
});
if (state.isUpdate || state.isView || isCopy.value) {
state.rowId = data.id;
if (state.isView) {
await formRef.value.setDisabledForm();
}
await formRef.value.setFormDataFromId(state.rowId);
} else {
formRef.value.resetFields();
}
}
async function saveModal() {
let saveSuccess = false;
try {
const values = await formRef.value?.validate();
//添加隐藏组件
if (formProps.hiddenComponent?.length) {
formProps.hiddenComponent.forEach((component) => {
values[component.bindField] = component.value;
});
}
if (values !== false) {
try {
if (!state.isUpdate || isCopy.value) {
saveSuccess = await formRef.value.add(values);
} else {
saveSuccess = await formRef.value.update({ values, rowId: state.rowId });
}
return saveSuccess;
} catch (error) {}
}
} catch (error) {
return saveSuccess;
}
}
async function handleSubmit() {
try {
const saveSuccess = await saveModal();
setModalProps({ confirmLoading: true });
if (saveSuccess) {
if (!state.isUpdate || isCopy.value) {
//false 新增
notification.success({
message: 'Tip',
description: isCopy.value ? '复制成功' : t('新增成功!'),
}); //提示消息
} else {
notification.success({
message: 'Tip',
description: t('修改成功!'),
}); //提示消息
}
closeModal();
formRef.value.resetFields();
emit('success');
}
} finally {
setModalProps({ confirmLoading: false });
}
}
function customClick(item) {
if (item.key == 'confirm') {
handleSubmit();
} else if (item.key == 'cancel' && props.formType !== 'normal') {
handleClose();
closeModal();
} else if (item.key == 'reset') {
formRef.value.resetFields();
} else {
executeCurFormEvent(item.event, state.formModel, true);
}
}
function handleClose() {
formRef.value.resetFields();
}
</script>
\ No newline at end of file
export const permissionList = [
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: 'BOM名称',
fieldId: 'bommc',
isSubTable: false,
showChildren: true,
type: 'input',
key: '0bb6edfef8ac486482e02a6e650306e6',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: 'BOM数量',
fieldId: 'bomsl',
isSubTable: false,
showChildren: true,
type: 'number',
key: '4bc74304a0144e879b2fc45ae28ab1c5',
children: [],
options: {},
defaultValue: 0,
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: 'BOM版本',
fieldId: 'bombb',
isSubTable: false,
showChildren: true,
type: 'input',
key: '50bff2d4c82d40a98ace5fd2b1d3b41e',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '选择产品',
fieldId: 'cpid',
isSubTable: false,
showChildren: true,
type: 'associate-popup',
key: 'c42ef62f38e1445b89e5c3362ffd3af2',
children: [],
options: {},
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '产品编号',
fieldId: 'cpbh',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'b2682f1ff2dc48448211cacb4bf48bfd',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '产品名称',
fieldId: 'cpmc',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'db0bea5c2dbf4505833e67179e8618f3',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '产品规格',
fieldId: 'cpgg',
isSubTable: false,
showChildren: true,
type: 'input',
key: '3e7491b6d43c4ef7a7b6c2fd49a94a7f',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '产品型号',
fieldId: 'cpxh',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'cf7d04d1e6374a3fbc4a9dfb9ebdf19e',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '是否有效',
fieldId: 'sfyy',
isSubTable: false,
showChildren: true,
type: 'switch',
key: 'd8387e383f7342f8b829cb672dad42cb',
children: [],
options: {},
defaultValue: 1,
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '备注',
fieldId: 'bz',
isSubTable: false,
showChildren: true,
type: 'textarea',
key: 'ccb91eb8f48b4ff3aaa1086f0adcd48e',
children: [],
options: {},
defaultValue: '',
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: true,
showChildren: false,
tableName: 'mesBaseBomItemList',
fieldName: 'BOM清单',
fieldId: 'mesBaseBomItemList',
type: 'form',
key: 'c87fc2d18e24429a819521f35f19137b',
children: [
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesBaseBomItemList',
fieldName: '选择物料',
fieldId: 'bomid',
type: 'MultiplePopup',
key: '709b38c05d11468db0db4e6e9168e4f9',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesBaseBomItemList',
fieldName: '物料编号',
fieldId: 'wlbh',
type: 'Input',
key: '3988d1cba45a464abbeabce6ed09970e',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesBaseBomItemList',
fieldName: '物料名称',
fieldId: 'wlmc',
type: 'Input',
key: '112f6292bd884006ad872f06aeef4e6f',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesBaseBomItemList',
fieldName: '物料数量',
fieldId: 'wlsl',
type: 'InputNumber',
key: '80fe637a2eaa47a49e96f6e86f0efdda',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesBaseBomItemList',
fieldName: '库存数量',
fieldId: 'wlkcl',
type: 'InputNumber',
key: '1afa69530c154b6f904f1661e82ff9a3',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesBaseBomItemList',
fieldName: '客户标准(%)',
fieldId: 'khbz',
type: 'InputNumber',
key: 'd15b4777d2794944995aa2a085442a6e',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesBaseBomItemList',
fieldName: '内控标准(%)',
fieldId: 'nkbz',
type: 'InputNumber',
key: '1ef860d823ff46c690334dc5eff5a6e4',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesBaseBomItemList',
fieldName: '是否投料',
fieldId: 'sftl',
type: 'Switch',
key: '40a1e893e8ee496a96d7ed6dbe17e271',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesBaseBomItemList',
fieldName: '备注',
fieldId: 'bz',
type: 'Input',
key: '9230b500d1024028af68ed4ac49bdbd3',
children: [],
},
],
},
];
<template>
<ResizePageWrapper :hasLeft="false">
<template #resizeRight>
<BasicTable @register="registerTable" isMenuTable ref="tableRef"
>
<template #toolbar>
<template v-for="button in tableButtonConfig" :key="button.code">
<a-button v-if="button.isDefault" type="primary" @click="buttonClick(button.code)">
<template #icon><Icon :icon="button.icon" /></template>
{{ button.name }}
</a-button>
<CustomButtonModal v-else-if="button.buttonType == 'modal'" :info="button" />
<a-button v-else :type="button.buttonType === 'danger' ? 'default' : button.buttonType || 'primary'" :danger="button.buttonType === 'danger'" >
<template #icon><Icon :icon="button.icon" /></template>
{{ button.name }}
</a-button>
</template>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.componentType === 'switch'">
<a-switch
v-model:checked="record[column.dataIndex]"
:unCheckedValue="0"
:checkedValue="1"
:disabled="true"
/>
</template>
<template v-if="column.dataIndex === 'action'">
<TableAction
:actions="getLessActions(record)"
:dropDownActions="getMoreActions(record)"
/>
</template>
<template v-else-if="column.dataIndex && column?.listStyle">
<span :style="executeListStyle(getValue(record, column, 'style'), column?.listStyle)">{{
getValue(record, column, 'value')
}}</span>
</template>
</template>
</BasicTable>
</template>
<WlqdModal @register="registerModal" @success="handleFormSuccess" @cancel="handleFormCancel"/>
</ResizePageWrapper>
</template>
<script lang="ts" setup>
import { ref, computed,provide,Ref, createVNode,
} from 'vue';
import { Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
import { getMesBaseBomPage, deleteMesBaseBom} from '/@/api/jcsj/wlqd';
import { ResizePageWrapper } from '/@/components/Page';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { usePermission } from '/@/hooks/web/usePermission';
import CustomButtonModal from '/@/components/Form/src/components/CustomButtonModal.vue';
import { executeListStyle, getValue } from '/@/hooks/web/useListStyle';//列表样式配置
import { useRouter } from 'vue-router';
import { useModal } from '/@/components/Modal';
import WlqdModal from './components/WlqdModal.vue';
import { searchFormSchema, columns } from './components/config';
import Icon from '/@/components/Icon/index';
const listSpliceNum = ref(3); //操作列最先展示几个
import { useConcurrentLock } from '/@/hooks/web/useConcurrentLock';
const pageParamsInfo = ref<any>({});
const { enableLockeData,handleOpenFormEnableLockeData, handleCloseFormEnableLocke, handleHasEnableLocke } =
useConcurrentLock();
const { notification } = useMessage();
const { t } = useI18n();
defineEmits(['register']);
const { filterColumnAuth, filterButtonAuth, hasPermission } = usePermission();
const filterColumns = filterColumnAuth(columns);
const tableRef = ref();
//展示在列表内的按钮
const actionButtons = ref<string[]>(["view","edit","delete"]);
const buttonConfigs = computed(()=>{
const list = [{"buttonId":"2006204718531538944","name":"查看","code":"view","icon":"ant-design:eye-outlined","isDefault":true,"isUse":true},{"buttonId":"2006204718531538945","name":"新增","code":"add","icon":"ant-design:plus-outlined","isDefault":true,"isUse":true},{"buttonId":"2006204718531538946","name":"编辑","code":"edit","icon":"ant-design:form-outlined","isDefault":true,"isUse":true,"isEnableLock":true},{"buttonId":"2006204718531538947","name":"删除","code":"delete","icon":"ant-design:delete-outlined","isDefault":true,"isUse":true}]
return filterButtonAuth(list);
})
const tableButtonConfig = computed(() => {
return buttonConfigs.value?.filter((x) => !actionButtons.value.includes(x.code));
});
const actionButtonConfig = computed(() => {
return buttonConfigs.value?.filter((x) => actionButtons.value.includes(x.code));
});
const btnEvent = {view : handleView,add : handleAdd,edit : handleEdit,delete : handleDelete,}
const { currentRoute } = useRouter();
const formIdComputedRef = computed(() => currentRoute.value.meta.formId as string);
provide<Ref<string>>('currentFormId', formIdComputedRef);
const [registerModal, { openModal }] = useModal();
const [registerTable, { reload, }] = useTable({
title: 'Wlqd列表',
api: getMesBaseBomPage,
rowKey: 'id',
columns: filterColumns,
pagination: {
pageSize: 10,
},
formConfig: {
labelWidth: 100,
schemas: searchFormSchema,
fieldMapToTime: [],
showResetButton: false,
},
bordered:false,
beforeFetch: (params) => {
pageParamsInfo.value = {...params, FormId: formIdComputedRef.value,PK: 'id' }
return pageParamsInfo.value;
},
afterFetch: (res) => {
},
useSearchForm: true,
showTableSetting: true,
striped: false,
actionColumn: {
width: 195,
title: '操作',
dataIndex: 'action',
slots: { customRender: 'action' },
},
tableSetting: {
size: false,
},
customRow,
isAdvancedQuery: false,
querySelectOption: JSON.stringify(searchFormSchema),
objectId: formIdComputedRef.value, ////系统表单formId,自定义表单releaseId的id值
});
function buttonClick(code) {
btnEvent[code]();
}
function handleAdd() {
openModal(true, { isUpdate: false, });
}
async function handleEdit(record: Recordable) {
let field = 'id';
try {
let hasIn = handleHasEnableLocke(buttonConfigs.value, 'edit');
if (hasIn) {
let res = await handleOpenFormEnableLockeData(
record[field],
formIdComputedRef.value,
);
if (res !== null) {
return;
}
}
let info = {
id: record[field],
isUpdate: true,
};
openModal(true, info);
} catch (error) {}
}
function handleDelete(record: Recordable) {
deleteList([record.id]);
}
function deleteList(ids) {
Modal.confirm({
title: '提示信息',
icon: createVNode(ExclamationCircleOutlined),
content: '是否确认删除?',
okText: '确认',
cancelText: '取消',
onOk() {
deleteMesBaseBom(ids).then((_) => {
handleSuccess();
notification.success({
message: 'Tip',
description: t('删除成功!'),
});
});
},
onCancel() {},
});
}
function customRow(record: Recordable) {
return {
ondblclick: () => {
if (record.isCanEdit && hasPermission("wlqd:edit")) {
handleEdit(record);
}
},
};
}
function handleSuccess() {
reload();
}
function handleFormSuccess() {
handleSuccess();
handleCloseFormEnableLocke(buttonConfigs.value, 'edit');
}
function handleFormCancel() {
handleCloseFormEnableLocke(buttonConfigs.value, 'edit');
}
function handleView(record: Recordable) {
let info={
isView: true,
id: record.id,
}
openModal(true, info);
}
function getLessActions(record: Recordable) {
let list = getActions(record);
return list.slice(0, listSpliceNum.value);
}
function getMoreActions(record: Recordable) {
let list = getActions(record);
return list.slice(listSpliceNum.value);
}
function getActions(record: Recordable):ActionItem[] {
record.isCanEdit = false;
let actionsList: ActionItem[] = [];
actionButtonConfig.value?.map((button) => {
if (!record?.workflowData?.processId) {
record.isCanEdit = true;
actionsList.push({
...button,
auth: `wlqd:${button.code}`,
label: button?.name,
color: button.code === 'delete' ? 'error' : undefined,
onClick: btnEvent[button.code]?.bind(null, record),
});
} else {
if (!['edit', 'delete'].includes(button.code)) {
actionsList.push({
auth: `wlqd:${button.code}`,
label: button?.name,
onClick: btnEvent[button.code]?.bind(null, record),
});
}
}
});
return actionsList;
}
</script>
<style lang="less" scoped>
:deep(.ant-table-selection-col) {
width: 50px;
}
.show{
display: flex;
}
.hide{
display: none !important;
}
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment