yyb
21 小时以前 3a57c9d62fb7833dcff3742dea15dbae5e5c9046
pages/product/report/index.vue
@@ -43,8 +43,8 @@
      <u-form-item label="零件描述" :border-bottom="false" prop="partName">
        <u-input v-model="form.partName" placeholder="" disabled />
      </u-form-item>
      <u-form-item label="批量大小" :border-bottom="false" prop="qtyrequired">
        <u-input v-model="form.qtyrequired" placeholder="" disabled />
      <u-form-item label="批量大小" :border-bottom="false" prop="qtyRequired">
        <u-input v-model="form.qtyRequired" placeholder="" disabled />
      </u-form-item>
      <u-form-item
        label="剩余数量"
@@ -68,26 +68,28 @@
          <u-radio name="part">替代零件</u-radio>
        </u-radio-group>
      </u-form-item>
      <u-form-item label="物料" prop="materialcost">
        <u-radio-group v-model="form.materialcost" :disabled="true">
      <u-form-item label="物料" prop="materialCost">
        <u-radio-group v-model="form.materialCost" :disabled="true">
          <u-radio name="倒冲">倒冲</u-radio>
          <u-radio name="投料">投料</u-radio>
        </u-radio-group>
      </u-form-item>
      <u-form-item label="工序" prop="value1">
        <u-checkbox-group>
          <u-checkbox
            :name="item.name"
            v-for="(item, index) in checkboxList"
            :key="index"
            v-model="item.value1"
            @change="changeCheckbox"
            :disabled="subdisabled || item.disabled"
          >
            {{ item.name }}
          </u-checkbox>
        </u-checkbox-group>
     <u-form-item label="简化物料检查" prop="simplifyMaterials">
       <u-radio-group v-model="form.simplifyMaterials" :disabled="subdisabled || simplifyDisabled" @change="radioChange">
         <u-radio name="true">是</u-radio>
         <u-radio name="false">否</u-radio>
       </u-radio-group>
     </u-form-item>
      <u-form-item label="报工方式" prop="status">
        <u-radio-group v-model="form.status" :disabled="subdisabled" @change="handleReportTypeChange">
          <u-radio name="false">按班组报工</u-radio>
          <u-radio name="true">按人员报工</u-radio>
        </u-radio-group>
      </u-form-item>
      <u-form-item label="人员名称" :border-bottom="false" prop="Persons">
            <u-input v-model="form.Persons" type="select" placeholder="请选择"
               @click="openselectedPersons" :disabled="!canSelectPerson || subdisabled"/>
         </u-form-item>
      <u-form-item label="产出列表" :border-bottom="false"></u-form-item>
    </u-form>
    <view class="wrap">
@@ -101,6 +103,7 @@
            v-for="(item, index) in InventoryReceiptList"
            :key="index"
            :index="index"
            @click="cancelReport(item)"
          >
            <view class="content-header">
              <view class="content-header-title">{{ index + 1 }}</view>
@@ -111,7 +114,7 @@
                  <view class="_label-name">批号:</view>
                </view>
                <view class="_content">
                  {{ item.productNo }}
                  {{ item.outBatchNo }}
                </view>
              </view>
              <view class="row-list">
@@ -150,6 +153,69 @@
      :operationTaskList="this.form"
      @update="handleUpdate"
    />
    <u-modal
      width="720rpx"
      v-model="showModal"
      title=""
      :show-cancel-button="true"
      :show-confirm-button="true"
      @confirm="confirmModle"
      @cancel="cancelModle"
    >
      <view class="popup-content">
        <view class="packing-registration-param">
          <view class="packing-registration-param-view">
            <view class="packing-registration-param-item param-extra">
              <view class="packing-registration-param-item-left">
                <text class="item-one">批号</text>
              </view>
              <view class="packing-registration-param-item-right">
                <text class="item-one">{{ detailedList.outBatchNo }}</text>
              </view>
            </view>
            <view class="packing-registration-param-item param-extra">
              <view class="packing-registration-param-item-left">
                <text class="item-one">零件号</text>
              </view>
              <view class="packing-registration-param-item-right">
                <text class="item-one">{{ detailedList.partNo }}</text>
              </view>
            </view>
            <view class="packing-registration-param-item param-extra">
              <view class="packing-registration-param-item-left">
                <text class="item-one">零件描述</text>
              </view>
              <view class="packing-registration-param-item-right">
                <span class="item-one">{{ detailedList.partName }}</span>
              </view>
            </view>
            <view class="packing-registration-param-item param-extra">
              <view class="packing-registration-param-item-left">
                <text class="item-one">取消接收数量</text>
              </view>
              <view class="packing-registration-param-item-right">
                <span class="item-one">{{ detailedList.netWeight }}</span>
              </view>
            </view>
          </view>
        </view>
      </view>
    </u-modal>
    <u-modal v-model="personShowModal" title="" :show-cancel-button="true" :show-confirm-button="true"
         @confirm="confirmSelection" @cancel="cancelSelection">
      <scroll-view scroll-y="true" style="height: 100%">
         <view class="popup-content">
            <view class="popup-header">
               <checkbox-group @change="checkboxChange">
                  <label class="checkbox-item" v-for="(item, index) in selectedPersons" :key="index">
                     <checkbox :value="item.staffId" :checked="item.checked" />
                     <text class="label">{{ item.staffName }}</text>
                  </label>
               </checkbox-group>
            </view>
         </view>
      </scroll-view>
      </u-modal>
    <scan></scan>
  </div>
