Commit 470bb9a0 by 张珈源

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

parents 80d3812d 644a6545
import { MesBaseCplxPageModel, MesBaseCplxPageParams, MesBaseCplxPageResult } from './model/CplxModel';
import { defHttp } from '/@/utils/http/axios';
import { ErrorMessageMode } from '/#/axios';
enum Api {
Page = '/jcsj/cplx/page',
List = '/jcsj/cplx/list',
Info = '/jcsj/cplx/info',
MesBaseCplx = '/jcsj/cplx',
}
/**
* @description: 查询MesBaseCplx分页列表
*/
export async function getMesBaseCplxPage(params: MesBaseCplxPageParams, mode: ErrorMessageMode = 'modal') {
return defHttp.get<MesBaseCplxPageResult>(
{
url: Api.Page,
params,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 获取MesBaseCplx信息
*/
export async function getMesBaseCplx(id: String, mode: ErrorMessageMode = 'modal') {
return defHttp.get<MesBaseCplxPageModel>(
{
url: Api.Info,
params: { id },
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 新增MesBaseCplx
*/
export async function addMesBaseCplx(mesBaseCplx: Recordable, mode: ErrorMessageMode = 'modal') {
return defHttp.post<boolean>(
{
url: Api.MesBaseCplx,
params: mesBaseCplx,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 更新MesBaseCplx
*/
export async function updateMesBaseCplx(mesBaseCplx: Recordable, mode: ErrorMessageMode = 'modal') {
return defHttp.put<boolean>(
{
url: Api.MesBaseCplx,
params: mesBaseCplx,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 删除MesBaseCplx(批量删除)
*/
export async function deleteMesBaseCplx(ids: string[], mode: ErrorMessageMode = 'modal') {
return defHttp.delete<boolean>(
{
url: Api.MesBaseCplx,
data: ids,
},
{
errorMessageMode: mode,
},
);
}
import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';
/**
* @description: MesBaseCplx分页参数 模型
*/
export interface MesBaseCplxPageParams extends BasicPageParams {
cm: string;
pid: string;
}
/**
* @description: MesBaseCplx分页返回值模型
*/
export interface MesBaseCplxPageModel {
id: string;
cm: string;
pid: string;
bh: string;
paixu: string;
bz: string;
}
/**
* @description: MesBaseCplx表类型
*/
export interface MesBaseCplxModel {
id: string;
deleteMark: string;
pid: string;
cm: string;
bh: string;
paixu: string;
bz: 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;
}
/**
* @description: MesBaseCplx分页返回值结构
*/
export type MesBaseCplxPageResult = BasicFetchResult<MesBaseCplxPageModel>;
......@@ -9,14 +9,6 @@ export interface MesBaseProductInfoPageParams extends BasicPageParams {
cpbh: string;
cplx: string;
xh: string;
hjzt: string;
nbdm: string;
sfyx: string;
}
/**
......@@ -29,19 +21,13 @@ export interface MesBaseProductInfoPageModel {
cpbh: string;
cplx: string;
gg: string;
xh: string;
hjzt: string;
nbdm: string;
erpid: string;
cplx: string;
sfyx: string;
bzzl: string;
}
/**
......@@ -86,7 +72,7 @@ export interface MesBaseProductInfoModel {
bz: string;
p1: string;
dw: string;
p2: string;
......@@ -113,6 +99,8 @@ export interface MesBaseProductInfoModel {
modifyDate: string;
modifyUserId: string;
p1: string;
}
/**
......
<template>
<BasicModal
:height="500"
v-bind="$attrs" @register="registerModal" :title="getTitle"
@ok="handleSubmit" @cancel="handleClose" >
<ModalForm ref="formRef" v-model:value="state.formModel" :fromPage="FromPageType.MENU" />
</BasicModal>
</template>
<script lang="ts" setup>
import { ref, computed, reactive, provide, Ref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { formProps } from './config';
import ModalForm from './Form.vue';
import { FromPageType } from '/@/enums/workflowEnum';
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: !state.isView,
showOkBtn: !state.isView,
canFullscreen: true,
width: 900,
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 handleClose() {
formRef.value.resetFields();
}
</script>
<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 { addMesBaseCplx, getMesBaseCplx, updateMesBaseCplx } from '/@/api/jcsj/cplx';
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 getMesBaseCplx(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 updateMesBaseCplx(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 addMesBaseCplx(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>
import { FormProps, FormSchema } from '/@/components/Form';
import { BasicColumn } from '/@/components/Table';
export const searchFormSchema: FormSchema[] = [
{
field: 'cm',
label: '类型名称',
defaultValue: undefined,
component: 'Input',
},
{
field: 'pid',
label: '父类别',
defaultValue: undefined,
component: 'ApiCascader',
componentProps: {
apiConfig: {
path: '/jcxx/cplx/getAllCPLXTree_zujian',
method: 'GET',
apiId: 'copy1770283483454d34933',
apiParams: [
{
key: '1',
title: 'Query Params',
tableInfo: [
{
name: 'code',
value: null,
description: null,
required: false,
dataType: 'String',
type: null,
defaultValue: null,
validateType: null,
error: null,
expression: null,
children: null,
bindType: '',
},
],
},
{ key: '2', title: 'Header', tableInfo: [] },
{ key: '3', title: 'Body' },
],
script:
'var sql = ""\r\n + "select id,"\r\n + " pid as \'parentId\', "\r\n + " id as \'value\', "\r\n + " cm as \'label\' "\r\n + "from mes_base_cplx "\r\n + "where delete_mark = 0 "\r\n + "order by pid, id";\r\nvar list = db.select(sql);\r\n\r\nif (list == null || list.size() == 0) {\r\n return [];\r\n}\r\nvar map = new HashMap();\r\nvar idx = 0;\r\nwhile (idx < list.size()) {\r\n var itemNode = list.get(idx);\r\n itemNode.children = [];\r\n map.put(itemNode.id, itemNode);\r\n idx = idx + 1;\r\n}\r\nvar dataList = [];\r\nidx = 0;\r\nwhile (idx < list.size()) {\r\n var itemNode = list.get(idx);\r\n if (itemNode.parentId == null || itemNode.parentId == \'0\' || itemNode.parentId == \'\') {\r\n dataList.add(itemNode);\r\n } else {\r\n var parentNode = map.get(itemNode.parentId);\r\n if (parentNode != null) {\r\n parentNode.children.add(itemNode);\r\n } else {\r\n dataList.add(itemNode);\r\n }\r\n }\r\n idx = idx + 1;\r\n}\r\nreturn dataList\r\n',
},
showFormat: 'all',
separator: '/',
selectedConfig: 'any',
},
},
];
export const columns: BasicColumn[] = [
{
resizable: true,
dataIndex: 'cm',
title: '类型名称',
componentType: 'input',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: '',
},
{
resizable: true,
dataIndex: 'pid',
title: '父类别',
componentType: 'cascader',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: undefined,
},
{
resizable: true,
dataIndex: 'bh',
title: '类型编码',
componentType: 'auto-code',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: undefined,
},
{
resizable: true,
dataIndex: 'paixu',
title: '排序',
componentType: 'input',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: '',
},
{
resizable: true,
dataIndex: 'bz',
title: '备注',
componentType: 'textarea',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: undefined,
},
];
//表头合并配置
export const headerMergingData = [];
//表单事件
export const formEventConfigs = {
0: [
{
type: 'circle',
color: '#2774ff',
text: '开始节点',
icon: '#icon-kaishi',
bgcColor: '#D8E5FF',
isUserDefined: false,
},
{
color: '#F6AB01',
icon: '#icon-chushihua',
text: '初始化表单',
bgcColor: '#f9f5ea',
isUserDefined: false,
nodeInfo: { processEvent: [] },
},
],
1: [
{
color: '#B36EDB',
icon: '#icon-shujufenxi',
text: '获取表单数据',
detail: '(新增无此操作)',
bgcColor: '#F8F2FC',
isUserDefined: false,
nodeInfo: { processEvent: [] },
},
],
2: [
{
color: '#F8625C',
icon: '#icon-jiazai',
text: '加载表单',
bgcColor: '#FFF1F1',
isUserDefined: false,
nodeInfo: { processEvent: [] },
},
],
3: [
{
color: '#6C6AE0',
icon: '#icon-jsontijiao',
text: '提交表单',
bgcColor: '#F5F4FF',
isUserDefined: false,
nodeInfo: { processEvent: [] },
},
],
4: [
{
type: 'circle',
color: '#F8625C',
text: '结束节点',
icon: '#icon-jieshuzhiliao',
bgcColor: '#FFD6D6',
isLast: true,
isUserDefined: false,
},
],
};
export const formProps: FormProps = {
labelCol: { span: 3, offset: 0 },
labelAlign: 'right',
layout: 'horizontal',
size: 'default',
schemas: [
{
key: 'd8a01b822ee141d6913c8db73c37d07a',
field: '',
label: '',
type: 'grid',
colProps: { span: 24 },
component: 'Grid',
children: [
{
span: 8,
list: [
{
key: 'db121a41243b404a90482cb07852313a',
field: 'cm',
label: '类型名称',
type: 'input',
component: 'Input',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: 7,
defaultValue: '',
placeholder: '请输入类型名称',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: true,
rules: [],
events: {},
listStyle: '',
isSave: false,
isShow: true,
scan: false,
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
style: { width: '100%' },
},
},
{
key: '8eaade4e896f41d1a0d1c0374a7268c7',
field: 'pid',
label: '父类别',
type: 'cascader',
component: 'ApiCascader',
colProps: { span: 24 },
componentProps: {
width: '100%',
span: 7,
placeholder: '请选择父类别',
showFormat: 'all',
separator: '/',
selectedConfig: 'any',
disabled: false,
allowClear: false,
showLabel: true,
apiConfig: {
path: '/jcxx/cplx/getAllCPLXTree_zujian',
method: 'GET',
apiId: 'copy1770283483454d34933',
apiParams: [
{
key: '1',
title: 'Query Params',
tableInfo: [
{
name: 'code',
value: null,
description: null,
required: false,
dataType: 'String',
type: null,
defaultValue: null,
validateType: null,
error: null,
expression: null,
children: null,
bindType: '',
},
],
},
{ key: '2', title: 'Header', tableInfo: [] },
{ key: '3', title: 'Body' },
],
script:
'var sql = ""\r\n + "select id,"\r\n + " pid as \'parentId\', "\r\n + " id as \'value\', "\r\n + " cm as \'label\' "\r\n + "from mes_base_cplx "\r\n + "where delete_mark = 0 "\r\n + "order by pid, id";\r\nvar list = db.select(sql);\r\n\r\nif (list == null || list.size() == 0) {\r\n return [];\r\n}\r\nvar map = new HashMap();\r\nvar idx = 0;\r\nwhile (idx < list.size()) {\r\n var itemNode = list.get(idx);\r\n itemNode.children = [];\r\n map.put(itemNode.id, itemNode);\r\n idx = idx + 1;\r\n}\r\nvar dataList = [];\r\nidx = 0;\r\nwhile (idx < list.size()) {\r\n var itemNode = list.get(idx);\r\n if (itemNode.parentId == null || itemNode.parentId == \'0\' || itemNode.parentId == \'\') {\r\n dataList.add(itemNode);\r\n } else {\r\n var parentNode = map.get(itemNode.parentId);\r\n if (parentNode != null) {\r\n parentNode.children.add(itemNode);\r\n } else {\r\n dataList.add(itemNode);\r\n }\r\n }\r\n idx = idx + 1;\r\n}\r\nreturn dataList\r\n',
},
required: false,
rules: [],
events: {},
isShow: true,
tooltipConfig: { visible: false, title: '提示文本' },
style: { width: '100%' },
},
},
],
},
{
span: 8,
list: [
{
key: 'e0ca71c675704d2db7029f845aba3f86',
field: 'bh',
label: '类型编码',
type: 'auto-code',
component: 'AutoCodeRule',
colProps: { span: 24 },
componentProps: {
width: '100%',
span: 7,
placeholder: '请输入类型编码',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
showLabel: true,
autoCodeRule: 'cplx',
required: true,
isShow: true,
tooltipConfig: { visible: false, title: '提示文本' },
style: { width: '100%' },
},
},
],
},
{
span: 8,
list: [
{
key: 'ec842ddda4a14613b585f6e9904257ec',
field: 'paixu',
label: '排序',
type: 'input',
component: 'Input',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: 7,
defaultValue: '',
placeholder: '请输入排序',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
listStyle: '',
isSave: false,
isShow: true,
scan: false,
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
style: { width: '100%' },
},
},
],
},
],
componentProps: {
gutter: 0,
justify: 'start',
align: 'top',
isShow: true,
showBorder: false,
bordercolor: '#d9d9d9',
bordershowtype: [true, true, true, true],
borderwidth: 1,
padding: '10px',
margin: '10px',
},
},
{
key: '9501144a835544dab10f5dd0b1fbf0ca',
field: 'bz',
label: '备注',
type: 'textarea',
component: 'InputTextArea',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: '',
defaultValue: '',
placeholder: '请输入备注',
rows: 4,
autoSize: false,
showCount: false,
disabled: false,
showLabel: true,
allowClear: false,
required: false,
isShow: true,
isShowAi: true,
rules: [],
events: {},
tooltipConfig: { visible: false, title: '提示文本' },
style: { width: '100%' },
},
},
],
showActionButtonGroup: false,
buttonLocation: 'center',
actionColOptions: { span: 24 },
showResetButton: false,
showSubmitButton: false,
hiddenComponent: [],
};
export const permissionList = [
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '类型名称',
fieldId: 'cm',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'db121a41243b404a90482cb07852313a',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '父类别',
fieldId: 'pid',
isSubTable: false,
showChildren: true,
type: 'cascader',
key: '8eaade4e896f41d1a0d1c0374a7268c7',
children: [],
options: {},
},
{
required: false,
view: true,
edit: false,
disabled: true,
isSaveTable: false,
tableName: '',
fieldName: '类型编码',
fieldId: 'bh',
isSubTable: false,
showChildren: true,
type: 'auto-code',
key: 'e0ca71c675704d2db7029f845aba3f86',
children: [],
options: {},
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '排序',
fieldId: 'paixu',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'ec842ddda4a14613b585f6e9904257ec',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '备注',
fieldId: 'bz',
isSubTable: false,
showChildren: true,
type: 'textarea',
key: '9501144a835544dab10f5dd0b1fbf0ca',
children: [],
options: {},
defaultValue: '',
},
];
<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.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>
<CplxModal @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 { getMesBaseCplxPage, deleteMesBaseCplx} from '/@/api/jcsj/cplx';
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 CplxModal from './components/CplxModal.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":"2019334653844258816","name":"查看","code":"view","icon":"ant-design:eye-outlined","isDefault":true,"isUse":true},{"buttonId":"2019334653844258817","name":"新增","code":"add","icon":"ant-design:plus-outlined","isDefault":true,"isUse":true},{"buttonId":"2019334653844258818","name":"编辑","code":"edit","icon":"ant-design:form-outlined","isDefault":true,"isUse":true,"isEnableLock":true},{"buttonId":"2019334653844258819","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: 'Cplx列表',
api: getMesBaseCplxPage,
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() {
deleteMesBaseCplx(ids).then((_) => {
handleSuccess();
notification.success({
message: 'Tip',
description: t('删除成功!'),
});
});
},
onCancel() {},
});
}
function customRow(record: Recordable) {
return {
ondblclick: () => {
if (record.isCanEdit && hasPermission("cplx: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: `cplx:${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: `cplx:${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>
......@@ -19,52 +19,42 @@ export const searchFormSchema: FormSchema[] = [
field: 'cplx',
label: '产品类别',
defaultValue: undefined,
component: 'XjrSelect',
component: 'ApiCascader',
componentProps: {
datasourceType: 'dic',
params: { itemId: '2003761375221407745' },
labelField: 'name',
valueField: 'value',
mode: 'multiple',
showSearch: true,
getPopupContainer: () => document.body,
},
},
{
field: 'xh',
label: '型号',
defaultValue: undefined,
component: 'Input',
},
{
field: 'hjzt',
label: '合金状态',
defaultValue: undefined,
component: 'Input',
},
{
field: 'nbdm',
label: '内部代码',
defaultValue: undefined,
component: 'Input',
},
{
field: 'sfyx',
label: '有效的',
defaultValue: 1,
component: 'Select',
componentProps: {
getPopupContainer: () => document.body,
options: [
{
label: '开',
value: 1,
},
{
label: '关',
value: 0,
},
],
apiConfig: {
path: '/jcxx/cplx/getAllCPLXTree_zujian',
method: 'GET',
apiId: 'copy1770283483454d34933',
apiParams: [
{
key: '1',
title: 'Query Params',
tableInfo: [
{
name: 'code',
value: null,
description: null,
required: false,
dataType: 'String',
type: null,
defaultValue: null,
validateType: null,
error: null,
expression: null,
children: null,
bindType: '',
},
],
},
{ key: '2', title: 'Header', tableInfo: [] },
{ key: '3', title: 'Body' },
],
script:
'var sql = ""\r\n + "select id,"\r\n + " pid as \'parentId\', "\r\n + " id as \'value\', "\r\n + " cm as \'label\' "\r\n + "from mes_base_cplx "\r\n + "where delete_mark = 0 "\r\n + "order by pid, id";\r\nvar list = db.select(sql);\r\n\r\nif (list == null || list.size() == 0) {\r\n return [];\r\n}\r\nvar map = new HashMap();\r\nvar idx = 0;\r\nwhile (idx < list.size()) {\r\n var itemNode = list.get(idx);\r\n itemNode.children = [];\r\n map.put(itemNode.id, itemNode);\r\n idx = idx + 1;\r\n}\r\nvar dataList = [];\r\nidx = 0;\r\nwhile (idx < list.size()) {\r\n var itemNode = list.get(idx);\r\n if (itemNode.parentId == null || itemNode.parentId == \'0\' || itemNode.parentId == \'\') {\r\n dataList.add(itemNode);\r\n } else {\r\n var pid = null;\r\n if (itemNode.parentId.contains(",")){\r\n var arr = itemNode.parentId.split(",");\r\n pid=arr[arr.length-1]\r\n }else{\r\n pid=itemNode.parentId;\r\n }\r\n var parentNode = map.get(pid);\r\n if (parentNode != null) {\r\n parentNode.children.add(itemNode);\r\n } else {\r\n dataList.add(itemNode);\r\n }\r\n }\r\n idx = idx + 1;\r\n}\r\nreturn dataList\r\n',
},
showFormat: 'all',
separator: '/',
selectedConfig: 'any',
},
},
];
......@@ -98,19 +88,6 @@ export const columns: BasicColumn[] = [
{
resizable: true,
dataIndex: 'cplx',
title: '产品类别',
componentType: 'select',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: undefined,
},
{
resizable: true,
dataIndex: 'gg',
title: '规格',
componentType: 'input',
......@@ -137,48 +114,22 @@ export const columns: BasicColumn[] = [
{
resizable: true,
dataIndex: 'hjzt',
title: '合金状态',
componentType: 'input',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: '',
},
{
resizable: true,
dataIndex: 'nbdm',
title: '内部代码',
componentType: 'input',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: '',
},
{
resizable: true,
dataIndex: 'erpid',
title: 'ERP ID',
componentType: 'input',
dataIndex: 'cplx',
title: '产品类别',
componentType: 'cascader',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: '',
listStyle: undefined,
},
{
resizable: true,
dataIndex: 'sfyx',
title: '有效的',
componentType: 'switch',
dataIndex: 'bzzl',
title: '标准重量',
componentType: 'number',
fixed: false,
sorter: true,
......@@ -566,42 +517,58 @@ export const formProps: FormProps = {
span: 6,
list: [
{
key: '61a60627cf7b44b5a3131074bebc5a64',
key: '2c05765e50b44fa8be4aec443066f781',
field: 'cplx',
label: '产品类别',
type: 'select',
component: 'XjrSelect',
type: 'cascader',
component: 'ApiCascader',
colProps: { span: 24 },
componentProps: {
width: '100%',
span: 7,
placeholder: '请选择下拉选择产品类别',
showLabel: true,
showSearch: false,
isMultiple: false,
clearable: false,
placeholder: '请选择产品类别',
showFormat: 'all',
separator: '/',
selectedConfig: 'any',
disabled: false,
staticOptions: [
{ key: 1, label: 'Option 1', value: 'Option 1' },
{ key: 2, label: 'Option 2', value: 'Option 2' },
{ key: 3, label: 'Option 3', value: 'Option 3' },
],
datasourceType: 'dic',
labelField: 'name',
valueField: 'value',
allowClear: false,
showLabel: true,
apiConfig: {
path: 'CodeGeneration/selection',
path: '/jcxx/cplx/getAllCPLXTree_zujian',
method: 'GET',
apiId: '93d735dcb7364a0f8102188ec4d77ac7',
apiId: 'copy1770283483454d34933',
apiParams: [
{
key: '1',
title: 'Query Params',
tableInfo: [
{
name: 'code',
value: null,
description: null,
required: false,
dataType: 'String',
type: null,
defaultValue: null,
validateType: null,
error: null,
expression: null,
children: null,
bindType: '',
},
],
},
{ key: '2', title: 'Header', tableInfo: [] },
{ key: '3', title: 'Body' },
],
script:
'var sql = ""\r\n + "select id,"\r\n + " pid as \'parentId\', "\r\n + " id as \'value\', "\r\n + " cm as \'label\' "\r\n + "from mes_base_cplx "\r\n + "where delete_mark = 0 "\r\n + "order by pid, id";\r\nvar list = db.select(sql);\r\n\r\nif (list == null || list.size() == 0) {\r\n return [];\r\n}\r\nvar map = new HashMap();\r\nvar idx = 0;\r\nwhile (idx < list.size()) {\r\n var itemNode = list.get(idx);\r\n itemNode.children = [];\r\n map.put(itemNode.id, itemNode);\r\n idx = idx + 1;\r\n}\r\nvar dataList = [];\r\nidx = 0;\r\nwhile (idx < list.size()) {\r\n var itemNode = list.get(idx);\r\n if (itemNode.parentId == null || itemNode.parentId == \'0\' || itemNode.parentId == \'\') {\r\n dataList.add(itemNode);\r\n } else {\r\n var pid = null;\r\n if (itemNode.parentId.contains(",")){\r\n var arr = itemNode.parentId.split(",");\r\n pid=arr[arr.length-1]\r\n }else{\r\n pid=itemNode.parentId;\r\n }\r\n var parentNode = map.get(pid);\r\n if (parentNode != null) {\r\n parentNode.children.add(itemNode);\r\n } else {\r\n dataList.add(itemNode);\r\n }\r\n }\r\n idx = idx + 1;\r\n}\r\nreturn dataList\r\n',
},
dicOptions: [],
required: false,
rules: [],
events: {},
isShow: true,
tooltipConfig: { visible: false, title: '提示文本' },
params: { itemId: '2003761375221407745' },
itemId: '2003761375221407745',
style: { width: '100%' },
},
},
......@@ -930,14 +897,10 @@ export const formProps: FormProps = {
};
export const treeConfig = {
id: '1768452851557543938',
isMultiple: false,
name: 'api树',
id: '2019350969972043778',
isMultiple: true,
name: '产品类型',
type: 2,
configTip: '',
config: [
{ bindFiled: '', name: 'label-0', value: 'a' },
{ bindFiled: '', name: '测试', value: 'b' },
{ bindFiled: '', name: '开发', value: 'c' },
],
configTip: '已配置',
config: [{ bindFiled: 'cplx', name: '类型名称', value: 'value' }],
};
......@@ -127,8 +127,8 @@ export const permissionList = [
fieldId: 'cplx',
isSubTable: false,
showChildren: true,
type: 'select',
key: '61a60627cf7b44b5a3131074bebc5a64',
type: 'cascader',
key: '2c05765e50b44fa8be4aec443066f781',
children: [],
options: {},
},
......
......@@ -5,24 +5,7 @@
<ResizePageWrapper :hasLeft="true" :formLeftWidth="300">
<template #resizeLeft>
<BasicTree
title="产品类别"
toolbar
search
switcher
:clickRowToExpand="true"
:treeData="treeData"
:fieldNames="{ key: 'value', title: 'name' }"
@select="handleSelect"
>
<template #title="item">
<template v-if="item.renderIcon === 'childIcon'">
<Icon icon="ant-design:appstore-outlined" />
</template>
&nbsp;&nbsp;{{ item.name }}
</template>
</BasicTree>
<TreeStructure :treeConfig="treeConfig" @select="handleSelectTree"/>
</template>
......@@ -45,14 +28,7 @@
</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'">
......@@ -125,7 +101,7 @@
import Icon from '/@/components/Icon/index';
import { BasicTree, TreeItem } from '/@/components/Tree';
import { getDicDetailList } from '/@/api/system/dic';
......@@ -376,9 +352,6 @@
}
async function fetch() {
treeData.value = (await getDicDetailList({
itemId: '2003761375221407745',
})) as unknown as TreeItem[];
......@@ -448,4 +421,4 @@
</style>
\ No newline at end of file
</style>
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