index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <div id="index">
  3. <data-form :span="24" :fields="fields" :rules="rules" v-model="form" labelWidth="150px" @save="toSave">
  4. <template #buyPoint>
  5. <el-input v-model="form.buyPoint" type="number" placeholder="请输入购物赠送积分"></el-input>
  6. <p style="color: #999">金额:积分=10:1</p>
  7. </template>
  8. <template #autoCloseOrder>
  9. <el-input v-model="form.autoCloseOrder" type="number" placeholder="请输入自动关闭订单时间"></el-input>
  10. <p style="color: #999">关闭订单时间小于等于0时不自动关闭</p>
  11. </template>
  12. <template #agree>
  13. <editor v-model="form.agree" url="/files/point/config/upload" />
  14. </template>
  15. <template #bottom_menu>
  16. <data-form :span="24" :fields="testfields" v-model="form.bottom_menu" labelWidth="auto" :isSave="false"> </data-form>
  17. </template>
  18. </data-form>
  19. </div>
  20. </template>
  21. <script>
  22. import { mapState, createNamespacedHelpers } from 'vuex';
  23. const { mapActions: config } = createNamespacedHelpers('config');
  24. const { mapActions: dictData } = createNamespacedHelpers('dictData');
  25. export default {
  26. name: 'index',
  27. props: {},
  28. components: { editor: () => import('@/components/editor.vue') },
  29. data: function () {
  30. return {
  31. fields: [
  32. { label: '系统名称', model: 'title' },
  33. { label: 'logo', model: 'logo', type: 'upload', limit: 1, url: '/files/point/config/upload' },
  34. { label: '购物赠送积分', model: 'buyPoint', custom: true },
  35. { label: '自动关闭订单时间', model: 'autoCloseOrder', custom: true },
  36. // { label: '积分计划', model: 'pointPlan' },
  37. { label: '底部文字', model: 'bottom_title' },
  38. { label: '底部菜单', model: 'bottom_menu', custom: true },
  39. { label: '分享图片', model: 'share', type: 'upload', limit: 1, url: '/files/point/config/upload' },
  40. { label: '用户协议', model: 'agree', custom: true },
  41. ],
  42. rules: {},
  43. form: { bottom_menu: {} },
  44. testfields: [
  45. { label: '是否使用', model: 'is_use' },
  46. { label: '菜单列表', model: 'list' },
  47. ],
  48. };
  49. },
  50. computed: {
  51. ...mapState(['user']),
  52. },
  53. async created() {
  54. await this.searchOther();
  55. await this.search();
  56. },
  57. methods: {
  58. ...config(['query', 'fetch', 'update']),
  59. ...dictData({ dictQuery: 'query' }),
  60. //执行查询
  61. async search() {
  62. const res = await this.fetch();
  63. if (this.$checkRes(res)) {
  64. this.$set(this, `form`, res.data);
  65. if (this.form.config) {
  66. this.form = {
  67. ...this.form,
  68. logo: this.form.config.logo,
  69. buyPoint: this.form.config.buyPoint,
  70. pointPlan: this.form.config.pointPlan,
  71. share: this.form.config.share,
  72. autoCloseOrder: this.form.config.autoCloseOrder,
  73. };
  74. }
  75. if (!this.form.bottom_menu) {
  76. console.log('1');
  77. }
  78. }
  79. },
  80. async toSave({ data }) {
  81. let config = { logo: data.logo, buyPoint: data.buyPoint, pointPlan: data.pointPlan, share: data.share, autoCloseOrder: data.autoCloseOrder };
  82. data.config = config;
  83. const res = await this.update(data);
  84. this.$checkRes(res, '操作成功', '操作失败');
  85. },
  86. // 查询其他信息
  87. async searchOther() {
  88. let res;
  89. // 是否使用
  90. // res = await this.dictQuery({ code: 'use' });
  91. // if (this.$checkRes(res)) {
  92. // this.$set(this, `useList`, res.data);
  93. // }
  94. },
  95. },
  96. metaInfo() {
  97. return { title: this.$route.meta.title };
  98. },
  99. };
  100. </script>
  101. <style lang="less" scoped></style>