yijianjun 1 долоо хоног өмнө
parent
commit
607981b64b

+ 77 - 0
mer_plat_admin/src/api/product.js

@@ -576,3 +576,80 @@ export function productMarketingListApi(params) {
     params,
   });
 }
+
+
+
+/**
+ * 今日吃啥搜索分页列表
+ * @param pram
+ */
+export function whattodayeatTagList(params) {
+  return request({
+    url: '/admin/platform/whattodayeatTag/list',
+    method: 'get',
+    params,
+  });
+}
+
+/**
+ * 新增商品标签
+ * @param data 待新增数据
+ * @returns {*} 新增结果
+ */
+export function whattodayeatTagAddApi(data) {
+  return request({
+    url: `admin/platform/whattodayeatTag/save`,
+    method: 'post',
+    data,
+  });
+}
+
+/**
+ * 编辑商品标签
+ * @param data 待编辑数据
+ * @returns {*} 新增结果
+ */
+export function whattodayeatTagUpdateApi(data) {
+  return request({
+    url: `admin/platform/whattodayeatTag/update`,
+    method: 'post',
+    data,
+  });
+}
+
+/**
+ * 商品标签删除
+ * @param id 待删除id
+ * @returns {*}
+ */
+export function whattodayeatTagDelete(id) {
+  return request({
+    url: `/admin/platform/whattodayeatTag/delete/${id}`,
+    method: 'get',
+  });
+}
+
+/**
+ * 商品标签详情
+ * @param id
+ * @returns {*}
+ */
+export function whattodayeatTagInfoApi(id) {
+  return request({
+    url: `/admin/platform/whattodayeatTag/info/${id}`,
+    method: 'get',
+  });
+}
+
+/**
+ * 更新标签状态
+ * @param id 标签id
+ * @param status 标签状态
+ * @returns {*}
+ */
+export function whattodayeatTagStatusApi(id, status) {
+  return request({
+    url: `/admin/platform/whattodayeatTag/status/${id}/${status}`,
+    method: 'get',
+  });
+}

+ 15 - 3
mer_plat_admin/src/router/modules/product.js

@@ -62,7 +62,19 @@ const productRouter = {
       name: 'CreatTag',
       meta: { title: '添加商品标签', icon: '', noCache: true, activeMenu: `/product/tag` },
     },
-  ],
-};
+    {
+      path: 'whattodayeatTag',
+      component: () => import('@/views/product/whattodayeatTag/index'),
+      name: 'whattodayeatTag',
+      meta: { title: '今日吃啥标签', icon: '' }
+    },
+    {
+      path: 'whattodayeatTag/creatTag/:id?',
+      component: () => import('@/views/product/whattodayeatTag/creatTag'),
+      name: 'whattodayeatTagCreatTag',
+      meta: { title: '添加标签', icon: '', noCache: true, activeMenu: `/product/whattodayeatTag` },
+    }
+  ]
+}
 
-export default productRouter;
+export default productRouter

+ 216 - 0
mer_plat_admin/src/views/product/whattodayeatTag/creatTag.vue

