index.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <div id="goods">
  3. <template v-if="view === 'list'">
  4. <data-table ref="dataTable" :fields="fields" :opera="opera" :data="list" :total="total" :limit="limit" @query="search" @edit="toEdit"></data-table>
  5. </template>
  6. <template v-else>
  7. <el-row>
  8. <el-col :span="24">
  9. <el-button icon="el-icon-back" size="mini" @click="toBack()">返回</el-button>
  10. </el-col>
  11. <el-col :span="24">
  12. <data-form :fields="infoFields" :rules="rules" v-model="form" labelWidth="150px" @save="toSave"> </data-form>
  13. </el-col>
  14. </el-row>
  15. </template>
  16. </div>
  17. </template>
  18. <script>
  19. const _ = require('lodash');
  20. import methodsUtil from '@/util/opera';
  21. import { mapState, createNamespacedHelpers } from 'vuex';
  22. const { mapActions } = createNamespacedHelpers('serviceContact');
  23. export default {
  24. name: 'index',
  25. props: {},
  26. components: {},
  27. data: function () {
  28. return {
  29. view: 'list',
  30. fields: [
  31. { label: '联系电话', model: 'phone' },
  32. { label: '微信', model: 'wx' },
  33. { label: 'QQ', model: 'qq' },
  34. { label: '邮箱', model: 'email' },
  35. ],
  36. opera: [{ label: '修改', method: 'edit' }],
  37. list: [],
  38. total: 0,
  39. limit: 10,
  40. // info部分
  41. infoFields: [
  42. { label: '联系电话', model: 'phone' },
  43. { label: '微信', model: 'wx' },
  44. { label: 'QQ', model: 'qq' },
  45. { label: '邮箱', model: 'email' },
  46. ],
  47. rules: {},
  48. form: {},
  49. };
  50. },
  51. created() {
  52. this.searchOthers();
  53. this.search();
  54. },
  55. methods: {
  56. ...mapActions(['query', 'delete', 'fetch', 'update', 'create']),
  57. ...methodsUtil,
  58. async search({ skip = 0, limit = this.limit, ...info } = {}) {
  59. const res = await this.query({ skip, limit, ...info });
  60. if (this.$checkRes(res)) {
  61. console.log(res);
  62. this.$set(this, `list`, res.data);
  63. this.$set(this, `total`, res.total);
  64. }
  65. },
  66. async searchOthers() {},
  67. },
  68. };
  69. </script>
  70. <style lang="less" scoped></style>