|  | @@ -0,0 +1,282 @@
 | 
											
												
													
														|  | 
 |  | +<template>
 | 
											
												
													
														|  | 
 |  | +  <div class="edu-training-edit">
 | 
											
												
													
														|  | 
 |  | +    <DialogCom :title="'录入介绍信'" :close="onHide" :visible.sync="isShow" width="960px">
 | 
											
												
													
														|  | 
 |  | +      <div class="page-body">
 | 
											
												
													
														|  | 
 |  | +        <el-form ref="form" :model="formData" :rules="formDataRules" label-width="100px">
 | 
											
												
													
														|  | 
 |  | +          <el-row>
 | 
											
												
													
														|  | 
 |  | +            <el-col :span="12">
 | 
											
												
													
														|  | 
 |  | +              <el-form-item prop="letterName" label="介绍信名称">
 | 
											
												
													
														|  | 
 |  | +                <el-input v-model="formData.letterName" placeholder="请输入介绍信名称" :length="200"/>
 | 
											
												
													
														|  | 
 |  | +              </el-form-item>
 | 
											
												
													
														|  | 
 |  | +            </el-col>
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +            <el-col :span="12">
 | 
											
												
													
														|  | 
 |  | +              <el-form-item label="接待机构" prop="orgId">
 | 
											
												
													
														|  | 
 |  | +                <org-tree-select
 | 
											
												
													
														|  | 
 |  | +                  v-model="formData.orgId"
 | 
											
												
													
														|  | 
 |  | +                  ref="orgTreeSelect"
 | 
											
												
													
														|  | 
 |  | +                >
 | 
											
												
													
														|  | 
 |  | +                </org-tree-select>
 | 
											
												
													
														|  | 
 |  | +              </el-form-item>
 | 
											
												
													
														|  | 
 |  | +            </el-col>
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +            <el-col :span="12">
 | 
											
												
													
														|  | 
 |  | +              <el-form-item  prop="startTime" label="有效开始时间">
 | 
											
												
													
														|  | 
 |  | +                <el-date-picker required v-model="formData.startTime" :picker-options="startDatepickerOptions"
 | 
											
												
													
														|  | 
 |  | +                                type="date" placeholder="选择日期"  @change="startDateChanged">
 | 
											
												
													
														|  | 
 |  | +                </el-date-picker>
 | 
											
												
													
														|  | 
 |  | +              </el-form-item>
 | 
											
												
													
														|  | 
 |  | +            </el-col>
 | 
											
												
													
														|  | 
 |  | +            <el-col :span="12">
 | 
											
												
													
														|  | 
 |  | +              <el-form-item prop="endTime" label="培训结束时间">
 | 
											
												
													
														|  | 
 |  | +                <el-date-picker required v-model="formData.endTime" :picker-options="endDatepickerOptions" @change="endDateChanged"
 | 
											
												
													
														|  | 
 |  | +                                type="date" placeholder="选择日期">
 | 
											
												
													
														|  | 
 |  | +                </el-date-picker>
 | 
											
												
													
														|  | 
 |  | +              </el-form-item>
 | 
											
												
													
														|  | 
 |  | +            </el-col>
 | 
											
												
													
														|  | 
 |  | +          </el-row>
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +<!--          <el-form-item label="介绍信文件" prop="letterFile">
 | 
											
												
													
														|  | 
 |  | +            <file-upload v-model="formData.letterFile"/>
 | 
											
												
													
														|  | 
 |  | +          </el-form-item>-->
 | 
											
												
													
														|  | 
 |  | +          <el-form-item label="介绍信文件" prop="letterFile">
 | 
											
												
													
														|  | 
 |  | +            <K-file-upload ref="upload" :defaultValue="formFileListDefualtValue" v-model="formData.letterFile"/>
 | 
											
												
													
														|  | 
 |  | +          </el-form-item>
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +          <el-form-item label="备注" prop="checkRemark">
 | 
											
												
													
														|  | 
 |  | +            <el-input v-model="formData.checkRemark" type="textarea" placeholder="请输入内容" />
 | 
											
												
													
														|  | 
 |  | +          </el-form-item>
 | 
											
												
													
														|  | 
 |  | +          <el-row :gutter="10" class="mb8">
 | 
											
												
													
														|  | 
 |  | +            <el-col :span="1.5">
 | 
											
												
													
														|  | 
 |  | +              <el-button
 | 
											
												
													
														|  | 
 |  | +                type="primary"
 | 
											
												
													
														|  | 
 |  | +                plain
 | 
											
												
													
														|  | 
 |  | +                icon="el-icon-plus"
 | 
											
												
													
														|  | 
 |  | +                size="mini"
 | 
											
												
													
														|  | 
 |  | +                @click="handleAddUser"
 | 
											
												
													
														|  | 
 |  | +              >新增人员</el-button>
 | 
											
												
													
														|  | 
 |  | +            </el-col>
 | 
											
												
													
														|  | 
 |  | +          </el-row>
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +          <el-table v-loading="loading" :data="formData.userInfos">
 | 
											
												
													
														|  | 
 |  | +            <el-table-column label="人员姓名" align="center" prop="userName" />
 | 
											
												
													
														|  | 
 |  | +            <el-table-column label="单位" align="center" prop="companyName" />
 | 
											
												
													
														|  | 
 |  | +            <el-table-column label="证据号码" align="center" prop="idCard">
 | 
											
												
													
														|  | 
 |  | +            </el-table-column>
 | 
											
												
													
														|  | 
 |  | +            <el-table-column label="证件" align="center" prop="imgFile" >
 | 
											
												
													
														|  | 
 |  | +              <template slot-scope="scope">
 | 
											
												
													
														|  | 
 |  | +                <img width="50" height="50" :src="scope.row.imgFile">
 | 
											
												
													
														|  | 
 |  | +              </template>
 | 
											
												
													
														|  | 
 |  | +            </el-table-column>>
 | 
											
												
													
														|  | 
 |  | +            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
 | 
											
												
													
														|  | 
 |  | +              <template slot-scope="scope">
 | 
											
												
													
														|  | 
 |  | +              <el-button
 | 
											
												
													
														|  | 
 |  | +                size="mini"
 | 
											
												
													
														|  | 
 |  | +                type="text"
 | 
											
												
													
														|  | 
 |  | +                @click="editUser(scope.row)"
 | 
											
												
													
														|  | 
 |  | +              >编辑</el-button>
 | 
											
												
													
														|  | 
 |  | +                <el-button
 | 
											
												
													
														|  | 
 |  | +                  size="mini"
 | 
											
												
													
														|  | 
 |  | +                  type="text"
 | 
											
												
													
														|  | 
 |  | +                  @click="remove(scope.row)"
 | 
											
												
													
														|  | 
 |  | +                >移除</el-button>
 | 
											
												
													
														|  | 
 |  | +              </template>
 | 
											
												
													
														|  | 
 |  | +            </el-table-column>
 | 
											
												
													
														|  | 
 |  | +          </el-table>
 | 
											
												
													
														|  | 
 |  | +        </el-form>
 | 
											
												
													
														|  | 
 |  | +      </div>
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +      <DialogCom title="添加出入人员" :visible.sync="open" width="800px" append-to-body @close="onHideUser">
 | 
											
												
													
														|  | 
 |  | +        <el-form ref="formUser" :model="userInfo" :rules="userInfoRules" label-width="80px">
 | 
											
												
													
														|  | 
 |  | +          <el-form-item label="人员姓名" prop="userName">
 | 
											
												
													
														|  | 
 |  | +            <el-input v-model="userInfo.userName" placeholder="请输入姓名" />
 | 
											
												
													
														|  | 
 |  | +          </el-form-item>
 | 
											
												
													
														|  | 
 |  | +          <el-form-item label="单位" prop="companyName">
 | 
											
												
													
														|  | 
 |  | +            <el-input v-model="userInfo.companyName" placeholder="请输入单位" />
 | 
											
												
													
														|  | 
 |  | +          </el-form-item>
 | 
											
												
													
														|  | 
 |  | +          <el-form-item label="证件号码" prop="idCard">
 | 
											
												
													
														|  | 
 |  | +            <el-input v-model="userInfo.idCard" placeholder="请输入证件号码" />
 | 
											
												
													
														|  | 
 |  | +          </el-form-item>
 | 
											
												
													
														|  | 
 |  | +          <el-form-item prop="imgFile" label="上传图片">
 | 
											
												
													
														|  | 
 |  | +            <imgUpload ref="uploadimage" type="alone" :value="userInfo.imgFile"
 | 
											
												
													
														|  | 
 |  | +                       @input="imageListChanged"></imgUpload>
 | 
											
												
													
														|  | 
 |  | +          </el-form-item>
 | 
											
												
													
														|  | 
 |  | +        </el-form>
 | 
											
												
													
														|  | 
 |  | +        <div slot="footer" class="dialog-footer">
 | 
											
												
													
														|  | 
 |  | +          <el-button type="primary" @click="submitUser">确 定</el-button>
 | 
											
												
													
														|  | 
 |  | +          <el-button @click="onHideUser">取 消</el-button>
 | 
											
												
													
														|  | 
 |  | +        </div>
 | 
											
												
													
														|  | 
 |  | +      </DialogCom>
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +      <div slot="footer" class="dialog-footer">
 | 
											
												
													
														|  | 
 |  | +        <el-button type="primary" @click="submitForm">确 定</el-button>
 | 
											
												
													
														|  | 
 |  | +        <el-button @click="onHide">取 消</el-button>
 | 
											
												
													
														|  | 
 |  | +      </div>
 | 
											
												
													
														|  | 
 |  | +    </DialogCom>
 | 
											
												
													
														|  | 
 |  | +  </div>
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +</template>
 | 
											
												
													
														|  | 
 |  | +<script>
 | 
											
												
													
														|  | 
 |  | +import {mapState, mapMutations} from "vuex";
 | 
											
												
													
														|  | 
 |  | +import { listLetter, getLetter, delLetter, addLetter, updateLetter } from "@/api/core/letter";
 | 
											
												
													
														|  | 
 |  | +import OrgTreeSelect from "@/components/orgTreeSelect";
 | 
											
												
													
														|  | 
 |  | +import KFileUpload from "@/components/K-FileUpload/index.vue";
 | 
											
												
													
														|  | 
 |  | +import dayjs from "dayjs";
 | 
											
												
													
														|  | 
 |  | +import imgUpload from "@/components/ImageUpload";
 | 
											
												
													
														|  | 
 |  | +export default {
 | 
											
												
													
														|  | 
 |  | +  components: {OrgTreeSelect,KFileUpload,imgUpload},
 | 
											
												
													
														|  | 
 |  | +  data() {
 | 
											
												
													
														|  | 
 |  | +    const params = this.$route.params;
 | 
											
												
													
														|  | 
 |  | +    return {
 | 
											
												
													
														|  | 
 |  | +      id: params ? params.id : null,
 | 
											
												
													
														|  | 
 |  | +      isShow: false,
 | 
											
												
													
														|  | 
 |  | +      formData: this.reset(),
 | 
											
												
													
														|  | 
 |  | +      formDataRules: {
 | 
											
												
													
														|  | 
 |  | +        letterName: [{required: true, message: "请输入介绍信名称"}],
 | 
											
												
													
														|  | 
 |  | +        orgId: [{required: true, message: "请选择接待机构"}],
 | 
											
												
													
														|  | 
 |  | +        startTime: [{required: true,  message: "请选择有效开始时间"}],
 | 
											
												
													
														|  | 
 |  | +        endTime: [{required: true, message: "请选择有效结束时间"}],
 | 
											
												
													
														|  | 
 |  | +        userInfos:[{required: true, message: "请添加出入人员"}],
 | 
											
												
													
														|  | 
 |  | +      },
 | 
											
												
													
														|  | 
 |  | +      userInfoRules: {
 | 
											
												
													
														|  | 
 |  | +        userName: [{required: true, message: "请输入姓名"}],
 | 
											
												
													
														|  | 
 |  | +        companyName: [{required: true, message: "请输入单位"}],
 | 
											
												
													
														|  | 
 |  | +        idCard: [{required: true, message: "请输入证件号码"}],
 | 
											
												
													
														|  | 
 |  | +      },
 | 
											
												
													
														|  | 
 |  | +      startDatepickerOptions: {
 | 
											
												
													
														|  | 
 |  | +        disabledDate:this.endDisabledDate,
 | 
											
												
													
														|  | 
 |  | +      },
 | 
											
												
													
														|  | 
 |  | +      endDatepickerOptions: {
 | 
											
												
													
														|  | 
 |  | +        disabledDate: this.endDisabledDate,
 | 
											
												
													
														|  | 
 |  | +      },
 | 
											
												
													
														|  | 
 |  | +      formFileListDefualtValue: [],
 | 
											
												
													
														|  | 
 |  | +      open: false,
 | 
											
												
													
														|  | 
 |  | +      userInfo:this.resetUserInfo(),
 | 
											
												
													
														|  | 
 |  | +      imageList:[]
 | 
											
												
													
														|  | 
 |  | +    };
 | 
											
												
													
														|  | 
 |  | +  },
 | 
											
												
													
														|  | 
 |  | +  dicts: ['letter_status'],
 | 
											
												
													
														|  | 
 |  | +  props: {},
 | 
											
												
													
														|  | 
 |  | +  watch: {},
 | 
											
												
													
														|  | 
 |  | +  created() {
 | 
											
												
													
														|  | 
 |  | +  },
 | 
											
												
													
														|  | 
 |  | +  computed: {
 | 
											
												
													
														|  | 
 |  | +    ...mapState(["loginUser", "org",]),
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +  },
 | 
											
												
													
														|  | 
 |  | +  methods: {
 | 
											
												
													
														|  | 
 |  | +    ...mapMutations([]),
 | 
											
												
													
														|  | 
 |  | +    reset(other = {}) {
 | 
											
												
													
														|  | 
 |  | +      return {
 | 
											
												
													
														|  | 
 |  | +        letterName:null,
 | 
											
												
													
														|  | 
 |  | +        orgId:null,
 | 
											
												
													
														|  | 
 |  | +        startTime: null,
 | 
											
												
													
														|  | 
 |  | +        endTime: null,
 | 
											
												
													
														|  | 
 |  | +        checkRemark: null,
 | 
											
												
													
														|  | 
 |  | +        fileList: [],
 | 
											
												
													
														|  | 
 |  | +        userInfos:[],
 | 
											
												
													
														|  | 
 |  | +        ...other,
 | 
											
												
													
														|  | 
 |  | +      };
 | 
											
												
													
														|  | 
 |  | +    },
 | 
											
												
													
														|  | 
 |  | +    resetUserInfo(){
 | 
											
												
													
														|  | 
 |  | +      return {
 | 
											
												
													
														|  | 
 |  | +        userName: null,
 | 
											
												
													
														|  | 
 |  | +        companyName:null,
 | 
											
												
													
														|  | 
 |  | +        idCard:null,
 | 
											
												
													
														|  | 
 |  | +        imgFile:null,
 | 
											
												
													
														|  | 
 |  | +      }
 | 
											
												
													
														|  | 
 |  | +    },
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    async show(id, other = {}) {
 | 
											
												
													
														|  | 
 |  | +      this.isShow = true;
 | 
											
												
													
														|  | 
 |  | +    },
 | 
											
												
													
														|  | 
 |  | +    handleAddUser() {
 | 
											
												
													
														|  | 
 |  | +      this.open = true;
 | 
											
												
													
														|  | 
 |  | +    },
 | 
											
												
													
														|  | 
 |  | +    imageListChanged(list) {
 | 
											
												
													
														|  | 
 |  | +      this.userInfo.imgFile = list;
 | 
											
												
													
														|  | 
 |  | +    },
 | 
											
												
													
														|  | 
 |  | +    endDisabledDate(time) {
 | 
											
												
													
														|  | 
 |  | +      //小于开始日期禁止选择
 | 
											
												
													
														|  | 
 |  | +      let startDate = new Date();
 | 
											
												
													
														|  | 
 |  | +      startDate.setTime(startDate.getTime() - 3600 * 1000 * 24);
 | 
											
												
													
														|  | 
 |  | +      if (this.formData.trainingStartDateTime) {
 | 
											
												
													
														|  | 
 |  | +        startDate = new Date(dayjs(this.formData.trainingStartDateTime).format('YYYY-MM-DD'));
 | 
											
												
													
														|  | 
 |  | +        startDate.setTime(startDate.getTime() - 3600 * 1000 * 24);
 | 
											
												
													
														|  | 
 |  | +      }
 | 
											
												
													
														|  | 
 |  | +      return time.getTime() < new Date(startDate).getTime()
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    },
 | 
											
												
													
														|  | 
 |  | +    startDateChanged(time) {
 | 
											
												
													
														|  | 
 |  | +      if (dayjs(this.formData.startTime).isAfter(dayjs(this.formData.endTime))) {
 | 
											
												
													
														|  | 
 |  | +        this.formData.endTime = this.formData.startTime;
 | 
											
												
													
														|  | 
 |  | +      }
 | 
											
												
													
														|  | 
 |  | +    },
 | 
											
												
													
														|  | 
 |  | +    endDateChanged(time) {
 | 
											
												
													
														|  | 
 |  | +      if (dayjs(this.formData.startTime).isAfter(dayjs(this.formData.endTime))) {
 | 
											
												
													
														|  | 
 |  | +        this.formData.startTime = this.formData.endTime;
 | 
											
												
													
														|  | 
 |  | +      }
 | 
											
												
													
														|  | 
 |  | +    },
 | 
											
												
													
														|  | 
 |  | +    onHide() {
 | 
											
												
													
														|  | 
 |  | +      this.isShow = false;
 | 
											
												
													
														|  | 
 |  | +      this.formData = this.reset();
 | 
											
												
													
														|  | 
 |  | +    },
 | 
											
												
													
														|  | 
 |  | +    onHideUser() {
 | 
											
												
													
														|  | 
 |  | +      this.open = false;
 | 
											
												
													
														|  | 
 |  | +      this.imageList=[];
 | 
											
												
													
														|  | 
 |  | +      this.userInfo = this.resetUserInfo();
 | 
											
												
													
														|  | 
 |  | +    },
 | 
											
												
													
														|  | 
 |  | +    submitUser(){
 | 
											
												
													
														|  | 
 |  | +      this.$refs["formUser"].validate(valid => {
 | 
											
												
													
														|  | 
 |  | +          if (valid) {
 | 
											
												
													
														|  | 
 |  | +            this.open = false;
 | 
											
												
													
														|  | 
 |  | +            console.log("================",this.userInfo);
 | 
											
												
													
														|  | 
 |  | +            this.formData.userInfos.push(this.userInfo);
 | 
											
												
													
														|  | 
 |  | +            this.userInfo = this.resetUserInfo();
 | 
											
												
													
														|  | 
 |  | +            this.imageList=[];
 | 
											
												
													
														|  | 
 |  | +          }})
 | 
											
												
													
														|  | 
 |  | +    },
 | 
											
												
													
														|  | 
 |  | +    submitForm(){
 | 
											
												
													
														|  | 
 |  | +      this.$refs["form"].validate(valid => {
 | 
											
												
													
														|  | 
 |  | +        if (valid) {
 | 
											
												
													
														|  | 
 |  | +          if(this.formData.userInfos.length<=0){
 | 
											
												
													
														|  | 
 |  | +            this.$message.error("请添加人员");
 | 
											
												
													
														|  | 
 |  | +            return;
 | 
											
												
													
														|  | 
 |  | +          }
 | 
											
												
													
														|  | 
 |  | +          console.log("================",this.formData);
 | 
											
												
													
														|  | 
 |  | +          if (this.formData.id != null) {
 | 
											
												
													
														|  | 
 |  | +            updateLetter(this.formData).then(response => {
 | 
											
												
													
														|  | 
 |  | +              this.$modal.msgSuccess("修改成功");
 | 
											
												
													
														|  | 
 |  | +              this.isShow = false;
 | 
											
												
													
														|  | 
 |  | +              this.formData = this.reset();
 | 
											
												
													
														|  | 
 |  | +              this.getList();
 | 
											
												
													
														|  | 
 |  | +            });
 | 
											
												
													
														|  | 
 |  | +          } else {
 | 
											
												
													
														|  | 
 |  | +            addLetter(this.formData).then(response => {
 | 
											
												
													
														|  | 
 |  | +              this.$modal.msgSuccess("新增成功");
 | 
											
												
													
														|  | 
 |  | +              this.isShow = false;
 | 
											
												
													
														|  | 
 |  | +              this.formData = this.reset();
 | 
											
												
													
														|  | 
 |  | +              this.getList();
 | 
											
												
													
														|  | 
 |  | +            });
 | 
											
												
													
														|  | 
 |  | +          }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        }})
 | 
											
												
													
														|  | 
 |  | +    },
 | 
											
												
													
														|  | 
 |  | +    editUser(row){
 | 
											
												
													
														|  | 
 |  | +      this.open = true;
 | 
											
												
													
														|  | 
 |  | +      this.userInfo = row;
 | 
											
												
													
														|  | 
 |  | +    },
 | 
											
												
													
														|  | 
 |  | +    remove(row){
 | 
											
												
													
														|  | 
 |  | +      console.log("================",row);
 | 
											
												
													
														|  | 
 |  | +      this.formData.userInfos.splice(this.formData.userInfos.indexOf(row),1);
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +  },
 | 
											
												
													
														|  | 
 |  | +  mounted() {
 | 
											
												
													
														|  | 
 |  | +  },
 | 
											
												
													
														|  | 
 |  | +};
 | 
											
												
													
														|  | 
 |  | +</script>
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 |