hongxudong 2 лет назад
Родитель
Сommit
44fae2ce6e
3 измененных файлов с 302 добавлено и 102 удалено
  1. 13 0
      src/api/pages/pdm/pci-record.js
  2. 2 2
      src/components/base/dk-modal/dk-modal.vue
  3. 287 100
      src/view/pdm/qci/index.vue

+ 13 - 0
src/api/pages/pdm/pci-record.js

@@ -0,0 +1,13 @@
+/**
+ * @desc   : 检验记录
+ * @author : 洪旭东
+ * @date   : 2024-04-02 11:24
+ */
+export default {
+  qciRecordService:{
+    prefix:'/pdm-server/pdm/qci_record/',
+    getRecordByPdtCode: 'get_product_record',
+  },
+
+}
+

+ 2 - 2
src/components/base/dk-modal/dk-modal.vue

@@ -42,9 +42,9 @@
         <!--      <DkButton :loading="loading" v-if="okVisibleFlag" type="primary" @click="modalOk" name="confirm" :ref="saveFlag?'save':'confirm'">{{ saveFlag?$t('save') :$t('confirm') }}</DkButton>-->
         <!--      <DkButton v-if="cancelVisibleFlag" @click="modalCancel" name="close" ref="close">{{ $t('close') }}</DkButton>-->
         <DkButton :loading="loading" v-if="okVisibleFlag" type="primary" @click="modalOk" name="confirm"
-                  :ref="saveFlag?'save':'confirm'">{{ saveFlag ? '保存(S)' : '确定(O)' }}
+                  :ref="saveFlag?'save':'confirm'">{{ saveFlag ? '保存' : '确定' }}
         </DkButton>
-        <DkButton v-if="cancelVisibleFlag" @click="modalCancel" name="close" :ref="saveFlag?'close':'cancel'">{{ saveFlag ? '关闭(X)' : '取消(Y)' }}</DkButton>
+        <DkButton v-if="cancelVisibleFlag" @click="modalCancel" name="close" :ref="saveFlag?'close':'cancel'">{{ saveFlag ? '关闭' : '取消' }}</DkButton>
       </div>
     </Modal>
   </div>

+ 287 - 100
src/view/pdm/qci/index.vue

@@ -63,29 +63,29 @@
 
       <Col :span="leftHide?24:16" class="full" style="padding: 5px">
         <Card class="full">
-          <Form ref="formInline" v-model="formData" style="width: 100%" inline>
+          <Form ref="formInline" v-model="pdtData" style="width: 100%" inline>
             <FormItem :label="$t('inspectUserCode')" style="width: 32%">
               <Input size="large" v-model="$store.state.user.userCode" disabled/>
             </FormItem>
             <FormItem :label="$t('pdtBarcode')" style="width: 32%">
-              <Input size="large" v-model="productCode"/>
+              <Input size="large" v-model="productCode" @on-enter="getProductByCode"/>
             </FormItem>
             <FormItem style="width: 32%">
               <br/>
               <div style="display: flex; width: 100%">
-                <Button type="primary" long @click="getProductByCode">产品查询</Button>
-                <Button type="primary" style="margin-left: 10px">检验合格</Button>
+                <Button type="primary" long @click="getProductByCode" :disabled="!qciPlan">产品查询</Button>
+                <Button type="primary" style="margin-left: 10px" @click="checkResult">检验合格</Button>
               </div>
             </FormItem>
 
             <FormItem :label="$t('productCode')" style="width: 32%">
-              <Input size="large" v-model="formData.modelCode" disabled/>
+              <Input size="large" v-model="pdtData.modelCode" disabled/>
             </FormItem>
             <FormItem :label="$t('productName')" style="width: 32%">
-              <Input size="large" v-model="formData.modelName" disabled/>
+              <Input size="large" v-model="pdtData.modelName" disabled/>
             </FormItem>
             <FormItem :label="$t('pdtLogo')" style="width: 32%">
-              <Input size="large" v-model="formData.logoName" disabled/>
+              <Input size="large" v-model="pdtData.logoName" disabled/>
             </FormItem>
           </Form>
 
@@ -107,14 +107,19 @@
             </Col>
           </Row>
 
