index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <!--
  2. * @FilePath: index.vue
  3. * @Author: 旭颖
  4. * @Date: 2022-12-14 16:03:57
  5. * @LastEditors: Please set LastEditors
  6. * @LastEditTime: 2023-02-28 18:29:04
  7. -->
  8. <template>
  9. <div class="page-container">
  10. <vab-query-form>
  11. <vab-query-form-left-panel :span="24">
  12. <!-- <el-button :icon="Plus" type="primary" @click="addCheck()">
  13. 添加审核流程
  14. </el-button> -->
  15. <el-button
  16. v-if="show && totalList.length > 0"
  17. :icon="Plus"
  18. type="warning"
  19. @click="pushPersonnel()"
  20. >
  21. 添加推送
  22. </el-button>
  23. <!-- <el-button :icon="Plus" type="warning">保存流程</el-button> -->
  24. </vab-query-form-left-panel>
  25. </vab-query-form>
  26. <div v-if="totalList.length > 0">
  27. <el-row v-loading="listLoading" style="margin-top: 20px">
  28. <el-col :span="12">
  29. <el-timeline>
  30. <el-timeline-item
  31. v-for="(item, index) in startList"
  32. :key="index"
  33. placement="top"
  34. :timestamp="'第' + item.node_num + '步'"
  35. type="primary"
  36. >
  37. <div class="line">
  38. <el-card style="flex: 0 0 750px; margin-right: 10px">
  39. <h3>{{ item.name }}</h3>
  40. </el-card>
  41. <el-button
  42. circle
  43. :icon="Plus"
  44. type="primary"
  45. @click="addCheck(0, 2)"
  46. />
  47. </div>
  48. </el-timeline-item>
  49. <el-timeline-item
  50. v-for="(item, index) in list"
  51. :key="index"
  52. placement="top"
  53. :timestamp="'第' + item.node_num + '步'"
  54. type="primary"
  55. >
  56. <div class="line">
  57. <el-card style="flex: 0 0 750px; margin-right: 10px">
  58. <div class="title">
  59. <h3>{{ item.name }}</h3>
  60. <el-button
  61. v-if="item.check_type"
  62. plain
  63. type="primary"
  64. @click="editCheck(item.type, index)"
  65. >
  66. 编辑当前节点
  67. </el-button>
  68. </div>
  69. <div>
  70. <div v-if="item.check_type == 5">
  71. <el-tag type="warning">对应驻场</el-tag>
  72. </div>
  73. <div v-else>
  74. <el-tag
  75. v-for="(item, index) in item.check_body"
  76. :key="index"
  77. type="primary"
  78. >
  79. {{ item.name }}
  80. </el-tag>
  81. </div>
  82. </div>
  83. </el-card>
  84. <el-button
  85. circle
  86. :icon="Minus"
  87. type="danger"
  88. @click="deleteStep(index, item.type)"
  89. />
  90. <el-button
  91. circle
  92. :icon="Plus"
  93. type="primary"
  94. @click="addCheck(index, item.type)"
  95. />
  96. </div>
  97. </el-timeline-item>
  98. <el-timeline-item
  99. v-for="(item, index) in endList"
  100. :key="index"
  101. placement="top"
  102. :timestamp="'第' + item.node_num + '步'"
  103. type="success"
  104. >
  105. <el-card style="width: 750px">
  106. <h3>{{ item.name }}</h3>
  107. </el-card>
  108. </el-timeline-item>
  109. <el-timeline-item
  110. v-for="(item, index) in tuisong"
  111. :key="index"
  112. placement="top"
  113. :timestamp="'第' + item.node_num + '步'"
  114. type="warning"
  115. >
  116. <div class="line">
  117. <el-card style="flex: 0 0 750px; margin-right: 10px">
  118. <div class="title">
  119. <h3>{{ item.name }}</h3>
  120. <el-button
  121. plain
  122. type="primary"
  123. @click="editCheck(item.type, index)"
  124. >
  125. 编辑当前节点
  126. </el-button>
  127. </div>
  128. <div>
  129. <el-tag
  130. v-for="(item, index) in item.check_body"
  131. :key="index"
  132. type="primary"
  133. >
  134. {{ item.name }}
  135. </el-tag>
  136. </div>
  137. </el-card>
  138. <el-button
  139. circle
  140. :icon="Minus"
  141. type="danger"
  142. @click="deleteStep(index, item.type)"
  143. />
  144. </div>
  145. </el-timeline-item>
  146. </el-timeline>
  147. </el-col>
  148. <el-col :span="12">
  149. <div class="grid-content ep-bg-purple-light" />
  150. </el-col>
  151. </el-row>
  152. </div>
  153. <div v-else>
  154. <div class="empty">
  155. <el-empty description="暂未配置审核流程" />
  156. <div class="empty-text">
  157. 请先配置流程框架
  158. <span style="margin-left: 10px">
  159. <el-button type="primary" @click="baseConfig">
  160. 配置流程框架
  161. </el-button>
  162. </span>
  163. </div>
  164. </div>
  165. </div>
  166. <Add ref="addRef" @fetch-data="getFlow" />
  167. <Edit ref="editRef" @fetch-data="getFlow" />
  168. </div>
  169. </template>
  170. <script>
  171. import {
  172. Plus,
  173. Search,
  174. Refresh,
  175. Delete,
  176. Minus,
  177. Download,
  178. Avatar,
  179. CirclePlus,
  180. } from '@element-plus/icons-vue'
  181. import { getFlows, getFlowsId, doAdd } from './api/index'
  182. export default defineComponent({
  183. name: 'RoleManagement',
  184. components: {
  185. Add: defineAsyncComponent(() => import('./components/AddManage.vue')),
  186. Edit: defineAsyncComponent(() => import('./components/EditManage.vue')),
  187. },
  188. props: {
  189. code: {
  190. type: String,
  191. required: true,
  192. default: '',
  193. },
  194. },
  195. setup(props) {
  196. const $baseConfirm = inject('$baseConfirm')
  197. const $baseMessage = inject('$baseMessage')
  198. const state = reactive({
  199. addRef: null,
  200. editRef: null,
  201. listLoading: true,
  202. activeName: 'first',
  203. startList: [],
  204. list: [], //审核步骤审核流程
  205. endList: [], //结束
  206. tuisong: [],
  207. flowId: '', //流程id
  208. show: false,
  209. key: '',
  210. totalList: [], //所有审核流程
  211. })
  212. watch(
  213. () => props.code,
  214. () => {
  215. if (props.code) {
  216. state.key = props.code
  217. getFlow()
  218. getflowId()
  219. }
  220. }
  221. )
  222. //配置审核基础框架
  223. const baseConfig = async () => {
  224. const node = [
  225. {
  226. check_body: null,
  227. check_type: 0,
  228. name: '用户提交申请',
  229. node_num: 1,
  230. type: 1,
  231. },
  232. {
  233. check_body: null,
  234. check_type: 0,
  235. name: '审核完成',
  236. node_num: 2,
  237. type: 5,
  238. },
  239. ]
  240. const { message } = await doAdd({
  241. flow_id: state.flowId,
  242. nodes: node,
  243. })
  244. $baseMessage(message, 'success', 'vab-hey-message-success')
  245. await getFlow()
  246. }
  247. //获取流程
  248. const getFlow = async () => {
  249. state.listLoading = true
  250. state.startList = []
  251. state.list = []
  252. state.endList = [] //结束
  253. state.tuisong = []
  254. state.totalList = []
  255. const { data } = await getFlows({
  256. flow_code: state.key,
  257. })
  258. if (data.length > 0) {
  259. state.totalList = data
  260. data.map((item) => {
  261. if (item.type == 6) {
  262. state.show = false
  263. } else {
  264. state.show = true
  265. }
  266. if (item.type == 1) {
  267. console.log(item, 'pppp')
  268. state.startList.push(item)
  269. }
  270. if (item.type == 5) {
  271. state.endList.push(item)
  272. }
  273. if (item.type == 2) {
  274. state.list.push(item)
  275. }
  276. if (item.type == 6) {
  277. state.tuisong.push(item)
  278. }
  279. })
  280. } else {
  281. state.show = true
  282. state.startList = [
  283. {
  284. check_body: null,
  285. check_type: 0,
  286. name: '用户提交申请',
  287. node_num: 1,
  288. type: 1,
  289. },
  290. ]
  291. state.endList = [
  292. {
  293. check_body: null,
  294. check_type: 0,
  295. name: '审核完成',
  296. node_num: 2,
  297. type: 5,
  298. },
  299. ]
  300. }
  301. state.listLoading = false
  302. }
  303. //获取流程id
  304. const getflowId = async () => {
  305. const { data } = await getFlowsId({ code: state.key })
  306. state.flowId = data.data[0].id
  307. }
  308. //点击添加新流程
  309. const addCheck = (index, type) => {
  310. state['addRef'].showEdit({
  311. tuisong: state.tuisong,
  312. list: state.list,
  313. flowId: state.flowId,
  314. type: type,
  315. index: index,
  316. })
  317. }
  318. //编辑节点
  319. const editCheck = (type, index) => {
  320. state['editRef'].showEdit(
  321. {
  322. tuisong: state.tuisong,
  323. list: state.list,
  324. flowId: state.flowId,
  325. type: type,
  326. },
  327. index
  328. )
  329. }
  330. //添加推送人员
  331. const pushPersonnel = () => {
  332. state['addRef'].showEdit({
  333. tuisong: state.tuisong,
  334. list: state.list,
  335. flowId: state.flowId,
  336. type: 6,
  337. })
  338. }
  339. const handleEdit = (row) => {
  340. if (row.id) {
  341. state['addRef'].showEdit(row)
  342. } else {
  343. state['addRef'].showEdit()
  344. }
  345. }
  346. //删除推送步骤
  347. const deletePush = () => {
  348. $baseConfirm('你确定要删除当前推送人员吗', null, async () => {
  349. state.tuisong = []
  350. })
  351. }
  352. //删除当前步骤
  353. const deleteStep = (index, type) => {
  354. console.log(state.tuisong, '-------', state.totalList)
  355. $baseConfirm('你确定要删除当前审核步骤吗吗', null, async () => {
  356. const arr = []
  357. let node = []
  358. if (type == 2) {
  359. state.list.map((item, index1) => {
  360. if (index1 !== index) {
  361. arr.push(item)
  362. }
  363. })
  364. state.list = arr
  365. node = state.list.concat(state.tuisong)
  366. }
  367. if (type == 6) {
  368. //删除推送
  369. node = state.totalList.filter((item) => {
  370. return item.type !== type
  371. })
  372. state.show = true
  373. }
  374. console.log(node, 'ppppp'), 'pppp'
  375. const { message } = await doAdd({
  376. flow_id: state.flowId,
  377. nodes: node,
  378. })
  379. $baseMessage(message, 'success', 'vab-hey-message-success')
  380. await getFlow()
  381. })
  382. }
  383. //删除当前审核人员
  384. const deletePeople = () => {}
  385. onMounted(() => {})
  386. return {
  387. ...toRefs(state),
  388. handleEdit,
  389. addCheck,
  390. deleteStep,
  391. pushPersonnel,
  392. deletePeople,
  393. deletePush,
  394. editCheck,
  395. getFlow,
  396. getflowId,
  397. baseConfig,
  398. Plus,
  399. Search,
  400. Refresh,
  401. Delete,
  402. Minus,
  403. Avatar,
  404. Download,
  405. CirclePlus,
  406. }
  407. },
  408. })
  409. </script>
  410. <style lang="scss" scoped>
  411. .title {
  412. display: flex;
  413. align-items: center; /*垂直居中*/
  414. h3 {
  415. flex: 1;
  416. }
  417. }
  418. .line {
  419. display: flex;
  420. align-items: center; /*垂直居中*/
  421. }
  422. .empty {
  423. text-align: center;
  424. }
  425. .empty-text {
  426. color: red;
  427. margin-bottom: 50px;
  428. font-weight: 550;
  429. }
  430. </style>