<template>
  <el-form ref="recyleFormRef" :model="form" label-width="100px">
    <headerTitle title="基本信息" style="margin-top: 15px"></headerTitle>
    <el-row>
      <el-col :span="8">
        <el-form-item label="编码:" prop="code">
          <el-input v-model="form.code" disabled />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="工单名称:">
          <el-input
            v-model="form.workOrderName"
            disabled
            placeholder="请选择"
          />
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <el-form-item label="原因">
          <el-input v-model="form.remarks" type="textarea" :rows="2" disabled />
        </el-form-item>
      </el-col>
    </el-row>
    <spareParts obtain="仓库" ref="sparePartsRef" type="view"></spareParts>
    <div class="title" v-if="!isView && taskDefinitionKey == 'wms_out'">
      出库单信息</div
    >
    <keep-alive>
      <add
        ref="add"
        :form="form"
        :sourceBizNo="form.code"
        :bizType="4"
        :saleProductList="detailList"
        v-if="!isView && taskDefinitionKey == 'wms_out' && form.id"
      ></add>
    </keep-alive>
  </el-form>
</template>

<script>
  import add from '@/views/bpm/outgoingManagement/outbound.vue';
  import spareParts from './sparePartsList.vue';
  import { salesrealcostinfo } from '@/api/afterSales/index';
  export default {
    props: {
      businessId: {
        default: ''
      },
      taskDefinitionKey: {
        type: String,
        default: ''
      },
      isView: ''
    },
    components: {
      spareParts,
      add
    },
    data() {
      return {
        form: {
          remarks: '',
          workOrderName: '',
          code: ''
        }
      };
    },
    mounted() {
      this.getDetail(this.businessId);
    },
    methods: {
      async getTableValue() {
        return {
          form: this.form,
          returnStorageData:
            this.$refs.add && (await this.$refs.add.getReturnStorage())
        };
      },
      async getDetail(id) {
        const res = await salesrealcostinfo(id);
        // this.detailList = res.detailList;
        console.log(res)
        this.$set(this.form, 'workOrderName', res.workOrderName);
        this.$set(this.form, 'code', res.code);
        this.$set(this.form, 'remarks', res.remarks);
         this.$refs.sparePartsRef.setTableValue(res?.detailLst || []);
        console.log(res,'resresresresresresresresres 123')
        this.form.id = res.id;
      }
    }
  };
</script>
