indexDis.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <div class="inline-16">
  3. <el-button :type="btnType?btnType:'text'" size="mini" @click="open" :disabled="disabled">{{$t(btnTitle?btnTitle:'删除')}}</el-button>
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. name: "index",
  9. props:['btnType','btnTitle','message','confirmButtonText','cancelButtonText','isNumber','nameId','nameKey','id','disabled'],
  10. data() {
  11. return {
  12. param: {
  13. id: this.nameId,
  14. content: {
  15. // "sa_contractid": this.$route.query.id,
  16. [this.nameKey]: [this.id],
  17. },
  18. },
  19. };
  20. },
  21. methods:{
  22. open() {
  23. this.$confirm(this.$t(this.message), this.$t('提示'), {
  24. confirmButtonText: this.$t(this.confirmButtonText?this.confirmButtonText:'确定'),
  25. cancelButtonText: this.$t(this.cancelButtonText?this.cancelButtonText:'取消'),
  26. type: 'warning'
  27. }).then(() => {
  28. this.onDel()
  29. }).catch(() => {
  30. this.$message({
  31. type: 'info',
  32. message: this.$t('已取消删除')
  33. });
  34. });
  35. },
  36. async onDel(){
  37. this.param.content[this.nameKey] = this.isNumber ? this.id : [this.id];
  38. const res = await this.$api.requested(this.param)
  39. this.tool.showMessage(res, () => {
  40. this.$emit("deleteSuccess");
  41. });
  42. }
  43. }
  44. }
  45. </script>
  46. <style scoped>
  47. </style>