index.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <script>
  2. import { submit } from "@/api/expend/customerExpend";
  3. export default {
  4. name: "OpenOrClose",
  5. props: {
  6. selectData: {
  7. type: Array,
  8. default: () => [],
  9. },
  10. },
  11. data() {
  12. return {
  13. title: "提交",
  14. loading: false,
  15. };
  16. },
  17. computed: {
  18. disabled: {
  19. get() {
  20. const { selectData } = this;
  21. if (selectData.length < 1) {
  22. return true;
  23. }
  24. return false;
  25. },
  26. set() {},
  27. },
  28. },
  29. methods: {
  30. //提交
  31. useClick() {
  32. if(this.selectData.length != 1){
  33. this.$modal.msgWarning("请选择一条数据进行提交!");
  34. return;
  35. }
  36. let that = this;
  37. this.$modal.confirm('确认提交吗?').then(async function() {
  38. that.loading = true;
  39. return await submit(that.selectData[0]);
  40. }).then(() => {
  41. that.$modal.msgSuccess("提交成功");
  42. that.loading = false;
  43. }).catch(() => {
  44. that.loading = false;
  45. });
  46. },
  47. },
  48. created() {},
  49. };
  50. </script>
  51. <template>
  52. <el-button v-loading="loading" @click="useClick" :disabled="disabled" v-bind="$attrs">{{
  53. title
  54. }}</el-button>
  55. </template>