zuozhengqing
2023-11-06 e7ccd2a06e4cdf3709e699507e1e15379ded5b83
src/views/operate/orderPoint/index.vue
@@ -1,29 +1,55 @@
<template>
  <div class="rightContent">
    <div class="top">
      <SearchCommonView :add-title="addTitle" :show-discard="showDiscard" :show-apply="false" :placeholder="'请输入位置/产品'"
        :amount-view="false" @addCommonClick="addProductClick" @searchClick="getList"
        @discardBtnClick="discardBtnClick" />
      <SearchCommonView
        :add-title="addTitle"
        :show-discard="showDiscard"
        :show-apply="false"
        :placeholder="'请输入位置/产品'"
        :amount-view="false"
        :search-task-map="searchTaskMap"
        :show-sreen="false"
        :screen-array="screenArray"
        @addCommonClick="addProductClick"
        @searchClick="getList"
        @discardBtnClick="discardBtnClick"
        @delSelectClick="delSelectClick"
        @switchKeywords="switchKeywords"
      />
    </div>
    <div class="content_wrap">
      <div class="con_left">
          <p>位置</p>
          <div class="stash">
            <template>
              <el-tree :data="datas" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
            </template>
          </div>
        <p>位置</p>
        <div class="stash">
          <template>
            <el-tree :data="datas" :props="defaultProps" @node-click="handleNodeClick">
              <span class="span-ellipsis" slot-scope="{ node }">
                <span :title="node.label">{{ node.label }}</span>
              </span>
            </el-tree>
          </template>
        </div>
      </div>
      <div class="list-view">
        <div class="table">
          <CommonFormTableView ref="tablelistRef" :isReorder="true" :product-table-list="tableList"
            @inputContent="inputContent" @selLocationClick="selLocationClick" @selProductClick="selProductClick"
            @tableRowClick="tableRowClick" @selRouteClick="selRouteClick">
          <CommonFormTableView
            ref="tablelistRef"
            :isReorder="true"
            :product-table-list="tableList"
            @inputContent="inputContent"
            @selLocationClick="selLocationClick"
            @selProductClick="selProductClick"
            @tableRowClick="tableRowClick"
            @selRouteClick="selRouteClick"
          >
            <template slot="tableButton">
              <el-table-column label="操作" width="180" align="center">
                <template slot-scope="scope">
                  <span v-if="scope.row.isEdit && scope.row.isView" @click.stop="handleOrderOnceClick(scope.row)"
                    class="yes-cursor">
                  <span
                    v-if="scope.row.isEdit && scope.row.isView"
                    @click.stop="handleOrderOnceClick(scope.row)"
                    class="yes-cursor"
                  >
                    <i class="el-icon-truck"></i>
                    <span>订购一次</span>
                  </span>
