소스 검색

新增分类添加、列表

hwb0 3 년 전
부모
커밋
92ea71457f

+ 0 - 5
src/views/business/banner/components/BannerCreate.vue

@@ -115,11 +115,6 @@ export default {
       },
       bannerLocationList: [],
       goodsTagItemsList: [],
-      // 盲票组序列号
-      pkgNo: "",
-      // 选中盲票组列表
-      list: [],
-      
       rules: {
         name: [
           { required: true, message: "请输入banner名称", trigger: "blur" },

+ 2 - 3
src/views/business/banner/index.vue

@@ -76,7 +76,7 @@
         </template>
       </el-table-column>
       <el-table-column label="操作" align="center">
-        <template slot-scope="{ row }">
+        <template>
           <div>
             <el-button
               v-hasPermi="['order:deliver:query']"
@@ -104,7 +104,7 @@
       @pagination="getList"
     />
 
-    <banner-create :dialog-show="createShow" @close="close" />
+    <banner-create v-if="createShow" :dialog-show="createShow" @close="close" />
   </div>
 </template>
 <script>
@@ -161,7 +161,6 @@ export default {
             });
             this.total = res.total;
             this.list = res.rows;
-            console.log("this.list", this.list);
           }
         })
         .catch(() => {

+ 153 - 0
src/views/business/category/components/CategoryCreate.vue

@@ -0,0 +1,153 @@
+<template>
+  <div>
+    <el-dialog
+      title="添加分类"
+      :visible.sync="dialogShow"
+      width="800px"
+      :before-close="close"
+    >
+      <el-form :model="form" ref="form" :rules="rules" label-width="100px">
+        <el-form-item label="分类名称" prop="name">
+          <el-input
+            v-model="form.name"
+            style="width: 300px"
+            size="small"
+            placeholder="请输入分类名称"
+          ></el-input>
+        </el-form-item>
+        <el-form-item label="排序">
+          <el-input
+            v-model.number="form.sort"
+            style="width: 300px"
+            size="small"
+            placeholder="请输入排序"
+          ></el-input>
+        </el-form-item>
+        <el-form-item label="分类图片" prop="picUrl">
+          <image-upload
+            :limit="1"
+            :value="form.picUrl"
+            :file-size="50"
+            :is-public="true"
+            @input="pictureSelect"
+          />
+        </el-form-item>
+        <el-form-item label="是否显示" prop="isShow">
+          <el-radio-group v-model="form.isShow" size="small">
+            <el-radio :label="1">是</el-radio>
+            <el-radio :label="2">否</el-radio>
+          </el-radio-group>
+        </el-form-item>
+      </el-form>
+
+      <!-- 按钮 -->
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="close">取 消</el-button>
+        <el-button type="primary" :disabled="loading" @click="saveClick"
+          >确 定</el-button
+        >
+      </div>
+    </el-dialog>
+  </div>
+</template>
+<script>
+import CustomFieldsMixin from "@/mixins/CustomFields";
+import { goodsCategoryCreate } from "@/api/business/category";
+export default {
+  mixins: [CustomFieldsMixin],
+  props: {
+    // 弹框显示
+    dialogShow: {
+      type: Boolean,
+      default: false,
+    },
+  },
+  created() {
+
+  },
+  data() {
+    return {
+      loading: false,
+      form: {
+        picUrl: [],
+        isShow: 1,
+      },
+      rules: {
+        name: [
+          { required: true, message: "请输入分类名称", trigger: "blur" },
+        ],
+        picUrl: [
+          {
+            type: "array",
+            required: true,
+            message: "请上传分类图片",
+            trigger: "change",
+          },
+        ],
+        isShow:  [
+          { required: true, message: "请选择", trigger: "change" },
+        ],
+      },
+    };
+  },
+  methods: {
+
+    changeType(){
+      this.$refs["form"].clearValidate();
+    },
+
+    // 添加图片
+    pictureSelect(data) {
+      this.form.picUrl = data;
+    },
+
+    // 关闭弹框
+    close() {
+      this.$emit("close");
+      this.loading = false;
+      this.$refs["form"].resetFields();
+    },
+
+    // 确认
+    saveClick() {
+      this.loading = true;
+      const subForm = this.$refs["form"];
+      subForm.validate((valid) => {
+        if (valid) {
+          this.submitForm(this.form);
+        } else {
+          this.loading = false;
+          // 提示第一个error
+          this.getFormErrorMessage(subForm);
+          return false;
+        }
+      });
+    },
+
+    // 提交
+    submitForm(form) {
+      let data = {
+        ... form,
+        picUrl: this.form.picUrl[0].fileName,
+      };
+      goodsCategoryCreate(data)
+        .then((res) => {
+          if (res.code == 0) {
+            this.msgSuccess("添加成功");
+            this.close();
+          }
+        })
+        .catch(() => {
+          this.loading = false;
+        });
+    },
+  },
+};
+</script>
+<style scoped>
+.channel {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+}
+</style>

+ 172 - 0
src/views/business/category/index.vue

@@ -0,0 +1,172 @@
+<template>
+  <div class="app-container">
+    <!-- <el-form
+      :model="queryParams"
+      ref="queryForm"
+      :inline="true"
+      v-show="showSearch"
+      label-width="90px"
+    >
+      <el-form-item label="位置">
+        <el-select
+          v-model="queryParams.location"
+          placeholder="请选择位置"
+          clearable
+          @change="queryParams.pageNum = 1;getList()"
+        >
+          <el-option
+            :label="item.dictLabel"
+            :value="item.dictValue"
+            v-for="(item, index) in bannerLocationList"
+            :key="index"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item>
+        <el-button
+          type="primary"
+          icon="el-icon-search"
+          size="mini"
+          @click="handleQuery"
+          >搜索</el-button
+        >
+        <el-button icon="el-icon-refresh" size="mini" @click="getList(true)"
+          >重置</el-button
+        >
+      </el-form-item>
+    </el-form> -->
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="1.5">
+        <el-button
+          type="primary"
+          icon="el-icon-plus"
+          size="mini"
+          @click="handleAdd"
+          v-hasPermi="['business:ticket:add']"
+          >添加分类</el-button
+        >
+      </el-col>
+      <right-toolbar
+        :showSearch.sync="showSearch"
+        @queryTable="getList()"
+      ></right-toolbar>
+    </el-row>
+    <!-- 列表 -->
+    <el-table ref="table" v-loading="loading" :data="list">
+      <el-table-column label="分类名称" prop="name" />
+      <el-table-column label="分类图片">
+        <div slot-scope="{ row }">
+          <el-image
+            style="width: 100px; height: 100px"
+            :src="row.picUrl"
+            :preview-src-list="[row.picUrl]"
+          />
+        </div>
+      </el-table-column>
+      <el-table-column label="排序" align="center">
+        <template slot-scope="{ row }">
+          <div>{{ row.sort }}</div>
+        </template>
+      </el-table-column>
+      <el-table-column label="状态" prop="status"  align="center">
+        <template slot-scope="{ row }">
+          <el-tag :type="row.isShow === 1 ? 'success' : 'info'">{{
+            row.isShow === 1 ? "显示" : "不显示"
+          }}</el-tag>
+        </template>
+      </el-table-column>
+      <el-table-column label="操作" align="center">
+        <template>
+          <div>
+            <el-button v-hasPermi="['order:deliver:query']" type="text" disabled
+              >编辑</el-button
+            >
+            <el-button v-hasPermi="['order:deliver:ship']" type="text" disabled
+              >删除</el-button
+            >
+          </div>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <!-- 分页 -->
+    <pagination
+      v-show="total > 0"
+      :total="total"
+      :page.sync="pageParams.pageNum"
+      :limit.sync="pageParams.pageSize"
+      @pagination="getList"
+    />
+
+    <category-create v-if="createShow" :dialog-show="createShow" @close="close" />
+  </div>
+</template>
+<script>
+import { publicFileGetUrl } from "@/api/common";
+import {
+  goodsCategoryList,
+  goodsCategoryRemove,
+} from "@/api/business/category";
+import CategoryCreate from "./components/CategoryCreate";
+export default {
+  name: "ListCate",
+  components: {
+    CategoryCreate,
+  },
+  data() {
+    return {
+      loading: false,
+      showSearch: true,
+      queryParams: {},
+      pageParams: {
+        pageNum: 1,
+        pageSize: 10,
+      },
+      // 总条数
+      total: 0,
+      list: [],
+      createShow: false,
+    };
+  },
+  created() {
+    this.getList();
+  },
+  methods: {
+    getList() {
+      this.loading = true;
+      goodsCategoryList(
+        "pageNum=" +
+          this.pageParams.pageNum +
+          "&pageSize=" +
+          this.pageParams.pageSize +
+          "&",
+        this.queryParams
+      )
+        .then((res) => {
+          this.loading = false;
+          if (res.code == 0) {
+            res.rows.forEach((item) => {
+              item.picUrl = publicFileGetUrl + item.picUrl.split(",")[0];
+            });
+            this.total = res.total;
+            this.list = res.rows;
+          }
+        })
+        .catch(() => {
+          this.loading = false;
+        });
+    },
+    handleQuery() {},
+    handleAdd() {
+      this.createShow = true;
+    },
+    // 关闭发货弹框
+    close() {
+      this.createShow = false;
+      this.getList();
+    },
+  },
+};
+</script>
+<style>
+</style>

+ 20 - 0
src/views/business/tag/index.vue

@@ -0,0 +1,20 @@
+<template>
+  <div class="app-container">
+
+  </div>
+</template>
+<script>
+export default {
+  name: 'ListTag',
+  components: {},
+  data() {
+    return {};
+  },
+  created(){
+    
+  },
+  methods: {},
+};
+</script>
+<style>
+</style>