zouyu
2023-10-31 b5d7cad27e6d6382cc375a7bbfb91aad0c31195c
src/views/quality/rawMaterial/rawMaterial-form.vue
@@ -11,14 +11,6 @@
    </div>
    <div class="page-main">
      <div class="rawMaterial-basic">
        <el-row style="width:100%;height:20px;margin-bottom:20px;" v-show="dataForm.id==null">
          <el-col :span="20">
            <span style="color:red;font-size:18px;padding: 0;margin: 0;">请扫描二维码获取数据</span>
          </el-col>
          <el-col :span="4" style="text-align: right;">
            <el-button>扫描二维码</el-button>
          </el-col>
        </el-row>
        <el-form
        :model="dataForm"
        :rules="dataRule"
@@ -27,15 +19,14 @@
        class="l-mes"
        label-width="110px">
            <el-row>
            <el-col :span="6">
                <el-form-item prop="formTime" label="来料日期">
                <el-date-picker
                    v-model="dataForm.formTime"
                    type="datetime"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    disabled>
                </el-date-picker>
              <el-col :span="6">
                <el-form-item label="零件号" prop="code">
                <el-input v-model="dataForm.code">
                  <el-button
                    slot="append"
                    icon="el-icon-search"
                    @click="queryCode()"></el-button>
                </el-input>
                </el-form-item>
            </el-col>
            <el-col :span="6">
@@ -45,8 +36,14 @@
                </el-form-item>
            </el-col>
            <el-col :span="6">
                <el-form-item label="原材料编码" prop="code">
                <el-input v-model="dataForm.code" disabled></el-input>
                <el-form-item prop="formTime" label="来料日期">
                <el-date-picker
                    v-model="dataForm.formTime"
                    type="datetime"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    disabled>
                </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="6">
@@ -102,12 +99,18 @@
        </el-row>
        <el-row style="width:100%;">
            <el-col :span="24">
                <el-table :data="list" border style="width: 100%;" height="320">
                <el-table :header-cell-style="{textAlign:'center',color:'black',backgroundColor:'#fafafa'}"
                :cell-style="{textAlign:'center'}" ref="table"
                :data="list" border style="width: 100%;" height="320">
                  <el-table-column type="index" label="序号" width="60">
                  </el-table-column>
                  <el-table-column prop="name" label="项目" width="260">
                    <template slot-scope="scope">
                      <el-input :disabled="dataForm.id != null" class="inline-input" v-model="scope.row.name"
                      <el-select v-if="projectList.length > 0" :disabled="dataForm.id != null" class="inline-input" v-model="scope.row.name"
                      filterable allow-create placeholder="请输入或选择项目名称" style="width:100%" @change="changeName(scope.$index,scope.row)">
                        <el-option v-for="(item,index) in projectList" :key="index" :label="item.name" :value="item.name"/>
                    </el-select>
                      <el-input v-else :disabled="dataForm.id != null" class="inline-input" v-model="scope.row.name"
                        placeholder="请输入项目名称"></el-input>
                    </template>
                  </el-table-column>
@@ -179,6 +182,7 @@
        </el-row>
      </div>
    </div>
    <rawMaterialPartDialog :paramObj="paramObj" :currshowlist.sync="showPart"  @listenToPartEvent="selectPart" />
  </div>
</template>
@@ -190,10 +194,21 @@
  getObj,
  updateRawInsProduct,
  updateRawInspectsById,
  chooseIFS,
  selectHisByCode,
  updateDeviceById, } from '@/api/quality/rawMaterial'
  import rawMaterialPartDialog from '@/views/common/rawMaterial-part'
export default {
    computed:{},
    components:{
      rawMaterialPartDialog
    },
    data(){
        return{
            projectList: [],
            paramObj: {},
            IFSData: [],
            showPart: false,
            // 添加列
            empiricalValueAdd: 1,
            // 编辑时存储最长的列数字,做删除判断
@@ -202,14 +217,14 @@
            dataForm:{
                id: null,
                judgeState: null,
                formTime: '2023-10-28 00:00:00',
                message: '-2050314,1,1,*,1002',
                name: 'name',
                code: 'code4',
                specs: 'specs',
                unit: 'mm',
                number: '111',
                supplier: 'supplier',
                formTime: '',
                message: '',
                name: '',
                code: '88.118.1/A0487643',
                specs: '',
                unit: '',
                number: '',
                supplier: '',
                rawInsProducts: [{
                  equipmentId: 0,
                  name: '',
@@ -234,6 +249,11 @@
            deviceList: [],
        }
    },
    beforeUpdate(){
      this.$nextTick(()=>{
        this.$refs.table.doLayout();
      })
    },
    mounted(){
      this.dataForm.id = this.$route.query.id
      this.init()
@@ -247,6 +267,34 @@
    },
    methods:{
      changeName(index,row){
        this.projectList.forEach(item=>{
          if(row.name == item.name){
            this.list[index].unit = item.unit
            this.list[index].required = item.required
          }
        })
      },
      // 确认回调
      selectPart(param, nodePart, index) {
        if (typeof param !== 'undefined') {
          this.dataForm.code = param.code
          this.dataForm.name = param.name
          this.dataForm.formTime = param.formTime
          this.dataForm.unit = param.unit
          this.dataForm.specs = param.specs
          this.dataForm.supplier = param.supplier
          this.dataForm.number = param.number
          this.dataForm.message = param.message
          this.projectList = param.rawInsProducts
        }
      },
      queryCode(){
        this.paramObj = {
          code: this.dataForm.code
        }
        this.showPart = true
      },
      updateDevice(row){
        if(this.dataForm.id != null){
          updateDeviceById({equiomentId:row.equipmentId,rpId:row.rpId}).then(res=>{
@@ -283,6 +331,19 @@
      },
      addTeatValueColumn(){
        this.empiricalValueAdd = this.empiricalValueAdd + 1;
      },
      // 添加行
      clickAddLine() {
        let obj = {
          equipmentId: null,
          name: "",
          required: "",
          testValue: "",
          unit: "",
          testState: null,
          testValueList: [],
        };
        this.list.push(obj);
      },
      // 删除行
      clickDeleteline(scope) {
@@ -381,27 +442,12 @@
          this.$message.error(error)
        })
      },
      // 添加行
      clickAddLine() {
        let obj = {
          equipmentId: null,
          name: "",
          required: "",
          testValue: "",
          unit: "",
          testState: null,
          testValueList: [],
        };
        this.list.push(obj);
      },
      getDeviceList(){
        selectDevice(null).then(res=>{
          this.deviceList = res.data.data
        })
      },
    },
    computed:{},
    components:{}
}
</script>
@@ -420,7 +466,7 @@
.rawMaterial-basic {
  background-color: #fff;
  height: 150px;
  height: 155px;
  display: flex;
  flex-wrap: wrap;
  padding: 10px 20px;