zhaoyun 1 周之前
父節點
當前提交
c760b3ffcf

+ 1 - 0
mer_plat_admin/.env.development

@@ -4,6 +4,7 @@ ENV = 'development'
 # base api
 # VUE_APP_BASE_API = '/dev-api'
 VUE_APP_BASE_API = 'http://39.105.58.247:20800'
+#VUE_APP_BASE_API = 'http://127.0.0.1:20800'
 # vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
 # to control whether the babel-plugin-dynamic-import-node plugin is enabled.
 # It only does one thing by converting all import() to require().

+ 224 - 0
mer_plat_admin/src/views/product/whattodayeatTag/index-bak.vue

@@ -0,0 +1,224 @@
+<template>
+  <div class="divBox">
+    <el-card :bordered="false" shadow="never" class="ivu-mt" :body-style="{ padding: 0 }">
+      <div class="padding-add">
+        <el-form inline label-position="right" @submit.native.prevent>
+          <el-form-item label="标签名称:">
+            <el-input
+              v-model.trim="keywords"
+              @keyup.enter.native="handleSearch"
+              size="small"
+              clearable
+              class="selWidth"
+              placeholder="请输入标签名称"
+            ></el-input>
+          </el-form-item>
+          <el-form-item>
+            <el-button size="small" type="primary" @click="handleSearch">搜索</el-button>
+          </el-form-item>
+        </el-form>
+      </div>
+    </el-card>
+    <el-card class="box-card mt14" shadow="never" :bordered="false">
+      <div class="container">
+        <router-link
+          :to="{ path: '/product/whattodayeatTag/creatTag' }"
+        >
+          <el-button size="small" type="primary" class="mr10">添加标签</el-button>
+        </router-link>
+      </div>
+      <el-table
+        v-loading="tableConfig.listLoading"
+        :data="tableData.data"
+        size="small"
+        row-key="tag_id"
+        :default-expand-all="false"
+        :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
+        class="mt20"
+      >
+        <el-table-column prop="id" label="ID" min-width="60" />
+        <el-table-column
+          label="标签名称"
+          prop="tagName"
+          min-width="140"
+          :show-overflow-tooltip="true"
+        />
+        <el-table-column
+          label="标签图片"
+          prop="icon"
+          :show-overflow-tooltip="true"
+        >
+        <template slot-scope="scope">
+				    <div class="demo-image__preview line-heightOne">
+				      <el-image :src="scope.row.icon" :preview-src-list="[scope.row.icon]" v-if="scope.row.icon" />
+				      <img v-else :src="defaultImg" alt="" />
+				    </div>
+				  </template>
+        </el-table-column>
+        <el-table-column prop="status" label="是否显示" min-width="100" fixed="right">
+          <template slot-scope="scope">
+           <el-switch
+              v-model="scope.row.status"
+              :active-value="1"
+              :inactive-value="0"
+              active-text="显示"
+              inactive-text="隐藏"
+          @change="onchangeIsShow(scope.row)"
+            />
+            <!-- <div >{{ scope.row.status ? "显示" : "隐藏" }}</div> -->
+          </template>
+        </el-table-column>
+        <el-table-column prop="createTime" label="创建时间" min-width="150" />
+        <el-table-column prop="sort" label="排序" min-width="80" />
+        <el-table-column label="操作" width="100" fixed="right">
+          <template slot-scope="scope">
+            <router-link
+              :to="{ path: '/product/whattodayeatTag/creatTag/' + scope.row.id }"
+            >
+              <a>编辑</a>
+            </router-link>
+            <template
+            >
+              <el-divider direction="vertical"></el-divider>
+              <a @click="handleDelete(scope.row.id, scope.$index)">删除</a>
+            </template>
+          </template>
+        </el-table-column>
+      </el-table>
+      <div class="block">
+        <el-pagination
+          background
+          :page-sizes="[20, 40, 60, 80]"
+          :page-size="tableFrom.limit"
+          :current-page="tableFrom.page"
+          layout="total, sizes, prev, pager, next, jumper"
+          :total="tableData.total"
+          @size-change="handleSizeChange"
+          @current-change="pageChange"
+        />
+      </div>
+    </el-card>
+  </div>
+</template>
+
+<script>
+// +----------------------------------------------------------------------
+// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
+// +----------------------------------------------------------------------
+// | Author: CRMEB Team <admin@crmeb.com>
+// +----------------------------------------------------------------------
+import * as storeApi from "@/api/product.js";
+import { checkPermi } from "@/utils/permission";
+export default {
+  name: "whattodayeatTag",
+  components: {
+  },
+  computed: {},
+  data() {
+    return {
+      	 defaultImg: require('@/assets/imgs/moren.jpg'),
+      tableConfig: {
+        listLoading: false,
+      },
+      tableData: {
+        data: [],
+        total: 0,
+      },
+      tableFrom: {
+        page: 1,
+        limit: 20,
+        keywords: "", // 搜索关键字
+      },
+      keywords: "",
+      editData: {},
+      editDataDialogConfig: {
+        visible: false,
+      },
+    };
+  },
+  mounted() {
+    if (checkPermi(["platform:product:tag:list"])) this.getList(1);
+  },
+  methods: {
+    checkPermi,
+    handleSearch() {
+      this.getList(1);
+    },
+    // 列表
+    getList(num) {
+      this.tableFrom.keywords = this.keywords;
+      this.tableFrom.page = num ? num : this.tableFrom.page;
+      this.tableConfig.listLoading = true;
+      storeApi
+        .whattodayeatTagList(this.tableFrom)
+        .then((res) => {
+          this.tableData.data = res.list;
+          this.tableData.total = res.total;
+          this.tableConfig.listLoading = false;
+        })
+        .catch((res) => {
+          this.tableConfig.listLoading = false;
+          this.$message.error(res.message);
+        });
+    },
+    pageChange(page) {
+      this.tableFrom.page = page;
+      this.getList();
+    },
+    handleSizeChange(val) {
+      this.tableFrom.limit = val;
+      this.getList();
+    },
+    // 添加
+    onAdd() {
+      this.editData = {};
+      this.editDataDialogConfig.visible = true;
+    },
+    // 编辑
+    onEdit(row) {
+      this.editData = row;
+      this.editDataDialogConfig.visible = true;
+    },
+    // 删除
+    handleDelete(id, idx) {
+      this.$modalSure("删除当前标签吗?").then(async () => {
+        await storeApi.whattodayeatTagDelete(id);
+        this.$message.success("删除成功");
+        await this.getList();
+      });
+    },
+    onchangeIsShow(row) {
+      storeApi
+        .whattodayeatTagStatusApi(row.id, row.status)
+        .then((res) => {
+          this.$message.success("操作成功");
+          this.getList();
+        })
+        .catch((e) => {
+          return (row.status = !row.status);
+        });
+    },
+    handleOnEditDiaClosed() {
+      this.editDataDialogConfig.visible = false;
+      this.getList();
+    },
+  },
+};
+</script>
+
+<style scoped lang="scss">
+.infoBox {
+  ::v-deep.el-drawer__header {
+    margin-bottom: 0;
+    font-size: 20px;
+  }
+  ::v-deep.el-icon-arrow-down,
+  ::v-deep .el-icon-arrow-up {
+    display: none;
+  }
+}
+</style>

