index.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <div id="index">
  3. <data-form :span="12" :fields="fields" :rules="rules" v-model="form" labelWidth="150px" @save="toSave">
  4. <template #status>
  5. <el-option v-for="i in statusList" :key="i.model" :label="i.label" :value="i.value"></el-option>
  6. </template>
  7. </data-form>
  8. </div>
  9. </template>
  10. <script>
  11. import { mapState, createNamespacedHelpers } from 'vuex';
  12. const { mapActions: selfShop } = createNamespacedHelpers('selfShop');
  13. const { mapActions: shop } = createNamespacedHelpers('shop');
  14. export default {
  15. name: 'index',
  16. props: {},
  17. components: {},
  18. data: function () {
  19. return {
  20. fields: [
  21. { label: '店铺logo', model: 'logo', type: 'upload', limit: 1, url: '/files/point/shopLogo/upload' },
  22. { label: '商店名称', model: 'name' },
  23. { label: '店主', model: 'person' },
  24. { label: '联系电话', model: 'phone' },
  25. { label: '地址', model: 'address' },
  26. { label: '证件照片', model: 'file', type: 'upload', url: '/files/point/shopFile/upload' },
  27. ],
  28. rules: {},
  29. form: {},
  30. };
  31. },
  32. computed: {
  33. ...mapState(['user']),
  34. },
  35. created() {
  36. this.search();
  37. },
  38. methods: {
  39. ...selfShop(['getInfo']),
  40. ...shop(['update']),
  41. //执行查询
  42. async search() {
  43. const res = await this.getInfo();
  44. if (this.$checkRes(res)) {
  45. this.$set(this, `form`, res.data);
  46. }
  47. },
  48. async toSave({ data }) {
  49. const res = await this.update(data);
  50. this.$checkRes(res, '操作成功', '操作失败');
  51. },
  52. },
  53. metaInfo() {
  54. return { title: this.$route.meta.title };
  55. },
  56. };
  57. </script>
  58. <style lang="less" scoped></style>