charles
2024-08-06 5ecb7958c96d3f0b6d47b79aff7eb306c2cf690f
src/views/operate/inventoryAdjustment/index.vue
@@ -1,169 +1,613 @@
<template>
  <div class="rightContent">
    <div class="label-fixed-element">
      <span>库存调整</span>
    </div>
    <div class="top">
      <SearchCommonView
        :add-title="'新建'"
        :placeholder="'请输入单号'"
        :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"
          :show-checkcol="false"
          @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">
                <template slot-scope="scope">
                  <span>{{scope.row.moreUnitList.map(item=>item.amount).join('/')}}</span>
                </template>
              </el-table-column>
              <el-table-column label="辅助单位" width="160">
                <template slot-scope="scope">
                  <span>{{scope.row.moreUnitList.map(item=>item.unit).join('/')}}</span>
                </template>
              </el-table-column>
            </template>
          </TableCommonView>
        </div>
      </div>
    </div>
    <!-- 新建/编辑 -->
    <AddDialog
    <AddOverviewDialog
      v-if="editConfig.visible"
      @refresh="refresh"
      :positionList="tableList.tableInfomation"
      :workType="workType"
      :edit-common-config="editConfig"
    />
      :add-name="addName"
      :display-edit="displayEdit"/>
  </div>