+ 150 - 125
mer_plat_admin/src/views/product/whattodayeatTag/index.vue

@@ -1,87 +1,83 @@
 <template>
-  <div class="divBox">
-    <el-card :bordered="false" shadow="never" class="ivu-mt" :body-style="{ padding: 0 }">
+  <div class="divBox relative">
+    <el-card
+      v-hasPermi="['platform:product:whattodayeatTag:list']"
+      :bordered="false"
+      shadow="never"
+      class="ivu-mt"
+      :body-style="{ padding: 0 }"
+    >
       <div class="padding-add">
-        <el-form inline label-position="right" @submit.native.prevent>
+        <el-form :inline="true" @submit.native.prevent>
           <el-form-item label="标签名称:">
             <el-input
               v-model.trim="keywords"
-              @keyup.enter.native="handleSearch"
+              @keyup.enter.native="getList(1)"
+              placeholder="请输入标签名称"
+              class="selWidth"
               size="small"
               clearable
-              class="selWidth"
-              placeholder="请输入标签名称"
-            ></el-input>
+            />
+          </el-form-item>
+          <el-form-item label="显示状态:">
+            <el-select v-model="tableFrom.isShow" placeholder="请选择显示状态" size="small" class="selWidth" clearable>
+              <el-option label="显示" value="1"></el-option>
+              <el-option label="隐藏" value="0"></el-option>
+            </el-select>
           </el-form-item>
           <el-form-item>
