Mr.Zhang
2023-09-07 044b6f50a7cc57565409f67b62d4766f2e7cbf52
minipro_standard/pages/inspectPatrol/inspectPatrol.vue
@@ -59,21 +59,27 @@
</template>
<script>
   import {
      createStandard
   } from '@/util/api/QualityAPI'
   import {
      checkAllList
   } from "@/util/api/WorkOrderAPI"
   import { REGULAR } from '@/util/utils'
   export default {
      data() {
         return {
            info: {},
            show1: false,
            columns: [['中国', '美国', '日本']],
            columns1: [],
            columns: [],
            form: {
               status: '0',
               status: '1',
               gdid: '',
               gdmc: '',
               jygz: '',
               jygzmc: '',
               hgsl: 0,
               blsl: 1,
               blsl: 0,
               blgz: '',
               blgzmc: '',
               blsm: '',
@@ -82,8 +88,19 @@
         };
      },
      onLoad() {
         checkAllList({
               bmodelCateType: '3'
            })
            .then(res => {
               let bad = res.data.map(item => {
                  return {
                     name: item.combinationName,
                     id: item.id
                  }
               })
               this.columns = [bad]
            })
         uni.$on('workOrder', (data) => {
            console.log(data);
            this.form.gdmc = data.mmodel.name + '-' + data.pgmodel.name
            this.form.gdid = data.id
            this.info = data
@@ -93,17 +110,60 @@
      methods: {
         jumpGD() {
            uni.navigateTo({
               url: '/pages/selectWorkOrder/selectWorkOrder'
               url: '/pages/selectWorkOrder/selectWorkOrder?type=1'
            })
         },
         openBL() {},
         getValue1() {},
         selectBad() {
            console.log('------0-----');
            this.show1 = true
         },
         badConfirm(value) {
            this.show1 = false;
         badConfirm({
            value
         }) {
            this.form.blsm = value[0].name
            this.show1 = false
         },
         submit() {
            if (!this.form.gdid) return uni.$u.toast('工单不能为空')
            if (this.form.hgsl || this.form.blsl) {
               if (this.form.hgsl) {
                  if (this.form.dw == '0') { // 整数
                     if (!REGULAR.positiveInteger.test(this.form.hgsl)) return uni.$u.toast('良品数量只能为正整数')
                  } else if (this.form.dw == '1') { // 小数
                     if (!REGULAR.number.test(this.form.hgsl)) uni.$u.toast('良品数量只能为正整数或四位小数')
                  }
               }
               if (this.form.blsl) {
                  if (this.form.dw == '0') { // 整数
                     if (!REGULAR.positiveInteger.test(this.form.blsl)) return uni.$u.toast('不良数量只能为正整数')
                  } else if (this.form.dw == '1') { // 小数
                     if (!REGULAR.number.test(this.form.blsl)) {
                        return uni.$u.toast('不良数量只能为正整数或四位小数')
                     }
                  }
               }
            } else {
               return uni.$u.toast('良品和不良不能同时为空')
            }
            let total = (this.form.hgsl ? Number(this.form.hgsl) : 0) + (this.form.blsl ? Number(this.form.blsl) : 0)
            if (total > this.info.planNum) {
               return  uni.$u.toast('合格不良相加不能超过计划数量')
            }
            if (Number(this.form.blsl) > 0) {
               if (!this.form.blsm) return uni.$u.toast('不良说明不能为空')
            }
            createStandard({
               workorderId: this.form.gdid,
               qualifiedNum: this.form.hgsl ? this.form.hgsl : 0,
               unqualifiedNum: this.form.blsl ? this.form.blsl : 0,
               checkInfo: this.form.blsm,
               checkType: this.form.status
            }).then(res => {
               if (res.code === 200) {
                  uni.$u.toast('检验成功')
                  uni.navigateBack()
               }
            })
         }
      }
   }