<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <label class="el-form-item-label">信息主键</label>
        <el-input v-model="query.infoId" clearable placeholder="信息主键" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">审批人</label>
        <el-input v-model="query.approvalUser" clearable placeholder="审批人" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">(00-待审核  01-审批通过(已发布） 02-审核未通过)</label>
        <el-input v-model="query.status" clearable placeholder="(00-待审核  01-审批通过(已发布） 02-审核未通过)" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">审批备注</label>
        <el-input v-model="query.approvalRemark" clearable placeholder="审批备注" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">是否为最新审批</label>
        <el-input v-model="query.isNew" clearable placeholder="是否为最新审批" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <rrOperation :crud="crud" />
      </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="small" label-width="80px">
          <el-form-item label="主键" prop="id">
            <el-input v-model="form.id" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="信息主键">
            <el-input v-model="form.infoId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="审批人">
            <el-input v-model="form.approvalUser" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="(00-待审核  01-审批通过(已发布） 02-审核未通过)">
            <el-radio v-for="item in dict.information_status" :key="item.id" v-model="form.status" :label="item.value">{{ item.label }}</el-radio>
          </el-form-item>
          <el-form-item label="审批备注">
            <el-input v-model="form.approvalRemark" :rows="3" type="textarea" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否为最新审批">
            <el-radio v-for="item in dict.is_true" :key="item.id" v-model="form.isNew" :label="item.value">{{ item.label }}</el-radio>
          </el-form-item>
          <el-form-item label="任务ID act_ru_task">
            <el-input v-model="form.taskId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="任务实例id act_ru_execution">
            <el-input v-model="form.procInstId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="创建者">
            <el-input v-model="form.createBy" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="更新者">
            <el-input v-model="form.updateBy" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="创建日期">
            <el-input v-model="form.createTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="更新时间">
            <el-input v-model="form.updateTime" 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.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="id" label="主键" />
        <el-table-column prop="infoId" label="信息主键" />
        <el-table-column prop="approvalUser" label="审批人" />
        <el-table-column prop="status" label="(00-待审核  01-审批通过(已发布） 02-审核未通过)">
          <template slot-scope="scope">
            {{ dict.label.information_status[scope.row.status] }}
          </template>
        </el-table-column>
        <el-table-column prop="approvalRemark" label="审批备注" />
        <el-table-column prop="isNew" label="是否为最新审批">
          <template slot-scope="scope">
            {{ dict.label.is_true[scope.row.isNew] }}
          </template>
        </el-table-column>
        <el-table-column prop="taskId" label="任务ID act_ru_task" />
        <el-table-column prop="procInstId" label="任务实例id act_ru_execution" />
        <el-table-column prop="createBy" label="创建者" />
        <el-table-column prop="updateBy" label="更新者" />
        <el-table-column prop="createTime" label="创建日期" />
        <el-table-column prop="updateTime" label="更新时间" />
        <el-table-column v-if="checkPer(['admin','dmInformationApproval:edit','dmInformationApproval:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudDmInformationApproval from '@/api/dm/informationApproval/dmInformationApproval'
import CRUD, { presenter, header, form, crud } 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 = { id: null, infoId: null, approvalUser: null, status: null, approvalRemark: null, isNew: null, taskId: null, procInstId: null, createBy: null, updateBy: null, createTime: null, updateTime: null }
export default {
  name: 'DmInformationApproval',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: ['information_status', 'is_true'],
  cruds() {
    return CRUD({ title: 'dmInformationApproval', url: 'api/dmInformationApproval', idField: 'id', sort: 'id,desc', crudMethod: { ...crudDmInformationApproval }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'dmInformationApproval:add'],
        edit: ['admin', 'dmInformationApproval:edit'],
        del: ['admin', 'dmInformationApproval:del']
      },
      rules: {
        id: [
          { required: true, message: '主键不能为空', trigger: 'blur' }
        ]
      },
      queryTypeOptions: [
        { key: 'infoId', display_name: '信息主键' },
        { key: 'approvalUser', display_name: '审批人' },
        { key: 'status', display_name: '(00-待审核  01-审批通过(已发布） 02-审核未通过)' },
        { key: 'approvalRemark', display_name: '审批备注' },
        { key: 'isNew', display_name: '是否为最新审批' }
      ]
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
