<template>
  <ifrm ref="ifrm">
    <!-- 工序接收 -->
    <uni-forms ref="form" err-show-type="toast">
      <uni-forms-item name="allegation"
        ><input
          type="text"
          v-model="value"
          @confirm="confirm"
          class="uni-input-border"
          :focus="twoInputFcous"
          placeholder="流程卡"
      /></uni-forms-item>
    </uni-forms>
    <t-table style="margin-top: 20rpx">
      <t-tr>
        <t-td>流程卡号</t-td>
        <t-td>{{ tableObj.cardNo }}</t-td>
      </t-tr>
      <t-tr>
        <t-td>车间订单号</t-td>
        <t-td>{{ tableObj.woCode }}</t-td>
      </t-tr>
      <t-tr>
        <t-td>批单号</t-td>
        <t-td>{{ tableObj.batchNo }}</t-td>
      </t-tr>
      <t-tr>
        <t-td>零件编码</t-td>
        <t-td>{{ tableObj.partCode }}</t-td>
      </t-tr>
      <t-tr>
        <t-td>零件名称</t-td>
        <t-td>{{ tableObj.partName }}</t-td>
      </t-tr>
      <t-tr>
        <t-td>数量</t-td>
        <t-td>{{ tableObj.notInQty }}</t-td>
      </t-tr>
      <t-tr>
        <t-td>当前工序名</t-td>
        <t-td>{{ tableObj.currentWpTitle }}</t-td>
      </t-tr>
      <t-tr>
        <t-td>当前工序名</t-td>
        <t-td>{{ tableObj.currentMakeTeam }}</t-td>
      </t-tr>
      <!-- <t-tr>
        <t-td>上序加工班组</t-td>
        <t-td>{{ tableObj.frontWpTitle }}</t-td>
      </t-tr>
      <t-tr>
        <t-td>上序工序名</t-td>
        <t-td>{{ tableObj.currentWpTitle }}</t-td>
      </t-tr>
      <t-tr>
        <t-td>上序加工单位</t-td>
        <t-td>{{ tableObj.currentWpTitle }}</t-td>
      </t-tr>
      <t-tr>
        <t-td>下序工序号</t-td>
        <t-td>{{ tableObj.frontWpTitle }}</t-td>
      </t-tr>
      <t-tr>
        <t-td>下序工序名</t-td>
        <t-td>{{ tableObj.currentWpTitle }}</t-td>
      </t-tr>
      <t-tr>
        <t-td>下序加工单位</t-td>
        <t-td>{{ tableObj.currentWpTitle }}</t-td>
      </t-tr> -->
    </t-table>
    <!-- <view class="buttonBox"
      ><button
        class="button"
        type="primary"
        :disabled="!(Object.keys(tableObj).length > 0)"
        @click="submitClick"
      >
        接收
      </button></view
    > -->
  </ifrm>
</template>

<script>
import ifrm from "@/pages/index/ifrm";
import tTable from "@/components/t-table/t-table.vue";
import tTh from "@/components/t-table/t-th.vue";
import tTr from "@/components/t-table/t-tr.vue";
import tTd from "@/components/t-table/t-td.vue";
import scan from "../../mixin/scan.js";
export default {
  mixins: [scan],
  components: {
    ifrm,
    tTable,
    tTh,
    tTr,
    tTd,
  },
  data() {
    return {
      value: "",
      tableObj: {},
      qty: "",
      twoInputFcous: false,
    };
  },
  methods: {},
  onNavigationBarButtonTap(btn) {
    this.$refs.ifrm.topMenuClick(btn);
  },
  onShow() {},
  methods: {
    getBarCode(code, isConfirm = false) {
      this.getData(code);
    },
    confirm(e) {
      uni.showLoading({
        title: "接收中...",
        mask: true,
      });
      this.getBarCode(e.target.value, true);
    },
    getData(code) {
      this.twoInputFcous = false;
      if (!code) return;
      this.value = code;
      this.$u.api
        .loadNotReceived({ cardNo: code })
        .then((res) => {
          this.value = "";
          this.tableObj = res.data;
          // uni.showToast({
          //   title: "数据获取成功",
          // });
          this.submitClick()
        })
        .catch((err) => {
          this.value = "";
          this.tableObj = {};
        });
    },
    submitClick() {
      this.$u.api.workPlanReceive({ wpIds: this.tableObj.wpId }).then((res) => {
        this.tableObj = {};
        this.hideLoading();
        uni.showToast({
          title: "接收成功",
        });
        this.twoInputFcous = true;
      });
    },
  },
};
</script>

<style scoped></style>