<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="400px">
        <el-form ref="form" :model="form" :rules="rules" size="mini" label-width="120px">
          <el-form-item label="产品名称" prop="name_today">
            <el-input v-model="form.name_today" style="width: 200px;" />
          </el-form-item>
          <el-form-item label="今日产量" prop="num_today">
            <el-input v-model="form.num_today" style="width: 200px;" />
          </el-form-item>
          <el-form-item label="计划数量" prop="num_plan">
            <el-input v-model="form.num_plan" 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="num_today" label="今日产量" />
        <el-table-column prop="name_today" label="今日产品名称" />
        <el-table-column prop="num_plan" 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 rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'

const defaultForm = { addType: 'todayAndPlanNum', pro_id: null, num_today: null, name_today: null, num_plan: null }
export default {
  name: 'Todayandplannum',
  components: { crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({
      title: '今日产量和计划产量',
      url: 'api/bigScreenScreen/queryInfo',
      idField: 'pro_id',
      sort: 'pro_id,desc',
      crudMethod: { ...crudBigScreen },
      query: {
        queryType: 'todayAndPlanNum'
      },
      optShow: {
        add: true,
        edit: false,
        del: false,
        download: false,
        reset: false
      }})
  },
  data() {
    return {
      permission: {
      },
      rules: {
        pro_id: [
          { required: true, message: '标识不能为空', trigger: 'blur' }
        ],
        num_today: [
          { required: true, message: '今日产量不能为空', trigger: 'blur' }
        ],
        name_today: [
          { required: true, message: '今日产品名称不能为空', trigger: 'blur' }
        ],
        num_plan: [
          { required: true, message: '计划数量不能为空', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
