zouyu
2023-12-14 43b705c29b0e089bdc1cf1cc9076b83f500b1ff5
src/views/technology/structure/single-structure-form.vue
@@ -2,11 +2,11 @@
  <div style="height: 100%">
    <div class="page-header">
      <div class="header-left">
        <a @click="$router.go(-1)"><i class="icon-btn-back"></i></a>
        <a @click="goBack"><i class="icon-btn-back"></i></a>
        <h2>编辑-产品结构</h2>
      </div>
      <div class="btn-group header-right">
        <el-button title="保存" :disabled="isSubmit" v-thinclick="`save`"
        <el-button title="保存" type="primary" :disabled="isSubmit" v-thinclick="`save`"
          >保存</el-button
        >
      </div>
@@ -47,34 +47,6 @@
                >
                </el-input>
              </el-form-item>
              <!-- <el-form-item label="结构类型" prop="bomTypeDb">
                <el-select
                  v-model="dataForm.bomTypeDb"
                  placeholder="请选择结构类型"
                  style="width:100%"
                >
                  <el-option
                    v-for="(item, index) in bomTypeDbOptions"
                    :label="item.label"
                    :value="item.value"
                    :key="index"
                  >
                  </el-option>
                </el-select>
              </el-form-item> -->
              <!-- <el-form-item label="替代" prop="alternativeNo">
                <el-input v-model="dataForm.alternativeNo"></el-input>
              </el-form-item>
              <el-form-item label="替代描述" prop="alternativeDesc">
                <el-input
                  type="textarea"
                  :autosize="{ minRows: 1, maxRows: 3 }"
                  v-model="dataForm.alternativeDesc"
                ></el-input>
              </el-form-item> -->
              <!-- <el-form-item label="版本号" prop="version">
                <el-input v-model="dataForm.version" disabled></el-input>
              </el-form-item> -->
              <el-form-item label="备注" prop="remark">
                <el-input
                  type="textarea"
@@ -82,15 +54,6 @@
                  v-model="dataForm.remark"
                ></el-input>
              </el-form-item>
              <!-- <el-form-item label="已同步至IFS" prop="ifsSync">
                <span
                  style="width: 146px;display: inline-block;font-size:12px;font-weight:bold;"
                  >{{ dataForm.ifsSync ? '是' : '否' }}</span
                >
              </el-form-item> -->
              <!-- <el-form-item label="默认结构" prop="master">
                <el-checkbox v-model="dataForm.master"></el-checkbox>
              </el-form-item> -->
            </el-col>
          </el-row>
        </el-form>
@@ -110,7 +73,7 @@
                size="medium"
                class="blue-but"
                @click="addNode()"
                >添加
                >添加行
              </el-button>
            </div>
          </div>
@@ -120,12 +83,14 @@
            :data="nodeList"
            :default-sort="{ prop: 'lineItemNo' }"
            height="650"
            :header-cell-style="{ color: '#999' }"
            border
            :header-cell-style="{ color: '#000' }"
            :row-class-name="structureComponentRowClass"
            class="l-mes"
          >
            <el-table-column
              prop="lineItemNo"
              label="行项号"
              label="序号"
              align="center"
              width="70"
            >
@@ -137,8 +102,10 @@
            >
              <template scope="scope">
                <el-input
                style="width:90%"
                  v-model="scope.row.operationName"
                  placeholder="请选择消耗工序"
                readonly
                  v-if="scope.row.isUpdate"
                >
                  <el-button
@@ -155,6 +122,7 @@
            <el-table-column label="零件号" prop="partNo" align="center">
              <template scope="scope">
                <el-input
                  style="width:90%"
                  :class="customClass[scope.$index]"
                  v-model="scope.row.partNo"
                  placeholder="请选择零件"
@@ -184,6 +152,8 @@
            <el-table-column label="数量" prop="qpa" align="center">
              <template slot-scope="scope">
                <el-input
                  style="width:90%"
                  clearable
                  size="small"
                  v-model="scope.row.qpa"
                  placeholder="请填写数量"