-<!--          <div :style="'overflow: auto; height:' + standardItemHeight + 'px;'">-->
-          <div :style="'overflow: auto;'">
-            <Row v-for="item of standardItemList" :key="item.stdItemId" style="margin-top: 10px">
+          <div :style="'overflow: auto; height:' + standardItemHeight + 'px;'">
+<!--          <div :style="'overflow: auto;'">-->
+            <Row v-for="(item, index) of standardItemList" :key="item.stdItemId" style="margin-top: 10px" @click.native="clickStandardItem(index)"
+                 :class="index === currentStandardItemIndex ? 'current-standard-item':'no-current-standard-item'">
               <Col span="6" class="standard-item">
-                <Input size="large" v-model="item.qciItemName" disabled/>
+                <div class="ivu-form-item-required" style="display: flex">
+                  <Input size="large" v-model="item.itemName" disabled/>
+                  <span v-if="item.flgMust" class="ivu-form-item-label" style="margin-left: 2px"></span>
+                  <span v-else style="width: 10px; margin-left: 2px"></span>
+                </div>
               </Col>
               <Col span="8" class="standard-item">
-                <Poptip trigger="click" style="width: 100%">
+                <Poptip transfer trigger="click" style="width: 100%">
                   <Input size="large" v-model="item.inspStandard" disabled/>
                   <div slot="content">{{ item.inspStandard }}</div>
                 </Poptip>
@@ -134,8 +139,8 @@
                   </div>
                 </Poptip>
               </Col>
-              <Col span="3" class="standard-item">
-                <i-switch :value="item.determineResult === '检验结果-合格'" @on-change="(val) => changeDetermineResult(val, item)" />
+              <Col span="3" class="standard-item" style="align-self: center;">
+                <i-switch :value="item.determineResult === '检验结果-合格'" @on-change="(val) => changeDetermineResult(val, item)"/>
 <!--                <Select transfer v-model="item.determineResult">-->
 <!--                  <Option v-for="item in fitErrorReasonList" :value="item.value" :key="item.value">{{ item.label }}</Option>-->
 <!--                </Select>-->
@@ -147,7 +152,7 @@
           </div>
 
           <div style="width: 100%; position: absolute; bottom: 60px;font-size: 16px !important;line-height: 32px"
-               v-if="fitFlag">
+               v-if="fitFlag" id="fit-list">
             <Row style="margin-top: 10px">
               <Col span="6">
                 物料编码
@@ -166,25 +171,27 @@
               </Col>
             </Row>
 
-            <Row v-for="item of skuList" :key="item.itemId" style="margin-top: 10px">
-              <Col span="6">
-                {{item.modelCode}}
-              </Col>
-              <Col span="6">
-                {{item.modelName}}
-              </Col>
-              <Col span="3">
-                <Radio :value="item.flgResult" @on-change="$set(item, 'flgResult',true)"></Radio>
-              </Col>
-              <Col span="3">
-                <Radio :value="item.flgResult==false" @on-change="$set(item, 'flgResult',false)"></Radio>
-              </Col>
-              <Col span="3" v-show="item.flgResult==false">
-                <Select transfer v-model="item.fitErrorId">
-                  <Option v-for="item in fitErrorReasonList" :value="item.dataId" :key="item.value">{{ item.dataValue }}</Option>
-                </Select>
-              </Col>
-            </Row>
+            <div v-if="currentStandardItemIndex!=null && standardItemList[currentStandardItemIndex]">
+              <Row v-for="item of standardItemList[currentStandardItemIndex].qciRecordFitList" :key="item.itemId" style="margin-top: 10px;">
+                <Col span="6">
+                  {{item.modelCode}}
+                </Col>
+                <Col span="6">
+                  {{item.modelName}}
+                </Col>
+                <Col span="3">
+                  <Radio :value="item.flgResult" @on-change="$set(item, 'flgResult',true)"></Radio>
+                </Col>
+                <Col span="3">
+                  <Radio :value="item.flgResult==false" @on-change="$set(item, 'flgResult',false)"></Radio>
+                </Col>
+                <Col span="3" v-show="item.flgResult==false">
+                  <Select transfer v-model="item.fitErrorId">
+                    <Option v-for="item in fitErrorReasonList" :value="item.dataId" :key="item.value">{{ item.dataValue }}</Option>
+                  </Select>
+                </Col>
+              </Row>
+            </div>
           </div>
 
           <div class="footer-btn">
