| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595 |
- <template>
- <ele-modal
- custom-class="ele-dialog-form long-dialog-form"
- :centered="true"
- :visible="processSubmitDialogFlag"
- :title="title"
- append-to-body
- :close-on-click-modal="false"
- :width="isRight ? '800px' : '450px'"
- :before-close="cancel"
- >
- <div style="display: flex; height: 100%; justify-content: space-between">
- <div class="form-box">
- <!-- <div style="text-align: center; padding: 5px">-->
- <!-- {{ form.name }}-->
- <!-- </div>-->
- <fm-generate-form
- class="el-form-box"
- v-if="Object.keys(form?.formJson || {}).length !== 0"
- :data="jsonData"
- :value="form.valueJson"
- ref="generateForm"
- >
- </fm-generate-form>
- <!-- <el-tree-->
- <!-- @check-change="handleTreeChange"-->
- <!-- show-checkbox-->
- <!-- node-key="id"-->
- <!-- class="filter-tree"-->
- <!-- check-strictly-->
- <!-- :data="treeData"-->
- <!-- :props="defaultProps"-->
- <!-- :filter-node-method="filterNode"-->
- <!-- ref="tree"-->
- <!-- >-->
- <!-- </el-tree>-->
- </div>
- <div
- style="
- align-self: center;
- display: flex;
- color: #1890ff;
- cursor: pointer;
- width: 15px;
- "
- @click="() => (isRight = !isRight)"
- >
- <span
- style="
- align-self: center;
- transform: scale(1.5);
- "
- :class="isRight ? 'el-icon-caret-left' : 'el-icon-caret-right'"
- >
- </span>
- <span style="writing-mode: vertical-rl">选择流程</span>
- </div>
- <div style="flex: 1" v-if="isRight">
- <el-form
- ref="form"
- :rules="rules"
- class="el-form-box"
- :model="form"
- label-width="80px"
- >
- <el-row>
- <el-col :span="12">
- <el-form-item label="流程分类">
- <ele-tree-select
- @change="changeLCFL"
- clearable
- ref="processTypeRef"
- filterable
- :data="LCFLList"
- v-model="form.LCFL"
- childrenKey="children"
- valueKey="id"
- labelKey="name"
- placeholder="请选择"
- default-expand-all
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="发起流程">
- <el-select
- filterable
- v-model="form.FQLC"
- @change="changeFQLC"
- style="width: 100%"
- >
- <el-option
- v-for="item in processList"
- :key="item.id"
- :value="item.id"
- :label="item.name"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-form-item label="流程名称">
- <el-input v-model="form.name" clearable></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="流程标识">
- <el-input v-model="form.key" disabled></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <headerTitle
- title="流程执行人/流程图"
- style="margin-top: 30px"
- ></headerTitle>
- <el-table
- :data="datasource"
- height="150px"
- border
- style="margin-bottom: 10px"
- >
- <el-table-column
- label="任务节点"
- align="center"
- prop="taskDefinitionName"
- width="140"
- fixed
- />
- <el-table-column
- label="执行人"
- align="center"
- prop="options"
- min-width="140px"
- >
- <template v-slot="scope">
- <div
- v-if="scope.row.type !== 60 && scope.row.options.length > 0"
- >
- <el-tag
- size="medium"
- :key="option"
- v-for="option in scope.row.options"
- >
- {{ getAssignRuleOptionName(scope.row, option) }}
- </el-tag>
- </div>
- <el-tag size="medium" v-if="scope.row.type === 60">
- {{ getAssignRuleOptionName(scope.row) }}
- </el-tag>
- </template>
- </el-table-column>
- </el-table>
- <my-process-viewer
- style="min-width: 100%; height: 200px"
- key="designer"
- v-model="bpmnXML"
- />
- </el-form>
- </div>
- </div>
- <div slot="footer">
- <el-form :model="form" label-width="100px">
- <el-form-item label="通知人">
- <ele-tree-select
- @change="handleTreeChange"
- filterable
- style="width: 100%"
- ref="treeSelect"
- multiple
- clearable
- :data="treeData"
- v-model="treeList"
- placeholder="请选择"
- valueKey="id"
- labelKey="name"
- :checkStrictly="true"
- />
- </el-form-item>
- </el-form>
- <!-- <el-button-->
- <!-- type="primary"-->
- <!-- size="small"-->
- <!-- v-if="active == 0"-->
- <!-- @click="() => ((active = 1), (isRight = true))"-->
- <!-- >下一步-->
- <!-- </el-button>-->
- <!-- <el-button-->
- <!-- type="primary"-->
- <!-- size="small"-->
- <!-- v-if="active == 1"-->
- <!-- @click="() => (active = 0)"-->
- <!-- >上一步-->
- <!-- </el-button>-->
- <el-button type="primary" size="small" @click="submit">提交</el-button>
- <el-button size="small" @click="cancel">关闭</el-button>
- </div>
- </ele-modal>
- </template>
- <script>
- import {
- getModelPage,
- getProcessDefinitionBpmnXML,
- getProcessDefinitionInfo,
- getTaskAssignRuleList,
- listAllUserBind,
- listSimpleUserGroups,
- processInstanceCreateAPI
- } from './api';
- import { treeClassifyCodeEnum } from '@/enum/dict';
- import { listRoles } from '@/api/system/role';
- import { listOrganizations } from '@/api/system/organization';
- import dictMixins from '@/mixins/dictMixins';
- import { getByCode } from '@/api/system/dictionary-data';
- import { getGroupUserTree, getProduceTreeByCode } from '@/api/main';
- import { getModel } from '@/api/bpm/model';
- import { getProcessDefinitionList } from '@/api/bpm/definition';
- import { getToken } from '@/utils/token-util';
- import {mapGetters} from "vuex";
- export default {
- name: 'processSubmitDialog',
- components: {},
- mixins: [dictMixins],
- props: {
- processSubmitDialogFlag: {
- type: Boolean,
- default: false
- }
- },
- watch: {
- filterText(val) {
- this.$refs.tree.filter(val);
- }
- },
- data() {
- return {
- isRight: false,
- jsonData: {},
- form: {
- LCFL: '',
- FQLC: '',
- processDefinitionId: '',
- name: '',
- businessId: '',
- noticeScope: [],
- formJson: {},
- valueJson: {},
- businessKey: ''
- },
- title: '',
- active: 0,
- bpmnXML: null,
- filterText: null,
- treeList: [],
- treeData: [],
- defaultProps: {
- children: 'children',
- label: 'name'
- },
- LCFLList: [],
- processList: [],
- datasource: [],
- roleOptions: [],
- deptOptions: [],
- deptTreeOptions: [],
- postOptions: [],
- userOptions: [],
- userGroupOptions: [],
- dictList: {},
- rules: {}
- };
- },
- computed:{
- ...mapGetters(['user']),
- },
- async created() {
- let typeObj = await getProduceTreeByCode(
- treeClassifyCodeEnum['PROCESSTYPE']
- );
- await this.getTreeData();
- this.LCFLList = typeObj[0].children;
- // 获得角色列表
- this.roleOptions = [];
- listRoles({
- current: 1,
- size: 9999
- }).then((data) => {
- this.roleOptions.push(...data.list);
- });
- // 获得部门列表
- this.deptOptions = [];
- this.deptTreeOptions = [];
- listOrganizations().then((data) => {
- this.deptOptions.push(...data);
- this.deptTreeOptions.push(...this.handleTree(data, 'id'));
- });
- // 获得岗位列表 暂无岗位概念
- this.postOptions = [];
- /*listSimplePosts().then(response => {
- this.postOptions.push(...response.data);
- });*/
- // 获得用户列表
- this.userOptions = [];
- listAllUserBind().then((data) => {
- this.userOptions.push(...data);
- });
- // 获得用户组列表
- this.userGroupOptions = [];
- listSimpleUserGroups().then((response) => {
- this.userGroupOptions.push(...response);
- });
- //this.dictEnum['工作流任务分配自定义脚本']
- await this.getDictList(this.dictEnum['工作流任务分配自定义脚本']);
- await this.getDictList(this.dictEnum['工种类型']);
- },
- mounted() {
- //this.isRight = false
- },
- methods: {
- async init(row = {}) {
- this.title = '新建' + row.name + '单';
- this.form = _.cloneDeep(row);
- this.form.formId = row.id;
- this.$set(this.form, 'noticeScope', []);
- this.$set(this.form, 'LCFL', '');
- this.$set(this.form, 'FQLC', '');
- this.$set(this.form, 'name', '');
- this.$set(this.form, 'key', '');
- this.$set(this.form, 'valueJson', {});
- this.jsonData = JSON.parse(this.form.formJson.makingJson);
- this.jsonData.config.dataSource &&
- this.jsonData.config.dataSource.forEach((item) => {
- item.headers = {
- Authorization: getToken()
- };
- // item.url = item.url && item.url.replace('/api', this.APIUrl);
- });
- console.log(this.user,'');
- this.jsonData.list.forEach((item) => {
- if (item.type == 'deptAndUserCascader') {
- }
- if (item.type == 'deptCascader') {
- this.form.valueJson[item.model] = this.user.info.deptIds
- }
- if (item.type == 'userSelect') {
- this.form.valueJson[item.model] = this.user.info.userId
- }
- if (item.type == 'imgupload') {
- // this.form.valueJson[item.model].length &&
- // this.form.valueJson[item.model].forEach((item) => {
- // //item.objectUrl = this.APIUrl +'/kd-aiot' + item.storePath
- // // item.objectUrl = item.url;
- // // console.log(item);
- // });
- }
- });
- await this.getProcessDefinitionBpmnXMLInfo(this.form.processModelId);
- await this.getTaskAssignRuleListInfo({
- modelId: this.form.processModelId,
- processDefinitionId: this.form.processDefinitionId
- });
- await this.getDefaultInfo(row.processModelId);
- },
- async getDefaultInfo(businessKey) {
- let info = await getModel(businessKey);
- //let info = await getProcessDefinitionInfo({ id: businessKey });
- this.form.LCFL = info?.category;
- this.form.FQLC = info?.id;
- this.form.name = this.title;
- this.form.key = info?.key;
- if (this.form.LCFL) await this.getProcessList(this.form.LCFL);
- },
- async getProcessList(val) {
- let params = {
- pageNo: 1,
- pageSize: 999,
- processTypeId: val
- };
- const { list } = await getModelPage(params);
- this.processList = list.filter((item) => item.processDefinition);
- },
- async getProcessDefinitionBpmnXML(val) {
- this.bpmnXML = await getProcessDefinitionBpmnXML(val);
- },
- async getProcessDefinitionBpmnXMLInfo(val) {
- // 加载流程图
- let res = await getModel(val);
- this.bpmnXML = res.bpmnXml;
- },
- async getTaskAssignRuleListInfo(find) {
- this.datasource = await getTaskAssignRuleList({
- modelId: find.modelId,
- processDefinitionId: find.processDefinitionId
- });
- },
- getAssignRuleOptionName(row, option) {
- if (row.type == 10) {
- for (const roleOption of this.roleOptions) {
- if (roleOption.id === option) {
- return roleOption.name;
- }
- }
- } else if (row.type === 20 || row.type === 21) {
- for (const deptOption of this.deptOptions) {
- if (deptOption.id === option) {
- return deptOption.name;
- }
- }
- } else if (row.type === 22) {
- option = option + ''; // 转换成 string
- return this.getDictV(this.dictEnum['工种类型'], option);
- } else if (row.type === 30 || row.type === 31 || row.type === 32) {
- for (const userOption of this.userOptions) {
- if (userOption.id === option) {
- return userOption.nickname || userOption.name;
- }
- }
- } else if (row.type === 40) {
- for (const userGroupOption of this.userGroupOptions) {
- if (userGroupOption.id === option) {
- return userGroupOption.name;
- }
- }
- } else if (row.type === 50) {
- option = option + ''; // 转换成 string
- return this.getDictV(
- this.dictEnum['工作流任务分配自定义脚本'],
- option
- );
- } else if (row.type === 60) {
- return row.variableName;
- }
- return '未知(' + option + ')';
- },
- async getTreeData() {
- this.treeData = await getGroupUserTree();
- },
- filterNode(value, data) {
- if (!value) return true;
- return data.name.indexOf(value) !== -1;
- },
- /**
- * 构造树型结构数据
- * @param {*} data 数据源
- * @param {*} id id字段 默认 'id'
- * @param {*} parentId 父节点字段 默认 'parentId'
- * @param {*} children 孩子节点字段 默认 'children'
- * @param {*} rootId 根Id 默认 0
- */
- handleTree(data, id, parentId, children, rootId) {
- id = id || 'id';
- parentId = parentId || 'parentId';
- children = children || 'children';
- rootId =
- rootId ||
- Math.min.apply(
- Math,
- data.map((item) => {
- return item[parentId];
- })
- ) ||
- 0;
- //对源数据深度克隆
- const cloneData = JSON.parse(JSON.stringify(data));
- //循环所有项
- const treeData = cloneData.filter((father) => {
- let branchArr = cloneData.filter((child) => {
- //返回每一项的子级数组
- return father[id] == child[parentId];
- });
- branchArr.length > 0 ? (father.children = branchArr) : '';
- //返回第一层
- return father[parentId] == rootId;
- });
- return treeData !== '' ? treeData : data;
- },
- getDictV(code, val) {
- if (!this.dictList[code]) return '';
- return this.dictList[code].find((item) => item.value == val)?.label;
- },
- async getDictList(code) {
- let { data: res } = await getByCode(code);
- this.dictList[code] = res.map((item) => {
- let values = Object.keys(item);
- return {
- value: values[0],
- label: item[values[0]]
- };
- });
- },
- generateFormValid(validate = true) {
- return this.$refs.generateForm.getData(validate).then((data) => {
- return data;
- });
- },
- handleTreeChange() {
- this.$nextTick(() => {
- this.form.noticeScope =
- this.$refs.treeSelect.$refs.tree.getCheckedNodes();
- console.log(this.form.noticeScope);
- });
- },
- async changeLCFL(val) {
- this.bpmnXML = null;
- this.form.processDefinitionId = null;
- this.form.FQLC = null;
- await this.getProcessList(val);
- },
- async changeFQLC(val) {
- if (!val) return;
- let find = this.processList.find((item) => item.id === val) || {};
- this.form.name = find.name;
- this.form.key = find.key;
- this.form.processDefinitionId = find.processDefinition.id;
- this.form.processModelId = val;
- await this.getProcessDefinitionBpmnXML(find.processDefinition.id);
- await this.getTaskAssignRuleListInfo({
- modelId: find.id,
- processDefinitionId: find.processDefinition.id
- });
- },
- async submit() {
- this.form.valueJson = await this.generateFormValid();
- this.form.processType = '1';
- await processInstanceCreateAPI({
- ...this.form,
- variables: { ...this.form.valueJson }
- });
- this.$message('提交审核成功');
- this.$emit('reload');
- this.cancel();
- },
- cancel() {
- this.$emit('update:processSubmitDialogFlag', false);
- }
- }
- };
- </script>
- <style scoped lang="scss">
- .box {
- display: flex;
- height: 450px;
- .left-box {
- width: 55%;
- border-right: 1px solid #e2e4e7;
- padding-right: 15px;
- height: 100%;
- .el-tree {
- height: 85%;
- overflow-y: auto;
- }
- }
- .right-box {
- flex: 1;
- padding-left: 20px;
- height: 100%;
- .right-box-item {
- margin-top: 5px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- }
- }
- .form-box {
- max-height: 500px;
- min-width: 400px;
- overflow: auto;
- }
- ::v-deep .el-dialog {
- min-width: 400px;
- .el-dialog__header {
- background: #1890ffd6;
- }
- .el-dialog__title,
- .el-dialog__close {
- color: #ffffff;
- }
- }
- </style>
|