Commit d344eeca by 张珈源

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

parents 3df80c14 e7063ef0
import { MesHegezhengPageModel, MesHegezhengPageParams, MesHegezhengPageResult } from './model/HgzglModel';
import { defHttp } from '/@/utils/http/axios';
import { ErrorMessageMode } from '/#/axios';
enum Api {
Page = '/jcsj/hgzgl/page',
List = '/jcsj/hgzgl/list',
Info = '/jcsj/hgzgl/info',
MesHegezheng = '/jcsj/hgzgl',
}
/**
* @description: 查询MesHegezheng分页列表
*/
export async function getMesHegezhengPage(params: MesHegezhengPageParams, mode: ErrorMessageMode = 'modal') {
return defHttp.get<MesHegezhengPageResult>(
{
url: Api.Page,
params,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 获取MesHegezheng信息
*/
export async function getMesHegezheng(id: String, mode: ErrorMessageMode = 'modal') {
return defHttp.get<MesHegezhengPageModel>(
{
url: Api.Info,
params: { id },
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 新增MesHegezheng
*/
export async function addMesHegezheng(mesHegezheng: Recordable, mode: ErrorMessageMode = 'modal') {
return defHttp.post<boolean>(
{
url: Api.MesHegezheng,
params: mesHegezheng,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 更新MesHegezheng
*/
export async function updateMesHegezheng(mesHegezheng: Recordable, mode: ErrorMessageMode = 'modal') {
return defHttp.put<boolean>(
{
url: Api.MesHegezheng,
params: mesHegezheng,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 删除MesHegezheng(批量删除)
*/
export async function deleteMesHegezheng(ids: string[], mode: ErrorMessageMode = 'modal') {
return defHttp.delete<boolean>(
{
url: Api.MesHegezheng,
data: ids,
},
{
errorMessageMode: mode,
},
);
}
import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';
/**
* @description: MesHegezheng分页参数 模型
*/
export interface MesHegezhengPageParams extends BasicPageParams {
ph: string;
lch: string;
gg: string;
khzs: string;
mzjz: string;
jy: string;
csrq: string;
cd: string;
id: string;
}
/**
* @description: MesHegezheng分页返回值模型
*/
export interface MesHegezhengPageModel {
id: string;
ph: string;
lch: string;
gg: string;
khzs: string;
mzjz: string;
jy: string;
csrq: string;
cd: string;
}
/**
* @description: MesHegezheng表类型
*/
export interface MesHegezhengModel {
id: string;
ph: string;
lch: string;
gg: string;
khzs: string;
mzjz: string;
jy: string;
csrq: string;
cd: string;
hgzmc: string;
}
/**
* @description: MesHegezheng分页返回值结构
*/
export type MesHegezhengPageResult = BasicFetchResult<MesHegezhengPageModel>;
<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 { addMesHegezheng, getMesHegezheng, updateMesHegezheng } from '/@/api/jcsj/hgzgl';
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 getMesHegezheng(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 updateMesHegezheng(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 addMesHegezheng(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: 1980,
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
import { FormProps, FormSchema } from '/@/components/Form';
import { BasicColumn } from '/@/components/Table';
export const searchFormSchema: FormSchema[] = [
{
field: 'ph',
label: '牌号',
defaultValue: undefined,
component: 'Input',
},
{
field: 'lch',
label: '炉次号',
defaultValue: undefined,
component: 'Input',
},
{
field: 'gg',
label: '规格',
defaultValue: undefined,
component: 'Input',
},
{
field: 'khzs',
label: '捆号/支数',
defaultValue: undefined,
component: 'Input',
},
{
field: 'mzjz',
label: '毛/净重',
defaultValue: undefined,
component: 'Input',
},
{
field: 'jy',
label: '检验',
defaultValue: undefined,
component: 'Input',
},
{
field: 'csrq',
label: '生产日期',
defaultValue: undefined,
component: 'RangePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm:ss',
style: { width: '100%' },
getPopupContainer: () => document.body,
},
},
{
field: 'cd',
label: '产地',
defaultValue: undefined,
component: 'Input',
},
{
field: 'id',
label: 'ID',
defaultValue: undefined,
component: 'Input',
},
];
export const columns: BasicColumn[] = [
{
resizable: true,
dataIndex: 'ph',
title: '牌号',
componentType: 'input',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: '',
},
{
resizable: true,
dataIndex: 'lch',
title: '炉次号',
componentType: 'input',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: '',
},
{
resizable: true,
dataIndex: 'gg',
title: '规格',
componentType: 'input',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: '',
},
{
resizable: true,
dataIndex: 'khzs',
title: '捆号/支数',
componentType: 'input',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: '',
},
{
resizable: true,
dataIndex: 'mzjz',
title: '毛/净重',
componentType: 'input',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: '',
},
{
resizable: true,
dataIndex: 'jy',
title: '检验',
componentType: 'input',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: '',
},
{
resizable: true,
dataIndex: 'csrq',
title: '生产日期',
componentType: 'date',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: undefined,
},
{
resizable: true,
dataIndex: 'cd',
title: '产地',
componentType: 'input',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: '',
},
{
resizable: true,
dataIndex: 'id',
title: 'ID',
componentType: 'input',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: '',
},
];
//表头合并配置
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: '594b50813c7949cd801f7612800596b3',
field: '',
label: '',
type: 'grid',
colProps: { span: 24 },
component: 'Grid',
children: [
{
span: 6,
list: [
{
key: '843fe0e5c5c844e1a87fa98b5788ab1d',
field: 'ph',
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%' },
},
},
],
},
{
span: 6,
list: [
{
key: 'eceff29af36e4e84b242f00c04084212',
field: 'lch',
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%' },
},
},
],
},
{
span: 6,
list: [
{
key: 'a1fa44483ba34cc18f041e2fce0c214b',
field: 'gg',
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%' },
},
},
],
},
{
span: 6,
list: [
{
key: '845691a6170a468ca05842fc6e88ae7f',
field: 'khzs',
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%' },
},
},
],
},
{
span: 6,
list: [
{
key: '2be62731c7964f8e93ab4aa2355c52e2',
field: 'mzjz',
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%' },
},
},
],
},
{
span: 6,
list: [
{
key: 'ba10b71965e742f09f48c88cc8d7048b',
field: 'jy',
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%' },
},
},
],
},
{
span: 6,
list: [
{
key: 'b3372ab4e99d42c3aaf1f0f2fff6363c',
field: 'csrq',
label: '生产日期',
type: 'date',
component: 'DatePicker',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
span: 7,
defaultValue: '',
width: '100%',
placeholder: '请选择生产日期',
format: 'YYYY-MM-DD HH:mm:ss',
showLabel: true,
allowClear: true,
disabled: false,
required: false,
isShow: true,
rules: [],
events: {},
isGetCurrent: false,
tooltipConfig: { visible: false, title: '提示文本' },
searchType: 'time',
style: { width: '100%' },
},
},
],
},
{
span: 6,
list: [
{
key: '3c1a5583a5374519aedc6f628a84dc90',
field: 'cd',
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%' },
},
},
],
},
{
span: 8,
list: [
{
key: 'e071b7bb0650495abc832118d86c11a6',
field: '',
label: '二维码',
type: 'qrcode',
component: 'XjrQrcode',
colProps: { span: 24 },
defaultValue: ' ',
componentProps: {
span: 7,
defaultValue: ' ',
showLabel: true,
isShow: true,
codeType: 'api',
apiConfig: {
path: '/jcxx//dy/getHgzInfo',
method: 'GET',
apiId: '',
apiParams: [
{
key: '1',
title: 'Query Params',
tableInfo: [
{
name: 'id',
value: '{"bindField":"id","fieldKey":"54403f0c4467446d94a962ec21485a17"}',
required: false,
defaultValue: '0',
bindType: 'data',
},
],
},
{ key: '2', title: 'Header', tableInfo: [] },
{ key: '3', title: 'Body' },
],
script:
'var sql="select * from mes_hegezheng where id = #{id}";\r\nreturn db.select(sql);',
},
tooltipConfig: { visible: false, title: '提示文本' },
style: {},
},
},
],
},
{
span: 6,
list: [
{
key: '54403f0c4467446d94a962ec21485a17',
field: 'id',
label: 'ID',
type: 'input',
component: 'Input',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: 7,
defaultValue: '',
placeholder: '请输入ID',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
listStyle: '',
isSave: false,
isShow: false,
scan: false,
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
style: { width: '100%' },
},
},
],
},
],
componentProps: {
gutter: 16,
justify: 'start',
align: 'top',
isShow: true,
showBorder: false,
bordercolor: '#d9d9d9',
bordershowtype: [true, true, true, true],
borderwidth: 1,
padding: '10px',
margin: '10px',
},
},
],
showActionButtonGroup: false,
buttonLocation: 'center',
actionColOptions: { span: 24 },
showResetButton: false,
showSubmitButton: false,
hiddenComponent: [],
};
export const formButtons = [
{
key: 'confirm',
code: 'confirm',
name: '确定',
style: 'primary',
event: [],
isShow: true,
index: 2,
type: 1,
},
{
key: 'cancel',
code: 'cancel',
name: '取消',
style: 'default',
event: [],
isShow: true,
index: 1,
type: 1,
},
{
key: 'reset',
code: 'reset',
name: '重置',
style: 'default',
event: [],
isShow: true,
index: 0,
type: 1,
},
];
export const permissionList = [
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '牌号',
fieldId: 'ph',
isSubTable: false,
showChildren: true,
type: 'input',
key: '843fe0e5c5c844e1a87fa98b5788ab1d',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '炉次号',
fieldId: 'lch',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'eceff29af36e4e84b242f00c04084212',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '规格',
fieldId: 'gg',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'a1fa44483ba34cc18f041e2fce0c214b',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '捆号/支数',
fieldId: 'khzs',
isSubTable: false,
showChildren: true,
type: 'input',
key: '845691a6170a468ca05842fc6e88ae7f',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '毛/净重',
fieldId: 'mzjz',
isSubTable: false,
showChildren: true,
type: 'input',
key: '2be62731c7964f8e93ab4aa2355c52e2',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '检验',
fieldId: 'jy',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'ba10b71965e742f09f48c88cc8d7048b',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '生产日期',
fieldId: 'csrq',
isSubTable: false,
showChildren: true,
type: 'date',
key: 'b3372ab4e99d42c3aaf1f0f2fff6363c',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '产地',
fieldId: 'cd',
isSubTable: false,
showChildren: true,
type: 'input',
key: '3c1a5583a5374519aedc6f628a84dc90',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: false,
disabled: true,
isSaveTable: false,
tableName: '',
fieldName: '二维码',
fieldId: '',
isSubTable: false,
showChildren: true,
type: 'qrcode',
key: 'e071b7bb0650495abc832118d86c11a6',
children: [],
options: {},
defaultValue: ' ',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: 'ID',
fieldId: 'id',
isSubTable: false,
showChildren: true,
type: 'input',
key: '54403f0c4467446d94a962ec21485a17',
children: [],
options: {},
defaultValue: '',
},
];
<template>
<ResizePageWrapper :hasLeft="false">
<template #resizeRight>
<BasicTable @register="registerTable" isMenuTable ref="tableRef" :row-selection="{ selectedRowKeys: selectedKeys, onChange: onSelectChange }"
>
<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>
<PrintPreview
v-if="printData.visible"
:id="printData.id"
:request-params-configs="printData.requestParamsConfigs"
:request-body-configs="printData.requestBodyConfigs"
:request-header-configs="printData.requestHeaderConfigs"
@close="handleClosePrintPreview"
/>
<HgzglModal @register="registerModal" @success="handleFormSuccess" @cancel="handleFormCancel"/>
</ResizePageWrapper>
</template>
<script lang="ts" setup>
import { ref, computed,provide,Ref,
reactive, } from 'vue';
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
import { getMesHegezhengPage, deleteMesHegezheng} from '/@/api/jcsj/hgzgl';
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 { getPrintConfigInfo } from '/@/api/system/generator/print';
import PrintPreview from '/@/views/generator/print/Preview.vue';
import { PrintButton } from '/@/enums/printEnum';
import { InputParamItem } from '/@/components/ApiConfig/src/interface';
import { useModal } from '/@/components/Modal';
import HgzglModal from './components/HgzglModal.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"]);
const buttonConfigs = computed(()=>{
const list = [{"buttonId":"2013807357670838272","name":"查看","code":"view","icon":"ant-design:eye-outlined","isDefault":true,"isUse":true},{"buttonId":"2013807357670838273","name":"编辑","code":"edit","icon":"ant-design:form-outlined","isDefault":true,"isUse":true,"isEnableLock":true},{"buttonId":"2013807357670838275","name":"模板打印","code":"templateprint","icon":"ant-design:printer-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,edit : handleEdit,templateprint : handleTemplateprint,}
const { currentRoute } = useRouter();
const printMenuId = computed(() => currentRoute.value.meta.menuId as string);
const formIdComputedRef = computed(() => currentRoute.value.meta.formId as string);
provide<Ref<string>>('currentFormId', formIdComputedRef);
const selectedKeys = ref<string[]>([]);
const selectedRowsData = ref<any[]>([]);
const [registerModal, { openModal }] = useModal();
// 模板打印 入参参数
let printData: {
visible:boolean;
id: string;
code:string;
requestParamsConfigs: Array<InputParamItem>;
requestHeaderConfigs: Array<InputParamItem>;
requestBodyConfigs: Array<InputParamItem>;
} = reactive({
visible:false,
id: '',
code:'',
requestParamsConfigs: [],
requestHeaderConfigs: [],
requestBodyConfigs: [],
});
const [registerTable, { reload, }] = useTable({
title: 'Hgzgl列表',
api: getMesHegezhengPage,
rowKey: 'id',
columns: filterColumns,
pagination: {
pageSize: 10,
},
formConfig: {
labelWidth: 100,
schemas: searchFormSchema,
fieldMapToTime: [['csrq', ['csrqStart', 'csrqEnd'], 'YYYY-MM-DD HH:mm:ss ', true],],
showResetButton: false,
},
bordered:false,
beforeFetch: (params) => {
pageParamsInfo.value = {...params, FormId: formIdComputedRef.value,PK: 'id' }
return pageParamsInfo.value;
},
afterFetch: (res) => {
selectedKeys.value = [];
selectedRowsData.value = [];
},
useSearchForm: true,
showTableSetting: true,
striped: false,
actionColumn: {
width: 130,
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) {
if (code.includes(PrintButton.CODE)) {
printData.code = code;
}
btnEvent[code]();
}
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) {}
}
// 模板打印
async function handleTemplateprint() {
if (!selectedKeys.value.length) {
notification.warning({
message: t('提示'),
description: t('请选择数据'),
});
return;
}
if (selectedKeys.value.length > 1) {
notification.warning({
message: t('提示'),
description: t('只能选择一条数据进行操作'),
});
return;
}
try {
let id = selectedKeys.value[0];
const record = await getMesHegezheng(id);
let res = await getPrintConfigInfo(printData.code, printMenuId.value);
if(res.enabledMark==null){
notification.warning({
message: t('提示'),
description: t('当前功能未绑定打印模板,请绑定后再进行模板打印。'),
});
return ;
}
if(res.enabledMark==0){
notification.warning({
message: t('提示'),
description: t('找不到打印模板,请联系管理员。'),
});
return ;
}
printData.id = res.schemaId;
if (res.apiConfig) {
let json = JSON.parse(res.apiConfig);
if (json.requestParamsConfigs && json.requestParamsConfigs.length > 0) {
printData.requestParamsConfigs = json.requestParamsConfigs.map((ele) => {
if (ele.config && record[ele.config] != undefined) {
ele.value = record[ele.config];
}
return ele;
});
}
if (json.requestHeaderConfigs && json.requestHeaderConfigs.length > 0) {
printData.requestHeaderConfigs = json.requestHeaderConfigs.map((ele) => {
if (ele.config && record[ele.config] != undefined) {
ele.value = record[ele.config];
}
return ele;
});
}
if (json.requestBodyConfigs && json.requestBodyConfigs.length > 0) {
printData.requestBodyConfigs = json.requestBodyConfigs.map((ele) => {
if (ele.config && record[ele.config] != undefined) {
ele.value = record[ele.config];
}
return ele;
});
}
printData.visible = true;
}else{
notification.warning({
message: t('提示'),
description: t('当前功能未绑定打印模板,请绑定后再进行模板打印。'),
});
}
} catch (error) {}
}
function handleClosePrintPreview() {
printData.visible = false;
reload();
}
function onSelectChange(selectedRowKeys: [], selectedRows) {
selectedKeys.value = selectedRowKeys;
selectedRowsData.value = selectedRows;
}
function customRow(record: Recordable) {
return {
onClick: () => {
let selectedRowKeys = [...selectedKeys.value];
if (selectedRowKeys.indexOf(record.id) >= 0) {
let index = selectedRowKeys.indexOf(record.id);
selectedRowKeys.splice(index, 1);
} else {
selectedRowKeys.push(record.id);
}
selectedKeys.value = selectedRowKeys;
},
ondblclick: () => {
if (record.isCanEdit && hasPermission("hgzgl:edit")) {
handleEdit(record);
}
},
};
}
function handleSuccess() {
selectedKeys.value = [];
selectedRowsData.value = [];
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: `hgzgl:${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: `hgzgl:${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
......@@ -1388,7 +1388,7 @@ export const formProps: FormProps = {
},
],
},
{
/*{
span: 24,
name: '数据采集详情',
prefix: '',
......@@ -1562,7 +1562,7 @@ export const formProps: FormProps = {
},
},
],
},
},*/
{
span: 24,
name: '质检信息',
......
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