소스 검색

feat: BOM 添加已审核列表和已审核详情页面

ZhaoJun 1 년 전
부모
커밋
db55347b91
9개의 변경된 파일651개의 추가작업 그리고 58개의 파일을 삭제
  1. 29 10
      pages.json
  2. 366 0
      pages/approved/BOM/detail.vue
  3. 19 0
      pages/approved/BOM/excelDetail.vue
  4. 151 0
      pages/approved/BOM/list.vue
  5. 13 0
      pages/approved/README.md
  6. 13 18
      pages/audit/OA/excelDetail.vue
  7. 10 1
      pages/audit/detail.vue
  8. 13 18
      pages/audit/excelDetail.vue
  9. 37 11
      services/bom.js

+ 29 - 10
pages.json

@@ -56,17 +56,36 @@
         "navigationBarTitleText": "",
         "enablePullDownRefresh": false
       }
+    },
+    {
+      "path": "pages/approved/detail",
+      "style": {
+        "navigationBarTitleText": "",
+        "enablePullDownRefresh": false
+      }
+    },
+    {
+      "path": "pages/approved/BOM/list",
+      "style": {
+        "navigationBarTitleText": "",
+        "enablePullDownRefresh": false
+      }
+    },
+    {
+      "path": "pages/approved/BOM/detail",
+      "style": {
+        "navigationBarTitleText": "",
+        "enablePullDownRefresh": false
+      }
+    },
+    {
+      "path": "pages/approved/BOM/excelDetail",
+      "style": {
+        "navigationBarTitleText": "",
+        "enablePullDownRefresh": false
+      }
     }
