merchant.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <div class="app-container" v-loading="loading">
  3. <FilterList :readOnly="false" v-if="tableData" :pagination="true" :options="options" :operate="false"
  4. :filed="listFileds" :tableData="tableData" :total="total" @query="query" @edit="listEdit" @delete="listDel"
  5. @add="add">
  6. <template v-slot:tablesOperate="{ scope }">
  7. <el-button type="text" size="mini" @click="listRecord(scope.row)">记录</el-button>
  8. <el-button type="text" size="mini" @click="listEdit(scope.row)">修改</el-button>
  9. <el-button type="text" size="mini" @click="listDel(scope.row)">删除</el-button>
  10. </template>
  11. </FilterList>
  12. <el-dialog :title="dialogInfo.title" :visible.sync="dialogInfo.dialogVisible" :width="dialogInfo.width">
  13. <dynamicForm :readOnly="readOnly" ref="dynamicForm" v-if="formFiled && dialogInfo.dialogVisible" :filed="formFiled"
  14. :data="formData" @save="formSave"></dynamicForm>
  15. </el-dialog>
  16. </div>
  17. </template>
  18. <script>
  19. // 商户管理
  20. import _ from 'lodash';
  21. import { businessAdd, businessUpdate, businessDel, businessQuery, businessFetch } from "@/api/communityGovernance/merchant";
  22. export default {
  23. name: "merchant",
  24. dicts: [],
  25. data() {
  26. return {
  27. tableData: [],
  28. total: 0,
  29. listFileds: [
  30. { label: "商户名称", name: "name", filter: true },
  31. { label: "负责人", name: "responsible", filter: true },
  32. { label: "联系电话", name: "phone", filter: true },
  33. { label: "评分", name: "point" },
  34. ],
  35. dialogInfo: {
  36. title: "",
  37. dialogVisible: false,
  38. width: "50%",
  39. },
  40. formFiled: [
  41. { label: "门店照片", name: "image", formater: "imageUpload" },
  42. { label: "商户名称", name: "name" },
  43. { label: "负责人", name: "responsible" },
  44. { label: "联系电话", name: "phone" },
  45. { label: "详细描述", name: "description", formater: 'editor' },
  46. ],
  47. formData: {},
  48. loading: false,
  49. operation: [],
  50. options: {
  51. width: '180'
  52. },
  53. readOnly: false
  54. };
  55. },
  56. async created() {
  57. this.query();
  58. },
  59. methods: {
  60. // 列表查询
  61. async query(e) {
  62. this.loading = true;
  63. const res = await businessQuery({ ...e, pageNum: e?.pageNum ?? 1, pageSize: e?.pageSize ?? 10 });
  64. if (res.code == 200) {
  65. this.tableData = res.rows.map(j => ({ ...j, point: j.point ?? '无' }));
  66. this.total = res.total;
  67. }
  68. this.loading = false;
  69. },
  70. // 列表修改
  71. async listEdit(e) {
  72. // this.readOnly = true;
  73. this.loading = true;
  74. const res = await businessFetch(e.id);
  75. if (res.code == 200) {
  76. this.formData = res.data;
  77. this.dialogInfo.title = `修改商户`;
  78. this.dialogInfo.dialogVisible = true;
  79. }
  80. this.loading = false;
  81. },
  82. // 列表删除
  83. async listDel(e) {
  84. this.$modal.confirm('是否确认删除"').then(function () {
  85. return businessDel([e.id]);
  86. }).then(() => {
  87. this.query();
  88. this.$modal.msgSuccess('删除成功');
  89. }).catch(() => { });
  90. },
  91. // 添加
  92. async add() {
  93. this.readOnly = false;
  94. this.formData = {};
  95. this.dialogInfo.title = `添加商户`;
  96. this.dialogInfo.dialogVisible = true;
  97. },
  98. // 列表查看评分记录
  99. async listRecord(e) {
  100. console.log(e);
  101. this.$router.push(`/communityGovernance/community_governance_record?id=${e.id}`);
  102. },
  103. // 表单保存
  104. async formSave(e) {
  105. this.loading = true;
  106. let res;
  107. // 修改
  108. if (e.id) res = await businessUpdate(e);
  109. // 新增
  110. if (!e.id) res = await businessAdd(e);
  111. if (res.code == 200) {
  112. this.$modal.msgSuccess(`${e.id ? '修改' : '新增'}成功`);
  113. this.dialogInfo.dialogVisible = false;
  114. this.query();
  115. }
  116. this.loading = false;
  117. },
  118. }
  119. };
  120. </script>