init
This commit is contained in:
208
src/views/jsonflow/def-flow/form.vue
Normal file
208
src/views/jsonflow/def-flow/form.vue
Normal file
@@ -0,0 +1,208 @@
|
||||
<template>
|
||||
<el-dialog :title="title" v-model="visible" width="80%"
|
||||
:close-on-click-modal="false" draggable>
|
||||
<el-form ref="dataFormRef" :model="form" :rules="dataRules" label-width="130px" v-loading="loading" :disabled="operType === 'view'">
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item :label="t('defFlow.flowName')" prop="flowName">
|
||||
<el-input v-model="form.flowName" :placeholder="t('defFlow.inputFlowNameTip')"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item :label="t('defFlow.flowKey')" prop="flowKey">
|
||||
<el-input v-model="form.flowKey" :disabled="operType === 'edit'" :placeholder="t('defFlow.inputFlowKeyTip')"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item :label="t('defFlow.groupName')" prop="groupName">
|
||||
<el-select v-model="form.groupName" :placeholder="t('defFlow.inputGroupNameTip')" style="width: 81%!important;"
|
||||
clearable filterable allowCreate defaultFirstOption>
|
||||
<el-option v-for="(item, index) in dicData.groupName" :key="index" :label="item.groupName" :value="item.groupName"></el-option>
|
||||
</el-select>
|
||||
|
||||
<el-button
|
||||
type="primary" size="small" round style="margin-left: 10px"
|
||||
@click="handleAddGroupName"
|
||||
>新增分组
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item :label="t('defFlow.status')" prop="status">
|
||||
<el-radio-group v-model="form.status">
|
||||
<el-radio v-for="(item, index) in DIC_PROP.TEMP_STATUS" :key="index" :label="item.value" >
|
||||
{{ getLabelByLanguage(item) }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item :label="t('defFlow.remark')" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" :placeholder="t('defFlow.inputRemarkTip')"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item :label="t('defFlow.sort')" prop="sort">
|
||||
<el-input-number :min="1" :max="1000" v-model="form.sort" :placeholder="t('defFlow.inputSortTip')"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item :label="t('defFlow.isIndependent')" prop="isIndependent">
|
||||
<el-radio-group v-model="form.isIndependent">
|
||||
<el-radio v-for="(item, index) in DIC_PROP.YES_OR_NO" :key="index" :label="item.value" >
|
||||
{{ getLabelByLanguage(item) }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer v-if="operType !== 'view'">
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="visible = false">{{ $t('common.cancelButtonText') }}</el-button>
|
||||
<el-button type="primary" @click="onSubmit" :disabled="loading">{{ $t('common.confirmButtonText') }}</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="DefFlowDialog">
|
||||
|
||||
import {useMessage, useMessageBox} from "/@/hooks/message";
|
||||
import {getObj, addObj, putObj, getByFlowName, tempStore} from '/@/api/jsonflow/def-flow'
|
||||
import { useI18n } from "vue-i18n"
|
||||
import { rule } from '/@/utils/validate';
|
||||
import {onLoadDicUrl, onUpdateDicData} from "/@/flow/components/convert-name/convert";
|
||||
import {deepClone} from "/@/utils/other";
|
||||
import {setPropsNullValue} from "/@/flow/support/common";
|
||||
const emit = defineEmits(['refresh']);
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
// 定义变量内容
|
||||
const dataFormRef = ref();
|
||||
const visible = ref(false);
|
||||
const loading = ref(false);
|
||||
const operType = ref(false);
|
||||
const title = ref('');
|
||||
// 定义字典
|
||||
const dicData = reactive({});
|
||||
const onLoad = onLoadDicUrl({prefix: "defFlow", key: "groupName"});
|
||||
const onUpdate = onUpdateDicData({key: "groupName"});
|
||||
onMounted(() => {
|
||||
onLoad(dicData);
|
||||
});
|
||||
|
||||
// 提交表单数据
|
||||
const form = reactive({
|
||||
flowName: '',
|
||||
flowKey: '',
|
||||
groupName: '',
|
||||
status: '-1',
|
||||
isIndependent: '0',
|
||||
remark: '',
|
||||
sort: 1,
|
||||
});
|
||||
// 初始表单数据
|
||||
const initForm = reactive(deepClone(form));
|
||||
|
||||
// 校验是否已存在
|
||||
let validateIsExist = (rule, value, callback) => {
|
||||
// 修改判断相同id
|
||||
getByFlowName(value).then(response => {
|
||||
const result = response.data
|
||||
if (result !== null) {
|
||||
if (result.id !== form.id)
|
||||
callback(new Error('流程名称已经存在'))
|
||||
else callback()
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 定义校验规则
|
||||
const dataRules = ref({
|
||||
flowName: [{required: true, message: '流程名称不能为空', trigger: 'blur'}/*, {validator: validateIsExist, trigger: 'blur'}*/],
|
||||
flowKey: [{required: true, message: '流程KEY不能为空', trigger: 'blur'}],
|
||||
groupName: [{required: true, message: '分组名称不能为空', trigger: 'blur'}],
|
||||
status: [{required: true, message: '状态不能为空', trigger: 'blur'}],
|
||||
sort: [{required: true, message: '排序值不能为空', trigger: 'blur'}],
|
||||
})
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = (type: string, id: string) => {
|
||||
visible.value = true
|
||||
operType.value = type;
|
||||
form.id = ''
|
||||
|
||||
if (type === 'add') {
|
||||
title.value = t('common.addBtn');
|
||||
} else if (type === 'edit') {
|
||||
title.value = t('common.editBtn');
|
||||
} else if (type === 'view') {
|
||||
title.value = t('common.viewBtn');
|
||||
}
|
||||
|
||||
// 重置表单数据
|
||||
setPropsNullValue(form, initForm)
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
});
|
||||
|
||||
// 获取DefFlow信息
|
||||
if (id) {
|
||||
form.id = id
|
||||
getDefFlowData(id)
|
||||
}
|
||||
};
|
||||
|
||||
function handleAddGroupName() {
|
||||
useMessageBox().prompt("请输入新的分组名称")
|
||||
.then(({ value }) => {
|
||||
form.groupName = value
|
||||
onUpdate(dicData, form);
|
||||
})
|
||||
}
|
||||
|
||||
// 提交
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
try {
|
||||
loading.value = true;
|
||||
await tempStore(form);
|
||||
useMessage().success(t(form.id ? 'common.editSuccessText' : 'common.addSuccessText'));
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化表单数据
|
||||
const getDefFlowData = (id: string) => {
|
||||
// 获取数据
|
||||
loading.value = true
|
||||
getObj(id).then((res: any) => {
|
||||
Object.assign(form, res.data)
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
};
|
||||
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
openDialog
|
||||
});
|
||||
</script>
|
||||
36
src/views/jsonflow/def-flow/i18n/en.ts
Normal file
36
src/views/jsonflow/def-flow/i18n/en.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
export default {
|
||||
defFlow: {
|
||||
index: '#',
|
||||
importdefFlowTip: 'import DefFlow',
|
||||
id: 'id',
|
||||
flowName: 'flowName',
|
||||
flowKey: 'flowKey',
|
||||
groupName: 'groupName',
|
||||
status: 'status',
|
||||
remark: 'remark',
|
||||
version: 'version',
|
||||
createUser: 'createUser',
|
||||
createTime: 'createTime',
|
||||
sort: 'sort',
|
||||
isIndependent: 'isIndependent',
|
||||
updateUser: 'updateUser',
|
||||
updateTime: 'updateTime',
|
||||
delFlag: 'delFlag',
|
||||
|
||||
inputIdTip: 'input id',
|
||||
inputFlowNameTip: 'input flowName',
|
||||
inputFlowKeyTip: 'input flowKey',
|
||||
inputGroupNameTip: 'input groupName',
|
||||
inputStatusTip: 'input status',
|
||||
inputRemarkTip: 'input remark',
|
||||
inputVersionTip: 'input version',
|
||||
inputCreateUserTip: 'input createUser',
|
||||
inputCreateTimeTip: 'input createTime',
|
||||
inputSortTip: 'input sort',
|
||||
inputIsIndependentTip: 'input isIndependent',
|
||||
inputUpdateUserTip: 'input updateUser',
|
||||
inputUpdateTimeTip: 'input updateTime',
|
||||
inputDelFlagTip: 'input delFlag',
|
||||
|
||||
}
|
||||
}
|
||||
36
src/views/jsonflow/def-flow/i18n/zh-cn.ts
Normal file
36
src/views/jsonflow/def-flow/i18n/zh-cn.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
export default {
|
||||
defFlow: {
|
||||
index: '#',
|
||||
importdefFlowTip: '导入流程定义管理',
|
||||
id: '主键ID',
|
||||
flowName: '流程名称',
|
||||
flowKey: '流程KEY',
|
||||
groupName: '分组名称',
|
||||
status: '状态',
|
||||
remark: '备注',
|
||||
version: '版本',
|
||||
createUser: '创建人',
|
||||
createTime: '创建时间',
|
||||
sort: '排序值',
|
||||
isIndependent: '发起后配置独立',
|
||||
updateUser: '修改人',
|
||||
updateTime: '修改时间',
|
||||
delFlag: '删除标识',
|
||||
|
||||
inputIdTip: '请输入主键ID',
|
||||
inputFlowNameTip: '请输入流程名称',
|
||||
inputFlowKeyTip: '请输入流程KEY',
|
||||
inputGroupNameTip: '请输入分组名称',
|
||||
inputStatusTip: '请输入状态',
|
||||
inputRemarkTip: '请输入备注',
|
||||
inputVersionTip: '请输入版本',
|
||||
inputCreateUserTip: '请输入创建人',
|
||||
inputCreateTimeTip: '请输入创建时间',
|
||||
inputSortTip: '请输入排序值',
|
||||
inputIsIndependentTip: '请选择发起后配置独立',
|
||||
inputUpdateUserTip: '请输入修改人',
|
||||
inputUpdateTimeTip: '请输入修改时间',
|
||||
inputDelFlagTip: '请输入删除标识',
|
||||
|
||||
}
|
||||
}
|
||||
197
src/views/jsonflow/def-flow/index.vue
Normal file
197
src/views/jsonflow/def-flow/index.vue
Normal file
@@ -0,0 +1,197 @@
|
||||
<template>
|
||||
<div class="layout-padding">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<el-row v-show="showSearch">
|
||||
<el-form :model="state.queryForm" ref="queryRef" :inline="true" @keyup.enter="getDataList">
|
||||
<el-form-item :label="$t('defFlow.flowName')" prop="flowName" >
|
||||
<el-input :placeholder="t('defFlow.inputFlowNameTip')" v-model="state.queryForm.flowName"
|
||||
style="max-width: 180px" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button icon="search" type="primary" @click="getDataList">
|
||||
{{ $t('common.queryBtn') }}
|
||||
</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">{{ $t('common.resetBtn') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<div class="mb8" style="width: 100%">
|
||||
<el-tooltip placement="top">
|
||||
<template #content>
|
||||
{{ $t('common.addBtn') }}
|
||||
</template>
|
||||
<el-button icon="Plus" type="primary" class="ml10" @click="formDialogRef.openDialog('add')"
|
||||
v-auth="'jsonflow_defflow_add'">
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
|
||||
<el-tooltip placement="top">
|
||||
<template #content>
|
||||
{{ $t('common.delBtn') }}
|
||||
</template>
|
||||
<el-button plain :disabled="multiple" icon="Delete" type="primary" class="ml10"
|
||||
v-auth="'jsonflow_defflow_del'" @click="handleDelete(selectObjs)">
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
|
||||
<right-toolbar v-model:showSearch="showSearch" :export="'jsonflow_defflow_export'"
|
||||
@exportExcel="exportExcel" class="ml10" style="float: right;margin-right: 20px"
|
||||
@queryTable="getDataList"></right-toolbar>
|
||||
</div>
|
||||
</el-row>
|
||||
<el-table :data="state.dataList" v-loading="state.loading" style="width: 100%"
|
||||
@selection-change="handleSelectionChange" @sort-change="sortChangeHandle">
|
||||
<el-table-column type="selection" width="40" align="center" />
|
||||
<el-table-column type="index" :label="t('defFlow.index')" width="40" />
|
||||
<el-table-column prop="flowName" :label="t('defFlow.flowName')" show-overflow-tooltip/>
|
||||
<el-table-column prop="flowKey" :label="t('defFlow.flowKey')" show-overflow-tooltip/>
|
||||
<el-table-column prop="groupName" :label="t('defFlow.groupName')" show-overflow-tooltip/>
|
||||
<!-- <el-table-column prop="isIndependent" :label="t('defFlow.isIndependent')" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<dict-tag :options="DIC_PROP.YES_OR_NO" :value="scope.row.isIndependent"></dict-tag>
|
||||
</template>
|
||||
</el-table-column>-->
|
||||
<el-table-column prop="remark" :label="t('defFlow.remark')" width="300" show-overflow-tooltip/>
|
||||
<el-table-column prop="status" :label="t('defFlow.status')" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<dict-tag :options="DIC_PROP.TEMP_STATUS" :value="scope.row.status"></dict-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="version" :label="t('defFlow.version')" show-overflow-tooltip/>
|
||||
<!-- <el-table-column prop="createUser" :label="t('defFlow.createUser')" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<convert-name :options="state.dicData.createUser" :value="scope.row.createUser"
|
||||
:valueKey="'userId'" :showKey="'name'"></convert-name>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" :label="t('defFlow.createTime')" show-overflow-tooltip/>-->
|
||||
<el-table-column :label="$t('common.action')" width="120">
|
||||
<template #default="scope">
|
||||
<el-tooltip placement="top">
|
||||
<template #content>
|
||||
{{ $t('common.viewBtn') }}
|
||||
</template>
|
||||
<el-button text type="primary" icon="view" @click="formDialogRef.openDialog('view', scope.row.id)" v-auth="'jsonflow_defflow_view'">
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip placement="top">
|
||||
<template #content>
|
||||
{{ $t('common.editBtn') }}
|
||||
</template>
|
||||
<el-button icon="edit-pen" text type="primary" v-auth="'jsonflow_defflow_edit'" @click="formDialogRef.openDialog('edit', scope.row.id)">
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip placement="top">
|
||||
<template #content>
|
||||
{{ $t('common.delBtn') }}
|
||||
</template>
|
||||
<el-button icon="delete" text type="primary" v-auth="'jsonflow_defflow_del'" @click="handleDelete([scope.row.id])">
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip placement="top" v-if="scope.row.fromType === '1'">
|
||||
<template #content>
|
||||
{{ $t('jfI18n.designFlow') }}
|
||||
</template>
|
||||
<el-button text type="primary" icon="Share" v-auth="'jsonflow_defflow_edit'"
|
||||
@click="handleEditPhoto(scope.row)">
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
||||
</div>
|
||||
|
||||
<!-- 编辑、新增 -->
|
||||
<form-dialog ref="formDialogRef" @refresh="getDataList(false)" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="systemDefFlow">
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||
import { fetchList, delObjs } from "/@/api/jsonflow/def-flow";
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { onLoaded } from "/@/flow/components/convert-name/convert";
|
||||
|
||||
// 引入组件
|
||||
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||
const { t } = useI18n()
|
||||
// 定义查询字典
|
||||
|
||||
// 定义变量内容
|
||||
const formDialogRef = ref()
|
||||
// 搜索变量
|
||||
const queryRef = ref()
|
||||
const showSearch = ref(true)
|
||||
// 多选变量
|
||||
const selectObjs = ref([]) as any
|
||||
const multiple = ref(true)
|
||||
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
queryForm: {fromType: '1'},
|
||||
pageList: fetchList,
|
||||
onLoaded: onLoaded({key: "createUser"}),
|
||||
descs: ["create_time"]
|
||||
})
|
||||
|
||||
// table hook
|
||||
const {
|
||||
getDataList,
|
||||
currentChangeHandle,
|
||||
sizeChangeHandle,
|
||||
sortChangeHandle,
|
||||
downBlobFile
|
||||
} = useTable(state)
|
||||
|
||||
// 清空搜索条件
|
||||
const resetQuery = () => {
|
||||
// 清空搜索条件
|
||||
queryRef.value?.resetFields()
|
||||
// 清空多选
|
||||
selectObjs.value = []
|
||||
getDataList()
|
||||
}
|
||||
|
||||
// 导出excel
|
||||
const exportExcel = () => {
|
||||
downBlobFile('/jsonflow/def-flow/export', state.queryForm, 'def-flow.xlsx')
|
||||
}
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: any) => {
|
||||
selectObjs.value = objs.map(({ id }) => id);
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObjs(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
const router = useRouter();
|
||||
const handleEditPhoto = (row: any) => {
|
||||
let src = "/jsonflow/flow-design/index";
|
||||
router.push({
|
||||
path: src,
|
||||
query: {
|
||||
currFlowId: row.id,
|
||||
flowType: '0'
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user