index.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <script>
  2. import { TERMINATION } from "@/api/business/purchase/contract";
  3. export default {
  4. name: "TerminationDialog",
  5. props: {
  6. selectData: {
  7. type: [Array],
  8. require: true,
  9. },
  10. },
  11. data() {
  12. return {
  13. title: "终 止",
  14. visible: false,
  15. loading: false,
  16. };
  17. },
  18. computed: {
  19. disabled: {
  20. get() {
  21. if (this.selectData.length === 1) {
  22. const [{ status }] = this.selectData;
  23. if (status !== "2") {
  24. return true;
  25. } else {
  26. return false;
  27. }
  28. } else {
  29. return true;
  30. }
  31. },
  32. set() {},
  33. },
  34. },
  35. watch: {},
  36. methods: {
  37. //
  38. open() {
  39. this.visible = true;
  40. },
  41. //
  42. hide() {
  43. this.visible = false;
  44. },
  45. //
  46. async submit(prop) {
  47. try {
  48. // try
  49. this.loading = true;
  50. const { msg, code } = await TERMINATION({ id: prop });
  51. if (code === 200) {
  52. this.hide();
  53. this.$emit("success");
  54. this.$notify.success(msg);
  55. }
  56. } catch (err) {
  57. // catch
  58. console.error(err);
  59. } finally {
  60. // finally
  61. this.loading = false;
  62. }
  63. },
  64. },
  65. created() {},
  66. mounted() {},
  67. destroyed() {},
  68. };
  69. </script>
  70. <template>
  71. <el-button
  72. v-bind="$attrs"
  73. v-on="$listeners"
  74. :disabled="disabled"
  75. @click="open"
  76. >
  77. {{ title }}
  78. <el-dialog
  79. :title="title"
  80. :visible.sync="visible"
  81. width="25%"
  82. append-to-body
  83. @close="hide"
  84. >
  85. <div slot="footer">
  86. <el-button
  87. :size="$attrs.size"
  88. :loading="loading"
  89. @click="visible = false"
  90. >取 消</el-button
  91. >
  92. <el-button
  93. type="primary"
  94. :size="$attrs.size"
  95. :loading="loading"
  96. @click="submit(selectData[0].id)"
  97. >确 认</el-button
  98. >
  99. </div>
  100. <el-alert title="是否终止数据项?" type="info" show-icon :closable="false">
  101. </el-alert>
  102. </el-dialog>
  103. </el-button>
  104. </template>