ソースを参照

Merge branch 'dev' of http://113.31.163.91:7777/quanshu/mp-ui-pc into dev

guanglong 3 年 前
コミット
bac872b11b

+ 42 - 14
src/views/business/banner/components/BannerCreate.vue

@@ -40,11 +40,8 @@
         </el-form-item>
         <el-form-item label="图片" prop="picUrl">
           <image-upload
+            v-model="bannerPicUrl"
             :limit="1"
-            :value="form.picUrl"
-            :file-size="50"
-            :is-public="true"
-            @input="pictureSelect"
           />
         </el-form-item>
         <el-form-item label="类型" prop="type">
@@ -91,7 +88,7 @@
 </template>
 <script>
 import CustomFieldsMixin from "@/mixins/CustomFields";
-import { goodsBannerCreate } from "@/api/business/banner";
+import { goodsBannerCreate, goodsBannerDetail, goodsBannerUpdate } from "@/api/business/banner";
 import { goodsTagItems } from "@/api/business/tag";
 export default {
   mixins: [CustomFieldsMixin],
@@ -101,16 +98,16 @@ export default {
       type: Boolean,
       default: false,
     },
-  },
-  created() {
-    this.getBannerLocation();
-    this.getGoodsTagItems();
+    // ID
+    bannerId: {
+      type:[Number, String],
+      default: ''
+    }
   },
   data() {
     return {
       loading: false,
       form: {
-        picUrl: [],
         type: 'link',
         sort: 0
       },
@@ -133,7 +130,6 @@ export default {
         ],
         picUrl: [
           {
-            type: "array",
             required: true,
             message: "请上传banner图片",
             trigger: "change",
@@ -151,6 +147,35 @@ export default {
       },
     };
   },
+  computed: {
+    bannerPicUrl: {
+      get() {
+        return this.form.picUrl ? this.form.picUrl.split(',').map(item => {
+          return {
+            fileName: item
+          }
+        }) : []
+      },
+      set(val) {
+        this.$set(this.form, 'picUrl', val.map(item => { return item.fileName }).toString())
+      }
+    }
+  },
+  created() {
+    this.getBannerLocation();
+    this.getGoodsTagItems();
+    if(this.bannerId){
+      goodsBannerDetail({ bannerId: this.bannerId }).then(res => {
+        console.log('res', res)
+        const { location, name, sort, picUrl, type, linkUrl, goodsTags } = res.data
+        this.form = {
+          location: JSON.parse(location).value,
+          goodsTags: goodsTags ? goodsTags.split(',').map(item => Number(item)) : [],
+          name, sort, picUrl, type, linkUrl
+        }
+      })
+    }
+  },
   methods: {
     getBannerLocation() {
       this.getDicts("banner_location").then((res) => {
@@ -199,13 +224,16 @@ export default {
     submitForm(form) {
       let data = {
         ... form,
-        picUrl: this.form.picUrl[0].fileName,
         goodsTags: form.goodsTags ? form.goodsTags.join(',') : ''
       };
-      goodsBannerCreate(data)
+      let request = this.bannerId ? goodsBannerUpdate : goodsBannerCreate
+      if(this.bannerId){
+        data.bannerId = this.bannerId
+      }
+      request(data)
         .then((res) => {
           if (res.code == 0) {
-            this.msgSuccess("添加成功");
+            this.msgSuccess(this.bannerId ? "修改成功" : '添加成功');
             this.close();
           }
         })

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

@@ -33,7 +33,7 @@
           @click="getList()"
           >搜索</el-button
         >
-        <el-button icon="el-icon-refresh" size="mini" @click="getList(true)"
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
           >重置</el-button
         >
       </el-form-item>
@@ -84,7 +84,7 @@
             <el-button
               v-hasPermi="['business:banner:edit']"
               type="text"
-              disabled
+              @click="edit(row)"
               >编辑</el-button
             >
             <el-button
@@ -108,7 +108,12 @@
       @pagination="getList"
     />
 
-    <banner-create v-if="createShow" :dialog-show="createShow" @close="close" />
+    <banner-create
+      v-if="createShow"
+      :dialog-show="createShow"
+      :banner-id="bannerId"
+      @close="close"
+    />
   </div>
 </template>
 <script>
@@ -134,6 +139,7 @@ export default {
       list: [],
       bannerLocationList: [],
       createShow: false,
+      bannerId: '',
     };
   },
   created() {
@@ -172,6 +178,11 @@ export default {
         });
     },
 
+    edit(item) {
+      this.bannerId = item.bannerId;
+      this.createShow = true;
+    },
+
     del(item) {
       this.$confirm(`确认删除banner “${item.name}” 吗?`, "删除banner", {
         confirmButtonText: "确定",
@@ -187,6 +198,13 @@ export default {
       });
     },
 
+    // 重置
+    resetQuery() {
+      this.queryParams = {};
+      this.pageParams.pageNum = 1
+      this.getList();
+    },
+
     handleAdd() {
       this.createShow = true;
     },
@@ -194,6 +212,7 @@ export default {
     // 关闭发货弹框
     close() {
       this.createShow = false;
+      this.bannerId = "";
       this.getList();
     },
   },

+ 11 - 2
src/views/business/category/components/CategoryCreate.vue

@@ -15,7 +15,7 @@
             placeholder="请输入分类名称"
           ></el-input>
         </el-form-item>
-        <el-form-item label="排序">
+        <el-form-item label="排序" prop="sort">
           <el-input
             v-model.number="form.sort"
             style="width: 300px"
@@ -35,7 +35,7 @@
         <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 :label="0">否</el-radio>
           </el-radio-group>
         </el-form-item>
       </el-form>
@@ -71,6 +71,7 @@ export default {
       form: {
         picUrl: [],
         isShow: 1,
+        sort: 0
       },
       rules: {
         name: [
@@ -84,6 +85,14 @@ export default {
             trigger: "change",
           },
         ],
+        sort: [
+          { required: true, message: "请输入排序", trigger: "blur" },
+          {
+            pattern: /^([0-9]\d*)$/,
+            message: "请输入合法的数字",
+            trigger: ["blur", "change"],
+          },
+        ],
         isShow:  [
           { required: true, message: "请选择", trigger: "change" },
         ],

+ 35 - 5
src/views/business/category/index.vue

@@ -68,7 +68,7 @@
           <div>{{ row.sort }}</div>
         </template>
       </el-table-column>
-      <el-table-column label="状态" prop="status"  align="center">
+      <el-table-column label="状态" prop="status" align="center">
         <template slot-scope="{ row }">
           <el-tag :type="row.isShow === 1 ? 'success' : 'info'">{{
             row.isShow === 1 ? "显示" : "不显示"
@@ -76,12 +76,16 @@
         </template>
       </el-table-column>
       <el-table-column label="操作" align="center">
-        <template>
+        <template slot-scope="{ row }">
           <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
+              v-hasPermi="['business:category:remove']"
+              type="text"
+              class="del"
+              @click="del(row)"
               >删除</el-button
             >
           </div>
@@ -98,7 +102,11 @@
       @pagination="getList"
     />
 
-    <category-create v-if="createShow" :dialog-show="createShow" @close="close" />
+    <category-create
+      v-if="createShow"
+      :dialog-show="createShow"
+      @close="close"
+    />
   </div>
 </template>
 <script>
@@ -156,10 +164,32 @@ export default {
           this.loading = false;
         });
     },
-    handleQuery() {},
+
+    del(item) {
+      this.$confirm(`确认删除分类 “${item.name}” 吗?`, "删除分类", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      }).then(() => {
+        goodsCategoryRemove({ categoryId: item.categoryId }).then((res) => {
+          if (res.code === 0) {
+            this.$message.success("操作已完成!");
+            this.getList();
+          }
+        });
+      });
+    },
+
+    // 重置
+    resetQuery() {
+      this.pageParams.pageNum = 1
+      this.getList();
+    },
+
     handleAdd() {
       this.createShow = true;
     },
+
     // 关闭发货弹框
     close() {
       this.createShow = false;