浏览代码

修改商品没有规格,不允许上架或下架

YY 2 年之前
父节点
当前提交
5eca926f5f
共有 3 个文件被更改,包括 66 次插入48 次删除
  1. 22 13
      src/views/platmanag/goods/index.vue
  2. 22 13
      src/views/selfShop/goods/index.vue
  3. 22 22
      vue.config.js

+ 22 - 13
src/views/platmanag/goods/index.vue

@@ -114,6 +114,7 @@ const _ = require('lodash');
 import methodsUtil from '@/util/opera';
 import methodsUtil from '@/util/opera';
 import { mapState, createNamespacedHelpers } from 'vuex';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: goods } = createNamespacedHelpers('goods');
 const { mapActions: goods } = createNamespacedHelpers('goods');
+const { mapActions: goodsSpec } = createNamespacedHelpers('goodsSpec');
 const { mapActions: goodsTags } = createNamespacedHelpers('goodsTags');
 const { mapActions: goodsTags } = createNamespacedHelpers('goodsTags');
 const { mapActions: dictData } = createNamespacedHelpers('dictData');
 const { mapActions: dictData } = createNamespacedHelpers('dictData');
 const { mapActions: actTags } = createNamespacedHelpers('actTags');
 const { mapActions: actTags } = createNamespacedHelpers('actTags');
