chenrui 9 hónapja
szülő
commit
1feaf2f0e0

+ 25 - 0
src/config/router.config.js

@@ -3468,6 +3468,31 @@ export const asyncRouterMap = [
           permission: 'M_promotionRulesManagement'
         },
         children: [
+          {
+            path: '/promotionRulesManagement/shoppingManagement',
+            redirect: '/promotionRulesManagement/shoppingManagement/list',
+            name: 'shoppingManagement',
+            component: BlankLayout,
+            meta: {
+              title: '易码通商城',
+              icon: 'file-ppt'
+              // permission: 'M_shoppingManagementList'
+            },
+            hideChildrenInMenu: true,
+            children: [
+              {
+                path: 'list',
+                name: 'shoppingManagementList',
+                component: () => import(/* webpackChunkName: "promotionRulesManagement" */ '@/views/promotionRulesManagement/shoppingManagement/list.vue'),
+                meta: {
+                  title: '易码通商城',
+                  icon: 'file-ppt',
+                  hidden: true
+                  // permission: 'M_shoppingManagementList'
+                }
+              }
+            ]
+          },
           {
             path: '/promotionRulesManagement/promotionManagement',
             redirect: '/promotionRulesManagement/promotionManagement/list',

+ 179 - 0
src/views/promotionRulesManagement/shoppingManagement/addCategoryModal.vue

@@ -0,0 +1,179 @@
+<template>
+  <a-modal
+    centered
+    class="promotionRules-rule-modal"
+    :footer="null"
+    :maskClosable="false"
+    :title="itemSn ? '编辑类目':'新增类目'"
+    v-model="isShow"
+    @cancel="isShow = false"
+    :width="700">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <a-form-model
+        id="promotionRules-rule-form"
+        ref="ruleForm"
+        :model="form"
+        :rules="rules"
+        :label-col="formItemLayout.labelCol"
+        :wrapper-col="formItemLayout.wrapperCol"
+      >
+        <a-form-model-item label="父类名称">
+          滤清器
+        </a-form-model-item>
+        <a-form-model-item label="上传图标" prop="logo">
+          <Upload
+            class="upload"
+            id="promotionEdit-imageSet"
+            v-model="form.logo"
+            ref="imageSet"
+            :fileSize="10"
+            :maxNums="1"
+            @change="changeImage"
+            listType="picture-card"></Upload>
+        </a-form-model-item>
+        <a-form-model-item label="类目名称" prop="name">
+          <a-input
+            id="promotionEdit-title"
+            :maxLength="30"
+            v-model.trim="form.name"
+            placeholder="请输入类目名称(最多5个字符)"
+            :disabled="isDisabled"
+            allowClear/>
+        </a-form-model-item>
+        <a-form-model-item label="优先级" prop="tip">
+          <a-input
+            id="promotionEdit-title"
+            :maxLength="30"
+            v-model.trim="form.tip"
+            placeholder="请输入正整数,数字越大优先级越低"
+            :disabled="isDisabled"
+            allowClear/>
+        </a-form-model-item>
+      </a-form-model>
+      <div class="btn-cont">
+        <a-button id="promotionRules-rule-modal-back" @click="isShow = false" style="margin-right: 15px;">取消</a-button>
+        <a-button type="primary" id="promotionRules-rule-modal-save" @click="handleSave">保存</a-button>
+      </div>
+    </a-spin>
+  </a-modal>
+</template>
+
+<script>
+import { commonMixin } from '@/utils/mixin'
+import { Upload } from '@/components'
+import { promoRuleSave } from '@/api/promoRule'
+export default {
+  name: 'AddCategoryModal',
+  mixins: [commonMixin],
+  components: { Upload },
+  props: {
+    openModal: {//  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    itemSn: {
+      type: String || Number,
+      default: ''
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      formItemLayout: {
+        labelCol: { span: 3 },
+        wrapperCol: { span: 20 }
+      },
+      spinning: false,
+      form: {
+        name: '', //  促销类型
+        tip: '', //  正价品数量
+        logo: undefined //  促销品数量
+      },
+      rules: {
+        name: [{ required: true, message: '请选择促销类型', trigger: 'change' }],
+        tip: [{ required: true, message: '请输入正价品数量', trigger: 'blur' }],
+        logo: [{ required: true, message: '请输入促销品数量', trigger: 'blur' }]
+      }
+    }
+  },
+  methods: {
+    //  图片上传
+    changeImage (file) {
+      this.form.imageSet = file
+    },
+    //  保存
+    handleSave () {
+      const _this = this
+      //  处理表单校验
+      _this.form.normalGoodsList = this.normalGoodsList.length > 0 ? 'a' : ''
+      _this.form.promoGoodsList = this.promoGoodsList.length > 0 ? 'a' : ''
+      this.$refs.ruleForm.validate(valid => {
+        if (valid) {
+          const form = JSON.parse(JSON.stringify(_this.form))
+          form.normalGoodsList = this.normalGoodsList
+          form.promoGoodsList = this.promoGoodsList
+          form.promoActiveSn = this.$route.params.sn
+          if (form.promoRuleType == 'BUY_PROD_GIVE_MONEY' && form.promoType == 'promo_amount_per') { //  买产品送采购额  百分比
+            form.promoAmountPer = Number(form.promoAmountPer) / 100
+            form.orderAmounts = ''
+            form.promoAmount = ''
+          } else if (form.promoRuleType == 'BUY_PROD_GIVE_MONEY' && form.promoType == 'promo_amount') { //  买产品送采购额  金额
+            form.orderAmount = form.orderAmounts
+            form.promoAmountPer = ''
+          }
+          if (!_this.itemSn) { delete form.id }
+          _this.spinning = true
+          promoRuleSave(form).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              setTimeout(() => {
+                _this.$emit('ok')
+                _this.isShow = false
+                _this.spinning = false
+              }, 1000)
+            } else {
+              _this.spinning = false
+            }
+          })
+        } else {
+          console.log('error submit!!')
+          return false
+        }
+      })
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+        // this.$refs.ruleForm.resetFields()
+      }
+    },
+    itemSn (newValue, oldValue) {
+      if (this.isShow && newValue) {
+        this.getDetail()
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less">
+.promotionRules-rule-modal {
+	.ant-modal-body {
+		padding: 40px 40px 24px;
+	}
+	.btn-cont {
+		text-align: center;
+		margin: 35px 0 10px;
+	}
+  .ant-radio + span{
+    line-height: 40px;
+  }
+}
+</style>

+ 224 - 0
src/views/promotionRulesManagement/shoppingManagement/list.vue

@@ -0,0 +1,224 @@
+<template>
+  <a-card size="small" :bordered="false" class="marketingDivisionSetNew-wrap">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <!-- 操作按钮 -->
+      <div ref="tableSearch" class="table-operator" style="border: 0;">
+        <a-button id="marketingDivisionSetNew-add" type="primary" @click="addCategory">新增类目</a-button>
+      </div>
+      <!-- 列表 -->
+      <s-table
+        class="sTable fixPagination"
+        ref="table"
+        :style="{ height: tableHeight+70+'px'}"
+        size="small"
+        :rowKey="(record) => record.id"
+        :columns="columns"
+        :showPagination="false"
+        :data="loadData"
+        :scroll="{ y: tableHeight }"
+        :defaultLoadData="false"
+        bordered>
+        <template slot="titles" slot-scope="text, record">
+          {{ record.type && record.type == 'root' ? record.subareaName : record.subareaAreaName }}
+        </template>
+        <!-- 操作 -->
+        <template slot="action" slot-scope="text, record">
+          <a-button
+            size="small"
+            type="link"
+            class="button-info"
+            @click="handleEdit(record)"
+            :id="'marketingDivisionSetNew-edit-btn'+record.id">编辑</a-button>
+          <a-button
+            size="small"
+            type="link"
+            class="button-info"
+            v-if="record.type && record.type == 'root'"
+            @click="addZone(record)"
+            :id="'marketingDivisionSetNew-edit-btn'+record.id">添加子类目</a-button>
+          <a-button
+            size="small"
+            type="link"
+            class="button-success"
+            v-else
+            @click="handleView(record)"
+            :id="'marketingDivisionSetNew-edit-btn'+record.id">添加产品</a-button>
+          <a-button
+            size="small"
+            type="link"
+            class="button-error"
+            @click="handleDel(record)"
+            :id="'marketingDivisionSetNew-del-btn'+record.id">删除</a-button>
+        </template>
+      </s-table>
+    </a-spin>
+    <!-- 新增类目 -->
+    <addCategoryModal
+      v-drag
+      :openModal="openCategoryModal"
+      @ok="$refs.table.refresh()"
+      @close="openCategoryModal=false"></addCategoryModal>
+    <!-- 新增分区 -->
+    <addZoneModal
+      v-drag
+      :openModal="openZoneModal"
+      :parentData="parentData"
+      @ok="$refs.table.refresh()"
+      @close="openZoneModal=false"></addZoneModal>
+    <!-- 查看经销商 -->
+    <viewDealers
+      :showModal="openDealerModal"
+      :parentData="parentData"
+      @close="openDealerModal=false"></viewDealers>
+  </a-card>
+</template>
+
+<script>
+import { commonMixin } from '@/utils/mixin'
+// 组件
+import { STable, VSelect } from '@/components'
+import addCategoryModal from './addCategoryModal.vue'
+// import addZoneModal from './addZoneModal.vue'
+// import viewDealers from './viewDealers.vue'
+// 接口
+import { subareaQueryAll, deleteSubareaBySn, deleteSubareaAreaBySn } from '@/api/subarea'
+export default {
+  name: 'MarketingDivisionSetNew',
+  mixins: [commonMixin],
+  components: { STable, VSelect, addCategoryModal },
+  data () {
+    return {
+      spinning: false,
+      tableHeight: 0, // 表格高度
+      openCategoryModal: false, // 打开新增类目弹窗
+
+      openZoneModal: false, // 打开分区弹窗
+      openDealerModal: false, // 打开经销商弹窗
+      columns: [
+        { title: '类目名称', dataIndex: 'createDate', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '图片', scopedSlots: { customRender: 'titles' }, width: '70%', align: 'left' },
+        { title: '优先级', dataIndex: 'remark', width: '13%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '创建时间', dataIndex: 'remark', width: '13%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '状态', scopedSlots: { customRender: 'titles' }, width: '70%', align: 'left' },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: '30%', align: 'center' }
+      ],
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        this.spinning = true
+        return subareaQueryAll(parameter).then(res => {
+          let data
+          if (res.status == 200) {
+            data = res.data
+            // 计算列表序号
+            const no = 0
+            for (var i = 0; i < data.length; i++) {
+              data[i].no = no + i + 1
+              data[i].children = data[i].subareaAreaList || undefined
+              data[i].type = 'root'
+            }
+          }
+          this.spinning = false
+          return data
+        })
+      },
+      itemId: null, // 营销分区id
+      parentData: null// 营销分区一行数据
+    }
+  },
+  methods: {
+    // 新增类目
+    addCategory () {
+      this.openCategoryModal = true
+    },
+    // 新增分区
+    addZone (row) {
+      console.log(row)
+      this.openZoneModal = true
+      this.parentData = row
+    },
+    // 删除
+    handleDel (row) {
+      const _this = this
+      this.$confirm({
+        title: '提示',
+        content: '确定要删除吗?删除后相关用户权限自动解绑。',
+        centered: true,
+        onOk () {
+          _this.spinning = true
+          const delFun = row.type && row.type == 'root' ? deleteSubareaBySn : deleteSubareaAreaBySn
+          const params = { sn: row.type && row.type == 'root' ? row.subareaSn : row.subareaAreaSn }
+          delFun(params).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$refs.table.refresh()
+              _this.spinning = false
+            } else {
+              _this.spinning = false
+            }
+          })
+        }
+      })
+    },
+    //  编辑
+    handleEdit (row) {
+      // 大区
+      if (row.type && row.type == 'root') {
+        this.itemId = row && row.subareaSn ? row.subareaSn : null
+        this.openAreaModal = true
+      } else {
+        // 分区
+        this.parentData = row
+        this.openZoneModal = true
+      }
+    },
+    // 查看经销商
+    handleView (row) {
+      this.parentData = row
+      this.openDealerModal = true
+    },
+    // 初始化
+    pageInit () {
+      const _this = this
+      this.$nextTick(() => { // 页面渲染完成后的回调
+        _this.setTableH()
+      })
+    },
+    // 计算表格高度
+    setTableH () {
+      const tableSearchH = this.$refs.tableSearch.offsetHeight
+      this.tableHeight = window.innerHeight - tableSearchH - 230
+    }
+  },
+  watch: {
+    '$store.state.app.winHeight' (newValue, oldValue) { //  窗口变更时,需同时更改表格高度
+      this.setTableH()
+    }
+  },
+  mounted () {
+    if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
+      this.pageInit()
+      this.$refs.table.refresh()
+    }
+  },
+  activated () {
+    // 如果是新页签打开,则重置当前页面
+    if (this.$store.state.app.isNewTab) {
+      this.pageInit()
+      this.$refs.table.refresh()
+    }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+      this.$refs.table.refresh()
+    }
+  },
+  beforeRouteEnter (to, from, next) {
+    next(vm => {})
+  }
+}
+</script>
+<style lang="less">
+  .marketingDivisionSetNew-wrap{
+    height: 100%;
+  }
+</style>