<script>
import WorkForm from '@views/workOrder/modules/work/WorkForm.vue'
import OperationRecordList from '@views/workOrder/modules/work/OperationRecordList.vue'
import OperationIssueModal from '@views/workOrder/modules/OperationIssueModal.vue'
import RepairSupplementModal from '@views/workOrder/modules/RepairSupplementModal.vue'
import ReplacementRecordModal from '@views/workOrder/modules/work/ReplacementRecordModal.vue'
export default {
  name: 'WorkModal',
  components: { ReplacementRecordModal, RepairSupplementModal, OperationRecordList, WorkForm,OperationIssueModal },
  data() {
    return {
      title: '作业详情',
      width: 1200,
      visible: false,
      disableSubmit: false,
      orderId: null,
    }
  },
  methods: {
    handleShowIssueModal(){
      this.$refs.issueModal.add(this.orderId)
    },
    handleComplete(){
      this.$refs.recordList.handleCompleteAllSelectRecords()
    },
    show(id) {
      this.visible = true
      this.orderId = id
    },
    edit(record) {
      this.visible = true
      this.$nextTick(() => {
        this.$refs.realForm.edit(record)
      })
    },
    close() {
      this.$emit('close')
      this.visible = false
    },
    // submitCallback() {
      // this.$emit('ok')
      // this.visible = false
    // },
    // handleOk() {
    //   this.$refs.realForm.submitForm()
    // },
    handleCancel() {
      this.close()
    },
    handleShowSupplement(){
      this.$refs.supplementModal.add(this.orderId)
    },
    handleShowReplacement(){
      this.$refs.replacementRecordsModal.add(this.orderId)
    }
  },
}
</script>

<template>
  <a-drawer
    :title="title"
    :width="width"
    placement="right"
    :closable="false"
    @close="close"
    destroyOnClose
    :visible="visible"
  >
    <replacement-record-modal ref="replacementRecordsModal"/>
    <operation-issue-modal ref="issueModal"/>
    <repair-supplement-modal ref="supplementModal"/>
    <operation-record-list ref="recordList" :order-id="orderId" />
    <div class="drawer-footer">
      <a-button @click="handleComplete">一键完成</a-button>
      <a-button @click="handleShowReplacement">配件更换</a-button>
      <a-button @click="handleShowIssueModal">问题说明</a-button>
      <a-button @click="handleShowSupplement">维修备注</a-button>
    </div>
    <!--    <work-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit" normal></work-form>-->
    <!--    <div class="drawer-footer">-->
    <!--      <a-button @click="handleCancel" style="margin-bottom: 0;">关闭</a-button>-->
    <!--      <a-button v-if="!disableSubmit"  @click="handleOk" type="primary" style="margin-bottom: 0;">提交</a-button>-->
    <!--    </div>-->
  </a-drawer>
</template>

<style lang="less" scoped>
/** Button按钮间距 */
.ant-btn {
  margin-left: 30px;
  margin-bottom: 30px;
  float: right;
}
.drawer-footer {
  position: absolute;
  bottom: -8px;
  width: 100%;
  border-top: 1px solid #e8e8e8;
  padding: 10px 16px;
  text-align: right;
  left: 0;
  background: #fff;
  border-radius: 0 0 2px 2px;
}
</style>
