loulijun2021
2022-08-26 d9493eb7905545e5509689eae73a450c576418e0
src/views/zlgl/gxjy.vue
@@ -124,7 +124,42 @@
              :value="item.usercode"
            />
          </el-select>
          <div style="width: 90px;margin-left: 50px;display: flex">
            <div style="color: red;width:10px">*</div>
            检验数量:
        </div>
          <el-input v-model="checkCount" oninput="value=value.replace(/[^0-9]/g,'')" style="width: 200px" />
        </div>
        <!--   检验结果   和  检验备注      -->
        <div style="display: flex;margin-top: 20px;align-items: center">
          <div style="display: flex;margin-right: 50px;align-items: center">
            <div style="width: 90px;display: flex">
              <div style="color: red;width:10px">*</div>
              检验结果:
            </div>
            <el-select
              v-model="checkResult"
              style="width: 200px;"
              placeholder="请选择"
              filterable
            >
              <el-option
                v-for="item in checkResultSelect"
                :key="item.code"
                :label="item.name"
                :value="item.code"
              />
            </el-select>
          </div>
          <div style="display: flex;align-items: center">
            <div style="width: 90px">检验备注:</div>
            <el-input v-model="checkdescr" style="width: 540px" placeholder="请输入" />
          </div>
        </div>
        <div style="margin: 15px 0;font-size: 14px">
          <i class="el-icon-s-operation" style="color:#42b983; margin-right: 5px" />检验项信息
        </div>
@@ -151,38 +186,80 @@
              width="100"
              fixed
            />
            <!--            <el-table-column-->
            <!--              prop="code"-->
            <!--              label="检验项目编码"-->
            <!--              sortable="custom"-->
            <!--              label="检验项目编码(名称)"-->
            <!--            >-->
            <!--              <template slot-scope="{row}">-->
            <!--                <div v-if="row.isVisible===0" style="display: flex;">-->
            <!--                  <div>{{ row.code }}</div>-->
            <!--                  <div style="margin-left: 10px">{{ row.name }}</div>-->
            <!--                </div>-->
            <!--                <el-select-->
            <!--                  v-if="row.isVisible===1"-->
            <!--                  v-model="row.code"-->
            <!--                  filterable-->
            <!--                  style="width: 400px;"-->
            <!--                  placeholder="请选择"-->
            <!--                  @change="val=>changeCode(val,row)"-->
            <!--                >-->
            <!--                  <el-option-->
            <!--                    v-for="item in JYSelectArr"-->
            <!--                    :key="item.code"-->
            <!--                    :label="item.code+''+item.name"-->
            <!--                    :value="item.code"-->
            <!--            />-->
            <!--                </el-select>-->
            <!--              </template>-->
            <!--            </el-table-column>-->
            <el-table-column
              prop="code"
              label="检验项目编码(名称)"
              label="检验标准编码"
            >
              <template slot-scope="{row}">
                <div v-if="row.isVisible===0" style="display: flex;">
                  <div>{{ row.code }}</div>
                  <div style="margin-left: 10px">{{ row.name }}</div>
                </div>
                <div v-if="row.isVisible===0">{{ row.code }}</div>
                <el-select
                  v-if="row.isVisible===1"
                  v-model="row.code"
                  filterable
                  style="width: 400px;"
                  style="width: 200px;"
                  placeholder="请选择"
                  @change="val=>changeCode(val,row)"
                  @change="val=>changeName(val,row)"
                >
                  <el-option
                    v-for="item in JYSelectArr"
                    :key="item.name"
                    :label="item.code"
                    :value="item.name"
                  />
                </el-select>
              </template>
            </el-table-column>
            <el-table-column
              prop="name"
              label="检验标准名称"
            >
              <template slot-scope="{row}">
                <div v-if="row.isVisible===0">{{ row.name }}</div>
                <el-select
                  v-if="row.isVisible===1"
                  v-model="row.name"
                  style="width: 200px;"
                  placeholder="请选择"
                  @change="val=>changeName(val,row)"
                >
                  <el-option
                    v-for="item in JYSelectArr"
                    :key="item.code"
                    :label="item.code+''+item.name"
                    :label="item.name"
                    :value="item.code"
                  />
                </el-select>
              </template>
            </el-table-column>
            <el-table-column
              prop="stepcheckitem_desc"
              label="检验标准描述"
@@ -242,6 +319,7 @@
            <el-table-column
              label="操作"
              fixed="right"
            >
              <template slot-scope="{row}">
                <div class="operationClass">
@@ -252,34 +330,6 @@
              </template>
            </el-table-column>
          </el-table>
        </div>
        <!--   检验结果   和  检验备注      -->
        <div style="display: flex;margin-top: 20px;align-items: center">
          <div style="display: flex;margin-right: 50px;align-items: center">
            <div style="width: 90px;display: flex">
              <div style="color: red;width:10px">*</div>
              检验结果:
            </div>
            <el-select
              v-model="checkResult"
              style="width: 200px;"
              placeholder="请选择"
              filterable
            >
              <el-option
                v-for="item in checkResultSelect"
                :key="item.code"
                :label="item.name"
                :value="item.code"
              />
            </el-select>
          </div>
          <div style="display: flex;align-items: center">
            <div style="width: 90px">检验备注:</div>
            <el-input v-model="checkdescr" style="width: 300px" placeholder="请输入" />
          </div>
        </div>
        <div style="display: flex;margin: 30px 0;align-items: center">
