Browse Source

feat:工单增加审批流

lupeng 2 months ago
parent
commit
e76b606d5e
3 changed files with 110 additions and 57 deletions
  1. 18 0
      src/api/flow/index.ts
  2. 63 50
      src/views/base/apply/apply.vue
  3. 29 7
      src/views/base/apply/index.vue

+ 18 - 0
src/api/flow/index.ts

@@ -106,3 +106,21 @@ export function queryFlowRecord(insId: string) {
     method: "get",
   });
 }
+
+
+// 提交流程
+export function submitFormDataFlow(data: object) {
+  return request({
+    url: `/api/v1/ProcessFormData/startFlow`,
+    method: "post",
+    data: data,
+  });
+}
+// 流程撤销
+export function cancelFormDataFlow(data: object) {
+  return request({
+    url: `/api/v1/ProcessFormData/cancelFlow`,
+    method: "post",
+    data: data,
+  });
+}

+ 63 - 50
src/views/base/apply/apply.vue

@@ -56,54 +56,31 @@
         @click="showProExcel(rowData.id)"
         >查看表格数据</el-button
       >
-      <div class="el-descriptions__title">提交申请</div>
-      <div class="applyForm" v-if="checkList.length > 0">
-        <template v-for="(item, index) in checkList" :key="item">
-          <el-form :model="item" ref="applyFormRef">
-            <el-row>
-              <el-col :span="12" style="display: flex">
-                <svg-icon
-                  :icon-class="
-                    rowData.state == '3'
-                      ? 'jiantoumr'
-                      : item.sort == rowData.sort
-                        ? 'jiantou'
-                        : 'jiantoumr'
-                  "
-                  v-if="showStatus"
-                  style="margin-right: 10px"
-                  size="30"
-                />
-                <el-form-item
-                  style="flex: 1; align-items: start"
-                  :label="item.positionName + ':'"
-                  :rules="[{ required: true }]"
-                  prop="userName"
-                >
-                  <el-tree-select
-                    v-model="item.userName"
-                    :data="userList"
-                    :disabled="showStatus"
-                    filterable
-                  />
-                </el-form-item>
-              </el-col>
-              <el-col :span="12">
-                <el-form-item
-                  style="margin-left: 20px"
-                  label="备注:"
-                  v-if="item.remark"
-                  prop="remark"
-                >
-                  {{ item.remark }}
-                </el-form-item>
-              </el-col>
-            </el-row>
-          </el-form>
-        </template>
+      <div class="el-descriptions__title" v-if="!showStatus">提交申请</div>
+      <div class="applyForm" v-if="!showStatus">
+
+        <el-form ref="flowFormRef" v-model="flowForm" label-width="100px">
+          <el-form-item label="选择流程模板">
+            <el-tree-select
+              v-model="flowForm.definitionId"
+              :data="flowDataList"
+              filterable
+              :props="{ label: 'flowName', value: 'id' }"
+              @change="whenSelectFlow"
+            />
+          </el-form-item>
+          <el-form-item :label="name" v-if="name">
+            <el-tree-select
+              v-model="flowForm.users"
+              :data="nextUserList"
+              filterable
+              :props="{ label: 'userName', value: 'userName' }"
+            />
+          </el-form-item>
+        </el-form>
       </div>
       <div class="btns">
-        <el-button type="primary" @click="submit" v-if="!showStatus"
+        <el-button type="primary" @click="sureToSave" v-if="!showStatus"
           >提交</el-button
         >
       </div>
@@ -143,6 +120,7 @@ import {
   examineList,
   getExcelData,
 } from "@/api/apply";
