<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， 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="180px">
          <el-form-item label="总设计年产量(pcs)">
            <el-input v-model="form.total_input1" style="width: 200px;" />
          </el-form-item>
          <el-form-item label="总设计年产量(吨)">
            <el-input v-model="form.total_input2" style="width: 200px;" />
          </el-form-item>
          <el-form-item label="一期设计年产量(pcs)">
            <el-input v-model="form.year_output1" style="width: 200px;" />
          </el-form-item>
          <el-form-item label="一期设计年产量(吨)">
            <el-input v-model="form.year_output2" style="width: 200px;" />
          </el-form-item>
          <el-form-item label="车间工序数">
            <el-input v-model="form.process_num" style="width: 200px;" />
          </el-form-item>
          <el-form-item label="生产规格数">
            <el-input v-model="form.product_num" style="width: 200px;" />
          </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="process_num" label="车间工序数" />
        <el-table-column prop="product_num" label="生产规格数" />
        <el-table-column prop="total_input1" label="总设计年产量(pcs)" />
        <el-table-column prop="total_input2" label="总设计年产量(吨)" />
        <el-table-column prop="year_output1" label="一期设计年产量(pcs)" />
        <el-table-column prop="year_output2" label="一期设计年产量(吨)" />
        <el-table-column prop="b_date" 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>
      <!--分页组件-->
    </div>
  </div>
</template>

<script>
import crudBigScreen from '@/api/wms/bigScreen/bigScreen'
import CRUD, { crud, form, header, presenter } from '@crud/crud'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'

const defaultForm = { addType: 'yearInOut', id: null, process_num: null, product_num: null, total_input1: null, total_input2: null, year_output1: null, year_output2: null, b_date: null }
export default {
  name: 'Yearinout',
  components: { crudOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({
      title: '今天昨日出入量',
      url: 'api/bigScreenScreen/queryInfo',
      idField: 'id',
      sort: 'id,desc',
      crudMethod: { ...crudBigScreen },
      query: {
        queryType: 'yearInOut'
      },
      optShow: {
        add: true,
        edit: false,
        del: false,
        download: false,
        reset: false
      }
    })
  },
  data() {
    return {
      permission: {
      },
      rules: {
        id: [
          { required: true, message: '标识不能为空', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
