1
0

edit.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <div class="cmain">
  3. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  4. <el-form-item label="标题" prop="title">
  5. <el-input v-model="form.title" placeholder="请输入标题" clearable/>
  6. </el-form-item>
  7. <el-form-item label="介绍" prop="context">
  8. <editor v-model="form.context" :min-height="192"/>
  9. </el-form-item>
  10. </el-form>
  11. <div class="mfooter">
  12. <el-button type="primary" @click="submitForm">确 定</el-button>
  13. <el-button @click="$layer.close(layerid)">取 消</el-button>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. form: {},
  22. rules: {
  23. }
  24. };
  25. },
  26. props: {
  27. param: {
  28. type: Object,
  29. default: () => {
  30. return {};
  31. }
  32. },
  33. layerid: {
  34. type: String
  35. }
  36. },
  37. mounted() {
  38. if (this.param.id) {
  39. this.ajax({ url: '/work/introduction/detail/' + this.param.id }).then(response => {
  40. this.form = response.data;
  41. });
  42. }
  43. },
  44. methods: {
  45. submitForm() {
  46. this.$refs["form"].validate(valid => {
  47. if (valid) {
  48. if (this.form.id) {
  49. this.ajax({method: 'post',url: '/work/introduction/edit', data: this.form }).then(response => {
  50. this.$modal.msgSuccess("修改成功");
  51. this.$layer.close(this.layerid);
  52. this.$parent.getList();
  53. });
  54. } else {
  55. this.ajax({method: 'post',url: '/work/introduction/add', data: this.form }).then(response => {
  56. this.$modal.msgSuccess("新增成功");
  57. this.$layer.close(this.layerid);
  58. this.$parent.getList();
  59. });
  60. }
  61. }
  62. });
  63. }
  64. }
  65. };
  66. </script>