谢杰标 2 лет назад
Родитель
Сommit
08016f1036

+ 34 - 0
src/api/store/index.js

@@ -25,3 +25,37 @@ export function getStoreList(query) {
     params: query,
   });
 }
+
+// 店铺详情
+export function getStoreDetail(id) {
+  return request({
+    url: `/store/` + id,
+    method: "get",
+  });
+}
+
+//新增店铺
+export function addStore(data) {
+  return request({
+    url: "/store",
+    method: "post",
+    data,
+  });
+}
+//修改店铺
+export function editStore(data) {
+  return request({
+    url: "/store/edit",
+    method: "post",
+    data,
+  });
+}
+
+//店铺批量删除
+export function storeBatchDel(data) {
+  return request({
+    url: "/store/batchRemove",
+    method: "post",
+    data,
+  });
+}

+ 4 - 4
src/views/storeMag/components/StaffSetDlg.vue

@@ -63,8 +63,8 @@
       </el-form-item>
       <el-form-item label="启动状态:" prop="status">
         <el-radio-group v-model="form.status">
-          <el-radio :label="1">启</el-radio>
-          <el-radio :label="0">用</el-radio>
+          <el-radio :label="1">启</el-radio>
+          <el-radio :label="0">用</el-radio>
         </el-radio-group>
       </el-form-item>
     </el-form>