@@ -193,31 +163,15 @@
                <span v-show="!scope.row.isUpdate">{{ scope.row.qpa }}</span>
              </template>
            </el-table-column>
            <el-table-column label="单位" prop="unit" align="center">
            </el-table-column>
            <!-- <el-table-column label="盘数(盘)" prop="discNum" align="center">
              <template slot-scope="scope">
                <el-input
                  size="small"
                  v-model="scope.row.discNum"
                  placeholder="请填写盘数"
                  v-show="scope.row.isUpdate"
                ></el-input>
                <span v-show="!scope.row.isUpdate">{{
                  scope.row.discNum
                }}</span>
              </template>
            </el-table-column> -->
            <!-- <el-table-column label="图号" prop="drawingNumber" align="center">
            </el-table-column> -->
            <el-table-column align="center" label="操作" width="85px">
              <template slot-scope="scope">
                <el-button
                  type="text"
                  size="small"
                  class="blue-but"
                  v-if="!scope.row.isUpdate"
                  v-if="!scope.row.isUpdate && scope.row.id!=null"
                  @click="editNode(scope.$index, scope.row)"
                  >编辑</el-button
                >
@@ -225,7 +179,7 @@
                  type="text"
                  size="small"
                  class="blue-but"
                  v-if="scope.row.isUpdate"
                  v-if="scope.row.isUpdate && scope.row.id!=null"
                  :loading="nodeSaveLoading"
                  @click="addOrUpdateNode(scope.$index, scope.row)"
                  >保存</el-button
@@ -346,6 +300,26 @@
    this.getBomTypeDbOptions()
  },
  methods: {
    goBack(){
      let isUnSave = false
      const _than = this
      _than.nodeList.forEach(e=>{
        if(e.isUpdate || e.id==null){
          isUnSave = true
        }
      })
      if(isUnSave){
        _than.$confirm('您还有未保存的子节点,确认离开吗?', '提示', {
          confirmButtonText: '仍要离开',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          _than.$router.go(-1)
        }).catch(() => {});
      }else{
        _than.$router.go(-1)
      }
    },
    // 查询结构类型字典
    getBomTypeDbOptions() {
      remote('bom_type_db').then((response) => {
@@ -424,41 +398,49 @@
      this.currRow = null
    },
    save() {
      const _than = this
      this.isSubmit = true
      this.$refs.dataForm.validate((valid) => {
       _than.nodeList.forEach(e=>{
        e.version = _than.dataForm.version
      })
      _than.dataForm.components = _than.nodeList
      _than.$refs.dataForm.validate((valid) => {
        if (valid) {
          if (this.dataForm.id) {
            putObj(this.dataForm)
          if (_than.dataForm.id) {
            putObj(_than.dataForm)
              .then((response) => {
                var data = response.data
                if (data.code === 0) {
                  this.$message.success('保存成功')
                  _than.$message.success('保存成功')
                  _than.$nextTick(()=>{
                    _than.init(_than.dataForm.id)
                  })
                } else {
                  this.$message.error('保存失败')
                  _than.$message.error('保存失败')
                }
                this.isSubmit = false
                _than.isSubmit = false
              })
              .catch(() => {
                this.isSubmit = false
                _than.isSubmit = false
              })
          } else {
            addObj(this.dataForm)
            addObj(_than.dataForm)
              .then((response) => {
                var data = response.data
                if (data.code === 0) {
                  this.dataForm.id = data.data
                  this.$message.success('保存成功')
                  _than.dataForm.id = data.data
                  _than.$message.success('保存成功')
                } else {
                  this.$message.error('保存失败')
                  _than.$message.error('保存失败')
                }
                this.isSubmit = false
                _than.isSubmit = false
              })
              .catch(() => {
                this.isSubmit = false
                _than.isSubmit = false
              })
          }
        } else {
          this.isSubmit = false
          _than.isSubmit = false
        }
      })
    },
@@ -635,6 +617,10 @@
      }
    },
    delNode(index, row) {
      if(row.id==null){
        this.nodeList.splice(index,1)
        return
      }
      this.$confirm('是否确认删除零件号为' + row.partNo, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
@@ -826,4 +812,28 @@
.el-input__red {
  border: 1px solid red;
}
.l-mes .el-input-group__append,
.l-mes .el-input-group__prepend {
  padding: 0;
  border-top: none;
  border-right: none;
  border-left: none;
  border-radius: 0;
  background-color: transparent;
}
.l-mes .el-input-group__append .el-button,
.l-mes .el-input-group__prepend .el-button {
  padding: 0;
  width: 25px;
  border: none !important;
  line-height: 28px;
  color: #c0c4cc;
  margin: -1px 0;
}
.l-mes .el-input-group__append .el-button i,
.l-mes .el-input-group__prepend .el-button i {
  vertical-align: middle;
}
</style>