bug
jiangping
2023-12-06 1f4e7d0f73a73e7350cf5a1df279d5f30904c5d5
minipro_standard/pages/allocation/allocation.vue
@@ -21,7 +21,7 @@
               <u-icon name="arrow-right" color="#999999"></u-icon>
            </view>
         </view>
         <view class="fp_list_item" @click="show = true">
         <view class="fp_list_item" @click="show1 = true">
            <view class="fp_list_item_left">
               <text>生产设备</text>
            </view>
@@ -36,10 +36,20 @@
               <text>生产人员</text>
            </view>
            <view class="fp_list_item_right">
               <u-checkbox-group v-model="form.personnelId" v-show="personnelData.length > 0">
                  <u-checkbox :name="item.id" v-for="(item, index) in personnelData" :key="index" activeColor="#4275FC">{{item.text}}</u-checkbox>
               </u-checkbox-group>
               <view class="wu" v-show="personnelData.length === 0">
               <template v-if="personnelData.length > 0">
                  <u-checkbox-group
                     placement="column"
                     @change="checkboxChange">
                     <u-checkbox
                        :customStyle="{marginBottom: '16rpx'}"
                        v-for="(item, index) in personnelData"
                        :key="index"
                        :label="item.text"
                        :name="item.id">
                     </u-checkbox>
                  </u-checkbox-group>
               </template>
               <view class="wu" v-else>
                  <text>暂无数据</text>
               </view>
            </view>
@@ -52,17 +62,19 @@
      <!-- 选择日期 -->
      <u-calendar :show="timeShow" @close="timeShow = false" @confirm="timeConfirm"></u-calendar>
      <!-- 选择设备 -->
      <u-picker :show="show" :columns="columns" @confirm="confirm" @cancel="show = false" keyName="label"></u-picker>
      <u-picker :show="show1" :columns="equipment" @confirm="confirm" @cancel="show1 = false" keyName="text"></u-picker>
   </view>
</template>
<script>
   import { gsdate } from '@/util/utils.js'
   import { distributeById, getFindAll, getDeviceByCondition } from '@/util/api/PlanningAPI'
   export default {
      data() {
         return {
            show: false,
            columns: [[{ label: '设备一' }]],
            id: null,
            show1: false,
            checkboxValue1: [],
            form: {
               num: '',        // 生产数量
               startTime: gsdate(new Date()),      // 开始时间
@@ -70,25 +82,80 @@
               equipmentName: '',    // 设备名称 
               personnelId: []    // 人员id
            },
            isOpenDate: false,
            equipment: [],   // 设备数据
            personnelData: [],    // 人员数据
            timeShow: false
         };
      },
      onLoad(option) {
         this.form.num = option.num
         this.id = option.jhid
         this.getDeviceByConditions()
      },
      methods: {
         checkboxChange(ids) {
            this.form.personnelId = ids;
         },
         go() {
            uni.navigateBack({ delta: 1 });
         },
         // 确认选择设备
         confirm(val) {
            this.form.equipmentName = val.value[0].label
            this.form.equipmentId = 1
            this.show = false
            this.form.equipmentId = val.value[0].id
            this.form.equipmentName = val.value[0].text
            this.personnelData = []
            getFindAll({
               deviceId: this.form.equipmentId
            }).then(res => {
               if (res.code === 200 && res.data && res.data.length !== 0) {
                  this.form.personnelId = []
                  let arr = []
                  res.data.forEach((item) => {
                     arr.push({ text: item.dmodel.name + '-' + item.umodel.name, id: item.userId })
                  })
                  this.personnelData = arr
               }
               this.show1 = false
            })
         },
         timeConfirm(val) {
            this.form.startTime = val[0]
            this.timeShow = false
         },
         // 提交分配
         submit() {
            if (!this.form.num) return uni.showToast({ title: '计划生产数量不能为空!', icon: 'none', duration: 2000 });
            if (!this.form.startTime) return uni.showToast({ title: '计划开始日期不能为空!', icon: 'none', duration: 2000 });
            distributeById({
               planId: this.id,
               planNum: this.form.num,
               planDate: this.form.startTime,
               proGroupId: this.form.equipmentId,
               proUserList: this.form.personnelId
            }).then(res => {
               if (res.code === 200) {
                  uni.showToast({ title: '分配成功', icon: 'success', duration: 2000, mask: true });
                  setTimeout(() => {
                     uni.$emit('update', { msg:'刷新列表' })
                     uni.navigateBack({ delta: 1 });
                  }, 2000)
               }
            })
         },
         // 查询设备
         getDeviceByConditions() {
            getDeviceByCondition({})
               .then(res => {
                  if (res.code === 200) {
                     this.equipment = []
                     let arr = []
                     res.data.forEach((element) => {
                        arr.push({ text: element.code + '-' + element.name, id: element.id, checked: false })
                     })
                     this.equipment.push(arr)
                  }
               })
         }
      }
   }
