#
zhou zhou
2 天以前 58b41dc039c5c9d1b758c9e190a7c35225ad7585
pages/InManagement/ContainerBinding/Container_Binding.vue
@@ -2,7 +2,7 @@
   <view class="page-container">
      <!-- 头部导航 -->
      <u-navbar
         title="组托"
         :title="$t('container.title')"
         :fixed="true"
         :placeholder="true"
         bgColor="#ffffff"
@@ -25,13 +25,13 @@
                           color="#409eff"
                           customStyle="margin-right: 10rpx;"
                        ></u-icon>
                        <text class="label-text">托盘码</text>
                        <text class="label-text">{{ $t('container.palletCode') }}</text>
                     </view>
                  </template>
                  <view class="input-wrap">
                     <u--input
                        v-model="barcode"
                        placeholder="扫码 / 输入托盘码"
                        :placeholder="$t('container.scanPallet')"
                        clearable
                        border="none"
                        :focus="barcodeFocus"
@@ -47,13 +47,13 @@
                           color="#409eff"
                           customStyle="margin-right: 10rpx;"
                        ></u-icon>
                        <text class="label-text">物料码</text>
                        <text class="label-text">{{ $t('container.matCode') }}</text>
                     </view>
                  </template>
                  <view class="input-wrap">
                     <u--input
                        v-model="matnr"
                        placeholder="扫码 / 输入物料码"
                        :placeholder="$t('container.scanMat')"
                        clearable
                        border="none"
                        :focus="matFocus"
@@ -70,7 +70,7 @@
         <view class="list-header">
            <view class="title-indicator"></view>
            <text class="header-title">
               商品列表 ({{ dataList.length }})
               {{ $t('container.matList') }} ({{ dataList.length }})
            </text>
         </view>
@@ -86,33 +86,9 @@
               </view>
               <view class="card-content">
                  <view class="info-row">
                     <text class="info-label">品名</text>
                     <text class="info-value">
                        {{ item.maktx || '-' }}
                     </text>
                  </view>
                  <view class="info-row">
                     <view class="info-col">
                        <text class="info-label">规格</text>
                        <text class="info-value">
                           {{ item.specs || '-' }}
                        </text>
                     </view>
                     <view class="info-col">
                        <text class="info-label">批号</text>
                        <text class="info-value highlight">
                           {{ item.batch || '-' }}
                        </text>
                     </view>
                  </view>
                  <view class="info-row">
                     <view class="info-col">
                        <text class="info-label">数量</text>
                        <text class="info-value qty">
                           {{ item.anfme }}
                        </text>
                     </view>
                  <view class="info-row" v-for="(field, idx) in displayFields" :key="idx">
                     <text class="info-label">{{ $t(field.label) }}</text>
                     <text class="info-value">{{ item[field.field] || '-' }}</text>
                  </view>
               </view>
@@ -121,7 +97,7 @@
                     type="primary"
                     size="small"
                     plain
                     text="修改"
                     :text="$t('container.modify')"
                     @click="revise(item, i)"
                     customStyle="width: 140rpx; margin: 0;"
                  ></u-button>
@@ -130,7 +106,7 @@
                     type="error"
                     size="small"
                     plain
                     text="移除"
                     :text="$t('container.remove')"
                     @click="remove(item, i)"
                     customStyle="width: 140rpx; margin: 0;"
                  ></u-button>
@@ -140,7 +116,7 @@
            <u-empty
               v-if="dataList.length === 0"
               mode="list"
               text="暂无商品,请扫描物料码添加"
               :text="$t('container.emptyList')"
               marginTop="40"
            ></u-empty>
         </view>
@@ -151,7 +127,7 @@
         <view class="btn-wrap">
            <u-button
               type="info"
               text="重置"
               :text="$t('container.reset')"
               @click="resetConfirmBtn"
            ></u-button>
         </view>
@@ -161,7 +137,7 @@
         >
            <u-button
               type="primary"
               text="确认组托"
               :text="$t('container.confirmComb')"
               @click="combConfirmBtn"
               :disabled="dataList.length === 0"
               :throttleTime="1500"
