<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.bill_code"
              clearable
              size="mini"
              placeholder="入库单号"
              @keyup.enter.native="crud.toQuery"
            />
          </el-form-item>
          <el-form-item label="所属仓库">
            <el-select
              v-model="query.stor_id"
              clearable
              size="mini"
              placeholder="全部"
              class="filter-item"
              @change="crud.toQuery"
            >
              <el-option
                v-for="item in storlist"
                :key="item.stor_id"
                :label="item.stor_name"
                :value="item.stor_id"
              />
            </el-select>
          </el-form-item>

          <el-form-item label="创建时间">
            <el-date-picker
              v-model="query.createTime"
              type="daterange"
              value-format="yyyy-MM-dd HH:mm:ss"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :default-time="['00:00:00', '23:59:59']"
              @change="crud.toQuery"
            />
          </el-form-item>
          <el-form-item label="生成方式">
            <el-select
              v-model="query.create_mode"
              clearable
              size="mini"
              placeholder="生成方式"
              class="filter-item"
              @change="crud.toQuery"
            >
              <el-option
                v-for="item in dict.ST_CREATE_MODE"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>

          <el-form-item label="单据状态">
            <el-select
              v-model="query.bill_status"
              clearable
              size="mini"
              placeholder="单据状态"
              class="filter-item"
              @change="crud.toQuery"
            >
              <el-option
                v-for="item in dict.io_bill_status"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>

          <el-form-item label="业务类型">
            <el-select
              v-model="query.bill_type"
              clearable
              filterable
              size="mini"
              placeholder="业务类型"
              class="filter-item"
              @change="crud.toQuery"
            >
              <el-option
                v-for="item in dict.ST_INV_OUT_TYPE"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <rrOperation />
        </el-form>
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission">
        <el-button
          slot="right"
          class="filter-item"
          type="warning"
          :disabled="dis_flag"
          icon="el-icon-check"
          size="mini"
          @click="backConfirm"
        >
          强制确认
        </el-button>
      </crudOperation>
      <!--表格渲染-->
      <!--表格渲染-->
      <el-table
        ref="table"
        v-loading="crud.loading"
        :data="crud.data"
        size="mini"
        style="width: 100%;"
        @selection-change="crud.selectionChangeHandler"
      >
        <el-table-column show-overflow-tooltip prop="bill_code" width="130" label="单据编码"/>
        <el-table-column show-overflow-tooltip :formatter="stateFormat" width="100" prop="bill_status" label="单据状态" />
        <el-table-column prop="stor_name" label="仓库" width="100" />
        <el-table-column show-overflow-tooltip prop="bill_type" :formatter="bill_typeFormat" label="业务类型" />
        <el-table-column show-overflow-tooltip width="135" prop="biz_date" label="业务日期" />
        <el-table-column show-overflow-tooltip :formatter="create_modeFormat" prop="create_mode" label="生成方式" width="100" />
        <el-table-column label="明细数" align="center" prop="detail_count" width="100" />
        <el-table-column label="总重量" align="center" prop="total_qty" width="100" />
        <el-table-column show-overflow-tooltip label="备注" align="center" prop="remark" width="100" />
        <el-table-column show-overflow-tooltip label="制单人" align="center" prop="input_optname" />
        <el-table-column show-overflow-tooltip label="制单时间" align="center" prop="input_time" width="140" />
        <el-table-column show-overflow-tooltip label="修改人" align="center" prop="update_optname" />
        <el-table-column show-overflow-tooltip label="修改时间" align="center" prop="update_time" width="140" />
        <el-table-column show-overflow-tooltip label="分配人" align="center" prop="dis_optname" />
        <el-table-column show-overflow-tooltip label="分配时间" align="center" prop="dis_time" width="140" />
        <el-table-column show-overflow-tooltip label="确认人" align="center" prop="confirm_optname" />
        <el-table-column show-overflow-tooltip label="确认时间" align="center" prop="confirm_time" width="140" />
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import CRUD, { crud, 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'
import DateRangePicker from '@/components/DateRangePicker/index'
import crudInchargefrom from '@/views/wms/st/incharge/incharge'
import crudStorattr from '@/views/wms/basedata/st/stor/storattr'

export default {
  name: 'Incharge',
  components: { crudOperation, rrOperation, udOperation, pagination, DateRangePicker },
  cruds() {
    return CRUD({
      title: '入库冲销',
      url: 'api/incharge',
      idField: 'id',
      sort: 'id,desc',
      crudMethod: { ...crudInchargefrom },
      optShow: {
        add: true,
        edit: true,
        del: true,
        download: false,
        reset: false
      }
    })
  },
  mixins: [presenter(), header(), crud()],
  // 数据字典
  dicts: ['ST_CREATE_MODE', 'ST_INV_OUT_TYPE'],
  data() {
    return {
      permission: {
      },
      billType: null,
      storlist: [],
      createtypelist: [],
      statuslist: []
    }
  },
  created() {
    crudStorattr.getStor({ 'is_productstore': '1' }).then(res => {
      this.storlist = res.content
    })
  },
  methods: {
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
::v-deep .el-dialog__body {
  padding-top: 10px;
}
</style>