-      ,{
-            "path" : "pages/approved/detail",
-            "style" :                                                                                    
-            {
-                "navigationBarTitleText": "",
-                "enablePullDownRefresh": false
-            }
-            
-        }
-    ],
+  ],
   "globalStyle": {
     "app-plus": {
       "titleNView": false

+ 366 - 0
pages/approved/BOM/detail.vue

@@ -0,0 +1,366 @@
+<template>
+  <view class="page-detail">
+    <view class="page-center">
+      <uni-section title="清单名称" type="line"></uni-section>
+      <text style="padding-left: 20rpx">{{ version.version_name }}</text>
+
+      <!-- 表单数据 -->
+      <template v-if="formList.length > 0">
+        <uni-section title="表单数据" type="line"></uni-section>
+        <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="excelFileList.length > 0">
+        <uni-section title="附件信息" type="line"></uni-section>
+        <view class="attachment" v-for="item in excelFileList" :key="item.id">
+          <!-- {{item.name}} -->
+          <previewFile :src="item.url" :name="item.name" />
+        </view>
+      </template>
+
+      <!-- 审批信息 -->
+      <uni-section title="审批信息" type="line"></uni-section>
+      <uni-steps
+        :options="flow.list.FlowNodes"
+        :active="flow.current"
+        direction="column"
+      ></uni-steps>
+
+      <!-- 清单详情 -->
+      <uni-section title="清单详情" type="line"></uni-section>
+      <view class="excel-detail" @click="toExcelDetail">查看详情</view>
+      <!-- 审批按钮 -->
+      <view class="btns" v-if="isAuditor">
+        <button type="primary" @click="showAuditModal">通过</button>
+        <button type="warn" @click="showRejectModal">拒绝</button>
+      </view>
+    </view>
+
+    <!-- 审核通过弹窗 -->
+    <uni-popup ref="popup" type="dialog">
+      <uni-popup-dialog
+        type="info"
+        mode="base"
+        title="审批"
+        content="是否通过审批"
+        :duration="2000"
+        :before-close="true"
+        @close="auditClose"
+        @confirm="auditConfirm"
+      ></uni-popup-dialog>
+    </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 {
+  queryAttachment,
+  queryAuditList,
+  approve,
+  queryCheckedVersionDetail,
+} from "@/services/bom.js";
+import { gerCurrentUser } from "@/services/user.js";
+import previewFile from "@/components/preview-file/preview-file.vue";
+
+export default {
+  components: {
+    previewFile,
+  },
+  computed: {
+    formList() {
+      if (!this.version.formStr && !this.version.ding_schema) {
+        return [];
+      }
+      if (this.version.formStr) {
+        try {
+          const formStrArray = JSON.parse(this.version.formStr);
+          const formComponents = [];
+          if (formStrArray && formStrArray.length) {
+            formStrArray.forEach((item) => {
+              formComponents.push(JSON.parse(item));
+            });
+          }
+          const formComponent = formComponents.filter(
+            (item) => item.template_node_id === this.version.template_node_id
+          );
+          console.log(formComponent);
+          return formComponent[0].formComponentValues || [];
+        } catch (e) {
+          return [];
+        }
+      }
+      if (this.version.ding_schema) {
+        try {
+          const formStrArray = JSON.parse(this.version.ding_schema);
+          const formComponents = [];
+          if (formStrArray && formStrArray.length) {
+            formStrArray.forEach((item) => {
+              formComponents.push(JSON.parse(item));
+            });
+          }
+          const formComponent = formComponents.filter(
+            (item) => item.template_node_id === this.version.template_node_id
+          );
+          return (
+            formComponent[0].formComponentValues.filter(
+              (item) => !item.id.includes("DIYTable")
+            ) || []
+          );
+        } catch (e) {
+          return [];
+        }
+      }
+    },
+  },
+  data() {
+    return {
+      projectId: 580,
+      templateNodeId: 0,
+      id: 0,
+      version: {},
+      excelFileList: [],
+      auditMessage: "",
+      flow: {
+        active: 0,
+        active_id: null,
+        current: 0,
+        currentNode: {},
+        list: {
+          FlowNodes: [],
+        },
+      },
+      isAuditor: false,
+      isMobile: true,
+      options: {},
+    };
+  },
+  onLoad(options) {
+    this.templateNodeId = options.templateNodeId;
+    this.projectId = Number(options.projectId);
+    this.id = options.excel_id;
+    // 如果链接带着token, 则强制替换最新的token
+    if (options["JWT-TOKEN"]) {
+      uni.setStorageSync("token", options["JWT-TOKEN"]);
+    }
+    this.options = options;
+    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);
+
+      var version = await queryCheckedVersionDetail(this.id);
+      if (!this.isMobile) {
+        // 如果是在电脑上打开,转到PC端的页面去
+        window.location.href = `http://120.55.44.4:8896/#/bom/home/detail/${version.project_id}/${version.template_id}?excel_id=${this.id}&JWT-TOKEN=${this.options["JWT-TOKEN"]}`;
+      }
+
+      if (version.flow_id) {
+        this.getFlow(version);
+      }
+      this.version = version;
+
+      if (version.attachment_id) {
+        var {
+          data: { list: excelFileList },
+        } = await queryAttachment({
+          excel_id: version.attachment_id,
+        });
+        this.excelFileList = excelFileList.map((item) => {
+          const list = item.url.split("/");
+          const name = list[list.length - 1];
+          return {
+            ...item,
+            name,
+          };
+        });
+        // console.log(this.excelFileList)
+      }
+    },
+
+    // 显示通过审批弹窗
+    async showAuditModal() {
+      this.$refs.popup.open();
+    },
+
+    // 通过审批
+    async auditConfirm() {
+      let flow = this.flow;
+      let flowNode = flow.currentNode;
+      var { data: newVersion } = await approve({
+        id: flow.active_id,
+        project_id: this.projectId,
+        audit_status: 3,
+        flow_id: flowNode.flow_id,
+        node_id: flowNode.seq,
+      });
+      this.version = {
+        ...this.version,
+        id: newVersion.id,
+      };
+      this.getFlow(this.version);
+      uni.showToast({
+        title: "操作成功",
+      });
+      this.$refs.popup.close();
+    },
+
+    // 显示拒绝审批弹窗
+    showRejectModal() {
+      this.$refs.rejectPopup.open();
+    },
+
+    auditClose() {
+      this.$refs.popup.close();
+    },
+
+    rejectClose() {
+      this.$refs.rejectPopup.close();
+    },
+
+    async rejectConfirm(audit_comment) {
+      const flow = this.flow;
+      const flowNode = flow.currentNode;
+
+      var { data: newVersion } = await approve({
+        id: flow.active_id,
+        project_id: this.projectId,
+        audit_status: 2,
+        flow_id: flowNode.flow_id,
+        node_id: flowNode.seq,
+        audit_comment,
+      });
+      uni.showToast({
+        title: "操作成功",
+      });
+      this.version = {
+        ...this.version,
+        id: newVersion.id,
+      };
+      this.getFlow(this.version);
+      this.rejectClose();
+    },
+    // 查询审批信息
+    async getFlow(version) {
+      const { data: auditList } = await queryAuditList({
+        template_id: version.template_id,
+        template_node_id: version.template_node_id,
+        flow_id: version.flow_id,
+        version_id: version.version_id,
+        audit_series: version.audit_series,
+      });
+      if (auditList.length > 0) {
+        let item = auditList.find((item) => item.list.id == version.flow_id);
+        if (!item) return;
+        // 查询当前节点
+        let current = item.list.FlowNodes.findIndex(
+          (node) => node.seq == item.active
+        );
+        item.current = current == -1 ? 0 : current;
+        // 保存当前所处节点
+        item.currentNode = item.list.FlowNodes[item.current];
+        item.list.FlowNodes.forEach((item) => {
+          item.title = item.node;
+          item.desc = item.AuditRoleInfo
+            ? `审批人:${item?.AuditRoleInfo.Name || "-"}`
+            : `审批人:${item?.AuditorUser.CName || "-"}`;
+        });
+        this.flow = item;
+        // 判断是否含有审批权限
+        this.isAuditor = false;
+        if (item.active_audit == 1) {
+          let user = uni.getStorageSync("user");
+          if (item.currentNode && item.currentNode.auditor == user.ID) {
+            this.isAuditor = true;
+          }
+        }
+      }
+    },
+
+    toExcelDetail() {
+      uni.navigateTo({
+        url: `./excelDetail?templateNodeId=${this.templateNodeId}&versionId=${this.version.version_id}`,
+      });
+    },
+  },
+};
+</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;
+  box-shadow: 0 0 1 3 rgba(0, 0, 0, 0.1);
+
+  .content {
+    line-height: 44rpx;
+    padding: 14rpx;
+    word-break: break-all;
+  }
+}
+
+.attachment {
+  padding-left: 20rpx;
+  margin-bottom: 20rpx;
+}
+</style>