</template>
@@ -166,19 +232,21 @@
  },
  data() {
    return {
      checkboxList: [
        {
          name: "工序的自动报告",
          value: false,
          disabled: false,
        },
        {
          name: "简化物料检查",
          value: false,
          disabled: false,
        },
      ],
      simplifyDisabled:false,
      // checkboxList: [
      //   {
      //     name: "工序的自动报告",
      //     value: false,
      //     disabled: false,
      //   },
      //   {
      //     name: "简化物料检查",
      //     value: false,
      //     disabled: false,
      //   },
      // ],
      InventoryReceiptList: [],
        selectedPersons: [],
      form: {
        workstationId: "",
        work: "",
@@ -187,15 +255,21 @@
        moOn: "",
        partNo: "",
        partName: "",
        qtyrequired: "",
        qtyRequired: "",
        Jianqtyfinished: "",
        proposedLocation: "",
        productType: "dep",
        receive: "mo",
        materialcost: "",
        autoReport: false,
        simplifyMaterials: false,
        materialCost: "",
        // autoReport: false,
        simplifyMaterials: 'false',
        status: 'false',
        Persons: '',
        productStaffIds: [],
        productStaffs:[]
      },
      personList: [],
      canSelectPerson: false,
      rules: {
        work: [
          {
@@ -239,10 +313,29 @@
            trigger: ["change"],
          },
        ],
        status: [
          {
            required: true,
            message: "请选择报工方式",
            trigger: ["change"],
          },
        ],
        Persons: [
          {
            required: true,
            message: "请选择人员",
            trigger: ["change"],
          },
        ],
      },
      showSave: false,
      operationTaskId: "",
      subdisabled: false,
      codeInfoId: "",
      detailedList: {},
      showModal: false,
      personShowModal: false,
         checkboxList: [],
    };
  },
  // 点击提交按钮的事件处理函数
@@ -259,6 +352,7 @@
            id: this.form.id,
          })
          .then((res) => {
            res.data.name = this.form.name;
            this.$refs.saveForm.open(res);
            uni.hideLoading();
          });
@@ -279,17 +373,14 @@
      if (data.code) {
        let codeInfo = JSON.parse(data.code);
        if (codeInfo.moOn) {
           that.codeInfoId = codeInfo.id;
          // 扫描报工单二维码
          that.saveForm(codeInfo);
          that.$u.api.workReporting
            .getProductMainV1({
              current: 1,
              size: -1,
              id: codeInfo.id,
            })
            .then((res) => {
              that.InventoryReceiptList = res.data.productOutputList;
            });
          that.getHandelList();
        }
        if (codeInfo.BN) {
          // 扫描报工单二维码
          that.CopperReportingWork(codeInfo);
        }
      }
    });
