charles
2024-08-06 5ecb7958c96d3f0b6d47b79aff7eb306c2cf690f
src/views/operate/orderPoint/index.vue
@@ -1,21 +1,7 @@
<template>
  <div class="rightContent">
    <div class="top">
      <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"
      />
      <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">
@@ -32,24 +18,11 @@
      </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>
@@ -67,18 +40,12 @@
</template>
<script>
import CommonFormTableView from "@/components/makepager/CommonFormTableView"
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import {
  getReorderRuleList,
  addReorderRule,
  updateReorderRule,
  orderAgain,
  getLocationTreeList
} from "@/api/product/reorderRules"
import { currentTime } from "@/common/config/index"
  import CommonFormTableView from '@/components/makepager/CommonFormTableView'
  import pageMixin from '@/components/makepager/pager/mixin/pageMixin'
  import { getReorderRuleList, addReorderRule, updateReorderRule, orderAgain, getLocationTreeList } from '@/api/product/reorderRules'
  import { currentTime } from '@/common/config/index'
export default {
  name: "ReorderRules",
    name: 'ReorderRules',
  props: {},
  components: { CommonFormTableView },
  mixins: [pageMixin],
@@ -87,10 +54,10 @@
    return {
      datas: [],
      defaultProps: {
        children: "children",
        label: "jointName"
          children: 'children',
          label: 'name',
      },
      addTitle: "新建",
        addTitle: '新建',
      showDiscard: false,
      tableList: {},
      tableData: [],
@@ -105,11 +72,11 @@
      minInventory: 0,
      maxInventory: 1,
      orderNumber: 1,
      unit: "",
        unit: '',
      reorderId: 0,
      searchTaskMap: [],
      type: "bh",
      screenArray: [{ id: "0", type: "bh", title: "重新订购" }]
        type: 'bh',
        screenArray: [{ id: '0', type: 'bh', title: '重新订购' }],
    }
  },
  created() {
@@ -117,7 +84,7 @@
      this.getData({
        productId: this.$route.params.productId,
        pageSize: 15,
        page: 1
          page: 1,
      })
    }else if(this.$route.params.locationId){
      this.searchTaskMap=[]
@@ -126,13 +93,13 @@
        jointName:this.$route.params.locationName,
        // type:"",
        pageSize: 15,
        page: 1
          page: 1,
      })
    }else {
      this.getData()
    }
    this.setTable()
    this.searchTaskMap = [{ id: "0", type: this.type, title: "重新订购" }]
      this.searchTaskMap = [{ id: '0', type: this.type, title: '重新订购' }]
    this.getLocationList()
  },
  methods: {
@@ -142,16 +109,16 @@
        selectBox: false,
        selectIndex: true,
        tableColumn: [
          { label: "产品", prop: "productName", product: true },
          { label: "位置", prop: "locationName", defaultLocation: true },
          { label: "在库数量", prop: "amount" },
          { label: "预测数量", prop: "prediction" },
          { label: "首选路线", prop: "route", route: true },
          { label: "最小数量", prop: "minInventory", inputFloat: true },
          { label: "最大数量", prop: "maxInventory", inputFloat: true },
          { label: "订购数量", prop: "orderNumber", inputFloat: true },
          { label: "计量单位", prop: "unit" }
        ]
            { label: '产品', prop: 'productName', product: true },
            { label: '位置', prop: 'locationName', defaultLocation: true },
            { label: '在库数量', prop: 'amount' },
            { label: '预测数量', prop: 'prediction' },
            { label: '首选路线', prop: 'route', route: true },
            { label: '最小数量', prop: 'minInventory', inputFloat: true },
            { label: '最大数量', prop: 'maxInventory', inputFloat: true },
            { label: '订购数量', prop: 'orderNumber', inputFloat: true },
            { label: '计量单位', prop: 'unit' },
          ],
      }
    },
    // 请求数据
@@ -162,18 +129,14 @@
        keyWord: data?.jointName,
        page: this.pagerOptions.currPage,
        pageSize: this.pagerOptions.pageSize,
        productId: data?.productId
          productId: data?.productId,
      }).then((res) => {
        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)
              )
                orderNum = this.caculateOrderNumber(parseFloat(item.minInventory), parseFloat(item.maxInventory), parseFloat(item.prediction))
            }
            return {
              ...item,
@@ -184,7 +147,7 @@
              editable: true,
              isOrder: true,
              isView: item?.minInventory - item?.prediction > 0 ? true : false,
              orderNumber: orderNum
                orderNumber: orderNum,
            }
          })
          this.tableList.tableData = list || []
