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) { export function assign(flow_id, data) {
return request({ return request({

@ -15,6 +15,15 @@
storage storage
show-footer 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 <vxe-table
ref="table" ref="table"
stripe stripe
@ -26,7 +35,17 @@
:row-config="{ keyField: 'id' }" :row-config="{ keyField: 'id' }"
:custom-config="{ mode: 'popup' }" :custom-config="{ mode: 'popup' }"
:data="dealFlows" :data="dealFlows"
:checkbox-config="{
checkMethod: ({ row }) => {
return isValidDone
}
}"
> >
<vxe-column
type="checkbox"
width="50"
align="center"
></vxe-column>
<vxe-column <vxe-column
min-width="140" min-width="140"
header-align="center" header-align="center"
@ -85,7 +104,7 @@
" "
></vxe-column> ></vxe-column>
</vxe-table> </vxe-table>
<template v-if="device === 'desktop'"> <template>
<DesktopForm <DesktopForm
:device="device" :device="device"
ref="desktopForm" ref="desktopForm"
@ -103,54 +122,38 @@
:logs="config.logs" :logs="config.logs"
></DesktopForm> ></DesktopForm>
</template> </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> <template #footer>
<el-button <el-button
icon="el-icon-document-add" icon="el-icon-document-add"
type="info" type="info"
size="small" size="small"
@click="submit('only-submit')" @click="saveData('only-submit')"
>暂存不流转</el-button >暂存不流转</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 >保存并流转 <i class="el-icon-right"></i
></el-button> ></el-button>
</template> </template>
</vxe-modal> </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> </div>
</template> </template>
<script> <script>
import { PopupManager } from 'element-ui/lib/utils/popup' import { PopupManager } from 'element-ui/lib/utils/popup'
import { defaultModalSize } from '@/settings' 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 { validation, validationName } from "@/utils/validate";
import MobileForm from "@/views/flow/MobileForm.vue";
import DesktopForm from "@/views/flow/DesktopForm.vue"; import DesktopForm from "@/views/flow/DesktopForm.vue";
import assign from './assign.vue' import assign from './assign.vue'
import {deepCopy} from "@/utils"; import { deepCopy } from "@/utils";
export default { export default {
components: { components: {
DesktopForm, MobileForm,assign DesktopForm,assign
}, },
props: { props: {
isShow: { isShow: {
@ -176,7 +179,10 @@ export default {
flows: [], flows: [],
isShowAssign: false, isShowAssign: false,
result: {},
batchData: null,
isValidDone: false,
pickRowIds: []
} }
}, },
methods: { methods: {
@ -351,31 +357,61 @@ 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) { if (window.$_uploading) {
this.$message.warning("文件正在上传中") this.$message.warning("文件正在上传中")
return return
} }
let copyForm; let copyForm;
if (this.device === "desktop") { try {
try { await this.$refs['desktopForm'].validate()
await this.$refs['desktopForm'].validate() } catch (err) {
} catch (err) { console.warn(err)
console.warn(err) this.$message.warning('数据校验失败')
this.$message.warning('数据校验失败') return
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);
} }
copyForm = deepCopy(this.$refs["desktopForm"].form);
const uploadHandler = (form, fields) => { const uploadHandler = (form, fields) => {
let keys = Object.keys(form) let keys = Object.keys(form)
keys.forEach(key => { keys.forEach(key => {
@ -410,28 +446,25 @@ export default {
} }
copyForm["current_node_id"] = this.config.currentNode.id; copyForm["current_node_id"] = this.config.currentNode.id;
try { try {
let callback; let callback = () => {}
switch (type) { switch (type) {
case "only-submit": case "only-submit":
if (this.$route.query.flow_id) { copyForm["temporary_save"] = 1;
copyForm["temporary_save"] = 1;
}
callback = () => { callback = () => {
this.$emit('update:isShow', false) this.$emit('update:isShow', false)
this.$emit('refresh') this.$emit('refresh')
} }
break; break;
case "assign": case "assign":
if (this.$route.query.flow_id) { copyForm["temporary_save"] = 0;
copyForm["temporary_save"] = 0; callback = () => {
this.validFlow()
} }
callback = () => (this.isShowAssign = true);
break; break;
} }
const resArr = await Promise.all(this.dealFlows.map(flow => deal(flow.id, copyForm))) const resArr = await Promise.all(this.dealFlows.map(flow => deal(flow.id, copyForm)))
const { flow, is_last_handled_log } = resArr[0] const { flow, is_last_handled_log } = resArr[0]
this.result = flow;
if (!is_last_handled_log) { if (!is_last_handled_log) {
await this.$alert( await this.$alert(
"办理成功,其他会签办理完成后,由最后办理的成员流转到下一节点。", "办理成功,其他会签办理完成后,由最后办理的成员流转到下一节点。",
@ -445,11 +478,29 @@ export default {
this.$emit('refresh') this.$emit('refresh')
} }
} }
callback(); callback()
} catch (err) { } catch (err) {
console.error(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: { computed: {
device() { device() {
@ -473,6 +524,11 @@ export default {
}, },
isFirstNode() { isFirstNode() {
return this.config?.logs?.length === 0 || this.config?.currentNode?.category === 'start' 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: { watch: {
@ -483,6 +539,10 @@ export default {
if (this.dealFlows instanceof Array && this.dealFlows.length > 0) { if (this.dealFlows instanceof Array && this.dealFlows.length > 0) {
this.getConfig() this.getConfig()
} }
} else {
this.batchData = null
this.isValidDone = false
this.pickRowIds.length = 0
} }
} }
} }

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

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

Loading…
Cancel
Save