Browse Source

feature:(仪器管理)完成仪器预约模块开发

liuzhenlin 11 months ago
parent
commit
f013a7de9a

+ 1 - 1
src/api/instr/index.js

@@ -181,7 +181,7 @@ export function getMySelfProjectGroup(data) {
   return request.postRequestWithClientInfo(
     basePath,
     "ProjectGroup",
-    "GetProjectGroupList",
+    "GetProjectGroupByUser",
     data
   );
 }

+ 107 - 10
src/views/equipment/components/appoint-create.vue

@@ -170,7 +170,7 @@
                   </el-form-item>
                 </el-col>
                 <el-col :span="24">
-                  <el-form-item label="备注" prop="assistEnable" required>
+                  <el-form-item label="备注" prop="assistEnable">
                     <el-input
                       type="textarea"
                       placeholder="请输入"
@@ -335,12 +335,14 @@
     getUserList,
     getInstrAppointInfo,
     getSettingDetail,
+    appointUpdate,
+    appointAdd,
   } from "@/api/instr/index";
+  import { mapGetters } from "vuex";
   export default {
     name: "FrontendWebTest",
     data() {
       return {
-        userInfos: {},
         title: "预约信息",
         visible: false,
         InstCfgCharge: {},
@@ -397,10 +399,13 @@
         },
       };
     },
+    computed: {
+      ...mapGetters(["userInfo"]),
+    },
     methods: {
       // 获取课题组和服务信息
       async getProData() {
-        const [err, res] = await to(getMySelfProjectGroup({}));
+        const [err, res] = await to(getMySelfProjectGroup());
         if (err) return;
         this.projectOptions = [
           {
@@ -409,7 +414,7 @@
           },
         ];
         if (res.data.id) {
-          changeProject(res.data.id);
+          this.changeProject(res.data.id);
         }
         const [serErr, serRes] = await to(getTechList({ noPage: true }));
         if (serErr) return;
@@ -518,9 +523,10 @@
         } else {
           const dynamicForm = row.createForm ? JSON.parse(row.createForm) : [];
           this.form = Object.assign(this.form, { ...row });
-          this.form.userContact = this.userInfos.phone || "";
-          this.form.userName = this.userInfos.nickName || "";
-          this.form.userId = this.userInfos.id || null;
+          console.log(this.userInfo);
+          this.form.userContact = this.userInfo.phone || "";
+          this.form.userName = this.userInfo.nickName || "";
+          this.form.userId = this.userInfo.id || null;
           this.form.expenseCardId = row.expenseCardId || null;
           this.state.dynamicForm = dynamicForm;
         }
@@ -540,11 +546,102 @@
         this.state.isShowDialog = true;
       },
       onCancel() {
-        this.editFormRef.clearValidate();
-        this.editFormRef.resetFields();
+        this.$refs.editFormRef.clearValidate();
+        this.$refs.editFormRef.resetFields();
         this.state.isShowDialog = false;
       },
