zouyu
2023-11-01 1094076235c6765ee0b527272d476df227d690ff
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,15 @@
                </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
                    style="width:100%"
                    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">
@@ -95,19 +93,25 @@
            <el-col :span="5">
                <div style="width:100%;text-align: right;">
                    <el-button v-show="dataForm.id==null" size="small" @click="clickAddLine">添加检验行</el-button>
                    <el-button size="small" @click="addTeatValueColumn()">添加检验值列</el-button>
                    <el-button size="small" @click="delTeatValueColumn()">删除检验值列</el-button>
                    <el-button size="small" @click="addTeatValueColumn()">添加检测值列</el-button>
                    <el-button size="small" @click="delTeatValueColumn()">删除检测值列</el-button>
                </div>
            </el-col>
        </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="400">
                  <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>
@@ -156,44 +160,60 @@
            </el-col>
        </el-row>
      </div>
      <div class="rawMaterial-detail">
      <div class="rawMaterial-result">
        <el-row>
          <el-col :span="24">检验结论</el-col>
        </el-row>
        <el-row style="width:100%">
          <el-col :span="24">
            <avue-crud
              ref="conclusion"
              :option="option"
              :data="conclusionTable"
              v-model="conclusion">
                <template slot="judgeState" slot-scope="scope">
                  <el-tag type="success" v-if="scope.row.judgeState == 1">合格</el-tag>
                  <el-tag type="danger" v-else-if="scope.row.judgeState == 0">不合格</el-tag>
                </template>
                <template #menu>
                  <el-button type="text" @click="submitSave()" size="small">上报</el-button>
                </template>
              </avue-crud>
            <el-table border height="90" :data="conclusionTable" ref="conclusion" v-model="conclusion"
            :header-cell-style="{textAlign:'center',color:'black',backgroundColor:'#fafafa'}"
            :cell-style="{textAlign:'center'}">
                <el-table-column prop="code" label="物料编号"></el-table-column>
                <el-table-column prop="name" label="物料名称"></el-table-column>
                <el-table-column prop="userName" label="检验员"></el-table-column>
                <el-table-column prop="judgeState" label="检验结论">
                  <template slot-scope="scope">
                    <el-tag type="success" v-if="scope.row.judgeState == 1">合格</el-tag>
                    <el-tag type="danger" v-else-if="scope.row.judgeState == 0">不合格</el-tag>
                  </template>
                </el-table-column>
                <el-table-column  label="操作">
                    <template>
                        <el-button type="text" @click="submitSave()" size="small">上报</el-button>
                    </template>
                </el-table-column>
            </el-table>
          </el-col>
        </el-row>
      </div>
    </div>
    <rawMaterialPartDialog :paramObj="paramObj" :currshowlist.sync="showPart"  @listenToPartEvent="selectPart" />
  </div>
</template>
<script>
import { object,conclusion } from '@/const/crud/quality/rawMaterial'
import { 
  selectDevice,
  addRawInspects,
  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 +222,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: '',
@@ -228,25 +248,52 @@
              userName: '',
              testState: ''
            }],
            tableOption: object,
            option: conclusion,
            dataRule: {},
            deviceList: [],
        }
    },
    beforeUpdate(){
      this.$nextTick(()=>{
        this.$refs.table.doLayout();
      })
    },
    mounted(){
      this.dataForm.id = this.$route.query.id
      this.init()
      let isShow = this.dataForm.id == null ? true : false
      this.tableOption.menu = isShow
      let len = this.tableOption.column.length
      this.tableOption.column[len-1].hide = isShow
      this.getDeviceList()
    },
    watch:{
    },
    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 +330,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) {
@@ -365,7 +425,6 @@
          })
        }else{
          this.conclusionTable = []
          this.tableOption.column = object.column
        }
      },
      save(){
@@ -381,34 +440,31 @@
          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>
<style>
.rawMaterial-detail {
  width: 100%;
  height: 400px;
  height: 470px;
  padding: 10px 20px;
  display: flex;
  border: 1px solid #ddd;
  background-color: #fff;
  margin-top: 10px;
  box-sizing: border-box;
  flex-wrap: wrap;
}
.rawMaterial-result {
  width: 100%;
  height: 150px;
  padding: 10px 20px;
  display: flex;
  border: 1px solid #ddd;
@@ -420,7 +476,7 @@
.rawMaterial-basic {
  background-color: #fff;
  height: 150px;
  height: 155px;
  display: flex;
  flex-wrap: wrap;
  padding: 10px 20px;