From bc3f630d4cdbaad3cd4620cc01fd6f693f07dfcd Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Sat, 07 Aug 2021 16:35:08 +0800
Subject: [PATCH] 培训报名修改

---
 src/views/traincompany/index.vue |  187 ++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 160 insertions(+), 27 deletions(-)

diff --git a/src/views/traincompany/index.vue b/src/views/traincompany/index.vue
index 40b99da..3ef9284 100644
--- a/src/views/traincompany/index.vue
+++ b/src/views/traincompany/index.vue
@@ -3,7 +3,7 @@
  * @Date: 2021-07-07 17:30:05
  * @Last Modified by: Morpheus
  * @Last Modified time: 2021-07-10 16:06:14
- * menu-name 保安培训单位查询
+ * menu-name 保安培训单位
  */
 <template>
   <basic-container>
@@ -28,7 +28,26 @@
       @row-click="handleRowClick"
       @on-load="onLoad"
     >
+
+      <template slot-scope="{ type,row }" slot="menu">
+                            <el-button
+                            :type="type"
+                            size="small"
+                            icon="el-icon-edit"
+                            @click="handleTrainApply(row)"
+                            >报名
+                            </el-button>
+                        </template>
     </avue-crud>
+
+    <el-dialog
+        title="报名"
+        append-to-body
+        :visible.sync="dialogDisable"
+        width="1000px"
+        >
+      <avue-form ref="formTrainApply" :option="optionTrainApply" v-model="formTrainApply" @submit="submit"></avue-form>
+    </el-dialog>
   </basic-container>
 </template>
 
@@ -40,14 +59,19 @@
   update,
   remove,
 } from "@/api/securityCompany/train";
+import {adddata} from "@/api/trainingRegistration/trainingRegistration";
 import { mapGetters } from "vuex";
+import { mapState } from 'vuex';
 
 export default {
+  
   data() {
     return {
       form: {},
+      formTrainApply: {},
       query: {},
       loading: true,
+      dialogDisable:false,
       page: {
         pageSize: 10,
         currentPage: 1,
@@ -60,8 +84,7 @@
         editBtn: false,
         addBtn: false,
         selection: true,
-        menu: false,
-
+        menu: true,
         align: "center",
         height: "auto",
         calcHeight: 30,
@@ -70,9 +93,10 @@
         searchShow: true,
         searchMenuSpan: 6,
         index: true,
-        viewBtn: true,
+        viewBtn: false,
+        editBtnText:'报名',
+        editTitle: '报名',
         dialogClickModal: false,
-
         column: [
           {
             label: "公司名称",
@@ -124,33 +148,98 @@
             prop: "address",
             display: false,
             width: 280,
-          },
+          }
         ],
-        group: [
+      },
+      optionTrainApply: {
+        align: "center",
+        height: "auto",
+        calcHeight: 30,
+        searchShowBtn: false,
+        tip: false,
+        searchShow: true,
+        searchMenuSpan: 6,
+        index: true,
+        dialogClickModal: false,
+        labelWidth:110,
+        column: [
           {
-            label: "详细信息",
-            prop: "baseInfo",
-            icon: "el-icon-user-solid",
-            column: [
-              {
-                label: "公司名称",
-                prop: "enterprisename",
-                display: false,
+              label: "培训公司名称",
+              prop: "trainingUnitId",
+              dicUrl: "/api/blade-system/dept/lazy-tree-type?parentId=1418458374477549569",
+              cascaderItem: ["trainExamId"],
+              props: {
+                  label: "title",
+                  value: "id"
               },
-            ],
+              type: "select",
+              disabled:true,
+              rules: [{
+                  required: true,
+                  message: "请输入培训公司名称",
+                  trigger: "blur"
+              }],
+              hide:true,
+              searchSpan: 6,
+              searchLabelWidth: 110,
+              search: true,
+              span:24
           },
+          // {
+          //     label: "考试名称",
+          //     prop: "trainExamId",
+          //     dicUrl: "/api/trainExam/page-tree?deptId={{key}}",
+          //     props: {
+          //         label: "trainExamName",
+          //         value: "id"
+          //     },
+          //     type: "select",
+          //     rules: [{
+          //         required: true,
+          //         message: "请输入考试名称",
+          //         trigger: "blur"
+          //     }],
+          //     hide: true,
+          // },
           {
-            label: "详细信息",
-            prop: "detailInfo",
-            icon: "el-icon-s-order",
-            column: [],
+              label: "单位名称",
+              prop: "deptId",
+              // width: 70,
+              // search: true,
+              // searchSpan: 4,
+              dicUrl: "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697",
+              cascaderItem: ["userId"],
+              props: {
+                  label: "title",
+                  value: "id"
+              },
+              // search: true,
+              type: "select",
+              hide: true,
+              rules: [{
+                  required: true,
+                  message: "请输入单位名称",
+                  trigger: "blur"
+              }],
+              overHidden: true
+          }, {
+              label: "姓名",
+              prop: "userId",
+              type: "select",
+              hide: true,
+              dicUrl: "/api/blade-user/page-security-unit?deptId={{key}}",
+              props: {
+                  label: "realName",
+                  value: "id"
+              },
+              searchSpan: 5,
+              rules: [{
+                  required: true,
+                  message: "请输入姓名",
+                  trigger: "blur"
+              }],
           },
-          {
-            label: "职责信息",
-            prop: "dutyInfo",
-            icon: "el-icon-s-custom",
-            column: [],
-          },
+          
         ],
       },
       data: [],
@@ -173,8 +262,52 @@
       });
       return ids.join(",");
     },
+    ...mapState({
+        userInfo: state => state.user.userInfo
+    })
   },
   methods: {
+    handleTrainApply(row){
+      this.dialogDisable = true;
+      this.optionTrainApply.column.trainingUnitId = row.departmentid;
+      this.formTrainApply = {
+        trainingUnitId: row.departmentid
+      }
+    },
+    //关闭窗口清除数据
+    closeDialog(){
+      this.$refs.formTrainApply.resetFields();
+    },
+    submit(row, done, loading) {
+      adddata(row).then(
+        (res) => {
+          // this.onLoad(this.page);
+          if(res.data.data==201){
+              this.$message({
+                type: "warning",
+                message:"已报名,不能重复报名",
+              });
+          }else if(res.data.data==201){
+              this.$message({
+                type: "warning",
+                message:"报名失败",
+              });
+          }else{
+              this.$message({
+                type: "success",
+                message:"报名成功",
+              });
+              this.dialogDisable = false;
+              this.$refs.formTrainApply.resetFields();
+          }
+          done();
+        },
+        (error) => {
+          window.console.log(error);
+          loading();
+        }
+      );
+    },
     rowSave(row, done, loading) {
       add(row).then(
         () => {
@@ -224,7 +357,7 @@
           });
         });
     },
-    beforeOpen(done, type) {
+    beforeOpen(done,type) {
       if (["edit", "view"].includes(type)) {
         getDetail(this.form.id).then((res) => {
           this.form = res.data.data;

--
Gitblit v1.9.3