@@ -197,7 +204,7 @@
             </Col>
             <Col span="1"/>
             <Col span="14">
-              <Button type="primary" long>保存</Button>
+              <Button type="primary" long @click="save" :disabled="!standardItemList.length">保存</Button>
             </Col>
           </div>
         </Card>
@@ -224,7 +231,7 @@
 
     <!--  键盘  -->
 <!--    <div :style="{bottom:keyboardFlag?'0px':'-350px'}" class="key-board-div">-->
-<!--      <SimpleKeyboard @onChange="onChangeKeyboard($event)" @onKeyPress="onKeyPress" :input="formData.barCode"/>-->
+<!--      <SimpleKeyboard @onChange="onChangeKeyboard($event)" @onKeyPress="onKeyPress" :input="pdtData.barCode"/>-->
 <!--    </div>-->
   </div>
 </template>
@@ -251,9 +258,11 @@ export default {
           standardItemList: [],
           skuList: [],
           qciTypeId: null,
+          qciPlan: null,
           qciTypeList: [],
-          productCode: '23120408',
-          formData: {},
+          productCode: null,
+          pdtData: {},
+          materialBom: null,
           options: [
             {
               value: 0,
@@ -278,6 +287,8 @@ export default {
           workSopHide: false,
           standardModal: false,
           workSop: null,
+          //当前计划明细行
+          currentStandardItemIndex: null,
         }
     },
   computed: {
@@ -292,7 +303,7 @@ export default {
        * @date   : 2023-07-05 15:01
        */
       onChangeKeyboard(input) {
-        this.formData.barCode = input;
+        this.pdtData.barCode = input;
       },
       /**
        * @desc   : 键盘按钮点击
@@ -327,7 +338,7 @@ export default {
         }
       },
       getPlan(){
-        this.planItemList = []
+        this.clearAll()
         request(this.$service.qciPlanService.prefix + this.$service.qciPlanService.selectByCond, {
           planDateStart: new Date().format('yyyy-MM-dd'),
           planDateEnd: new Date().format('yyyy-MM-dd'),
@@ -338,6 +349,7 @@ export default {
           if (res.code === this.$config.SUCCESS_CODE) {
             if (res.data.total === 1) {
               this.qciTypeId = res.data.list[0].qciType
+              this.qciPlan = res.data.list[0]
               this.getPlanItem(res.data.list[0].planId)
             }
           } else {
@@ -355,36 +367,37 @@ export default {
           planId: id
         }).then(res => {
           if (res.code === this.$config.SUCCESS_CODE) {
-            let currentQci = this.qciTypeList.filter(f => f.typeId === this.qciTypeId)
-            if (currentQci.length) {
-              let planCalculation = currentQci[0].planCalculation
-              if (planCalculation === 1) {
-                // 百分比
-                for (let it of res.data.list) {
-                  it.planQty = parseInt((it.poutQty * currentQci[0].percentage / 100).toFixed(0))
-                }
-                this.planItemList = res.data.list
-              } else if (planCalculation === 2) {
-                // 阶梯
-                request(this.$service.qciTypeStepService.prefix + this.$service.qciTypeStepService.selectByCond, {
-                  typeId: currentQci[0].typeId
-                }).then(res2=>{
-                  if (res2.code === this.$config.SUCCESS_CODE) {
-                    for (let it of res.data.list) {
-                      let typeStep = res2.data.list.filter(f => f.stepBegin <= it.poutQty && f.stepEnd >= it.poutQty)
-                      if (typeStep.length) {
-                        it.planQty = typeStep[0].planQty
-                      }
-                    }
-                    this.planItemList = res.data.list
-                  } else {
-                    this.$Message.warning(res2.message)
-                  }
-                })
-              }
-            } else {
-              this.planItemList = res.data.list
-            }
+            this.planItemList = res.data.list
+            // let currentQci = this.qciTypeList.filter(f => f.typeId === this.qciTypeId)
+            // if (currentQci.length) {
+            //   let planCalculation = currentQci[0].planCalculation
+            //   if (planCalculation === 1) {
+            //     // 百分比
+            //     for (let it of res.data.list) {
+            //       it.planQty = parseInt((it.poutQty * currentQci[0].percentage / 100).toFixed(0))
+            //     }
+            //     this.planItemList = res.data.list
+            //   } else if (planCalculation === 2) {
+            //     // 阶梯
+            //     request(this.$service.qciTypeStepService.prefix + this.$service.qciTypeStepService.selectByCond, {
+            //       typeId: currentQci[0].typeId
+            //     }).then(res2=>{
+            //       if (res2.code === this.$config.SUCCESS_CODE) {
+            //         for (let it of res.data.list) {
+            //           let typeStep = res2.data.list.filter(f => f.stepBegin <= it.poutQty && f.stepEnd >= it.poutQty)
+            //           if (typeStep.length) {
+            //             it.planQty = typeStep[0].planQty
+            //           }
+            //         }
+            //         this.planItemList = res.data.list
+            //       } else {
+            //         this.$Message.warning(res2.message)
+            //       }
+            //     })
+            //   }
+            // } else {
+            //   this.planItemList = res.data.list
+            // }
           } else {
             this.$Message.warning(res.message)
           }
@@ -451,6 +464,9 @@ export default {
                   it.inspValues.push(0)
                 }
               }
+
+              it.qciRecordFitList = JSON.parse(JSON.stringify(this.skuList))
+
             }
             this.standardItemList = res.data.list
           } else {
@@ -478,16 +494,30 @@ export default {
        * @date   : 2024-04-01 08:46
        */
       getProductByCode () {
+        if (!this.productCode) {
+          return
+        }
         let params = {
-          barCode: this.productCode,
+          productCode: this.productCode,
+          planId: this.qciPlan.planId
         }
-        request(this.$service.collectService.prefix + this.$service.collectService.getProductByCode, params).then(res=>{
+        request(this.$service.qciRecordService.prefix + this.$service.qciRecordService.getRecordByPdtCode, params).then(res=>{
           if (res.code === this.$config.SUCCESS_CODE) {
-            this.formData = res.data
-            this.getStandard(res.data.modelId)
-            this.getModelProduct(res.data.modelId)
-            this.getWorkSop(res.data.modelId)
+            if (res.data.recordId) {
+              this.pdtData = res.data
+              //有过记录
+              this.standardItemList = res.data.qciRecordItemList
+              this.getWorkSop(res.data.pdtModelId)
+              // this.setStandardListHeight()
+            } else {
+              //没有记录
+              this.pdtData = res.data
+              this.getStandard(res.data.modelId)
+              this.getModelProduct(res.data.modelId)
+              this.getWorkSop(res.data.modelId)
+            }
           } else {
+            this.clear()
             this.$Message.warning(res.message)
           }
         })
@@ -516,19 +546,18 @@ export default {
        */
       getMaterialBom(defErpSkuId) {
         if (defErpSkuId) {
-          let today = new Date().format('yyyy-MM-dd')
           request(this.$service.materialBomService.prefix + this.$service.materialBomService.selectByCond, {
-            validityDateStart: today,
-            validityDateEnd: today,
+            validityDate: new Date().format('yyyy-MM-dd'),
             matModelId: defErpSkuId
           }).then(res=>{
             if (res.code === this.$config.SUCCESS_CODE) {
               if (res.data.total === 1) {
+                this.materialBom = res.data.list[0]
                 request(this.$service.materialBomItemService.prefix + this.$service.materialBomItemService.selectByCond, {
                   bomId: res.data.list[0].bomId
                 }).then(res2=>{
                   if (res2.code === this.$config.SUCCESS_CODE) {
-                    this.skuList = res2.data.list
+                    this.skuList = res2.data.list.filter(f => f.flgFitting)
                   } else {
                     this.$Message.warning(res2.message)
                   }
@@ -538,21 +567,26 @@ export default {
               this.$Message.warning(res.message)
             }
           })
-
-          request(this.$service.commonService.prefix + this.$service.commonService.getDictionaryData, {
-            ftyId: this.$store.state.user.ftyId,
-            dictCode: this.$config.dictType.fitErrorReason
-          }).then(res=>{
-            if (res.code === this.$config.SUCCESS_CODE) {
-              this.fitErrorReasonList = res.data
-            } else {
-              this.$Message.warning(res.message)
-            }
-          })
-
         }
       },
       /**
+       * @desc   : 查询错误原因
+       * @author : 洪旭东
+       * @date   : 2024-04-03 08:52
+       */
+      getErrorReason () {
+        request(this.$service.commonService.prefix + this.$service.commonService.getDictionaryData, {
+          ftyId: this.$store.state.user.ftyId,
+          dictCode: this.$config.dictType.fitErrorReason
+        }).then(res=>{
+          if (res.code === this.$config.SUCCESS_CODE) {
+            this.fitErrorReasonList = res.data
+          } else {
+            this.$Message.warning(res.message)
+          }
+        })
+      },
+      /**
        * @desc   : 查询检验标准
        * @author : 洪旭东
        * @date   : 2024-04-01 08:46
@@ -601,24 +635,37 @@ export default {
         this.leftHide = !this.leftHide
       },
       /**
+       * @desc   : 恢复默认检验结果
+       * @author : 洪旭东
+       * @date   : 2024-04-02 08:53
+       */
+      checkResult () {
+        for (let item of this.standardItemList) {
+          if (item.itemKind === '品检项类-定性') {
+            this.changeInspValue(item)
+          } else if (item.itemKind === '品检项类-定量') {
+            this.setInspValues(item)
+          }
+        }
+      },
+      /**
        * @desc   : 检验值失焦事件
        * @author : 洪旭东
        * @date   : 2024-04-01 11:39
        */
       setInspValues (item, index) {
         this.$nextTick(()=>{
-          this.$set(item.inspValues, index, parseFloat(parseFloat(item.inspValues[index]).toFixed(6)))
-          console.log(item)
+          if (index!=null) {
+            this.$set(item.inspValues, index, parseFloat(parseFloat(item.inspValues[index]).toFixed(6)))
+          }
           //找出数组中最小值
           if (item.inspValueKind === '品检取值-最小') {
             item.inspValue = item.inspValues.map(f => parseFloat(f)).min()
           } else if (item.inspValueKind === '品检取值-最大') {
             item.inspValue = item.inspValues.map(f => parseFloat(f)).max()
           } else if (item.inspValueKind === '品检取值-平均') {
-            console.log('item.inspValues.map(f => parseFloat(f)).reduce((acc, cur) => (cur + acc), 0)', item.inspValues.map(f => parseFloat(f)).reduce((acc, cur) => (cur + acc), 0))
             item.inspValue = item.inspValues.map(f => parseFloat(f)).reduce((acc, cur) => (cur + acc), 0) / item.inspValues.length
           }
-          console.log('item.inspValue = ', item.inspValue)
           if ((item.refValueMax == null || item.inspValue < item.refValueMax) && (item.refValueMin == null || item.inspValue > item.refValueMin)) {
             this.$set(item, 'determineResult', '检验结果-合格')
           } else {
@@ -643,14 +690,143 @@ export default {
       changeInspValue (item) {
         this.$set(item, 'determineResult', item.inspValue==0?'检验结果-合格':'检验结果-不合格')
       },
+      /**
+       * @desc   : 店家标准明细
+       * @author : 洪旭东
+       * @date   : 2024-04-02 10:47
+       */
+      clickStandardItem(index) {
+        this.currentStandardItemIndex = index
+        this.setStandardListHeight()
+      },
+      /**
+       * @desc   : 保存
+       * @author : 洪旭东
+       * @date   : 2024-04-02 08:58
+       */
+      save () {
+        if (this.pdtData.recordId) {
+          this.update()
+        } else {
+          this.insert()
+        }
+      },
+      /**
+       * @desc   : 新建
+       * @author : 洪旭东
+       * @date   : 2024-04-03 09:12
+       */
+      insert() {
+        let data = {
+          planId: this.qciPlan.planId,
+          planDate: this.qciPlan.planDate,
+          qciType: this.qciTypeId,
+          pdtUniqueId: this.pdtData.uniqueId,
+          pdtModelId: this.pdtData.modelId,
+          qciRecordItemList: this.standardItemList.map(m => {
+            return {
+              pdtUniqueId: this.pdtData.uniqueId,
+              stdId: m.stdId,
+              qciItemId: m.qciItemId,
+              itemName: m.itemName,
+              inspTool: m.inspTool,
+              inspMethod: m.inspMethod,
+              inspStandard: m.inspStandard,
+              inspInstruction: m.inspInstruction,
+              itemKind: m.itemKind,
+              refValueMax: m.refValueMax,
+              refValueMin: m.refValueMin,
+              refValueUnit: m.refValueUnit,
+              inspNum: m.inspNum,
+              inspValueKind: m.inspValueKind,
+              flgMust: m.flgMust,
+              inspValues: m.inspValues,
+              inspValue: m.inspValue,
+              determineResult: m.determineResult,
+
+              qciRecordFitList: m.qciRecordFitList.map(mm => {
+                return {
+                  pdtUniqueId: this.pdtData.uniqueId,
+                  matModelId: mm.matModelId,
+                  matItemModelId: mm.itemModelId,
+                  matBomId: mm.bomId,
+                  matBomItemId: mm.itemId,
+                  flgResult: mm.flgResult,
+                  fitErrorId: mm.fitErrorId
+                }
+              })
+            }
+          })
+        }
+        this.excute(this.$service.qciRecordService, this.$service.qciRecordService.insert, data).then(res=>{
+          if (res.code === this.$config.SUCCESS_CODE) {
+            this.$Message.success(this.$t('I_002'))
+            let planItems = this.planItemList.filter(f => f.pdtModelId === this.pdtData.modelId)
+            if (planItems.length) {
+              planItems[0].compQty++
+            } else {
+              this.planItemList.push({
+                pdtModelId: this.pdtData.modelId,
+                pdtModelCode: this.pdtData.modelCode,
+                materialModelCode: this.materialBom.modelCode,
+                compQty: 1,
+                planQty: 0,
+                poutQty: 0
+              })
+            }
+            this.clear()
+          } else {
+            this.$Message.warning(res.message)
+          }
+        })
+      },
+      /**
+       * @desc   : 编辑
+       * @author : 洪旭东
+       * @date   : 2024-04-03 09:12
+       */
+      update() {
+        this.excute(this.$service.qciRecordService, this.$service.qciRecordService.update, this.pdtData).then(res=>{
+          if (res.code === this.$config.SUCCESS_CODE) {
+            this.$Message.success(this.$t('I_002'))
+            this.clear()
+          } else {
+            this.$Message.warning(res.message)
+          }
+        })
+      },
+      clear(){
+        this.pdtData = {}
+        this.standardList = []
+        this.standardItemList = []
+        this.materialBom = null
+        this.currentStandardItemIndex = null
+        this.productCode = null
+      },
+      clearAll(){
+        this.qciPlan = null
+        this.planItemList = []
+        this.clear()
+      },
+      setStandardListHeight(){
+        this.$nextTick(()=>{
+          let fitHeight = 42
+          if (document.getElementById('fit-list')) {
+            fitHeight = document.getElementById('fit-list').clientHeight
+          }
+          this.standardItemHeight = document.documentElement.clientHeight - 370 - fitHeight
+        })
+      }
     },
     created(){
       this.getPlan()
       this.getQciType()
-      this.getProductByCode()
+      this.getErrorReason()
       this.planItemHeight = document.documentElement.clientHeight - 160
-      this.standardItemHeight = document.documentElement.clientHeight - 370
-    }
+    },
+  mounted() {
+    this.setStandardListHeight()
+  }
 }
 </script>
 
@@ -700,7 +876,14 @@ export default {
   color: white !important;
 }
 
-/deep/ .ivu-poptip-rel{
+.current-standard-item{
+  border: 1px solid #57a3f3;
+}
+.no-current-standard-item{
+  border: 1px solid #ffffff;
+}
+
+.ivu-poptip-body-content > div{
   font-size: 18px;
 }
 /deep/ .ivu-btn > span {
@@ -718,4 +901,8 @@ export default {
 /deep/.ivu-poptip-body-content{
   font-size: 18px !important;
 }
+
+.ivu-switch{
+  margin-top: 0 !important;
+}
 </style>