index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. <template>
  2. <div class="processApproval">
  3. <div class="left-card">
  4. <div class="top">
  5. <div class="commons-title title">
  6. {{
  7. route.query.flowName
  8. ? route.query.flowName + (route.query.processType ? typeName[route.query.processType] : "(发起)")
  9. : keyName[route.query.flowKey] + "(审批)"
  10. }}
  11. </div>
  12. <div class="line"></div>
  13. <Subscribe :queryData="detailsData.data" v-if="route.query.flowKey == 'apply_buy'" ref="makeDom"></Subscribe>
  14. <Purchase :queryData="detailsData.data" v-else-if="route.query.flowKey == 'purchase'" ref="makeDom"></Purchase>
  15. </div>
  16. <div class="bottom" v-if="route.query.processType != 20">
  17. <div class="commons-title title">处理意见</div>
  18. <el-form :model="flowForm" :rules="flowRules" ref="flowFormDom">
  19. <el-form-item prop="remark" label-width="0px" label="">
  20. <el-input type="textarea" placeholder="请输入" v-model="flowForm.remark"> </el-input>
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button type="primary" v-if="!route.query.processType || ['30', '40'].includes(route.query.processType)" @click="handleSaveDraft" v-preReClick>
  24. 保存草稿
  25. </el-button>
  26. <el-button type="primary" v-if="approvalRecordData.buttonInfoList.length == 0" @click="handleSubmit" v-preReClick>提交</el-button>
  27. <el-button type="primary" v-else v-for="i in approvalRecordData.buttonInfoList" :key="i.type" @click="handleSubmit(i.type)" v-preReClick>
  28. {{ i.name }}
  29. </el-button>
  30. </el-form-item>
  31. </el-form>
  32. </div>
  33. </div>
  34. <div class="right-card">
  35. <el-tabs v-model="activeName" class="demo-tabs">
  36. <el-tab-pane label="审批记录" name="first">
  37. <ul class="flow-chart">
  38. <li
  39. v-for="item in recordList"
  40. :key="item.id"
  41. :class="
  42. !route.query.flowId
  43. ? ''
  44. : item.status == 2
  45. ? 'flow-orange'
  46. : item.status == 3 && !route.query.flowId
  47. ? 'flow-orange'
  48. : item.status == 3 && route.query.flowId
  49. ? 'flow-grey'
  50. : ''
  51. ">
  52. <div class="left-icon">
  53. <i class="iconfont icon-iconm_daick"></i>
  54. <i class="iconfont icon-icomx_quertj1 right-btm-status"></i>
  55. </div>
  56. <div class="right-conetnt">
  57. <div class="name">{{ item.nodeName }}</div>
  58. <div class="remark">
  59. <div class="label">
  60. <span v-if="item.status != 3">办理人:</span>{{ item.processedUser }}<span class="time">{{ item.processedDate }}</span>
  61. </div>
  62. {{ item.remark }}
  63. <div v-for="j in fileObj[item.flowExampleDetailId]" v-if="fileObj[item.flowExampleDetailId]">
  64. <a :href="j.fileUrl" style="color: #409eff; line-height: 30px">{{ j.fileName }}</a>
  65. </div>
  66. </div>
  67. </div>
  68. <div class="line"></div>
  69. </li>
  70. </ul>
  71. </el-tab-pane>
  72. </el-tabs>
  73. </div>
  74. <el-dialog title="下一处理人" width="400" v-model="dialogVisible">
  75. <el-form :model="flowForm">
  76. <el-form-item prop="remark" label="处理人">
  77. <el-select v-model="flowForm.handleUserId" placeholder="请选择" filterable style="width: 100%">
  78. <el-option v-for="item in nextHandleUser" :label="item.name" :value="item.id"> </el-option>
  79. </el-select>
  80. </el-form-item>
  81. <el-form-item>
  82. <div style="width: 100%; text-align: center">
  83. <el-button type="primary" @click="handleSelectUser">提交</el-button>
  84. </div>
  85. </el-form-item>
  86. </el-form>
  87. </el-dialog>
  88. </div>
  89. </template>
  90. <script setup>
  91. import useTagsViewStore from "@/store/modules/tagsView.js";
  92. import { useRouter, useRoute } from "vue-router";
  93. import { ElMessage } from "element-plus";
  94. // 申购单
  95. import Subscribe from "@/components/process/subscribe";
  96. // 采购合同
  97. import Purchase from "@/components/process/purchase";
  98. const typeName = ref({
  99. 10: "(审批)",
  100. 20: "(详情)",
  101. 30: "(发起)",
  102. 40: "(发起)",
  103. });
  104. const keyName = ref({
  105. apply_buy: "申购流程",
  106. purchase: "采购流程",
  107. });
  108. const flowKeyCollect = reactive({
  109. apply_buy: {
  110. backPath: "/group/oa/subscribe",
  111. edit: "/applyBuy/edit",
  112. add: "/applyBuy/add",
  113. detail: "/applyBuy/detail",
  114. },
  115. purchase: {
  116. backPath: "/group/purchase/purchase-contract",
  117. edit: "/purchase/edit",
  118. add: "/purchase/add",
  119. detail: "/purchase/detail",
  120. },
  121. });
  122. const detailsData = reactive({
  123. data: {},
  124. });
  125. const router = useRouter();
  126. const route = useRoute();
  127. // tab切换逻辑
  128. const activeName = ref("first");
  129. // 意见表单
  130. const flowForm = reactive({
  131. flowKey: "",
  132. tenantType: "",
  133. handleUserId: "",
  134. remark: "",
  135. data: {},
  136. fileList: [],
  137. });
  138. const flowRules = reactive({
  139. // remark: [{ required: true, message: "请输入处理意见", trigger: "blur" }],
  140. });
  141. //组件实例
  142. const { proxy } = getCurrentInstance();
  143. const flowFormDom = ref(null);
  144. let dialogVisible = ref(false);
  145. const nextHandleUser = ref([]);
  146. const handleSelectUser = () => {
  147. if (!flowForm.handleUserId) {
  148. return ElMessage({
  149. message: "请选择下一节点处理人!",
  150. type: "info",
  151. });
  152. }
  153. handleSubmit();
  154. };
  155. const handleResult = (res) => {
  156. if (res !== null && res.success) {
  157. skipPage();
  158. } else {
  159. dialogVisible.value = true;
  160. nextHandleUser.value = res.userList;
  161. }
  162. };
  163. // 提交逻辑
  164. const handleSubmit = async (_type) => {
  165. try {
  166. // 调用发起组件的提交事件
  167. const flag = await proxy.$refs.makeDom.handleSubmit();
  168. if (flag) {
  169. flowFormDom.value.validate((valid) => {
  170. if (valid) {
  171. const data = { ...proxy.$refs.makeDom.getFormData() };
  172. if (route.query.processType == "10" || route.query.processType == "30") {
  173. if (_type && _type == 1) {
  174. proxy
  175. .post("/flowExample/setStartData", {
  176. exampleId: route.query.flowId,
  177. startData: data,
  178. })
  179. .then();
  180. }
  181. proxy
  182. .post("/flowProcess/jump", {
  183. ...flowForm,
  184. data,
  185. handleType: _type,
  186. version: route.query.version,
  187. flowId: route.query.flowId,
  188. })
  189. .then((res) => {
  190. handleResult(res);
  191. });
  192. return;
  193. } else {
  194. proxy
  195. .post("/flowProcess/initiate", {
  196. ...flowForm,
  197. data,
  198. })
  199. .then((res) => {
  200. handleResult(res);
  201. });
  202. }
  203. }
  204. });
  205. }
  206. } catch (err) {
  207. console.log("数据未填完整!", err);
  208. }
  209. };
  210. // 页面跳转
  211. const skipPage = () => {
  212. const useTagsStore = useTagsViewStore();
  213. useTagsStore.delVisitedView(router.currentRoute.value);
  214. if (route.query.processType && route.query.processType != "40") {
  215. router.replace({
  216. path: "/oa/1/dealWith",
  217. });
  218. } else {
  219. ElMessage({ message: "操作成功!", type: "success" });
  220. router.replace({
  221. path: flowKeyCollect[route.query.flowKey].backPath,
  222. });
  223. }
  224. };
  225. let queryData = reactive({
  226. data: {},
  227. });
  228. // 记录
  229. const recordList = ref([]);
  230. const fileIds = ref([]);
  231. const fileObj = ref({});
  232. const approvalRecordData = ref({
  233. buttonInfoList: [],
  234. });
  235. const getRecords = (_id) => {
  236. if (_id) {
  237. proxy
  238. .post("/flowExample/getApprovalRecord", {
  239. id: _id,
  240. })
  241. .then((res) => {
  242. recordList.value = res.recordList;
  243. queryData.data.recordList = res.recordList;
  244. approvalRecordData.value = res;
  245. fileIds.value = res.recordList.map((item) => {
  246. return item.flowExampleDetailId;
  247. });
  248. proxy.post("fileInfo/getList", { businessIdList: fileIds.value }).then((res2) => {
  249. fileObj.value = res2;
  250. });
  251. });
  252. } else {
  253. proxy
  254. .post("/flowExample/getFlowNode", {
  255. flowKey: route.query.flowKey,
  256. })
  257. .then((res) => {
  258. recordList.value = res;
  259. });
  260. }
  261. };
  262. const handleSaveDraft = async () => {
  263. const flag = await proxy.$refs.makeDom.handleSubmit();
  264. if (flag) {
  265. let data = proxy.$refs.makeDom.getFormData();
  266. if (data.id) {
  267. proxy.post(flowKeyCollect[route.query.flowKey].edit, data).then(() => {
  268. skipPage();
  269. });
  270. } else {
  271. proxy.post(flowKeyCollect[route.query.flowKey].add, data).then(() => {
  272. skipPage();
  273. });
  274. }
  275. }
  276. };
  277. onMounted(() => {
  278. //processType 10 为修改 20为查看 30回退发起
  279. flowForm.flowKey = route.query.flowKey;
  280. flowForm.tenantType = route.query.tenantType;
  281. if (route.query.random) {
  282. useTagsViewStore().visitedViews = useTagsViewStore().visitedViews.map((item) => {
  283. if (item.query && item.query.random === route.query.random) {
  284. return {
  285. ...item,
  286. name: route.query.flowName,
  287. title: route.query.flowName,
  288. };
  289. } else {
  290. return {
  291. ...item,
  292. };
  293. }
  294. });
  295. }
  296. if (route.query.id) {
  297. proxy.post(flowKeyCollect[route.query.flowKey].detail, { id: route.query.id }).then((res) => {
  298. detailsData.data = { ...res };
  299. });
  300. }
  301. getRecords(route.query.flowId);
  302. });
  303. </script>
  304. <style>
  305. .el-upload-list {
  306. float: left;
  307. margin: 0 !important;
  308. }
  309. .el-upload-list li {
  310. width: 100px;
  311. margin-left: 10px;
  312. }
  313. .el-upload--text {
  314. float: left;
  315. }
  316. </style>
  317. <style lang="scss" scoped>
  318. .processApproval {
  319. display: flex;
  320. justify-content: space-between;
  321. height: calc(100vh - 120px);
  322. .left-card {
  323. border-radius: 4px;
  324. width: calc(100% - 400px - 10px);
  325. margin-right: 10px;
  326. display: flex;
  327. flex-direction: column;
  328. .top {
  329. flex: 1;
  330. overflow-y: auto;
  331. overflow-x: hidden;
  332. background: #fff;
  333. padding: 20px;
  334. .line {
  335. border-bottom: 1px solid #ddd;
  336. margin-bottom: 10px;
  337. }
  338. }
  339. .bottom {
  340. margin-top: 10px;
  341. height: 190px;
  342. background: #fff;
  343. padding: 20px;
  344. overflow-y: auto;
  345. overflow-x: hidden;
  346. }
  347. }
  348. .right-card {
  349. background: #fff;
  350. border-radius: 4px;
  351. padding: 0 20px 20px;
  352. width: 400px;
  353. box-sizing: border-box;
  354. .flow-chart {
  355. overflow-y: auto;
  356. overflow-x: hidden;
  357. height: calc(100vh - 200px);
  358. padding: 0;
  359. margin: 0;
  360. li {
  361. margin: 0;
  362. padding: 0 0 20px;
  363. list-style: none;
  364. display: flex;
  365. justify-content: space-between;
  366. position: relative;
  367. .right-conetnt {
  368. flex: 1;
  369. .name {
  370. font-size: 12px;
  371. color: #39c55a;
  372. margin-bottom: 10px;
  373. span {
  374. color: #999;
  375. }
  376. }
  377. .time {
  378. float: right;
  379. }
  380. .remark {
  381. padding: 10px;
  382. color: #666666;
  383. font-size: 12px;
  384. background: #f1f1f1;
  385. border-radius: 2px;
  386. .label {
  387. color: #999;
  388. margin-bottom: 10px;
  389. }
  390. }
  391. }
  392. .left-icon {
  393. width: 40px;
  394. height: 40px;
  395. text-align: center;
  396. line-height: 40px;
  397. background: #0084ff;
  398. border-radius: 10px;
  399. color: #fff;
  400. font-size: 20px;
  401. position: relative;
  402. margin-right: 27px;
  403. z-index: 2;
  404. .right-btm-status {
  405. position: absolute;
  406. bottom: 0px;
  407. right: -10px;
  408. height: 20px;
  409. width: 20px;
  410. line-height: 16px;
  411. border-radius: 10px;
  412. background: #39c55a;
  413. border: 2px solid #fff;
  414. font-size: 12px;
  415. box-sizing: border-box;
  416. }
  417. }
  418. }
  419. li::before {
  420. content: "";
  421. position: absolute;
  422. top: 0;
  423. left: 20px;
  424. width: 2px;
  425. height: 100%;
  426. background: #ddd;
  427. z-index: 1;
  428. }
  429. li:last-child::before {
  430. display: none;
  431. }
  432. .flow-orange {
  433. .right-btm-status {
  434. background: #ff9a00 !important;
  435. }
  436. .name {
  437. color: #ff9a00 !important;
  438. }
  439. .left-icon {
  440. background: #ff9a00 !important;
  441. }
  442. }
  443. .flow-grey {
  444. .right-btm-status {
  445. background: #999 !important;
  446. }
  447. .name {
  448. color: #999 !important;
  449. }
  450. .left-icon {
  451. background: #999 !important;
  452. }
  453. }
  454. .flow-red {
  455. .right-btm-status {
  456. background: #ff4d4f !important;
  457. }
  458. .name {
  459. color: #ff4d4f !important;
  460. }
  461. .left-icon {
  462. background: #ff4d4f !important;
  463. }
  464. }
  465. }
  466. }
  467. }
  468. </style>