@@ -113,7 +180,7 @@
            border-bottom: 1rpx solid #ececec;
            .fp_list_item_left {
                flex-shrink: 0;
                margin-bottom: 20rpx;
                margin-bottom: 40rpx;
            display: flex;
            align-items: center;
                text {
@@ -122,9 +189,24 @@
               font-weight: 400;
                }
            }
            .fp_list_item_right {
            .fp_list_item_right::v-deep {
                display: flex;
                align-items: center;
            flex-direction: column;
            .u-checkbox-group--row {
               display: flex;
               flex-direction: column;
            }
            .u-icon__icon {
               margin-right: 0 !important;
            }
            .fp_list_item_right_dis {
               display: flex;
               align-items: center;
               margin-bottom: 20rpx;
               &:last-child {
                  margin-bottom: 0 !important;
               }
            }
                .wu {
                    width: 100%;
                    margin: 30rpx 0;
@@ -136,34 +218,18 @@
                        color: black;
                    }
                }
                .van-checkbox {
                    margin-right: 5rpx !important;
                    margin-top: 10rpx !important;
                    &:nth-child(1) {
                        margin-top: 0 !important;
                    }
                    &:nth-child(2) {
                        margin-top: 0 !important;
                    }
                    &:nth-child(3) {
                        margin-top: 0 !important;
                    }
                    .van-checkbox__label {
                        color: black !important;
                    }
                }
                .black {
                    color: black !important;
                }
                input {
                    width: 180rpx;
                    height: 60rpx;
                    border-radius: 8rpx;
                    border: 2rpx solid #E5E5E5;
                    padding: 0 30rpx;
                    text-align: right;
                    font-size: 25rpx;
                }
                // input {
                //     width: 180rpx;
                //     height: 60rpx;
                //     border-radius: 8rpx;
                //     border: 2rpx solid #E5E5E5;
                //     padding: 0 30rpx;
                //     text-align: right;
                //     font-size: 25rpx;
                // }
                text {
                    font-size: 28rpx;
                    font-weight: 400;
@@ -194,9 +260,12 @@
                    font-weight: 400;
                }
            }
            .fp_list_item_right {
            .fp_list_item_right::v-deep {
                display: flex;
                align-items: center;
            .u-icon__icon {
               margin-right: 0 !important;
            }
                .wu {
                    text-align: center;
                    text {
@@ -207,15 +276,15 @@
                .black {
                    color: black !important;
                }
                input {
                    width: 180rpx;
                    height: 60rpx;
                    border-radius: 8rpx;
                    border: 1rpx solid #E5E5E5;
                    padding: 0 30rpx;
                    text-align: right;
                    font-size: 25rpx;
                }
                // input {
                //     width: 180rpx;
                //     height: 60rpx;
                //     border-radius: 8rpx;
                //     border: 1rpx solid #E5E5E5;
                //     padding: 0 30rpx;
                //     text-align: right;
                //     font-size: 25rpx;
                // }
                text {
                    font-size: 28rpx;
                    font-weight: 400;