-            <el-button size="small" type="primary" @click="handleSearch">搜索</el-button>
+            <el-button type="primary" size="small" @click="getList(1)">查询</el-button>
+            <el-button size="small" @click="reset()">重置</el-button>
           </el-form-item>
         </el-form>
       </div>
     </el-card>
-    <el-card class="box-card mt14" shadow="never" :bordered="false">
-      <div class="container">
-        <router-link
-          :to="{ path: '/product/whattodayeatTag/creatTag' }"
+    <el-card class="box-card mt14" :body-style="{ padding: '20px' }" :bordered="false" shadow="never">
+      <div class="acea-row">
+        <el-button
+          type="primary"
+          size="small"
+          v-hasPermi="['platform:product:whattodayeatTag:save']"
+          @click="handlerOpenEdit(0)"
+          >添加标签</el-button
         >
-          <el-button size="small" type="primary" class="mr10">添加标签</el-button>
-        </router-link>
       </div>
-      <el-table
-        v-loading="tableConfig.listLoading"
-        :data="tableData.data"
-        size="small"
-        row-key="tag_id"
-        :default-expand-all="false"
-        :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
-        class="mt20"
-      >
-        <el-table-column prop="id" label="ID" min-width="60" />
-        <el-table-column
-          label="标签名称"
-          prop="tagName"
-          min-width="140"
-          :show-overflow-tooltip="true"
-        />
-        <el-table-column
-          label="标签图片"
-          prop="icon"
-          :show-overflow-tooltip="true"
-        >
-        <template slot-scope="scope">
+      <el-table v-loading="listLoading" :data="tableData.data" size="small" :highlight-current-row="true" class="mt20">
+        <el-table-column prop="id" label="ID" min-width="50" />
+        <el-table-column label="标签名称" prop="tagName" min-width="100" :show-overflow-tooltip="true"> </el-table-column>
+		<el-table-column label="标签图标" min-width="120">
+				  <template slot-scope="scope">
 				    <div class="demo-image__preview line-heightOne">
 				      <el-image :src="scope.row.icon" :preview-src-list="[scope.row.icon]" v-if="scope.row.icon" />
 				      <img v-else :src="defaultImg" alt="" />
 				    </div>
 				  </template>
+		</el-table-column>
+        <el-table-column prop="sort" label="排序" min-width="100" />
+        <el-table-column label="添加时间" min-width="120">
+          <template slot-scope="scope">
+            <span>{{ scope.row.createTime }}</span>
+          </template>
         </el-table-column>
-        <el-table-column prop="status" label="是否显示" min-width="100" fixed="right">
+        <el-table-column label="是否开启" fixed="right" min-width="90">
           <template slot-scope="scope">
-           <el-switch
+            <el-switch
+              v-if="checkPermi(['platform:product:whattodayeatTag:status'])"
               v-model="scope.row.status"
               :active-value="1"
               :inactive-value="0"
