Mr.Shi
2023-09-06 0256141ad70be0d254fd9958e8d28867db1d7531
minipro_standard/pages_adjust/pages/addReceipt/addReceipt.vue
@@ -20,23 +20,24 @@
         <view class="rework_qd_title">
            <view class="rework_qd_title_left">
               <view class="x"></view>
               <text>{{`入库物料清单${list.length}`}}</text>
               <text>入库物料清单</text>
            </view>
            <view class="rework_qd_title_right" @click="addItem()">
               <image src="@/static/gongdan_ic_shoudong@2x.png" mode="widthFix"></image>
               <text>增加入库</text>
            </view>
         </view>
         <van-swipe-cell v-for="(item, index) in list" :key="index">
         <u-swipe-action :autoClose="true">
            <u-swipe-action-item v-for="(item, index) in list" :key="index" @click="dele($event, index)" :options="item.options">
            <view class="rework_qd_list">
               <view class="rework_qd_item" @click="locationShow = true">
                  <view class="rework_qd_item" @click="openL(index)">
                  <text><b>*</b>入库货位</text>
                  <view class="rework_qd_item_right">
                     <text :class="item.locationName ? 'black' : ''">{{item.locationName ? item.locationName : '请选择'}}</text>
                     <u-icon name="arrow-right"></u-icon>
                  </view>
               </view>
               <view class="rework_qd_item" @click="materialsShow = true">
                  <view class="rework_qd_item" @click="openMaterial(index)">
                  <text><b>*</b>入库物料</text>
                  <view class="rework_qd_item_right">
                     <text :class="item.materialName ? 'black' : ''">{{item.materialName ? item.materialName : '请选择'}}</text>
@@ -44,7 +45,7 @@
                  </view>
               </view>
               <template v-if="form.type !== 25">
                  <view class="rework_qd_item" @click="productionShow = true">
                     <view class="rework_qd_item" @click="openGX(index)">
                     <text>生产工序</text>
                     <view class="rework_qd_item_right">
                        <text :class="item.procedureName ? 'black' : ''">{{item.procedureName ? item.procedureName : '请选择'}}</text>
@@ -52,7 +53,7 @@
                     </view>
                  </view>
               </template>
               <view class="rework_qd_item" @click="qualityShow = true">
                  <view class="rework_qd_item" @click="openQ(index)">
                  <text><b>*</b>质量属性</text>
                  <view class="rework_qd_item_right">
                     <text :class="item.qualityTypeName ? 'black' : ''">{{item.qualityTypeName ? item.qualityTypeName : '请选择'}}</text>
@@ -72,15 +73,13 @@
                  </view>
               </view>
            </view>
            <template #right>
               <van-button style="height: 100%;" square type="danger" text="删除" @click="dele(index)" />
            </template>
         </van-swipe-cell>
            </u-swipe-action-item>
         </u-swipe-action>
      </view>
      <view class="rework_zw"></view>
      <!-- 底部操作按钮 -->
      <view class="rework_footer">
         <button class="rework_footer_submit">提交</button>
         <button class="rework_footer_submit" @click="onConfirm()">提交</button>
      </view>
      <u-toast ref="uToast"></u-toast>
      <!-- 仓库 -->
@@ -90,7 +89,7 @@
      <!-- 货位 -->
      <location :show="locationShow" :list="locationList" @close="close3" @value="getValue3" />
      <!-- 工序 -->
      <ProductionProcess :show="productionShow" :list="productionList" @close="close4" @value="getValue4" />
      <ProductionProcess :show="productionShow" :list="productionList" @close="productionShow = false" @value="getValue4" />
      <!-- 单据类型 -->
      <u-picker :show="typeShow" keyName="name" :columns="typeList" @confirm="confirm" @cancel="typeClose"></u-picker>
      <!-- 质量属性 -->
@@ -103,6 +102,8 @@
   import location from '../../components/location.vue'
   import Material from '../../components/Material.vue'
   import ProductionProcess from '../../components/ProductionProcess.vue'
   import { getListByWarehouseId, wOutBoundForStockUp } from '@/util/api/WorkOrderAPI'
   import { getListByMaterialId } from '@/util/api/ExWarehouse'
   export default {
      components: { Warehouse, location, Material, ProductionProcess },
      data() {
@@ -138,7 +139,15 @@
                  qualityType: '',
                  qualityTypeName: '',
                  unitId: '',
                  unitName: ''
                  unitName: '',
                  options: [
                     {
                        text: '删除',
                        style: {
                           backgroundColor: '#f56c6c'
                        }
                     }
                  ]
               }
            ],
            typeList: [[{name: '采购入库', id: 25}, {name: '库存调整', id: 28}]],
