石广澎
2023-11-30 50b1b07bfa382c3f19c6b23f1cff4dfa50294f07
admin-web/src/views/stock/procure/purchaseOrder/edit.vue
@@ -1,6 +1,6 @@
<template>
  <win-md class="stock-edit" :title="`${setting.title}采购入库`" @close="close" :width="'800px'" :loading="loading">
    <el-form class="form" ref="ruleForm" :model="formData" :rules="rules" label-width="120px">
    <el-form v-loading="loading" class="form" ref="ruleForm" :model="formData" :rules="rules" label-width="120px">
      <div class="main-w">
        <el-row :gutter="24" class="headerHeight">
          <el-col :span="12">
@@ -168,7 +168,8 @@
              plain
              size="mini"
              @click="removeGoods(goodsIndex)"
              >移除</el-button
            >移除
            </el-button
            >
            <el-button
              v-if="formData.procureGoods.length - 1 == goodsIndex"
@@ -177,7 +178,8 @@
              plain
              size="mini"
              @click="addGoods"
              >新增物品</el-button
            >新增物品
            </el-button
            >
          </div>
        </div>
@@ -211,7 +213,8 @@
  props: {
    setting: {
      type: Object,
      default: () => {},
      default: () => {
      },
    },
  },
  data() {
@@ -328,9 +331,8 @@
  },
  methods: {
    async init() {
      this.getWarehouseList();
      this.getgoodsTemplate();
      this.getgoodsModel();
      await this.getWarehouseList();
      // 获取物品分类列表
      const treeRes = await getTree();
      this.categoryOptions = this.removeEmptyChildren(treeRes);
@@ -342,7 +344,7 @@
        }
        this.$set(this.formData, 'buyType', this.formData.buyType.toString());
        this.formData.procureTime = this.formData.procureTime.toString();
        this.formData.procureGoods.map((item, index) => {
        this.formData.procureGoods.map(async (item, index) => {
          // 根据子集ID拼接物品分类列表
          item.baseCategoryIds = findParentIds(this.categoryOptions, item.baseCategoryId);
          this.$set(
@@ -350,20 +352,23 @@
            'modelsIds',
            item.models.map((v) => v.baseGoodsModelsId),
          );
          this.getgoodsTemplate(item.baseCategoryId, index);
          this.getgoodsModel(item.baseGoodsTemplateId, index);
          item.models.forEach((child, childIndex) => {
          await this.getgoodsTemplate(item.baseCategoryId, index);
          await this.getgoodsModel(item.baseGoodsTemplateId, index);
          await item.models.forEach((child, childIndex) => {
            this.$set(this.formData.procureGoods[index].models[childIndex], 'priceYuan', child.price / 100);
          });
          return item;
        });
      } else {
        await this.getgoodsTemplate();
        await this.getgoodsModel();
      }
      this.loading = false;
    },
    // 获取入库仓库列表
    getWarehouseList() {
      selectTenantWarehouse({ agencyId: this.userInfo.tenantId })
    async getWarehouseList() {
      await selectTenantWarehouse({agencyId: this.userInfo.tenantId})
        .then((res) => {
          this.warehouses = res;
          if (!this.setting.id && res.length) {
@@ -391,8 +396,8 @@
    },
    // 获取物品名称列表
    getgoodsTemplate(id, index) {
      goodsTemplate({ categoryId: id || '' }).then((res) => {
    async getgoodsTemplate(id, index) {
      await goodsTemplate({categoryId: id || ''}).then((res) => {
        if (index || index == 0) {
          this.$set(this.formData.procureGoods[index], 'goodsOptions', res);
        } else {
@@ -402,8 +407,8 @@
    },
    // 规格型号
    getgoodsModel(id, index) {
      goodsModel({ goodsTemplatesId: id || '' }).then((res) => {
    async getgoodsModel(id, index) {
      await goodsModel({goodsTemplatesId: id || ''}).then((res) => {
        if (index || index == 0) {
          this.$set(this.formData.procureGoods[index], 'modelsOptions', res);
        } else {
@@ -500,6 +505,7 @@
    handleSubmit() {
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          if (this.loading) return
          this.loading = true;
          if (!this.setting.id) {
            procureAdd(this.formData)