index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <div id="">
  3. <search-box-new
  4. ref="searchBox"
  5. :formData="formData"
  6. :formList="formList"
  7. @search="search"
  8. @init="init"
  9. />
  10. <table-list
  11. rowKey="storeId"
  12. ref="tableList"
  13. :tableSets="tableSet"
  14. :tableData="tableData"
  15. :navText="navText"
  16. :loading="loading"
  17. @addClick="addClick"
  18. >
  19. <template slot="customize">
  20. <el-button type="warning" @click="remove"> 批量删除 </el-button>
  21. </template>
  22. <template slot="status" slot-scope="props">
  23. <el-switch
  24. v-model="props.scope.row.status"
  25. active-color="#13ce66"
  26. inactive-color="#ff4949"
  27. :active-value="1"
  28. :inactive-value="0"
  29. @change="statusChange($event, props.scope.row)"
  30. >
  31. </el-switch>
  32. </template>
  33. <template slot="btn" slot-scope="props">
  34. <el-button type="text" @click="addClick(props.scope.row)"
  35. >编辑</el-button
  36. ><el-button type="text" @click="del(props.scope.row)">删除</el-button>
  37. </template>
  38. </table-list>
  39. <pagination
  40. :total="total"
  41. :pageSize.sync="formData.pageSize"
  42. :currentPage.sync="formData.pageNum"
  43. @search="search"
  44. />
  45. <dislog
  46. :dialogVisible.sync="dialogVisible"
  47. @search="search"
  48. :storeId="storeId"
  49. ></dislog>
  50. </div>
  51. </template>
  52. <script>
  53. import dislog from "./dislog.vue";
  54. import searchBoxNew from "@/components/searchBoxNew";
  55. import tableList from "@/components/tableList";
  56. import pagination from "@/components/pagination";
  57. export default {
  58. name: "StoreManageMent",
  59. components: { searchBoxNew, tableList, pagination, dislog },
  60. data() {
  61. return {
  62. loading: false,
  63. navText: {
  64. title: "店铺管理",
  65. index: 0,
  66. ch: "条",
  67. num: true,
  68. choice: true,
  69. addHide: false,
  70. custom: false,
  71. openCheckMore: true,
  72. },
  73. formList: [
  74. {
  75. prop: "merId",
  76. placeholder: "请选择合作商户",
  77. scope: "merList",
  78. },
  79. {
  80. prop: "storeName",
  81. placeholder: "输入店铺简称",
  82. },
  83. ],
  84. formData: {},
  85. tableSet: [
  86. {
  87. label: "店铺简称",
  88. prop: "storeName",
  89. hidden: true,
  90. },
  91. {
  92. label: "店铺地址",
  93. prop: "address",
  94. hidden: true,
  95. },
  96. {
  97. label: "合作商户",
  98. prop: "merName",
  99. hidden: true,
  100. },
  101. {
  102. label: "启用状态",
  103. prop: "status",
  104. hidden: true,
  105. scope: "solt",
  106. soltName: "status",
  107. },
  108. {
  109. label: "创建时间",
  110. prop: "createTime",
  111. hidden: true,
  112. scope: "aTimeList",
  113. },
  114. ],
  115. tableData: [],
  116. total: 0,
  117. dialogVisible: false,
  118. storeId: 0,
  119. };
  120. },
  121. created() {
  122. this.search(2);
  123. },
  124. methods: {
  125. remove() {
  126. if (this.$refs.tableList.allCheckData.length === 0) {
  127. this.$message.error("请勾选数据");
  128. return;
  129. }
  130. this.$confirm("确定批量删除选中的数据吗?", "提示", {
  131. confirmButtonText: "确定",
  132. cancelButtonText: "取消",
  133. type: "warning",
  134. })
  135. .then(() => {
  136. this.$api
  137. .mallstorebatchRemove({
  138. storeIds: this.$refs.tableList.allCheckData.map((i) => i.storeId),
  139. status: -1,
  140. })
  141. .then(() => {
  142. this.$message.success("批量删除成功");
  143. this.search(3);
  144. });
  145. })
  146. .catch(() => {});
  147. },
  148. addClick(data) {
  149. this.storeId = data?.storeId || 0;
  150. this.dialogVisible = true;
  151. },
  152. search(v) {
  153. this.loading = true;
  154. if (v === 2) {
  155. this.formData = {
  156. pageSize: 10,
  157. pageNum: 1,
  158. status: "0,1",
  159. };
  160. this.$nextTick(() => {
  161. this.$refs.tableList.clearMoreActive();
  162. });
  163. }
  164. if (v === 3) {
  165. this.$nextTick(() => {
  166. this.$refs.tableList.clearMoreActive();
  167. });
  168. }
  169. this.$api
  170. .mallstorelist(this.formData)
  171. .then((res) => {
  172. this.tableData = res.rows;
  173. this.total = res.total;
  174. this.navText.index = res.total;
  175. })
  176. .finally(() => {
  177. this.loading = false;
  178. });
  179. },
  180. statusChange(e, row) {
  181. this.$api
  182. .editmallstore({ storeId: row.storeId, merId: row.merId, status: e })
  183. .then((res) => {
  184. this.$message.success("操作成功");
  185. row.status = e;
  186. })
  187. .catch(() => {
  188. return (row.status = e ? 0 : 1);
  189. });
  190. },
  191. init() {
  192. this.search(2);
  193. },
  194. del(v) {
  195. this.$confirm("确定删除此内容?", "提示", {
  196. confirmButtonText: "确定",
  197. cancelButtonText: "取消",
  198. type: "warning",
  199. })
  200. .then(() => {
  201. this.$api
  202. .editmallmerchant({ storeId: row.storeId, status: -1 })
  203. .then((res) => {
  204. this.$message.success("删除成功");
  205. this.search();
  206. });
  207. })
  208. .catch(() => {});
  209. },
  210. },
  211. };
  212. </script>
  213. <style lang="scss" scoped></style>