prodTemplateSeries-add-or-update.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <el-dialog
  3. :title="!dataForm.seriesId ? this.$i18n.t('crud.addTitle') : this.$i18n.t('temp.modify')"
  4. :close-on-click-modal="false"
  5. :visible.sync="visible">
  6. <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
  7. <el-form-item label="系列名称" prop="seriesName">
  8. <el-input v-model="dataForm.seriesName"></el-input>
  9. </el-form-item>
  10. <el-form-item label="排序" prop="seq">
  11. <el-input v-model="dataForm.seq" type="number"></el-input>
  12. </el-form-item>
  13. </el-form>
  14. <span slot="footer" class="dialog-footer">
  15. <el-button class="default-btn" @click="visible = false">{{$t("crud.filter.cancelBtn")}}</el-button>
  16. <el-button class="default-btn primary-btn" type="primary" @click="dataFormSubmit()">{{$t("crud.filter.submitBtn")}}</el-button>
  17. </span>
  18. </el-dialog>
  19. </template>
  20. <script>
  21. export default {
  22. data () {
  23. return {
  24. visible: false,
  25. dataForm: {
  26. seriesId: null,
  27. seriesName: null,
  28. shopId: this.$store.state.user.shopId
  29. },
  30. dataRule: {
  31. }
  32. }
  33. },
  34. methods: {
  35. init (seriesId) {
  36. this.dataForm.seriesId = seriesId || 0
  37. this.visible = true
  38. this.$nextTick(() => {
  39. this.$refs['dataForm'].resetFields()
  40. if (this.dataForm.seriesId) {
  41. this.$http({
  42. url: this.$http.adornUrl('/prod/prodTemplateSeries/info/' + this.dataForm.seriesId),
  43. method: 'get',
  44. params: this.$http.adornParams()
  45. }).then(({data}) => {
  46. this.dataForm = data
  47. })
  48. }
  49. })
  50. },
  51. // 表单提交
  52. dataFormSubmit () {
  53. this.$refs['dataForm'].validate((valid) => {
  54. if (valid) {
  55. this.$http({
  56. url: this.$http.adornUrl('/prod/prodTemplateSeries'),
  57. method: this.dataForm.seriesId ? 'put' : 'post',
  58. data: this.$http.adornData(this.dataForm)
  59. }).then(({data}) => {
  60. this.$message({
  61. message: this.$i18n.t('publics.operation'),
  62. type: 'success',
  63. duration: 1500,
  64. onClose: () => {
  65. this.visible = false
  66. this.$emit('refreshDataList')
  67. }
  68. })
  69. })
  70. }
  71. })
  72. }
  73. }
  74. }
  75. </script>