@@ -330,6 +380,7 @@
      checkStandard: '', // 检验标准
      checkStandardSelect: [], // 检验标准下拉数组
      checkUser: '', // 检验人员
      checkCount: 0, // 检验数量
      checkUserSelect: [], // 检验人员下拉数组
      checkResult: '', // 检验结果
      checkResultSelect: [
@@ -340,7 +391,8 @@
      JYTableData: [], // 检验项信息表格
      JYSelectArr: [], // 检验下拉数组
      JYSelectedArr: [], // 已选检验项目数组
      // JYSelectedArr: [], // 已选检验项目数组
      JYIsCancel: true,
      multipleSelection: [], // 表格多选框
      tabClickIndex: null, // 点击的单元格
      tabClickLabel: '', // 当前点击的列名
@@ -390,10 +442,14 @@
    },
    // 检验标准下拉值改变
    async changeCheckStandard(val) {
      await this.getJYSelectArr()
      this.isCancel = false
      this.JYSelectedArr = []
      const { data: res } = await MesOrderStepCheckItemList({ checkstandcode: val })
      this.JYTableData = res
      // let arr = […b].filter(x => […a].every(y => y.id !== x.id));
      this.JYSelectArr = [...this.JYSelectArr].filter(x => [...this.JYTableData].every(y => y.code !== x.code))
      this.JYTableData.forEach(item => {
        let number = Math.random() * Math.random()// 作为删除时的标识符
@@ -404,7 +460,6 @@
        item.isVisible = 0
        item.number = number
        this.JYSelectedArr.push(item.code)
      })
      this.$refs.multipleTable.toggleAllSelection()
    },
@@ -436,9 +491,13 @@
      }
    },
    // 检验项目编码(名称)
    changeCode(val, row) {
      row.stepcheckitem_desc = this.JYSelectArr.find(it => it.code === val).descr
      row.name = this.JYSelectArr.find(it => it.code === val).name
    changeName(val, row) {
      const res = this.JYSelectArr.find(item => {
        return item.code === val || item.name === val
      })
      row.code = res.code
      row.name = res.name
      row.stepcheckitem_desc = res.descr
    },
    // 扫码键盘回车事件
    async enterNative(val, belong) {
@@ -455,6 +514,9 @@
    //  新增
    add() {
      if (this.JYTableData.length === 0) {
        return this.$message.info('请先选择检验标准!')
      }
      if (this.JYTableData.length > 0 && this.JYTableData[this.JYTableData.length - 1].isVisible === 1) {
        return this.$message.info('请先确定或取消本条记录!')
      }
@@ -464,19 +526,25 @@
      const data = { result: 'OK', code: '', name: '', stepcheckitem_desc: '', isVisible: 1, number }
      this.JYTableData.push(data)
      this.$refs.multipleTable.toggleRowSelection(data, true)
      this.JYIsCancel = false
    },
    //  确认
    confirm(row) {
      if (row.code === '') {
        return this.$message.info('检验项目编码(名称)不能为空!')
        return this.$message.info('检验项目编码不能为空!')
      }
      if (row.name === '') {
        return this.$message.info('检验项目名称不能为空!')
      }
      if (this.JYSelectedArr.find(item => item === row.code) !== undefined) {
        return this.$message.info('检验项目编码(名称)不能重复!')
      } else {
        this.JYSelectedArr.push(row.code)
      this.JYSelectArr.forEach((item, index) => {
        if (item.code === row.code) {
          this.JYSelectArr.splice(index, 1)
      }
      })
      this.JYTableData.forEach((item, index) => {
        if (item.number === row.number) {
          item.isVisible = 0
@@ -501,24 +569,27 @@
        }
      })
      this.JYSelectedArr.forEach((item, index) => {
        if (item === row.code) {
          this.JYSelectedArr.splice(index, 1)
        }
      if (this.JYIsCancel && row.code.toString().length > 0) {
        this.JYSelectArr.splice(0, 0, {
          code: row.code,
          name: row.name,
          descr: row.stepcheckitem_desc
      })
      }
      this.JYIsCancel = true
    },
    // 删除
    del(row) {
      this.JYSelectArr.splice(0, 0, {
        code: row.code,
        name: row.name,
        descr: row.stepcheckitem_desc
      })
      this.JYTableData.forEach((item, index) => {
        if (item.number === row.number) {
          this.JYTableData.splice(index, 1)
        }
      })
      this.JYSelectedArr.forEach((item, index) => {
        if (item === row.code) {
          this.JYSelectedArr.splice(index, 1)
        }
      })
    },
@@ -533,6 +604,9 @@
        }
        if (this.checkUser.length < 1) {
          return this.$message.info('检验人员不能为空!')
        }
        if (parseFloat(this.checkCount) > 0) {
          return this.$message.info('检验数量必须要大于零!')
        }
        if (this.JYTableData.length < 1) {
          return this.$message.info('检验项信息不能为空!')
@@ -573,6 +647,7 @@
              this.$message.success(text + '成功!')
              this.clearContent()
              this.getFocus()
              this.getJYSelectArr()
            }
          })
        }).catch(() => {
@@ -581,15 +656,16 @@
      } else {
        this.clearContent()
        this.getFocus()
        this.getJYSelectArr()
      }
    },
    // 清空页面内容
    clearContent() {
      this.JYTableData = []
      this.multipleSelection = []
      this.JYSelectedArr = []
      this.checkdescr = ''
      this.checkUser = ''
      this.checkCount = 0
      this.checkResult = ''
      this.checkStandard = ''
      this.form.orderstepqrcode = ''