+ 19 - 0
pages/approved/BOM/excelDetail.vue

@@ -0,0 +1,19 @@
+<template>
+  <web-view :src="url"></web-view>
+</template>
+
+<script>
+const token = uni.getStorageSync("token");
+export default {
+  data() {
+    return {
+      url: "",
+    };
+  },
+  onLoad(options) {
+    this.url = `http://120.55.44.4:8896/#/mobile/detail/${options.templateNodeId}/${options.versionId}?JWT-TOKEN=${token}`;
+  },
+};
+</script>
+
+<style></style>

+ 151 - 0
pages/approved/BOM/list.vue

@@ -0,0 +1,151 @@
+<template>
+  <view class="page-detail">
+    <view class="page-center">
+      <uni-section title="已审批列表" type="line"> </uni-section>
+      <uni-card
+        v-for="item in list"
+        :title="project[item.project_id] || '未知项目'"
+        @click="toDetail(item)"
+      >
+        <view class="item">
+          <view class="label">审批节点</view>
+          <view class="value">{{
+            item.TemplateNodeInfo ? item.TemplateNodeInfo.label : "-"
+          }}</view>
+        </view>
+        <view class="item">
+          <view class="label">清单名称</view>
+          <view class="value"
+            >{{ item.version_name }}.{{ item.version_no }}</view
+          >
+        </view>
+        <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 {
+  queryCheckedList,
+  queryProjectList,
+  queryClassify,
+} from "@/services/bom.js";
+import { queryUser } from "@/services/index";
+
+export default {
+  data() {
+    return {
+      user: {},
+      list: [],
+      classify: {},
+      project: {},
+      pagination: {
+        current: 1,
+        pageSize: 10,
+        total: 0,
+      },
+    };
+  },
+  mounted() {
+    this.init();
+  },
+  onShow() {
+    this.queryList();
+  },
+  methods: {
+    async init() {
+      let project = {},
+        classify = {};
+      const userInfo = await queryUser();
+      if (userInfo?.data) {
+        uni.setStorageSync("user", userInfo.data);
+      }
+      var { data: projectData } = await queryProjectList();
+      var { data: classifyData } = await queryClassify();
+      projectData.forEach((p) => {
+        project[p.id] = p.project_name;
+      });
+      classifyData.forEach((item) => {
+        classify[item.id] = item.name;
+      });
+      this.project = project;
+      this.classify = classify;
+    },
+
+    async queryList() {
+      let user = uni.getStorageSync("user");
+      var { data: list } = await queryCheckedList(user.ID, {
+        pageSize: 9999,
+      });
+      this.list = list.list;
+    },
+
+    toDetail(item) {
+      uni.navigateTo({
+        url: `./detail?templateNodeId=${item.TemplateNodeInfo.Id}&excel_id=${item.id}&projectId=${item.project_id}`,
+      });
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.page-detail {
+  min-height: 100vh;
+  padding: 20rpx 20rpx 40rpx;
+  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;
+    }
+  }
+}
+</style>

+ 13 - 0
pages/approved/README.md

@@ -0,0 +1,13 @@
+# 2023-12-05 因为需要向前兼容做如下变更
+
+## approved
+
+- detail.vue
+- list.vue
+这两个文件是OA的审批相关页面
+
+### BOM文件夹
+
+- detail.vue
+- list.vue
+这两个文件是BOM的审批相关页面

+ 13 - 18
pages/audit/OA/excelDetail.vue

@@ -1,24 +1,19 @@
 <template>
-	<web-view :src="url"></web-view>
+  <web-view :src="url"></web-view>
 </template>
 
 <script>
-	import {
-		host
-	} from "@/services/constants.js"
-
-	const token = uni.getStorageSync('token')
-	export default {
-		data() {
-			return {
-				url: '',
-			}
-		},
-		onLoad(options) {
-			this.url = `http://120.55.44.4:8896/#/mobile/detail/${options.templateNodeId}/${options.versionId}?JWT-TOKEN=${token}`
-		},
-	}
+const token = uni.getStorageSync("token");
+export default {
+  data() {
+    return {
+      url: "",
+    };
+  },
+  onLoad(options) {
+    this.url = `http://120.55.44.4:8896/#/mobile/detail/${options.templateNodeId}/${options.versionId}?JWT-TOKEN=${token}`;
+  },
+};
 </script>
 
-<style>
-</style>
+<style></style>

+ 10 - 1
pages/audit/detail.vue

@@ -143,6 +143,11 @@ export default {
         userID: currentUser.ID,
         excelID: this.id,
       });