@@ -0,0 +1,216 @@
+<template>
+  <div class="divBox">
+    <div class="container_box">
+      <pages-header
+        ref="pageHeader"
+        :title="$route.params.id ? '商品标签编辑' : '商品标签新增'"
+        backUrl="/product/whattodayeatTag"
+      ></pages-header>
+      <el-card class="box-card box-body mt14" :bordered="false" shadow="never">
+        <el-tabs class="list-tabs">
+          <el-tab-pane label="基础设置" name="first"></el-tab-pane>
+        </el-tabs>
+        <el-form
+          ref="dataForm"
+          class="form-boder-padding"
+          :model="dataForm"
+          label-width="99px"
+          v-loading="loadingFrom"
+        >
+          <el-form-item label="标签名称:" prop="tagName">
+            <el-input
+              v-model.trim="dataForm.tagName"
+              type="text"
+              placeholder="请输入标签名称"
+              maxLength="5"
+              class="from-ipt-width"
+              :disabled="dataForm.owner === 0"
+            />
+          </el-form-item>
+          <el-form-item label="标签图片:" prop="icon">
+            <el-upload
+              action
+              :http-request="handleUploadForm"
+              :on-change="imgSaveToUrl"
+              :headers="myHeaders"
+            >
+              <el-button icon="el-icon-upload2" type="primary" 
+                >上传
+              </el-button>
+            </el-upload>
+          </el-form-item>
+          <el-form-item label="排序:" prop="sort">
+            <el-input-number
+              class="from-ipt-width"
+              v-model.trim="dataForm.sort"
+              :min="1"
+              :max="99999"
+              :step="1"
+            ></el-input-number>
+          </el-form-item>
+          <el-form-item label="状态:" prop="status">
+            <el-switch
+              v-model="dataForm.status"
+              :active-value="1"
+              :inactive-value="0"
+              active-text="显示"
+              inactive-text="隐藏"
+            >
+            </el-switch>
+          </el-form-item>
+          <el-form-item>
+            <el-button
+                type="primary"
+                :loading="loading"
+                @click="onsubmit('dataForm')"
+                >保存
+              </el-button>
+          </el-form-item>
+        </el-form>
+      </el-card>
+    </div>
+  </div>
+</template>
+<script>
+import * as storeApi from "@/api/product";
+import { productTagInfoApi } from "@/api/product";
+import { getToken } from "@/utils/auth";
+import {
+  fileImageApi,
+  fileListApi,
+  fileDeleteApi,
+  attachmentMoveApi,
+} from "@/api/systemSetting";
+export default {
+  name: "editProductCateTag1",
+  data() {
+    return {
+      loading: false,
+      loadingFrom: false,
+      // 初始化表单数据
+      dataForm: {
+        tagName: "",
+        sort: 0,
+        status: 0,
+        icon: "",
+      },
+      myHeaders: { "X-Token": getToken() },
+    };
+  },
+  created() {
+    console.log(this.$route,'this.$route');
+    
+    if (this.$route.params.id) {
+      this.initEditData();
+    }
+  },
+  methods: {
+    // 上传
+    handleUploadForm(param) {
+      const formData = new FormData();
+      const data = {
+        model: "todayTag",
+        pid: this.dataForm.pid ? this.dataForm.pid : 0,
+      };
+      formData.append("multipart", param.file);
+      this.uploadPic(formData, data);
+    },
+    uploadPic(formData, data) {
+      let loading = this.$loading({
+        lock: true,
+        text: "上传中,请稍候...",
+        spinner: "el-icon-loading",
+        background: "rgba(0, 0, 0, 0.7)",
+      });
+      fileImageApi(formData, data)
+        .then((res) => {
+          console.log(res.url.substring(27));
+          let _url = res.url.startWitch
+          this.dataForm.icon = res.url.substring(27)
+          loading.close();
+        })
+        .catch((res) => {
+          loading.close();
+        });
+    },
+    // 选取图片后自动回调,里面可以获取到文件
+    imgSaveToUrl(event) {
+      // 也可以用file
+      this.localFile = event.raw; // 或者 this.localFile=file.raw
+
+      // 转换操作可以不放到这个函数里面,
+      // 因为这个函数会被多次触发,上传时触发,上传成功也触发
+      let reader = new FileReader();
+      reader.readAsDataURL(this.localFile); // 这里也可以直接写参数event.raw
+
+      // 转换成功后的操作,reader.result即为转换后的DataURL ,
+      // 它不需要自己定义,你可以console.integralLog(reader.result)看一下
+      reader.onload = () => {
+        // console.integralLog(reader.result)
+      };
+
+      /* 另外一种本地预览方法 */
+      let URL = window.URL || window.webkitURL;
+      this.localImg = URL.createObjectURL(event.raw);
+      // 转换后的地址为 blob:http://xxx/7bf54338-74bb-47b9-9a7f-7a7093c716b5
+    },
+    initEditData() {
+      this.loading = true;
+      storeApi.whattodayeatTagInfoApi(this.$route.params.id)
+        .then((res) => {
+          this.dataForm = { ...res };
+          this.loading = false;
+        })
+        .catch((res) => {
+          this.loading = false;
+        });
+    },
+    handleClose() {
+      this.$refs["dataForm"].resetFields();
+      this.$emit("onCloseHandle");
+    },
+    onClose() {
+      this.$emit("onCloseHandle");
+    },
+    onsubmit(formName) {
+      this.$refs[formName].validate((valid) => {
+        if (valid) {
+          this.loading = true;
+          if (this.dataForm.id) {
+            storeApi
+              .whattodayeatTagUpdateApi(this.dataForm)
+              .then(() => {
+                this.$message.success("编辑成功");
+                this.$router.push({ path: `/product/whattodayeatTag` });
+              })
+              .catch((err) => {})
+              .finally(() => {
+                this.loading = false;
+              });
+          } else {
+            storeApi
+              .whattodayeatTagAddApi(this.dataForm)
+              .then(() => {
+                this.$message.success("新增成功");
+                this.$router.push({ path: `/product/whattodayeatTag` });
+              })
+              .catch((err) => {})
+              .finally(() => {
+                this.loading = false;
+              });
+          }
+        } else {
+          return false;
+        }
+      });
+    },
+  },
+};
+</script>
+<style scoped lang="scss">
+.box-body {
+  ::v-deep.el-card__body {
+    padding-top: 0px;
+  }
+}
+</style>

+ 224 - 0
mer_plat_admin/src/views/product/whattodayeatTag/index.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>