yangfeng
2024-03-28 99cce1342e08baf832edd0e92c941cb64669af5e
src/views/overview/OverviewListView.vue
@@ -1,33 +1,83 @@
<template>
  <div class="rightContent">
    <!-- <div class="label-fixed-element">
      <span>{{ params.name }}</span>
    </div> -->
    <div class="top">
      <SearchCommonView
        :add-title="'新建'"
        :placeholder="'请输入单号/来源单据'"
        :amount-view="false"
        :search-task-map="searchTaskMap"
        @addCommonClick="addBtnClick"
        @searchClick="getList"
        @delSelectClick="delSelectClick"
      />
    </div>
    <div class="list-view">
      <div class="table">
        <TableCommonView
          ref="tableListRef"
          :table-list="tableList"
          @selTableCol="selTableCol"
          @tableRowClick="tableRowClick"
        ></TableCommonView>
    <div class="body">
      <!-- <div class="body-card"> -->
      <div class="content-top">
        <div class="list-view">
          <TableCommonView
            ref="tableListRef"
            :table-list="tableList"
            @selTableCol="selTableCol"
            @tableRowClick="tableRowClick"
            :selectClassRow="selectRow"
          >
            <template slot="tableButton">
              <el-table-column label="操作" width="100">
                <template slot-scope="scope">
                  <el-button @click="viewEditClick(scope.row, '查看')" type="text" size="small">查看</el-button>
                  <el-button
                    v-if="scope.row.status !== 4 && scope.row.status !== 5"
                    @click="viewEditClick(scope.row, '编辑')"
                    type="text"
                    size="small"
                    >编辑</el-button
                  >
                </template>
              </el-table-column>
            </template>
          </TableCommonView>
          <div class="btn-pager">
            <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
          </div>
        </div>
      </div>
      <div class="btn-pager">
        <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
      <div class="content-bottom">
        <div class="bottom-tabs">
          <div
            class="tab-pane"
            @click="getTab(0)"
            :style="{
              background: TabsIndex == 0 ? '#2a78fb' : '#F1F3F8',
              color: TabsIndex == 0 ? '#fff' : '#666'
            }"
          >
            产品信息
          </div>
        </div>
        <div class="list-view">
          <TableCommonView :table-list="productTableList" @selTableCol="selBottomTableCol">
            <!-- <template slot="tableButton">
              <el-table-column label="操作" width="160" fixed="right">
                <template slot-scope="scope">
                  <el-button @click="viewClick(scope.row)" type="text" size="small">查看</el-button>
                </template>
              </el-table-column>
            </template> -->
          </TableCommonView>
        </div>
      </div>
    </div>
    <!-- 新建/编辑 -->
    <AddOverviewDialog
      v-if="editConfig.visible"
      :work-type="workType"
      :workType="workType"
      :edit-common-config="editConfig"
      :add-name="this.$route.params.name"
      :add-name="addName"
      :display-edit="displayEdit"
    />
  </div>
</template>
@@ -47,7 +97,7 @@
  data() {
    return {
      tableList: {},
      showcol: ["从", "至", "联系人", "日期", "来源单据", "状态"],
      showcol: ["仓库位置", "调出位置", "调入位置", "联系人", "日期", "来源", "来源单据", "销售明细单", "状态"],
      searchOptions: [],
      commonDetail: {
        visible: false,
@@ -61,10 +111,40 @@
      },
      workType: this.$route.params.workType,
      keyword: "",
      params: {}
      params: {},
      displayEdit: false,
      formLabel: "",
      toLabel: "",
      addName: "",
      searchTaskMap: [],
      numberLabel: "单号",
      TabsIndex: "0",
      productTableList: {},
      showBottomCol: ["产品编号", "产品名称", "产品规格", "产品型号", "计量单位", "调出位置", "调入位置", "数量"],
      tableBottomColumn: [],
      selectRow: {},
      productColumn: [
        { label: "产品编号", prop: "id", default: true },
        { label: "产品名称", prop: "productName" },
        { label: "产品规格", prop: "specs" },
        { label: "产品型号", prop: "model" },
        { label: "计量单位", prop: "unit" },
        { label: "数量", prop: "amount" }
      ],
      allotProductColumn: [
        { label: "产品编号", prop: "id", default: true },
        { label: "产品名称", prop: "productName" },
        { label: "产品规格", prop: "specs" },
        { label: "产品型号", prop: "model" },
        { label: "计量单位", prop: "unit" },
        { label: "调出位置", prop: "location" },
        { label: "调入位置", prop: "toLocation" },
        { label: "数量", prop: "amount" }
      ]
    }
  },
  created() {
    this.setFormToLabel()
    this.setTable()
    var paramsData = sessionStorage.getItem("paramsData")
    let params = {}
@@ -75,6 +155,8 @@
      sessionStorage.setItem("paramsData", JSON.stringify(params))
    }
    this.params = params
    this.searchTaskMap =
      this.params.status > 0 ? [{ id: this.params.id, title: this.getStatus(this.params.status) }] : []
    this.getData()
    // console.log(this.$route.params.workType)
  },
