浏览代码

对接智能补货

chenrui 3 年之前
父节点
当前提交
f3f31e0afc

+ 68 - 0
src/api/predict.js

@@ -20,6 +20,7 @@ export const predictRangeList = (params) => {
 export const predictTrendList = (params) => {
   return axios({
     url: '/predict/stockPredict/queryTrendList',
+    params: params,
     method: 'get'
   })
 }
@@ -31,3 +32,70 @@ export const predictSave = (params) => {
     method: 'post'
   })
 }
+//  智能补货  删除
+export const predictDel = (params) => {
+  const url = `/predict/stockPredict/delete/${params.sn}`
+  return axios({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
+//  智能补货  详情
+export const predictDetail = (params) => {
+  const url = `/predict/stockPredict/queryBySn/${params.sn}`
+  return axios({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
+//  智能补货  产品范围 保存
+export const predictRangeSave = (params) => {
+  return axios({
+    url: '/predict/stockPredict/saveBatchRange',
+    data: params,
+    method: 'post'
+  })
+}
+//  智能补货  产品范围 删除
+export const predictRangeDel = (params) => {
+  return axios({
+    url: '/predict/stockPredict/deleteRange',
+    data: params,
+    method: 'post'
+  })
+}
+//  智能补货  计算
+export const predictRun = (params) => {
+  return axios({
+    url: '/predict/stockPredict/run',
+    data: params,
+    method: 'post'
+  })
+}
+//  智能补货  基础信息设置  批量插入
+export const predictProductInfoInsert = (params) => {
+  return axios({
+    url: '/predictProductInfo/batchInsert',
+    data: params,
+    method: 'post'
+  })
+}
+//  智能补货  基础信息设置  下载
+export const predictProductInfoExport = (params) => {
+  return axios({
+    url: '/predictProductInfo/exportExcel',
+    data: params,
+    method: 'post',
+    responseType: 'blob'
+  })
+}
+//  智能补货  基础信息设置  解析
+export const predictProductInfoGoods = (params) => {
+  return axios({
+    url: '/predictProductInfo/parseGoods',
+    data: params,
+    method: 'post'
+  })
+}

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

@@ -1057,7 +1057,7 @@ export const asyncRouterMap = [
                 }
               },
               {
-                path: 'set/:sn',
+                path: 'set',
                 name: 'intelligentReplenishmentSet',
                 component: () => import(/* webpackChunkName: "shop" */ '@/views/inventoryManagement/intelligentReplenishment/set.vue'),
                 meta: {
@@ -1067,7 +1067,7 @@ export const asyncRouterMap = [
                 }
               },
               {
-                path: 'import/:sn',
+                path: 'import',
                 name: 'intelligentReplenishmentImport',
                 component: () => import(/* webpackChunkName: "shop" */ '@/views/inventoryManagement/intelligentReplenishment/import.vue'),
                 meta: {

+ 280 - 0
src/views/common/chooseSupplierModal.vue

@@ -0,0 +1,280 @@
+<template>
+  <a-modal
+    centered
+    class="chooseSupplier-modal"
+    :footer="null"
+    :maskClosable="false"
+    title="选择供应商"
+    v-model="isShow"
+    @cancle="isShow=false"
+    :width="900">
+    <div class="products-con">
+      <div>
+        <!-- 搜索条件 -->
+        <div class="table-page-search-wrapper">
+          <a-form-model
+            layout="inline"
+            ref="ruleForm"
+            :model="queryParam"
+            :rules="rules"
+            @keyup.enter.native="getSupplierList(1)"
+            :label-col="formItemLayout.labelCol"
+            :wrapper-col="formItemLayout.wrapperCol">
+            <a-row :gutter="15">
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="供应商名称">
+                  <a-input id="chooseSupplier-supplierName" v-model.trim="queryParam.supplierName" allowClear placeholder="请输入供应商名称"/>
+                </a-form-model-item>
+              </a-col>
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="状态">
+                  <v-select code="ENABLE_FLAG" id="chooseSupplier-enabledFlag" v-model="queryParam.enabledFlag" allowClear placeholder="请选择状态"></v-select>
+                </a-form-model-item>
+              </a-col>
+              <a-col :md="6" :sm="24">
+                <a-button style="margin-bottom: 18px;" type="primary" @click="handleSearch" :disabled="disabled" id="chooseSupplier-refresh">查询</a-button>
+                <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="chooseSupplier-reset">重置</a-button>
+              </a-col>
+            </a-row>
+          </a-form-model></a-form>
+        </div>
+        <p style="font-weight: bold;">当前已选:{{ selectedRowKeys.length }}个</p>
+        <!-- 列表 -->
+        <a-table
+          class="sTable"
+          ref="table"
+          size="small"
+          :rowKey="(record) => record.supplierSn"
+          :row-selection="{
+            selectedRowKeys: selectedRowKeys,
+            onChange: onChange,
+            onSelect: onSelectChange,
+            onSelectAll: onSelectAllChange
+          }"
+          :data-source="loadData"
+          :columns="columns"
+          :pagination="paginationProps"
+          :loading="loading"
+          :scroll="{ y: 450 }"
+          bordered>
+        </a-table>
+      </div>
+      <!-- 按钮 -->
+      <div class="btn-con">
+        <a-button
+          type="primary"
+          id="chooseSupplier-save"
+          size="large"
+          class="button-primary"
+          @click="handleSave"
+          style="padding: 0 60px;">保存</a-button>
+        <a-button
+          id="chooseSupplier-cancel"
+          size="large"
+          class="button-cancel"
+          @click="isShow=false"
+          style="padding: 0 60px;margin-left: 15px;">取消</a-button>
+      </div>
+    </div>
+  </a-modal>
+</template>
+
+<script>
+import { STable, VSelect } from '@/components'
+import { supplierList } from '@/api/supplier'
+export default {
+  name: 'ChooseSupplierModal',
+  components: { STable, VSelect },
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    chooseData: {
+      type: Array,
+      default: () => {
+        return []
+      }
+    },
+    dealerSn: {
+      type: String || Number,
+      default: ''
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      formItemLayout: {
+        labelCol: { span: 4 },
+        wrapperCol: { span: 20 }
+      },
+      queryParam: { //  查询条件
+        supplierName: '',
+        enabledFlag: undefined
+      },
+      rules: {},
+      disabled: false, //  查询、重置按钮是否可操作
+      loading: false, //  表格加载中
+      columns: [
+        { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
+        { title: '供应商名称', dataIndex: 'supplierName', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
+        { title: '状态', dataIndex: 'enableFlagDictValue', align: 'center', customRender: function (text) { return text || '--' } }
+      ],
+      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)
+      },
+      selectedRowKeys: [],
+      selectedRows: []
+    }
+  },
+  methods: {
+    // 查询
+    handleSearch () {
+      const _this = this
+      _this.$refs.ruleForm.validate(valid => {
+        if (valid) {
+          _this.getSupplierList(1)
+        } else {
+          return false
+        }
+      })
+    },
+    // 重置数据
+    resetData () {
+      this.queryParam.supplierName = ''
+      this.queryParam.enabledFlag = undefined
+      this.pageNo = 1
+      this.pageSize = 10
+      this.paginationProps.total = 0
+      this.paginationProps.current = 1
+    },
+    //  重置
+    resetSearchForm () {
+      this.resetData()
+      this.loadData = []
+      this.disabled = false
+    },
+    // 保存
+    handleSave () {
+      if (this.selectedRowKeys.length < 1) {
+        this.$message.warning('请在列表勾选后再进行操作!')
+        return
+      }
+      this.$emit('ok', this.selectedRows)
+      this.isShow = false
+    },
+    onChange (selectedRowKeys, selectedRows) {
+      this.selectedRowKeys = selectedRowKeys
+    },
+    onSelectChange (record, selected, selectedRows, nativeEvent) {
+      const _this = this
+      if (selected) { //  选择
+        this.selectedRows.push(record)
+      } else { //  取消
+        this.selectedRows.map((item, index) => {
+          if (item.supplierSn == record.supplierSn) {
+            _this.selectedRows.splice(index, 1)
+          }
+        })
+      }
+    },
+    // 本页全选/取消全选
+    onSelectAllChange (selected, selectedRows, changeRows) {
+      const _this = this
+      if (selected) { //  选择
+        this.selectedRows = [...this.selectedRows, ...changeRows]
+      } else { //  取消
+        this.selectedRows.map((item, index) => {
+          this.selectedRows.map((subItem, ind) => {
+            if (item.supplierSn == subItem.supplierSn) {
+              _this.selectedRows.splice(index, 1)
+            }
+          })
+        })
+      }
+    },
+    // 供应商列表
+    getSupplierList (pageNo) {
+      this.pageNo = pageNo || this.pageNo
+      this.disabled = true
+      const params = {
+        pageNo: this.pageNo,
+        pageSize: this.pageSize
+      }
+      this.loading = true
+      supplierList(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.getSupplierList()
+    },
+    //  已选产品 分页 页码change
+    changePage (current) {
+      this.pageNo = current
+      this.getSupplierList()
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+        this.loadData = []
+        this.disabled = false
+        this.resetData()
+      } else {
+        this.getSupplierList(1)
+        this.selectedRows = this.chooseData
+        this.selectedRowKeys = []
+        this.chooseData.map(item => {
+          this.selectedRowKeys.push(item.rangeDataSn)
+        })
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less" scoped>
+  .chooseSupplier-modal{
+    .products-con{
+      .btn-con{
+        text-align: center;
+        margin: 30px 0 20px;
+        .button-cancel{
+          font-size: 12px;
+        }
+      }
+    }
+  }
+</style>

+ 44 - 41
src/views/inventoryManagement/intelligentReplenishment/detailModal.vue

@@ -12,34 +12,35 @@
       <a-alert type="info" showIcon style="margin-bottom:15px">
         <div slot="message">此预测单的各项参数信息如下</div>
       </a-alert>
-      <div class="module-cont">
+      <div class="module-cont" v-if="detailData">
         <p class="title">产品范围</p>
-        <a-tag color="blue" style="margin-bottom: 10px;">自选产品</a-tag>
-        <s-table
+        <a-tag color="blue" style="margin-bottom: 10px;">{{ detailData.stockPredictRange==0?'自选产品':'全部产品' }}</a-tag>
+        <a-table
           class="sTable"
           ref="table"
           size="small"
           :rowKey="(record) => record.id"
           :columns="columns"
-          :data="loadData"
+          :data-source="loadData"
           :scroll="{ y: 400 }"
+          :pagination="false"
           bordered>
-        </s-table>
+        </a-table>
       </div>
       <div class="module-cont">
         <p class="title">销售保障法</p>
-        <p class="explain">保障倍数:<span>1.5</span></p>
+        <p class="explain">保障倍数:<span>{{ (detailData&&detailData.saleEnsureNum) || '--' }}</span></p>
       </div>
       <div class="module-cont">
         <p class="title">趋势平均法</p>
-        <p class="explain">服务水平:<span>90%(对应的安全系数为1.28)</span></p>
+        <p class="explain">服务水平:<span>{{ (detailData&&detailData.trendServiceLevel) || '--' }}%(对应的安全系数为{{ (detailData&&detailData.trendSafetyFactor) || '--' }})</span></p>
       </div>
-      <div class="spin-cont">
+      <div class="spin-cont" v-if="detailData&&detailData.state=='RUN'">
         按照以上参数设置,系统正在计算中,请耐心等待...
         <a-spin style="margin-left: 15px;" />
       </div>
       <div class="btn-cont">
-        <a-button type="primary" id="intelligentReplenishmentDetail-save" @click="handleDownload">结果下载</a-button>
+        <!-- <a-button type="primary" id="intelligentReplenishmentDetail-save" @click="handleDownload">结果下载</a-button> -->
         <a-button id="intelligentReplenishmentDetail-back" @click="isShow = false">关闭</a-button>
       </div>
     </div>
@@ -48,7 +49,7 @@
 
 <script>
 import { STable } from '@/components'
-// import { custTypeSave } from '@/api/custType'
+import { predictDetail, predictRangeList } from '@/api/predict'
 export default {
   name: 'IntelligentReplenishmentDetailModal',
   components: { STable },
@@ -57,7 +58,7 @@ export default {
       type: Boolean,
       default: false
     },
-    itemId: {
+    itemSn: {
       type: [Number, String],
       default: ''
     }
@@ -68,38 +69,40 @@ export default {
       detailsData: null, //  详情数据
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
-        { title: '类型', dataIndex: 'createDate', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '类型名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' } }
+        { title: '类型', dataIndex: 'rangeTypeName', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '类型名称', dataIndex: 'rangeDataName', align: 'center', customRender: function (text) { return text || '--' } }
       ],
-      // 加载数据方法 必须为 Promise 对象
-      loadData: parameter => {
-        // return custTypeList(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
-        //   }
-        //   return data
-        // })
-        return new Promise(function (resolve, reject) {
-          const data = {
-            pageNo: 1,
-            pageSize: 10,
-            list: [
-              { id: '1', state: 1, purchaseNo: 'jgqp11111111111', creatDate: '产品1', custName: 'jgqp111123545', totalP: '箭冠品牌', totalNums: '产品分类1', totalPrice: '5', payType: '122' },
-              { id: '2', state: 2, purchaseNo: 'jgqp11111111111', creatDate: '产品1', custName: 'jgqp111123545', totalP: '箭冠品牌', totalNums: '产品分类1', totalPrice: '5', payType: '122' },
-              { id: '3', state: 3, purchaseNo: 'jgqp11111111111', creatDate: '产品1', custName: 'jgqp111123545', totalP: '箭冠品牌', totalNums: '产品分类1', totalPrice: '5', payType: '122' },
-              { id: '4', state: 4, purchaseNo: 'jgqp11111111111', creatDate: '产品1', custName: 'jgqp111123545', totalP: '箭冠品牌', totalNums: '产品分类1', totalPrice: '5', payType: '122' },
-              { id: '5', state: 5, purchaseNo: 'jgqp11111111111', creatDate: '产品1', custName: 'jgqp111123545', totalP: '箭冠品牌', totalNums: '产品分类1', totalPrice: '5', payType: '122' }
-            ],
-            count: 10
-          }
-          resolve(data)
-        })
-      }
+      loadData: [],
+      detailData: null
     }
   },
   methods: {
+    // 详情
+    getDetail () {
+      predictDetail({ sn: this.itemSn }).then(res => {
+        if (res.status == 200) {
+          this.detailData = res.data
+          if (this.detailData.stockPredictRange == 0) { //  自选产品
+            this.getPredictRange()
+          }
+        } else {
+          this.detailData = null
+        }
+      })
+    },
+    // 获取产品范围
+    getPredictRange () {
+      predictRangeList({ 'sn': this.detailData.stockPredictSn }).then(res => {
+        if (res.status == 200) {
+          res.data.map((item, index) => {
+            item.no = index + 1
+          })
+          this.loadData = res.data
+        } else {
+          this.loadData = []
+        }
+      })
+    },
     //  结果下载
     handleDownload () {
       const params = this.queryParam
@@ -133,9 +136,9 @@ export default {
         this.$emit('close')
       }
     },
-    itemId (newValue, oldValue) {
+    itemSn (newValue, oldValue) {
       if (this.isShow && newValue) {
-
+        this.getDetail()
       }
     }
   }

+ 158 - 58
src/views/inventoryManagement/intelligentReplenishment/edit.vue

@@ -6,15 +6,15 @@
         <a id="intelligentReplenishmentEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
       </template>
     </a-page-header>
-    <a-card size="small" :bordered="false" class="intelligentReplenishmentEdit-cont">
-      <div class="steps-cont">
-        <a-steps :current="current" size="small">
-          <a-step title="参数设置" />
-          <a-step title="系统计算" />
-        </a-steps>
-      </div>
-      <!-- 参数设置 -->
-      <div v-if="current==0">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <a-card size="small" :bordered="false" class="intelligentReplenishmentEdit-cont">
+        <div class="steps-cont">
+          <a-steps :current="current" size="small">
+            <a-step title="产品设置" />
+            <a-step title="参数设置" />
+            <a-step title="系统计算" />
+          </a-steps>
+        </div>
         <a-form-model
           id="intelligentReplenishmentEdit-form"
           ref="ruleForm"
@@ -23,88 +23,158 @@
           :label-col="formItemLayout.labelCol"
           :wrapper-col="formItemLayout.wrapperCol"
         >
-          <div class="module-cont">
-            <p class="title">产品范围</p>
-            <a-form-model-item label=" " :colon="false" prop="stockPredictRange" class="form-item">
-              <a-radio-group name="radioGroup" v-model="form.stockPredictRange" placeholder="请选择">
-                <a-radio :value="1">全部产品</a-radio>
-                <a-radio :value="0">自选产品</a-radio>
-              </a-radio-group>
-            </a-form-model-item>
-            <productRange :itemSn="$route.params.sn" />
+          <!-- 产品设置 -->
+          <div v-if="current==0">
+            <div class="module-cont">
+              <p class="title">产品范围</p>
+              <a-form-model-item label=" " :colon="false" prop="stockPredictRange" class="form-item">
+                <a-radio-group name="radioGroup" v-model="form.stockPredictRange" placeholder="请选择">
+                  <a-radio :value="1">全部产品</a-radio>
+                  <a-radio :value="0">自选产品</a-radio>
+                </a-radio-group>
+              </a-form-model-item>
+              <productRange v-if="form.stockPredictRange==0" ref="productRange" :itemSn="$route.params.sn" @ok="handleProductOk" />
+            </div>
           </div>
-          <div class="module-cont">
-            <p class="title">销售保障法<a-button type="link" size="small" class="link-btn" @click="handleExplain('xsbz')">算法说明</a-button></p>
-            <a-form-model-item label="保障倍数" prop="saleEnsureNum" class="form-item">
-              <a-input-number
-                id="intelligentReplenishmentEdit-saleEnsureNum"
-                v-model="form.saleEnsureNum"
-                :precision="2"
-                :min="1"
-                :max="3"
-                placeholder="请输入1~3之间的数字,最多两位小数"
-                style="width: 100%;" />
-            </a-form-model-item>
+          <!-- 参数设置 -->
+          <div v-if="current==1">
+            <div class="module-cont">
+              <p class="title">销售保障法<a-button type="link" size="small" class="link-btn" @click="handleExplain('xsbz')">算法说明</a-button></p>
+              <a-form-model-item label="保障倍数" prop="saleEnsureNum" class="form-item">
+                <a-input-number
+                  id="intelligentReplenishmentEdit-saleEnsureNum"
+                  v-model="form.saleEnsureNum"
+                  :precision="2"
+                  :min="1"
+                  :max="3"
+                  placeholder="请输入1~3之间的数字,最多两位小数"
+                  style="width: 100%;" />
+              </a-form-model-item>
+            </div>
+            <div class="module-cont">
+              <p class="title">趋势平均法<a-button type="link" size="small" class="link-btn" @click="handleExplain('qspj')">算法说明</a-button></p>
+              <a-form-model-item label="服务水平" prop="trendSn" class="form-item">
+                <div class="intelligentReplenishmentEdit-trendSn" @click="openModal=true">{{ form.serviceLevel || '--' }}%(对应的安全系数为{{ form.safetyFactor || '--' }})</div>
+              </a-form-model-item>
+            </div>
           </div>
-          <div class="module-cont">
-            <p class="title">趋势平均法<a-button type="link" size="small" class="link-btn" @click="handleExplain('qspj')">算法说明</a-button></p>
-            <a-form-model-item label="服务水平" prop="loginFlag" class="form-item">
-              <a-input id="intelligentReplenishmentEdit-outQty" v-model="form.productOrigCode" placeholder="请选择" read-only @click="chooseFun" />
-            </a-form-model-item>
+          <!-- 系统计算 -->
+          <div v-if="current==2">
+            <div class="item-cont">
+              <img src="@/assets/explain/def_calculation.png" width="200" class="item-pic" />
+              <p class="item-txt">按照上一步的参数设置,系统正在<br/>计算中...点击左上角的返回列表可查看该条预测记录</p>
+            </div>
           </div>
         </a-form-model>
-        <div class="btn-cont">
-          <a-button type="primary" class="button-error" id="intelligentReplenishmentLevel-submit" @click="handleSubmit">下一步</a-button>
-        </div>
-      </div>
-      <!-- 系统计算 -->
-      <div v-if="current==1">
-        <div class="item-cont">
-          <img src="@/assets/explain/def_calculation.png" width="200" class="item-pic" />
-          <p class="item-txt">按照上一步的参数设置,系统正在<br/>计算中...点击左上角的返回列表可查看该条预测记录</p>
+        <div class="btn-cont" v-if="current==0 || current==1">
+          <a-button
+            type="primary"
+            id="intelligentReplenishmentLevel-submit"
+            size="large"
+            class="button-primary"
+            @click="handleNext"
+            style="padding: 0 60px;">下一步</a-button>
         </div>
-      </div>
-    </a-card>
+      </a-card>
+    </a-spin>
     <!-- 服务水平 -->
-    <replenishment-service-level-modal :openModal="openModal" @close="openModal=false" @ok="handleOk" />
+    <replenishment-service-level-modal :openModal="openModal" :itemSn="form.trendSn" @close="openModal=false" @ok="handleOk" />
   </div>
 </template>
 
 <script>
 import ReplenishmentServiceLevelModal from './serviceLevelModal.vue'
 import productRange from './productRange.vue'
+import { predictDetail, predictRangeSave, predictSave, predictTrendList, predictRun } from '@/api/predict'
 export default {
   components: { ReplenishmentServiceLevelModal, productRange },
   data () {
     return {
+      spinning: false,
       formItemLayout: {
         labelCol: { span: 2 },
         wrapperCol: { span: 16 }
       },
       form: {
         stockPredictRange: 1,
-        saleEnsureNum: ''
+        saleEnsureNum: '',
+        trendSn: '',
+        serviceLevel: '',
+        safetyFactor: ''
       },
       rules: {
-        saleEnsureNum: [ { required: true, message: '请输入保障倍数', trigger: 'blur' } ]
+        saleEnsureNum: [ { required: true, message: '请输入保障倍数', trigger: 'blur' } ],
+        trendSn: [ { required: true, message: '请选择服务水平', trigger: ['blur', 'change'] } ]
       },
       openModal: false,
-      current: 0
+      current: 0,
+      detailData: null
     }
   },
-  mounted () {
-    console.log(this.$route.params.sn)
-  },
   methods: {
     // 返回
     handleBack () {
       this.$router.push({ path: `/inventoryManagement/intelligentReplenishment/list` })
     },
+    // 详情
+    getDetail () {
+      predictDetail({ sn: this.$route.params.sn }).then(res => {
+        if (res.status == 200) {
+          this.detailData = res.data
+        } else {
+          this.detailData = null
+        }
+      })
+    },
+    // 产品范围 ok
+    handleProductOk (params) {
+      predictRangeSave(params).then(res => {
+        if (res.status == 200) {
+          this.$refs.productRange.refreshList()
+        }
+      })
+    },
     // 下一步
-    handleSubmit () {},
-    //  选择
-    chooseFun () {
-      this.openModal = true
+    handleNext () {
+      const _this = this
+      if (this.current == 0) { //  产品设置
+        const params = {
+          stockPredictSn: this.$route.params.sn,
+          stockPredictRange: this.form.stockPredictRange
+        }
+        this.handleSave(params)
+      } else if (this.current == 1) { //  参数设置
+        this.$refs.ruleForm.validate(valid => {
+          if (valid) {
+            const params = {
+              stockPredictSn: _this.$route.params.sn,
+              saleEnsureNum: _this.form.saleEnsureNum,
+              trendSn: _this.form.trendSn,
+              trendServiceLevel: _this.form.serviceLevel,
+              trendSafetyFactor: _this.form.safetyFactor
+            }
+            _this.handleRun(params)
+          } else {
+            return false
+          }
+        })
+      }
+    },
+    // 保存
+    handleSave (params) {
+      predictSave(params).then(res => {
+        if (res.status == 200) {
+          this.current++
+        }
+      })
+    },
+    // 计算
+    handleRun (params) {
+      predictRun(params).then(res => {
+        if (res.status == 200) {
+          this.current++
+        }
+      })
     },
     // 算法说明
     handleExplain (type) {
@@ -116,9 +186,32 @@ export default {
     },
     // 服务水平选择
     handleOk (val) {
-      console.log(val)
+      this.form.trendSn = val.trendSn
+      this.form.serviceLevel = val.serviceLevel
+      this.form.safetyFactor = val.safetyFactor
       this.openModal = false
+    },
+    // 获取默认服务水平
+    getTrendSn () {
+      predictTrendList({ defaultFlag: 1 }).then(res => {
+        if (res.status == 200) {
+          this.form.trendSn = res.data[0].trendSn
+          this.form.serviceLevel = res.data[0].serviceLevel
+          this.form.safetyFactor = res.data[0].safetyFactor
+        } else {
+          this.form.trendSn = ''
+          this.form.serviceLevel = ''
+          this.form.safetyFactor = ''
+        }
+      })
     }
+  },
+  beforeRouteEnter (to, from, next) {
+    next(vm => {
+      vm.getDetail()
+      vm.getTrendSn()
+      vm.current = 0
+    })
   }
 }
 </script>
@@ -153,6 +246,13 @@ export default {
         .form-item{
           margin-top: 25px;
         }
+        .intelligentReplenishmentEdit-trendSn{
+          border: 1px solid #d9d9d9;
+          border-radius: 4px;
+          line-height: 1.5;
+          padding: 4px 11px;
+          margin-top: 4px;
+        }
       }
       .item-cont{
         text-align: center;

+ 65 - 37
src/views/inventoryManagement/intelligentReplenishment/import.vue

@@ -6,9 +6,9 @@
         <a id="intelligentReplenishmentImport-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
       </template>
     </a-page-header>
-    <a-card size="small" :bordered="false" class="intelligentReplenishmentImport-cont">
+    <a-card :bordered="false" class="intelligentReplenishmentImport-cont">
       <div>
-        <p class="total">共 <span>50</span> 条数据,红色字体表示数据不符合规范,请返回上一步修改文件后重新上传</p>
+        <p class="total">共 <span>{{ listData.length }}</span> 条数据,红色字体表示数据不符合规范,请返回上一步修改文件后重新上传</p>
         <s-table
           class="sTable"
           ref="table"
@@ -17,12 +17,32 @@
           :columns="columns"
           :data="loadData"
           :scroll="{ x: 1440 }"
+          :showPagination="false"
           bordered>
         </s-table>
         <div class="btn-cont">
-          <a-button type="primary" class="button-error" id="intelligentReplenishmentLevel-submit" @click="handleSubmit">确认导入</a-button>
-          <a-button type="primary" class="button-error" id="intelligentReplenishmentLevel-back" @click="handleBackSet">上一步</a-button>
-          <a-button id="intelligentReplenishmentLevel-back" @click="isShow = false" class="button-cancel">取消</a-button>
+          <a-button
+            type="primary"
+            v-if="errorFlag.indexOf('1')==-1"
+            id="intelligentReplenishmentLevel-submit"
+            size="large"
+            class="button-primary"
+            @click="handleSubmit"
+            style="padding: 0 60px;">确认导入</a-button>
+          <a-button
+            type="primary"
+            v-if="errorFlag.indexOf('1')!=-1"
+            id="intelligentReplenishmentLevel-set"
+            size="large"
+            class="button-primary"
+            @click="handleBackSet"
+            style="padding: 0 60px;">上一步</a-button>
+          <a-button
+            id="intelligentReplenishmentLevel-back"
+            size="large"
+            class="button-cancel"
+            @click="handleBack"
+            style="padding: 0 60px;">取消</a-button>
         </div>
       </div>
     </a-card>
@@ -31,47 +51,36 @@
 
 <script>
 import { STable } from '@/components'
+import { predictProductInfoGoods, predictProductInfoInsert } from '@/api/predict'
 export default {
   components: { STable },
   data () {
     return {
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
-        { title: '产品编码', dataIndex: 'purchaseNo', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '产品名称', dataIndex: 'creatDate', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '产品状态', dataIndex: 'purchaseNos', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '订货周期(天)', dataIndex: 'purchaseNoa', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '是否淘汰', dataIndex: 'purchaseNod', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '淘汰描述', dataIndex: 'purchaseNof', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '备注', dataIndex: 'purchaseNog', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '错误原因', dataIndex: 'purchaseNoh', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true }
+        { title: '产品编码', dataIndex: 'productCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '产品状态', dataIndex: 'productStateDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '订货周期(天)', dataIndex: 'cycle', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '是否淘汰', dataIndex: 'eliminateText', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '淘汰描述', dataIndex: 'eliminateDesc', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '备注', dataIndex: 'remark', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '错误原因', dataIndex: 'errorDesc', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
-        // return custTypeList(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
-        //   }
-        //   return data
-        // })
-        return new Promise(function (resolve, reject) {
-          const data = {
-            pageNo: 1,
-            pageSize: 10,
-            list: [
-              { id: '1', state: 1, purchaseNo: 'jgqp11111111111', creatDate: '产品1', custName: 'jgqp111123545', totalP: '箭冠品牌', totalNums: '产品分类1', totalPrice: '5', payType: '122' },
-              { id: '2', state: 2, purchaseNo: 'jgqp11111111111', creatDate: '产品1', custName: 'jgqp111123545', totalP: '箭冠品牌', totalNums: '产品分类1', totalPrice: '5', payType: '122' },
-              { id: '3', state: 3, purchaseNo: 'jgqp11111111111', creatDate: '产品1', custName: 'jgqp111123545', totalP: '箭冠品牌', totalNums: '产品分类1', totalPrice: '5', payType: '122' },
-              { id: '4', state: 4, purchaseNo: 'jgqp11111111111', creatDate: '产品1', custName: 'jgqp111123545', totalP: '箭冠品牌', totalNums: '产品分类1', totalPrice: '5', payType: '122' },
-              { id: '5', state: 5, purchaseNo: 'jgqp11111111111', creatDate: '产品1', custName: 'jgqp111123545', totalP: '箭冠品牌', totalNums: '产品分类1', totalPrice: '5', payType: '122' }
-            ],
-            count: 10
+        return predictProductInfoGoods({ path: JSON.parse(this.$cookies.get('REPLENISHMENT_PATH')) }).then(res => {
+          const data = res.data
+          for (var i = 0; i < data.list.length; i++) {
+            data.list[i].no = i + 1
+            this.errorFlag.push(data.list[i].errorFlag)
           }
-          resolve(data)
+          this.listData = data.list
+          return data
         })
-      }
+      },
+      listData: [],
+      errorFlag: []
     }
   },
   methods: {
@@ -81,10 +90,29 @@ export default {
     },
     // 返回基础设置页
     handleBackSet () {
-      this.$router.push({ path: `/inventoryManagement/intelligentReplenishment/set/${this.$route.params.sn}` })
+      this.$router.push({ path: `/inventoryManagement/intelligentReplenishment/set` })
     },
     // 确认导入
-    handleSubmit () {}
+    handleSubmit () {
+      const _this = this
+      predictProductInfoInsert(this.listData).then(res => {
+        if (res.status == 200) {
+          _this.$success({
+            content: '数据导入成功!',
+            centered: true,
+            onOk () {
+              _this.handleBack()
+            }
+          })
+        } else {
+          _this.$error({
+            content: '数据导入失败,请重试!',
+            centered: true,
+            onOk () {}
+          })
+        }
+      })
+    }
   }
 }
 </script>

+ 18 - 15
src/views/inventoryManagement/intelligentReplenishment/list.vue

@@ -24,18 +24,21 @@
           size="small"
           type="link"
           class="button-info"
+          v-if="record.state == 'WAIT'"
           @click="handleEdit(record)"
           id="intelligentReplenishmentList-edit-btn">编辑</a-button>
         <a-button
           size="small"
           type="link"
           class="button-error"
+          v-if="record.state == 'WAIT'"
           @click="handleDel(record)"
           id="intelligentReplenishmentList-del-btn">删除</a-button>
         <a-button
           size="small"
           type="link"
           class="button-success"
+          v-if="record.state != 'WAIT'"
           @click="handleDetail(record)"
           id="customerManagementList-detail-btn">详情</a-button>
         <a-button
@@ -43,12 +46,13 @@
           type="link"
           class="button-warning"
           :loading="downloadLoading"
+          v-if="record.state == 'FINISH'"
           @click="handleDownload(record)"
           id="chainTransferInList-download-btn">结果下载</a-button>
       </template>
     </s-table>
     <!-- 详情 -->
-    <intelligent-replenishment-detail-modal :openModal="openDetailModal" :itemId="itemId" @close="closeModal" />
+    <intelligent-replenishment-detail-modal :openModal="openDetailModal" :itemSn="itemSn" @close="closeModal" />
   </a-card>
 </template>
 
@@ -56,7 +60,7 @@
 import moment from 'moment'
 import { STable, VSelect } from '@/components'
 import intelligentReplenishmentDetailModal from './detailModal.vue'
-import { predictList, predictSave } from '@/api/predict'
+import { predictList, predictSave, predictDel } from '@/api/predict'
 export default {
   components: { STable, VSelect, intelligentReplenishmentDetailModal },
   data () {
@@ -78,7 +82,7 @@ export default {
           return data
         })
       },
-      itemId: '', //  当前id
+      itemSn: '', //  当前sn
       downloadLoading: false,
       openDetailModal: false
     }
@@ -91,20 +95,19 @@ export default {
       } else { //  新增
         predictSave({}).then(res => {
           if (res.status == 200) {
-            this.$router.push({ path: `/inventoryManagement/intelligentReplenishment/add/${row.stockPredictSn}` })
+            this.$router.push({ path: `/inventoryManagement/intelligentReplenishment/add/${res.data.stockPredictSn}` })
           }
         })
       }
     },
     //  详情
     handleDetail (row) {
-      this.itemId = row ? row.id : null
+      this.itemSn = row ? row.stockPredictSn : null
       this.openDetailModal = true
     },
     // 设置
-    handleSet (row) {
-      // this.$router.push({ path: `/inventoryManagement/intelligentReplenishment/set/${row.sn}` })
-      this.$router.push({ path: `/inventoryManagement/intelligentReplenishment/set/111` })
+    handleSet () {
+      this.$router.push({ path: `/inventoryManagement/intelligentReplenishment/set` })
     },
     // 删除
     handleDel (row) {
@@ -114,18 +117,18 @@ export default {
         content: '删除后不可恢复,确定要进行删除吗?',
         centered: true,
         onOk () {
-          // custTypeDel({ id: row.id }).then(res => {
-          //   if (res.status == 200) {
-          //     _this.$message.success(res.message)
-          //     _this.$refs.table.refresh()
-          //   }
-          // })
+          predictDel({ sn: row.stockPredictSn }).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$refs.table.refresh()
+            }
+          })
         }
       })
     },
     //  关闭弹框
     closeModal () {
-      this.itemId = ''
+      this.itemSn = ''
       this.openDetailModal = false
       this.$refs.table.refresh(true)
     },

+ 93 - 45
src/views/inventoryManagement/intelligentReplenishment/productRange.vue

@@ -2,14 +2,16 @@
   <div class="productRange-wrap">
     <!-- 操作按钮 -->
     <div class="table-operator">
-      <a-button id="productRange-brand" type="primary" class="button-error" @click="choosePModal('BRAND')">选择产品品牌</a-button>
-      <a-button id="productRange-type" type="primary" class="button-info" @click="choosePModal('CATEGORY')">选择产品分类</a-button>
-      <a-button id="productRange-product" type="primary" class="button-success" @click="choosePModal('PRODUCT')">选择供应商</a-button>
+      <a-button id="productRange-brand" type="primary" class="button-error" @click="choosePModal('PRODUCT_BRAND')">选择产品品牌</a-button>
+      <a-button id="productRange-type" type="primary" class="button-info" @click="choosePModal('PRODUCT_TYPE')">选择产品分类</a-button>
+      <a-button id="productRange-product" type="primary" class="button-success" @click="choosePModal('SUPPLIER')">选择供应商</a-button>
     </div>
     <!-- 选择产品品牌 -->
     <chooseBrandModal :openModal="openBrandModal" :chooseData="chooseBrand" @close="openBrandModal=false" @ok="handleBrandOk" />
     <!-- 选择产品分类 -->
     <chooseTypeModal :openModal="openTypeModal" :chooseData="chooseType" @close="openTypeModal=false" @ok="handleTypeOk" />
+    <!-- 选择供应商 -->
+    <chooseSupplierModal :openModal="openSupplierModal" :chooseData="chooseSupplier" @close="openSupplierModal=false" @ok="handleSupplierOk" />
     <!-- 列表 -->
     <s-table
       class="sTable"
@@ -20,6 +22,15 @@
       :data="loadData"
       :showPagination="false"
       bordered>
+      <!-- 操作 -->
+      <template slot="action" slot-scope="text, record">
+        <a-button
+          size="small"
+          type="link"
+          class="button-error"
+          @click="handleDel(record)"
+          id="productRange-del-btn">删除</a-button>
+      </template>
     </s-table>
   </div>
 </template>
@@ -28,9 +39,10 @@
 import { STable } from '@/components'
 import ChooseBrandModal from '@/views/common/chooseBrandModal.vue'
 import ChooseTypeModal from '@/views/common/chooseTypeModal.vue'
-import { predictRangeList } from '@/api/predict'
+import ChooseSupplierModal from '@/views/common/chooseSupplierModal.vue'
+import { predictRangeList, predictRangeDel } from '@/api/predict'
 export default {
-  components: { STable, ChooseBrandModal, ChooseTypeModal },
+  components: { STable, ChooseBrandModal, ChooseTypeModal, ChooseSupplierModal },
   props: {
     itemSn: {
       type: [String, Number],
@@ -41,14 +53,15 @@ export default {
     return {
       openBrandModal: false, //  选择产品品牌
       openTypeModal: false, //  选择产品分类
+      openSupplierModal: false, //  选择供应商
       chooseBrand: [], //  所选品牌
       chooseType: [], //  所选分类
+      chooseSupplier: [], //  所选供应商
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
-        { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '创建人', dataIndex: 'creatorName', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '状态', dataIndex: 'stateDictValue', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center' }
+        { title: '类型', dataIndex: 'rangeTypeName', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '类型名称', dataIndex: 'rangeDataName', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '操作', scopedSlots: { customRender: 'action' }, align: 'center' }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
@@ -57,9 +70,11 @@ export default {
           for (var i = 0; i < data.length; i++) {
             data[i].no = i + 1
           }
+          this.listData = data
           return data
         })
-      }
+      },
+      listData: []
     }
   },
   methods: {
@@ -67,67 +82,100 @@ export default {
     choosePModal (type) {
       const brandList = []
       const typeList = []
-      predictRangeList({ 'sn': this.itemSn }).then(res => {
-        if (res.status == 200) {
-          const data = res.data
-          data.map(item => {
-            if (item.goodsType == 'BRAND') {
-              brandList.push(item)
-            } else if (item.goodsType == 'CATEGORY') {
-              typeList.push(item)
-            }
-          })
-          if (type == 'BRAND') { //  选择品牌
-            this.chooseBrand = brandList
-            this.openBrandModal = true
-          } else if (type == 'CATEGORY') { //  选择分类
-            this.chooseType = typeList
-            this.openTypeModal = true
-          }
+      const supplierList = []
+      this.listData.map(item => {
+        if (item.rangeType == 'PRODUCT_BRAND') {
+          brandList.push(Object.assign(item, { goodsSn: item.rangeDataSn, brandSn: item.rangeDataSn }))
+        } else if (item.rangeType == 'PRODUCT_TYPE') {
+          typeList.push(Object.assign(item, { goodsSn: item.rangeDataSn, productTypeSn: item.rangeDataSn }))
+        } else if (item.rangeType == 'SUPPLIER') {
+          supplierList.push(Object.assign(item, { supplierSn: item.rangeDataSn }))
         }
       })
-      if (type == 'BRAND') { //  选择品牌
-        // this.chooseBrand = brandList
+      if (type == 'PRODUCT_BRAND') { //  选择品牌
+        this.chooseBrand = brandList
         this.openBrandModal = true
-      } else if (type == 'CATEGORY') { //  选择分类
-        // this.chooseType = typeList
+      } else if (type == 'PRODUCT_TYPE') { //  选择分类
+        this.chooseType = typeList
         this.openTypeModal = true
+      } else if (type == 'SUPPLIER') {
+        this.chooseSupplier = supplierList
+        this.openSupplierModal = true
       }
     },
     // 品牌
     handleBrandOk (obj) {
       this.chooseBrand = obj
-      this.changeData('BRAND')
+      this.changeData('PRODUCT_BRAND')
     },
     // 分类
     handleTypeOk (obj) {
       this.chooseType = obj
-      this.changeData('CATEGORY')
+      this.changeData('PRODUCT_TYPE')
+    },
+    // 供应商
+    handleSupplierOk (obj) {
+      this.chooseSupplier = obj
+      this.changeData('SUPPLIER')
     },
     changeData (type) {
       const _this = this
-      if (type == 'BRAND') { //  选择品牌
+      const dataList = []
+      if (type == 'PRODUCT_BRAND') { //  选择品牌
         if (_this.chooseBrand.length > 0) {
-          const snList = []
           _this.chooseBrand.map(item => {
-            snList.push(item.brandSn)
+            dataList.push({
+              rangeType: type,
+              rangeDataSn: item.brandSn,
+              stockPredictSn: this.itemSn
+            })
           })
-          this.setData(snList, type)
         }
-      } else if (type == 'CATEGORY') { //  选择分类
+      } else if (type == 'PRODUCT_TYPE') { //  选择分类
         if (_this.chooseType.length > 0) {
-          const snList = []
           _this.chooseType.map(item => {
-            snList.push(item.productTypeSn)
+            dataList.push({
+              rangeType: type,
+              rangeDataSn: item.productTypeSn,
+              stockPredictSn: this.itemSn
+            })
+          })
+        }
+      } else if (type == 'SUPPLIER') { //  选择供应商
+        if (_this.chooseSupplier.length > 0) {
+          _this.chooseSupplier.map(item => {
+            dataList.push({
+              rangeType: type,
+              rangeDataSn: item.supplierSn,
+              stockPredictSn: this.itemSn
+            })
           })
-          this.setData(snList, type)
         }
       }
+      console.log('----------------选择', dataList)
+      this.$emit('ok', dataList)
+    },
+    // 删除
+    handleDel (row) {
+      const _this = this
+      this.$confirm({
+        title: '提示',
+        content: '删除后不可恢复,确定要进行删除吗?',
+        centered: true,
+        onOk () {
+          predictRangeDel({ stockPredictSn: row.stockPredictSn, rangeDataSn: row.rangeDataSn }).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$refs.table.refresh()
+            }
+          })
+        }
+      })
+    },
+    // 刷新数据
+    refreshList () {
+      this.$refs.table.refresh()
     }
   }
 }
 </script>
-
-<style lang="less">
-  .productRange-wrap{}
-</style>

+ 16 - 6
src/views/inventoryManagement/intelligentReplenishment/serviceLevelModal.vue

@@ -18,6 +18,7 @@
         :columns="columns"
         :data="loadData"
         :scroll="{ y: 400 }"
+        :showPagination="false"
         bordered>
       </s-table>
       <div class="btn-cont">
@@ -39,7 +40,7 @@ export default {
       type: Boolean,
       default: false
     },
-    itemId: {
+    itemSn: {
       type: [Number, String],
       default: ''
     }
@@ -49,16 +50,18 @@ export default {
       isShow: this.openModal, //  是否打开弹框
       detailsData: null, //  详情数据
       columns: [
-        { title: '服务水平(%)', dataIndex: 'purchaseNo', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '安全系数', dataIndex: 'creatDate', align: 'center', customRender: function (text) { return text || '--' } }
+        { title: '服务水平(%)', dataIndex: 'serviceLevel', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '安全系数', dataIndex: 'safetyFactor', align: 'center', customRender: function (text) { return text || '--' } }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
         return predictTrendList({}).then(res => {
           const data = res.data
+          this.listData = data
           return data
         })
       },
+      listData: [],
       selectedRowKeys: []
     }
   },
@@ -70,7 +73,13 @@ export default {
     //  保存
     handleSave () {
       if (this.selectedRowKeys.length > 0) {
-        this.$emit('ok', this.selectedRowKeys)
+        const ind = this.listData.findIndex(item => item.trendSn == this.selectedRowKeys[0])
+        const params = {
+          trendSn: this.listData[ind].trendSn,
+          serviceLevel: this.listData[ind].serviceLevel,
+          safetyFactor: this.listData[ind].safetyFactor
+        }
+        this.$emit('ok', params)
       } else {
         this.$message.warning('请选择服务水平后再进行保存!')
       }
@@ -87,9 +96,10 @@ export default {
         this.$emit('close')
       }
     },
-    itemId (newValue, oldValue) {
+    itemSn (newValue, oldValue) {
       if (this.isShow && newValue) {
-
+        this.selectedRowKeys = [newValue]
+        console.log(this.selectedRowKeys)
       }
     }
   }

+ 29 - 8
src/views/inventoryManagement/intelligentReplenishment/set.vue

@@ -21,9 +21,7 @@
               <li>4) “是否淘汰”字段,如果确定淘汰,则输入“是”,如果不淘汰,则不需要输入,保持为空即可</li>
               <li>5) “淘汰描述”字段,只有当是否淘汰为“是”时,才能录入淘汰描述,否则,淘汰描述只能保持为空</li>
             </ul>
-            <a :href="filePath" style="padding: 5px 0 0 23px;display: block;">
-              <a-icon type="download" style="padding-right: 5px;" />下载导入模板
-            </a>
+            <a-button type="link" icon="download" style="padding: 0 0 0 23px;" @click="handleExport">下载导入模板</a-button>
           </div>
           <div class="explain-item">
             <div class="explain-tit">
@@ -66,7 +64,10 @@
 </template>
 
 <script>
+import moment from 'moment'
+import VueCookies from 'vue-cookies'
 import { Upload } from '@/components'
+import { predictProductInfoExport } from '@/api/predict'
 export default {
   components: { Upload },
   data () {
@@ -87,15 +88,35 @@ export default {
     },
     // 下一步
     handlerNextStep () {
-      // if (this.paramsData) {
-      this.$router.push({ path: `/inventoryManagement/intelligentReplenishment/import/${this.$route.params.sn}` })
-      // } else {
-      //   this.$message.warning('添加文件后再进行下一步操作!')
-      // }
+      if (this.paramsData) {
+        this.$router.push({ path: `/inventoryManagement/intelligentReplenishment/import` })
+      } else {
+        this.$message.warning('添加文件后再进行下一步操作!')
+      }
     },
     // 上传文件  change
     changeImport (file) {
       console.log(file, '----上传')
+      this.paramsData = file
+      VueCookies.set('REPLENISHMENT_PATH', JSON.stringify(file))
+    },
+    //  导出
+    handleExport () {
+      predictProductInfoExport({}).then(res => {
+        this.download(res)
+      })
+    },
+    download (data) {
+      if (!data) { return }
+      const url = window.URL.createObjectURL(new Blob([data]))
+      const link = document.createElement('a')
+      link.style.display = 'none'
+      link.href = url
+      const a = moment().format('YYYYMMDDHHmmss')
+      const fname = '智能补货_模板_' + a
+      link.setAttribute('download', fname + '.xlsx')
+      document.body.appendChild(link)
+      link.click()
     }
   }
 }