@@ -298,19 +389,176 @@
    "form.taskNo": function (newVal, oldVal) {
      this.subdisabled = false;
    },
    'form.status'(newVal) {
      this.selectedPersons = this.selectedPersons.map(item => ({
        ...item,
        checked: newVal === 'false'
      }));
    }
  },
  methods: {
    // 多选处理
    changeCheckbox(val) {
      if (val.name === "工序的自动报告") {
        this.form.autoReport = val.value;
      }
      if (val.name === "简化物料检查") {
        this.form.simplifyMaterials = val.value;
      }
    // 处理报工方式变更
    handleReportTypeChange() {
      // 切换报工方式时清空人员名称
      this.form.Persons = '';
      this.form.productStaffs = [];
      this.form.productStaffIds = [];
    },
    // 人员名称
             openselectedPersons() {
            this.personShowModal = true;
    },
               // 复选框变化事件
    checkboxChange(e) {
      console.log('e',e)
            const values = e.target.value || [];
            if (this.form.status === 'true') {
               // 单选模式,只允许选择一个人
               const previouslySelected = this.selectedPersons.find(item => item.checked);
               const newlySelected = values.length > 0 ? values[values.length - 1] : null;
               if (previouslySelected && newlySelected && previouslySelected.staffId !== newlySelected) {
                  // 已有选中项且选择了新的项,提示只能选择一个人
                  this.$u.toast('按人员报工时只能选择一位人员');
                  // 保持原选择
                  this.selectedPersons = this.selectedPersons.map(item => ({
                     ...item,
                     checked: item.staffId === previouslySelected.staffId
            }));
               } else {
                  // 首次选择或取消选择
                  this.selectedPersons = this.selectedPersons.map(item => ({
                     ...item,
                     checked: newlySelected ? item.staffId === newlySelected : false
            }));
               }
            } else {
               // 多选模式
               this.selectedPersons = this.selectedPersons.map(item => ({
                  ...item,
                  checked: values.includes(item.staffId)
               }));
            }
    },
               // 确认选择
         confirmSelection() {
        const selected = this.selectedPersons.filter(item => item.checked);
            // 根据报工方式设置人员名称
            if (this.form.status === 'true' && selected.length > 0) {
               this.form.Persons = selected[0].staffName;
            } else {
               this.form.Persons = selected.map(item => item.staffName).join(',');
            }
            this.form.productStaffs = selected.map(item => item.staffNo);
            this.form.productStaffIds = selected.map(item => item.staffId);
    },
      cancelSelection(){},
    // 铜杆报工
    CopperReportingWork(val) {
      const copperList = {};
      copperList.outBatchNo = val.BN
      copperList.partNo = val.PN
      copperList.weighingClerk = val.WC
      copperList.executiveStandard = val.ES
      copperList.netWeight = val.NW
      copperList.specificationType = val.ST
      copperList.grossWeight = val.TR
      copperList.operationTaskId = this.form.id
      copperList.status = this.form.status;
      copperList.Persons = this.form.Persons;
      copperList.productStaffIds = this.form.productStaffIds;
      copperList.productStaffs = this.form.productStaffs;
      this.form.productOutputList = [];
      this.form.operationTaskId = this.form.id;
      this.form.productOutputList.push(copperList);
      console.log('this.form',this.form)
      this.$u.api.workReporting.submitPDA(this.form).then((res) => {
        this.subdisabled = true;
        this.getHandelList();
        this.$u.toast("报工成功");
      });
    },
    // 点击确认后获取取消报工记录
    radioChange() {
      // 处理单选框变化事件
    },
    // 获取人员列表
    getPersonList(dutyId) {
      console.log('111111')
      try {
        this.$u.api.workReporting.getPersonByDutyRecordId({ id: dutyId }).then((res) => {
        this.selectedPersons = res.data.map(item => ({
          ...item,
          checked: this.form.status === 'false'
        }));
      })
      .catch(err => {
        console.log(err)
      })
      } catch (err) {
        console.log(err)
      }
    },
    confirmModle() {
      console.log("点击确认后获取取消报工记录");
      // 处理确认逻辑
      this.$u.api.cancelReporting
        .cancelDTAOfWorkApplication({
          outBatchNo: this.detailedList.outBatchNo,
        })
        .then((res) => {
          console.log("res", res);
          this.showModal = false;
          this.getHandelList();
          this.$u.toast("取消报工成功");
        });
    },
    cancelModle() {
      this.showModal = false; // 关闭弹窗
    },
    // 取消报工
    cancelReport(item) {
      let that = this;
      uni.showModal({
        title: "提示",
        content: "是否确认取消批次" + item.outBatchNo + "的报工",
        success: function (res) {
          if (res.confirm) {
            that.detailedList = item;
            that.showModal = true;
          } else if (res.cancel) {
            return;
          }
        },
      });
    },
    getHandelList() {
      this.$u.api.workReporting
        .getProductMainV1({
          current: 1,
          size: -1,
          id: this.codeInfoId,
        })
        .then((res) => {
          this.InventoryReceiptList = res.data.productOutputList;
        });
    },
    // 多选处理
    // changeCheckbox(val) {
      // if (val.name === "工序的自动报告") {
      //   this.form.autoReport = val.value;
      // }
      // if (val.name === "简化物料检查") {
      //   this.form.simplifyMaterials = val.value;
      // }
    // },
    handleUpdate() {
      this.subdisabled = true;
      this.getHandelList();
    },
    // 打开弹框--后面还需要监听扫码枪扫码结果,赋值给报工单号字段,然后打开弹框选择订单号等操作
    open() {
@@ -346,17 +594,23 @@
        moOn: val.moOn,
        partNo: val.partNo,
        partName: val.partName,
        qtyrequired: val.qtyrequired,
        Jianqtyfinished: val.qtyrequired - val.qtyfinished,
        qtyRequired: val.qtyRequired,
        Jianqtyfinished: val.qtyRequired - val.qtyFinished,
        proposedLocation: val.proposedLocation,
        productType: "dep",
        receive: "mo", // 复选框组的值
        materialcost: val.materialcost,
        autoReport: false,
        simplifyMaterials: false,
        receive: "mo",
        materialCost: val.materialCost,
        // autoReport: false,
        simplifyMaterials: 'false',
        status: 'false',
        Persons:'',
      };
      if (this.form.materialcost == "倒冲") {
        this.checkboxList[1].disabled = true;
      if (this.form.materialCost == "倒冲") {
        this.simplifyDisabled = true;
      }
      // 如果有dutyNo,获取人员列表
      if (val.dutyId) {
        this.getPersonList(val.dutyId);
      }
    },
  },