wangyi
2026-01-19 7fb0a8f0ab16c149484bf043754cd10cfa94de2f
src/views/gyStockPlace/edit/index.vue
New file
@@ -0,0 +1,486 @@
<template>
  <div v-loading="formLoading" v-if="formShow">
    <div style="margin-bottom: 10px; border-bottom: 1px solid #f6f6f6">
      <el-button type="primary" @click="submitForm" :disabled="subDisabled"
        >保 存</el-button
      >
      <el-button type="primary" @click="close">退 出</el-button>
    </div>
    <el-form ref="form" :model="form" :rules="rules" label-width="110px">
      <el-tabs v-model="activeName" type="card">
        <el-tab-pane label="基本信息" name="first">
          <el-row>
            <el-col :span="8">
              <el-form-item label="仓位代码" prop="HNumber">
                <el-input v-model="form.HNumber" placeholder="请输入仓库代码" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="仓位名称" prop="HName">
                <el-input v-model="form.HName" placeholder="请输入仓库名称" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="所属仓位" prop="HSPGroupName" class="form-inline">
                <el-input disabled v-model="form.HSPGroupName" placeholder="请选择仓位">
                </el-input>
                <el-button icon="el-icon-search" @click="openDataDialog(1)"></el-button>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="使用组织" prop="HUSEORGID">
                <el-select
                  v-model="form.HUSEORGID"
                  placeholder="请选择组织"
                  :disabled="zzSelDis"
                >
                  <el-option
                    v-for="(item, index) in organizationList"
                    :key="index"
                    :label="item.Name"
                    :value="item.ID"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="助记码" prop="HHelpCode">
                <el-input v-model="form.HAddress" placeholder="请输入助记码" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="备注" prop="HRemark">
                <el-input v-model="form.HPhone" placeholder="请输入备注" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="默认仓位" prop="HStandard">
                <el-checkbox v-model="form.HStandard">是否默认</el-checkbox>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="禁用标志" prop="HStopflag">
                <el-checkbox v-model="form.HStopflag" disabled>是否禁用</el-checkbox>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row> </el-row>
        </el-tab-pane>
      </el-tabs>
    </el-form>
    <!-- 部门弹窗 -->
    <el-dialog
      :title="dialogTitle"
      :visible.sync="openData"
      width="1280px"
      append-to-body
    >
      <Dept @deptEmitDb="dbEmitData" @deptEmit="emitData" v-if="deptShow" />
      <Warehouse @deptEmitDb="dbEmitData" @deptEmit="emitData" v-if="warehouseShow" />
      <Material @deptEmitDb="dbEmitData" @deptEmit="emitData" v-if="materialShow" />
      <GyWorkCenter @deptEmitDb="dbEmitData" @deptEmit="emitData" v-if="workCenterShow" />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="deptClickSub">确 定</el-button>
        <el-button @click="deptClose">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import axios from "axios";
