rollback^2
xy 10 months ago
parent fd922c0721
commit ffb17034e3

@ -105,6 +105,15 @@ export function todoTotal() {
})
}
// 批量审批检查节点
export function getNextNodeBatch(params) {
return request({
url: '/api/oa/flow/get-next-node-batch',
method: 'get',
params,
})
}
//流转
export function assign(flow_id, data) {
return request({

@ -15,6 +15,15 @@
storage
show-footer
>
<div v-if="isValidDone" style="margin-bottom: 10px;">
<div style="color: #606266;font-weight: 600;font-size: 14px;line-height: 2;">可批量办理流程分组</div>
<div>
<el-tag style="margin-right: 4px;" v-for="(value, key) in batchData" :key="key">
流水号{{ tagFlowId(value) }}
</el-tag>
</div>
</div>
<vxe-table
ref="table"
stripe
@ -26,7 +35,17 @@
:row-config="{ keyField: 'id' }"
:custom-config="{ mode: 'popup' }"
:data="dealFlows"
:checkbox-config="{
checkMethod: ({ row }) => {
return isValidDone
}
}"
>
<vxe-column
type="checkbox"
width="50"
align="center"
></vxe-column>
<vxe-column
min-width="140"
header-align="center"
@ -85,7 +104,7 @@
"
></vxe-column>
</vxe-table>
<template v-if="device === 'desktop'">
<template>
<DesktopForm
:device="device"
ref="desktopForm"
@ -103,54 +122,38 @@
:logs="config.logs"
></DesktopForm>
</template>
<template v-else>
<MobileForm
:device="device"
ref="mobileForm"
:config="config"
:is-first-node="isFirstNode"
:need-flow-title="false"
:sub-form="subConfig"
:fields="fields"
:original-form="form"
:readable="[]"
:script-content="scriptContent"
:writeable="writeableFields"
:rules="rules"
:sub-rules="subRules"
:logs="config.logs"
></MobileForm>
</template>
<template #footer>
<el-button
icon="el-icon-document-add"
type="info"
size="small"
@click="submit('only-submit')"
@click="saveData('only-submit')"
>暂存不流转</el-button
>
<el-button type="primary" size="small" @click="submit('assign')"
<el-button v-if="!isValidDone" type="primary" size="small" @click="saveData('assign')"
>检查流转 <i class="el-icon-s-check"></i
></el-button>
<el-button v-else type="primary" size="small" @click="submit('assign')"
>保存并流转 <i class="el-icon-right"></i
></el-button>
</template>
</vxe-modal>
<assign :visible.sync="isShowAssign" :result="result" multiple :multipleIds="dealFlows.map(flow => flow.id)" @refresh="$emit('update:isShow', false),$emit('refresh')" />
<assign :visible.sync="isShowAssign" multiple :multipleIds="pickRowIds" @refresh="$emit('update:isShow', false),$emit('refresh')" />
</div>
</template>
<script>
import { PopupManager } from 'element-ui/lib/utils/popup'
import { defaultModalSize } from '@/settings'
import {create, deal, fieldConfig, preDeal} from '@/api/flow'
import { create, deal, fieldConfig, preDeal, getNextNodeBatch } from '@/api/flow'
import { validation, validationName } from "@/utils/validate";
import MobileForm from "@/views/flow/MobileForm.vue";
import DesktopForm from "@/views/flow/DesktopForm.vue";
import assign from './assign.vue'
import { deepCopy } from "@/utils";
export default {
components: {
DesktopForm, MobileForm,assign
DesktopForm,assign
},
props: {
isShow: {
@ -176,7 +179,10 @@ export default {
flows: [],
isShowAssign: false,
result: {},
batchData: null,
isValidDone: false,
pickRowIds: []
}
},
methods: {
@ -351,13 +357,53 @@ export default {
}
},
async submit(type) {
async validFlow() {
let loading;
try {
loading = this.$loading({
lock: true,
text: "验证是否能批量审批",
spinner: "el-icon-loading",
background: "rgba(0, 0, 0, 0.8)",
});
const { list } = await getNextNodeBatch({
ids: this.dealFlows.map(i => i.id).toString()
})
this.batchData = {}
list?.forEach((item, index) => {
let nextNodeIds = item.current_node?.nextNodes?.sort((a, b) => a.id - b.id)?.map(j => j.id)?.toString()
if (this.batchData.hasOwnProperty(nextNodeIds)) {
this.batchData[nextNodeIds].push({
data: item.flow_id,
trend: item.is_trend
})
} else {
Object.defineProperty(this.batchData, nextNodeIds, {
value: [{
data: item.flow_id,
trend: item.is_trend
}],
enumerable: true,
writable: true,
configurable: false
})
}
})
this.isValidDone = true
let longerData = Object.values(this.batchData).reduce((pre, cur) => (pre.length >= cur.filter(j => !j.trend)?.length) ? pre : cur.map(j => j.data), [])
this.$refs['table']?.setCheckboxRow(this.dealFlows.filter(flow => longerData.indexOf(flow.id) !== -1), true)
} catch (err) {
console.error(err)
} finally {
loading.close()
}
},
async saveData(type) {
if (window.$_uploading) {
this.$message.warning("文件正在上传中")
return
}
let copyForm;
if (this.device === "desktop") {
try {
await this.$refs['desktopForm'].validate()
} catch (err) {
@ -366,16 +412,6 @@ export default {
return
}
copyForm = deepCopy(this.$refs["desktopForm"].form);
} else {
try {
await this.$refs['mobileForm'].validate()
} catch (err) {
console.warn(err)
this.$message.warning('数据校验失败')
return
}
copyForm = deepCopy(this.$refs["mobileForm"].form);
}
const uploadHandler = (form, fields) => {
let keys = Object.keys(form)
keys.forEach(key => {
@ -410,28 +446,25 @@ export default {
}
copyForm["current_node_id"] = this.config.currentNode.id;
try {
let callback;
let callback = () => {}
switch (type) {
case "only-submit":
if (this.$route.query.flow_id) {
copyForm["temporary_save"] = 1;
}
callback = () => {
this.$emit('update:isShow', false)
this.$emit('refresh')
}
break;
case "assign":
if (this.$route.query.flow_id) {
copyForm["temporary_save"] = 0;
callback = () => {
this.validFlow()
}
callback = () => (this.isShowAssign = true);
break;
}
const resArr = await Promise.all(this.dealFlows.map(flow => deal(flow.id, copyForm)))
const { flow, is_last_handled_log } = resArr[0]
this.result = flow;
if (!is_last_handled_log) {
await this.$alert(
"办理成功,其他会签办理完成后,由最后办理的成员流转到下一节点。",
@ -445,11 +478,29 @@ export default {
this.$emit('refresh')
}
}
callback();
callback()
} catch (err) {
console.error(err);
}
},
async submit() {
function areAllElementsInArray(subsetArray, mainArray) {
return subsetArray.every(element => mainArray.includes(element));
}
this.pickRowIds = this.$refs['table']?.getCheckboxRecords(true)?.map(i => i.id)
console.log(345, this.pickRowIds)
let groupAllowIds = Object.values(this.batchData)?.map(group => {
return group.filter(j => !j.trend).map(j => j.data)
})
for(let i = 0;i < groupAllowIds.length;i++) {
const group = groupAllowIds[i]
if (areAllElementsInArray(this.pickRowIds, group)) {
this.isShowAssign = true
return
}
}
this.$message.warning("存在不符合批量流转流程")
},
},
computed: {
device() {
@ -473,6 +524,11 @@ export default {
},
isFirstNode() {
return this.config?.logs?.length === 0 || this.config?.currentNode?.category === 'start'
},
tagFlowId() {
return function (data) {
return data?.filter(i => !i.trend)?.map(i => i.data)?.toString()
}
}
},
watch: {
@ -483,6 +539,10 @@ export default {
if (this.dealFlows instanceof Array && this.dealFlows.length > 0) {
this.getConfig()
}
} else {
this.batchData = null
this.isValidDone = false
this.pickRowIds.length = 0
}
}
}

@ -136,7 +136,7 @@ export default {
config: Object,
result: {
type: Object,
required: true
default: () => ({})
},
},
data() {
@ -205,7 +205,7 @@ export default {
async getPreShare() {
try {
const res = await preShare(this.result.id);
const res = await preShare(this.multipleIds[0] || this.result?.id);
this.shareConfig = res;
this.form.cc_users = res.exists_users;
} catch (err) {
@ -216,7 +216,7 @@ export default {
async getNextNode() {
try {
const res = await getNextNode({
id: this.result.id
id: this.multipleIds[0] || this.result?.id
})
this.node = res.currentNode || {}
} catch(err) {
@ -229,7 +229,7 @@ export default {
const nodeIds = this.node?.nextNodes?.map(node => node.id);
this.form.next_node_id = nodeIds[0];
const res = await Promise.all(nodeIds.map(nodeId => getNextNodeUsers({
id: this.result.id,
id: this.multipleIds[0] || this.result?.id,
next_node_id: nodeId,
},false)));

@ -658,6 +658,8 @@ export default {
]
}
}
} else {
return {}
}
}
},

Loading…
Cancel
Save