@@ -138,7 +138,7 @@ export default {
   methods: {
     open() {
       this.resetForm();
-      this.userId && this.getUserDatail();
+      this.userId && this.getDatail();
     },
     resetForm() {
       this.form = {
@@ -153,7 +153,7 @@ export default {
       };
       this.clearForm("form");
     },
-    getUserDatail() {
+    getDatail() {
       this.$api.obtainUserDetails(this.userId).then(({ data, roleIds }) => {
         data.roleIds = roleIds;
         Object.keys(this.form).forEach((key) => {

+ 27 - 21
src/views/storeMag/components/StoreSetDlg.vue

@@ -22,11 +22,18 @@
         <el-input v-model="form.address" placeholder="请输入店铺地址">
         </el-input>
       </el-form-item>
+      <el-form-item label="状态:" prop="status">
+        <el-radio-group v-model="form.status">
+          <el-radio :label="1">启用</el-radio
+          ><el-radio :label="0">禁用</el-radio>
+        </el-radio-group>
+      </el-form-item>
     </el-form>
   </Base-dialog>
 </template>
 
 <script>
+import { getStoreDetail, addStore, editStore } from "../../../api/store/index";
 export default {
   props: {
     dialogVisible: {
@@ -34,7 +41,7 @@ export default {
       default: false,
     },
     storeId: {
-      type: [Number || String],
+      type: [Number, String],
     },
   },
   data() {
@@ -50,38 +57,37 @@ export default {
   methods: {
     open() {
       this.resetForm();
+      this.storeId && this.getDatail();
+    },
+    getDatail() {
+      getStoreDetail(this.storeId).then(({ data }) => {
+        Object.keys(this.form).forEach((key) => {
+          this.form[key] = data[key];
+        });
+      });
     },
     resetForm() {
       this.form = {
         storeId: undefined,
-        status: undefined,
+        status: 1,
         storeName: undefined,
         address: undefined,
+        merId: "1",
       };
       this.clearForm("form");
     },
     submitForm() {
       this.$refs.form.validate(async (valid) => {
         if (valid) {
-          if (this.userId) {
-            this.$api
-              .editUser(this.form)
-              .then((res) => {
-                this.$message.success("修改成功");
-                this.$emit("search");
-                this.isShow = false;
-              })
-              .catch(() => {});
-          } else {
-            this.$api
-              .addUser(this.form)
-              .then((res) => {
-                this.$message.success("新增成功");
-                this.$emit("search");
-                this.isShow = false;
-              })
-              .catch(() => {});
-          }
+          const fn = this.storeId ? editStore : addStore;
+          fn(this.form)
+            .then((res) => {
+              this.$message.success(this.storeId ? "修改成功" : "新增成功");
+              this.$emit("search");
+              this.$store.commit("EDICSTORELIST");
+              this.isShow = false;
+            })
+            .catch(() => {});
         } else {
           return false;
         }

+ 23 - 24
src/views/storeMag/index.vue

@@ -1,9 +1,7 @@
 <template>
   <container title="店铺管理">
     <template v-slot:btn>
-      <el-button type="primary" @click="handelEdit('')"
-        >添加店铺</el-button
-      >
+      <el-button type="primary" @click="handelEdit('')">添加店铺</el-button>
       <el-button @click="batchDel">批量删除</el-button>
     </template>
     <search-box-new
@@ -27,7 +25,7 @@
           inactive-color="#ff4949"
           :active-value="1"
           :inactive-value="0"
-          @change="statusChange($event, props.scope.row)"
+          @change="editStore(props.scope.row.storeId, $event)"
         >
         </el-switch>
       </template>
@@ -35,7 +33,7 @@
         <el-button type="text" @click="handelEdit(props.scope.row.storeId)"
           >编辑</el-button
         >
-        <el-button type="text" @click="handelDel(props.scope.row.storeId)"
+        <el-button type="text" @click="del(props.scope.row.storeId)"
           >删除</el-button
         >
       </template>
@@ -48,6 +46,7 @@
     />
     <Store-set-dlg
       :storeId="storeId"
+      @search="search"
       :dialogVisible.sync="dialogVisible"
     ></Store-set-dlg>
   </container>
@@ -55,7 +54,7 @@
 
 <script>
 import StoreSetDlg from "./components/StoreSetDlg.vue";
-import { getStoreList } from "../../api/store/index";
+import { getStoreList, editStore, storeBatchDel } from "../../api/store/index";
 export default {
   name: "SaasMemberRecord",
 
@@ -116,6 +115,7 @@ export default {
     search(v) {
       if (v === 2) {
         this.formData = {
+          status: "0,1",
           pageSize: 10,
           pageNum: 1,
           storeName: undefined,
@@ -131,15 +131,24 @@ export default {
           this.loading = false;
         });
     },
-    del(id) {
-      this.$confirm("确定删除吗?", "提示", {
+    del(storeId) {
+      this.$confirm("确定删除该店铺吗?", "提示", {
         confirmButtonText: "确定",
         cancelButtonText: "取消",
         type: "warning",
       })
-        .then(() => {})
+        .then(() => {
+          this.editStore(storeId, -1);
+        })
         .catch(() => {});
     },
+    editStore(storeId, status) {
+      editStore({ storeId, status, merId: "1" }).then((res) => {
+        status == -1 && this.$message.success("删除成功");
+        this.$store.commit("EDICSTORELIST");
+        this.search();
+      });
+    },
     handelEdit(storeId) {
       this.storeId = storeId;
       this.dialogVisible = true;
@@ -156,30 +165,20 @@ export default {
       })
         .then(() => {
           const ids = this.$refs.tableList.allCheckData.map(
-            (item) => item.moduleExamId
+            (item) => item.storeId
           );
-          moduleVolumeBatchDel({
+          storeBatchDel({
             status: -1,
-            ids,
+            storeIds: ids,
           }).then((res) => {
             this.$message.success("批量删除成功");
             this.$refs.tableList.clearMoreActive();
-            this.search(1);
+            this.$store.commit("EDICSTORELIST");
+            this.search();
           });
         })
         .catch(() => {});
     },
-    statusChange(e, row) {
-      //   this.$api
-      //     .editmallstore({ storeId: row.storeId, status: e })
-      //     .then((res) => {
-      //       this.$message.success("操作成功");
-      //       row.status = e;
-      //     })
-      //     .catch(() => {
-      //       return (row.status = e ? 0 : 1);
-      //     });
-    },
   },
   components: { StoreSetDlg },
 };