<template>
  <div>
    <el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList()">
      <el-form-item>
        <el-input v-model="state.queryForm.name" placeholder="流程名称" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-input v-model="state.queryForm.key" placeholder="流程编码" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-input v-model="state.queryForm.category" placeholder="流程分类" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table
     class="flex-content-1" height="100%"
        v-loading="state.dataListLoading"
        show-overflow-tooltip
        :data="state.dataList"
        border
        style="width: 100%"
        @selection-change="selectionChangeHandle"
    >
      <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
      <el-table-column prop="key" label="流程编码" header-align="center" align="center"></el-table-column>
      <el-table-column prop="name" label="流程名称" header-align="center" align="center"></el-table-column>
      <el-table-column prop="category" label="流程类型" header-align="center"
                       align="center"></el-table-column>
      <el-table-column prop="version" label="流程版本" header-align="center"
                       align="center" width="90"></el-table-column>
      <el-table-column prop="deploymentId" label="是否部署" header-align="center"
                       align="center" width="90">
        <template #default="scope">
          {{ scope.row.deploymentId && scope.row.deploymentId!=''?'是':'否' }}
        </template>
      </el-table-column>
      <el-table-column prop="createTime" label="创建时间" header-align="center" align="center"
                       width="190"></el-table-column>
      <el-table-column prop="lastUpdateTime" label="更新时间" header-align="center" align="center"
                       width="190"></el-table-column>
      <el-table-column label="操作" fixed="right" header-align="center" align="center" width="230">
        <template #default="scope">

          <el-button v-auth="'ebo:flow:flowmanager:setting2'" type="primary" link
                     @click="settingHandle(scope.row.id)">配置
          </el-button>
          <el-button v-auth="'ebo:flow:flowmanager:setting'" type="primary" link
                     @click="settingHandle(scope.row.id)">人员设置
          </el-button>



        </template>
      </el-table-column>
    </el-table>
    <el-pagination
        :current-page="state.page"
        :page-sizes="state.pageSizes"
        :page-size="state.limit"
        :total="state.total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="sizeChangeHandle"
        @current-change="currentChangeHandle"
    >
    </el-pagination>
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update ref="addOrUpdateRef" @refresh-data-list="getDataList"></add-or-update>

  </div>
</template>

<script setup lang="ts" name="flowFlowmanagerFlowUser">
import {useCrud} from '@/hooks'
import {reactive, ref} from 'vue'
import {IHooksOptions} from '@/hooks/interface'
import {ElMessage, ElMessageBox} from "element-plus";
import {deploymentFlowApi} from "@/views/ebo/flow/api/flowmanager";
import AddOrUpdate from "@/views/ebo/flow/flowmanager/flowUserDetail.vue";

const state: IHooksOptions = reactive({
  dataListUrl: '/flow/template/page',
  deleteUrl: '/flow/template',
  queryForm: {
    name: '',
    key: '',
    category: ''
  }
})


const addOrUpdateRef = ref()
const settingHandle = (id?: string) => {
  addOrUpdateRef.value.init(id)
}


const {getDataList, selectionChangeHandle, sizeChangeHandle, currentChangeHandle, deleteBatchHandle} = useCrud(state)
</script>
