From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目

---
 src/views/bpm/processInstance/index.vue |  338 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 338 insertions(+), 0 deletions(-)

diff --git a/src/views/bpm/processInstance/index.vue b/src/views/bpm/processInstance/index.vue
new file mode 100644
index 0000000..1a8ef89
--- /dev/null
+++ b/src/views/bpm/processInstance/index.vue
@@ -0,0 +1,338 @@
+<template>
+  <doc-alert title="娴佺▼鍙戣捣銆佸彇娑堛�侀噸鏂板彂璧�" url="https://doc.iocoder.cn/bpm/process-instance/" />
+
+  <ContentWrap>
+    <!-- 鎼滅储宸ヤ綔鏍� -->
+    <el-form
+      class="-mb-15px"
+      :model="queryParams"
+      ref="queryFormRef"
+      :inline="true"
+      label-width="68px"
+    >
+      <el-form-item label="" prop="name">
+        <el-input
+          v-model="queryParams.name"
+          placeholder="璇疯緭鍏ユ祦绋嬪悕绉�"
+          clearable
+          @keyup.enter="handleQuery"
+          class="!w-240px"
+        />
+      </el-form-item>
+
+      <el-form-item>
+        <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 鎼滅储</el-button>
+      </el-form-item>
+
+      <el-form-item label="" prop="category" class="absolute right-[300px]">
+        <el-select
+          v-model="queryParams.category"
+          placeholder="璇烽�夋嫨娴佺▼鍒嗙被"
+          clearable
+          class="!w-155px"
+          @change="handleQuery"
+        >
+          <el-option
+            v-for="category in categoryList"
+            :key="category.code"
+            :label="category.name"
+            :value="category.code"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="" prop="status" class="absolute right-[130px]">
+        <el-select
+          v-model="queryParams.status"
+          placeholder="璇烽�夋嫨娴佺▼鐘舵��"
+          clearable
+          class="!w-155px"
+          @change="handleQuery"
+        >
+          <el-option
+            v-for="dict in getIntDictOptions(DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS)"
+            :key="dict.value"
+            :label="dict.label"
+            :value="dict.value"
+          />
+        </el-select>
+      </el-form-item>
+
+      <!-- 楂樼骇绛涢�� -->
+      <el-form-item class="absolute right-0">
+        <el-popover
+          :visible="showPopover"
+          persistent
+          :width="400"
+          :show-arrow="false"
+          placement="bottom-end"
+        >
+          <template #reference>
+            <el-button @click="showPopover = !showPopover">
+              <Icon icon="ep:plus" class="mr-5px" />楂樼骇绛涢��
+            </el-button>
+          </template>
+          <el-form-item
+            label="鎵�灞炴祦绋�"
+            class="font-bold"
+            label-position="top"
+            prop="processDefinitionKey"
+          >
+            <el-select
+              v-model="queryParams.processDefinitionKey"
+              placeholder="璇烽�夋嫨娴佺▼瀹氫箟"
+              clearable
+              class="!w-390px"
+              @change="handleQuery"
+            >
+              <el-option
+                v-for="item in processDefinitionList"
+                :key="item.key"
+                :label="item.name"
+                :value="item.key"
+              />
+            </el-select>
+          </el-form-item>
+          <el-form-item label="鍙戣捣鏃堕棿" class="font-bold" label-position="top" prop="createTime">
+            <el-date-picker
+              v-model="queryParams.createTime"
+              value-format="YYYY-MM-DD HH:mm:ss"
+              type="daterange"
+              start-placeholder="寮�濮嬫棩鏈�"
+              end-placeholder="缁撴潫鏃ユ湡"
+              :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
+              class="!w-240px"
+            />
+          </el-form-item>
+          <el-form-item class="font-bold" label-position="top">
+            <div class="flex justify-end w-full">
+              <el-button @click="resetQuery">娓呯┖</el-button>
+              <el-button @click="showPopover = false">鍙栨秷</el-button>
+              <el-button type="primary" @click="handleQuery">纭</el-button>
+            </div>
+          </el-form-item>
+        </el-popover>
+      </el-form-item>
+    </el-form>
+  </ContentWrap>
+
+  <!-- 鍒楄〃 -->
+  <ContentWrap>
+    <el-table v-loading="loading" :data="list">
+      <el-table-column label="娴佺▼鍚嶇О" align="center" prop="name" min-width="200px" fixed="left" />
+      <el-table-column label="鎽樿" prop="summary" width="180" fixed="left">
+        <template #default="scope">
+          <div class="flex flex-col" v-if="scope.row.summary && scope.row.summary.length > 0">
+            <div v-for="(item, index) in scope.row.summary" :key="index">
+              <el-text type="info"> {{ item.key }} : {{ item.value }} </el-text>
+            </div>
+          </div>
+        </template>
+      </el-table-column>
+      <el-table-column
+        label="娴佺▼鍒嗙被"
+        align="center"
+        prop="categoryName"
+        min-width="100"
+        fixed="left"
+      />
+      <el-table-column label="娴佺▼鐘舵��" prop="status" min-width="200">
+        <template #default="scope">
+          <!-- 瀹℃壒涓姸鎬� -->
+          <template
+            v-if="
+              scope.row.status === BpmProcessInstanceStatus.RUNNING && scope.row.tasks?.length > 0
+            "
+          >
+            <!-- 鍗曚汉瀹℃壒 -->
+            <template v-if="scope.row.tasks.length === 1">
+              <span>
+                <el-button link type="primary" @click="handleDetail(scope.row)">
+                  {{ scope.row.tasks[0].assigneeUser?.nickname }}
+                </el-button>
+                ({{ scope.row.tasks[0].name }}) 瀹℃壒涓�
+              </span>
+            </template>
+            <!-- 澶氫汉瀹℃壒 -->
+            <template v-else>
+              <span>
+                <el-button link type="primary" @click="handleDetail(scope.row)">
+                  {{ scope.row.tasks[0].assigneeUser?.nickname }}
+                </el-button>
+                绛� {{ scope.row.tasks.length }} 浜� ({{ scope.row.tasks[0].name }})瀹℃壒涓�
+              </span>
+            </template>
+          </template>
+          <!-- 闈炲鎵逛腑鐘舵�� -->
+          <template v-else>
+            <dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS" :value="scope.row.status" />
+          </template>
+        </template>
+      </el-table-column>
+      <el-table-column
+        label="鍙戣捣鏃堕棿"
+        align="center"
+        prop="startTime"
+        width="180"
+        :formatter="dateFormatter"
+      />
+      <el-table-column
+        label="缁撴潫鏃堕棿"
+        align="center"
+        prop="endTime"
+        width="180"
+        :formatter="dateFormatter"
+      />
+      <el-table-column label="鎿嶄綔" align="center" fixed="right" width="180">
+        <template #default="scope">
+          <el-button
+            link
+            type="primary"
+            v-hasPermi="['bpm:process-instance:cancel']"
+            @click="handleDetail(scope.row)"
+          >
+            璇︽儏
+          </el-button>
+          <el-button
+            link
+            type="primary"
+            v-if="scope.row.status === 1"
+            v-hasPermi="['bpm:process-instance:query']"
+            @click="handleCancel(scope.row)"
+          >
+            鍙栨秷
+          </el-button>
+          <el-button link type="primary" v-else @click="handleCreate(scope.row)">
+            閲嶆柊鍙戣捣
+          </el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+    <!-- 鍒嗛〉 -->
+    <Pagination
+      :total="total"
+      v-model:page="queryParams.pageNo"
+      v-model:limit="queryParams.pageSize"
+      @pagination="getList"
+    />
+  </ContentWrap>
+</template>
+<script lang="ts" setup>
+import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
+import { dateFormatter } from '@/utils/formatTime'
+import { ElMessageBox } from 'element-plus'
+import * as ProcessInstanceApi from '@/api/bpm/processInstance'
+import { CategoryApi, CategoryVO } from '@/api/bpm/category'
+import { ProcessInstanceVO } from '@/api/bpm/processInstance'
+import * as DefinitionApi from '@/api/bpm/definition'
+import { BpmProcessInstanceStatus } from '@/utils/constants'
+
+defineOptions({ name: 'BpmProcessInstanceMy' })
+
+const router = useRouter() // 璺敱
+const message = useMessage() // 娑堟伅寮圭獥
+const { t } = useI18n() // 鍥介檯鍖�
+
+const loading = ref(true) // 鍒楄〃鐨勫姞杞戒腑
+const total = ref(0) // 鍒楄〃鐨勬�婚〉鏁�
+const list = ref([]) // 鍒楄〃鐨勬暟鎹�
+const processDefinitionList = ref<any[]>([]) // 娴佺▼瀹氫箟鍒楄〃
+const queryParams = reactive({
+  pageNo: 1,
+  pageSize: 10,
+  name: '',
+  processDefinitionKey: undefined,
+  category: undefined,
+  status: undefined,
+  createTime: []
+})
+const queryFormRef = ref() // 鎼滅储鐨勮〃鍗�
+const categoryList = ref<CategoryVO[]>([]) // 娴佺▼鍒嗙被鍒楄〃
+const showPopover = ref(false) // 楂樼骇绛涢�夋槸鍚﹀睍绀�
+
+/** 鏌ヨ鍒楄〃 */
+const getList = async () => {
+  loading.value = true
+  try {
+    const data = await ProcessInstanceApi.getProcessInstanceMyPage(queryParams)
+    list.value = data.list
+    total.value = data.total
+  } finally {
+    loading.value = false
+  }
+}
+
+/** 鎼滅储鎸夐挳鎿嶄綔 */
+const handleQuery = () => {
+  queryParams.pageNo = 1
+  getList()
+}
+
+/** 閲嶇疆鎸夐挳鎿嶄綔 */
+const resetQuery = () => {
+  queryFormRef.value.resetFields()
+  handleQuery()
+}
+
+/** 鍙戣捣娴佺▼鎿嶄綔 **/
+const handleCreate = async (row?: ProcessInstanceVO) => {
+  if (row?.id) {
+    const processDefinitionDetail = await DefinitionApi.getProcessDefinition(
+      row.processDefinitionId
+    )
+    // 濡傛灉鏄�愪笟鍔¤〃鍗曘�戯紝璺宠浆鍒板搴旂殑鍙戣捣鐣岄潰
+    if (processDefinitionDetail.formType === 20) {
+      await router.push({
+        path: processDefinitionDetail.formCustomCreatePath,
+        query: {
+          id: row.businessKey
+        }
+      })
+    } else if (processDefinitionDetail.formType === 10) {
+      //濡傛灉鏄�愭祦绋嬭〃鍗曘�戯紝璺宠浆鍒版祦绋嬪彂璧风晫闈�
+      await router.push({
+        name: 'BpmProcessInstanceCreate',
+        query: { processInstanceId: row.id }
+      })
+    }
+  }
+}
+
+/** 鏌ョ湅璇︽儏 */
+const handleDetail = (row: ProcessInstanceVO) => {
+  router.push({
+    name: 'BpmProcessInstanceDetail',
+    query: {
+      id: row.id
+    }
+  })
+}
+
+/** 鍙栨秷鎸夐挳鎿嶄綔 */
+const handleCancel = async (row: ProcessInstanceVO) => {
+  // 浜屾纭
+  const { value } = await ElMessageBox.prompt('璇疯緭鍏ュ彇娑堝師鍥�', '鍙栨秷娴佺▼', {
+    confirmButtonText: t('common.ok'),
+    cancelButtonText: t('common.cancel'),
+    inputPattern: /^[\s\S]*.*\S[\s\S]*$/, // 鍒ゆ柇闈炵┖锛屼笖闈炵┖鏍�
+    inputErrorMessage: '鍙栨秷鍘熷洜涓嶈兘涓虹┖'
+  })
+  // 鍙戣捣鍙栨秷
+  await ProcessInstanceApi.cancelProcessInstanceByStartUser(row.id, value)
+  message.success('鍙栨秷鎴愬姛')
+  // 鍒锋柊鍒楄〃
+  await getList()
+}
+
+/** 婵�娲绘椂 **/
+onActivated(() => {
+  getList()
+})
+
+/** 鍒濆鍖� **/
+onMounted(async () => {
+  await getList()
+  categoryList.value = await CategoryApi.getCategorySimpleList()
+  // 鑾峰彇娴佺▼瀹氫箟鍒楄〃
+  processDefinitionList.value = await DefinitionApi.getSimpleProcessDefinitionList()
+})
+</script>

--
Gitblit v1.8.0