detail.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <sc-dialog v-model="visible" width="80%" top="13vh" @closed="$emit('closed')">
  3. <template v-slot:header>
  4. <el-tabs v-model="activeName" @tab-change="$refs.planTracking.getToken()">
  5. <el-tab-pane label="计划信息" name="purchase_plan"></el-tab-pane>
  6. <el-tab-pane v-if="form.processInstanceId" label="流程跟踪" name="purchase_plan_tracking"></el-tab-pane>
  7. </el-tabs>
  8. </template>
  9. <el-tabs v-model="activeName">
  10. <el-tab-pane name="purchase_plan">
  11. <scPlan ref="scPlan" :id="form.id" :lg="12" :disabled="!showFooter"></scPlan>
  12. </el-tab-pane>
  13. <el-tab-pane v-if="form.processInstanceId" name="purchase_plan_tracking">
  14. <tracking ref="planTracking" :processInstanceId="form.processInstanceId"></tracking>
  15. </el-tab-pane>
  16. </el-tabs>
  17. <template v-if="showFooter" #footer>
  18. <el-button @click="visible = false">取 消</el-button>
  19. <el-button type="primary" :loading="isSaveing" @click="validateForm(mode)">保 存</el-button>
  20. <el-button type="primary" :loading="isSaveing" @click="validateForm('saveApprove')">提 交</el-button>
  21. </template>
  22. </sc-dialog>
  23. <approve-iframe v-if="popoverShow" ref="approveIframe" @success="approve" @closed="popoverShow = false"></approve-iframe>
  24. </template>
  25. <script>
  26. import scPlan from "@/components/scChengTou/purchase/plan";
  27. import Tracking from "@/components/scChengTou/purchase/tracking";
  28. export default {
  29. emits: ["success", "closed"],
  30. components: {
  31. scPlan,
  32. Tracking
  33. },
  34. data() {
  35. return {
  36. mode: "add",
  37. visible: false,
  38. isSaveing: false,
  39. popoverShow: false,
  40. activeName: "purchase_plan",
  41. form: {}
  42. }
  43. },
  44. computed: {
  45. showFooter() {
  46. return !this.form.status || this.form.status == "active";
  47. }
  48. },
  49. methods: {
  50. // 显示
  51. open(mode = "add") {
  52. this.mode = mode;
  53. this.visible = true;
  54. return this;
  55. },
  56. // 表单注入数据
  57. setData({ id, status, processTaskId, processInstanceId }) {
  58. this.form["id"] = id;
  59. this.form["status"] = status;
  60. this.form["processTaskId"] = processTaskId;
  61. this.form["processInstanceId"] = processInstanceId;
  62. },
  63. // 表单提交方法
  64. validateForm(mode) {
  65. this.$refs.scPlan.$refs.dialogForm.validate(valid => {
  66. if (valid) {
  67. if (mode == "saveApprove") {
  68. if (!this.form.status) {
  69. this.popoverShow = true;
  70. this.$nextTick(() => this.$refs.approveIframe.open("purchase_plan").setData());
  71. } else this.submit("resubmit");
  72. } else this.submit(mode);
  73. } else {
  74. return false;
  75. }
  76. });
  77. },
  78. submit(mode, templateId) {
  79. const data = Object.assign({}, this.$refs.scPlan.form);
  80. if (templateId) data["templateId"] = templateId;
  81. if (mode == "resubmit") data["processTaskId"] = this.form.processTaskId;
  82. this.isSaveing = true;
  83. this.$API.procurement.plan[mode](data).then(() => {
  84. this.isSaveing = false;
  85. this.$message.success("操作成功");
  86. this.visible = false;
  87. this.$emit("success", mode);
  88. }).catch(() => this.isSaveing = false);
  89. },
  90. approve(data) {
  91. this.submit("saveApprove", data.processDefinitionId || null);
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss" scoped>
  97. .sc-dialog:deep(.el-dialog) {
  98. .el-dialog__header {
  99. padding: 0;
  100. &::after {
  101. display: none;
  102. }
  103. .sc-dialog__headerbtn button {
  104. margin-left: 0;
  105. }
  106. .el-tabs {
  107. flex-basis: 100%;
  108. --el-tabs-header-height: 50px;
  109. .el-tabs__header {
  110. margin-bottom: 0;
  111. .el-tabs__nav-wrap::after {
  112. height: 1px;
  113. }
  114. .el-tabs__item {
  115. padding-bottom: 10px;
  116. }
  117. }
  118. .el-tabs__content {
  119. display: none;
  120. }
  121. }
  122. }
  123. .el-dialog__body {
  124. padding-bottom: 0;
  125. .el-tabs .el-tabs__header {
  126. display: none;
  127. }
  128. }
  129. }
  130. </style>