@@ -43,7 +69,13 @@
<script>
import CommonFormTableView from "@/components/makepager/CommonFormTableView"
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import { getReorderRuleList, addReorderRule, updateReorderRule, orderAgain,getLocationList } from "@/api/product/reorderRules"
import {
  getReorderRuleList,
  addReorderRule,
  updateReorderRule,
  orderAgain,
  getLocationTreeList
} from "@/api/product/reorderRules"
import { currentTime } from "@/common/config/index"
export default {
  name: "ReorderRules",
@@ -53,45 +85,10 @@
  computed: {},
  data() {
    return {
      datas:[],
      // datas: [{
      //     label: '一级 1',
      //     children: [{
      //       label: '二级 1-1',
      //       children: [{
      //         label: '三级 1-1-1'
      //       }]
      //     }]
      //   }, {
      //     label: '一级 2',
      //     children: [{
      //       label: '二级 2-1',
      //       children: [{
      //         label: '三级 2-1-1'
      //       }]
      //     }, {
      //       label: '二级 2-2',
      //       children: [{
      //         label: '三级 2-2-1'
      //       }]
      //     }]
      //   }, {
      //     label: '一级 3',
      //     children: [{
      //       label: '二级 3-1',
      //       children: [{
      //         label: '三级 3-1-1'
      //       }]
      //     }, {
      //       label: '二级 3-2',
      //       children: [{
      //         label: '三级 3-2-1'
      //       }]
      //     }]
      // }],
      datas: [],
      defaultProps: {
        children: 'children',
        label: 'jointName'
        children: "children",
        label: "jointName"
      },
      addTitle: "新建",
      showDiscard: false,
@@ -109,11 +106,15 @@
      maxInventory: 0,
      orderNumber: 0,
      unit: "",
      reorderId: 0
      reorderId: 0,
      searchTaskMap: [],
      type: "bh",
      screenArray: [{ id: "0", type: "bh", title: "重新订购" }]
    }
  },
  created() {
    this.setTable()
    this.searchTaskMap = [{ id: "0", type: this.type, title: "重新订购" }]
    this.getData()
    this.getLocationList()
  },
@@ -137,14 +138,17 @@
      }
    },
    // 请求数据
    async getData() {
    async getData(data) {
      await getReorderRuleList({
        locationId: data?.id,
        type: this.type,
        keyWord: data?.jointName,
        page: this.pagerOptions.currPage,
        pageSize: this.pagerOptions.pageSize
      }).then((res) => {
        if (res.code === 200) {
          console.log(res)
          const list = res.data.map((item) => {
          const list = res.data?.map((item) => {
            let orderNum = 0
            if (parseFloat(item.minInventory) - parseFloat(item.prediction) > 0) {
              orderNum = this.caculateOrderNumber(
@@ -356,54 +360,31 @@
    },
    //树点击
    handleNodeClick(data) {
      console.log(data,"sss");
      getReorderRuleList({
        locationId:data.id,
        page:1,
        pageSize:15,
        type:"",
        keyWord:data.jointName,
      }).then((res)=>{
        console.log(res,"res999")
        if (res.code === 200) {
          console.log(res)
          const list = res.data.map((item) => {
            let orderNum = 0
            if (parseFloat(item.minInventory) - parseFloat(item.prediction) > 0) {
              orderNum = this.caculateOrderNumber(
                parseFloat(item.minInventory),
                parseFloat(item.maxInventory),
                parseFloat(item.prediction)
              )
            }
            return {
              ...item,
              productName: item.product.name,
              locationName: item.location.name,
              isSet: false,
              isEdit: true,
              editable: true,
              isOrder: true,
              isView: item?.minInventory - item?.prediction > 0 ? true : false,
              orderNumber: orderNum
            }
          })
          this.tableList.tableData = list || []
          this.tableData = list || []
          this.pagerOptions.totalCount = res.total
        }
      console.log(data, "sss")
      this.getData(data)
    },
    async getLocationList() {
      await getLocationTreeList().then((res) => {
        this.datas = [
          {
            id: 0,
            jointName: "全部",
            children: []
          },
          ...res.data
        ]
        console.log(res, "res666")
      })
    },
    async getLocationList(){
      await getLocationList({
        categoryId:"",
        keyWord:"",
        // page:1,
        // pageSize:,
      }).then((res)=>{
        this.datas=res.data
        console.log(res,"res666")
      })
    // 删除type
    delSelectClick() {
      this.type = ""
      this.getData()
    },
    switchKeywords(item) {
      console.log(item, "switchKeywords")
      this.type = item?.length > 0 ? "bh" : ""
      this.getData()
    }
  }
}
@@ -418,28 +399,37 @@
    overflow: auto;
  }
  .content_wrap {
  height: calc(100% - 0px);
  display: flex;
  justify-content: space-between;
  .con_left {
    width: 200px;
    .el-checkbox-group {
      width:100%;
      display: flex;
      flex-direction: column;
    }
    .stash {
      display: flex;
      flex-direction: column;
      .el-tree{
        background-color: #E6ECF2;
    height: calc(100% - 0px);
    display: flex;
    justify-content: space-between;
    .con_left {
      max-height: calc(100% - 40px);
      overflow: hidden;
      width: 190px;
      margin-right: 10px;
      .el-checkbox-group {
        width: 100%;
        display: flex;
        flex-direction: column;
      }
      .stash {
        display: flex;
        flex-direction: column;
        .el-tree {
          background-color: #e6ecf2;
        }
      }
    }
    .list-view {
      flex: 1;
    }
  }
  .list-view {
    flex: 1;
  .span-ellipsis {
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 13px;
  }
}
}
</style>