@@ -158,7 +159,7 @@ export default {
         { label: '活动标签', model: 'act_tags', type: 'selectMany' },
         { label: '活动标签', model: 'act_tags', type: 'selectMany' },
         { label: '简短简介', model: 'shot_brief', maxLength: 50 },
         { label: '简短简介', model: 'shot_brief', maxLength: 50 },
         { label: '预计发货时间', model: 'send_time' },
         { label: '预计发货时间', model: 'send_time' },
-        { label: '商品状态', model: 'status', type: 'select' },
+        // { label: '商品状态', model: 'status', type: 'select' },
         { label: '商品来源', model: 'source' },
         { label: '商品来源', model: 'source' },
         { label: '网址', model: 'url' },
         { label: '网址', model: 'url' },
         { label: '排序', model: 'sort', type: 'number' },
         { label: '排序', model: 'sort', type: 'number' },
@@ -207,6 +208,7 @@ export default {
     ...goodsTags(['tree']),
     ...goodsTags(['tree']),
     ...shop({ shopQuery: 'query', shopFetch: 'fetch' }),
     ...shop({ shopQuery: 'query', shopFetch: 'fetch' }),
     ...goods(['copy', 'query', 'delete', 'fetch', 'update', 'create']),
     ...goods(['copy', 'query', 'delete', 'fetch', 'update', 'create']),
+    ...goodsSpec({ specQuery: 'query' }),
     ...methodsUtil,
     ...methodsUtil,
     toSearch() {
     toSearch() {
       this.$refs.dataTable.resetPage();
       this.$refs.dataTable.resetPage();
@@ -369,18 +371,25 @@ export default {
     },
     },
     // 上架
     // 上架
     async toPuton({ data }) {
     async toPuton({ data }) {
-      this.$confirm('是否确认上架/下架该商品?', '提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning',
-      }).then(async () => {
-        if (data.status == '1') data.status = '0';
-        else data.status = '1';
-        let res;
-        if (data._id) res = await this.update(data);
-        if (this.$checkRes(res)) this.$message({ type: `success`, message: `修改成功` });
-        this.search(this.searchQuery);
-      });
+      const res = await this.specQuery({ goods: data._id });
+      if (this.$checkRes(res)) {
+        if (res.total > 0) {
+          this.$confirm('是否确认上架/下架该商品?', '提示', {
+            confirmButtonText: '确定',
+            cancelButtonText: '取消',
+            type: 'warning',
+          }).then(async () => {
+            if (data.status == '1') data.status = '0';
+            else data.status = '1';
+            let res;
+            if (data._id) res = await this.update(data);
+            if (this.$checkRes(res)) this.$message({ type: `success`, message: `修改成功` });
+            this.search(this.searchQuery);
+          });
+        } else {
+          this.$message({ type: `warning`, message: `该商品没有规格,不允许上架` });
+        }
+      }
     },
     },
     // 库存管理
     // 库存管理
     toSpec({ data }) {
     toSpec({ data }) {

+ 22 - 13
src/views/selfShop/goods/index.vue

@@ -109,6 +109,7 @@ const _ = require('lodash');
 import methodsUtil from '@/util/opera';
 import methodsUtil from '@/util/opera';
 import { mapState, createNamespacedHelpers } from 'vuex';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: goods } = createNamespacedHelpers('goods');
 const { mapActions: goods } = createNamespacedHelpers('goods');
+const { mapActions: goodsSpec } = createNamespacedHelpers('goodsSpec');
 const { mapActions: goodsTags } = createNamespacedHelpers('goodsTags');
 const { mapActions: goodsTags } = createNamespacedHelpers('goodsTags');
 const { mapActions: dictData } = createNamespacedHelpers('dictData');
 const { mapActions: dictData } = createNamespacedHelpers('dictData');
 const { mapActions: actTags } = createNamespacedHelpers('actTags');
 const { mapActions: actTags } = createNamespacedHelpers('actTags');
@@ -158,7 +159,7 @@ export default {
         { label: '活动标签', model: 'act_tags', type: 'selectMany' },
         { label: '活动标签', model: 'act_tags', type: 'selectMany' },
         { label: '简短简介', model: 'shot_brief', maxLength: 50 },
         { label: '简短简介', model: 'shot_brief', maxLength: 50 },
         { label: '预计发货时间', model: 'send_time' },
         { label: '预计发货时间', model: 'send_time' },
-        { label: '商品状态', model: 'status', type: 'select' },
+        // { label: '商品状态', model: 'status', type: 'select' },
         { label: '商品来源', model: 'source' },
         { label: '商品来源', model: 'source' },
         { label: '网址', model: 'url' },
         { label: '网址', model: 'url' },
         { label: '排序', model: 'sort', type: 'number' },
         { label: '排序', model: 'sort', type: 'number' },
@@ -202,6 +203,7 @@ export default {
     ...actTags({ actQuery: 'query' }),
     ...actTags({ actQuery: 'query' }),
     ...goodsTags(['tree']),
     ...goodsTags(['tree']),
     ...goods(['copy', 'query', 'delete', 'fetch', 'update', 'create']),
     ...goods(['copy', 'query', 'delete', 'fetch', 'update', 'create']),
+    ...goodsSpec({ specQuery: 'query' }),
     ...methodsUtil,
     ...methodsUtil,
     toSearch() {
     toSearch() {
       this.$refs.dataTable.resetPage();
       this.$refs.dataTable.resetPage();
@@ -287,18 +289,25 @@ export default {
     },
     },
     // 上架
     // 上架
     async toPuton({ data }) {
     async toPuton({ data }) {
-      this.$confirm('是否确认上架/下架该商品?', '提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning',
-      }).then(async () => {
-        if (data.status == '1') data.status = '0';
-        else data.status = '1';
-        let res;
-        if (data._id) res = await this.update(data);
-        if (this.$checkRes(res)) this.$message({ type: `success`, message: `修改成功` });
-        this.search(this.searchQuery);
-      });
+      const res = await this.specQuery({ goods: data._id });
+      if (this.$checkRes(res)) {
+        if (res.total > 0) {
+          this.$confirm('是否确认上架/下架该商品?', '提示', {
+            confirmButtonText: '确定',
+            cancelButtonText: '取消',
+            type: 'warning',
+          }).then(async () => {
+            if (data.status == '1') data.status = '0';
+            else data.status = '1';
+            let res;
+            if (data._id) res = await this.update(data);
+            if (this.$checkRes(res)) this.$message({ type: `success`, message: `修改成功` });
+            this.search(this.searchQuery);
+          });
+        } else {
+          this.$message({ type: `warning`, message: `该商品没有规格,不允许上架` });
+        }
+      }
     },
     },
     // 库存管理
     // 库存管理
     toSpec({ data }) {
     toSpec({ data }) {

+ 22 - 22
vue.config.js

@@ -7,58 +7,58 @@ module.exports = {
     Object.assign(config, {
     Object.assign(config, {
       resolve: {
       resolve: {
         alias: {
         alias: {
-          "@": path.resolve(__dirname, "./src"),
-          "@c": path.resolve(__dirname, "./src/components"),
-          "@a": path.resolve(__dirname, "./src/assets"),
+          '@': path.resolve(__dirname, './src'),
+          '@c': path.resolve(__dirname, './src/components'),
+          '@a': path.resolve(__dirname, './src/assets'),
         },
         },
       },
       },
     });
     });
   },
   },
   devServer: {
   devServer: {
-    port: "9001",
+    port: '9001',
     proxy: {
     proxy: {
-      "/ws": {
-        target: "https://broadcast.waityou24.cn", // 127.0.0.1:13003
+      '/ws': {
+        target: 'https://broadcast.waityou24.cn', // 127.0.0.1:13003
         ws: true,
         ws: true,
       },
       },
-      "/files": {
-        target: "https://broadcast.waityou24.cn",
+      '/files': {
+        target: 'https://broadcast.waityou24.cn',
       },
       },
-      "/dev/point/v1/api": {
-        target: "http://192.168.1.144:12211", // 127.0.0.1:13003
+      '/dev/point/v1/api': {
+        target: 'https://broadcast.waityou24.cn', // 127.0.0.1:13003
         changeOrigin: true,
         changeOrigin: true,
         ws: false,
         ws: false,
       },
       },
-      "/point/v1/api": {
-        target: "https://broadcast.waityou24.cn", // 127.0.0.1:13003
+      '/point/v1/api': {
+        target: 'https://broadcast.waityou24.cn', // 127.0.0.1:13003
         changeOrigin: true,
         changeOrigin: true,
         ws: false,
         ws: false,
       },
       },
       // 团购
       // 团购
-      "/point/group/v1/api": {
-        target: "https://broadcast.waityou24.cn", // 127.0.0.1:13003
+      '/point/group/v1/api': {
+        target: 'https://broadcast.waityou24.cn', // 127.0.0.1:13003
         changeOrigin: true,
         changeOrigin: true,
         ws: false,
         ws: false,
       },
       },
-      "/dev/point/group/v1/api": {
-        target: "https://broadcast.waityou24.cn", // 127.0.0.1:13003
+      '/dev/point/group/v1/api': {
+        target: 'https://broadcast.waityou24.cn', // 127.0.0.1:13003
         changeOrigin: true,
         changeOrigin: true,
         ws: false,
         ws: false,
       },
       },
       // 聊天
       // 聊天
-      "/point/chat/v1/api": {
-        target: "https://broadcast.waityou24.cn", // 127.0.0.1:13003
+      '/point/chat/v1/api': {
+        target: 'https://broadcast.waityou24.cn', // 127.0.0.1:13003
         changeOrigin: true,
         changeOrigin: true,
         ws: false,
         ws: false,
       },
       },
-      "/dev/point/chat/v1/api": {
-        target: "https://broadcast.waityou24.cn", // 127.0.0.1:13003
+      '/dev/point/chat/v1/api': {
+        target: 'https://broadcast.waityou24.cn', // 127.0.0.1:13003
         changeOrigin: true,
         changeOrigin: true,
         ws: false,
         ws: false,
       },
       },
       // 尊荣
       // 尊荣
-      "/dev/point/zr/v1/api": {
-        target: "https://broadcast.waityou24.cn", // 127.0.0.1:13003
+      '/dev/point/zr/v1/api': {
+        target: 'https://broadcast.waityou24.cn', // 127.0.0.1:13003
         changeOrigin: true,
         changeOrigin: true,
         ws: false,
         ws: false,
         // pathRewrite: {
         // pathRewrite: {