edit.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <div class="add">
  3. <i style="font-weight:bold" class="el-icon-plus" @click="dialogVisible=true" v-if="type=='add'"></i>
  4. <i class="el-icon-edit" @click="editBtn" v-else></i>
  5. <el-dialog
  6. :title="type == 'add' ? '新增营销类别' : '编辑营销类别'"
  7. :visible.sync="dialogVisible"
  8. width="30%"
  9. :before-close="handleClose">
  10. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="130px" class="demo-ruleForm">
  11. <el-form-item label="营销类别名" prop="itemclassname">
  12. <el-input v-model="ruleForm.itemclassname" size="small" placeholder="请输入营销类别名"></el-input>
  13. </el-form-item>
  14. <el-form-item label="营销类别编号" prop="itemclassnum">
  15. <el-input v-model="ruleForm.itemclassnum" :disabled="type!='add'" size="small" placeholder="请输入营销类别编号"></el-input>
  16. </el-form-item>
  17. <!-- <el-form-item label="营销类别全称" prop="itemclassfullname">
  18. <el-input v-model="ruleForm.itemclassfullname" size="small" placeholder="请输入营销类别全称"></el-input>
  19. </el-form-item> -->
  20. </el-form>
  21. <span slot="footer" class="dialog-footer">
  22. <div>
  23. <el-button @click="dialogVisible = false" size="small">取 消</el-button>
  24. <el-button type="primary" @click="submit" size="small">确 定</el-button>
  25. </div>
  26. </span>
  27. </el-dialog>
  28. </div>
  29. </template>
  30. <script>
  31. export default {
  32. name: '',
  33. data() {
  34. return {
  35. currentData:'',
  36. dialogVisible:false,
  37. ruleForm: {
  38. "itemclassnum":'',
  39. "itemclassname":'',
  40. // "itemclassfullname":'',
  41. },
  42. rules:{
  43. itemclassname: [
  44. { required: true, message: '请输入营销类别名', trigger: 'blur' },
  45. ],
  46. itemclassnum: [
  47. { required: true, message: '请输入营销类别编号', trigger: 'blur' },
  48. ],
  49. // itemclassfullname: [
  50. // { required: true, message: '请输入营销类别全称', trigger: 'blur' },
  51. // ],
  52. }
  53. };
  54. },
  55. props:['type','rowData'],
  56. computed:{
  57. },
  58. watch:{
  59. currentData: {
  60. handler(val) {
  61. this.ruleForm.itemclassnum = val.itemclassnum
  62. this.ruleForm.itemclassname = val.itemclassname
  63. // this.ruleForm.itemclassfullname = val.itemclassfullname
  64. }
  65. }
  66. },
  67. methods: {
  68. editBtn() {
  69. this.dialogVisible=true
  70. this.currentData = this.rowData
  71. },
  72. handleClose() {
  73. this.dialogVisible = false
  74. },
  75. submit() {
  76. this.$refs.ruleForm.validate(async val => {
  77. if(val) {
  78. let res = await this.$api.requested({
  79. "accesstoken": "bed2f4500c0e799a29ddbbe47a2a04b6",
  80. "id": "20220922110303",
  81. "version":1,
  82. "content": {
  83. "itemclassid":this.type == 'add' ? 0 : this.rowData.itemclassid,
  84. "sa_brandid":this.rowData.sa_brandid,
  85. "parentid":this.rowData.itemclassid === undefined ? 0 : this.rowData.itemclassid,
  86. "itemclassnum":this.ruleForm.itemclassnum,
  87. "itemclassname":this.ruleForm.itemclassname,
  88. // "itemclassfullname":this.ruleForm.itemclassfullname,
  89. "classtype":"营销"
  90. }
  91. })
  92. this.tool.showMessage(res,() => {
  93. this.$emit('addSuccess')
  94. this.$refs.ruleForm.resetFields()
  95. this.dialogVisible = false
  96. })
  97. }
  98. })
  99. }
  100. },
  101. };
  102. </script>
  103. <style scoped>
  104. .dialog-footer {
  105. display: flex;
  106. justify-content: space-evenly;
  107. }
  108. /deep/.el-dialog__body {
  109. padding-top: 10px !important;
  110. padding-bottom: 0 !important;
  111. }
  112. /deep/.dialog-footer {
  113. margin-top: 10px !important;
  114. }
  115. /deep/.el-select {
  116. width: 100% !important;
  117. }
  118. </style>