yangfeng
2023-09-26 327b3157bb7e155d3333017bc2ddd66611ea06a9
src/views/warehouseManage/position/AddDialog.vue
@@ -34,11 +34,10 @@
      >
        <div>
          <!-- <div>aaa</div> -->
          <FormBtnsView :showPosition="true" :showWarehouse=false @productClick="productClick" />
          <FormBtnsView :showPosition="true" :showWarehouse="false" @productClick="productClick" />
        </div>
        <div class="basic-info">
          <div class="basic-info-view">
            <el-row>
              <el-col :span="24" class="line_height_30px">
                <el-form-item label="位置名称" prop="name">
@@ -58,12 +57,7 @@
                    style="width: 45%"
                    :disabled="!showFooter"
                  >
                    <el-option
                      v-for="item in positionList"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    >
                    <el-option v-for="item in positionList" :key="item.id" :label="item.name" :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
@@ -82,35 +76,22 @@
                    style="width: 100%"
                    no-data-text="暂无数据"
                  >
                    <el-option
                      v-for="item in positionTypeList"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    >
                  <el-option v-for="item in positionTypeList" :key="item.id" :label="item.name" :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item> 
                <el-form-item label="是一个报废位置" v-if="editConfig.infomation.type==3||editConfig.infomation.type==5" prop="isScrapLocation">
                  <el-checkbox
                  :disabled="!showFooter"
                  v-model="editConfig.infomation.isScrapLocation"
              <el-form-item
                label="是一个报废位置"
                v-if="editConfig.infomation.type == 3 || editConfig.infomation.type == 5"
                prop="isScrapLocation"
                  >
                  </el-checkbox>
                <el-checkbox :disabled="!showFooter" v-model="editConfig.infomation.isScrapLocation"> </el-checkbox>
                </el-form-item>
                <el-form-item label="是一个退回位置" prop="isReturnLocation">
                  <el-checkbox
                  :disabled="!showFooter"
                  v-model="editConfig.infomation.isReturnLocation"
                  >
                  </el-checkbox>
                <el-checkbox :disabled="!showFooter" v-model="editConfig.infomation.isReturnLocation"> </el-checkbox>
                </el-form-item>
                <el-form-item label="补充位置" v-if="editConfig.infomation.type==3" prop="replenishLocation">
                  <el-checkbox
                  :disabled="!showFooter"
                  v-model="editConfig.infomation.replenishLocation"
                  >
                  </el-checkbox>
                <el-checkbox :disabled="!showFooter" v-model="editConfig.infomation.replenishLocation"> </el-checkbox>
                </el-form-item>
              </div>
              <div class="left" v-if="editConfig.infomation.type==3||editConfig.infomation.type==7">
@@ -192,7 +173,7 @@
<script>
import { addLocation,updateLocation,deleteLocation } from "@/api/warehouseManage/warehouse"
import { getDataByType } from "@/api/data";
import { getDataByType } from "@/api/data"
export default {
  name: "AddScrapDialog",
  props: {
@@ -218,19 +199,21 @@
      editConfig: this.editCommonConfig,
      rules: {
        name: [{ required: true, message: "请输入", trigger: "change" }],
        countFrequency: [{
        countFrequency: [
          {
            required: false,
            message: "请填写不小于0的数字",
            trigger: "change",
            trigger: "change"
          },
          {
            validator: this.validatorNum,
            trigger: "blur",
          },],
            trigger: "blur"
          }
        ]
      },
      showEdit: false, // 是否显示编辑按钮
      showFooter: false, // 是否显示取消保存
      positionTypeList: getDataByType("positionType"),
      positionTypeList: getDataByType("positionType")
    }
  },
  created() {
@@ -240,23 +223,21 @@
    validatorNum(rule, value, callback) {
      if (value) {
        if (value == undefined || value == null) {
          callback(new Error("请输入有效数字"));
          callback(new Error("请输入有效数字"))
        } else {
          var reg = /^\+?[0-9]\d*$/;
          var reg = /^\+?[0-9]\d*$/
          if (!reg.test(value)) {
            callback(new Error("请填写不小于0的数字"));
            callback(new Error("请填写不小于0的数字"))
          } else {
            callback();
            callback()
          }
        }
      } else {
        callback();
        callback()
      }
    },
    // 路线
    productClick() {
    },
    productClick() {},
    // 设置删除/打印/编辑是否显示
    setBottonView() {
      if (this.editConfig.title === "新建") {
@@ -276,16 +257,16 @@
    },
    // 刪除
    deleteClick() {
      let data = JSON.parse(JSON.stringify(this.editConfig.infomation));
      let data = JSON.parse(JSON.stringify(this.editConfig.infomation))
      deleteLocation({ id: data.id }).then((res) => {
        if (res.code == 200) {
          this.editConfig.visible = false;
          this.$message.success("刪除成功!");
          this.$emit("refresh");
          this.editConfig.visible = false
          this.$message.success("刪除成功!")
          this.$emit("refresh")
        } else {
            this.$message.warning(res.msg?res.msg:"删除失败!")
         }
      });
      })
    },
    // 编辑
    editClick() {
@@ -293,11 +274,11 @@
      this.showFooter = true
    },
    saveParams() {
      let data =JSON.parse(JSON.stringify(this.editConfig.infomation));
      let data = JSON.parse(JSON.stringify(this.editConfig.infomation))
      
      let params = {
        name:data.name,
        parentId:data.parentId+'',
        parentId: data.parentId,
        type:data.type,
        isScrapLocation:data.isScrapLocation,
        isReturnLocation:data.isReturnLocation,
@@ -305,44 +286,44 @@
        countFrequency:data.countFrequency?Number(data.countFrequency):0,
        recentlyCount:data.recentlyCount,
        nextCount:data.nextCount,
        notes:data.notes,
        notes: data.notes
      }
      if(data.id){
        params.id=data.id
      }
      return params;
      return params
    },
    // 保存
    saveClick(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          const params = this.saveParams();
          const params = this.saveParams()
            if (this.editConfig.title === "新建") {
              addLocation(params).then((res) => {
                if (res.code == 200) {
                  this.editConfig.visible = false;
                  this.$message.success("添加成功!");
                  this.$emit('refresh')
                this.editConfig.visible = false
                this.$message.success("添加成功!")
                this.$emit("refresh")
                } else {
                    this.$message.warning(res.msg?res.msg:"添加失败!")
                }
              });
            })
            } else {
              updateLocation(params).then((res) => {
                if (res.code == 200) {
                  this.editConfig.visible = false;
                  this.$message.success("编辑成功!");
                  this.$emit('refresh')
                this.editConfig.visible = false
                this.$message.success("编辑成功!")
                this.$emit("refresh")
                } else {
                    this.$message.warning(res.msg?res.msg:"编辑失败!")
                }
              });
            })
            }
        }else {
          console.log("error submit");
          return false;
          console.log("error submit")
          return false
        }
      });
      })
    }
  }
}
@@ -377,7 +358,6 @@
  .basic-info-view {
    margin-top: 20px;
    padding:0 20px;
  }
  .bottom{
    display: flex;
@@ -390,7 +370,6 @@
      width: calc(50% - 10px);
    }
    .second-label {
      border-bottom: 1px solid #d9d9d9;
      margin-bottom: 10px;
    }
@@ -398,7 +377,6 @@
      padding: 0 20px;
    }
  }
}
.purchase-view {
  display: flex;