<template>
  <BasicModal
    v-bind="$attrs"
    @register="register"
    title="设备入库"
    @visible-change="handleVisibleChange"
    @cancel="resetFields"
    @ok="handleSubmit"
    :min-height="0"
  >
    <div class="pt-2px pr-3px recoverPage">
      <div class="form_item"><div class="item_lable">维修单号：</div>2022101100001</div>
      <div class="form_item"><div class="item_lable">维修工程师：</div>林繁茂</div>
      <BasicTable @register="registerTable" />
    </div>
  </BasicModal>
</template>
<script lang="ts">
import { defineComponent, ref, onMounted, reactive } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicTable, useTable, BasicColumn } from '/@/components/Table';
import { useMessage } from '/@/hooks/web/useMessage';
import { supplyOrderList } from '/@/api/spares';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n();
export default defineComponent({
  components: { BasicModal, BasicTable },
  props: {
    userData: { type: Object },
  },
  emits: ['update'],
  setup(_, { emit }) {
    const modelRef = ref({});
    const columns: BasicColumn[] = [
      {
        title: '备件编号',
        dataIndex: 'repairId',
        width: 100,
      },{
        title: '备件名称',
        dataIndex: 'customerName',
        width: 100,
      },{
        title: '数量',
        dataIndex: 'sendTrackingNum',
        width: 100,
      },
    ]
    const [registerTable, { setLoading }] = useTable({
      // api: supplyOrderList,
      columns,
    });
    const { createMessage, createConfirm } = useMessage();
    onMounted(() => {});
    let addListFunc = () => {};
    const [register, { closeModal }] = useModalInner((data) => {
      // console.log(data);
      data && onDataReceive(data);
    });

    function onDataReceive(data) {
      modelRef.value = data;
    }
    function handleVisibleChange() {}

    const handleSubmit = async () => {
      createConfirm({
          iconType: 'warning',
          title: () => h('span', '温馨提示'),
          content: '删除设备后需要重新入库<br/>确定删除吗?',
          onOk: async () => {
            await cameraIn({id:modelRef.id})
            createMessage.success(t('common.optSuccess'));
            closeModal();
            emit('update');
          },
        });
    };
    return {
      register,
      model: modelRef,
      registerTable,
      handleVisibleChange,
      handleSubmit,
      addListFunc,
      t,
    };
  },
});
</script>
<style lang="less" scoped>
.recoverPage{
  .form_item{
    line-height: 30px;
    .item_lable{
      display: inline-block;
      width: 100px;
      text-align: right;
    }
  }
}
</style>