@@ -177,41 +153,44 @@
         @close="showRevise = false"
      >
         <view class="popup-card">
            <view class="popup-header"><text>修改信息</text></view>
            <view class="popup-header"><text>{{ $t('container.modifyInfo') }}</text></view>
            <view class="popup-body">
               <u--form
                  labelWidth="80"
                  labelPosition="left"
               >
                  <u-form-item label="编码">
                  <u-form-item :label="$t('container.code')">
                     <text class="popup-text-val">{{ editMatnr }}</text>
                  </u-form-item>
                  <u-form-item label="批号">
                     <u--input
                        v-model="batch"
                        placeholder="输入批号"
                        border="surround"
                     ></u--input>
                  </u-form-item>
                  <u-form-item label="数量">
                  <u-form-item
                     v-for="(ef, efIdx) in editFields"
                     :key="efIdx"
                     :label="$t(ef.label)"
                  >
                     <u-number-box
                        v-model="count"
                        v-if="ef.type === 'number'"
                        v-model="editFormData[ef.field]"
                        :step="0.01"
                        :max="9999999"
                        @change="changeValue"
                     ></u-number-box>
                     <u--input
                        v-else
                        v-model="editFormData[ef.field]"
                        :placeholder="$t('settings.inputPlaceholder')"
                        border="surround"
                     ></u--input>
                  </u-form-item>
               </u--form>
            </view>
            <view class="popup-footer">
               <u-button
                  text="取消"
                  :text="$t('common.cancel')"
                  @click="showRevise = false"
                  customStyle="margin-right: 20rpx; flex: 1;"
               ></u-button>
               <u-button
                  type="primary"
                  text="确认"
                  :text="$t('common.confirm')"
                  @click="reviseConfirm"
                  customStyle="flex: 1;"
               ></u-button>
@@ -222,24 +201,24 @@
      <!-- 模态框 -->
      <u-modal
         :show="showRemove"
         title="确认移除"
         content="是否移除该商品?"
         :title="$t('container.confirmRemove')"
         :content="$t('container.removeMsg')"
         showCancelButton
         @confirm="removeConfirm"
         @cancel="showRemove = false"
      ></u-modal>
      <u-modal
         :show="showComb"
         title="确认组托"
         content="确认将商品组托入库?"
         :title="$t('container.confirmComb')"
         :content="$t('container.combMsg')"
         showCancelButton
         @confirm="comb"
         @cancel="showComb = false"
      ></u-modal>
      <u-modal
         :show="showReset"
         title="确认重置"
         content="是否清空所有商品?"
         :title="$t('container.confirmReset')"
         :content="$t('container.resetMsg')"
         showCancelButton
         @confirm="resetConfirm"
         @cancel="showReset = false"