@@ -151,17 +160,82 @@
         };
      },
      methods: {
         dele(e, index) {
            if (this.list.length === 1) return uni.showToast({ title: '请选择单据类型', icon: 'none', duration: 2000 });
            this.list.splice(index, 1)
         },
         // 选择工序
         getValue4(item) {
            this.list[this.i].procedureId = item.id
            this.list[this.i].procedureName = item.name
            this.productionShow = false
         },
         // 提交
         onConfirm() {
            if (!this.form.type) return uni.showToast({ title: '请选择单据类型', icon: 'none', duration: 2000 });
            if (!this.form.warehouseId) return uni.showToast({ title: '请选择入库仓库', icon: 'none', duration: 2000 });
            if (this.list.length === 0) return uni.showToast({ title: '请先添加入库物料', icon: 'none', duration: 2000 });
            for (let i = 0; i < this.list.length; i++) {
               if (!this.list[i].locationId) return uni.showToast({ title: `第${i+1}项入库货位不能为空`, icon: 'none', duration: 2000 });
               if (!this.list[i].materialId) return uni.showToast({ title: `第${i+1}项入库物料不能为空`, icon: 'none', duration: 2000 });
               if (!this.list[i].qualityType) return uni.showToast({ title: `第${i+1}项质量属性不能为空`, icon: 'none', duration: 2000 });
               if (this.list[i].num <= 0) {
                  return uni.showToast({ title: `第${i + 1}项入库数量必须大于0`, icon: 'none', duration: 2000 });
               }
            }
            wOutBoundForStockUp({
               type: this.form.type,
               planDate: this.getDay(),
               validDate: this.getDay(),
               warehouseId: this.form.warehouseId,
               woutboundInBodyBeanList: this.list
            }).then(res => {
               if (res.code === 200) {
                  uni.showToast({ title: '入库成功', icon: 'success', duration: 2000 });
                  setTimeout(() => {
                     uni.navigateBack({ delta: 1 });
                  }, 2000)
               }
            })
         },
         // 获取当天年月日
         getDay() {
            var date = new Date();
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            var day = date.getDate();
            return `${year}-${month <= 9 ? `0${month}` : month}-${day <= 9 ? `0${day}` : day}`
         },
         // 打开选择物料
         openQ(index) {
            if (this.list[index].locationIdLabel == 'APPLIANCE_ONTEST' || this.list[index].locationIdLabel == 'APPLIANCE_OFFTEST' || this.list[index].locationIdLabel == 'APPLIANCE_USELESS') {
               return
            }
            this.i = index
            this.qualityShow = true
         },
         // 打开工序
         openGX(index) {
            if (!this.list[index].materialId) return uni.showToast({ title: '请先选择入库物料', icon: 'none', duration: 2000 });
            this.i = index
            this.productionShow = true
         },
         // 打开选择货位
         openL(index) {
            if (!this.form.warehouseId) return uni.showToast({ title: '请选择入库仓库', icon: 'none', duration: 2000 });
            this.i = index
            this.locationShow = true
         },
         // 打开选择物料
         openMaterial(index) {
            this.i = index
            this.materialsShow = true
         },
         // 质量属性确认
         onConfirm1(value) {
            this.form.typeName = value.name
            this.form.type = value.id
            if (value.id == 25) {
               this.list.forEach(item => {
                  item.procedureId = ''
                  item.procedureName = ''
               })
            }
            this.typeShow = false
            this.list[this.i].qualityType = value.value[0].id
            this.list[this.i].qualityTypeName = value.value[0].name
            this.qualityShow = false
         },
         // 选择物料
         getValue1(item) {
@@ -175,12 +249,12 @@
               materialId: item.id
            }).then(res => {
               if (res.code === 200) {
                  productionList.value = res.data
                  this.productionList = res.data
                  this.list[this.i].procedureId = ''
                  this.list[this.i].procedureName = ''
               }
            })
            materialsShow.value = false
            this.materialsShow = false
         },
         // 关闭仓库选择弹框
         close1() {
@@ -213,12 +287,48 @@
         confirm(val) {
            this.form.type = val.value[0].id
            this.form.typeName = val.value[0].name
            if (val.value[0].id == 25) {
               this.list.forEach(item => {
                  item.procedureId = ''
                  item.procedureName = ''
               })
            }
            this.typeShow = false
         },
         // 仓库确认
         getValue(val) {
            this.form.warehouseName = val.name
            this.form.warehouseId = val.id
            getListByWarehouseId({ wareHouseId: val.id })
               .then(res => {
                  if (res.code === 200) {
                     this.locationList = res.data
                     if (res.data.length === 1) {
                        this.location = false
                        this.list.forEach(item => {
                           item.locationId = res.data[0].id
                           item.locationName = res.data[0].unionName
                        })
                        this.list[this.i].locationIdLabel = res.data[0].label
                        if (res.data[0].label === 'APPLIANCE_ONTEST') {
                           this.list[this.i].qualityType = '0'
                           this.list[this.i].qualityTypeName = '合格'
                        } else if (res.data[0].label === 'APPLIANCE_OFFTEST') {
                           this.list[this.i].qualityType = '1'
                           this.list[this.i].qualityTypeName = '不良'
                        } else if (res.data[0].label === 'APPLIANCE_USELESS') {
                           this.list[this.i].qualityType = '2'
                           this.list[this.i].qualityTypeName = '报废'
                        }
                     } else {
                        this.location = true
                        this.list.forEach(item => {
                           item.locationId = res.data[0].id
                           item.locationName = res.data[0].unionName
                        })
                     }
                  }
               })
            this.warehouseShow = false
         },
         typeClose() {
@@ -230,7 +340,7 @@
         // 添加明细
         addItem() {
            if (!this.form.warehouseId) return this.$refs.uToast.show({ type: 'default', message: "请选择入库仓库" })
            this.list.push({
            this.list.unshift({
               batch: '',
               locationId: this.list[this.list.length - 1].locationId,
               locationName: this.list[this.list.length - 1].locationName,
@@ -244,21 +354,25 @@
               qualityType: this.list[this.list.length - 1].qualityType,
               qualityTypeName: this.list[this.list.length - 1].qualityTypeName,
               unitId: '',
               unitName: ''
            })
         },
         // 删除
         dele(index) {
            if (this.list.length === 1) {
               this.$refs.uToast.show({ type: 'default', message: "至少保留一条物流清单信息" })
               return
               unitName: '',
               options: [
                  {
                     text: '删除',
                     style: {
                        backgroundColor: '#f56c6c'
            }
            this.list.splice(index, 1)
                  }
               ]
            })
         }
      }
   }
</script>
<style>
   .u-swipe-action-item__right {
      z-index: 9;
   }
</style>
<style lang="scss" scoped>
   .rework {
      width: 100%;