+import {getNextUser, queryFlowDataList, submitFlow, submitFormDataFlow} from "@/api/flow";
 import { getUserTree } from "@/api/system/user";
 import ExcelDataBbox from "@/views/base/apply/excelDataBbox.vue";
 const props = defineProps({
@@ -157,18 +135,52 @@ const dialog8 = reactive({
   title: "表单列表",
   visible: false,
 });
+// 流程定义的列表
+const flowDataList = ref([]);
+const getFlowList = () => {
+  queryFlowDataList({ flowType: flowForm.flow_type }).then((res) => {
+    flowDataList.value = res.data;
+  });
+};
 const showProList = ref([]);
 const showProExcel = async (id) => {
   const { data, code } = await getExcelData(id);
   showProList.value = data;
   dialog8.visible = true;
 };
+
+const flowFormRef = ref();
+const flowForm = reactive({
+  businessId: "",
+  flow_type: "workFormService",
+  definitionId: "",
+  users: "",
+});
 const excelShow = ref(false);
 const ExDataObj = ref({});
 const toShowExcel = (item) => {
   ExDataObj.value = item;
   excelShow.value = true;
 };
+const nextUserList=ref([]);
+const name = ref("");
+const whenSelectFlow = () => {
+    //   选择完模板之后  下一节点人员 type 1 流程 2 任务
+    getNextUser("1", flowForm.definitionId).then((res) => {
+        name.value = res.data?.roleName ?? "";
+        nextUserList.value = res.data?.users ?? [];
+    });
+};
+
+const sureToSave = () => {
+  flowForm.businessId=props.rowData.id;
+  submitFormDataFlow(flowForm).then(() => {
+    ElMessage.success("提交成功");
+    emits("close");
+    emits("dataList");
+
+  });
+};
 const emits = defineEmits(["close", "dataList"]);
 const getStatus = (val) => {
   switch (val) {
@@ -254,12 +266,13 @@ const getExamineList = async () => {
 };
 onMounted(async () => {
   await getlogList();
-  queryUserList();
-  if (props.showStatus == true) {
-    await getExamineList();
+  //queryUserList();
+  getFlowList();
+  /*if (props.showStatus == true) {
+    getFlowList();
   } else {
     await getFormListData(props.rowData.formType);
-  }
+  }*/
 });
 </script>
 <style lang="scss" scoped>

+ 29 - 7
src/views/base/apply/index.vue

@@ -20,11 +20,18 @@
       <template #menu="{ row, index, type }">
         <el-button
           @click="addApply(row)"
-          v-if="row.state == '0' || row.state == '1'"
+          v-if="row.state == '0' || row.state == '2'|| row.state == '-1'"
           text
           type="primary"
           >发起申请</el-button
         >
+          <el-button
+                  link
+                  icon="el-icon-copy-document"
+                  v-if="row.state == '3'"
+                  @click="onCancelFlow(row)"
+          >撤销</el-button
+          >
         <el-button
           @click="showApply(row)"
           v-if="row.state != '0'"
@@ -56,6 +63,7 @@ import { useCrud } from "@/hooks/userCrud";
 import { useCommonStoreHook, useDictionaryStore } from "@/store";
 import dictDataUtil from "@/common/configs/dictDataUtil";
 import Apply from "./apply.vue";
+import {cancelFormDataFlow} from "@/api/flow";
 const { isShowTable, tableType } = toRefs(useCommonStoreHook());
 const activeName = ref("no");
 // 数据字典相关
@@ -67,9 +75,11 @@ const rowData = ref({});
 const showStatus = ref(false);
 const applyKey = ref(false);
 const addApply = (row) => {
-  applyKey.value = !applyKey.value;
   rowData.value = row;
-  showStatus.value = false;
+  if(row.state==0||row.state==-1||row.state==2){
+    showStatus.value = false;
+  }
+
   dialog.value.visible = true;
 };
 const showApply = (row) => {
@@ -82,7 +92,15 @@ const dialog = ref({
   visible: false,
   title: "归档申请",
 });
-
+const onCancelFlow=(row)=>{
+    cancelFormDataFlow({
+        businessId: row.id,
+        flowIns: row.flowIns,
+    }).then(() => {
+        ElMessage.success("撤销成功");
+        dataList();
+    });
+}
 // 传入一个url,后面不带/
 const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
   useCrud({
@@ -177,15 +195,19 @@ option.value = Object.assign(option.value, {
         },
         {
           label: "驳回",
-          value: "1",
+          value: "-1",
         },
         {
-          label: "审核中",
+          label: "撤回",
           value: "2",
         },
+          {
+              label: "审核中",
+              value: "3",
+          },
         {
           label: "完成",
-          value: "3",
+          value: "1",
         },
       ],
     },