+      if (version === null) {
+        uni.redirectTo({
+          url: `/pages/approved/BOM/detail?templateNodeId=${this.templateNodeId}&excel_id=${this.id}&projectId=${this.projectId}`,
+        });
+      }
       if (!this.isMobile) {
         // 如果是在电脑上打开,转到PC端的页面去
         window.location.href = `http://120.55.44.4:8896/#/bom/home/detail/${version.project_id}/${version.template_id}?excel_id=${this.id}&JWT-TOKEN=${this.options["JWT-TOKEN"]}`;
@@ -293,7 +298,11 @@ export default {
           (item) => item.template_node_id === this.version.template_node_id
         );
         console.log(formComponent);
-        return formComponent[0].formComponentValues || [];
+        return (
+          formComponent[0].formComponentValues.filter(
+            (item) => !item.id.includes("DIYTable")
+          ) || []
+        );
       } catch (e) {
         return [];
       }

+ 13 - 18
pages/audit/excelDetail.vue

@@ -1,24 +1,19 @@
 <template>
-	<web-view :src="url"></web-view>
+  <web-view :src="url"></web-view>
 </template>
 
 <script>
-	import {
-		host
-	} from "@/services/constants.js"
-
-	const token = uni.getStorageSync('token')
-	export default {
-		data() {
-			return {
-				url: '',
-			}
-		},
-		onLoad(options) {
-			this.url = `http://120.55.44.4:8896/#/mobile/detail/${options.templateNodeId}/${options.versionId}?JWT-TOKEN=${token}`
-		},
-	}
+const token = uni.getStorageSync("token");
+export default {
+  data() {
+    return {
+      url: "",
+    };
+  },
+  onLoad(options) {
+    this.url = `http://120.55.44.4:8896/#/mobile/detail/${options.templateNodeId}/${options.versionId}?JWT-TOKEN=${token}`;
+  },
+};
 </script>
 
