index.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. { label: '店铺二维码', model: 'qrcode', type: 'upload', url: '/files/point/shopFile/upload' },
  28. ],
  29. rules: {},
  30. form: {},
  31. };
  32. },
  33. computed: {
  34. ...mapState(['user']),
  35. },
  36. created() {
  37. this.search();
  38. },
  39. methods: {
  40. ...selfShop(['getInfo']),
  41. ...shop(['update']),
  42. //执行查询
  43. async search() {
  44. const res = await this.getInfo();
  45. if (this.$checkRes(res)) {
  46. this.$set(this, `form`, res.data);
  47. }
  48. },
  49. async toSave({ data }) {
  50. const res = await this.update(data);
  51. this.$checkRes(res, '操作成功', '操作失败');
  52. },
  53. },
  54. metaInfo() {
  55. return { title: this.$route.meta.title };
  56. },
  57. };
  58. </script>
  59. <style lang="less" scoped></style>