-              active-text="显示"
-              inactive-text="隐藏"
-          @change="onchangeIsShow(scope.row)"
+              active-text="开启"
+              inactive-text="关闭"
+              @click.native="onchangeIsShow(scope.row)"
             />
-            <!-- <div >{{ scope.row.status ? "显示" : "隐藏" }}</div> -->
+            <div v-else>{{ scope.row.isShow ? '开启' : '关闭' }}</div>
           </template>
         </el-table-column>
-        <el-table-column prop="createTime" label="创建时间" min-width="150" />
-        <el-table-column prop="sort" label="排序" min-width="80" />
         <el-table-column label="操作" width="100" fixed="right">
           <template slot-scope="scope">
-            <router-link
-              :to="{ path: '/product/whattodayeatTag/creatTag/' + scope.row.id }"
-            >
-              <a>编辑</a>
-            </router-link>
-            <template
-            >
-              <el-divider direction="vertical"></el-divider>
-              <a @click="handleDelete(scope.row.id, scope.$index)">删除</a>
-            </template>
+            <a @click="handlerOpenEdit(1, scope.row)" v-hasPermi="['platform:product:whattodayeatTag:update']">编辑</a>
+            <el-divider direction="vertical"></el-divider>
+            <a @click="handlerOpenDel(scope.row)" v-hasPermi="['platform:product:whattodayeatTag:delete']">删除</a>
           </template>
         </el-table-column>
       </el-table>
@@ -100,125 +96,154 @@
     </el-card>
   </div>
 </template>
-
 <script>
-// +----------------------------------------------------------------------
+// +---------------------------------------------------------------------
 // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
-// +----------------------------------------------------------------------
+// +---------------------------------------------------------------------
 // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
-// +----------------------------------------------------------------------
+// +---------------------------------------------------------------------
 // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
-// +----------------------------------------------------------------------
+// +---------------------------------------------------------------------
 // | Author: CRMEB Team <admin@crmeb.com>
-// +----------------------------------------------------------------------
+// +---------------------------------------------------------------------
 import * as storeApi from "@/api/product.js";
