process-manager.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112
  1. <template>
  2. <div class="app-container">
  3. <el-card class="box-card">
  4. <save-form
  5. ref="listQuery"
  6. :model="listQuery"
  7. :inline="true"
  8. @submit="handleQuery"
  9. >
  10. <el-form-item label="流程名称">
  11. <el-input
  12. v-model="listQuery.name"
  13. placeholder="请输入流程名称"
  14. clearable
  15. size="small"
  16. style="width: 240px"
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="流程状态">
  21. <el-select v-model="listQuery.status" clearable @change="getList">
  22. <el-option :label="'启用'" :value="1"></el-option>
  23. <el-option :label="'停用'" :value="0"></el-option>
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item label="可用分部">
  27. <el-select v-model="listQuery.orgId" clearable @change="getList">
  28. <el-option
  29. v-for="item in organSearchList"
  30. :label="item.name"
  31. :value="item.id"
  32. :key="item.id"
  33. ></el-option>
  34. </el-select>
  35. </el-form-item>
  36. <el-form-item>
  37. <el-button
  38. type="primary"
  39. icon="el-icon-search"
  40. size="small"
  41. native-type="submit"
  42. >搜索</el-button
  43. >
  44. </el-form-item>
  45. </save-form>
  46. <el-row :gutter="10" class="mb8">
  47. <el-col :span="1.5">
  48. <el-button
  49. v-permisaction="['process:admin:manager:add']"
  50. type="primary"
  51. icon="el-icon-plus"
  52. size="mini"
  53. @click="handleCreate"
  54. >新增</el-button
  55. >
  56. </el-col>
  57. <!-- <el-col :span="1.5">
  58. <el-button
  59. v-permisaction="['system:sysrole:edit']"
  60. type="success"
  61. icon="el-icon-edit"
  62. size="mini"
  63. :disabled="single"
  64. @click="handleUpdate"
  65. >编辑</el-button>
  66. </el-col>
  67. <el-col :span="1.5">
  68. <el-button
  69. v-permisaction="['system:sysrole:remove']"
  70. type="danger"
  71. icon="el-icon-delete"
  72. size="mini"
  73. :disabled="multiple"
  74. @click="handleDelete"
  75. >删除</el-button>
  76. </el-col> -->
  77. </el-row>
  78. <el-table
  79. v-loading="loading"
  80. border
  81. :data="processValueList"
  82. @selection-change="handleSelectionChange"
  83. >
  84. <el-table-column type="selection" width="55" align="center" />
  85. <el-table-column label="ID" prop="id" width="60" />
  86. <el-table-column
  87. label="名称"
  88. prop="name"
  89. :show-overflow-tooltip="true"
  90. />
  91. <el-table-column
  92. label="可用分部"
  93. prop="orgNames"
  94. :show-overflow-tooltip="true"
  95. />
  96. <el-table-column
  97. label="创建者"
  98. prop="create_name"
  99. :show-overflow-tooltip="true"
  100. />
  101. <el-table-column
  102. label="操作时间"
  103. align="center"
  104. prop="create_time"
  105. width="240"
  106. >
  107. <template slot-scope="{ row }">
  108. 创建时间:{{ row.create_time }}<br />
  109. 更新时间:{{ row.update_time }}
  110. </template>
  111. </el-table-column>
  112. <!-- <el-table-column
  113. label="更新时间"
  114. align="center"
  115. prop="update_time"
  116. width="180"
  117. /> -->
  118. <el-table-column
  119. label="排序"
  120. align="center"
  121. prop="sort_no"
  122. width="80"
  123. />
  124. <el-table-column
  125. label="流程状态"
  126. align="center"
  127. prop="status"
  128. width="100"
  129. >
  130. <template slot-scope="scope">
  131. <el-tag type="succes" v-if="scope.row.status">启用</el-tag>
  132. <el-tag type="danger" v-else>停用</el-tag>
  133. </template>
  134. </el-table-column>
  135. <el-table-column
  136. label="操作"
  137. align="center"
  138. class-name="small-padding fixed-width"
  139. >
  140. <template slot-scope="scope">
  141. <el-button
  142. v-permisaction="['process:admin:manager:actionstop']"
  143. size="mini"
  144. type="text"
  145. :icon="
  146. scope.row.status ? 'el-icon-video-play' : 'el-icon-video-pause'
  147. "
  148. @click="handleStatus(scope.row)"
  149. >{{ scope.row.status ? "停用" : "启用" }}</el-button
  150. >
  151. <el-button
  152. v-permisaction="['process:admin:manager:sort']"
  153. size="mini"
  154. type="text"
  155. icon="el-icon-sort"
  156. @click="handleSort(scope.row)"
  157. >排序</el-button
  158. >
  159. <el-button
  160. v-permisaction="['process:admin:manager:clone']"
  161. size="mini"
  162. type="text"
  163. icon="el-icon-receiving"
  164. @click="handleClone(scope.row)"
  165. >克隆</el-button
  166. >
  167. <el-button
  168. v-permisaction="['process:admin:manager:edit']"
  169. size="mini"
  170. type="text"
  171. icon="el-icon-edit"
  172. @click="handleEdit(scope.row)"
  173. >编辑</el-button
  174. >
  175. <el-button
  176. v-permisaction="['process:admin:manager:delete']"
  177. size="mini"
  178. type="text"
  179. icon="el-icon-delete"
  180. @click="handleDelete(scope.row)"
  181. >删除</el-button
  182. >
  183. <el-button
  184. v-permisaction="['process:admin:manager:orgIds']"
  185. size="mini"
  186. type="text"
  187. icon="el-icon-setting"
  188. @click="handleSetting(scope.row)"
  189. >设置分部</el-button
  190. >
  191. </template>
  192. </el-table-column>
  193. </el-table>
  194. <pagination
  195. v-show="total > 0"
  196. :total="total"
  197. :page.sync="queryParams.pageIndex"
  198. :limit.sync="queryParams.pageSize"
  199. @pagination="getList"
  200. />
  201. <el-drawer
  202. :title="dialogProcessVisibleName === 1 ? '新建流程' : '编辑流程'"
  203. direction="rtl"
  204. :visible.sync="open"
  205. :before-close="handleClose"
  206. size="90%"
  207. >
  208. <div v-if="open" class="tpl-create-content" style="margin-right: 15px">
  209. <el-form
  210. ref="ruleForm"
  211. :model="ruleForm"
  212. :rules="rules"
  213. label-width="100px"
  214. >
  215. <el-row>
  216. <el-col :span="8">
  217. <el-form-item label="名称" prop="name">
  218. <el-input
  219. v-model="ruleForm.name"
  220. placeholder="请输入流程名称"
  221. style="width: 100%"
  222. />
  223. </el-form-item>
  224. </el-col>
  225. <el-col :span="8">
  226. <el-form-item label="图标" prop="icon">
  227. <e-icon-picker v-model="ruleForm.icon" style="width: 100%" />
  228. </el-form-item>
  229. </el-col>
  230. <el-col :span="8">
  231. <el-form-item label="分类" prop="classify">
  232. <el-select
  233. v-model="ruleForm.classify"
  234. filterable
  235. placeholder="请选择流程分类"
  236. style="width: 100%"
  237. >
  238. <el-option
  239. v-for="item in classifyListData"
  240. :key="item.id"
  241. :label="item.name"
  242. :value="item.id"
  243. />
  244. </el-select>
  245. </el-form-item>
  246. </el-col>
  247. </el-row>
  248. <el-row>
  249. <el-col :span="8">
  250. <el-form-item label="模版" prop="tpls">
  251. <el-select
  252. v-model="ruleForm.tpls"
  253. filterable
  254. multiple
  255. placeholder="请选择模版"
  256. style="width: 100%"
  257. >
  258. <el-option
  259. v-for="item in templates"
  260. :key="item.id"
  261. :label="item.name"
  262. :value="item.id"
  263. />
  264. </el-select>
  265. </el-form-item>
  266. </el-col>
  267. <el-col :span="8">
  268. <el-form-item label="通知">
  269. <el-select
  270. v-model="ruleForm.notice"
  271. multiple
  272. filterable
  273. clearable
  274. placeholder="请选择流程任务"
  275. style="width: 100%"
  276. >
  277. <el-option label="推送" :value="1" />
  278. <el-option label="IM消息" :value="2" />
  279. </el-select>
  280. </el-form-item>
  281. </el-col>
  282. <el-col :span="8">
  283. <el-form-item label="模板类型" prop="sub">
  284. <el-select
  285. v-model="ruleForm.sub"
  286. filterable
  287. placeholder="请选择模板类型"
  288. style="width: 100%"
  289. >
  290. <el-option label="父流程" :value="0" />
  291. <el-option label="子流程" :value="1" />
  292. </el-select>
  293. </el-form-item>
  294. </el-col>
  295. </el-row>
  296. <el-form-item label="描述" prop="remarks">
  297. <el-input
  298. v-model="ruleForm.remarks"
  299. placeholder="请输入流程描述"
  300. type="textarea"
  301. :autosize="{ minRows: 2, maxRows: 4 }"
  302. style="width: 100%"
  303. />
  304. </el-form-item>
  305. <el-form-item label="流程" prop="structure">
  306. <div style="border-radius: 4px; overflow: hidden">
  307. <div>
  308. <WfdDesign
  309. v-if="wfdDesignRefresh"
  310. ref="wfd"
  311. :users="users"
  312. :roles="roles"
  313. :departments="departments"
  314. :post-options="postOptions"
  315. :tasks="taskListData"
  316. :process="processData"
  317. :templates="ruleForm.tpls"
  318. :templates-base="templates"
  319. :data="ruleForm.structure"
  320. :height="600"
  321. :lang="lang"
  322. />
  323. </div>
  324. </div>
  325. </el-form-item>
  326. </el-form>
  327. <div
  328. style="text-align: center; margin-top: 20px; margin-bottom: 20px"
  329. >
  330. <el-button
  331. type="primary"
  332. @click="
  333. dialogProcessVisibleName === 1
  334. ? submitForm('ruleForm')
  335. : editForm('ruleForm')
  336. "
  337. >提交</el-button
  338. >
  339. <el-button @click="handleClose">取 消</el-button>
  340. </div>
  341. </div>
  342. </el-drawer>
  343. <el-dialog :title="'排序'" :visible.sync="sortOpen" width="400px">
  344. <div class="tpl-create-content">
  345. <el-form ref="sortRuleForm" :model="sortRuleForm" label-width="80px">
  346. <el-form-item
  347. label="排序值"
  348. prop="sortNo"
  349. :rules="[
  350. {
  351. required: true,
  352. message: '请输入排序值',
  353. },
  354. ]"
  355. style="width: 95%"
  356. >
  357. <!-- <el-input v-model="ruleForm.name" /> -->
  358. <el-input-number
  359. v-model="sortRuleForm.sortNo"
  360. controls-position="right"
  361. :min="0"
  362. :max="10000"
  363. style="width: 100%"
  364. ></el-input-number>
  365. </el-form-item>
  366. </el-form>
  367. <div slot="footer" class="dialog-footer" style="text-align: right">
  368. <el-button type="primary" @click="handleFormSort('sortRuleForm')"
  369. >提交</el-button
  370. >
  371. <el-button @click="sortOpen = false">取 消</el-button>
  372. </div>
  373. </div>
  374. </el-dialog>
  375. <el-dialog :title="'设置分部'" :visible.sync="openOrgin" width="500px">
  376. <div class="tpl-create-content">
  377. <el-form
  378. ref="ruleOrganForm"
  379. :model="ruleOrganForm"
  380. label-width="100px"
  381. >
  382. <el-form-item
  383. label="可用分部"
  384. style="width: 95%"
  385. prop="orgIds"
  386. :rules="[
  387. {
  388. required: true,
  389. message: '请选择可用分部',
  390. },
  391. ]"
  392. >
  393. <div class="select-all">
  394. <el-select
  395. v-model="ruleOrganForm.orgIds"
  396. clearable
  397. placeholder="请选择可用分部"
  398. style="width: 100%"
  399. multiple
  400. class="select"
  401. collapse-tags
  402. ref="select"
  403. @change="handleOrganChange"
  404. >
  405. <el-option
  406. v-for="item in organSearchList"
  407. :label="item.name"
  408. :value="item.id"
  409. :key="item.id"
  410. :disabled="item.disabled"
  411. ></el-option>
  412. </el-select>
  413. <el-button class="btn" @click="selectAll">全选</el-button>
  414. </div>
  415. </el-form-item>
  416. </el-form>
  417. <div slot="footer" class="dialog-footer" style="text-align: right">
  418. <el-button type="primary" @click="setOrgIdsForm('ruleOrganForm')"
  419. >提交</el-button
  420. >
  421. <el-button @click="openOrgin = false">取 消</el-button>
  422. </div>
  423. </div>
  424. </el-dialog>
  425. </el-card>
  426. </div>
  427. </template>
  428. <script>
  429. import {
  430. processList,
  431. createProcess,
  432. updateProcess,
  433. processDetails,
  434. deleteProcess,
  435. cloneProcess,
  436. statusProcess,
  437. sortProcess,
  438. orgIdsProcess,
  439. } from "@/api/process/admin/process";
  440. import { queryUserInfo, queryAllToOrgan } from "@/api/process/work-order";
  441. import SaveForm from "@/components/save-form";
  442. import { classifyList } from "@/api/process/admin/classify";
  443. import { templateList } from "@/api/process/admin/template";
  444. import { taskList } from "@/api/process/admin/task";
  445. import { listUser } from "@/api/system/sysuser";
  446. import { listRole } from "@/api/system/role";
  447. import { listPost } from "@/api/system/post";
  448. // import { getOrdinaryDeptList } from '@/api/system/dept'
  449. import { treeselect } from "@/api/system/dept";
  450. import load from "@/utils/loading";
  451. export default {
  452. name: "Process",
  453. components: {
  454. WfdDesign: () => import("@/components/wfd/components/Wfd"),
  455. SaveForm,
  456. },
  457. data() {
  458. return {
  459. queryParams: {},
  460. // 遮罩层
  461. loading: true,
  462. // 选中数组
  463. ids: [],
  464. // 非单个禁用
  465. single: true,
  466. // 非多个禁用
  467. multiple: true,
  468. // 总条数
  469. total: 0,
  470. // 是否显示弹出层
  471. open: false,
  472. // 查询参数
  473. structureValue: [],
  474. users: [],
  475. roles: [],
  476. groups: [],
  477. departments: [],
  478. postOptions: [],
  479. templates: [],
  480. taskListData: [],
  481. processData: [],
  482. wfdDesignRefresh: true,
  483. classifyListData: [],
  484. dialogProcessVisibleName: 1,
  485. processValueList: [],
  486. listQuery: {
  487. status: null,
  488. page: 1,
  489. orgId: "",
  490. per_page: 10,
  491. },
  492. lang: "zh",
  493. ruleForm: {},
  494. rules: {
  495. icon: [
  496. { required: true, message: "请输入流程图标", trigger: "change" },
  497. ],
  498. name: [{ required: true, message: "请输入流程名称", trigger: "blur" }],
  499. classify: [
  500. { required: true, message: "请选择流程分类", trigger: "change" },
  501. ],
  502. tpls: [{ required: true, message: "请选择模版", trigger: "change" }],
  503. sub: [{ required: true, message: "请选择模版类型", trigger: "change" }],
  504. structure: [{ required: true, message: "请设计流程", trigger: "blur" }],
  505. remarks: [
  506. { required: true, message: "请输入流程描述", trigger: "blur" },
  507. ],
  508. },
  509. sortOpen: false,
  510. sortRuleForm: {
  511. id: null,
  512. sortNo: 0,
  513. },
  514. openOrgin: false,
  515. tenantId: 1,
  516. organSearchList: [], // 只是搜索使用
  517. organList: [],
  518. organSetList: [], // 只是设置使用
  519. ruleOrganForm: {
  520. id: null,
  521. orgIds: [],
  522. },
  523. };
  524. },
  525. mounted() {
  526. this.getList();
  527. this.getUserInfo();
  528. this.getAllOrgan();
  529. },
  530. methods: {
  531. async getUserInfo() {
  532. await queryUserInfo().then((res) => {
  533. // console.log(res);
  534. if (res.code == 200) {
  535. this.userIds = res.data.id;
  536. this.tenantId = res.data.tenantId;
  537. this.userType = res.data.userType;
  538. } else {
  539. this.$message.error(res.data);
  540. }
  541. });
  542. },
  543. // 获取任务列表
  544. async getTaskList() {
  545. await taskList({
  546. page: 1,
  547. per_page: 99999,
  548. }).then((response) => {
  549. this.taskListData = response.data.data;
  550. });
  551. },
  552. async getProcessList() {
  553. await processList({
  554. page: 1,
  555. per_page: 99999,
  556. })
  557. .then((response) => {
  558. const tempList = response.data.data || [];
  559. const subList = [];
  560. tempList.forEach((item) => {
  561. if (item.sub == 1) {
  562. subList.push(item);
  563. }
  564. });
  565. this.processData = subList;
  566. })
  567. .catch(() => {
  568. load.endLoading();
  569. });
  570. },
  571. // 获取流程分类列表
  572. async getClassifyList() {
  573. await classifyList({
  574. page: 1,
  575. per_page: 99999,
  576. })
  577. .then((response) => {
  578. this.classifyListData = response.data.data;
  579. })
  580. .catch(() => {
  581. load.endLoading();
  582. });
  583. },
  584. // 获取模版列表
  585. async getTemplates() {
  586. await templateList({
  587. page: 1,
  588. per_page: 99999,
  589. })
  590. .then((response) => {
  591. this.templates = response.data.data;
  592. })
  593. .catch(() => {
  594. load.endLoading();
  595. });
  596. },
  597. // 获取用户
  598. async getUsers() {
  599. await listUser({
  600. pageSize: 999999,
  601. })
  602. .then((response) => {
  603. this.users = response.data.list;
  604. })
  605. .catch(() => {
  606. load.endLoading();
  607. });
  608. },
  609. async getRoles() {
  610. await listRole({
  611. pageSize: 999999,
  612. })
  613. .then((response) => {
  614. this.roles = response.data.list;
  615. })
  616. .catch(() => {
  617. load.endLoading();
  618. });
  619. },
  620. // 获取部门
  621. async getDepartments() {
  622. await treeselect()
  623. .then((response) => {
  624. this.departments = response.data;
  625. })
  626. .catch(() => {
  627. load.endLoading();
  628. });
  629. },
  630. // 获取岗位
  631. async getPostOptions() {
  632. await listPost({
  633. page: 1,
  634. pageSize: 99999,
  635. })
  636. .then((response) => {
  637. this.postOptions = response.data.list;
  638. })
  639. .catch(() => {
  640. load.endLoading();
  641. });
  642. },
  643. /** 查询流程列表 */
  644. getList() {
  645. this.loading = true;
  646. this.listQuery.page = this.queryParams.pageIndex;
  647. this.listQuery.per_page = this.queryParams.pageSize;
  648. processList(this.listQuery).then((response) => {
  649. this.processValueList = response.data.data;
  650. this.queryParams.pageIndex = response.data.page;
  651. this.queryParams.pageSize = response.data.per_page;
  652. this.total = response.data.total_count;
  653. this.loading = false;
  654. });
  655. },
  656. async getProcessInitData() {
  657. await this.getClassifyList();
  658. await this.getTemplates();
  659. await this.getUsers();
  660. await this.getRoles();
  661. await this.getDepartments();
  662. await this.getProcessList();
  663. await this.getPostOptions();
  664. },
  665. async handleCreate() {
  666. load.startLoading();
  667. await this.getProcessInitData();
  668. load.endLoading();
  669. this.ruleForm = {
  670. id: undefined,
  671. name: "",
  672. tpls: [],
  673. structure: { edges: [], nodes: [], groups: [] },
  674. classify: "",
  675. task: [],
  676. notice: [1],
  677. sub: 0,
  678. icon: "",
  679. remarks: "",
  680. };
  681. this.dialogProcessVisibleName = 1;
  682. this.open = true;
  683. this.wfdDesignRefresh = false;
  684. this.$nextTick(() => {
  685. this.wfdDesignRefresh = true;
  686. });
  687. },
  688. async handleSort(row) {
  689. try {
  690. this.sortOpen = true;
  691. this.sortRuleForm.id = row.id;
  692. this.sortRuleForm.sortNo = row.sort_no;
  693. } catch {
  694. //
  695. }
  696. },
  697. async handleEdit(row) {
  698. this.dialogProcessVisibleName = 2;
  699. load.startLoading();
  700. await this.getProcessInitData();
  701. load.endLoading();
  702. this.wfdDesignRefresh = false;
  703. await processDetails({
  704. processId: row.id,
  705. }).then((response) => {
  706. this.ruleForm = {
  707. id: response.data.id,
  708. name: response.data.name,
  709. tpls: response.data.tpls,
  710. structure: response.data.structure,
  711. classify: response.data.classify,
  712. task: response.data.task,
  713. notice: response.data.notice,
  714. sub: response.data.sub,
  715. icon: response.data.icon,
  716. remarks: response.data.remarks,
  717. };
  718. this.wfdDesignRefresh = false;
  719. this.$nextTick(() => {
  720. this.wfdDesignRefresh = true;
  721. });
  722. });
  723. this.open = true;
  724. },
  725. handleFormSort(formName) {
  726. this.$refs[formName].validate((valid) => {
  727. if (valid) {
  728. console.log(valid);
  729. sortProcess(this.sortRuleForm.sortNo, this.sortRuleForm.id).then(
  730. (res) => {
  731. if (res.code == 200) {
  732. this.sortOpen = false;
  733. this.getList();
  734. this.$message({
  735. type: "success",
  736. message: "更新成功",
  737. });
  738. }
  739. }
  740. );
  741. }
  742. });
  743. },
  744. handleClose(done) {
  745. this.$confirm("确认关闭?")
  746. .then((_) => {
  747. this.open = false;
  748. if (done) {
  749. done();
  750. }
  751. })
  752. .catch((_) => {});
  753. },
  754. verifyProcess(structureValue) {
  755. // console.log(structureValue)
  756. for (var r of structureValue.nodes) {
  757. if (r.sort === undefined || r.sort === null || r.sort === "") {
  758. return "流程节点顺序不能为空";
  759. }
  760. // else if (r.label === undefined || r.label === null || r.label === '') {
  761. // return '流程节点标题不能为空'
  762. // }
  763. if (r.clazz === "userTask" || r.clazz === "receiveTask") {
  764. if (
  765. r.assignType === undefined ||
  766. r.assignType === null ||
  767. r.assignType === ""
  768. ) {
  769. return "审批节点或处理节点的处理人类型不能为空";
  770. } else if (
  771. r.assignValue === undefined ||
  772. r.assignValue === null ||
  773. r.assignValue === "" ||
  774. r.assignValue.length === 0
  775. ) {
  776. return "审批节点或处理节点的处理人不能为空";
  777. }
  778. }
  779. }
  780. // else if (e.label === undefined || e.label === null || e.label === '') {
  781. // return '流转标题不能为空'
  782. // }
  783. // console.log(structureValue);
  784. for (var e of structureValue.edges) {
  785. if (e.sort === undefined || e.sort === null || e.sort === "") {
  786. return "流转顺序不能为空";
  787. } else if (
  788. e.flowProperties === undefined ||
  789. e.flowProperties === null ||
  790. e.flowProperties === ""
  791. ) {
  792. return "流转属性不能为空";
  793. }
  794. }
  795. return "";
  796. },
  797. submitForm(formName) {
  798. this.$refs[formName].validate((valid) => {
  799. if (valid) {
  800. var structureValue = this.$refs.wfd.graph.save();
  801. for (var n of structureValue.nodes) {
  802. n.sort = "1";
  803. n.activeOrder = false;
  804. const tempType = n.assignValue || [];
  805. if (tempType.includes(4)) {
  806. n.isCounterSign = true;
  807. } else {
  808. n.isCounterSign = false;
  809. }
  810. }
  811. for (var j of structureValue.edges) {
  812. j.sort = "1";
  813. j.flowProperties = "1";
  814. }
  815. var r = this.verifyProcess(structureValue);
  816. if (r !== "") {
  817. this.$message.error(r);
  818. return;
  819. }
  820. if (
  821. structureValue.nodes.length > 0 &&
  822. structureValue.edges.length > 0
  823. ) {
  824. this.ruleForm.structure = structureValue;
  825. createProcess(this.ruleForm).then((response) => {
  826. this.getList();
  827. this.open = false;
  828. });
  829. } else {
  830. this.$message.error("没有流程数据,请完善流程");
  831. }
  832. }
  833. });
  834. },
  835. editForm(formName) {
  836. this.$refs[formName].validate((valid) => {
  837. if (valid) {
  838. var structureValue = this.$refs.wfd.graph.save();
  839. for (var n of structureValue.nodes) {
  840. n.sort = "1";
  841. n.activeOrder = false;
  842. const tempType = n.assignValue || [];
  843. if (tempType.includes(4)) {
  844. n.isCounterSign = true;
  845. } else {
  846. n.isCounterSign = false;
  847. }
  848. }
  849. for (var j of structureValue.edges) {
  850. j.sort = "1";
  851. j.flowProperties = "1";
  852. }
  853. var r = this.verifyProcess(structureValue);
  854. if (r !== "") {
  855. this.$message.error(r);
  856. return;
  857. }
  858. if (
  859. structureValue.nodes.length > 0 &&
  860. structureValue.edges.length > 0
  861. ) {
  862. updateProcess({
  863. id: this.ruleForm.id,
  864. name: this.ruleForm.name,
  865. tpls: this.ruleForm.tpls,
  866. structure: structureValue,
  867. classify: this.ruleForm.classify,
  868. task: this.ruleForm.task,
  869. notice: this.ruleForm.notice,
  870. sub: this.ruleForm.sub,
  871. icon: this.ruleForm.icon,
  872. remarks: this.ruleForm.remarks,
  873. }).then((response) => {
  874. this.getList();
  875. this.open = false;
  876. });
  877. } else {
  878. this.$notify({
  879. title: "错误",
  880. message: "没有流程数据,请完善流程",
  881. type: "error",
  882. });
  883. }
  884. }
  885. });
  886. },
  887. handleQuery() {
  888. this.queryParams.pageIndex = 1;
  889. this.queryParams.pageSize = 10;
  890. this.getList();
  891. },
  892. selectAll() {
  893. const { options } = this.$refs.select;
  894. const values = options
  895. .filter((item) => !item.disabled && item.value)
  896. .map((item) => item.value);
  897. this.ruleOrganForm.orgIds = values;
  898. },
  899. async getAllOrgan() {
  900. // 获取分部
  901. queryAllToOrgan({ tenantId: this.tenantId }).then((res) => {
  902. if (res.code == 200) {
  903. const result = res.data;
  904. const filterOrganId = [
  905. 1, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
  906. 22, 23, 25, 26, 27, 28, 34, 37, 40, 71, 72, 123, 124, 125, 128, 134,
  907. 148, 147, 127, 139, 151, 36, 149, 152, 153,
  908. ];
  909. // 搜索的分部
  910. const filterSearchOrganId = [
  911. 148, 147, 127, 151, 36, 149, 152, 16, 1, 40, 15, 23, 28, 17, 6, 8,
  912. 13, 134, 139, 153, 71, 123
  913. ];
  914. let tempOrgan = [];
  915. let tempSearchOrgan = [];
  916. // 过滤不会显示的分部
  917. result.forEach((item) => {
  918. if (filterOrganId.includes(item.id)) {
  919. tempOrgan.push(item);
  920. }
  921. if (filterSearchOrganId.includes(item.id)) {
  922. tempSearchOrgan.push(item);
  923. }
  924. });
  925. this.organList = tempOrgan;
  926. this.organSearchList = tempSearchOrgan;
  927. }
  928. });
  929. },
  930. handleSetting(row) {
  931. this.ruleOrganForm.id = row.id;
  932. const ids = row.org_ids
  933. ? row.org_ids.split(",").map((item) => Number(item))
  934. : [];
  935. const tempOrganSet = [...this.organSearchList];
  936. const lastIds = []
  937. tempOrganSet.forEach((item) => {
  938. if(ids.includes(item.id)){
  939. lastIds.push(item.id)
  940. }
  941. });
  942. tempOrganSet.sort((a, b) => {
  943. return a.id - b.id;
  944. });
  945. this.ruleOrganForm.orgIds = lastIds;
  946. this.organSetList = tempOrganSet;
  947. this.openOrgin = true;
  948. },
  949. handleOrganChange(val) {
  950. // console.log(val)
  951. // const tempOrganSet = [...this.organSetList];
  952. // tempOrganSet.forEach((item) => {
  953. // if (!val.includes(item.id)) {
  954. // const index = this.organSearchList.findIndex((tempItem) => {
  955. // return tempItem.id === item.id;
  956. // });
  957. // if (index === -1) {
  958. // item.disabled = true;
  959. // } else {
  960. // item.disabled = false;
  961. // }
  962. // }
  963. // })
  964. // this.organSetList = tempOrganSet;
  965. },
  966. setOrgIdsForm(formName) {
  967. this.$refs[formName].validate(async (valid) => {
  968. if (valid) {
  969. try {
  970. await orgIdsProcess(
  971. this.ruleOrganForm.id,
  972. this.ruleOrganForm.orgIds.join(",")
  973. );
  974. this.$message.success("设置成功");
  975. this.getList();
  976. this.openOrgin = false;
  977. } catch {}
  978. }
  979. });
  980. },
  981. handleDelete(row) {
  982. this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
  983. confirmButtonText: "确定",
  984. cancelButtonText: "取消",
  985. type: "warning",
  986. })
  987. .then(() => {
  988. deleteProcess({
  989. processId: row.id,
  990. }).then((response) => {
  991. if (response !== undefined) {
  992. this.getList();
  993. this.$message({
  994. type: "success",
  995. message: "流程已删除!",
  996. });
  997. }
  998. });
  999. })
  1000. .catch(() => {
  1001. this.$message({
  1002. type: "info",
  1003. message: "已取消删除",
  1004. });
  1005. });
  1006. },
  1007. handleSelectionChange() {},
  1008. handleSave(values) {
  1009. if (values.list.length > 0) {
  1010. this.ruleForm.form_structure = values;
  1011. } else {
  1012. this.ruleForm.form_structure = "";
  1013. }
  1014. },
  1015. handleStatus(row) {
  1016. const str = row.status ? "停用" : "启用";
  1017. this.$confirm(`是否${str}流程 < ${row.name} > ?`, "提示", {
  1018. confirmButtonText: "确定",
  1019. cancelButtonText: "取消",
  1020. type: "info",
  1021. }).then(() => {
  1022. const status = row.status ? 0 : 1;
  1023. statusProcess(status, row.id).then(() => {
  1024. this.getList();
  1025. this.$message({
  1026. type: "success",
  1027. message: `流程已${str}!`,
  1028. });
  1029. });
  1030. });
  1031. },
  1032. handleClone(row) {
  1033. this.$confirm(`确认克隆流程 < ${row.name} > ?`, "提示", {
  1034. confirmButtonText: "确定",
  1035. cancelButtonText: "取消",
  1036. type: "info",
  1037. })
  1038. .then(() => {
  1039. cloneProcess(row.id).then(() => {
  1040. this.getList();
  1041. this.$message({
  1042. type: "success",
  1043. message: "流程已克隆!",
  1044. });
  1045. });
  1046. })
  1047. .catch(() => {
  1048. this.$message({
  1049. type: "info",
  1050. message: "已取消",
  1051. });
  1052. });
  1053. },
  1054. },
  1055. };
  1056. </script>
  1057. <style scoped>
  1058. :deep(.el-drawer__body) {
  1059. overflow-y: auto;
  1060. }
  1061. .select-all {
  1062. display: flex;
  1063. flex-direction: row;
  1064. align-items: center;
  1065. }
  1066. .select-all .select {
  1067. flex: 1;
  1068. }
  1069. .select-all .select :deep(.el-input__inner) {
  1070. min-height: 37px !important;
  1071. border-radius: 4px 0 0 4px;
  1072. }
  1073. .btn {
  1074. border-left: none;
  1075. border-radius: 0 4px 4px 0;
  1076. min-height: 37px;
  1077. }
  1078. .item {
  1079. width: 100%;
  1080. position: absolute;
  1081. z-index: 1000;
  1082. min-height: 40px;
  1083. }
  1084. .item .showDev {
  1085. width: 100%;
  1086. }
  1087. /* .select-all ::v-deep .el-select__tags {
  1088. flex-wrap: nowrap !important;
  1089. }
  1090. .selectWrap {
  1091. ::v-deep .el-select__tags {
  1092. flex-wrap: wrap !important;
  1093. }
  1094. } */
  1095. </style>