-      subAdd() {},
+      subAdd() {
+        this.$refs.editFormRef.validate(async (valid) => {
+          if (valid) {
+            if (this.form.projectType == "project" && !this.form.projectId) {
+              this.$message.warning("请选择课题组");
+              return;
+            }
+            if (
+              this.InstCfgCharge &&
+              this.form.projectType == "project" &&
+              !this.form.expenseCardId
+            ) {
+              this.$message.warning("请选择经费卡");
+              return;
+            }
+            if (this.form.projectType == "service" && !this.form.serviceId) {
+              this.$message.warning("请选择服务");
+              return;
+            }
+            let hasEmpty = false;
+            for (let i in this.state.dynamicForm) {
+              for (let item of this.state.dynamicForm[i].formItemList) {
+                console.log(item);
+                if (
+                  item.tagIcon !== "multiple-select" &&
+                  item.required &&
+                  !item.defaultValue
+                ) {
+                  hasEmpty = true;
+                  this.$message.warning(
+                    `请填写${this.state.dynamicForm[i].formTitle}表单下的${item.label}`
+                  );
+                  break;
+                } else if (
+                  item.tagIcon == "multiple-select" &&
+                  item.required &&
+                  item.defaultValue.length == 0
+                ) {
+                  hasEmpty = true;
+                  this.$message.warning(
+                    `请填写${this.state.dynamicForm[i].formTitle}表单下的${item.label}`
+                  );
+                  break;
+                }
+              }
+              if (hasEmpty) {
+                break;
+              }
+            }
+            if (hasEmpty) return;
+            let params = Object.assign({ ...this.form });
+            params.expenseCardName = this.fundsList
+              ? this.fundsList.find((item) => item.id == params.expenseCardId)
+                  .finAccount
+              : "";
+            params.createForm = JSON.stringify(this.state.dynamicForm);
+            console.log(params.createForm);
+            this.state.loading = true;
+            const post = params.id ? appointUpdate : appointAdd;
+            const [err] = await to(post({ ...params }));
+            this.state.loading = false;
+            if (err) return;
+            this.$message.success("预约成功");
+            // 外部页面预约
+            if (this.form.appointJump && this.form.appointJumpLink) {
+              this.$confirm(
+                "除了在当前系统预约,此仪器也必须在其他仪器共享平台进行预约,仪器在其他仪器共享平台编号为:" +
+                  this.form.assetNumber,
+                "提示",
+                {
+                  confirmButtonText: "确认",
+                  cancelButtonText: "取消",
+                  type: "warning",
+                }
+              )
+                .then(() => {
+                  this.$emit("refresh");
+                  this.closeDialog();
+                  window.open(this.form.appointJumpLink, "_blank");
+                })
+                .catch(() => {
+                  this.$emit("refresh");
+
+                  this.closeDialog();
+                });
+            } else {
+              this.$emit("refresh");
+              this.closeDialog();
+            }
+          }
+        });
+      },
     },
   };
 </script>

+ 1 - 5
src/views/equipment/components/appoint.vue

@@ -89,8 +89,7 @@
         </div>
       </template>
     </el-dialog>
-    <appointCreate ref="appointCreateRef"></appointCreate>
-    <!-- <create-sub ref="sub" @refresh="emitData"></create-sub> -->
+    <appointCreate ref="appointCreateRef" @refresh="emitData"></appointCreate>
   </div>
 </template>
 
@@ -131,7 +130,6 @@
           assetNumber: "",
           instHeadId: "",
         },
-        show: false,
         split_time: 0,
         calendarOptions: {
           plugins: [dayGridPlugin, interactionPlugin, timeGridPlugin],
@@ -226,7 +224,6 @@
           const [err, res] = await to(getSettingDetail({ ...params }));
           if (err) return;
           if (res.code == 200) {
-            this.show = true;
             this.split_time = res.data.config.timeSplit;
             this.form.createForm = res.data.config.createForm;
             let calendarFunc =
@@ -798,7 +795,6 @@
       dialogClose() {
         this.visible = false;
         this.form = { startTime: "", endTime: "", instId: 0, instName: "" };
-        this.show = false;
       },
       // 预约下一步
       nextStep() {

+ 7 - 1
src/views/equipment/details.vue

@@ -123,7 +123,7 @@
                 instrDetails.instStatus == '10' &&
                 instrDetails.isAppointment == '10'
               "
-              @click=""
+              @click="handleAppoint"
             >
               使用预约
             </el-button>
@@ -171,6 +171,7 @@
         </el-tabs>
       </div>
     </section>
+    <appoint ref="appointRef"></appoint>
   </div>
 </template>
 
@@ -182,6 +183,7 @@
   import NoticeTable from "./components/instr-notice.vue";
   import SampleCharg from "./components/sample-charg.vue";
   import AppointRecord from "./components/appoint-record.vue";
+  import appoint from "./components/appoint.vue";
   export default {
     name: "equipmentDetails",
     components: {
@@ -190,6 +192,7 @@
       NoticeTable,
       SampleCharg,
       AppointRecord,
+      appoint,
     },
     data() {
       return {
@@ -205,6 +208,9 @@
     },
 
     methods: {
+      handleAppoint() {
+        this.$refs.appointRef.openDialog(this.instrDetails);
+      },
       async getInstrDetails() {
         const id = this.$route.query.id * 1;
         if (!id)