家政小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

edit.vue 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <style lang="less">
  2. </style>
  3. <template>
  4. <div>
  5. <Row>
  6. <Col span="18">
  7. <Card>
  8. <Form :label-width="80">
  9. <FormItem label="产品名称">
  10. <Input v-model="form.name" icon="android-list"/>
  11. </FormItem>
  12. <FormItem label="产品款色">
  13. <Input v-model="form.color" icon="android-list"/>
  14. </FormItem>
  15. <FormItem label="产品价格">
  16. <Input v-model="form.price" icon="android-list"/>
  17. </FormItem>
  18. <FormItem label="产品分类">
  19. <Select v-model="form.classify">
  20. <Option v-for="classify in classifys" :value="classify" :key="classify">{{classify}}</Option>
  21. </Select>
  22. <!-- <Input v-model="form.classify" icon="android-list"/> -->
  23. </FormItem>
  24. <FormItem label="产品状态">
  25. <Select v-model="form.status" style="width: 150px">
  26. <Option :value="0">上架</Option>
  27. <Option :value="1">下架</Option>
  28. </Select>
  29. </FormItem>
  30. <FormItem label="产品信息">
  31. <editor :editor-content="form.info"></editor>
  32. </FormItem>
  33. </Form>
  34. <div class="submit">
  35. <Button @click="handlePublish" :loading="publishLoading" icon="ios-checkmark" size="large" type="primary">发布</Button>
  36. </div>
  37. </Card>
  38. </Col>
  39. </Row>
  40. </div>
  41. </template>
  42. <script>
  43. import tinymce from 'tinymce';
  44. import editor from '../main-components/editor'
  45. export default {
  46. name: 'edit',
  47. components: {
  48. editor
  49. },
  50. props: {
  51. formContent: Object
  52. },
  53. watch: {
  54. formContent() {
  55. if (!this.formContent.status) {
  56. this.formContent.status = 0;
  57. }
  58. this.form = this.formContent;
  59. }
  60. },
  61. data () {
  62. return {
  63. form: this.formContent,
  64. publishLoading: false,
  65. classifys: []
  66. };
  67. },
  68. methods: {
  69. handlePublish() {
  70. if (true) {
  71. this.publishLoading = true;
  72. let info = tinymce.activeEditor.getContent();
  73. let data = {
  74. name: this.form.name,
  75. info: info,
  76. color: this.form.color,
  77. price: parseFloat(this.form.price),
  78. classify: this.form.classify,
  79. status: this.form.status
  80. };
  81. if (this.form.id) {
  82. data.id = this.form.id;
  83. }
  84. this.axios.post("/product/store", data).then((res) => {
  85. if (res.data.status == 0) {
  86. this.$Message.success('操作成功!');
  87. this.publishLoading = false;
  88. setTimeout(() => {
  89. this.$emit("pub-success");
  90. }, 1000);
  91. }
  92. });
  93. } else {
  94. this.$Message.error('请完善所有信息!');
  95. this.publishLoading = false;
  96. }
  97. },
  98. getData() {
  99. this.axios.get("/product_classify")
  100. .then((res) => {
  101. this.classifys = res.data.data;
  102. });
  103. }
  104. },
  105. mounted() {
  106. this.getData();
  107. }
  108. };
  109. </script>