add.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <div>
  3. <el-button type="primary" size="small" @click="drawer=true">
  4. {{$t(`新建`)}}
  5. </el-button>
  6. <el-drawer
  7. :title="$t(`新建减速箱`)"
  8. :visible.sync="drawer"
  9. :wrapperClosable="false"
  10. size="664px"
  11. direction="rtl"
  12. append-to-body
  13. :show-close="false">
  14. <div class="drawer__panel">
  15. <customForm ref="form" formname="form" v-if="drawer"></customForm>
  16. </div>
  17. <div class="fixed__btn__panel">
  18. <el-button size="small" @click="drawer = false" class="normal-btn-width">{{$t(`取 消`)}}</el-button>
  19. <el-button size="small" type="primary" @click="onSubmit" :loading="loading" class="normal-btn-width">{{$t(`确 定`)}}</el-button>
  20. </div>
  21. </el-drawer>
  22. </div>
  23. </template>
  24. <script>
  25. import customForm from '@/components/customForm/customForm'
  26. import {mapGetters} from "vuex";
  27. export default {
  28. components:{customForm},
  29. data () {
  30. return {
  31. drawer:false,
  32. type:'',
  33. valvetype:''
  34. }
  35. },
  36. computed:{
  37. ...mapGetters({
  38. loading:'loading'
  39. })
  40. },
  41. watch: {
  42. },
  43. methods:{
  44. onSubmit () {
  45. this.$refs.form.validateFields(()=>{
  46. if (this.$refs.form.form.maxsquarewidth) {
  47. this.$refs.form.form.maxsquarewidth = [this.$refs.form.form.maxsquarewidth]
  48. } else {
  49. this.$refs.form.form.maxsquarewidth = []
  50. }
  51. this.$store.commit('setLoading',true)
  52. this.$api.requested({
  53. id:20240615135802,
  54. content: this.$refs.form.form
  55. }).then(res=>{
  56. this.tool.showMessage(res,() => {
  57. this.$store.dispatch('changeDetailDrawer',true)
  58. this.$router.push({path:'/speedBoxDetail',query:{id:res.data.itemid,rowindex:res.data.rowindex}})
  59. this.drawer = false
  60. this.$emit('onSuccess',res.data)
  61. })
  62. this.$store.commit('setLoading',false)
  63. })
  64. })
  65. },
  66. },
  67. }
  68. </script>
  69. <style scoped>
  70. .dialog-footer{
  71. margin-top:32px;
  72. text-align: center;
  73. }
  74. </style>