</template>
<script>
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import { getLocationList } from "@/api/warehouseManage/warehouse"
import AddDialog from "@/views/warehouseManage/position/AddDialog"
import { getDataByType } from "@/api/data"
import { getOperation } from "@/api/overview/overview"
import AddOverviewDialog from "@/views/overview/AddOverviewDialog"
import Cookies from 'js-cookie'
export default {
  name: "InventoryAdjustment",
  name: "OverviewListView",
  props: {},
  components: { AddDialog },
  components: { AddOverviewDialog },
  mixins: [pageMixin],
  computed: {},
  data() {
    return {
      tableList: {},
      showcol: ["仓库位置", "来源","来源单据","调出位置", "调入位置", "联系人", "日期",   "销售明细单", "状态" ,"主管","会计","保管员",],
      searchOptions: [],
      commonDetail: {
        visible: false,
        title: "新建",
        infomation: {}
      },
      editConfig: {
        visible: false,
        title: "新建",
        infomation: {}
      },
      positionTypeList: getDataByType("positionType")
      workType: parseInt(this.$route.query.workType),
      keyword: "",
      params: {},
      displayEdit: false,
      formLabel: "",
      toLabel: "",
      addName: "库存盘点",
      searchTaskMap: [],
      numberLabel: "单号",
      TabsIndex: "0",
      productTableList: {},
      showBottomCol: ["产品编号", "产品名称", "产品规格", "产品型号", "计量单位","盘点位置", "调出位置", "调入位置", "盘点数量","库存数量","主管","会计","保管员",'辅助数量','辅助单位','毛重','总毛重','净重','总净重'],
      tableBottomColumn: [],
      selectRow: {},
      productColumn: [
        { label: "产品编号", prop: "productId", default: true },
        { label: "产品名称", prop: "productName" },
        { label: "产品规格", prop: "specs" },
        { label: "产品型号", prop: "model" },
          { label: "盘点位置", prop: "location" },
        { label: "盘点数量", prop: "amount" },
         { label: "库存数量", prop: "stockAmount" },
        { label: "计量单位", prop: "unit" },
       /* { label: "辅助数量", prop: "adjunctAmount" },
        { label: "辅助单位", prop: "adjunctUnit" },*/
        { label: "毛重", prop: "grossWeight" },
        { label: "总毛重", prop: "totalGrossWeight" },
        { label: "净重", prop: "netWeight" },
        { label: "总净重", prop: "totalNetWeight" }
      ],
      allotProductColumn: [
        { label: "产品编号", prop: "productId", default: true },
        { label: "产品名称", prop: "productName" },
        { label: "产品规格", prop: "specs" },
        { label: "产品型号", prop: "model" },
        { label: "计量单位", prop: "unit" },
        { label: "调出位置", prop: "location" },
        { label: "调入位置", prop: "toLocation" },
        { label: "数量", prop: "amount" },
        /*{ label: "辅助数量", prop: "adjunctAmount" },
        { label: "辅助单位", prop: "adjunctUnit" },*/
        { label: "毛重", prop: "grossWeight" },
        { label: "总毛重", prop: "totalGrossWeight" },
        { label: "净重", prop: "netWeight" },
        { label: "总净重", prop: "totalNetWeight" }
      ]
    }
  },
  created() {
    this.setFormToLabel()
    this.setTable()
    this.getData()
    var paramsData = sessionStorage.getItem("paramsData")
    let params = {}
    if (paramsData) {
      params = JSON.parse(sessionStorage.getItem("paramsData"))
    } else {
      params = this.$route.query
      params.id=Number(params.id)
      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();
  },
  // 页面销毁之前
  beforeDestroy() {
    sessionStorage.removeItem("paramsData");
  },
  methods: {
    setFormToLabel() {
        this.showcol=["仓库位置", "仓库","调出位置", "调入位置", "联系人","日期","创建人" ,"创建时间","验证人","验证时间",  "销售明细单", "状态","主管","会计","保管员"];
        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)
      }
      let allcol = []
      };
      let allcol = [];
      for (let i = 0; i < this.tableList.tableColumn.length; i++) {
        if (!this.tableList.tableColumn[i].default) {
          const label = this.tableList.tableColumn[i].label
          const label = this.tableList.tableColumn[i].label;
          allcol.push(label)
        }
      }
      this.tableList.allcol = allcol
      this.tableBottomColumn = this.workType == 3 ? this.allotProductColumn : this.productColumn
      this.setBottomList()
    },
    setTableColumn(showcol) {
      console.log(showcol)
      let tableColumn = [
        {
          label: "位置",
          prop: "jointName",
          label: this.numberLabel,
          prop: "number",
          isShowColumn: true,
          default: true
        },
        {
          label: "位置类型",
          prop: "type",
          isShowColumn: true,
          default: true,
          conversion: true,
          getStatus: this.getTypesList
        }
      ]
          label: "来源",
          prop: "operationSource",
          isShowColumn: showcol.includes("来源"),
          default: false,
          // status: true,
          isCallMethod: true,
          getCallMethod: this.getSourceStatus
        },
        {
          label: "来源单据",
          prop: "sourceNumber",
          isShowColumn: showcol.includes("来源单据"),
          default: false
        },
          {
              label: "仓库",
              prop: "warehouseName",
              isShowColumn: showcol.includes("仓库"),
              default: false
          },
        /*{
          label: this.formLabel,
          prop: "from",
          isShowColumn: showcol.includes(this.formLabel),
          default: false
        },
        {
          label: this.toLabel,
          prop: "to",
          isShowColumn: showcol.includes(this.toLabel),
          default: false
        },*/
        {
          label: "联系人",
          prop: "companyName",
          isShowColumn: showcol.includes("联系人"),
          default: false
        },
        {
          label: "负责人",
          prop: "contacterName",
          isShowColumn: showcol.includes("负责人"),
          default: false
        },
        {
          label: "日期",
          prop: "operationDate",
          isShowColumn: showcol.includes("日期"),
          default: false,
          date: true
        },
          {
              label: "创建人",
              prop: "createBy",
              isShowColumn: showcol.includes("创建人"),
              default: false,
          },
          {
              label: "创建时间",
              prop: "createTime",
              isShowColumn: showcol.includes("创建时间"),
              default: false,
              date: true
          },
          {
              label: "验证人",
              prop: "checkedBy",
              isShowColumn: showcol.includes("验证人"),
              default: false,
          },
          {
              label: "验证时间",
              prop: "auditDate",
              isShowColumn: showcol.includes("验证时间"),
              default: false,
              date: true
          },
        // {
        //   label: "截止日期",
        //   prop: "faultTime",
        //   isShowColumn: showcol.includes("截止日期"),
        //   default: false
        // },
        // {
        //   label: "实际日期",
        //   prop: "shopName",
        //   isShowColumn: showcol.includes("实际日期"),
        //   default: false
        // },
        {
          label: "销售明细单",
          prop: "salesDetailsNumber",
          isShowColumn: showcol.includes("销售明细单"),
          default: false
        },
        {
          label: "入库类型",
          prop: "operationTypeName",
          isShowColumn: showcol.includes("入库类型"),
          default: false
        },
        {
          label: "状态",
          prop: "status",
          width: 120,
          isShowColumn: showcol.includes("状态"),
          default: false,
          status: true,
          isCallMethod: true,
          getCallMethod: this.getStatus
        },
        {
          label: "主管",
          prop: "manager",
          isShowColumn: showcol.includes("主管"),
          default: false
        },
        {
          label: "会计",
          prop: "accountant",
          isShowColumn: showcol.includes("会计"),
          default: false
        },
        {
          label: "保管员",
          prop: "custodian",
          isShowColumn: showcol.includes("保管员"),
          default: false
        },
      ];
      return tableColumn
    },
    getTypesList(val) {
      let string = "--"
      if (val) {
        for (let i in this.positionTypeList) {
          if (this.positionTypeList[i].id == val) {
            return this.positionTypeList[i].name
          }
        }
      }
      return string
    },
    selTableCol(val) {
      this.showcol = val
      this.tableList.tableColumn = this.setTableColumn(val)
      this.showcol = val;
      this.tableList.tableColumn = this.setTableColumn(val);
    },
    // 请求数据
    async getData() {
      await getLocationList({
        keyword: this.keyword,
      await getOperation({
        number: this.keyword,
        baseOperationType:5,
        page: this.pagerOptions.currPage,
        pageSize: this.pagerOptions.pageSize
        pageSize: this.pagerOptions.pageSize,
        status: this.params.status
      }).then((res) => {
        if (res.code === 200) {
          const list = res.data ? res.data : []
          this.tableList.tableInfomation = list
          const list = res.data.map((item) => {
            return {
              ...item,
              from: item.location.jointName,
              to: item.toLocation.jointName,
              operationDate:this.$moment(item.operationDate).format('yyyy-MM-DD'),
              warehouseName:item.warehouse?item.warehouse.name:''
            }
          });
          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)
          }
        }
      })
    },
    refresh() {
      this.pagerOptions.currPage = 1
      this.getData()
    // bottom产品信息数据处理
    bottomProductData(arr) {
        const list = arr.details.map((item) => {
          const params={
              ...item,
              productName: item.product.name,
              unit: item.product.unit,
              model:item.product.model,
              specs:item.product.specs,
              adjunctUnit:item.auxiliaryUnit,
              adjunctAmount:item.auxiliaryAmount,
              grossWeight:item.product.grossWeight==0?'':item.product.grossWeight,
              totalGrossWeight:item.totalGrossWeight==0?'':item.totalGrossWeight,
              netWeight:item.product.netWeight==0?'':item.product.netWeight,
              totalNetWeight:item.totalNetWeight==0?'':item.totalNetWeight,
          }
          params.location=item.fromLocation.name;
          return  params;
      });
      this.productTableList.tableInfomation = list
    },
    // top 行点击
    tableRowClick(row) {
      this.selectRow = row
      this.bottomProductData(this.selectRow)
    },
    // 搜索
    getList(val) {
      console.log(val)
      this.keyword = val
      this.pagerOptions.currPage = 1
      this.getData()
    },
    // 行点击
    tableRowClick(row) {
      console.log(row)
      this.editConfig.title = "编辑"
      this.editConfig.infomation = { ...row }
      this.editConfig.infomation.parentId = Number(this.editConfig.infomation.parentId)
    // 查看 编辑
    viewEditClick(row, val) {
      const row1=JSON.parse(JSON.stringify(row));
      this.editConfig.visible = true
      this.editConfig.title = val
      this.editConfig.operationTypeId = this.params.id
      this.editConfig.code = this.params.code
      row1.details.map((item) => {
        item.fromLocationId = item.fromLocation.jointName
        item.toLocationId = item.toLocation.jointName
        item.relAmount=item.amount;
        item.amount=item.stockAmount;
      });
      row1.location = {
          ...row1.location,
        value: row1.location.id || row1.location.value,
        label: row1.location.jointName || row1.location.label
      }
      row1.toLocation = {
          ...row1.toLocation,
        value: row1.toLocation.id || row1.toLocation.value,
        label: row1.toLocation.jointName || row1.toLocation.label
      }
      row1.locationID = row1.location.jointName
      row1.locationId = row1.location.value
      row1.managerObj={
        label:row1.manager,
        value:row1.managerId
      }
      row1.accountantObj={
        label:row1.accountant,
        value:row1.accountantId
      }
      row1.custodianObj={
        label:row1.custodian,
        value:row1.custodianId
      }
      this.editConfig.infomation = { ...row1 }
    },
    // 新建
    addBtnClick() {
      this.editConfig.title = "新建"
      //this.addName = this.params.name
      this.editConfig.operationTypeId = this.params.id
      this.editConfig.code = this.params.code
      this.editConfig.infomation = {
        name: "",
        parentId: null,
        type: 3,
        isScrapLocation: null,
        isReturnLocation: null,
        replenishLocation: null,
        countFrequency: 0,
        recentlyCount: "",
        nextCount: "",
        notes: ""
        // location:{jointName:""}
          operationDate:new Date()
      }
      this.editConfig.visible = true
      this.editConfig.title = "新建"
    },
    // 状态
    getStatus(val) {
      return val === 1 ? "草稿" : val === 3 ? "就绪" : val === 4 ? "完成" : val === 5 ? "取消" : ""
    },
    // 来源
    getSourceStatus(val){
      return val===0 ? '--':val === 1 ? "采购入库" : val === 2 ? "生产入库" : val === 3 ? "委外入库" : val === 4 ? "生产领料" : val=== 5 ? "委外领料": val === 6?"销售发货": "--"
    },
    // 删除搜索状态
    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 0px;
    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 {
  position: fixed;
  background:#f8f8f9;
  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>