Przeglądaj źródła

Merge branch 'deploy' of http://git.chelingzhu.com/jianguan-web/jg-ocs-html into deploy

lilei 4 lat temu
rodzic
commit
2d75d520e4

+ 39 - 0
src/api/allocateType.js

@@ -0,0 +1,39 @@
+import { axios } from '@/utils/request'
+
+//  调拨类型管理 列表  分页
+export const allocateTypeList = (params) => {
+  const url = `/allocateType/queryPage/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
+// 调拨类型管理  新增/编辑
+export const allocateTypeSave = params => {
+  return axios({
+    url: '/allocateType/save',
+    data: params,
+    method: 'post'
+  })
+}
+
+// 调拨类型管理  删除
+export const allocateTypeDel = params => {
+  return axios({
+    url: `/allocateType/delete/${params.sn}`,
+    data: {},
+    method: 'get'
+  })
+}
+
+// 调拨类型管理  详情
+export const allocateTypeDetail = params => {
+  return axios({
+    url: `/allocateType/findBySn/${params.sn}`,
+    data: {},
+    method: 'get'
+  })
+}

+ 68 - 0
src/api/power-mduser.js

@@ -0,0 +1,68 @@
+import { axios } from '@/utils/request'
+
+// 重置密码
+export const resetPSD = params => {
+  return axios({
+    url: '/mduser/resetPwd',
+    data: params,
+    method: 'POST'
+  })
+}
+
+// 获取列表数据
+export const getPowerUserList = params => {
+  const url = `/mduser/queryLike/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios({
+    url: url,
+    data: params,
+    method: 'POST'
+  })
+}
+
+// 获取所有用户
+export const getUserAllList = params => {
+  const url = `/mduser/findAll`
+  return axios({
+    url: url,
+    data: params,
+    method: 'POST'
+  })
+}
+
+// 改变权限状态接口
+export const updateEnableStatus = params => {
+  return axios({
+    url: `/mduser/enable/${params.id}/${params.flag}`,
+    data: {},
+    method: 'get'
+  })
+}
+
+// 删除用户接口
+export const delectUserPower = params => {
+  return axios({
+    url: `/mduser/delete/${params.id}`,
+    data: {},
+    method: 'get'
+  })
+}
+
+// 新增/编辑保存接口
+export const saveUserPower = params => {
+  return axios({
+    url: '/mduser/save',
+    data: params,
+    method: 'POST'
+  })
+}
+
+// 获取角色列表接口
+export const getRoleList = params => {
+  return axios({
+    url: '/mdrole/findAll',
+    data: params,
+    method: 'POST'
+  })
+}

+ 2 - 2
src/config/router.config.js

