Ver código fonte

商品分类管理增加排序

1004749546@qq.com 4 anos atrás
pai
commit
51492669fe
1 arquivos alterados com 51 adições e 5 exclusões
  1. 51 5
      src/views/shopSetting/goodsClass.vue

+ 51 - 5
src/views/shopSetting/goodsClass.vue

@@ -53,7 +53,23 @@
           @change="changeFlagHandle(text, record)" />
         <span v-if="!$hasPermissions('B_goodsClass_enable')">--</span>
       </span>
-      </span></s-table>
+      <!-- 排序 -->
+      <template slot="sort" slot-scope="text, record, index">
+        <a-icon
+          title="下移"
+          v-if="index != list.length-1"
+          :style="{ fontSize: '18px', color: '#1891FF', cursor: 'pointer',padding:'0 10px' }"
+          @click="changeSort(index,record,0)"
+          type="arrow-down" />
+        <a-icon
+          title="上移"
+          v-if="index != 0"
+          :style="{ fontSize: '18px', color: '#1891FF',cursor: 'pointer', padding:'0 10px' }"
+          @click="changeSort(index,record,1)"
+          type="arrow-up" />
+        <span v-if="list.length===1">--</span>
+      </template>
+    </s-table>
     <add-goodsClass-modal
       :itemId="itemId"
       :itemData="itemData"
@@ -91,6 +107,7 @@ export default {
       itemId: null, // 编辑行id
 	  itemData: {}, // 编辑行数据
       formLayout: 'horizontal',
+	  list: [], // 列表数据
       form: this.$form.createForm(this),
       // 表头
       columns: [{
@@ -135,6 +152,14 @@ export default {
           return text || '--'
         }
       },
+	  {
+	    title: '排序',
+	    width: 200,
+	    align: 'center',
+	    scopedSlots: {
+	      customRender: 'sort'
+	    }
+	  },
       {
         title: '操作',
         align: 'center',
@@ -149,6 +174,7 @@ export default {
         return getGoodsClassList(
           Object.assign(parameter, this.searchData)
         ).then(res => {
+          this.list = res.data.list || []
           const no = (res.data.pageNo - 1) * res.data.pageSize
           if (res.status == 200) {
             for (let i = 0; i < res.data.list.length; i++) {
@@ -225,11 +251,31 @@ export default {
         })
       }
     },
-    beforeRouteEnter (to, from, next) {
-      next(vm => {
-        vm.resetForm()
-      })
+    // 上移 下移 排序 index:下标  item:数据  type:类型 0 下移 1 上移
+    changeSort (index, item, type) {
+	  const indexThat = type === 0 ? index + 1 : index - 1
+	  const params = [{
+	    'id': item.id,
+	    'sort': item.sort
+	  },
+	  {
+	    'id': this.list[indexThat].id,
+	    'sort': this.list[indexThat].sort
+	  }
+	  ]
+	  goodsUpdateSort(params).then(res => {
+	    if (res.status == 200) {
+	      this.$refs.table.refresh()
+	    } else {
+	      this.$message.error(res.message)
+	    }
+	  })
     }
+  },
+  beforeRouteEnter (to, from, next) {
+    next(vm => {
+      vm.resetForm()
+    })
   }
 }
 </script>