-<style>
-</style>
+<style></style>

+ 37 - 11
services/bom.js

@@ -1,7 +1,7 @@
-import request from "./request"
+import request from "./request";
 
 export async function queryAttachment(data) {
-	return await request('v1/purchase/attachment', 'GET', data);
+  return await request("v1/purchase/attachment", "GET", data);
 }
 
 /** 查看版本列表
@@ -10,36 +10,62 @@ export async function queryAttachment(data) {
     template_node_id	流程节点id
  */
 export async function queryVersionsList(data) {
-	return await request('v1/purchase/bom/flow/node', 'GET', data);
+  return await request("v1/purchase/bom/flow/node", "GET", data);
 }
 
 // 查询审批流
 export async function queryAuditList(params) {
-  return request(`v1/purchase/flow/info`, 'GET', params);
+  return request(`v1/purchase/flow/info`, "GET", params);
 }
 
 // 审批
 export async function approve(data) {
-  return request(`v1/purchase/audit/status`,'POST', data);
+  return request(`v1/purchase/audit/status`, "POST", data);
 }
 
 // 获得待审批列表
 export async function queryAuthList(user_id) {
-  return request(`v1/purchase/bom/get-audit-list/${user_id}`, 'GET');
+  return request(`v1/purchase/bom/get-audit-list/${user_id}`, "GET");
 }
 
 // 查询全部分类
 export async function queryClassify() {
-  return await request(`v1/purchase/bom/get-classify`, 'GET');
+  return await request(`v1/purchase/bom/get-classify`, "GET");
 }
 
 // 查询全部项目
 export async function queryProjectList() {
-  return request(`v2/approval/record?pageSize=99999`, 'GET');
+  return request(`v2/approval/record/user?pageSize=99999`, "GET");
 }
 
 // 查询单个Version
 export async function queryVersionDetail(params) {
-	const res =  await request(`v1/purchase/bom/get-audit-detail/${params.userID}?excel_id=${params.excelID}`, 'GET');
-	return res.data
-}
+  const res = await request(
+    `v1/purchase/bom/get-audit-detail/${params.userID}?excel_id=${params.excelID}`,
+    "GET"
+  );
+  return res.data;
+}
+
+export async function queryCheckedVersionDetail(excel_id) {
+  const res = await request(
+    `v1/purchase/bom/get-excel-detail?excel_id=${excel_id}`,
+    "GET"
+  );
+  return res.data;
+}
+
+/**
+ * 获取BOM已审核列表
+ * @param {number} user_id
+ * @param {object} params
+ * @param {number} params.pageSize
+ * @param {number} params.currentPage
+ * @returns {Promise<any>}
+ */
+export async function queryCheckedList(user_id, params) {
+  return await request(
+    `v1/purchase/bom/get-checked-list/${user_id}?page_size=${params.pageSize}`,
+    "GET"
+  );
+}