@@ -1531,8 +1531,8 @@ export const asyncRouterMap = [
         component: PageView,
         meta: {
           title: '基础设置',
-          icon: 'pushpin',
-          permission: 'M_basicData'
+          icon: 'pushpin'
+          // permission: 'M_basicData'
         },
         children: [
           {

+ 152 - 0
src/views/basicData/transferTypeManagement/editModal.vue

@@ -0,0 +1,152 @@
+<template>
+  <a-modal
+    centered
+    class="transferTypeManagementEdit-modal"
+    :footer="null"
+    :maskClosable="false"
+    :title="modalTit"
+    v-model="isShow"
+    @cancle="isShow=false"
+    :width="800">
+    <!-- 表单 -->
+    <div>
+      <a-form-model
+        id="transferTypeManagementEdit-form"
+        ref="ruleForm"
+        :model="form"
+        :rules="rules"
+        :label-col="formItemLayout.labelCol"
+        :wrapper-col="formItemLayout.wrapperCol"
+      >
+        <a-form-model-item label="调拨类别" prop="allocateCategory">
+          <v-select code="ALLOCATE_CATEGORY" id="transferTypeManagementEdit-allocateCategory" v-model="form.allocateCategory" allowClear placeholder="请选择调拨类别"></v-select>
+        </a-form-model-item>
+        <a-form-model-item label="调拨类型名称" prop="name">
+          <a-input
+            id="transferTypeManagementEdit-name"
+            :maxLength="30"
+            v-model.trim="form.name"
+            @change="filterEmpty"
+            placeholder="请输入调拨类型名称(最多30个字符)"
+            allowClear />
+        </a-form-model-item>
+      </a-form-model>
+      <div class="btn-cont">
+        <a-button type="primary" id="storeTransferOut-type-edit-modal-save" @click="handleSave">保存</a-button>
+        <a-button id="storeTransferOut-type-edit-modal-back" @click="isShow = false" style="margin-left: 15px;">返回列表</a-button>
+      </div>
+    </div>
+  </a-modal>
+</template>
+
+<script>
+import { VSelect } from '@/components'
+import { allocateTypeSave } from '@/api/allocateType'
+export default {
+  name: 'TransferTypeManagementEditModal',
+  components: { VSelect },
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    itemSn: {
+      type: [Number, String],
+      default: ''
+    },
+    nowData: {
+      type: Object,
+      default: null
+    }
+  },
+  computed: {
+    modalTit () {
+      return (this.itemSn ? '编辑' : '新增') + '调拨类型'
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      detailsData: null, //  品牌数据
+      formItemLayout: {
+        labelCol: { span: 6 },
+        wrapperCol: { span: 16 }
+      },
+      form: {
+        name: '', // 调拨类型名称
+        allocateCategory: undefined //  调拨类别
+      },
+      rules: {
+        name: [
+          { required: true, message: '请输入调拨类型名称', trigger: 'blur' }
+        ],
+        allocateCategory: [
+          { required: true, message: '请选择调拨类别', trigger: 'change' }
+        ]
+      }
+    }
+  },
+  methods: {
+    filterEmpty () {
+      let str = this.form.name
+      str = str.replace(/\ +/g, '')
+      str = str.replace(/[ ]/g, '')
+      str = str.replace(/[\r\n]/g, '')
+      this.form.name = str
+    },
+    //  保存
+    handleSave () {
+      const _this = this
+      this.$refs.ruleForm.validate(valid => {
+        if (valid) {
+          const form = _this.form
+          form.id = _this.itemSn ? _this.itemSn : null
+          allocateTypeSave(form).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.isShow = 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.form.name = this.nowData && this.nowData.name ? this.nowData.name : ''
+        this.form.allocateCategory = this.nowData && this.nowData.allocateCategory ? this.nowData.allocateCategory : ''
+      } else { //  添加
+        this.form.name = ''
+        this.form.allocateCategory = undefined
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less">
+  .transferTypeManagementEdit-modal{
+    .ant-modal-body {
+      padding: 40px 40px 24px;
+    }
+    .btn-cont {
+      text-align: center;
+      margin: 35px 0 10px;
+    }
+  }
+</style>

+ 100 - 3
src/views/basicData/transferTypeManagement/list.vue

@@ -1,8 +1,105 @@
 <template>
+  <a-card size="small" :bordered="false" class="transferTypeManagementList-wrap">
+    <!-- 操作按钮 -->
+    <div class="table-operator-nobor">
+      <a-button
+        id="transferTypeManagementList-add"
+        type="primary"
+        class="button-error"
+        @click="handleEdit()">新增</a-button>
+    </div>
+    <!-- 列表 -->
+    <s-table
+      class="sTable"
+      ref="table"
+      size="default"
+      :rowKey="(record) => record.id"
+      :columns="columns"
+      :data="loadData"
+      :scroll="{ y: 300 }"
+      bordered>
+      <!-- 操作 -->
+      <template slot="action" slot-scope="text, record">
+        <a-button
+          size="small"
+          type="link"
+          class="button-info"
+          @click="handleEdit(record)"
+          id="transferTypeManagementList-edit-btn">编辑</a-button>
+        <a-button
+          size="small"
+          type="link"
+          class="button-error"
+          @click="handleDel(record)"
+          id="transferTypeManagementList-del-btn">删除</a-button>
+      </template>
+    </s-table>
+    <!-- 新增/编辑 -->
+    <transfer-type-management-edit-modal :openModal="openModal" :nowData="nowData" :itemSn="itemSn" @close="closeModal" />
+  </a-card>
 </template>
 
 <script>
+import { STable, VSelect } from '@/components'
+import transferTypeManagementEditModal from './editModal.vue'
+import { allocateTypeList, allocateTypeDel } from '@/api/allocateType'
+export default {
+  components: { STable, VSelect, transferTypeManagementEditModal },
+  data () {
+    return {
+      columns: [
+        { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
+        { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center' },
+        { title: '调拨类别', dataIndex: 'allocateCategoryDictValue', width: 200, align: 'center' },
+        { title: '调拨类型名称', dataIndex: 'name', align: 'center', ellipsis: true },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center' }
+      ],
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        return allocateTypeList(Object.assign(parameter, {})).then(res => {
+          const data = res.data
+          const no = (data.pageNo - 1) * data.pageSize
+          for (var i = 0; i < data.list.length; i++) {
+            data.list[i].no = no + i + 1
+          }
+          return data
+        })
+      },
+      openModal: false, //  新增编辑调拨类型  弹框
+      itemSn: '', //  当前sn
+      nowData: null //  当前记录数据
+    }
+  },
+  methods: {
+    //  新增/编辑
+    handleEdit (row) {
+      this.itemSn = row ? row.allocateTypeSn : null
+      this.nowData = row || null
+      this.openModal = true
+    },
+    //  删除
+    handleDel (row) {
+      const _this = this
+      _this.$confirm({
+        title: '提示',
+        content: '删除后原数据不可恢复,是否删除?',
+        centered: true,
+        onOk () {
+          allocateTypeDel({ sn: row.allocateTypeSn }).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$refs.table.refresh()
+            }
+          })
+        }
+      })
+    },
+    //  关闭弹框
+    closeModal () {
+      this.itemSn = ''
+      this.openModal = false
+      this.$refs.table.refresh(true)
+    }
+  }
+}
 </script>
-
-<style>
-</style>

+ 5 - 21
src/views/dealerManagement/dealerAccountManagement/list.vue

@@ -64,10 +64,10 @@
 </template>
 
 <script>
-// import { dealerProductBrandList, dealerProductBrandUpdate } from '@/api/dealerProductBrand'
 import { STable, VSelect } from '@/components'
 import dealerAccountEditModal from './editModal.vue'
 import dealerAccountDetailModal from './detailModal.vue'
+import { getPowerUserList } from '@/api/power-mduser'
 export default {
   components: { STable, VSelect, dealerAccountEditModal, dealerAccountDetailModal },
   data () {
@@ -94,30 +94,14 @@ export default {
         if (this.tableHeight == 0) {
           this.tableHeight = window.innerHeight - 380
         }
-        // return dealerProductBrandList(Object.assign(parameter, this.queryParam)).then(res => {
-        //   const data = res.data
-        //   const no = (data.pageNo - 1) * data.pageSize
-        //   for (var i = 0; i < data.list.length; i++) {
-        //     data.list[i].no = no + i + 1
-        //   }
-        //   this.disabled = false
-        //   return data
-        // })
-        const _this = this
-        return new Promise(function (resolve, reject) {
-          const data = {
-            pageNo: 1,
-            pageSize: 10,
-            list: [
-              { id: '1', productNum: 'jgqp11111111111', productName: '产品1', productOldNum: 'jgqp111123545', productBrand: '箭冠品牌', productType: '产品分类1', inventoryNum: '5', inventoryMoney: '122' }
-            ]
-          }
+        return getPowerUserList(Object.assign(parameter, this.queryParam)).then(res => {
+          const data = res.data
           const no = (data.pageNo - 1) * data.pageSize
           for (var i = 0; i < data.list.length; i++) {
             data.list[i].no = no + i + 1
           }
-          _this.disabled = false
-          resolve(data)
+          this.disabled = false
+          return data
         })
       },
       openModal: false, //  新增编辑  弹框

+ 79 - 24
src/views/promotionRulesManagement/promotionRules/chooseBrandModal.vue

@@ -7,15 +7,21 @@
     title="选择产品品牌"
     v-model="isShow"
     @cancle="isShow=false"
-    width="50%">
+    :width="800">
     <div class="chooseBrand-con">
       <div>
-        <a-checkbox :indeterminate="indeterminate" :checked="checkAll" @change="onCheckAllChange">
-          全选
-        </a-checkbox>
+        <a-checkbox :checked="checkAll" @change="onCheckAllChange">全选</a-checkbox>
       </div>
       <a-divider />
-      <a-checkbox-group v-model="checkedList" :options="plainOptions" @change="onChange" />
+      <a-checkbox-group v-model="checkedList" @change="onChange">
+        <a-row style="height: 400px;overflow-y: scroll;">
+          <a-col :span="6" v-for="item in brandList" :key="item.brandSn">
+            <a-checkbox :value="item.brandSn">
+              {{ item.brandName }}
+            </a-checkbox>
+          </a-col>
+        </a-row>
+      </a-checkbox-group>
       <!-- 按钮 -->
       <div class="btn-con">
         <a-button
@@ -23,6 +29,7 @@
           id="chooseBrand-submit"
           size="large"
           class="button-primary"
+          @click="handleSave"
           style="padding: 0 60px;">保存</a-button>
         <a-button
           id="chooseBrand-cancel"
@@ -36,8 +43,7 @@
 </template>
 
 <script>
-const plainOptions = ['箭冠', '非箭冠', 'NGK']
-const defaultCheckedList = ['箭冠', 'NGK']
+import { productBrandQuery } from '@/api/productBrand'
 export default {
   name: 'ChooseBrandModal',
   props: {
@@ -45,34 +51,73 @@ export default {
       type: Boolean,
       default: false
     },
-    itemId: {
-      type: [Number, String],
-      default: ''
-    },
-    nowData: {
-      type: Object,
-      default: null
+    chooseData: {
+      type: Array,
+      default: () => {
+        return []
+      }
     }
   },
   data () {
     return {
       isShow: this.openModal, //  是否打开弹框
-      checkedList: defaultCheckedList,
-      indeterminate: true,
-      checkAll: false,
-      plainOptions
+      checkAll: false, //  全选
+      checkedList: [], //  选中项
+      checkedRowList: [], //  选中项
+      brandList: [] //  品牌数据
     }
   },
   methods: {
+    // 保存
+    handleSave () {
+      const _this = this
+      if (this.checkedList.length < 1) {
+        this.$message.warning('请在列表勾选后再进行操作!')
+        return
+      }
+      this.checkedRowList = []
+      _this.brandList.map(item => {
+        if (_this.checkedList.indexOf(item.brandSn) != -1) {
+          _this.checkedRowList.push(item)
+        }
+      })
+      this.$emit('ok', this.checkedRowList)
+      this.isShow = false
+    },
+    // change
     onChange (checkedList) {
-      this.indeterminate = !!checkedList.length && checkedList.length < plainOptions.length
-      this.checkAll = checkedList.length === plainOptions.length
+      const _this = this
+      this.checkAll = checkedList.length === this.brandList.length
+      this.brandList.map(item => {
+        if (_this.checkedList.indexOf(item.brandSn) != -1) {
+          _this.checkedRowList.push(item)
+        }
+      })
     },
+    // 全选
     onCheckAllChange (e) {
-      Object.assign(this, {
-        checkedList: e.target.checked ? plainOptions : [],
-        indeterminate: false,
-        checkAll: e.target.checked
+      const _this = this
+      this.checkAll = e.target.checked
+      if (e.target.checked) {
+        this.checkedList = []
+        this.checkedRowList = []
+        this.brandList.map(item => {
+          _this.checkedList.push(item.brandSn)
+          _this.checkedRowList.push(item)
+        })
+      } else {
+        this.checkedList = []
+        this.checkedRowList = []
+      }
+    },
+    // 获取品牌数据
+    getBrandList () {
+      productBrandQuery({}).then(res => {
+        if (res.status == 200) {
+          this.brandList = res.data
+        } else {
+          this.brandList = []
+        }
       })
     }
   },
@@ -85,6 +130,16 @@ export default {
     isShow (newValue, oldValue) {
       if (!newValue) {
         this.$emit('close')
+      } else {
+        const _this = this
+        this.checkedRowList = this.chooseData
+        this.checkedList = []
+        this.chooseData.map(item => {
+          _this.checkedList.push(item.goodsSn)
+        })
+        if (this.brandList.length == 0) {
+          this.getBrandList()
+        }
       }
     }
   }

+ 1 - 2
src/views/promotionRulesManagement/promotionRules/chooseCustomerModal.vue

@@ -211,10 +211,9 @@ export default {
       if (!newValue) {
         this.$emit('close')
       } else {
-        console.log(this.selectedRowKeys, '++++', this.chooseCust)
         this.selectedRowKeys = this.chooseCust
         if (this.addrProvinceList.length == 0) {
-          // this.getArea('province')
+          this.getArea('province')
         }
       }
     }

+ 0 - 240
src/views/promotionRulesManagement/promotionRules/choosePosPriceProductsModal.vue

@@ -1,240 +0,0 @@
-<template>
-  <a-modal
-    centered
-    class="choosePosPriceProducts-modal"
-    :footer="null"
-    :maskClosable="false"
-    title="选择正价产品"
-    v-model="isShow"
-    @cancle="isShow=false"
-    width="80%">
-    <div class="table-operator">
-      <a-button id="choosePosPriceProducts-brand" type="primary" class="button-error" @click="openBrandModal=true">选择产品品牌</a-button>
-      <a-button id="choosePosPriceProducts-type" type="primary" class="button-info" @click="openTypeModal=true">选择产品分类</a-button>
-      <a-button id="choosePosPriceProducts-product" type="primary" class="button-success" @click="openProductsModal=true">选择产品</a-button>
-    </div>
-    <!-- 参与产品 -->
-    <div class="products-con">
-      <!-- 标题栏 -->
-      <div class="products-header">
-        <div class="products-tit">
-          参与产品:<a-button id="choosePosPriceProducts-import" type="primary" class="button-info" @click="openGuideModal=true">导入产品</a-button>
-        </div>
-        <div class="products-operation">
-          <a-row :gutter="15">
-            <a-col :span="8">
-              <a-select
-                id="choosePosPriceProducts-isLimit"
-                placeholder="请选择"
-                v-model="isLimit"
-                style="width: 100%;">
-                <a-select-option v-for="item in limitTypeList" :key="item.val" :value="item.val">{{ item.name }}</a-select-option>
-              </a-select>
-            </a-col>
-            <a-col :span="8">
-              <a-input-number
-                v-if="isLimit==0"
-                id="choosePosPriceProducts-limitQuantity"
-                v-model="limitQuantity"
-                :min="1"
-                :max="999999"
-                :precision="0"
-                style="width: 85%;margin-right: 5px;"
-                placeholder="请输入限制数量(1~999999)"
-                allowClear />
-            </a-col>
-            <a-col :span="8">
-              <a-button id="choosePosPriceProducts-import" type="primary" class="button-info" @click="handlerBulkCopy">批量复制</a-button>
-            </a-col>
-          </a-row>
-        </div>
-      </div>
-      <!-- 表格 -->
-      <a-table
-        class="sTable"
-        ref="table"
-        size="small"
-        :rowKey="(record) => record.id"
-        :columns="columns"
-        :dataSource="loadData"
-        :scroll="{ x: 1200, y: 500 }"
-        :pagination="paginationProps"
-        bordered>
-        <!-- 起订量限制 -->
-        <template slot="putQty" slot-scope="text, record">
-          <a-select
-            id="choosePosPriceProducts-isLimit"
-            placeholder="请选择"
-            v-model="record.isLimit"
-            style="width: 100%;">
-            <a-select-option v-for="item in limitTypeList" :key="item.val" :value="item.val">{{ item.name }}</a-select-option>
-          </a-select>
-          <a-input-number
-            v-if="record.isLimit==0"
-            id="choosePosPriceProducts-limitQuantity"
-            v-model="record.limitQuantity"
-            :precision="0"
-            :min="1"
-            :max="999999"
-            placeholder="请输入限制数量(1~999999)"
-            style="width: 100%;" />
-        </template>
-        <!-- 操作 -->
-        <template slot="action" slot-scope="text, record">
-          <a-button size="small" type="primary" class="button-error" @click="handleDel(record)" id="choosePosPriceProducts-del-btn">删除</a-button>
-        </template>
-      </a-table>
-      <!-- 按钮 -->
-      <div class="btn-con">
-        <a-button
-          type="primary"
-          id="choosePosPriceProducts-submit"
-          size="large"
-          class="button-primary"
-          style="padding: 0 60px;">保存</a-button>
-        <a-button
-          id="choosePosPriceProducts-cancel"
-          size="large"
-          class="button-cancel"
-          @click="isShow=false"
-          style="padding: 0 60px;margin-left: 15px;">取消</a-button>
-      </div>
-    </div>
-    <!-- 选择产品品牌 -->
-    <chooseBrandModal :openModal="openBrandModal" @close="openBrandModal=false" />
-    <!-- 选择产品分类 -->
-    <chooseTypeModal :openModal="openTypeModal" @close="openTypeModal=false" />
-    <!-- 选择产品 -->
-    <chooseProductsModal :openModal="openProductsModal" @close="openProductsModal=false" />
-    <!-- 导入产品 -->
-    <importGuideModal :openModal="openGuideModal" @close="openGuideModal=false" />
-  </a-modal>
-</template>
-
-<script>
-import ChooseProductsModal from './chooseProductsModal.vue'
-import ChooseBrandModal from './chooseBrandModal.vue'
-import ChooseTypeModal from './chooseTypeModal.vue'
-import ImportGuideModal from './importGuideModal.vue'
-export default {
-  name: 'ChoosePosPriceProductsModal',
-  components: { ChooseProductsModal, ChooseBrandModal, ChooseTypeModal, ImportGuideModal },
-  props: {
-    openModal: { //  弹框显示状态
-      type: Boolean,
-      default: false
-    },
-    itemId: {
-      type: [Number, String],
-      default: ''
-    },
-    nowData: {
-      type: Object,
-      default: null
-    }
-  },
-  data () {
-    return {
-      isShow: this.openModal, //  是否打开弹框
-      isLimit: undefined, //  起订量限制 批量
-      limitQuantity: '', //  限制数量
-      limitTypeList: [
-        { name: '按设置数量', val: 0 },
-        { name: '按整箱', val: 1 }
-      ],
-      // 表头
-      columns: [
-        { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
-        { title: '类型', dataIndex: 'origCode', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '类型名称', dataIndex: 'orisgCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '产品名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '产品编码', dataIndex: 'code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '起订量限制', scopedSlots: { customRender: 'putQty' }, width: 220, align: 'center' },
-        { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
-      ],
-      loadData: [],
-      pageNo: 1, //  分页页码
-      pageSize: 10, //  分页 每页多少条
-      paginationProps: {
-        showSizeChanger: true, //  是否可以改变 pageSize
-        total: 0, //  分页总条数
-        current: 1,
-        onShowSizeChange: (current, pageSize) => this.changePageSize(current, pageSize),
-        onChange: (current) => this.changePage(current)
-      },
-      openBrandModal: false, //  选择产品品牌
-      openTypeModal: false, //  选择产品分类
-      openProductsModal: false, //  选择产品
-      openGuideModal: false //  导入产品引导
-    }
-  },
-  methods: {
-    // 批量复制
-    handlerBulkCopy () {
-      const _this = this
-      this.$confirm({
-        title: '提示',
-        content: '批量复制会覆盖原单独设置的规则,确定要批量复制吗?',
-        centered: true,
-        onOk () {
-
-        }
-      })
-    },
-    // 删除
-    handleDel (record) {
-
-    },
-    //  分页  一页多少条change
-    changePageSize (current, pageSize) {
-      this.pageNo = current
-      this.pageSize = pageSize
-      this.getDealerProductList()
-    },
-    //  分页 页码change
-    changePage (current) {
-      this.pageNo = current
-      this.getDealerProductList()
-    }
-  },
-  watch: {
-    //  父页面传过来的弹框状态
-    openModal (newValue, oldValue) {
-      this.isShow = newValue
-    },
-    //  重定义的弹框状态
-    isShow (newValue, oldValue) {
-      if (!newValue) {
-        this.$emit('close')
-      }
-    }
-  }
-}
-</script>
-
-<style lang="less" scoped>
-  .choosePosPriceProducts-modal{
-    // 参与产品
-    .products-con{
-      .products-header{
-        padding: 10px 15px;
-        color: rgba(0,0,0,.85);
-        background-color: #fafafa;
-        border-radius: 6px;
-        margin: 10px 0;
-        display: flex;
-        justify-content: space-between;
-        .products-operation{
-          width: 40%;
-        }
-      }
-      .btn-con{
-        text-align: center;
-        margin: 30px 0 20px;
-        .button-cancel{
-          font-size: 12px;
-        }
-      }
-    }
-  }
-</style>

+ 353 - 0
src/views/promotionRulesManagement/promotionRules/choosePriceProductsModal.vue

@@ -0,0 +1,353 @@
+<template>
+  <a-modal
+    centered
+    class="choosePosPriceProducts-modal"
+    :footer="null"
+    :maskClosable="false"
+    title="选择正价产品"
+    v-model="isShow"
+    @cancle="isShow=false"
+    width="80%">
+    <div class="table-operator">
+      <a-button id="choosePosPriceProducts-brand" type="primary" class="button-error" @click="choosePModal('brand')">选择产品品牌</a-button>
+      <a-button id="choosePosPriceProducts-type" type="primary" class="button-info" @click="choosePModal('type')">选择产品分类</a-button>
+      <a-button id="choosePosPriceProducts-product" type="primary" class="button-success" @click="choosePModal('product')">选择产品</a-button>
+    </div>
+    <!-- 参与产品 -->
+    <div class="products-con">
+      <!-- 标题栏 -->
+      <div class="products-header">
+        <div class="products-tit">
+          参与产品:<a-button id="choosePosPriceProducts-import" type="primary" class="button-info" @click="openGuideModal=true">导入产品</a-button>
+        </div>
+        <div class="products-operation">
+          <a-row :gutter="15">
+            <a-col :span="9">
+              <v-select
+                code="ORDER_GOODS_UNIT"
+                id="choosePosPriceProducts-orderGoodsUnit"
+                v-model="orderGoodsUnit"
+                allowClear
+                placeholder="请选择"
+                style="width: 100%;"
+              ></v-select>
+            </a-col>
+            <a-col :span="10">
+              <a-input-number
+                v-if="orderGoodsUnit=='PROD_UNIT'"
+                id="choosePosPriceProducts-orderGoodsQty"
+                v-model="orderGoodsQty"
+                :min="1"
+                :max="999999"
+                :precision="0"
+                style="width: 85%;margin-right: 5px;"
+                placeholder="请输入限制数量(1~999999)"
+                allowClear />
+            </a-col>
+            <a-col :span="5">
+              <a-button id="choosePosPriceProducts-import" type="primary" class="button-info" @click="handlerBulkCopy">批量复制</a-button>
+            </a-col>
+          </a-row>
+        </div>
+      </div>
+      <!-- 表格 -->
+      <a-table
+        class="sTable"
+        ref="table"
+        size="small"
+        :rowKey="(record, index) => index"
+        :columns="columns"
+        :dataSource="loadData"
+        :scroll="{ x: 1380, y: 500 }"
+        :pagination="false"
+        bordered>
+        <!-- 序号 -->
+        <template slot="no" slot-scope="text, record, index">
+          {{ index+1 }}
+        </template>
+        <!-- 起订量限制 -->
+        <template slot="orderGoodsUnit" slot-scope="text, record">
+          <v-select
+            code="ORDER_GOODS_UNIT"
+            id="choosePosPriceProducts-orderGoodsUnit"
+            v-model="record.orderGoodsUnit"
+            allowClear
+            placeholder="请选择"
+            style="width: 40%;"
+          ></v-select>
+          <a-input-number
+            v-if="record.orderGoodsUnit=='PROD_UNIT'"
+            id="choosePosPriceProducts-orderGoodsQty"
+            v-model="record.orderGoodsQty"
+            :precision="0"
+            :min="1"
+            :max="999999"
+            placeholder="请输入限制数量(1~999999)"
+            style="width: 50%;margin-left: 5px;" />
+        </template>
+        <!-- 操作 -->
+        <template slot="action" slot-scope="text, record, index">
+          <a-button size="small" type="primary" class="button-error" @click="handleDel(record, index)" id="choosePosPriceProducts-del-btn">删除</a-button>
+        </template>
+      </a-table>
+      <!-- 按钮 -->
+      <div class="btn-con">
+        <a-button
+          type="primary"
+          id="choosePosPriceProducts-submit"
+          size="large"
+          class="button-primary"
+          @click="handleSave"
+          style="padding: 0 60px;">保存</a-button>
+        <a-button
+          id="choosePosPriceProducts-cancel"
+          size="large"
+          class="button-cancel"
+          @click="isShow=false"
+          style="padding: 0 60px;margin-left: 15px;">取消</a-button>
+      </div>
+    </div>
+    <!-- 选择产品品牌 -->
+    <chooseBrandModal :openModal="openBrandModal" :chooseData="chooseBrand" @close="openBrandModal=false" @ok="handleBrandOk" />
+    <!-- 选择产品分类 -->
+    <chooseTypeModal :openModal="openTypeModal" :chooseData="chooseType" @close="openTypeModal=false" @ok="handleTypeOk" />
+    <!-- 选择产品 -->
+    <chooseProductsModal :openModal="openProductsModal" :chooseData="chooseProducts" @close="openProductsModal=false" @ok="handleProductsOk" />
+    <!-- 导入产品 -->
+    <importGuideModal :openModal="openGuideModal" @close="openGuideModal=false" />
+  </a-modal>
+</template>
+
+<script>
+import ChooseProductsModal from './chooseProductsModal.vue'
+import ChooseBrandModal from './chooseBrandModal.vue'
+import ChooseTypeModal from './chooseTypeModal.vue'
+import ImportGuideModal from './importGuideModal.vue'
+import { VSelect } from '@/components'
+export default {
+  name: 'ChoosePriceProductsModal',
+  components: { VSelect, ChooseProductsModal, ChooseBrandModal, ChooseTypeModal, ImportGuideModal },
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    ruleType: { //  买产品送产品...
+      type: String,
+      default: ''
+    },
+    goodsType: { //  正价/促销
+      type: String,
+      default: ''
+    },
+    nowData: {
+      type: Array,
+      default: () => {
+        return []
+      }
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      orderGoodsUnit: undefined, //  起订量限制 批量
+      orderGoodsQty: '', //  限制数量
+      // 表头
+      columns: [
+        { title: '序号', scopedSlots: { customRender: 'no' }, width: 80, align: 'center' },
+        { title: '类型', dataIndex: 'goodsTypeName', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '类型名称', dataIndex: 'typeName', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '产品编码', dataIndex: 'code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '起订量限制', scopedSlots: { customRender: 'orderGoodsUnit' }, width: 400, align: 'center' },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
+      ],
+      loadData: [],
+      openBrandModal: false, //  选择产品品牌
+      openTypeModal: false, //  选择产品分类
+      openProductsModal: false, //  选择产品
+      openGuideModal: false, //  导入产品引导
+      chooseBrand: [], //  所选品牌
+      chooseProducts: [], //  所选产品
+      chooseType: [] //  所选分类
+    }
+  },
+  methods: {
+    // 选择产品
+    choosePModal (type) {
+      const productList = []
+      const brandList = []
+      const typeList = []
+      this.loadData.map(item => {
+        if (item.goodsType == 'product') {
+          productList.push(item)
+        } else if (item.goodsType == 'brand') {
+          brandList.push(item)
+        } else if (item.goodsType == 'type') {
+          typeList.push(item)
+        }
+      })
+      if (type == 'product') { //  选择产品
+        this.chooseProducts = productList
+        this.openProductsModal = true
+      } else if (type == 'brand') { //  选择品牌
+        this.chooseBrand = brandList
+        this.openBrandModal = true
+      } else if (type == 'type') { //  选择分类
+        this.chooseType = typeList
+        this.openTypeModal = true
+      }
+    },
+    // 品牌
+    handleBrandOk (obj) {
+      console.log('接收----品牌----', obj)
+      this.chooseBrand = obj
+      this.changeData()
+    },
+    // 产品
+    handleProductsOk (obj) {
+      console.log('接收----产品----', obj)
+      this.chooseProducts = obj
+      this.changeData()
+    },
+    // 分类
+    handleTypeOk (obj) {
+      console.log('接收----分类----', obj)
+      this.chooseType = obj
+      this.changeData()
+    },
+    //  保存
+    handleSave () {
+      const _this = this
+      const arr = []
+      _this.loadData.map((item, index) => {
+        if ((item.orderGoodsUnit == 'PROD_UNIT') && (!item.orderGoodsQty)) {
+          arr.push(index)
+        }
+      })
+      if (arr.length > 0) {
+        this.$message.warning('请完善起订量限制后再保存!')
+        return
+      }
+      console.log('liebiao', this.loadData)
+      this.$emit('ok', this.loadData)
+      this.isShow = false
+    },
+    changeData () {
+      const _this = this
+      _this.loadData = []
+      if (_this.chooseBrand.length > 0) {
+        _this.chooseBrand.map(item => {
+          _this.loadData.push({
+            goodsType: 'brand',
+            goodsTypeName: '品牌',
+            typeName: item.brandName,
+            goodsSn: item.brandSn,
+            orderGoodsUnit: undefined,
+            orderGoodsQty: ''
+          })
+        })
+      }
+      if (_this.chooseType.length > 0) {
+        _this.chooseType.map(item => {
+          _this.loadData.push({
+            goodsType: 'type',
+            goodsTypeName: (item.productTypeLevel == 1 ? '一级' : item.productTypeLevel == 2 ? '二级' : item.productTypeLevel == 3 ? '三级' : '') + '分类',
+            typeName: item.productTypeName,
+            goodsSn: item.productTypeSn,
+            orderGoodsUnit: undefined,
+            orderGoodsQty: ''
+          })
+        })
+      }
+      if (_this.chooseProducts.length > 0) {
+        _this.chooseProducts.map(item => {
+          _this.loadData.push({
+            goodsType: 'product',
+            goodsTypeName: '产品',
+            typeName: item.name,
+            name: item.name,
+            code: item.code,
+            goodsSn: item.productSn,
+            orderGoodsUnit: undefined,
+            orderGoodsQty: ''
+          })
+        })
+      }
+    },
+    // 批量复制
+    handlerBulkCopy () {
+      const _this = this
+      if ((!this.orderGoodsUnit) || ((this.orderGoodsUnit == 'PROD_UNIT') && !this.orderGoodsQty)) {
+        this.$message.warning('请选择需要批量复制的选项值后再操作!')
+        return
+      }
+      this.$confirm({
+        title: '提示',
+        content: '批量复制会覆盖原单独设置的规则,确定要批量复制吗?',
+        centered: true,
+        onOk () {
+          _this.loadData.map(item => {
+            item.orderGoodsUnit = _this.orderGoodsUnit
+            item.orderGoodsQty = _this.orderGoodsQty
+          })
+        }
+      })
+    },
+    // 删除
+    handleDel (record, ind) {
+      this.loadData.splice(ind, 1)
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.chooseBrand = []
+        this.chooseProducts = []
+        this.chooseType = []
+        this.$emit('close')
+      }
+    },
+    nowData: {
+      handler (newValue, oldValue) {
+        if (this.isShow && newValue) {
+          this.loadData = newValue
+        }
+      },
+      deep: true
+    }
+  }
+}
+</script>
+
+<style lang="less" scoped>
+  .choosePosPriceProducts-modal{
+    // 参与产品
+    .products-con{
+      .products-header{
+        padding: 10px 15px;
+        color: rgba(0,0,0,.85);
+        background-color: #fafafa;
+        border-radius: 6px;
+        margin: 10px 0;
+        display: flex;
+        justify-content: space-between;
+        .products-operation{
+          width: 50%;
+        }
+      }
+      .btn-con{
+        text-align: center;
+        margin: 30px 0 20px;
+        .button-cancel{
+          font-size: 12px;
+        }
+      }
+    }
+  }
+</style>

+ 129 - 37
src/views/promotionRulesManagement/promotionRules/chooseProductsModal.vue

@@ -16,14 +16,14 @@
             <a-row :gutter="15">
               <a-col :md="6" :sm="24">
                 <a-form-item label="产品编码">
-                  <a-input id="productInfoList-code" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
+                  <a-input id="chooseProducts-code" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
                 </a-form-item>
               </a-col>
               <a-col :md="6" :sm="24">
                 <a-form-item label="产品品牌">
                   <a-select
                     placeholder="请选择产品品牌"
-                    id="productInfoList-productBrandSn"
+                    id="chooseProducts-productBrandSn"
                     allowClear
                     v-model="queryParam.productBrandSn"
                     :showSearch="true"
@@ -42,39 +42,52 @@
                     expand-trigger="hover"
                     :options="productTypeList"
                     :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
-                    id="productInfoList-productType"
+                    id="chooseProducts-productType"
                     placeholder="请选择产品分类"
                     allowClear />
                 </a-form-item>
               </a-col>
               <a-col :md="6" :sm="24">
-                <a-button style="margin-bottom: 18px;" type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
-                <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="productInfoList-reset">重置</a-button>
+                <a-button style="margin-bottom: 18px;" type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="chooseProducts-refresh">查询</a-button>
+                <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="chooseProducts-reset">重置</a-button>
               </a-col>
             </a-row>
           </a-form>
         </div>
+        <p style="font-weight: bold;">当前已选:{{ selectedRowKeys.length }}个</p>
         <!-- 列表 -->
-        <s-table
+        <a-table
           class="sTable"
           ref="table"
           size="small"
-          :rowKey="(record) => record.id"
+          :rowKey="(record) => record.productSn"
           :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
+          :data-source="loadData"
           :columns="columns"
-          :data="loadData"
+          :pagination="paginationProps"
           :scroll="{ y: 400 }"
-          :showPagination="false"
+          :loading="loading"
+          bordered>
+        </a-table>
+        <!-- <s-table
+          class="sTable"
+          ref="table"
+          size="small"
+          :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
+          :rowKey="(record) => record.id"
+          :columns="columns"
+          :data="loadData"
           bordered>
-        </s-table>
+        </s-table> -->
       </div>
       <!-- 按钮 -->
       <div class="btn-con">
         <a-button
           type="primary"
-          id="chooseProducts-submit"
+          id="chooseProducts-save"
           size="large"
           class="button-primary"
+          @click="handleSave"
           style="padding: 0 60px;">保存</a-button>
         <a-button
           id="chooseProducts-cancel"
@@ -89,9 +102,9 @@
 
 <script>
 import { STable } from '@/components'
-// import { dealerProductList } from '@/api/dealerProduct'
-// import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
-// import { dealerProductTypeList } from '@/api/dealerProductType'
+import { productBrandQuery } from '@/api/productBrand'
+import { productTypeQuery } from '@/api/productType'
+import { productList } from '@/api/product'
 export default {
   name: 'ChooseProductsModal',
   components: { STable },
@@ -100,13 +113,11 @@ export default {
       type: Boolean,
       default: false
     },
-    itemId: {
-      type: [Number, String],
-      default: ''
-    },
-    nowData: {
-      type: Object,
-      default: null
+    chooseData: {
+      type: Array,
+      default: () => {
+        return []
+      }
     }
   },
   data () {
@@ -120,23 +131,34 @@ export default {
         productTypeSn3: '' //  产品三级分类
       },
       disabled: false, //  查询、重置按钮是否可操作
+      loading: false, //  表格加载中
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
         { title: '产品编码', dataIndex: 'code', align: 'center' },
         { title: '产品名称', dataIndex: 'name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } }
       ],
       // 加载数据方法 必须为 Promise 对象
-      loadData: parameter => {
-        this.disabled = true
-        return dealerProductList(Object.assign(parameter, this.queryParam)).then(res => {
-          const data = res.data
-          const no = (data.pageNo - 1) * data.pageSize
-          for (var i = 0; i < data.list.length; i++) {
-            data.list[i].no = no + i + 1
-          }
-          this.disabled = false
-          return data
-        })
+      // loadData: parameter => {
+      //   this.disabled = true
+      //   return productList(Object.assign(parameter, this.queryParam)).then(res => {
+      //     const data = res.data
+      //     const no = (data.pageNo - 1) * data.pageSize
+      //     for (var i = 0; i < data.list.length; i++) {
+      //       data.list[i].no = no + i + 1
+      //     }
+      //     this.disabled = false
+      //     return data
+      //   })
+      // },
+      loadData: [],
+      pageNo: 1, //  分页页码
+      pageSize: 10, //  分页 每页多少条
+      paginationProps: {
+        showSizeChanger: true, //  是否可以改变 pageSize
+        total: 0, //  分页总条数
+        current: 1,
+        onShowSizeChange: (current, pageSize) => this.changePageSize(current, pageSize),
+        onChange: (current) => this.changePage(current)
       },
       productType: [],
       productBrandList: [], //  品牌下拉数据
@@ -156,10 +178,71 @@ export default {
       this.productType = []
       this.$refs.table.refresh(true)
     },
+    // 保存
+    handleSave () {
+      if (this.selectedRowKeys.length < 1) {
+        this.$message.warning('请在列表勾选后再进行操作!')
+        return
+      }
+      this.$emit('ok', this.selectedRows)
+      this.isShow = false
+    },
     onSelectChange (selectedRowKeys, selectedRows) {
+      const _this = this
       console.log('selectedRowKeys changed: ', selectedRowKeys, selectedRows)
       this.selectedRowKeys = selectedRowKeys
       this.selectedRows = selectedRows
+      // this.selectedRows = []
+      // loadData
+      // this.loadData.map(item => {
+      //   _this.selectedRowKeys.map(subItem => {
+      //     if (item.productSn == subItem) {
+      //       _this.selectedRows.push(item)
+      //       console.log(111)
+      //     }
+      //   })
+      // })
+
+      // console.log(_this.selectedRows, '+++++++++')
+    },
+    // 产品列表
+    getProductList (pageNo) {
+      this.pageNo = this.pageNo || pageNo
+      this.disabled = true
+      const params = {
+        pageNo: this.pageNo,
+        pageSize: this.pageSize
+      }
+      this.loading = true
+      productList(Object.assign(params, this.queryParam)).then(res => {
+        this.loading = false
+        if (res.status == 200) {
+          const data = res.data
+          this.paginationProps.total = Number(res.data.count) || 0
+          this.paginationProps.current = data.pageNo
+          const no = (data.pageNo - 1) * data.pageSize
+          for (var i = 0; i < data.list.length; i++) {
+            data.list[i].no = no + i + 1
+          }
+          this.loadData = data.list
+          this.disabled = false
+        } else {
+          this.paginationProps.total = 0
+          this.paginationProps.current = 1
+          this.loadData = []
+        }
+      })
+    },
+    //  已选产品 分页  一页多少条change
+    changePageSize (current, pageSize) {
+      this.pageNo = current
+      this.pageSize = pageSize
+      this.getProductList()
+    },
+    //  已选产品 分页 页码change
+    changePage (current) {
+      this.pageNo = current
+      this.getProductList()
     },
     //  产品分类  change
     changeProductType (val, opt) {
@@ -168,14 +251,13 @@ export default {
       this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
     },
     filterOption (input, option) {
-      console.log(option.componentOptions.children[0].text, 'option')
       return (
         option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
       )
     },
     //  产品品牌  列表
     getProductBrand () {
-      dealerProductBrandQuery({ 'sysFlag': '0' }).then(res => {
+      productBrandQuery({}).then(res => {
         if (res.status == 200) {
           this.productBrandList = res.data
         } else {
@@ -185,7 +267,7 @@ export default {
     },
     //  产品分类  列表
     getProductType () {
-      dealerProductTypeList({ 'sysFlag': '0' }).then(res => {
+      productTypeQuery({}).then(res => {
         if (res.status == 200) {
           this.productTypeList = res.data
         } else {
@@ -204,8 +286,18 @@ export default {
       if (!newValue) {
         this.$emit('close')
       } else {
-        this.getProductBrand()
-        this.getProductType()
+        this.selectedRows = this.chooseData
+        this.selectedRowKeys = []
+        this.chooseData.map(item => {
+          this.selectedRowKeys.push(item.goodsSn)
+        })
+        if (this.productBrandList.length == 0) {
+          this.getProductBrand()
+        }
+        if (this.productTypeList.length == 0) {
+          this.getProductType()
+        }
+        this.getProductList(1)
       }
     }
   }

+ 81 - 63
src/views/promotionRulesManagement/promotionRules/chooseTypeModal.vue

@@ -9,14 +9,18 @@
     @cancle="isShow=false"
     width="50%">
     <div class="chooseType-con">
+      <div>
+        <a-checkbox :checked="checkAll" @change="onCheckAllChange">全选</a-checkbox>
+      </div>
+      <a-divider />
       <a-tree
+        style="height: 400px;overflow-y: scroll;"
         checkable
         @check="onCheck"
-        @expand="onExpand"
-        :expandedKeys="expandedKeys"
-        :autoExpandParent="autoExpandParent"
+        :checkStrictly="true"
         v-model="checkedKeys"
-        :treeData="treeData"
+        :treeData="productTypeList"
+        :replaceFields="replaceFields"
       />
       <!-- 按钮 -->
       <div class="btn-con">
@@ -25,6 +29,7 @@
           id="chooseType-submit"
           size="large"
           class="button-primary"
+          @click="handleSave"
           style="padding: 0 60px;">保存</a-button>
         <a-button
           id="chooseType-cancel"
@@ -38,6 +43,7 @@
 </template>
 
 <script>
+import { productTypeQuery } from '@/api/productType'
 export default {
   name: 'ChooseTypeModal',
   props: {
@@ -45,77 +51,79 @@ export default {
       type: Boolean,
       default: false
     },
-    itemId: {
-      type: [Number, String],
-      default: ''
-    },
-    nowData: {
-      type: Object,
-      default: null
+    chooseData: {
+      type: Array,
+      default: () => {
+        return []
+      }
     }
   },
   data () {
     return {
       isShow: this.openModal, //  是否打开弹框
-      expandedKeys: ['0-0-0', '0-0-1'],
-      autoExpandParent: true,
-      checkedKeys: ['0-0-0'],
-      selectedKeys: [],
-      treeData: [
-        {
-          title: '0-0',
-          key: '0-0',
-          children: [
-            {
-              title: '0-0-0',
-              key: '0-0-0',
-              children: [
-                { title: '0-0-0-0', key: '0-0-0-0' },
-                { title: '0-0-0-1', key: '0-0-0-1' },
-                { title: '0-0-0-2', key: '0-0-0-2' }
-              ]
-            },
-            {
-              title: '0-0-1',
-              key: '0-0-1',
-              children: [
-                { title: '0-0-1-0', key: '0-0-1-0' },
-                { title: '0-0-1-1', key: '0-0-1-1' },
-                { title: '0-0-1-2', key: '0-0-1-2' }
-              ]
-            },
-            {
-              title: '0-0-2',
-              key: '0-0-2'
-            }
-          ]
-        },
-        {
-          title: '0-1',
-          key: '0-1',
-          children: [
-            { title: '0-1-0-0', key: '0-1-0-0' },
-            { title: '0-1-0-1', key: '0-1-0-1' },
-            { title: '0-1-0-2', key: '0-1-0-2' }
-          ]
-        },
-        {
-          title: '0-2',
-          key: '0-2'
-        }
-      ]
+      checkedKeys: [], //  选中项
+      checkedRows: [], //  选中项  整条数据
+      checkAll: false, //  全选
+      replaceFields: {
+        children: 'children',
+        title: 'productTypeName',
+        key: 'productTypeSn'
+      },
+      productTypeList: []
     }
   },
   methods: {
-    onExpand (expandedKeys) {
-      console.log('onExpand', expandedKeys)
-      this.expandedKeys = expandedKeys
-      this.autoExpandParent = false
+    //  产品分类  列表
+    getProductType () {
+      productTypeQuery({}).then(res => {
+        if (res.status == 200) {
+          this.productTypeList = res.data
+        } else {
+          this.productTypeList = []
+        }
+      })
+    },
+    // 保存
+    handleSave () {
+      if (this.checkedKeys.length < 1) {
+        this.$message.warning('请在列表勾选后再进行操作!')
+        return
+      }
+      this.$emit('ok', this.checkedRows)
+      this.isShow = false
+    },
+    // 全选
+    onCheckAllChange (e) {
+      this.checkAll = e.target.checked
+      if (e.target.checked) {
+        this.checkedKeys = []
+        this.checkedRows = []
+        this.recursionFun(this.productTypeList)
+      } else {
+        this.checkedKeys = []
+        this.checkedRows = []
+      }
+    },
+    //  递归函数
+    recursionFun (data) {
+      if (data) {
+        data.map((item, index) => {
+          this.checkedKeys.push(item.productTypeSn)
+          this.checkedRows.push(item)
+          if (item.children && item.children.length > 0) {
+            this.recursionFun(item.children)
+          }
+        })
+      }
     },
     onCheck (checkedKeys, info) {
-      console.log('onCheck', checkedKeys, info)
+      // console.log('onCheck', checkedKeys, info)
       // this.checkedData = [...checkedKeys, ...info.halfCheckedKeys]
       this.checkedKeys = checkedKeys
+      this.checkedRows = []
+      info.checkedNodes.map((item, index) => {
+        this.checkedRows.push(item.data.props)
+      })
     }
   },
   watch: {
@@ -127,6 +135,16 @@ export default {
     isShow (newValue, oldValue) {
       if (!newValue) {
         this.$emit('close')
+      } else {
+        const _this = this
+        this.checkedRows = this.chooseData
+        this.checkedKeys = []
+        this.chooseData.map(item => {
+          _this.checkedKeys.push(item.goodsSn)
+        })
+        if (this.productTypeList.length == 0) {
+          this.getProductType()
+        }
       }
     }
   }

+ 4 - 4
src/views/promotionRulesManagement/promotionRules/edit.vue

@@ -231,16 +231,16 @@
           style="padding: 0 60px;">保存</a-button>
       </div>
     </a-affix>
-    <!-- 选择正价产品 -->
-    <choosePosPriceProductsModal :openModal="openModal" @close="openModal=false" />
+    <!-- 选择产品 -->
+    <choosePriceProductsModal :openModal="openModal" @close="openModal=false" />
   </div>
 </template>
 
 <script>
 import moment from 'moment'
-import ChoosePosPriceProductsModal from './choosePosPriceProductsModal.vue'
+import ChoosePriceProductsModal from './choosePriceProductsModal.vue'
 export default {
-  components: { ChoosePosPriceProductsModal },
+  components: { ChoosePriceProductsModal },
   data () {
     return {
       formItemLayout: {

+ 156 - 130
src/views/promotionRulesManagement/promotionRules/editRuleModal.vue

@@ -22,126 +22,139 @@
           id="promotionRules-rule-promoRuleType"
           v-model="form.promoRuleType"
           allowClear
+          @change="changeType"
           placeholder="请选择促销类型"
         ></v-select>
       </a-form-model-item>
       <!-- 买产品送产品 -->
       <div v-if="form.promoRuleType == 'BUY_PROD_GIVE_PROD'">
-        <a-form-model-item label="促销设置" prop="buyerLimitEnable">
+        <a-form-model-item label="促销设置" required>
           购买满
-          <a-input-number
-            id="promotionRules-rule-outQty"
-            v-model="form.orderGoodsQty"
-            :precision="0"
-            :min="1"
-            :max="999999"
-            placeholder="请输入数量"
-            style="width: 30%;" />
+          <a-form-model-item prop="orderGoodsQty" :label-col="{span: 0}" style="display: inline-block;">
+            <a-input-number
+              id="promotionRules-rule-orderGoodsQty"
+              v-model="form.orderGoodsQty"
+              :precision="0"
+              :min="1"
+              :max="999999"
+              placeholder="请输入"
+              style="width: 100%;" />
+          </a-form-model-item>
           正价产品,送
-          <a-input-number
-            id="promotionRules-rule-outQty"
-            v-model="form.promoQty"
-            :precision="0"
-            :min="1"
-            :max="999999"
-            placeholder="请输入数量"
-            style="width: 30%;" />
+          <a-form-model-item prop="promoQty" :label-col="{span: 0}" style="display: inline-block;">
+            <a-input-number
+              id="promotionRules-rule-promoQty"
+              v-model="form.promoQty"
+              :precision="0"
+              :min="1"
+              :max="999999"
+              placeholder="请输入"
+              style="width: 100%;" />
+          </a-form-model-item>
           促销品
         </a-form-model-item>
         <a-form-model-item label="正价产品" prop="normalGoodsList">
-          <a-button id="promotionRules-rule-choose" type="primary" class="button-success" @click="openCustomerModal=true">选择</a-button>
-          <span style="font-weight: bold;margin-left: 30px;">当前已选:{{ chooseCust.length }}个</span>
+          <a-button id="promotionRules-rule-normalGoodsList" type="primary" class="button-success" @click="chooseProduct('normal')">选择</a-button>
+          <span style="font-weight: bold;margin-left: 30px;">当前已选:{{ normalGoodsList.length }}个</span>
         </a-form-model-item>
         <a-form-model-item label="促销品" prop="promoGoodsList">
-          <a-button id="promotionRules-rule-choose" type="primary" class="button-success" @click="openCustomerModal=true">选择</a-button>
-          <span style="font-weight: bold;margin-left: 30px;">当前已选:{{ chooseCust.length }}个</span>
+          <a-button id="promotionRules-rule-promoGoodsList" type="primary" class="button-success" @click="chooseProduct('promo')">选择</a-button>
+          <span style="font-weight: bold;margin-left: 30px;">当前已选:{{ promoGoodsList.length }}个</span>
         </a-form-model-item>
       </div>
       <!-- 买产品送采购额 -->
       <div v-if="form.promoRuleType == 'BUY_PROD_GIVE_MONEY'">
-        <a-form-model-item label="促销设置" prop="buyerLimitEnable">
+        <a-form-model-item label="促销设置" prop="orderRuleType">
           <a-radio-group v-model="form.orderRuleType" @change="radioChange">
             <a-radio value="prod_qty" style="margin-bottom: 10px;">
               购买满
-              <a-input-number
-                id="promotionRules-rule-orderGoodsQty"
-                v-model="form.orderGoodsQty"
-                :precision="0"
-                :min="1"
-                :max="999999"
-                placeholder="请输入数量"
-                style="width: 30%;" />
+              <a-form-model-item prop="orderAmount" :label-col="{span: 0}" style="display: inline-block;">
+                <a-input-number
+                  id="promotionRules-rule-orderAmount"
+                  v-model="form.orderAmount"
+                  :precision="2"
+                  :min="0.1"
+                  :max="999999"
+                  placeholder="请输入"
+                  style="width: 100%;" />
+              </a-form-model-item>
               元正价产品,送
-              <a-input-number
-                id="promotionRules-rule-promoAmount"
-                v-model="form.promoAmount"
-                :precision="2"
-                :min="1"
-                :max="999999"
-                placeholder="请输入金额"
-                style="width: 30%;" />
+              <a-form-model-item prop="promoAmount" :label-col="{span: 0}" style="display: inline-block;">
+                <a-input-number
+                  id="promotionRules-rule-promoAmount"
+                  v-model="form.promoAmount"
+                  :precision="2"
+                  :min="0.1"
+                  :max="999999"
+                  placeholder="请输入"
+                  style="width: 100%;" />
+              </a-form-model-item>
               元采购额可用于购买促销品
             </a-radio>
             <a-radio value="order_amount">
               购买满
-              <a-input-number
-                id="promotionRules-rule-orderGoodsQty"
-                v-model="form.orderGoodsQty"
-                :precision="0"
-                :min="1"
-                :max="999999"
-                placeholder="请输入数量"
-                style="width: 30%;" />
+              <a-form-model-item prop="orderAmount" :label-col="{span: 0}" style="display: inline-block;">
+                <a-input-number
+                  id="promotionRules-rule-orderAmount"
+                  v-model="form.orderAmount"
+                  :precision="2"
+                  :min="0.1"
+                  :max="999999"
+                  placeholder="请输入"
+                  style="width: 100%;" />
+              </a-form-model-item>
               元正价产品可以返正价产品采购额的
-              <a-input-number
-                id="promotionRules-rule-promoAmountPer"
-                v-model="form.promoAmountPer"
-                :precision="0"
-                :min="1"
-                :max="999999"
-                placeholder="请输入数量"
-                style="width: 30%;" />
+              <a-form-model-item prop="promoAmountPer" :label-col="{span: 0}" style="display: inline-block;">
+                <a-input-number
+                  id="promotionRules-rule-promoAmountPer"
+                  v-model="form.promoAmountPer"
+                  :precision="2"
+                  :min="0.1"
+                  :max="100"
+                  placeholder="请输入"
+                  style="width: 100%;" />
+              </a-form-model-item>
               %用于购买促销品
             </a-radio>
           </a-radio-group>
         </a-form-model-item>
-        <a-form-model-item label="正价产品" prop="buyerLimitEnable">
-          <a-button id="promotionRules-rule-choose" type="primary" class="button-success" @click="openCustomerModal=true">选择</a-button>
-          <span style="font-weight: bold;margin-left: 30px;">当前已选:{{ chooseCust.length }}个</span>
+        <a-form-model-item label="正价产品" prop="normalGoodsList">
+          <a-button id="promotionRules-rule-normalGoodsList" type="primary" class="button-success" @click="chooseProduct('normal')">选择</a-button>
+          <span style="font-weight: bold;margin-left: 30px;">当前已选:{{ normalGoodsList.length }}个</span>
         </a-form-model-item>
-        <a-form-model-item label="促销品" prop="buyerLimitEnable">
-          <a-button id="promotionRules-rule-choose" type="primary" class="button-success" @click="openCustomerModal=true">选择</a-button>
-          <span style="font-weight: bold;margin-left: 30px;">当前已选:{{ chooseCust.length }}个</span>
+        <a-form-model-item label="促销品" prop="promoGoodsList">
+          <a-button id="promotionRules-rule-promoGoodsList" type="primary" class="button-success" @click="chooseProduct('promo')">选择</a-button>
+          <span style="font-weight: bold;margin-left: 30px;">当前已选:{{ promoGoodsList.length }}个</span>
         </a-form-model-item>
       </div>
       <!-- 特价产品销售 -->
       <div v-if="form.promoRuleType == 'PROMO_PROD'">
         <a-form-model-item label="特价产品" prop="promoGoodsList">
-          <a-button id="promotionRules-rule-choose" type="primary" class="button-success" @click="openCustomerModal=true">选择</a-button>
-          <span style="font-weight: bold;margin-left: 30px;">当前已选:{{ chooseCust.length }}个</span>
+          <a-button id="promotionRules-rule-promoGoodsList" type="primary" class="button-success" @click="chooseProduct('promo')">选择</a-button>
+          <span style="font-weight: bold;margin-left: 30px;">当前已选:{{ promoGoodsList.length }}个</span>
         </a-form-model-item>
       </div>
       <!-- 加价换购 -->
       <div v-if="form.promoRuleType == 'ADD_PRICE_PURCH'">
-        <a-form-model-item label="加价规则" prop="buyerLimitEnable">
+        <a-form-model-item label="加价规则" prop="orderGoodsQty">
           购买满
           <a-input-number
-            id="promotionRules-rule-outQty"
-            v-model="form.outQty"
+            id="promotionRules-rule-orderGoodsQty"
+            v-model="form.orderGoodsQty"
             :precision="0"
             :min="1"
             :max="999999"
-            placeholder="请输入数量"
+            placeholder="请输入"
             style="width: 30%;" />
-          个正价产品  可以以换购价购买任意1个换购产品
+          个正价产品可以以换购价购买任意1个换购产品
         </a-form-model-item>
-        <a-form-model-item label="正价产品" prop="buyerLimitEnable">
-          <a-button id="promotionRules-rule-choose" type="primary" class="button-success" @click="openCustomerModal=true">选择</a-button>
-          <span style="font-weight: bold;margin-left: 30px;">当前已选:{{ chooseCust.length }}个</span>
+        <a-form-model-item label="正价产品" prop="normalGoodsList">
+          <a-button id="promotionRules-rule-normalGoodsList" type="primary" class="button-success" @click="chooseProduct('normal')">选择</a-button>
+          <span style="font-weight: bold;margin-left: 30px;">当前已选:{{ normalGoodsList.length }}个</span>
         </a-form-model-item>
-        <a-form-model-item label="换购产品" prop="buyerLimitEnable">
-          <a-button id="promotionRules-rule-choose" type="primary" class="button-success" @click="openCustomerModal=true">选择</a-button>
-          <span style="font-weight: bold;margin-left: 30px;">当前已选:{{ chooseCust.length }}个</span>
+        <a-form-model-item label="换购产品" prop="promoGoodsList">
+          <a-button id="promotionRules-rule-promoGoodsList" type="primary" class="button-success" @click="chooseProduct('promo')">选择</a-button>
+          <span style="font-weight: bold;margin-left: 30px;">当前已选:{{ promoGoodsList.length }}个</span>
         </a-form-model-item>
       </div>
     </a-form-model>
@@ -149,19 +162,24 @@
       <a-button type="primary" id="promotionRules-rule-modal-save" @click="handleSave">保存</a-button>
       <a-button id="promotionRules-rule-modal-back" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
     </div>
-    <!-- 选择参与客户 -->
-    <choose-customer-modal :openModal="openCustomerModal" :chooseCust="chooseCust" @close="openCustomerModal=false" @ok="handleOk" />
+    <!-- 选择产品 -->
+    <choose-price-products-modal
+      :openModal="openPriceProductsModal"
+      :nowData="nowData"
+      :ruleType="form.promoRuleType"
+      :goodsType="nowChooseGoodsType"
+      @ok="handleOk"
+      @close="closePriceProducts" />
   </a-modal>
 </template>
 
 <script>
-import moment from 'moment'
 import { VSelect } from '@/components'
-import chooseCustomerModal from './chooseCustomerModal'
-import { promoActiveSave } from '@/api/promoActive'
+import ChoosePriceProductsModal from './choosePriceProductsModal.vue'
+import { promoRuleSave } from '@/api/promoRule'
 export default {
   name: 'StoreTransferOutBasicInfoModal',
-  components: { VSelect, chooseCustomerModal },
+  components: { VSelect, ChoosePriceProductsModal },
   props: {
     openModal: {
       //  弹框显示状态
@@ -173,34 +191,36 @@ export default {
     return {
       isShow: this.openModal, //  是否打开弹框
       formItemLayout: {
-        labelCol: { span: 4 },
-        wrapperCol: { span: 16 }
+        labelCol: { span: 3 },
+        wrapperCol: { span: 21 }
       },
       form: {
-        promoRuleType: undefined
+        promoRuleType: undefined, //  促销类型
+        orderGoodsQty: '', //  正价品数量
+        promoQty: '', //  促销品数量
+        orderRuleType: undefined, //  促销设置(买产品送采购额(定额)、买产品送采购额(定比例))
+        orderAmount: '', //  正价品金额
+        promoAmount: '', // 采购额
+        promoAmountPer: '', // 百分比
+        normalGoodsList: '', //  已选正价品
+        promoGoodsList: '' //  已选促销品
       },
       rules: {
-        name: [{ required: true, message: '请输入活动名称', trigger: 'blur' }],
-        activeDateEnable: [{ required: true, message: '请选择是否限制活动时间', trigger: 'change' }],
-        activeDate: [{ required: true, message: '请选择限制的活动时间', trigger: 'change' }],
-        buyerLimitEnable: [{ required: true, message: '请选择是否限制参与客户', trigger: 'change' }],
-        buyerSns: [{ required: true, message: '请选择参与客户', trigger: 'blur' }],
-        activeAmountEnable: [{ required: true, message: '请选择是否限制活动经费', trigger: 'change' }],
-        activeAmount: [{ required: true, message: '请输入活动经费上限', trigger: 'blur' }],
-        orderAmountEnable: [{ required: true, message: '请选择是否限制起订金额', trigger: 'change' }],
-        orderAmount: [{ required: true, message: '请输入订单起订金额', trigger: 'blur' }]
+        promoRuleType: [{ required: true, message: '请选择促销类型', trigger: 'change' }],
+        orderGoodsQty: [{ required: true, message: '请输入正价品数量', trigger: 'blur' }],
+        promoQty: [{ required: true, message: '请输入促销品数量', trigger: 'blur' }],
+        orderRuleType: [{ required: true, message: '请选择促销方式', trigger: 'change' }],
+        orderAmount: [{ required: true, message: '请输入正价品金额', trigger: 'blur' }],
+        promoAmount: [{ required: true, message: '请输入采购额', trigger: 'blur' }],
+        promoAmountPer: [{ required: true, message: '请输入百分比', trigger: 'blur' }],
+        normalGoodsList: [{ required: true, message: '请选择正价品', trigger: 'change' }],
+        promoGoodsList: [{ required: true, message: '请选择促销品', trigger: 'change' }]
       },
-      dateFormat: 'YYYY-MM-DD',
-      rangeList: [ //  是否限制
-        { name: '不限', val: 0 },
-        { name: '限制', val: 1 }
-      ],
-      rangeCList: [ //  是否全部
-        { name: '全部客户', val: 0 },
-        { name: '部分客户', val: 1 }
-      ],
-      openCustomerModal: false,
-      chooseCust: [] //  当前已选客户
+      openPriceProductsModal: false,
+      normalGoodsList: [], //  当前已选正价产品
+      promoGoodsList: [], //  当前已选促销品
+      nowChooseGoodsType: '', //  当前选择产品的类型(正价产品/促销品)
+      nowData: [] //  选择产品
     }
   },
   computed: {
@@ -222,23 +242,20 @@ export default {
     //  保存
     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))
-          if (form.activeDate && form.activeDate.length > 0) {
-            form.activeDateStart = moment(form.activeDate[0]).format(this.dateFormat)
-            form.activeDateEnd = moment(form.activeDate[1]).format(this.dateFormat)
-          } else {
-            form.activeDateStart = undefined
-            form.activeDateEnd = undefined
-          }
-          delete form.activeDate
-          promoActiveSave(form).then(res => {
+          form.normalGoodsList = this.normalGoodsList
+          form.promoGoodsList = this.promoGoodsList
+          promoRuleSave(form).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
               setTimeout(() => {
+                _this.$emit('ok')
                 _this.isShow = false
-                _this.$emit('ok', res.data)
               }, 1000)
             }
           })
@@ -249,30 +266,36 @@ export default {
       })
     },
     handleOk (obj) {
-      this.chooseCust = obj
-      this.form.buyerSns = this.chooseCust.join(',')
+      console.log('已选产品-----', obj)
+      if (this.nowChooseGoodsType == 'normal') { // 正价品
+        this.normalGoodsList = obj
+      } else if (this.nowChooseGoodsType == 'promo') { // 促销品
+        this.promoGoodsList = obj
+      }
     },
-    // select   change
-    handleChange (val) {
-      // 数据更改为不限时需重置之前所选数据
-      if (val == 'activeDateEnable' && this.form.activeDateEnable == 0) { //  活动时间
-        this.form.activeDate = []
-        this.form.activeDateStart = ''
-        this.form.activeDateEnd = ''
-      } else if (val == 'buyerLimitEnable' && this.form.buyerLimitEnable == 0) { //  参与客户
-        this.chooseCust = []
-      } else if (val == 'activeAmountEnable' && this.form.activeAmountEnable == 0) { //  活动经费
-        this.form.activeAmount = ''
-      } else if (val == 'orderAmountEnable' && this.form.orderAmountEnable == 0) { //  起订金额
-        this.form.orderAmount = ''
+    // 选择产品
+    chooseProduct (type) {
+      this.nowChooseGoodsType = type
+      if (type == 'normal') { // 正价品
+        this.nowData = this.normalGoodsList || []
+      } else if (type == 'promo') { // 促销品
+        this.nowData = this.promoGoodsList || []
       }
+      this.openPriceProductsModal = true
+    },
+    // 关闭选择产品弹框
+    closePriceProducts () {
+      this.openPriceProductsModal = false
     },
     radioChange (val) {
 
     },
-    // 不可选日期
-    disabledDate (date, dateStrings) {
-      return date && date.valueOf('day') < moment().subtract(1, 'day') // 今天以后,包含今天
+    //  促销类型  change
+    changeType (val) {
+      this.$refs.ruleForm.resetFields()
+      this.normalGoodsList = []
+      this.promoGoodsList = []
+      this.form.promoRuleType = val
     }
   },
   watch: {
@@ -300,5 +323,8 @@ export default {
 		text-align: center;
 		margin: 35px 0 10px;
 	}
+  .ant-radio + span{
+    line-height: 40px;
+  }
 }
 </style>

+ 0 - 1
src/views/promotionRulesManagement/promotionRules/rule.vue

@@ -91,7 +91,6 @@ export default {
     },
     handleOk (data) {
       this.$refs.table.refresh(true)
-      // this.$router.push({ path: `/promotionRulesManagement/promotionRules/add/${data.id}/${data.storeCallOutSn}` })
     },
     //  详情
     handleDetail (row) {