@@ -271,7 +250,42 @@
         showRevise: false,
         showRemove: false,
         showComb: false,
         showReset: false
         showReset: false,
         orderCombNeedSplit: true,
         orderCombSeparator: ';',
         orderCombArrayIndex: 0,
         orderCombStartPos: 3,
         displayFields: [
            { field: 'maktx', label: 'container.matName' },
            { field: 'specs', label: 'container.matSpec' },
            { field: 'batch', label: 'container.matBatch' },
            { field: 'anfme', label: 'container.matQty' }
         ],
         editFields: [
            { field: 'batch', label: 'container.matBatch', type: 'text' },
            { field: 'anfme', label: 'container.matQty', type: 'number' }
         ],
         editFormData: {}
      }
   },
   onShow() {
      let settings = uni.getStorageSync('appSettings')
      if (settings) {
         this.orderCombNeedSplit = settings.orderCombNeedSplit !== false
         this.orderCombSeparator = settings.orderCombSeparator || ';'
         this.orderCombArrayIndex = settings.orderCombArrayIndex !== undefined ? Number(settings.orderCombArrayIndex) : 0
         this.orderCombStartPos = settings.orderCombStartPos !== undefined ? Number(settings.orderCombStartPos) : 3
         if (settings.containerBindingFields && settings.containerBindingFields.length > 0) {
            this.displayFields = settings.containerBindingFields
         }
         if (settings.containerBindingEditFields && settings.containerBindingEditFields.length > 0) {
            this.editFields = settings.containerBindingEditFields
         }
      } else {
         this.orderCombNeedSplit = true
         this.orderCombSeparator = ';'
         this.orderCombArrayIndex = 0
         this.orderCombStartPos = 3
      }
   },
   methods: {
@@ -281,7 +295,7 @@
            if (len > 0 && len !== 8 && len !== 9) {
               this.$showToast({
                  type: 'error',
                  message: '托盘码有误请重试'
                  message: this.$t('toast.palletError')
               })
               this.barcodeFocuss()
               return
@@ -305,9 +319,15 @@
      },
      async findMat(val) {
         if (!this.matnr) return
         let matnr1 = this.matnr
         if (this.orderCombNeedSplit) {
            let m = this.matnr.split(this.orderCombSeparator)
            let targetChunk = m[this.orderCombArrayIndex] || m[0]
            matnr1 = targetChunk.slice(this.orderCombStartPos)
         }
         try {
            const { code, data, msg } = await findMatAuth(
               { matnr: this.matnr },
               { matnr: matnr1 },
               { custom: { catch: true } }
            )
            if (code === 200 && data) {
@@ -339,7 +359,7 @@
               if (!data && data !== null) {
                  this.$showToast({
                     type: 'error',
                     message: msg || '查询失败'
                     message: msg || this.$t('toast.queryFail')
                  })
               }
            }
@@ -378,21 +398,20 @@
      },
      revise(item, i) {
         this.editMatnr = this.dataList[i].matnr
         this.count = this.dataList[i].anfme
         this.batch = this.dataList[i].batch
         this.weight = this.dataList[i].weight
         this.rowNum = i
         var formData = {}
         this.editFields.forEach(ef => {
            formData[ef.field] = this.dataList[i][ef.field] !== undefined ? String(this.dataList[i][ef.field]) : ''
         })
         this.editFormData = formData
         this.showRevise = true
      },
      changeValue(e) {
         this.count = e.value
      },
      reviseConfirm() {
         this.dataList[this.rowNum].anfme = this.count
         this.dataList[this.rowNum].batch = this.batch
         this.dataList[this.rowNum].weight = this.weight
         this.editFields.forEach(ef => {
            this.dataList[this.rowNum][ef.field] = this.editFormData[ef.field]
         })
         this.editMatnr = ''
         this.$showToast({ type: 'success', message: '修改成功' })
         this.$showToast({ type: 'success', message: this.$t('toast.modifySuccess') })
         this.showRevise = false
      },
      remove(item, i) {
@@ -401,7 +420,7 @@
      },
      removeConfirm() {
         this.dataList.splice(this.removeNum, 1)
         this.$showToast({ type: 'success', message: '移除成功' })
         this.$showToast({ type: 'success', message: this.$t('toast.removeSuccess') })
         this.showRemove = false
      },
      combConfirmBtn() {
@@ -410,7 +429,7 @@
      },
      async comb() {
         if (this.barcode === '') {
            this.$showToast({ type: 'error', message: '请扫描托盘条码' })
            this.$showToast({ type: 'error', message: this.$t('toast.scanPalletCode') })
            this.showComb = false
            return
         }
@@ -421,7 +440,7 @@
            ) {
               this.$showToast({
                  type: 'error',
                  message: this.dataList[i].matnr + '组托数量不能为0'
                  message: this.$t('toast.qtyNotZeroMat').replace('{0}', this.dataList[i].matnr)
               })
               this.showComb = false
               return
@@ -442,7 +461,7 @@
            if (code === 200) {
               this.resst()
               this.$showToast({ type: 'success', message: '组托成功' })
               this.$showToast({ type: 'success', message: this.$t('toast.combSuccess') })
            } else if (code === 403) {
               this.$showToast({ type: 'error', message: msg })
               setTimeout(() => {
@@ -451,7 +470,7 @@
            } else {
               this.$showToast({
                  type: 'error',
                  message: msg || '组托失败'
                  message: msg || this.$t('toast.combFail')
               })
            }
         } catch (err) {
@@ -464,7 +483,7 @@
      resetConfirm() {
         this.dataList = []
         this.barcode = ''
         this.$showToast({ type: 'success', message: '重置完成' })
         this.$showToast({ type: 'success', message: this.$t('toast.resetComplete') })
         this.showReset = false
      },
      resst() {