@@ -200,36 +163,28 @@
    // 操作输入
    inputContent(val, prop, row) {
      console.log(row)
      if (prop === "minInventory") {
        if (prop === 'minInventory') {
        this.minInventory = val
        if (parseFloat(this.minInventory) - parseFloat(this.prediction) > 0) {
          this.orderNumber = this.caculateOrderNumber(
            parseFloat(this.minInventory),
            parseFloat(this.maxInventory),
            parseFloat(this.prediction)
          )
            this.orderNumber = this.caculateOrderNumber(parseFloat(this.minInventory), parseFloat(this.maxInventory), parseFloat(this.prediction))
        }
      } else if (prop === "maxInventory") {
        } else if (prop === 'maxInventory') {
        this.maxInventory = val
        if (parseFloat(this.minInventory) - parseFloat(this.prediction) > 0) {
          this.orderNumber = this.caculateOrderNumber(
            parseFloat(this.minInventory),
            parseFloat(this.maxInventory),
            parseFloat(this.prediction)
          )
            this.orderNumber = this.caculateOrderNumber(parseFloat(this.minInventory), parseFloat(this.maxInventory), parseFloat(this.prediction))
        }
      } else if (prop === "orderNumber") {
        } else if (prop === 'orderNumber') {
        this.orderNumber = val
      }
    },
    // 新增
    addProductClick() {
      console.log(this.addTitle, "qqqqqqqqqqqq")
        console.log(this.addTitle, 'qqqqqqqqqqqq')
      this.isSel()
      if (this.isNoProduct && this.addTitle === "新建") {
        if (this.isNoProduct && this.addTitle === '新建') {
        this.$refs.tablelistRef.getProductList()
        this.$refs.tablelistRef.getLocationList()
        this.addTitle = "保存"
          this.addTitle = '保存'
        this.showDiscard = true
        this.isRowClick = false
        this.operationId = 0
@@ -239,7 +194,7 @@
          countId: this.countId,
          amount: 0,
          minInventory: 0,
          productId: "",
            productId: '',
          maxInventory: 0,
          orderNumber: 0,
          prediction: 0,
@@ -248,24 +203,24 @@
          isSet: true,
          isEdit: false,
          editable: false,
          isOrder: true
            isOrder: true,
        })
        this.tableList.tableData = this.tableData
        this.locationId = 0
        this.productId = 0
      } else {
        this.addTitle = "新建"
          this.addTitle = '新建'
        this.showDiscard = false
        let requestUrl = this.currentRowId === 0 ? addReorderRule : updateReorderRule
        let params = this.saveParams()
        if(params.productId===0){
          this.$message.warning("请填写产品信息!")
            this.$message.warning('请填写产品信息!')
        }else{
          requestUrl(params)
          .then((res) => {
            console.log(res)
            if (res.code === 200) {
              let tipStr = this.currentRowId === 0 ? "添加成功" : "修改成功"
                  let tipStr = this.currentRowId === 0 ? '添加成功' : '修改成功'
              this.$message.success(tipStr)
              this.getData()
            }
@@ -290,7 +245,7 @@
        operationId: this.operationId,
        productId: this.productId,
        route: this.route,
        unit: this.unit
          unit: this.unit,
      }
    },
    // 是否选择产品
@@ -307,17 +262,17 @@
    // 取消
    discardBtnClick() {
      this.getData()
      this.addTitle = "新建"
        this.addTitle = '新建'
      this.showDiscard = false
    },
    // 订购一次
    handleOrderOnceClick(row) {
      let params = {
        ...row
          ...row,
      }
      orderAgain(params).then((res) => {
        if (res.code === 200) {
          this.$message.success("订购成功")
            this.$message.success('订购成功')
          this.getData()
        }
      })
@@ -329,10 +284,10 @@
      this.reorderId = row.id
      this.isSel()
      if (!this.isNoProduct && this.currentRowId === 0) {
        this.$message.error("请完成当前新建或取消新建")
          this.$message.error('请完成当前新建或取消新建')
      } else {
        this.currentRowId = row.id
        this.addTitle = "保存"
          this.addTitle = '保存'
        this.showDiscard = true
        this.isRowClick = true
        if (!this.isNoProduct) {
@@ -385,7 +340,7 @@
    },
    //树点击
    handleNodeClick(data) {
      console.log(data, "sss")
        console.log(data, 'sss')
      this.getData(data)
    },
    async getLocationList() {
@@ -393,24 +348,24 @@
        this.datas = [
          {
            id: 0,
            jointName: "全部",
            children: []
              jointName: '全部',
              children: [],
          },
          ...res.data
            ...res.data,
        ]
      })
    },
    // 删除type
    delSelectClick() {
      this.type = ""
        this.type = ''
      this.getData()
    },
    switchKeywords(item) {
      console.log(item, "switchKeywords")
      this.type = item?.length > 0 ? "bh" : ""
        console.log(item, 'switchKeywords')
        this.type = item?.length > 0 ? 'bh' : ''
      this.getData()
    }
  }
      },
    },
}
</script>
@@ -427,9 +382,9 @@
    display: flex;
    justify-content: space-between;
    .con_left {
      max-height: calc(100% - 40px);
      overflow: hidden;
      width: 190px;
        max-height: calc(100% - 90px);
        overflow: auto;
        width: 160px;
      margin-right: 10px;
      .el-checkbox-group {
        width: 100%;
@@ -449,11 +404,20 @@
    }
  }
  .span-ellipsis {
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
      // overflow: auto;
      // white-space: nowrap;
      // text-overflow: ellipsis;
    font-size: 13px;
      padding: 0px 10px;
    }
  }
  ::v-deep {
    .el-tree-node > .el-tree-node__children {
      overflow: visible !important;
    }
    .el-tree-node__content:hover, .el-upload-list__item:hover {
    width: 100%;
  }
}
</style>