import Dept from "@/views/component/dept";
import Warehouse from "@/views/component/warehouse";
import Material from "@/views/component/material";
import RowSettings from "@/views/component/rowSettings";
import GyWorkCenter from "@/views/component/gyWorkCenter";
import Employee from "@/views/component/employee";
import moment from "moment";
import dayjs from "dayjs";
export default {
  name: "gyWarehouse_Edit",
  components: { Dept, Warehouse, Material, RowSettings, GyWorkCenter, Employee },
  props: {
    OperationType: { type: Number },
    linterid: { type: Number },
    HSouceBillType: { type: String },
    copyType: { type: Number },
  },
  data() {
    return {
      formShow: false,
      temp: undefined,
      formLoading: true,
      zzSelDis: false,
      rowHideShow: false,
      openRowHide: false,
      workCenterShow: false,
      sWhere: "",
      sTime: "",
      eTime: "",
      zbIndex: null,
      dialogTypeNum: null, //部门弹窗1,仓库弹窗2
      deptShow: false, //部门数据组件
      warehouseShow: false, //仓库数据组件
      materialShow: false, //物料数据组件
      employeeShow: false, // 仓库管理员组件
      deptform: {}, //弹窗选中数据
      openData: false, //数据弹窗
      dialogTitle: "",
      zuzhiId: 0,
      organizationList: [], //组织列表
      subDisabled: false, //编辑页面保存按钮是否禁用(true禁用,false可用)
      CheckBillDisabled: true,
      // OperationType: this.$route.query.OperationType,//保存类型(新增1修改3)
      HInterID: null,
      baseURL: process.env.VUE_APP_BASE_API || "http://47.96.97.237/API/",
      user: "admin",
      currentRow: [],
      lastSelectedRowIndex: null, // 用于记录上次点击的行索引
      lastSelectedRow: null, // 上一次选中的行
      selectedRow: null, // 当前选中的行
      rowForm: {},
      checkedSysZb: [],
      editData: [], //子表
      editBtData: [], //子表表头
      activeName: "first",
      searchOpen: false,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 显示搜索条件
      showSearch: true,
      // 选中数组
      ids: [],
      // 表单参数
      form: {
        HWarehouseType: "生产仓库",
      },
      // 表单校验
      rules: {
        HNumber: [{ required: true, message: "仓库代码不能为空", trigger: "blur" }],
        HName: [{ required: true, message: "仓库名称名称不能为空", trigger: "blur" }],
        HWarehouseType: [
          { required: true, message: "仓库类型不能为空", trigger: "blur" },
        ],
      },
      HWarehouseTypeList: [
        {
          Name: "生产仓库",
        },
        {
          Name: "模具仓库",
        },
      ],
    };
  },
  created() {
    this.reset();
    this.fetchData();
  },
  activated() {
    this.reset();
    this.fetchData();
  },
  methods: {
    fetchData() {
      //登录用户信息
      axios
        .get(
          "http://47.96.97.237/API/Web/GetUser?UserName=001&PassWord=123456&HOrgName=100038"
        )
        .then((response) => {
          let data = response.data.data[0];
          this.zuzhiId = data.HUSEORGID; //根据登录用户获取默认的组织ID
          this.user = data.Czymc;
          axios
            .get(this.$baseUrl + "/Web/GetOrganizations", {})
            .then((response) => {
              if (response.data.count == 1) {
                this.organizationList = response.data.data; //组织列表
                this.getdata();
              }
            })
            .catch((error) => {
              this.$modal.msgError("接口请求失败!");
            });
        })
        .catch((error) => {
          this.$modal.msgError("接口请求失败!");
        });
    },
    getdata() {
      this.reset();
      console.log(this.OperationType);
      if (this.OperationType != 1) {
        this.zzSelDis = true;
        axios
          .get(this.$baseUrl + "/Gy_StockPlace/cx", {
            params: {
              HInterID: this.linterid,
            },
          })
          .then((response) => {
            console.log(response);
            let result = response.data;
            if (result.code == 1) {
              // 说明验证成功了,
              var data = result.data[0];
              Object.assign(this.form, {
                HItemID: data.HMainID,
                HNumber: data.仓位代码,
                HName: data.仓位名称,
                HHelpCode: data.助记码,
                HRemark: data.备注,
                HSPGroupID: data.HSPGroupID,
                HSPGroupName: data.所属仓位,
                HStopflag: data.禁用标记 == "Y" ? true : false,
                HStandard: data.默认仓位 == "Y" ? true : false,
              });
              if (!data.HCheckEmp) {
                this.CheckBillDisabled = false;
              }
            }
            this.$nextTick(() => {
              this.formShow = true;
              this.formLoading = false;
            });
          })
          .catch((error) => {
            this.$modal.msgError("接口请求失败!");
          });
      } else if (this.OperationType == 1) {
        let date = new Date();
        this.form.HMakeDate = moment(date).format("YYYY-MM-DDTHH:mm:ss");
        this.$nextTick(() => {
          this.formShow = true;
          this.formLoading = false;
        });
      }
    },
    handleRowHide() {
      this.rowHideShow = true;
      this.openRowHide = true;
    },
    rowSetClose(val) {
      this.rowHideShow = false;
      this.openRowHide = val;
    },
    organizationChange(val) {
      // let options=undefined
      //  this.form=this.organizationList.find(option => option.ID === val)?.Name || '';
    },
    //弹窗赋值
    dbEmitData(deptRow, num) {
      console.log(deptRow, num);
      // num=1 仓库
      if (num == 2) {
        Object.assign(this.form, {
          HSPGroupName: deptRow.仓库名称,
          HSPGroupID: deptRow.HItemID,
          HSPGroupNumber: deptRow.仓库代码,
        });
        this.openData = false;
      }
    },
    emitData(deptRow, num) {
      this.dialogTypeNum = num;
      this.deptform = deptRow;
    },
    deptClickSub() {
      this.dbEmitData(this.deptform, this.dialogTypeNum);
      this.deptform = {};
    },
    deptClose() {
      this.deptform = {};
      this.openData = false;
    },
    //新增编辑表单初始化
    reset() {
      this.form = {
        HNumber: null,
        HItemID: 0,
        HName: null,
        HHelpCode: null,
        HWorkTimes: "0",
        HMaxWorkTimes: "0",
        HRelationID: "0",
        HMinAdd: "0",
        HClassCount: "0",
        HOverTimes: "0",
        HCenter: null,
        HCenterID: null,
        HGroup: null,
        HGroupID: 0,
        HDeptName: null,
        HDeptID: 0,
        HProcName: null,
        HProcID: 0,
        HProcNumber: null,
        HStopflag: false,
        HType: null,
        HRemark: null,
        HUseFlag: "未检测",
        HUSEORGID: this.zuzhiId,
        HCREATEORGID: this.zuzhiId,
        HMacAddr: null,
        HEmpID: 0,
        HEmpName: null,
        HMakeEmp: this.user,
        HMakeTime: null,
        HStopEmp: null,
        HStopTime: null,
        HCheckEmp: null,
        HCheckTime: null,
        HPrimarySourceID: 0,
        HPrimarySourceName: null,
        HParentID: 0,
        HCubicleQty: "1",
        HProdLinePeopleNum: "0",
      };
      this.editData = [];
      this.editBtData = [];
      this.ids = [];
      this.formShow = false;
      this.subDisabled = false;
      this.formLoading = true;
      this.CheckBillDisabled = true;
      this.activeName = "first";
      this.resetForm("form");
    },
    //退出
    close() {
      this.reset();
      this.formShow = false;
      // console.log()
      this.$emit("editCloseGy", 0);
    },
    // 编辑提交保存
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          let fhck = false;
          this.$nextTick(() => {
            if (!fhck) {
              console.log(4);
              var sMainStr = JSON.stringify(this.form);
              // var sSubStr = JSON.stringify(this.editData);
              var sMainSub = sMainStr + ";" + this.user;
              axios({
                method: "post",
                url: this.$baseUrl + "/Gy_StockPlace/AddBill1",
                data: {
                  oMain: sMainSub,
                },
              })
                .then((response) => {
                  console.log(response);
                  if (response.data.count == 1) {
                    this.subDisabled = true; //设置保存按钮不可用
                    this.CheckBillDisabled = false;
                    this.$modal.msgSuccess(response.data.Message);
                  } else {
                    this.$modal.msgError(response.data.Message);
                    this.CheckBillDisabled = false;
                    this.subDisabled = false; //设置保存按钮可用
                  }
                })
                .catch((error) => {
                  this.$modal.msgError("接口请求失败!");
                });
            }
          });
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete() {
      this.$modal
        .confirm("确认要删除吗,删除后不能恢复")
        .then(() => {
          if (this.rowForm.状态 == "创建") {
            axios
              .get(this.$baseUrl + "/Kf_SellOutBill/DeltetSellOutBill", {
                params: { HInterID: this.rowForm.hmainid.toString(), user: this.user },
              })
              .then((response) => {
                if (response.data.count == 1) {
                  this.$modal.msgSuccess("删除成功");
                } else {
                  this.$modal.msgError("错误:" + result.code + result.Message);
                }
              })
              .catch((error) => {
                this.$modal.msgError("接口请求失败!");
              });
          } else {
            this.$modal.msgError("此条数据不是创建状态,无法删除!");
          }
        })
        .catch(() => {});
    },
    // 反审核/审核数据
    set_CheckBill(num, form) {
      var InterID = form.HItemID || form.HInterID;
      //逻辑审核方法
      axios
        .get(this.$baseUrl + "/Gy_Warehouse/AuditGy_Warehouse", {
          params: { HInterID: InterID, IsAudit: num, CurUserName: this.user },
        })
        .then((response) => {
          let result = response.data;
          if (result.code == 1) {
            this.$modal.msgSuccess("操作成功");
            this.CheckBillDisabled = true;
          } else {
            this.$modal.msgError("错误:" + result.code + result.Message);
          }
        })
        .catch((error) => {
          this.$modal.msgError("接口请求失败!");
        });
    },
    showReset() {
      this.deptShow = false;
      this.warehouseShow = false;
      this.materialShow = false;
      this.workCenterShow = false;
    },
    //  打开数据列表弹窗
    openDataDialog(num, row) {
      if (row) {
        this.zbIndex = row.index - 1;
      }
      this.showReset();
      if (num == 1) {
        this.dialogTitle = "仓位列表";
        this.warehouseShow = true;
        this.openData = true;
      }
    },
  },
};
</script>
<style>
.xsckdBox .el-date-editor.el-input {
  width: 100%;
}
.form-inline > .el-form-item__content {
  display: flex;
  flex-direction: row;
}
</style>