-import { checkPermi } from "@/utils/permission";
+import { checkPermi } from '@/utils/permission'; // 权限判断函数
 export default {
-  name: "whattodayeatTag",
-  components: {
-  },
-  computed: {},
   data() {
     return {
-      	 defaultImg: require('@/assets/imgs/moren.jpg'),
-      tableConfig: {
-        listLoading: false,
-      },
-      tableData: {
-        data: [],
-        total: 0,
-      },
       tableFrom: {
         page: 1,
         limit: 20,
         keywords: "", // 搜索关键字
+        isShow: '',
       },
       keywords: "",
-      editData: {},
-      editDataDialogConfig: {
-        visible: false,
+      tableData: {
+        data: [],
+        total: 0,
       },
+      listLoading: false,
+      keyNum: 0,
+      id: 0,
+	 defaultImg: require('@/assets/imgs/moren.jpg'),
     };
   },
   mounted() {
-    if (checkPermi(["platform:product:tag:list"])) this.getList(1);
+    if (checkPermi(['platform:product:whattodayeatTag:list'])) this.getList();
   },
   methods: {
     checkPermi,
-    handleSearch() {
-      this.getList(1);
-    },
+		onchangeIsShow(row) {
+		  storeApi
+		    .whattodayeatTagStatusApi(row.id, row.status)
+		    .then((res) => {
+		      this.$message.success("操作成功");
+		      this.getList();
+		    })
+		    .catch((e) => {
+		      return (row.status = !row.status);
+		    });
+		},
     // 列表
     getList(num) {
-      this.tableFrom.keywords = this.keywords;
       this.tableFrom.page = num ? num : this.tableFrom.page;
-      this.tableConfig.listLoading = true;
+      this.tableFrom.keywords = encodeURIComponent(this.keywords);
+      this.listLoading = true;
       storeApi
         .whattodayeatTagList(this.tableFrom)
         .then((res) => {
           this.tableData.data = res.list;
           this.tableData.total = res.total;
-          this.tableConfig.listLoading = false;
+          this.listLoading = false;
         })
         .catch((res) => {
-          this.tableConfig.listLoading = false;
-          this.$message.error(res.message);
+          this.listLoading = false;
         });
     },
+    reset() {
+      this.tableFrom.keywords = '';
+      this.tableFrom.isShow = '';
+      this.keywords = '';
+      this.getList(1);
+    },
     pageChange(page) {
       this.tableFrom.page = page;
       this.getList();
     },
     handleSizeChange(val) {
       this.tableFrom.limit = val;
-      this.getList();
-    },
-    // 添加
-    onAdd() {
-      this.editData = {};
-      this.editDataDialogConfig.visible = true;
+      this.getList(1);
     },
-    // 编辑
-    onEdit(row) {
-      this.editData = row;
-      this.editDataDialogConfig.visible = true;
+    handlerOpenEdit(isCreate, editDate) {
+      console.log(editDate)
+      const _this = this;
+      this.id = editDate ? editDate.id : 0;
+      this.$modalParserFrom(
+        isCreate === 0 ? '新建标签' : '编辑标签',
+        'whattodayeatTag',
+        isCreate,
+        isCreate === 0
+          ? {
+              id: 0,
+              tagName: '',
+			  icon: '',
+			  status: 0
+            }
+          : Object.assign({}, editDate),
+        function (formValue) {
+          _this.submit(formValue);
+          _this.resetForm(formValue);
+        },
+        (this.keyNum += 1),
+      );
     },
-    // 删除
-    handleDelete(id, idx) {
-      this.$modalSure("删除当前标签吗?").then(async () => {
-        await storeApi.whattodayeatTagDelete(id);
-        this.$message.success("删除成功");
-        await this.getList();
-      });
+    submit(formValue) {
+      const data = {
+        id: this.id,
+        tagName: formValue.tagName,
+        status: formValue.status,
+        sort: formValue.sort,
+		icon: formValue.icon,
+      };
+      this.id>0
+        ? storeApi
+            .whattodayeatTagUpdateApi(data)
+            .then((res) => {
+              this.$message.success('操作成功');
+              this.$msgbox.close();
+              this.getList();
+            })
+            .catch(() => {
+              this.loading = false;
+            })
+        : storeApi
+            .whattodayeatTagAddApi(data)
+            .then((res) => {
+              this.$message.success('操作成功');
+              this.$msgbox.close();
+              this.getList();
+            })
+            .catch(() => {
+              this.loading = false;
+            });
     },
-    onchangeIsShow(row) {
-      storeApi
-        .whattodayeatTagStatusApi(row.id, row.status)
-        .then((res) => {
-          this.$message.success("操作成功");
+    handlerOpenDel(rowData) {
+      this.$modalSure(
+        '删除当前标签吗?删除之后,移动端页面分类筛选不展示此标签',
+      ).then(() => {
+        storeApi.whattodayeatTagDelete(rowData.id).then((data) => {
+          this.$message.success('删除分类成功');
+          if (this.tableData.data.length === 1 && this.tableFrom.page > 1)
+            this.tableFrom.page = this.tableFrom.page - 1;
           this.getList();
-        })
-        .catch((e) => {
-          return (row.status = !row.status);
         });
-    },
-    handleOnEditDiaClosed() {
-      this.editDataDialogConfig.visible = false;
-      this.getList();
+      });
     },
   },
 };
 </script>
-
-<style scoped lang="scss">
-.infoBox {
-  ::v-deep.el-drawer__header {
-    margin-bottom: 0;
-    font-size: 20px;
-  }
-  ::v-deep.el-icon-arrow-down,
-  ::v-deep .el-icon-arrow-up {
-    display: none;
-  }
+<style>
+.alert_title {
+  margin-right: 10px;
 }
 </style>