@@ -83,10 +165,26 @@
    sessionStorage.removeItem("paramsData")
  },
  methods: {
    setFormToLabel() {
      if (this.workType === 1) {
        this.formLabel = "供应商位置"
        this.toLabel = "仓库位置"
        this.numberLabel = "入库单号"
      } else if (this.workType === 2) {
        this.formLabel = "仓库位置"
        this.toLabel = "客户位置"
        this.numberLabel = "出库单号"
      } else {
        this.formLabel = "调出位置"
        this.toLabel = "调入位置"
        this.numberLabel = "调拨单号"
      }
    },
    setTable() {
      this.tableList = {
        tableInfomation: [],
        selectBox: true,
        selectBox: false,
        selectIndex: true,
        showcol: this.showcol,
        allcol: [],
        tableColumn: this.setTableColumn(this.showcol)
@@ -99,25 +197,27 @@
        }
      }
      this.tableList.allcol = allcol
      this.tableBottomColumn = this.workType == 3 ? this.allotProductColumn : this.productColumn
      this.setBottomList()
    },
    setTableColumn(showcol) {
      let tableColumn = [
        {
          label: "单号",
          label: this.numberLabel,
          prop: "number",
          isShowColumn: true,
          default: true
        },
        {
          label: "从",
          label: this.formLabel,
          prop: "from",
          isShowColumn: showcol.includes("从"),
          isShowColumn: showcol.includes(this.formLabel),
          default: false
        },
        {
          label: "至",
          label: this.toLabel,
          prop: "to",
          isShowColumn: showcol.includes("至"),
          isShowColumn: showcol.includes(this.toLabel),
          default: false
        },
        {
@@ -139,12 +239,12 @@
          default: false,
          date: true
        },
        // {
        //   label: "产品可用性",
        //   prop: "status",
        //   isShowColumn: showcol.includes("产品可用性"),
        //   default: false
        // },
        {
          label: "来源",
          prop: "sourceType",
          isShowColumn: showcol.includes("来源"),
          default: false
        },
        // {
        //   label: "截止日期",
        //   prop: "faultTime",
@@ -163,12 +263,12 @@
          isShowColumn: showcol.includes("来源单据"),
          default: false
        },
        // {
        //   label: "欠单",
        //   prop: "status",
        //   isShowColumn: showcol.includes("欠单"),
        //   default: false
        // },
        {
          label: "销售明细单",
          prop: "salesDetailsNumber",
          isShowColumn: showcol.includes("销售明细单"),
          default: false
        },
        {
          label: "入库类型",
          prop: "operationTypeName",
@@ -196,23 +296,47 @@
    async getData() {
      await getOperation({
        number: this.keyword,
        operationTypeId: this.params.id,
        operationTypeId: this.$route.params.id ? this.$route.params.id : this.params.id,
        page: this.pagerOptions.currPage,
        pageSize: this.pagerOptions.pageSize
        pageSize: this.pagerOptions.pageSize,
        status: this.params.status
      }).then((res) => {
        console.log(res.data)
        if (res.code === 200) {
          const list = res.data.map((item) => {
            return {
              ...item,
              from: item.fromLocation.name,
              to: item.toLocation.name
              from: item.location.jointName,
              to: item.location.jointName
            }
          })
          this.tableList.tableInfomation = list || []
          this.pagerOptions.totalCount = res.total
          if (res.total > 0) {
            this.selectRow = this.tableList.tableInfomation.length > 0 ? this.tableList.tableInfomation[0] : {}
            this.tableRowClick(this.selectRow)
            this.bottomProductData(this.selectRow)
          }
        }
      })
    },
    // bottom产品信息数据处理
    bottomProductData(arr) {
      const list = arr.details.map((item) => {
        return {
          ...item,
          productName: item.product.name,
          unit: item.product.unit,
          location: arr.location.name,
          toLocation: arr.toLocation.name
        }
      })
      this.productTableList.tableInfomation = list
    },
    // top 行点击
    tableRowClick(row) {
      this.selectRow = row
      this.bottomProductData(this.selectRow)
    },
    // 搜索
    getList(val) {
@@ -221,28 +345,180 @@
      this.pagerOptions.currPage = 1
      this.getData()
    },
    // 行点击
    tableRowClick(row) {
      console.log(row)
    // 查看 编辑
    viewEditClick(row, val) {
      this.editConfig.visible = true
      this.editConfig.title = "编辑"
      this.editConfig.operationTypeId = this.$route.params.id
      this.editConfig.title = val
      this.editConfig.operationTypeId = this.params.id
      this.editConfig.code = this.params.code
      row.details.map((item) => {
        item.fromLocationId = item.fromLocation.jointName
        item.toLocationId = item.toLocation.jointName
      })
      row.location = {
        value: row.location.id || row.location.value,
        label: row.location.jointName || row.location.label
      }
      row.toLocation = {
        value: row.toLocation.id || row.toLocation.value,
        label: row.toLocation.jointName || row.toLocation.label
      }
      row.locationID = row.location.jointName
      row.locationId = row.location.value
      // row.tolocationId=row.tolocation.value
      this.editConfig.infomation = { ...row }
    },
    // 新建
    addBtnClick() {
      this.editConfig.visible = true
      this.editConfig.title = "新建"
      this.editConfig.operationTypeId = this.$route.params.id
      this.editConfig.infomation = {}
      this.addName = this.params.name
      this.editConfig.operationTypeId = this.params.id
      this.editConfig.code = this.params.code
      this.editConfig.infomation = {
        // location:{jointName:""}
      }
      this.editConfig.visible = true
    },
    // 状态
    getStatus(val) {
      return val === 1 ? "草稿" : val === 3 ? "就绪" : "完成"
      return val === 1 ? "草稿" : val === 3 ? "就绪" : val === 4 ? "完成" : val === 5 ? "取消" : ""
    },
    // 删除搜索状态
    delSelectClick() {
      this.params.status = 0
      this.getData()
    },
    // bottom 产品信息
    // bom 列表
    setBottomList() {
      this.productTableList = {
        selectIndex: true,
        tableInfomation: [],
        allcol: [],
        showcol: this.showBottomCol,
        tableColumn: this.setColumnVisible(this.showBottomCol, this.tableBottomColumn)
      }
      this.setTableList(this.productTableList)
    },
    setTableList(tableList) {
      tableList.allcol = tableList.tableColumn.filter((ele) => !ele.default).map((ele) => ele.label)
      // this.searchOptions = []
      // for (let i = 0; i < tableList.tableColumn.length; i++) {
      //   const label = tableList.tableColumn[i].label
      //   const value = tableList.tableColumn[i].prop
      //   this.searchOptions.push({ value: value, label: label })
      // }
    },
    setColumnVisible(showCol, tableColumn) {
      return tableColumn.map((ele) => {
        return {
          ...ele,
          isShowColumn: showCol.includes(ele.label)
        }
      })
    },
    selBottomTableCol(val) {
      this.showBottomCol = val
      this.productTableList.tableColumn = this.setColumnVisible(val, this.tableBottomColumn)
    },
    getTab(tab) {
      this.TabsIndex = tab
      // if (this.TabsIndex == 0) {
      //   // 产品信息列表
      //   this.setBottomList()
      //   this.getProductInventoryInfo(this.selectRow)
      // }
    }
  }
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped></style>
<style lang="scss" scoped>
.rightContent {
  height: 100%;
  overflow: hidden;
  .body {
    box-sizing: border-box;
    padding: 10px 20px;
    border-radius: 12px;
    height: calc(100% - 70px);
    .content-top {
      background-color: #fff;
      border-radius: 12px;
      min-height: 70px;
      height: 48%;
      position: relative;
      .list-view {
        height: calc(100% - 50px);
      }
    }
    .content-bottom {
      .bottom-tabs {
        height: 40px;
        line-height: 40px;
        background: #e6ecf2;
        display: flex;
        .tab-pane {
          width: 100px;
          margin-right: 20px;
          font-size: 14px !important;
          text-align: center;
          cursor: pointer;
          background: #2a78fb;
          border-top-left-radius: 20px;
          border-top-right-radius: 20px;
        }
      }
      .lable-view {
        background: #e6ecf2;
        height: 40px;
        line-height: 40px;
        .name {
          border-left: 4px solid #2a78fb;
          padding-left: 10px;
        }
      }
      background-color: #fff;
      border-radius: 12px;
      min-height: 70px;
      height: calc(52% - 60px);
      margin-top: 10px;
      // padding: 10px 20px;
      .list-view {
        height: calc(100% - 10px);
      }
    }
    .btn-pager {
      display: flex;
      margin-top: 0px;
      .page {
        margin-left: auto;
      }
    }
  }
}
.label-fixed-element {
  background: #e6ecf2;
  position: fixed;
  font-size: 14px;
  width: calc(100% - 530px);
  height: 45px;
  line-height: 45px;
  font-size: 18px;
  font-weight: 700;
  color: #171718;
  margin-top: -60px;
  margin-left: -5px;
}
::v-deep {
  .el-table__header-wrapper {
    position: sticky;
    width: 100%;
    //  left:0px;
    top: 0px;
    z-index: 2000;
  }
}
</style>