<template>
    <div class="app-container">
      <!--工具栏-->
      <div class="head-container">
        <div v-if="crud.props.searchToggle">
        <el-form
          :inline="true"
          class="demo-form-inline"
          label-position="right"
          label-width="80px"
          label-suffix=":"
        >
          <el-form-item label="物料编码">
            <el-input
              v-model="query.sku"
              clearable
              size="mini"
              placeholder="物料编码"
              @keyup.enter.native="crud.toQuery"
            />
          </el-form-item>

          <el-form-item label="是否启用">
            <el-select
              v-model="query.status"
              clearable
              size="mini"
              placeholder="是否启用"
              class="filter-item"
              @change="hand"
            >
              <el-option
                v-for="item in dict.is_used"
                :key="item.id"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>

          <rrOperation />
          </el-form>
          </div>
        <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
        <crudOperation :permission="permission" />
        <!--表单组件-->
        <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
          <el-form ref="form" :model="form" :rules="rules" size="mini" label-width="80px">
            <el-form-item label="主键ID" prop="note_id">
              <el-input v-model="form.note_id" style="width: 370px;" />
            </el-form-item>
            <el-form-item label="任务号">
              <el-input v-model="form.req_code" style="width: 370px;" />
            </el-form-item>
            <el-form-item label="出库单号">
              <el-input v-model="form.deliveryno" style="width: 370px;" />
            </el-form-item>
            <el-form-item label="出库单行号">
              <el-input v-model="form.deliverylineno" style="width: 370px;" />
            </el-form-item>
            <el-form-item label="物料">
              <el-input v-model="form.sku" style="width: 370px;" />
            </el-form-item>
            <el-form-item label="立库代码">
              <el-input v-model="form.lk_code" style="width: 370px;" />
            </el-form-item>
            <el-form-item label="拣货单号">
              <el-input v-model="form.pickdetailkey" style="width: 370px;" />
            </el-form-item>
            <el-form-item label="出库数量">
              <el-input v-model="form.qty" style="width: 370px;" />
            </el-form-item>
            <el-form-item label="出库时间">
              <el-input v-model="form.outboundtime" style="width: 370px;" />
            </el-form-item>
            <el-form-item label="请求参数">
              <el-input v-model="form.request_param" style="width: 370px;" />
            </el-form-item>
            <el-form-item label="响应结果">
              <el-input v-model="form.response_param" style="width: 370px;" />
            </el-form-item>
            <el-form-item label="创建时间">
              <el-input v-model="form.create_time" style="width: 370px;" />
            </el-form-item>
            <el-form-item label="skudesc">
              <el-input v-model="form.skudesc" style="width: 370px;" />
            </el-form-item>
            <el-form-item label="status">
              <el-input v-model="form.status" style="width: 370px;" />
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button type="text" @click="crud.cancelCU">取消</el-button>
            <el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
          </div>
        </el-dialog>
        <!--表格渲染-->
        <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="mini" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
          <el-table-column type="selection" width="55" />
          <el-table-column prop="note_id" label="主键ID"   show-overflow-tooltip/>
          <el-table-column prop="req_code" width="60" label="任务号"   show-overflow-tooltip/>
          <el-table-column prop="deliveryno" width="80" label="出库单号"   show-overflow-tooltip/>
          <el-table-column prop="deliverylineno" width="90" label="出库单行号"   show-overflow-tooltip/>
          <el-table-column prop="sku" width="60" label="物料"   show-overflow-tooltip/>
          <el-table-column prop="skudesc" width="120" label="物料描述"   show-overflow-tooltip/>
          <el-table-column prop="lk_code" width="80" label="立库代码"   show-overflow-tooltip/>
          <el-table-column prop="pickdetailkey" width="80" label="拣货单号"   show-overflow-tooltip/>
          <el-table-column prop="qty" width="80" label="出库数量"   show-overflow-tooltip/>
          <el-table-column prop="status" label="出库单状态" >
            <template slot-scope="scope">
               {{ getStatusText(scope.row.status) }}
            </template>
          </el-table-column>
          <el-table-column prop="outboundtime" width="200" label="出库时间" />
          <el-table-column prop="request_param" width="120" label="请求参数"  show-overflow-tooltip/>
          <el-table-column prop="response_param" width="120" label="响应结果" show-overflow-tooltip />
          <el-table-column prop="create_time" width="120" label="创建时间" />
          <el-table-column v-permission="[]" label="操作" width="120px" align="center" fixed="right">
            <template slot-scope="scope">
              <udOperation
                :data="scope.row"
                :permission="permission"
              />
            </template>
          </el-table-column>
        </el-table>
        <!--分页组件-->
        <pagination />
      </div>
    </div>
  </template>
  
  <script>
      import crudExtDeliveryNote, { changeActive } from '@/api/wms/sch/delivery'
      import CRUD, {crud, form, header, presenter} from '@crud/crud'
      import rrOperation from '@crud/RR.operation'
      import crudOperation from '@crud/CRUD.operation'
      import udOperation from '@crud/UD.operation'
      import pagination from '@crud/Pagination'
  
      const defaultForm = { note_id: null, req_code: null, deliveryno: null, deliverylineno: null, sku: null, lk_code: null, pickdetailkey: null, qty: null, outboundtime: null, request_param: null, response_param: null, create_time: null, skudesc: null, status: null }
  export default {
    name: 'ExtDeliveryNote',
    components: { pagination, crudOperation, rrOperation, udOperation },
    mixins: [presenter(), header(), form(defaultForm), crud()],
    dicts:['is_used'],
    cruds() {
      return CRUD({ title: 'delivery', url: 'api/extDeliveryNote', idField: 'note_id', sort: 'note_id,desc', crudMethod: { ...crudExtDeliveryNote }})
    },
    data() {
      return {
        permission: {
        },
        rules: {
          note_id: [
            { required: true, message: '主键ID不能为空', trigger: 'blur' }
          ]
        }    }
    },
    methods: {
      // 钩子：在获取表格数据之前执行，false 则代表不获取数据
      [CRUD.HOOK.beforeRefresh]() {
        return true
      },
      getStatusText(status) {
      return status === '1' ? '启用' : '禁用';
    }
    }
  }
  </script>
  
  <style scoped>
  
  </style>
  