Przeglądaj źródła

fix: 审批后不刷新及已完成审批查看

ZhaoJun 1 rok temu
rodzic
commit
8ed8f50e0a
6 zmienionych plików z 754 dodań i 369 usunięć
  1. 67 67
      manifest.json
  2. 74 57
      pages.json
  3. 159 0
      pages/approved/detail.vue
  4. 149 0
      pages/approved/list.vue
  5. 273 238
      pages/audit/OA/detail.vue
  6. 32 7
      services/oa.js

+ 67 - 67
manifest.json

@@ -1,73 +1,73 @@
 {
-    "name" : "BOM",
-    "appid" : "__UNI__87B699A",
-    "description" : "",
-    "versionName" : "2.0.8",
-    "versionCode" : 208,
-    "transformPx" : false,
-    "app-plus" : {
-        /* 5+App特有相关 */
-        "usingComponents" : true,
-        "nvueCompiler" : "uni-app",
-        "splashscreen" : {
-            "alwaysShowBeforeRender" : true,
-            "waiting" : true,
-            "autoclose" : true,
-            "delay" : 0
-        },
-        "modules" : {},
-        /* 模块配置 */
-        "distribute" : {
-            /* 应用发布信息 */
-            "android" : {
-                /* android打包配置 */
-                "permissions" : [
-                    "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
-                    "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
-                    "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
-                    "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
-                    "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
-                    "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
-                    "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
-                    "<uses-permission android:name=\"android.permission.CAMERA\"/>",
-                    "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
-                    "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
-                    "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
-                    "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
-                    "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
-                    "<uses-feature android:name=\"android.hardware.camera\"/>",
-                    "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
-                ]
-            },
-            "ios" : {},
-            /* ios打包配置 */
-            "sdkConfigs" : {}
-        }
+  "name": "BOM",
+  "appid": "__UNI__87B699A",
+  "description": "",
+  "versionName": "2.0.9",
+  "versionCode": 209,
+  "transformPx": false,
+  "app-plus": {
+    /* 5+App特有相关 */
+    "usingComponents": true,
+    "nvueCompiler": "uni-app",
+    "splashscreen": {
+      "alwaysShowBeforeRender": true,
+      "waiting": true,
+      "autoclose": true,
+      "delay": 0
     },
-    /* SDK配置 */
-    "quickapp" : {},
-    /* 快应用特有相关 */
-    "mp-weixin" : {
-        /* 小程序特有相关 */
-        "appid" : "",
-        "setting" : {
-            "urlCheck" : false
-        },
-        "usingComponents" : true
+    "modules": {},
+    /* 模块配置 */
+    "distribute": {
+      /* 应用发布信息 */
+      "android": {
+        /* android打包配置 */
+        "permissions": [
+          "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
+          "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
+          "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
+          "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
+          "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
+          "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
+          "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
+          "<uses-permission android:name=\"android.permission.CAMERA\"/>",
+          "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
+          "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
+          "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
+          "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
+          "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
+          "<uses-feature android:name=\"android.hardware.camera\"/>",
+          "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
+        ]
+      },
+      "ios": {},
+      /* ios打包配置 */
+      "sdkConfigs": {}
+    }
+  },
+  /* SDK配置 */
+  "quickapp": {},
+  /* 快应用特有相关 */
+  "mp-weixin": {
+    /* 小程序特有相关 */
+    "appid": "",
+    "setting": {
+      "urlCheck": false
     },
-    "h5" : {
-        "devServer" : {
-            "https" : false,
-            "port" : "",
-            "proxy" : {
-                "/api" : {
-                    "target" : "http://47.96.12.136:8896", // 后端接口的基础地址
-                    "changeOrigin" : true // 支持跨域
-                }
-            }
-        },
-        "router" : {
-            "base" : ""
+    "usingComponents": true
+  },
+  "h5": {
+    "devServer": {
+      "https": false,
+      "port": "",
+      "proxy": {
+        "/api": {
+          "target": "http://47.96.12.136:8896", // 后端接口的基础地址
+          "changeOrigin": true // 支持跨域
         }
+      }
+    },
+    "router": {
+      "base": ""
     }
+  }
 }

+ 74 - 57
pages.json

@@ -1,58 +1,75 @@
 {
-	"pages": [{
-			"path": "pages/index/index"
-		},
-		{
-			"path": "pages/login/login",
-			"style": {
-				"navigationBarBackgroundColor": "#7399DB"
-			}
-		},
-		{
-			"path": "pages/audit/list"
-		},
-		{
-			"path": "pages/audit/detail",
-			"style": {
-				"navigationBarTitleText": "",
-				"enablePullDownRefresh": false
-			}
-		},
-		{
-			"path": "pages/audit/excelDetail",
-			"style": {
-				"navigationBarTitleText": "",
-				"enablePullDownRefresh": false
-			}
-		},
-		{
-			"path": "pages/audit/OA/list"
-		},
-		{
-			"path": "pages/audit/OA/detail",
-			"style": {
-				"navigationBarTitleText": "",
-				"enablePullDownRefresh": false
-			}
-		},
-		{
-			"path": "pages/audit/OA/excelDetail",
-			"style": {
-				"navigationBarTitleText": "",
-				"enablePullDownRefresh": false
-			}
-		},
-		{
-			"path": "pages/preview/preview",
-			"style": {
-				"navigationBarTitleText": "",
-				"enablePullDownRefresh": false
-			}
-		}
-	],
-	"globalStyle": {
-		"app-plus": {
-			"titleNView": false
-		}
-	}
-}
+  "pages": [
+    {
+      "path": "pages/index/index"
+    },
+    {
+      "path": "pages/login/login",
+      "style": {
+        "navigationBarBackgroundColor": "#7399DB"
+      }
+    },
+    {
+      "path": "pages/audit/list"
+    },
+    {
+      "path": "pages/audit/detail",
+      "style": {
+        "navigationBarTitleText": "",
+        "enablePullDownRefresh": false
+      }
+    },
+    {
+      "path": "pages/audit/excelDetail",
+      "style": {
+        "navigationBarTitleText": "",
+        "enablePullDownRefresh": false
+      }
+    },
+    {
+      "path": "pages/audit/OA/list"
+    },
+    {
+      "path": "pages/audit/OA/detail",
+      "style": {
+        "navigationBarTitleText": "",
+        "enablePullDownRefresh": false
+      }
+    },
+    {
+      "path": "pages/audit/OA/excelDetail",
+      "style": {
+        "navigationBarTitleText": "",
+        "enablePullDownRefresh": false
+      }
+    },
+    {
+      "path": "pages/preview/preview",
+      "style": {
+        "navigationBarTitleText": "",
+        "enablePullDownRefresh": false
+      }
+    },
+    {
+      "path": "pages/approved/list",
+      "style": {
+        "navigationBarTitleText": "",
+        "enablePullDownRefresh": false
+      }
+    }
+      ,{
+            "path" : "pages/approved/detail",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "",
+                "enablePullDownRefresh": false
+            }
+            
+        }
+    ],
+  "globalStyle": {
+    "app-plus": {
+      "titleNView": false
+    }
+  }
+}

+ 159 - 0
pages/approved/detail.vue

@@ -0,0 +1,159 @@
+<template>
+  <view class="page-detail">
+    <view class="page-center">
+      <uni-section title="清单名称" type="line" style="margin-top: 0" />
+      <text style="padding-left: 20rpx">{{ detail.name }}</text>
+
+      <!-- 表单数据 -->
+      <template v-if="formList.length > 0">
+        <uni-section title="表单数据" type="line" />
+        <uni-forms class="form" label-align="right" :labelWidth="100">
+          <uni-forms-item
+            v-for="item in formList"
+            :label="item.name"
+            name="email"
+          >
+            <view class="content">{{ item.value.join(",") }}</view>
+          </uni-forms-item>
+        </uni-forms>
+      </template>
+
+      <!-- 附件信息 -->
+      <template v-if="attachments.length > 0">
+        <uni-section title="附件信息" type="line" />
+        <view class="attachment" v-for="item in attachments" :key="item.id">
+          <!-- {{item.name}} -->
+          <previewFile :src="item.url" :name="item.name" />
+        </view>
+      </template>
+
+      <!-- 审批信息 -->
+      <uni-section title="审批信息" type="line" />
+      <uni-steps
+        :options="auditList"
+        :active="currentStep"
+        direction="column"
+      />
+    </view>
+  </view>
+</template>
+
+<script>
+import { getOAAuditDetail } from "@/services/oa";
+
+export default {
+  data() {
+    return {
+      id: -1,
+      detail: {},
+      auditList: [],
+      currentStep: 0,
+    };
+  },
+
+  computed: {
+    formList() {
+      const form = this.detail?.form;
+      if (!form) {
+        return [];
+      }
+      try {
+        const formDatas = JSON.parse(form);
+        if (formDatas && formDatas.length) {
+          return formDatas.filter((item) => item.type !== "DIYTable");
+        }
+        return [];
+      } catch {
+        return [];
+      }
+    },
+    attachments() {
+      if (this.detail?.Files?.length) {
+        return this.detail.Files;
+      }
+      return [];
+    },
+  },
+
+  onLoad(query) {
+    if (query?.id !== undefined) {
+      this.id = Number(query.id);
+    } else {
+      return;
+    }
+
+    this.getDetail();
+  },
+
+  methods: {
+    getDetail() {
+      getOAAuditDetail(this.id)
+        .then((result) => {
+          this.detail = result;
+          this.getAuditList(result.OaAuditList, result.AuditorInfo);
+        })
+        .catch((err) => {
+          console.log(err);
+        });
+    },
+
+    getAuditList(list, currentAuditor) {
+      // 填充审核人列表
+      if (list && list.length) {
+        this.auditList = list.map((item, index) => {
+          if (currentAuditor.ID === item.auditor) {
+            this.currentStep = index;
+          }
+          return {
+            title: item.seq_name,
+            desc: `审核人:${item.AuditorUser.CName || "-"}`,
+          };
+        });
+      }
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.page-detail {
+  min-height: 100vh;
+  padding: 20rpx 30rpx 40rpx;
+  background: url("~@/static/index/bg.png") no-repeat center;
+  background-size: cover;
+  background-attachment: fixed;
+
+  .page-center {
+    padding: 30rpx;
+    padding-top: 0;
+    background-color: #fff;
+  }
+}
+
+.btns {
+  display: flex;
+  margin-top: 40rpx;
+}
+
+.excel-detail {
+  color: #2f42ca;
+  text-decoration: underline;
+  padding-left: 20rpx;
+}
+
+.form {
+  width: 90%;
+  margin: 0 auto;
+
+  .content {
+    line-height: 44rpx;
+    padding: 14rpx;
+    word-break: break-all;
+  }
+}
+
+.attachment {
+  padding-left: 20rpx;
+  margin-bottom: 20rpx;
+}
+</style>

+ 149 - 0
pages/approved/list.vue

@@ -0,0 +1,149 @@
+<template>
+  <view class="page-detail">
+    <view class="page-center">
+      <uni-section title="已审批列表" type="line" style="margin-top: 0" />
+      <uni-card
+        v-for="item in list"
+        :key="item.id"
+        :title="item.name || '无标题'"
+        @click="toDetail(item)"
+      >
+        <view class="item">
+          <view class="label">发起时间</view>
+          <view class="value">{{ formateDate(item.create_time) }}</view>
+        </view>
+        <view class="item">
+          <view class="label">发起人</view>
+          <view class="value">{{
+            item.AuthorInfo && item.AuthorInfo.CName
+          }}</view>
+        </view>
+        <button
+          size="mini"
+          type="default"
+          class="detailBtn"
+          @click="toDetail(item)"
+        >
+          查看详情
+        </button>
+        <!-- <view class="row">
+					<view class="item">
+						<view class="label">分类</view>
+						<view class="value">{{'classify[item.classify_id]' || '未知分类'}}</view>
+					</view>
+					<view class="item">
+						<view class="label">提交人</view>
+						<view class="value">{{'item.AuthorInfo && item.AuthorInfo.CName'}}</view>
+					</view>
+				</view> -->
+      </uni-card>
+      <view style="text-align: center" v-if="list.length == 0">暂无审批项</view>
+    </view>
+  </view>
+</template>
+
+<script>
+import { queryApprovedList } from "@/services/oa.js";
+
+export default {
+  data() {
+    return {
+      list: [],
+      pagination: {
+        current: 1,
+        pageSize: 10,
+        total: 0,
+      },
+    };
+  },
+
+  onShow() {
+    this.queryList();
+  },
+
+  methods: {
+    async queryList() {
+      var { list, pagination } = await queryApprovedList();
+      this.list = list;
+      this.pagination = pagination;
+    },
+
+    formateDate(date) {
+      const origin = new Date(date);
+      const datePart =
+        origin.getFullYear() +
+        "-" +
+        (origin.getMonth() + 1) +
+        "-" +
+        origin.getDate();
+      const timePart =
+        origin.getHours() +
+        ":" +
+        origin.getMinutes() +
+        ":" +
+        origin.getSeconds();
+      return datePart + " " + timePart;
+    },
+
+    toDetail(item) {
+      uni.navigateTo({
+        url: `./detail?id=${item.id}`,
+      });
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.page-detail {
+  min-height: 100vh;
+  padding: 15px;
+  background: url("~@/static/index/bg.png") no-repeat center;
+  background-size: cover;
+  background-attachment: fixed;
+
+  .page-center {
+    padding: 20rpx;
+    padding-top: 0;
+    border-radius: 5px;
+    background-color: #fff;
+  }
+}
+
+.item {
+  margin-bottom: 14px;
+
+  .label {
+    font-weight: bold;
+    font-size: 16px;
+    margin-bottom: 5px;
+  }
+
+  .value {
+    font-size: 14;
+  }
+}
+
+.row {
+  display: flex;
+
+  .item {
+    width: 50%;
+    display: flex;
+    align-items: center;
+
+    .label {
+      margin-right: 12px;
+      margin-bottom: 0;
+    }
+  }
+}
+
+.detailBtn {
+  position: absolute;
+  bottom: 20px;
+  right: 20px;
+  background-color: #2979ff;
+  color: #fff;
+}
+</style>

+ 273 - 238
pages/audit/OA/detail.vue

@@ -1,247 +1,282 @@
 <template>
-	<view class="page-detail">
-		<view class="page-center">
-			<uni-section title="清单名称" type="line" style="margin-top: 0;" />
-			<text style="padding-left: 20rpx;">{{detail.name}}</text>
-
-			<!-- 表单数据 -->
-			<template v-if="formList.length > 0">
-				<uni-section title="表单数据" type="line" />
-				<uni-forms class="form" label-align="right" :labelWidth="100">
-					<uni-forms-item v-for="item in formList" :label="item.name" name="email">
-						<view class="content">{{item.value.join(",")}}</view>
-					</uni-forms-item>
-				</uni-forms>
-			</template>
-
-			<!-- 附件信息 -->
-			<template v-if="attachments.length > 0">
-				<uni-section title="附件信息" type="line" />
-				<view class="attachment" v-for="item in attachments" :key="item.id">
-					<!-- {{item.name}} -->
-					<previewFile :src="item.url" :name="item.name" />
-				</view>
-			</template>
-
-			<!-- 审批信息 -->
-			<uni-section title="审批信息" type="line" />
-			<uni-steps :options="auditList" :active="currentStep" direction="column" />
-
-			<!-- 清单详情 -->
-			<!-- 	<uni-section title="清单详情" type="line" />
+  <view class="page-detail">
+    <view class="page-center">
+      <uni-section title="清单名称" type="line" style="margin-top: 0" />
+      <text style="padding-left: 20rpx">{{ detail.name }}</text>
+
+      <!-- 表单数据 -->
+      <template v-if="formList.length > 0">
+        <uni-section title="表单数据" type="line" />
+        <uni-forms class="form" label-align="right" :labelWidth="100">
+          <uni-forms-item
+            v-for="item in formList"
+            :label="item.name"
+            name="email"
+          >
+            <view class="content">{{ item.value.join(",") }}</view>
+          </uni-forms-item>
+        </uni-forms>
+      </template>
+
+      <!-- 附件信息 -->
+      <template v-if="attachments.length > 0">
+        <uni-section title="附件信息" type="line" />
+        <view class="attachment" v-for="item in attachments" :key="item.id">
+          <!-- {{item.name}} -->
+          <previewFile :src="item.url" :name="item.name" />
+        </view>
+      </template>
+
+      <!-- 审批信息 -->
+      <uni-section title="审批信息" type="line" />
+      <uni-steps
+        :options="auditList"
+        :active="currentStep"
+        direction="column"
+      />
+
+      <!-- 清单详情 -->
+      <!-- 	<uni-section title="清单详情" type="line" />
 			<view class="excel-detail" @click="toExcelDetail">查看详情</view> -->
 
-			<!-- 审批按钮 -->
-			<view class="btns" v-if="isAuditor">
-				<button type="primary" @click="showAuditModal" style="width: 200rpx; height: 45px;">通过</button>
-				<button type="warn" @click="showRejectModal" style="width: 200rpx; height: 45px;">拒绝</button>
-			</view>
-		</view>
-
-
-		<!-- 审核通过弹窗 -->
-		<uni-popup ref="popup" type="dialog">
-			<uni-popup-dialog mode="input" placeholder="请输入审批意见" :duration="2000" :before-close="true" @close="auditClose"
-				@confirm="auditConfirm" />
-		</uni-popup>
-
-		<!-- 审批拒绝弹窗 -->
-		<uni-popup ref="rejectPopup" type="dialog">
-			<uni-popup-dialog mode="input" placeholder="请输入拒绝原因" :duration="2000" :before-close="true" @close="rejectClose"
-				@confirm="rejectConfirm"></uni-popup-dialog>
-		</uni-popup>
-	</view>
+      <!-- 审批按钮 -->
+      <view class="btns" v-if="isAuditor">
+        <button
+          type="primary"
+          @click="showAuditModal"
+          style="width: 200rpx; height: 45px"
+        >
+          通过
+        </button>
+        <button
+          type="warn"
+          @click="showRejectModal"
+          style="width: 200rpx; height: 45px"
+        >
+          拒绝
+        </button>
+      </view>
+    </view>
+
+    <!-- 审核通过弹窗 -->
+    <uni-popup ref="popup" type="dialog">
+      <uni-popup-dialog
+        mode="input"
+        placeholder="请输入审批意见"
+        :duration="2000"
+        :before-close="true"
+        @close="auditClose"
+        @confirm="auditConfirm"
+      />
+    </uni-popup>
+
+    <!-- 审批拒绝弹窗 -->
+    <uni-popup ref="rejectPopup" type="dialog">
+      <uni-popup-dialog
+        mode="input"
+        placeholder="请输入拒绝原因"
+        :duration="2000"
+        :before-close="true"
+        @close="rejectClose"
+        @confirm="rejectConfirm"
+      ></uni-popup-dialog>
+    </uni-popup>
+  </view>
 </template>
 
 <script>
-	import {
-		gerCurrentUser
-	} from "@/services/user.js"
-
-	import previewFile from "@/components/preview-file/preview-file.vue"
-	import {
-		audit,
-		getOAAuditDetail
-	} from "../../../services/oa";
-
-	export default {
-		components: {
-			previewFile
-		},
-		data() {
-			return {
-				id: "",
-				detail: {},
-				attachments:[],
-				auditList: [],
-				currentStep: 0,
-				isAuditor: true,
-				query: {},
-				excelFileList: []
-			};
-		},
-		onLoad(query) {
-			if (!uni.getStorageSync('token')) {
-				uni.setStorageSync("token", query['JWT-TOKEN']);
-			}
-			this.id = query.id
-			this.query = query
-			this.checkDeviceType()
-			this.init()
-		},
-		methods: {
-			checkDeviceType() {
-				const userAgent = navigator.userAgent.toLowerCase();
-				const mobileKeywords = ['android', 'iphone', 'ipad', 'ipod', 'mobile'];
-				this.isMobile = mobileKeywords.some(keyword => userAgent.includes(keyword));
-				return this.isMobile
-			},
-
-			async init() {
-				var currentUser = await gerCurrentUser();
-				if (!currentUser) {
-					return
-				}
-				uni.setStorageSync("user", currentUser);
-
-				// if (!this.isMobile) {
-				// 	// 如果是在电脑上打开,转到PC端的页面去
-				// 	window.location.href =
-				// 		`http://120.55.44.4:8896/#/bom/home/detail/${version.project_id}/${version.template_id}?version_id=${this.versionId}&JWT-TOKEN=${this.query['JWT-TOKEN']}`
-				// }
-
-				const detail = await getOAAuditDetail(this.id)
-				this.detail = detail
-				this.attachments = detail.Files
-				this.getAuditList(detail.OaAuditList, detail.AuditorInfo)
-			},
-
-
-			getAuditList(list, currentAuditor) {
-				// 填充审核人列表
-				if (list && list.length) {
-					this.auditList = list.map((item, index) => {
-						if (currentAuditor.ID === item.auditor) {
-							this.currentStep = index
-						}
-						return {
-							title: item.seq_name,
-							desc: `审核人:${item.AuditorUser.CName || '-'}`
-						}
-					})
-				}
-			},
-
-			// 显示通过审批弹窗
-			async showAuditModal() {
-				this.$refs.popup.open();
-			},
-
-			// 通过审批
-			async auditConfirm(audit_comment) {
-				await audit({
-					id: this.id,
-					status: 1,
-					desc: audit_comment
-				})
-				uni.showToast({
-					title: "操作成功"
-				})
-				this.auditClose()
-			},
-
-			auditClose() {
-				this.$refs.popup.close();
-			},
-
-			// 显示拒绝审批弹窗
-			showRejectModal() {
-				this.$refs.rejectPopup.open()
-			},
-
-			async rejectConfirm(audit_comment) {
-				await audit({
-					id: this.id,
-					status: 2,
-					desc: audit_comment
-				})
-				uni.showToast({
-					title: "操作成功"
-				})
-
-				this.rejectClose()
-			},
-
-			rejectClose() {
-				this.$refs.rejectPopup.close();
-			},
-
-			toExcelDetail() {
-				uni.navigateTo({
-					url: `./excelDetail?templateNodeId=${this.templateNodeId}&versionId=${this.versionId}`
-				})
-			}
-		},
-		computed: {
-			formList() {
-				const form = this.detail?.form
-				if (!form) {
-					return []
-				}
-				try {
-					const formDatas = JSON.parse(form)
-					if (formDatas && formDatas.length) {
-						return formDatas.filter(item=>item.type!=='DIYTable')
-					}
-					return []
-				} catch {
-					return []
-				}
-			},
-			
-		}
-	}
+import { gerCurrentUser } from "@/services/user.js";
+
+import previewFile from "@/components/preview-file/preview-file.vue";
+import { audit, getOAAuditDetail } from "../../../services/oa";
+
+export default {
+  components: {
+    previewFile,
+  },
+  data() {
+    return {
+      id: "",
+      detail: {},
+      attachments: [],
+      auditList: [],
+      currentStep: 0,
+      isAuditor: true,
+      query: {},
+      excelFileList: [],
+    };
+  },
+  onLoad(query) {
+    if (!uni.getStorageSync("token")) {
+      uni.setStorageSync("token", query["JWT-TOKEN"]);
+    }
+    this.id = query.id;
+    this.query = query;
+    this.checkDeviceType();
+    this.init();
+  },
+  methods: {
+    checkDeviceType() {
+      const userAgent = navigator.userAgent.toLowerCase();
+      const mobileKeywords = ["android", "iphone", "ipad", "ipod", "mobile"];
+      this.isMobile = mobileKeywords.some((keyword) =>
+        userAgent.includes(keyword)
+      );
+      return this.isMobile;
+    },
+
+    async init() {
+      var currentUser = await gerCurrentUser();
+      if (!currentUser) {
+        return;
+      }
+      uni.setStorageSync("user", currentUser);
+
+      // if (!this.isMobile) {
+      // 	// 如果是在电脑上打开,转到PC端的页面去
+      // 	window.location.href =
+      // 		`http://120.55.44.4:8896/#/bom/home/detail/${version.project_id}/${version.template_id}?version_id=${this.versionId}&JWT-TOKEN=${this.query['JWT-TOKEN']}`
+      // }
+
+      const detail = await getOAAuditDetail(this.id);
+      // 如果传入链接是已完成审批的,则重定向到已审批详情中
+      if (detail.audit_status === 3) {
+        uni.redirectTo({
+          url: `/pages/approved/detail?id=${this.id}`,
+        });
+      }
+      this.detail = detail;
+      this.attachments = detail.Files;
+      this.getAuditList(detail.OaAuditList, detail.AuditorInfo);
+    },
+
+    getAuditList(list, currentAuditor) {
+      // 填充审核人列表
+      if (list && list.length) {
+        this.auditList = list.map((item, index) => {
+          if (currentAuditor.ID === item.auditor) {
+            this.currentStep = index;
+          }
+          return {
+            title: item.seq_name,
+            desc: `审核人:${item.AuditorUser.CName || "-"}`,
+          };
+        });
+      }
+    },
+
+    // 显示通过审批弹窗
+    async showAuditModal() {
+      this.$refs.popup.open();
+    },
+
+    // 通过审批
+    async auditConfirm(audit_comment) {
+      await audit({
+        id: this.id,
+        status: 1,
+        desc: audit_comment,
+      });
+      uni.showToast({
+        title: "操作成功",
+      });
+      this.auditClose();
+      uni.redirectTo({
+        url: `/pages/approved/detail?id=${this.id}`,
+      });
+    },
+
+    auditClose() {
+      this.$refs.popup.close();
+    },
+
+    // 显示拒绝审批弹窗
+    showRejectModal() {
+      this.$refs.rejectPopup.open();
+    },
+
+    async rejectConfirm(audit_comment) {
+      await audit({
+        id: this.id,
+        status: 2,
+        desc: audit_comment,
+      });
+      uni.showToast({
+        title: "操作成功",
+      });
+
+      this.rejectClose();
+    },
+
+    rejectClose() {
+      this.$refs.rejectPopup.close();
+    },
+
+    toExcelDetail() {
+      uni.navigateTo({
+        url: `./excelDetail?templateNodeId=${this.templateNodeId}&versionId=${this.versionId}`,
+      });
+    },
+  },
+  computed: {
+    formList() {
+      const form = this.detail?.form;
+      if (!form) {
+        return [];
+      }
+      try {
+        const formDatas = JSON.parse(form);
+        if (formDatas && formDatas.length) {
+          return formDatas.filter((item) => item.type !== "DIYTable");
+        }
+        return [];
+      } catch {
+        return [];
+      }
+    },
+  },
+};
 </script>
 
 <style lang="less" scoped>
-	.page-detail {
-		min-height: 100vh;
-		padding: 20rpx 30rpx 40rpx;
-		background: url("~@/static/index/bg.png") no-repeat center;
-		background-size: cover;
-		background-attachment: fixed;
-
-		.page-center {
-			padding: 30rpx;
-			padding-top: 0;
-			background-color: #fff;
-		}
-	}
-
-	.btns {
-		display: flex;
-		margin-top: 40rpx;
-	}
-
-	.excel-detail {
-		color: #2f42ca;
-		text-decoration: underline;
-		padding-left: 20rpx;
-	}
-
-	.form {
-		width: 90%;
-		margin: 0 auto;
-
-		.content {
-			line-height: 44rpx;
-			padding: 14rpx;
-			word-break: break-all;
-		}
-	}
-
-	.attachment {
-		padding-left: 20rpx;
-		margin-bottom: 20rpx;
-	}
-</style>
+.page-detail {
+  min-height: 100vh;
+  padding: 20rpx 30rpx 40rpx;
+  background: url("~@/static/index/bg.png") no-repeat center;
+  background-size: cover;
+  background-attachment: fixed;
+
+  .page-center {
+    padding: 30rpx;
+    padding-top: 0;
+    background-color: #fff;
+  }
+}
+
+.btns {
+  display: flex;
+  margin-top: 40rpx;
+}
+
+.excel-detail {
+  color: #2f42ca;
+  text-decoration: underline;
+  padding-left: 20rpx;
+}
+
+.form {
+  width: 90%;
+  margin: 0 auto;
+
+  .content {
+    line-height: 44rpx;
+    padding: 14rpx;
+    word-break: break-all;
+  }
+}
+
+.attachment {
+  padding-left: 20rpx;
+  margin-bottom: 20rpx;
+}
+</style>

+ 32 - 7
services/oa.js

@@ -1,15 +1,40 @@
-import request from "./request"
+import request from "./request";
 
+/**
+ * 获取待审批列表
+ * @returns {{list: any[], pagination:{total: number, pageSize: number, current: number}}} 待审批清单和分页信息
+ */
 export async function getOAAuditList() {
-	const res = await request('v1/oa/audit/list?pageSize=99999', 'GET');
-	return res.data
+  const res = await request("v1/oa/audit/list?pageSize=99999", "GET");
+  console.log(res.data);
+  return res.data;
 }
 
+/**
+ * 获取已审批列表
+ * @param  {{pageSize: number, currentPage: number}} data 分页参数
+ * @returns
+ */
+export const queryApprovedList = async (data) => {
+  const res = await request("v1/oa/audited/my/list", "GET", data);
+  if (res?.data) return res.data;
+};
+
+/**
+ * 获取审批单详情
+ * @param  {number} id 审批单id
+ * @returns
+ */
 export async function getOAAuditDetail(id) {
-	const res = await request(`v1/oa/audit/detail?id=${id}`, 'GET')
-	return res.data
+  const res = await request(`v1/oa/audit/detail?id=${id}`, "GET");
+  return res.data;
 }
 
+/**
+ * 审核
+ * @param {*} data
+ * @returns
+ */
 export async function audit(data) {
-	return await request('v1/oa/audit/status', 'GET', data)
-}
+  return await request("v1/oa/audit/status", "GET", data);
+}