index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <container title="店铺管理">
  3. <template v-slot:btn>
  4. <el-button type="primary" @click="handelEdit('')">添加店铺</el-button>
  5. <el-button @click="batchDel">批量删除</el-button>
  6. </template>
  7. <search-box-new
  8. :formData="formData"
  9. :formList="formList"
  10. @search="search"
  11. @init="init"
  12. />
  13. <table-list
  14. ref="tableList"
  15. :tableSets="tableSet"
  16. :tableData="tableData"
  17. :navText="navText"
  18. rowKey="id"
  19. :loading="loading"
  20. >
  21. <template slot="status" slot-scope="props">
  22. <el-switch
  23. v-model="props.scope.row.status"
  24. active-color="#13ce66"
  25. inactive-color="#ff4949"
  26. :active-value="1"
  27. :inactive-value="0"
  28. @change="editStore(props.scope.row.storeId, $event)"
  29. >
  30. </el-switch>
  31. </template>
  32. <template slot="btn" slot-scope="props">
  33. <el-button type="text" @click="handelEdit(props.scope.row.storeId)"
  34. >编辑</el-button
  35. >
  36. <el-button type="text" @click="del(props.scope.row.storeId)"
  37. >删除</el-button
  38. >
  39. </template>
  40. </table-list>
  41. <pagination
  42. :total="total"
  43. :pageSize.sync="formData.pageSize"
  44. :currentPage.sync="formData.pageNum"
  45. @search="search"
  46. />
  47. <Store-set-dlg
  48. :storeId="storeId"
  49. @search="search"
  50. :dialogVisible.sync="dialogVisible"
  51. ></Store-set-dlg>
  52. </container>
  53. </template>
  54. <script>
  55. import StoreSetDlg from "./components/StoreSetDlg.vue";
  56. import { getStoreList, editStore, storeBatchDel } from "../../api/store/index";
  57. export default {
  58. name: "SaasMemberRecord",
  59. data() {
  60. return {
  61. loading: false,
  62. navText: {
  63. index: 0,
  64. num: true,
  65. choice: true,
  66. addHide: true,
  67. openCheckMore: true,
  68. custom: false,
  69. },
  70. formData: {},
  71. tableSet: [
  72. {
  73. label: "店铺简称",
  74. prop: "storeName",
  75. },
  76. {
  77. label: "店铺地址",
  78. prop: "address",
  79. },
  80. {
  81. label: "启动状态",
  82. prop: "status",
  83. scope: "solt",
  84. soltName: "status",
  85. },
  86. {
  87. label: "创建时间",
  88. prop: "createTime",
  89. scope: "aTimeList",
  90. },
  91. ],
  92. tableData: [],
  93. total: 0,
  94. formList: [
  95. {
  96. prop: "storeName",
  97. placeholder: "请输入店铺简称",
  98. },
  99. ],
  100. dialogVisible: false,
  101. storeId: "",
  102. };
  103. },
  104. mounted() {
  105. this.init();
  106. },
  107. methods: {
  108. init() {
  109. this.search(2);
  110. },
  111. search(v) {
  112. if (v === 2) {
  113. this.formData = {
  114. status: "0,1",
  115. pageSize: 10,
  116. pageNum: 1,
  117. storeName: undefined,
  118. };
  119. }
  120. this.loading = true;
  121. getStoreList(this.formData)
  122. .then((res) => {
  123. this.tableData = res.rows;
  124. this.total = res.total;
  125. })
  126. .finally(() => {
  127. this.loading = false;
  128. });
  129. },
  130. del(storeId) {
  131. this.$confirm("确定删除该店铺吗?", "提示", {
  132. confirmButtonText: "确定",
  133. cancelButtonText: "取消",
  134. type: "warning",
  135. })
  136. .then(() => {
  137. this.editStore(storeId, -1);
  138. })
  139. .catch(() => {});
  140. },
  141. editStore(storeId, status) {
  142. editStore({ storeId, status, merId: "1" }).then((res) => {
  143. status == -1 && this.$message.success("删除成功");
  144. this.$store.commit("EDICSTORELIST");
  145. this.search();
  146. });
  147. },
  148. handelEdit(storeId) {
  149. this.storeId = storeId;
  150. this.dialogVisible = true;
  151. },
  152. batchDel() {
  153. let len = this.$refs.tableList.allCheckData.length;
  154. if (!len) {
  155. return this.$message.warning("请先勾选店员");
  156. }
  157. this.$confirm(`此操作将永久删除所勾选的${len}条店员, 是否继续?`, "提示", {
  158. confirmButtonText: "确定",
  159. cancelButtonText: "取消",
  160. type: "warning",
  161. })
  162. .then(() => {
  163. const ids = this.$refs.tableList.allCheckData.map(
  164. (item) => item.storeId
  165. );
  166. storeBatchDel({
  167. status: -1,
  168. storeIds: ids,
  169. }).then((res) => {
  170. this.$message.success("批量删除成功");
  171. this.$refs.tableList.clearMoreActive();
  172. this.$store.commit("EDICSTORELIST");
  173. this.search();
  174. });
  175. })
  176. .catch(() => {});
  177. },
  178. },
  179. components: { StoreSetDlg },
  180. };
  181. </script>
  182. <style lang="scss" scoped></style>