index.vue 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547
  1. <template>
  2. <div class="check-flow-index-bg">
  3. <el-tree v-loading="treeLoading"
  4. class="leftTree"
  5. ref="leftTree"
  6. :data="pageLeftTreeData"
  7. node-key="id"
  8. highlight-current
  9. default-expand-all
  10. :props="{children: 'children', label: 'name'}"
  11. @node-click="handleClickTreeNode" />
  12. <div v-if="currentBusinessCode"
  13. class="check-flow-page-right"
  14. v-loading="rightLoading">
  15. <div class="check-flow-page-title">
  16. <div class="check-flow-page-title-line" />
  17. {{ pageTitle }}
  18. </div>
  19. <div class="check-flow-page-save">
  20. <el-button type="primary"
  21. size="mini"
  22. @click="handleSave">
  23. 保存
  24. </el-button>
  25. <el-button size="mini"
  26. v-if="this.currentWorkFlowId"
  27. @click="handleDelete">
  28. 删除
  29. </el-button>
  30. </div>
  31. <div class="check-flow-page-content">
  32. <div ref="panel"
  33. class="check-flow-panel">
  34. <div class="check-flow-panel-title-bg"
  35. style="width: 320px;">
  36. <div style=" border: 1px solid #ccc;border-radius: 5px;width: 320px;">
  37. <div class="check-flow-panel-title-block">
  38. {{ currentBusinessTitle }}
  39. </div>
  40. <div style="padding:5px;">
  41. <el-checkbox-group v-model="checkList" @change="changed = true">
  42. <el-checkbox :label="0">申请人和审批人重复时,自动通过审批
  43. <el-tooltip placement="top">
  44. <div slot="content">①当申请人为A,审批流程为A - B - C时,审批流程变为B - C;<br />②当申请人为B,审批流程为 A - B - C时,审批流程变为A - C; </div>
  45. <i class="el-icon-info"
  46. style="color:#f5a623"></i>
  47. </el-tooltip>
  48. </el-checkbox>
  49. <el-checkbox :label="1">相邻两个审批人为同一人时,自动通过审批
  50. <el-tooltip placement="top">
  51. <div slot="content">当审批流程为A - A - B - C,选中后,审批流程变为 A - B - C。</div>
  52. <i class="el-icon-info"
  53. style="color:#f5a623"></i>
  54. </el-tooltip>
  55. </el-checkbox>
  56. </el-checkbox-group>
  57. </div>
  58. </div>
  59. <flow-Add :finalEnd="blocks.length === 0"
  60. :disabled="blocks.filter(itm=>typeof itm.type === 'number').length > 0"
  61. @handleAddCheckBranch="handleAddFirstBranch"
  62. @handleAddCheckPerson="handleAddFirstPerson" />
  63. </div>
  64. <check-flow ref="checkFlowBg"
  65. :blocks="blocks"
  66. :parentBranchIndex="0"
  67. @clickBlock="handleClickBlock" />
  68. </div>
  69. </div>
  70. </div>
  71. <div v-if="showSlide || showConditionSlide"
  72. class="check-flow-right-slide-block-bg" />
  73. <div class="check-flow-right-slide-block"
  74. :style="{right: showSlide?'0':'-400px'}">
  75. <div style=" overflow: auto;
  76. height: calc(100% - 120px);">
  77. <div class="check-flow-right-slide-block-title">
  78. <div class="check-flow-right-slide-block-title-text">
  79. <span class="check-flow-desc-label">描述:</span>
  80. <el-input class="check-flow-desc-input"
  81. v-model="slideDesc"
  82. @focus="showSlideDescError = false;"></el-input>
  83. <span v-if="showSlideDescError"
  84. class="check-flow-desc-error">"描述"为必填项</span>
  85. </div>
  86. </div>
  87. <div class="check-flow-right-slide-block-title">
  88. <div class="check-flow-right-slide-block-title-text">
  89. <span style="margin-left:10px">监听:</span>
  90. <el-select style="margin-left:7px"
  91. v-model="slideStepListenerId"
  92. placeholder="请选择"
  93. @change="listenerChange"
  94. clearable>
  95. <el-option v-for="(option, index) in availableListeners"
  96. :key="index"
  97. :value="option.id"
  98. :label="option.name"></el-option>
  99. </el-select>
  100. </div>
  101. </div>
  102. <div class="check-flow-right-slide-block-middle">
  103. <div class="check-flow-right-slide-block-middle-top">
  104. <el-radio v-model="slideWhichType"
  105. :label="0"
  106. @change="handleCheckPersonType">
  107. 指定成员
  108. </el-radio>
  109. <el-radio v-model="slideWhichType"
  110. :label="1"
  111. @change="handleCheckPersonType">
  112. 职务
  113. </el-radio>
  114. </div>
  115. <el-button type="primary"
  116. size="small"
  117. icon="el-icon-plus"
  118. @click="handleSlideAddOrEditPersonOrPost">
  119. {{ slideWhichType === 0?(slideSelected.length === 0?'添加成员':'修改成员'):(slideSelected.length === 0?'添加职务':'修改职务') }}
  120. </el-button>
  121. <div v-if="slideSelected.length > 0"
  122. class="check-flow-right-slide-block-middle-selected">
  123. <el-tag v-for="itm in slideSelected"
  124. :key="slideWhichType === 0 ? itm.staffId : itm.roleId"
  125. size="small"
  126. closable
  127. @close="handleSlideSelectedDelete(itm)">
  128. {{ slideWhichType === 0 ? itm.staffName : itm.roleName }}
  129. </el-tag>
  130. <el-button type="text"
  131. size="mini"
  132. @click="slideSelected = []">
  133. 清空
  134. </el-button>
  135. </div>
  136. </div>
  137. <div class="check-flow-right-slide-block-countersign">
  138. <el-radio-group v-model="slideCounterSign">
  139. <el-radio :label="0">普通节点</el-radio>
  140. <el-radio :label="1">多签节点</el-radio>
  141. </el-radio-group>
  142. </div>
  143. <div class="check-flow-right-slide-block-bottom"
  144. v-if="slideCounterSign === 1">
  145. <div class="check-flow-right-slide-block-bottom-title">
  146. 多人审批时采用的审批方式
  147. </div>
  148. <div class="check-flow-right-slide-block-bottom-option">
  149. <el-radio v-model="slideMultiType"
  150. :label="0">
  151. 会签(须所有审批人同意)
  152. </el-radio>
  153. <el-radio v-model="slideMultiType"
  154. :label="1">
  155. 或签(一名审批人同意或拒绝即可)
  156. </el-radio>
  157. </div>
  158. </div>
  159. <div class="check-flow-right-slide-block-bottom"
  160. v-else>
  161. <el-card class="box-card">
  162. <div slot="header"
  163. class="clearfix">
  164. <span>通用设置</span>
  165. </div>
  166. <h5>是否开启审批超时提醒</h5>
  167. <span style="padding-left: 20px;">
  168. <el-radio-group v-model="overdueFlag">
  169. <el-radio label="0">否</el-radio>
  170. <el-radio label="1">是</el-radio>
  171. </el-radio-group>
  172. </span>
  173. <h5>时间</h5>
  174. <el-row>
  175. <el-col :span="12">
  176. <el-input-number v-model="overdueTime"
  177. :min="0"
  178. :disabled="overdueFlag*1===0"
  179. :controls="false"
  180. :max="999"
  181. style="width:80%"></el-input-number>
  182. </el-col>
  183. <el-col :span="12">
  184. <el-select v-model="overdueTimeUnit"
  185. :disabled="overdueFlag*1===0"
  186. placeholder="请选择时间单位">
  187. <el-option label="小时"
  188. value="HOUR"></el-option>
  189. <el-option label="天"
  190. value="DAY"></el-option>
  191. </el-select>
  192. </el-col>
  193. </el-row>
  194. <p></p>
  195. <div class="check-flow-right-slide-block-bottom-title" v-if="isFinance">
  196. 是否开启部门内部审核 <span style="padding-left: 20px;">
  197. <el-switch active-value="1"
  198. inactive-value="0"
  199. v-model="deptAuditEnabled"></el-switch>
  200. </span>
  201. </div>
  202. </el-card>
  203. </div>
  204. </div>
  205. <div class="check-flow-right-slide-block-action">
  206. <el-button @click="handleCancelSlide">
  207. 取消
  208. </el-button>
  209. <el-button type="primary"
  210. @click="handleSlideSave">
  211. 保存
  212. </el-button>
  213. </div>
  214. </div>
  215. <div class="check-flow-right-slide-block"
  216. :style="{right: showConditionSlide?'0':'-400px'}">
  217. <div class="check-flow-right-slide-block-middle condition-block-middle">
  218. <el-button size="small"
  219. type="primary"
  220. @click="handleConditionAddButtonClick">新增条件</el-button>
  221. <el-select v-if="slideSelectedConditions.length > 1"
  222. v-model="slideBranchLogicOperator"
  223. placeholder="条件连接符">
  224. <el-option value="AND"
  225. label="并且"></el-option>
  226. <el-option value="OR"
  227. label="或"></el-option>
  228. </el-select>
  229. <div class="condition-block-middle-content">
  230. <div v-for="(condition, index) in slideSelectedConditions"
  231. :key="condition.id"
  232. class="condition-block-middle-content-block">
  233. <el-select v-model="condition.varName"
  234. @change="e => handleSlideConditionChange(e, condition)">
  235. <el-option v-for="(option, idx) in availableConditions"
  236. :key="idx"
  237. :value="option.varName"
  238. :label="option.name"></el-option>
  239. </el-select>
  240. <div class="condition-block-middle-content-value">
  241. <el-select v-model="condition.logicalSymbol"
  242. placeholder="逻辑符号">
  243. <el-option v-for="(option, idx) in condition.operators"
  244. :key="idx"
  245. :label="option.label"
  246. :value="option.value"></el-option>
  247. </el-select>
  248. <el-input v-if="condition.varType === 'value'"
  249. class="condition-content-input"
  250. v-model="condition.varValue"
  251. placeholder="请输入条件值"></el-input>
  252. <el-select v-else
  253. v-model="condition.varValue">
  254. <el-option v-for="(option, idx) in condition.options"
  255. :key="idx"
  256. :value="option.value"
  257. :label="option.label"></el-option>
  258. </el-select>
  259. </div>
  260. <el-button icon="el-icon-delete"
  261. class="condition-block-middle-content-delete"
  262. size="small"
  263. @click="handleConditionDelete(index)">删除该项</el-button>
  264. <div class="condition-block-middle-seperator"></div>
  265. </div>
  266. </div>
  267. </div>
  268. <div class="check-flow-right-slide-block-action">
  269. <el-button @click="handleCancelConditionSlide">
  270. 取消
  271. </el-button>
  272. <el-button type="primary"
  273. @click="handleConditionSlideSave">
  274. 保存
  275. </el-button>
  276. </div>
  277. </div>
  278. <el-dialog :title="slideWhichType === 0?'选择人员':'选择职务'"
  279. :visible.sync="dialogVisible"
  280. :close-on-click-modal="false">
  281. <div class="dialog-content">
  282. <div class="dialog-left">
  283. <div class="dialog-part-title">选择</div>
  284. <el-input class="dialog-left-search"
  285. placeholder="搜索"
  286. prefix-icon="el-icon-search"
  287. v-model="dialogTreeFilterText">
  288. </el-input>
  289. <el-tree class="dialog-left-tree"
  290. v-loading="dialogTreeLoading"
  291. :data="dialogTreeData"
  292. ref="dialogLeftTree"
  293. :filter-node-method="dialogTreeFilterMethod"
  294. @node-click="handleClickDialogTreeLeafNode" />
  295. </div>
  296. <div class="dialog-selected-zone">
  297. <div class="dialog-part-title">已选</div>
  298. <div v-for="item in dialogSelected"
  299. :key="slideWhichType === 0 ? item.staffId : item.roleId"
  300. class="dialog-selected-item">
  301. {{ slideWhichType === 0 ? item.staffName : item.roleName }}
  302. <el-button type="text"
  303. @click="handleDeleteDialogSelected(item)">删除</el-button>
  304. </div>
  305. </div>
  306. </div>
  307. <div slot="footer">
  308. <el-button @click="handleClickDialogCancel">取 消</el-button>
  309. <el-button type="primary"
  310. @click="handleDialogSelectedDone">确 定</el-button>
  311. </div>
  312. </el-dialog>
  313. </div>
  314. </template>
  315. <script>
  316. import checkFlow from './check-flow';
  317. import flowAdd from './flow-add';
  318. import { getTreeList } from '../../api/organization/tree';
  319. import {
  320. getBusinessListFromServer,
  321. queryPersonsUnderDept,
  322. queryRolesUnderDept,
  323. queryAllRolesInCompany,
  324. createWorkFlowToServer,
  325. getWorkFlowDefinitionFromServer,
  326. queryWorkFlowInfo,
  327. changeWorkFlowToServer,
  328. removeLatestWorkflow
  329. } from '../../api/check-flow';
  330. import getCheckListIdFromBusinessCode from './checkListId';
  331. import getListenerIdFromBusinessCode from './listenerId';
  332. import allAvailableConditions from './conditions';
  333. import allAvailableListeners from './stepListeners';
  334. import { getUuid } from '../../utils'
  335. import { cloneDeep } from 'lodash'
  336. export default {
  337. components: {
  338. checkFlow,
  339. flowAdd,
  340. },
  341. data () {
  342. return {
  343. isFinance: false,
  344. changed: false,
  345. editing: false, // 当前如果有审核流,则为true,属于修改审核流;否则为false,是新增审核流
  346. rightLoading: false,
  347. dialogTreeLoading: false,
  348. pageTitle: '申请单',
  349. showSlide: false, // 审核节点右侧弹出框
  350. showConditionSlide: false, // 条件右侧弹出框
  351. showSlideDescError: false,
  352. dialogVisible: false,
  353. pageLeftTreeData: [],
  354. treeLoading: false,
  355. blocks: [],
  356. blocksClone: [],
  357. currentWorkFlowId: '',
  358. currentBusinessCode: '',
  359. currentBusinessTitle: '',
  360. currentEditingBlock: {},
  361. currentEditingBranchBlockIndex: 0,
  362. slideDesc: '', // 右侧弹出框顶部的描述
  363. slideWhichType: 0, // 0是指定人员,1是指定职务
  364. slideCounterSign: 0, // 0是普通节点,1是多实例节点
  365. slideMultiType: 0, // 0是会签,1是或签
  366. slideSelectedConditions: [],
  367. slideBranchLogicOperator: '',
  368. dialogTreeFilterText: '',
  369. slideSelected: [], // 已选择的人或职务列表
  370. dialogTreeData: [], // 对话框里左侧树数据
  371. originalDialogTreeData: [], // 对话框里左侧树部门级的数据
  372. dialogSelected: [],
  373. allPersons: [],
  374. allRoles: [],
  375. slideStepListeners: [], // 右侧弹出框节点监听类
  376. slideStepListenerId: '',
  377. deptAuditEnabled: '0', // 是否开启部门内部审核
  378. overdueFlag: '0', // 是否开启超时提醒
  379. overdueTime: 0,
  380. overdueTimeUnit: 'HOUR',
  381. checkList: [],
  382. compId: localStorage.getItem('enterprise-front-companyId')
  383. };
  384. },
  385. watch: {
  386. dialogTreeFilterText (val) {
  387. this.$refs.dialogLeftTree.filter(val);
  388. }
  389. },
  390. computed: {
  391. availableConditions () {
  392. if (this.currentBusinessCode) {
  393. const ava = allAvailableConditions[this.currentBusinessCode];
  394. if (ava) {
  395. return ava;
  396. }
  397. return [];
  398. }
  399. return [];
  400. },
  401. availableListeners () {
  402. if (this.currentBusinessCode) {
  403. const ava = allAvailableListeners[this.currentBusinessCode];
  404. if (ava) {
  405. return ava;
  406. }
  407. return [];
  408. }
  409. return [];
  410. }
  411. },
  412. async created () {
  413. this.treeLoading = true;
  414. await this.getAllPersons();
  415. await this.getAllRoles();
  416. await this.getBusinessList();
  417. // await this.defaultChooseLeftTreeFirstLeaf();
  418. await this.getDialogDepartments();
  419. },
  420. methods: {
  421. listenerChange (value) {
  422. this.slideStepListeners = [];
  423. if (value && value != null && value.length > 0) {
  424. this.slideStepListeners.push({
  425. event: 'all',
  426. listenerId: value
  427. });
  428. }
  429. },
  430. /* 业务代码 */
  431. async getAllPersons () {
  432. this.rightLoading = true;
  433. const res = await queryPersonsUnderDept();
  434. this.allPersons = res.records;
  435. },
  436. async getAllRoles () {
  437. const res = await queryAllRolesInCompany({ compId: localStorage.getItem('enterprise-front-companyId') });
  438. this.allRoles = res[0].children;
  439. },
  440. async getDialogDepartments () {
  441. const res = await this.getCompanyDepartments();
  442. this.dialogTreeData = res;
  443. this.originalDialogTreeData = JSON.parse(JSON.stringify(res));
  444. },
  445. async getBusinessList () {
  446. this.pageLeftTreeData = await getBusinessListFromServer({ categoryCode: 'WORKFLOW' });
  447. this.treeLoading = false;
  448. console.log(this.pageLeftTreeData)
  449. this.pageTitle = this.pageLeftTreeData[0].children[0].name
  450. },
  451. async defaultChooseLeftTreeFirstLeaf () {
  452. // 默认选中第一个
  453. const first = this.deepFindFirst(this.pageLeftTreeData);
  454. if (first.id && this.$refs.leftTree) {
  455. this.$refs.leftTree.setCurrentKey(first.id)
  456. await this.treeClickMethod(first.code);
  457. }
  458. },
  459. async treeClickMethod (code) {
  460. this.blocks = []
  461. this.rightLoading = true;
  462. this.currentBusinessCode = code;
  463. this.isFinance = (code.indexOf('FINANCE') !== -1)
  464. const res = await getWorkFlowDefinitionFromServer({
  465. businessCode: code
  466. });
  467. if (res.length > 0) {
  468. const workflowDefinition = res.find(item => item.latest === 1); // 目前工作流定义取latest字段是1的
  469. this.currentWorkFlowId = workflowDefinition.id;
  470. const info = await queryWorkFlowInfo({
  471. workflowId: workflowDefinition.id
  472. })
  473. const branchSameNodeIds = [];
  474. this.convertStepsToBlocks(info.steps ? info.steps : [], this.blocks, branchSameNodeIds, 0, false, false);
  475. this.currentBusinessTitle = workflowDefinition.name || this.pageTitle;
  476. this.checkList = Array.from(new Set([workflowDefinition.creatorQuickAuditFlag * 1 ? 0 : '', workflowDefinition.skipAdjacentFlag * 1 ? 1 : '']))
  477. this.editing = true;
  478. } else {
  479. this.blocks = [];
  480. this.editing = false;
  481. this.currentBusinessTitle = '' || this.pageTitle;
  482. }
  483. this.blocksClone = cloneDeep(this.blocks)
  484. this.rightLoading = false;
  485. },
  486. async getCompanyDepartments () {
  487. if (!localStorage.getItem('enterprise-front-companyId')) {
  488. this.$message.error('没找到对应的公司ID');
  489. return;
  490. }
  491. const res = await getTreeList({
  492. compId: localStorage.getItem('enterprise-front-companyId')
  493. });
  494. return res[0].children;
  495. },
  496. async doSave () {
  497. const steps = [];
  498. this.convertBlocksToSteps(this.blocks, steps, false, [], 1);
  499. const params = {
  500. compId: this.compId,
  501. name: this.currentBusinessTitle,
  502. businessCode: this.currentBusinessCode,
  503. skipAdjacentFlag: this.checkList.indexOf(1) > -1 ? '1' : '0', //是否跳过相邻步骤
  504. creatorQuickAuditFlag: this.checkList.indexOf(0) > -1 ? '1' : '0', //是否初创人与审核人相同时跳过
  505. checklistId: getCheckListIdFromBusinessCode(this.currentBusinessCode),
  506. listeners: [{
  507. event: 'all',
  508. listenerId: getListenerIdFromBusinessCode(this.currentBusinessCode)
  509. }],
  510. steps
  511. };
  512. if (this.editing) {
  513. await changeWorkFlowToServer({ ...params, id: this.currentWorkFlowId });
  514. } else {
  515. await createWorkFlowToServer(params);
  516. }
  517. this.editing = true;
  518. this.treeClickMethod(this.currentBusinessCode);
  519. this.$message({
  520. type: 'success',
  521. message: !this.editing ? '创建工作流成功' : '修改工作流成功',
  522. showClose: true,
  523. });
  524. this.changed = false
  525. },
  526. /* 事件处理函数 */
  527. // 点击页面左侧树节点
  528. handleClickTreeNode (data, node) { // 先获取工作流定义,再拿定义的id去取工作流详情
  529. if (node.isLeaf && this.currentBusinessCode !== data.code) {
  530. if(this.blocksClone.length !== this.blocks.length){
  531. this.changed = true
  532. }
  533. if(this.changed){
  534. this.$confirm('审核流的修改未保存,是否切换?','提示',{
  535. confirmButtonText: '确认',
  536. cancelButtonText: '取消',
  537. type: 'warning'
  538. }).then(() => {
  539. this.treeClickMethod(data.code);
  540. this.pageTitle = data.name
  541. this.changed = false
  542. })
  543. } else {
  544. this.treeClickMethod(data.code);
  545. this.pageTitle = data.name
  546. this.changed = false
  547. }
  548. }
  549. },
  550. // 添加第一个审核人节点
  551. handleAddFirstPerson () {
  552. const element = {
  553. id: getUuid(),
  554. type: 0,
  555. desc: '',
  556. deptAuditEnabled: 0,
  557. overdueFlag: 0,
  558. overdueTime: 0,
  559. overdueTimeUnit: 'HOUR',
  560. stepType: 'NORMAL',
  561. content: '',
  562. onBranch: false,
  563. };
  564. this.blocks.unshift(element);
  565. },
  566. // 添加第一个分支节点
  567. handleAddFirstBranch () {
  568. const element = {
  569. id: getUuid(),
  570. type: 1,
  571. onBranch: false,
  572. subBlocks: [
  573. {
  574. id: getUuid(),
  575. showDeleteBtn: false,
  576. blocks: [
  577. {
  578. id: getUuid(),
  579. type: 2,
  580. desc: '',
  581. deptAuditEnabled: 0,
  582. overdueFlag: 0,
  583. overdueTime: 0,
  584. overdueTimeUnit: 'HOUR',
  585. content: '',
  586. onBranch: true,
  587. },
  588. ],
  589. },
  590. {
  591. id: getUuid(),
  592. showDeleteBtn: false,
  593. blocks: [
  594. {
  595. id: getUuid(),
  596. type: 2,
  597. desc: '',
  598. deptAuditEnabled: 0,
  599. overdueFlag: 0,
  600. overdueTime: 0,
  601. overdueTimeUnit: 'HOUR',
  602. content: '',
  603. onBranch: true,
  604. },
  605. ],
  606. },
  607. ],
  608. };
  609. this.blocks.unshift(element);
  610. },
  611. // 点击审核流节点
  612. handleClickBlock (block, index) {
  613. if (block.type === 0) {
  614. this.showSlide = true;
  615. this.currentEditingBlock = block;
  616. // 以下都是赋初值
  617. this.slideDesc = block.desc;
  618. this.slideStepListeners = block.listeners;
  619. this.deptAuditEnabled = block.deptAuditEnabled + '';
  620. this.overdueFlag = block.overdueFlag ? block.overdueFlag * 1 + '' : '0'
  621. this.overdueTime = block.overdueTime ? block.overdueTime + '' : null
  622. this.overdueTimeUnit = (block.overdueTimeUnit) || null
  623. if (this.slideStepListeners && this.slideStepListeners.length > 0) {
  624. this.slideStepListenerId = this.slideStepListeners[0].listenerId;
  625. }
  626. this.slideCounterSign = block.stepType === 'NORMAL' ? 0 : 1;
  627. if (block.countersignType) {
  628. this.slideMultiType = block.countersignType === 'ALL' ? 0 : 1;
  629. } else {
  630. this.slideMultiType = 0;
  631. }
  632. // this.deptAuditEnabled = block.deptAuditEnabled + '';
  633. // this.overdueFlag = block.overdueFlag * 1 + ''
  634. // this.overdueTime = block.overdueTime + ''
  635. // this.overdueTimeUnit = (block.overdueTimeUnit) || ''
  636. // 审核流节点的指定人或者职务
  637. if (block.auditUsers) {
  638. // this.deptAuditEnabled = block.deptAuditEnabled + '';
  639. // this.overdueFlag = block.overdueFlag * 1 + ''
  640. // this.overdueTime = block.overdueTime + ''
  641. // this.overdueTimeUnit = (block.overdueTimeUnit) || ''
  642. this.slideWhichType = 0;
  643. const slideSelectedIds = block.auditUsers.split(',')
  644. slideSelectedIds.forEach((item) => {
  645. const slideItem = this.allPersons.find(itm => itm.staffId === item);
  646. if (slideItem) {
  647. this.slideSelected.push(slideItem)
  648. }
  649. })
  650. } else if (block.auditRoles) {
  651. this.slideWhichType = 1;
  652. const slideSelectedIds = block.auditRoles.split(',')
  653. slideSelectedIds.forEach((item) => {
  654. const slideItem = this.allRoles.find(itm => itm.roleId === item);
  655. if (slideItem) {
  656. this.slideSelected.push(slideItem)
  657. }
  658. })
  659. }
  660. } else if (block.type === 2) {
  661. this.showConditionSlide = true;
  662. this.currentEditingBlock = block;
  663. this.currentEditingBranchBlockIndex = index;
  664. this.slideSelectedConditions = block.branchConditions || [];
  665. this.slideBranchLogicOperator = block.branchLogicOperator;
  666. }
  667. },
  668. handleCancelConditionSlide () {
  669. this.showConditionSlide = false;
  670. this.cleanSlideConditionContent();
  671. },
  672. handleSlideConditionChange (value, condition) {
  673. const selectedCondition = this.availableConditions.find(itm => itm.varName === value);
  674. condition.varValue = '';
  675. condition.logicalSymbol = '';
  676. condition.operators = selectedCondition.operators;
  677. condition.varType = selectedCondition.varType;
  678. condition.options = selectedCondition.options;
  679. condition.name = selectedCondition.name;
  680. },
  681. handleConditionAddButtonClick () {
  682. this.$set(this.slideSelectedConditions, this.slideSelectedConditions.length, {
  683. id: getUuid(),
  684. name: '',
  685. varName: '',
  686. varValue: '',
  687. operators: [],
  688. varType: 'enum',
  689. options: [],
  690. logicalSymbol: ''
  691. })
  692. },
  693. handleConditionDelete (index) {
  694. this.slideSelectedConditions.splice(index, 1);
  695. },
  696. // 侧弹出框点击取消
  697. handleCancelSlide () {
  698. this.showSlide = false;
  699. this.cleanSlideContent();
  700. },
  701. // 点击侧弹出框删除已选
  702. handleSlideSelectedDelete (selectedItem) {
  703. if (this.slideWhichType === 0) {
  704. const idx = this.slideSelected.findIndex(item => item.staffId === selectedItem.staffId);
  705. this.slideSelected.splice(idx, 1);
  706. } else {
  707. const idx = this.slideSelected.findIndex(item => item.roleId === selectedItem.roleId);
  708. this.slideSelected.splice(idx, 1);
  709. }
  710. },
  711. // 点击对话框保存按钮
  712. handleDialogSelectedDone () {
  713. this.slideSelected = JSON.parse(JSON.stringify(this.dialogSelected));
  714. this.dialogVisible = false;
  715. this.dialogTreeFilterText = '';
  716. },
  717. // 对话框点击取消
  718. handleClickDialogCancel () {
  719. this.dialogVisible = false;
  720. this.dialogTreeFilterText = '';
  721. },
  722. // 转换指定人员或者职务
  723. handleCheckPersonType () {
  724. this.slideSelected = [];
  725. this.dialogTreeData = JSON.parse(JSON.stringify(this.originalDialogTreeData));
  726. },
  727. // 对话框搜索框过滤方法
  728. dialogTreeFilterMethod (value, data) {
  729. if (!value) return true;
  730. return data.label.indexOf(value) !== -1
  731. },
  732. // 点击对话框叶子节点
  733. async handleClickDialogTreeLeafNode (data) {
  734. if (this.slideWhichType === 0) { // 指定成员
  735. if (!data.children) { // 这个是选择某个人或职务
  736. if (!this.dialogSelected.some(item => item.staffId === data.staffId)) {
  737. this.dialogSelected.push(data);
  738. }
  739. } else if (data.children.length === 0) { // 这是部门最后一层
  740. this.dialogTreeLoading = true;
  741. const res = await queryPersonsUnderDept({ deptId: data.id });
  742. this.dialogTreeLoading = false;
  743. const children = res.records.map((item) => {
  744. return {
  745. ...item,
  746. label: item.staffName,
  747. }
  748. })
  749. data.children = children;
  750. }
  751. } else { // 选择职务
  752. if (!data.children) { // 这个是选择某个人或职务
  753. if (!this.dialogSelected.some(item => item.roleId === data.roleId)) {
  754. this.dialogSelected.push(data);
  755. }
  756. } else if (data.children.length === 0) { // 这是部门最后一层
  757. this.dialogTreeLoading = true;
  758. const res = await queryRolesUnderDept({ deptId: data.id });
  759. this.dialogTreeLoading = false;
  760. const children = res.records.map((item) => {
  761. return {
  762. ...item,
  763. label: item.roleName,
  764. }
  765. })
  766. data.children = children;
  767. }
  768. }
  769. },
  770. // 对话框点击删除已选
  771. handleDeleteDialogSelected (selectedItem) {
  772. if (this.slideWhichType === 0) {
  773. const idx = this.dialogSelected.findIndex(item => item.staffId === selectedItem.staffId);
  774. this.dialogSelected.splice(idx, 1);
  775. } else {
  776. const idx = this.dialogSelected.findIndex(item => item.roleId === selectedItem.roleId);
  777. this.dialogSelected.splice(idx, 1);
  778. }
  779. },
  780. // 侧审核节点弹出框点击保存
  781. handleSlideSave () {
  782. this.changed = true
  783. if (!this.slideDesc) {
  784. this.showSlideDescError = true;
  785. return;
  786. }
  787. this.currentEditingBlock.desc = this.slideDesc;
  788. this.currentEditingBlock.listeners = this.slideStepListeners;
  789. this.currentEditingBlock.stepType = this.slideCounterSign === 0 ? 'NORMAL' : 'COUNTERSIGN';
  790. if (this.slideCounterSign === 1) {
  791. if (this.slideMultiType === 0) {
  792. this.currentEditingBlock.countersignType = 'ALL';
  793. } else {
  794. this.currentEditingBlock.countersignType = 'ONE';
  795. }
  796. this.currentEditingBlock.deptAuditEnabled = 0;
  797. this.currentEditingBlock.overdueFlag = 0
  798. this.currentEditingBlock.overdueTime = 0
  799. this.currentEditingBlock.overdueTimeUnit = 'HOUR'
  800. } else {
  801. this.currentEditingBlock.deptAuditEnabled = this.deptAuditEnabled;
  802. this.currentEditingBlock.overdueFlag = this.overdueFlag || '0'
  803. this.currentEditingBlock.overdueTime = this.overdueTime || null
  804. this.currentEditingBlock.overdueTimeUnit = this.overdueTimeUnit || null
  805. }
  806. if (this.slideWhichType === 0) {
  807. const audits = this.slideSelected.map(item => item.staffId);
  808. const content = this.slideSelected.map(item => item.staffName).join()
  809. this.currentEditingBlock.auditUsers = audits.join();
  810. this.currentEditingBlock.auditRoles = null;
  811. this.currentEditingBlock.content = content;
  812. } else {
  813. const audits = this.slideSelected.map(item => item.roleId);
  814. const content = this.slideSelected.map(item => item.roleName).join()
  815. this.currentEditingBlock.auditRoles = audits.join();
  816. this.currentEditingBlock.auditUsers = null;
  817. this.currentEditingBlock.content = content;
  818. }
  819. this.showSlide = false;
  820. this.cleanSlideContent();
  821. },
  822. handleConditionSlideSave () {
  823. if (this.slideSelectedConditions.length > 1 && !this.slideBranchLogicOperator) {
  824. this.$message({
  825. message: '条件多于两个时,条件连接符不能为空',
  826. showClose: true,
  827. type: 'error'
  828. })
  829. return;
  830. }
  831. this.currentEditingBlock.stepType = 'CONDITION';
  832. const branchConditions = [];
  833. let branchContent = '';
  834. for (let index = 0; index < this.slideSelectedConditions.length; index++) {
  835. const item = this.slideSelectedConditions[index];
  836. if (item.varName && item.varValue && item.logicalSymbol) {
  837. branchConditions.push({
  838. name: item.name,
  839. varName: item.varName,
  840. varValue: item.varValue,
  841. logicalSymbol: item.logicalSymbol,
  842. options: item.options,
  843. operators: item.operators
  844. })
  845. } else if (!item.varName) {
  846. this.$message({
  847. message: '条件名不能为空',
  848. showClose: true,
  849. type: 'error'
  850. })
  851. return;
  852. } else if (!item.varValue) {
  853. this.$message({
  854. message: '条件值不能为空',
  855. showClose: true,
  856. type: 'error'
  857. })
  858. return;
  859. } else {
  860. this.$message({
  861. message: '条件逻辑符不能为空',
  862. showClose: true,
  863. type: 'error'
  864. })
  865. return;
  866. }
  867. const condition = this.availableConditions.find(itm => itm.varName === item.varName);
  868. const type = condition.varType;
  869. if (type === 'enum') {
  870. const operator = condition.operators.find(itm => itm.value === item.logicalSymbol).label;
  871. const value = condition.options.find(itm => itm.value === item.varValue).label;
  872. branchContent += (index + 1) + '. ' + condition.name + ' ' + operator + ' ' + value;
  873. if (condition.unit) {
  874. branchContent += ' ' + condition.unit;
  875. }
  876. } else {
  877. const operator = condition.operators.find(itm => itm.value === item.logicalSymbol).label;
  878. const value = item.varValue;
  879. branchContent += (index + 1) + '. ' + condition.name + ' ' + operator + ' ' + value;
  880. if (condition.unit) {
  881. branchContent += ' ' + condition.unit;
  882. }
  883. }
  884. if (index < this.slideSelectedConditions.length - 1) {
  885. branchContent += '<br />'
  886. }
  887. }
  888. if (branchConditions.length > 1) {
  889. this.currentEditingBlock.desc = '条件' + (this.currentEditingBranchBlockIndex + 1) + ' 条件连接符:' + (this.slideBranchLogicOperator === 'AND' ? '并且' : '或');
  890. } else {
  891. this.currentEditingBlock.desc = '条件' + (this.currentEditingBranchBlockIndex + 1);
  892. }
  893. this.currentEditingBlock.branchConditions = branchConditions;
  894. this.currentEditingBlock.content = branchContent;
  895. this.currentEditingBlock.branchLogicOperator = this.slideBranchLogicOperator;
  896. this.showConditionSlide = false;
  897. this.cleanSlideConditionContent();
  898. },
  899. /**
  900. * 删除审核流
  901. * */
  902. async handleDelete () {
  903. // /workflow/api/removeLatestWorkflow
  904. await removeLatestWorkflow({ id: this.currentWorkFlowId }).then(() => {
  905. this.treeClickMethod(this.currentBusinessCode)
  906. this.$message({
  907. message: '删除工作流成功~',
  908. type: 'success'
  909. })
  910. window.location.reload()
  911. })
  912. },
  913. // 创建或修改审核流
  914. handleSave () {
  915. if (this.deepFindInvalidNode(this.blocks)) {
  916. this.rightLoading = true;
  917. this.doSave()
  918. } else {
  919. this.$message({
  920. type: 'error',
  921. message: '节点的描述和审核人(或审核职务)不能为空',
  922. showClose: true
  923. })
  924. }
  925. },
  926. // 弹出对话框
  927. async handleSlideAddOrEditPersonOrPost () {
  928. this.dialogSelected = JSON.parse(JSON.stringify(this.slideSelected));
  929. this.dialogVisible = true;
  930. },
  931. /* helper 函数 */
  932. cleanSlideContent () {
  933. this.slideSelected = [];
  934. this.slideWhichType = 0;
  935. this.slideCounterSign = 0;
  936. this.slideMultiType = 0;
  937. this.deptAuditEnabled = '0';
  938. this.overdueFlag = '0'
  939. this.overdueTime = '0'
  940. this.overdueTimeUnit = "HOUR"
  941. this.showSlideDescError = false;
  942. this.slideDesc = '';
  943. this.slideStepListeners = [];
  944. this.slideStepListenerId = '';
  945. },
  946. cleanSlideConditionContent () {
  947. this.slideBranchLogicOperator = '';
  948. },
  949. convertAudit (step) {
  950. let content = ''
  951. if (step.auditUsers) {
  952. const auditIds = step.auditUsers.split(',');
  953. const auditNames = [];
  954. auditIds.forEach((item) => {
  955. const audit = this.allPersons.find(itm => itm.staffId === item);
  956. // 有可能审核流里保存的人,已经被删除了,也就是说这个人已经从公司所有的人名单里删除了,下面职务亦然
  957. if (audit) {
  958. auditNames.push(audit.staffName);
  959. }
  960. })
  961. content = auditNames.join();
  962. } else if (step.auditRoles) {
  963. const auditIds = step.auditRoles.split(',');
  964. const auditNames = [];
  965. auditIds.forEach((item) => {
  966. const audit = this.allRoles.find(itm => itm.roleId === item);
  967. if (audit) {
  968. auditNames.push(audit.roleName);
  969. }
  970. })
  971. content = auditNames.join();
  972. }
  973. return content;
  974. },
  975. convertStepsToBlocks (steps, blocks, branchSameNodeIds, fromIndex, onBranch, shouldAddEndPoint) {
  976. let index = fromIndex;
  977. let whichBranch = 0;
  978. let subBlocks = [];
  979. let _shouldAddEndPoint = shouldAddEndPoint;
  980. let obj = {}; // 临时数据
  981. while (index < steps.length) {
  982. const item = steps[index];
  983. switch (item.stepType) {
  984. case 'NORMAL':
  985. if (item.branchNodeLocation !== 'END') { // 普通节点直接加上
  986. blocks.push({
  987. ...item,
  988. type: 0,
  989. content: this.convertAudit(item),
  990. onBranch,
  991. })
  992. } else { // END节点,需要在合适时机给加到主分支节点下面
  993. let endPoint = '';
  994. // END节点
  995. if (branchSameNodeIds.every(itm => itm !== item.branchSameNodeId)) {
  996. branchSameNodeIds.push(item.branchSameNodeId);
  997. }
  998. if ((item.auditUsers || item.auditRoles) && _shouldAddEndPoint) {
  999. endPoint = {
  1000. ...item,
  1001. type: 0,
  1002. content: this.convertAudit(item),
  1003. }
  1004. }
  1005. return {
  1006. index,
  1007. endPoint
  1008. };
  1009. }
  1010. break;
  1011. case 'COUNTERSIGN':
  1012. blocks.push({
  1013. ...item,
  1014. type: 0,
  1015. content: this.convertAudit(item),
  1016. onBranch,
  1017. })
  1018. break;
  1019. case 'CONDITION':
  1020. if (branchSameNodeIds.every(itm => itm !== item.branchSameNodeId)) { // 新的条件主节点
  1021. // branchConditions
  1022. const res = this.convertConditions(item.branchConditions);
  1023. const branchConditions = res.branchConditions;
  1024. const branchContent = res.branchContent;
  1025. const conditionPoint = {
  1026. id: item.id,
  1027. type: 2,
  1028. desc: '条件1 条件连接符:' + (item.branchLogicOperator === 'AND' ? '并且' : '或'),
  1029. content: branchContent,
  1030. branchConditions,
  1031. branchLogicOperator: item.branchLogicOperator,
  1032. onBranch: true
  1033. }
  1034. subBlocks = [{
  1035. blocks: [conditionPoint],
  1036. id: getUuid(),
  1037. showDeleteBtn: false
  1038. }];
  1039. if (item.auditUsers || item.auditRoles) { // 这是个placeholder和实际节点的合并点,需要把它拆开
  1040. let stepType;
  1041. if (item.countersignType) {
  1042. stepType = 'COUNTERSIGN'
  1043. } else {
  1044. stepType = 'NORMAL';
  1045. }
  1046. const beginPoint = {
  1047. ...item,
  1048. stepType,
  1049. type: 0,
  1050. content: this.convertAudit(item)
  1051. }
  1052. blocks.push(beginPoint);
  1053. }
  1054. branchSameNodeIds.push(item.branchSameNodeId);
  1055. whichBranch = 0;
  1056. blocks.push({
  1057. id: getUuid(),
  1058. type: 1,
  1059. onBranch,
  1060. subBlocks,
  1061. })
  1062. _shouldAddEndPoint = true;
  1063. } else { // 新的条件子节点
  1064. // branchConditions
  1065. const res = this.convertConditions(item.branchConditions);
  1066. const branchConditions = res.branchConditions;
  1067. const branchContent = res.branchContent;
  1068. const conditionPoint = {
  1069. id: getUuid(),
  1070. type: 2,
  1071. desc: '条件' + (subBlocks.length + 1) + ' 条件连接符:' + (item.branchLogicOperator === 'AND' ? '并且' : '或'),
  1072. content: branchContent,
  1073. branchConditions,
  1074. branchLogicOperator: item.branchLogicOperator,
  1075. onBranch: true
  1076. }
  1077. subBlocks.push({
  1078. blocks: [conditionPoint],
  1079. id: getUuid(),
  1080. showDeleteBtn: false
  1081. });
  1082. whichBranch += 1;
  1083. _shouldAddEndPoint = false;
  1084. }
  1085. obj = this.convertStepsToBlocks(steps, subBlocks[whichBranch].blocks, branchSameNodeIds, index + 1, true, _shouldAddEndPoint); // 继续深入遍历
  1086. index = obj.index;
  1087. if (obj.endPoint) {
  1088. blocks.push(obj.endPoint);
  1089. }
  1090. break;
  1091. default:
  1092. break;
  1093. }
  1094. index++;
  1095. }
  1096. },
  1097. convertConditions (conditions) {
  1098. let branchContent = '';
  1099. const branchConditions = [];
  1100. for (let index = 0; index < conditions.length; index++) {
  1101. const element = conditions[index];
  1102. const condition = this.availableConditions.find(itm => itm.varName === element.varName);
  1103. const type = condition.varType;
  1104. if (type === 'enum') {
  1105. console.log(condition.options,condition.options.find(itm => itm.value === element.varValue))
  1106. const operator = condition.operators.find(itm => itm.value === element.logicalSymbol).label;
  1107. const value = condition.options.find(itm => itm.value === element.varValue).label;
  1108. branchContent += (index + 1) + '. ' + condition.name + ' ' + operator + ' ' + value;
  1109. if (condition.unit) {
  1110. branchContent += ' ' + condition.unit;
  1111. }
  1112. } else {
  1113. const operator = condition.operators.find(itm => itm.value === element.logicalSymbol).label;
  1114. const value = element.varValue;
  1115. branchContent += (index + 1) + '. ' + condition.name + ' ' + operator + ' ' + value;
  1116. if (condition.unit) {
  1117. branchContent += ' ' + condition.unit;
  1118. }
  1119. }
  1120. if (index < conditions.length - 1) {
  1121. branchContent += '<br />';
  1122. }
  1123. branchConditions.push({
  1124. varName: element.varName,
  1125. varValue: element.varValue,
  1126. logicalSymbol: element.logicalSymbol,
  1127. name: condition.name,
  1128. operators: condition.operators,
  1129. varType: condition.varType,
  1130. options: condition.options,
  1131. });
  1132. }
  1133. return {
  1134. branchContent,
  1135. branchConditions
  1136. }
  1137. },
  1138. deepFindFirst (list) {
  1139. if (Array.isArray(list) && list.length > 0) {
  1140. const item = list[0];
  1141. if (Array.isArray(item.children) && item.children.length > 0) {
  1142. return this.deepFindFirst(item.children);
  1143. }
  1144. return item;
  1145. }
  1146. return '';
  1147. },
  1148. deepFindInvalidNode (blocks) {
  1149. for (let index = 0; index < blocks.length; index++) {
  1150. const itm = blocks[index];
  1151. if (itm.type === 0) {
  1152. if (!itm.desc || !itm.stepType || !(itm.auditUsers || itm.auditRoles)) {
  1153. return false;
  1154. }
  1155. } else if (itm.type === 1) {
  1156. for (let idx = 0; idx < itm.subBlocks; idx++) {
  1157. const element = itm.subBlocks[idx];
  1158. const res = this.deepFindInvalidNode(element.blocks);
  1159. if (!res) {
  1160. return false;
  1161. }
  1162. }
  1163. } else {
  1164. if (!itm.desc || !itm.stepType) {
  1165. return false;
  1166. }
  1167. }
  1168. }
  1169. return true;
  1170. },
  1171. makeEnd (nodeIds, index, blocks, level) {
  1172. // 取到end节点的beginNodeId,并把开始和end节点都加入全局nodeIds数组中
  1173. let branchBeginNodeId = 0;
  1174. while (nodeIds.indexOf(branchBeginNodeId) !== -1) {
  1175. branchBeginNodeId += 1;
  1176. }
  1177. const branchEndNodeId = branchBeginNodeId + 1;
  1178. nodeIds.push(branchBeginNodeId);
  1179. nodeIds.push(branchEndNodeId);
  1180. // 取end节点
  1181. if (index < blocks.length - 1) { // 当前非最后一个
  1182. let nextIndex = index + 1;
  1183. const temp = blocks[nextIndex];
  1184. if (temp.type === 0) { // end节点是一个实际节点
  1185. nodeIds.push(nextIndex + '_index_' + level);
  1186. return {
  1187. end: {
  1188. desc: temp.desc,
  1189. stepType: temp.stepType,
  1190. auditUsers: temp.auditUsers,
  1191. auditRoles: temp.auditRoles,
  1192. branchNodeLocation: 'END',
  1193. branchSameNodeId: branchEndNodeId + '',
  1194. countersignType: temp.countersignType,
  1195. listeners: temp.listeners
  1196. },
  1197. beginNodeId: branchBeginNodeId
  1198. }
  1199. }
  1200. }
  1201. return {
  1202. end: {
  1203. desc: '_PLACEHOLDER_',
  1204. stepType: 'NORMAL',
  1205. branchSameNodeId: branchEndNodeId + '',
  1206. branchNodeLocation: 'END'
  1207. },
  1208. beginNodeId: branchBeginNodeId
  1209. }
  1210. },
  1211. convertBlocksToSteps (blocks, res, onBranch, nodeIds, level, endPoint, beginPoint, beginNodeId) {
  1212. for (let index = 0; index < blocks.length; index++) {
  1213. const element = blocks[index];
  1214. if (element.type === 0) { // 实际节点
  1215. if (element.branchSameNodeId && element.branchSameNodeId != null && element.branchSameNodeId.length > 0) {
  1216. continue;
  1217. }
  1218. if (nodeIds.indexOf(index + '_index_' + level) != -1) {
  1219. continue;
  1220. }
  1221. if (index < blocks.length - 1 && blocks[index + 1].type === 1) {
  1222. continue;
  1223. }
  1224. const item = {};
  1225. item.desc = element.desc;
  1226. item.deptAuditEnabled = element.deptAuditEnabled;
  1227. item.overdueFlag = element.overdueFlag || '0'
  1228. item.overdueTime = element.overdueTime ? element.overdueTime + '' : null
  1229. item.overdueTimeUnit = element.overdueTimeUnit || null
  1230. item.stepType = element.stepType;
  1231. if (element.countersignType) {
  1232. item.countersignType = element.countersignType;
  1233. }
  1234. if (element.auditUsers) {
  1235. item.auditUsers = element.auditUsers;
  1236. } else if (element.auditRoles) {
  1237. item.auditRoles = element.auditRoles;
  1238. }
  1239. item.listeners = element.listeners;
  1240. res.push(item);
  1241. } else if (element.type === 1) {
  1242. // 分支节点:取当前主分支下一个点(如果有)为branch end节点
  1243. const result = this.makeEnd(nodeIds, index, blocks, level);
  1244. const end = result.end;
  1245. const beginNodeId = result.beginNodeId;
  1246. // 取当前主分支上面的这个节点(如果有)为各个分支的branch begin 节点,并删除这个主分支上面的这个节点
  1247. let begin;
  1248. if (index > 0) {
  1249. const last = blocks[index - 1];
  1250. if (last.type === 0) {
  1251. begin = last;
  1252. }
  1253. }
  1254. level++;
  1255. // 遍历子节点
  1256. for (let idx = 0; idx < element.subBlocks.length; idx++) {
  1257. const item = element.subBlocks[idx];
  1258. this.convertBlocksToSteps(item.blocks, res, true, nodeIds, level, end, begin, beginNodeId);
  1259. }
  1260. level--;
  1261. } else { // 条件框节点,需要合二为一(beginPoint是一,条件框节点是二,合二为一)
  1262. const item = {};
  1263. item.stepType = 'CONDITION';
  1264. item.branchNodeLocation = 'BEGIN';
  1265. item.branchSameNodeId = beginNodeId + '';
  1266. const branchConditions = [];
  1267. if (element.branchConditions && element.branchConditions.length > 0) {
  1268. for (let index = 0; index < element.branchConditions.length; index++) {
  1269. const item = element.branchConditions[index];
  1270. branchConditions.push({
  1271. varName: item.varName,
  1272. varValue: item.varValue,
  1273. name: item.name,
  1274. logicalSymbol: item.logicalSymbol
  1275. })
  1276. }
  1277. }
  1278. item.branchConditions = branchConditions;
  1279. item.branchLogicOperator = element.branchLogicOperator;
  1280. // 如果上层有beginPoint,需要把原来convertStepsToBlocks时拆开的点合起来,这个beginPoint
  1281. if (beginPoint) {
  1282. res.push({
  1283. ...beginPoint,
  1284. ...item
  1285. });
  1286. } else {
  1287. res.push({
  1288. ...item,
  1289. desc: '_PLACEHOLDER_'
  1290. });
  1291. }
  1292. }
  1293. if (index === blocks.length - 1 && onBranch) {
  1294. res.push(endPoint);
  1295. }
  1296. }
  1297. },
  1298. },
  1299. };
  1300. </script>
  1301. <style lang="scss" scoped>
  1302. .check-flow-index-bg {
  1303. display: flex;
  1304. height: calc(100vh - 70px);
  1305. }
  1306. .leftTree {
  1307. width: 260px;
  1308. padding-top: 20px;
  1309. border-right: 1px solid #ccc;
  1310. overflow: auto;
  1311. }
  1312. .check-flow-page-title {
  1313. font-size: 16px;
  1314. color: #333333;
  1315. font-weight: bold;
  1316. display: flex;
  1317. align-items: center;
  1318. }
  1319. .check-flow-page-title-line {
  1320. width: 4px;
  1321. background-color: #1d6ced;
  1322. height: 16px;
  1323. margin-right: 8px;
  1324. }
  1325. .check-flow-page-right {
  1326. padding: 20px 20px;
  1327. }
  1328. .check-flow-page-save {
  1329. width: 900px;
  1330. height: 48px;
  1331. background-color: #eee;
  1332. margin-top: 20px;
  1333. box-sizing: border-box;
  1334. display: flex;
  1335. align-items: center;
  1336. .el-button {
  1337. margin-left: 9px;
  1338. width: 70px;
  1339. }
  1340. }
  1341. .check-flow-page-content {
  1342. width: 900px;
  1343. overflow: auto;
  1344. margin-top: 16px;
  1345. height: calc(100% - 124px);
  1346. display: flex;
  1347. }
  1348. .check-flow-panel {
  1349. display: flex;
  1350. flex-direction: column;
  1351. align-items: center;
  1352. padding: 0 32px 32px;
  1353. flex: 1 0 auto;
  1354. }
  1355. .check-flow-panel-title-bg {
  1356. width: 220px;
  1357. display: flex;
  1358. flex-direction: column;
  1359. }
  1360. .check-flow-panel-title-block {
  1361. height: 22px;
  1362. line-height: 22px;
  1363. font-size: 12px;
  1364. color: #fff;
  1365. width: 100%;
  1366. border-radius: 5px;
  1367. padding-left: 8px;
  1368. background-color: #1d6ced;
  1369. }
  1370. .check-flow-right-slide-block {
  1371. transition: right ease-out 0.3s;
  1372. position: absolute;
  1373. top: 0;
  1374. z-index: 2;
  1375. right: -400px;
  1376. width: 400px;
  1377. height: 100vh;
  1378. background-color: white;
  1379. .check-flow-right-slide-block-title {
  1380. height: 50px;
  1381. display: flex;
  1382. align-items: center;
  1383. border-bottom: 1px solid #ccc;
  1384. .check-flow-right-slide-block-title-text {
  1385. margin-left: 30px;
  1386. font-size: 14px;
  1387. line-height: 1;
  1388. color: #333;
  1389. display: flex;
  1390. align-items: center;
  1391. white-space: nowrap;
  1392. .check-flow-desc-error {
  1393. color: #e74c3c;
  1394. font-size: 14px;
  1395. margin-left: 4px;
  1396. }
  1397. }
  1398. .el-button {
  1399. margin-left: 4px;
  1400. border: none;
  1401. }
  1402. }
  1403. .check-flow-right-slide-block-middle {
  1404. padding: 20px 30px 30px;
  1405. border-bottom: 1px solid #ccc;
  1406. }
  1407. .condition-block-middle {
  1408. border-bottom: 0;
  1409. }
  1410. .check-flow-right-slide-block-middle-top {
  1411. margin-bottom: 30px;
  1412. .el-radio {
  1413. font-size: 12px;
  1414. color: #333;
  1415. }
  1416. }
  1417. .check-flow-right-slide-block-middle-selected {
  1418. margin-top: 8px;
  1419. .el-button {
  1420. margin-left: 16px;
  1421. }
  1422. }
  1423. .check-flow-right-slide-block-countersign {
  1424. border-bottom: 1px solid #ccc;
  1425. padding: 20px 30px;
  1426. }
  1427. .check-flow-right-slide-block-bottom {
  1428. padding: 10px 10px 0;
  1429. .check-flow-right-slide-block-bottom-title {
  1430. font-size: 14px;
  1431. line-height: 1;
  1432. color: #333;
  1433. }
  1434. .check-flow-right-slide-block-bottom-option {
  1435. margin-top: 30px;
  1436. .el-radio + .el-radio {
  1437. margin-top: 20px;
  1438. }
  1439. }
  1440. }
  1441. .check-flow-right-slide-block-action {
  1442. position: absolute;
  1443. bottom: 0;
  1444. height: 76px;
  1445. width: 400px;
  1446. display: flex;
  1447. align-items: center;
  1448. justify-content: flex-end;
  1449. background-color: #f6f6f6;
  1450. .el-button:last-of-type {
  1451. margin-right: 30px;
  1452. }
  1453. }
  1454. .condition-block-middle-content {
  1455. overflow-y: auto;
  1456. margin-top: 8px;
  1457. height: calc(100vh - 144px);
  1458. }
  1459. .condition-block-middle-seperator {
  1460. margin-top: 8px;
  1461. height: 1px;
  1462. width: 100%;
  1463. background-color: #ccc;
  1464. }
  1465. .condition-block-middle-content-block {
  1466. padding: 8px 0;
  1467. }
  1468. .condition-block-middle-content-value {
  1469. margin-top: 4px;
  1470. display: flex;
  1471. }
  1472. .condition-block-middle-content-delete {
  1473. margin-top: 8px;
  1474. }
  1475. .condition-name {
  1476. font-size: 14px;
  1477. }
  1478. .condition-content {
  1479. display: flex;
  1480. }
  1481. .condition-content-input {
  1482. margin-left: 4px;
  1483. }
  1484. }
  1485. .check-flow-right-slide-block-bg {
  1486. background-color: black;
  1487. opacity: 0.4;
  1488. position: absolute;
  1489. width: 100vw;
  1490. height: 100vh;
  1491. z-index: 1;
  1492. top: 0;
  1493. left: 0;
  1494. }
  1495. .dialog-content {
  1496. display: flex;
  1497. margin: -30px -20px;
  1498. }
  1499. .dialog-left {
  1500. width: 50%;
  1501. padding: 20px 0 32px 32px;
  1502. }
  1503. .dialog-part-title {
  1504. font-size: 14px;
  1505. color: #333;
  1506. }
  1507. .dialog-left-search {
  1508. margin-top: 22px;
  1509. width: 240px;
  1510. }
  1511. .dialog-left-tree {
  1512. margin-top: 30px;
  1513. max-height: 300px;
  1514. overflow: auto;
  1515. }
  1516. .dialog-selected-zone {
  1517. width: 50%;
  1518. padding: 20px;
  1519. background-color: #eee;
  1520. }
  1521. .dialog-selected-item {
  1522. padding: 0 20px 0 10px;
  1523. height: 36px;
  1524. width: 280px;
  1525. display: flex;
  1526. justify-content: space-between;
  1527. align-items: center;
  1528. background-color: white;
  1529. border-radius: 4px;
  1530. margin-top: 20px;
  1531. }
  1532. .dialog-selected-item + .dialog-selected-item {
  1533. margin-top: 8px;
  1534. }
  1535. .check-flow-desc-label::before {
  1536. content: "*";
  1537. color: #f56c6c;
  1538. margin-right: 4px;
  1539. }
  1540. .check-flow-desc-input {
  1541. margin-left: 8px;
  1542. }
  1543. </style>