| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- <template>
- <div class="tab2Add">
- <div class="insideTop">
- 学院领导管理 > 新增领导信息
- <div class="add">
- <el-button type="primary" @click="goBack">返 回</el-button>
- </div>
- </div>
- <div class="obstruct"></div>
- <!-- 主要内容 -->
- <div class="conten">
- <div class="con_top">基本信息</div>
- <!-- 表单 -->
- <el-form
- :model="ruleForm"
- :rules="rules"
- ref="ruleForm"
- label-width="120px"
- class="demo-ruleForm"
- >
- <el-form-item label="姓名:" prop="name">
- <el-input
- v-model="ruleForm.name"
- maxlength="25"
- show-word-limit
- style="width: 500px"
- ></el-input>
- </el-form-item>
- <el-form-item label="性别:" prop="sex">
- <el-radio v-model="ruleForm.sex" label="1">男</el-radio>
- <el-radio v-model="ruleForm.sex" label="0">女</el-radio>
- </el-form-item>
- <el-form-item label="政治面貌:" prop="face">
- <el-select
- v-model="ruleForm.face"
- placeholder="请选择"
- style="width: 500px"
- >
- <el-option label="中共党员" value="中共党员"></el-option>
- <el-option label="中共预备党员" value="中共预备党员"></el-option>
- <el-option label="共青团员" value="共青团员"></el-option>
- <el-option label="民革党员" value="民革党员"></el-option>
- <el-option label="民盟盟员" value="民盟盟员"></el-option>
- <el-option label="民建会员" value="民建会员"></el-option>
- <el-option label="民进会员" value="民进会员"></el-option>
- <el-option label="农工党党员" value="农工党党员"></el-option>
- <el-option label="致公党党员" value="致公党党员"></el-option>
- <el-option label="九三学社社员" value="九三学社社员"></el-option>
- <el-option label="台盟盟员" value="台盟盟员"></el-option>
- <el-option label="无党派人士" value="无党派人士"></el-option>
- <el-option label="群众" value="群众"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="任期职位:" prop="position">
- <el-input
- v-model="ruleForm.position"
- maxlength="50"
- show-word-limit
- style="width: 500px"
- ></el-input>
- </el-form-item>
- <el-form-item label="任期:">
- <i class="biaoshi biaoshi1"></i>
- <el-date-picker
- style="width: 500px"
- v-model="time"
- type="daterange"
- range-separator="-"
- start-placeholder="开始时间"
- end-placeholder="结束时间"
- >
- </el-date-picker>
- </el-form-item>
- <!-- 图片和附件 -->
- <el-form-item label="领导照片">
- <i class="biaoshi biaoshi2"></i>
- <el-upload
- class="avatar-uploader"
- :action="baseURL + '/cms/security/video/upload/img'"
- :headers="{
- token,
- }"
- :show-file-list="false"
- :before-upload="beforethumbUpload"
- :on-success="upload_thumb_success"
- >
- <div v-if="ruleForm.thumb" class="imgdiv">
- <img
- style="width: 100%; height: 100%"
- :src="baseURL + ruleForm.thumb"
- />
- <i
- class="el-icon-circle-close"
- @click.stop="ruleForm.thumb = ''"
- ></i>
- </div>
- <i v-else class="el-icon-plus avatar-uploader-icon"></i>
- </el-upload>
- <p class="upHint">
- 格式要求:支持png、jpg、gif和jpeg的图片格式;最大支持20M。
- </p>
- </el-form-item>
- </el-form>
- <!-- 富文本 -->
- <div class="con_top">领导简介</div>
- <div id="div1" style="z-index: 1"></div>
- <!-- 底部按钮 -->
- <div class="con_btn">
- <el-button type="primary">保 存</el-button>
- </div>
- </div>
- </div>
- </template>
- <script>
- import E from 'wangeditor'
- export default {
- name: 'tab2Add',
- components: {},
- data () {
- // 这里存放数据
- return {
- time: '',
- // 服务器前缀地址
- baseURL: '',
- token: '',
- ruleForm: {
- name: '',
- sex: '1',
- face: '',
- position: '',
- startTime: '',
- endTime: '',
- thumb: ''
- },
- rules: {
- name: [{ required: true, message: '不能为空', trigger: 'blur' }],
- sex: [{ required: true, message: '不能为空', trigger: 'blur' }],
- face: [{ required: true, message: '不能为空', trigger: 'change' }],
- position: [{ required: true, message: '不能为空', trigger: 'change' }]
- }
- }
- },
- // 监听属性 类似于data概念
- computed: {},
- // 监控data中的数据变化
- watch: {
- time (val) {
- this.handleSelect(val)
- }
- },
- // 方法集合
- methods: {
- // 上传图片
- beforethumbUpload (file) {
- // console.log(998, file)
- // 限制图片大小和格式
- const sizeOk = file.size / 1024 / 1024 < 5
- const typeOk =
- file.type === 'image/png' ||
- file.type === 'image/jpeg' ||
- file.type === 'image/gif'
- return new Promise((resolve, reject) => {
- if (!typeOk) {
- this.$message.error('照片格式有误!')
- reject(file)
- } else if (!sizeOk) {
- this.$message.error('照片大小超过5M!')
- reject(file)
- } else if (file.name.length > 32) {
- this.$message.error('照片名字不能超过32个字!')
- reject(file)
- } else {
- this.$message.success('上传成功')
- resolve(file)
- }
- })
- },
- upload_thumb_success (data) {
- // console.log('图片上传成功', data.data.urlPath)
- this.ruleForm.thumb = data.data.urlPath
- },
- // 点击返回
- goBack () {
- this.$confirm('点击返回后,编辑的信息将无法保存,是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- })
- .then(async () => {
- this.$router.push('/layout/tab2')
- })
- .catch(() => {
- this.$message.info('已取消')
- })
- },
- // 时间处理----------------
- handleSelect (e) {
- const date = []
- for (const i in e) {
- date.push(this.gettime(e[i]))
- }
- this.ruleForm.startTime = date[0]
- if (date[1]) {
- this.ruleForm.endTime = date[1].replace('00:00:00', '23:59:59')
- }
- if (e === null) this.ruleForm.endTime = ''
- },
- gettime (data) {
- const value =
- data.getFullYear() +
- '-' +
- this.checkTime(data.getMonth() + 1) +
- '-' +
- this.checkTime(data.getDate()) +
- ' ' +
- this.checkTime(data.getHours()) +
- ':' +
- this.checkTime(data.getMinutes()) +
- ':' +
- this.checkTime(data.getSeconds())
- return value
- },
- checkTime (i) {
- if (i < 10) {
- i = '0' + i
- }
- return i
- }
- },
- // 生命周期 - 创建完成(可以访问当前this实例)
- created () {},
- // 生命周期 - 挂载完成(可以访问DOM元素)
- mounted () {
- // 初始化富文本
- // 富文本
- this.editor = new E('#div1')
- // 配置字体
- this.editor.config.fontNames = [
- '黑体',
- '仿宋',
- '楷体',
- '标楷体',
- '华文仿宋',
- '华文楷体',
- '宋体',
- '微软雅黑',
- 'Arial',
- 'Tahoma',
- 'Verdana',
- 'Times New Roman'
- ]
- this.editor.config.uploadImgShowBase64 = true // 图片地址
- this.editor.config.showLinkVideo = false
- this.editor.create()
- this.editor.txt.html('66666666666666666')
- },
- beforeCreate () {}, // 生命周期 - 创建之前
- beforeMount () {}, // 生命周期 - 挂载之前
- beforeUpdate () {}, // 生命周期 - 更新之前
- updated () {}, // 生命周期 - 更新之后
- beforeDestroy () {}, // 生命周期 - 销毁之前
- destroyed () {}, // 生命周期 - 销毁完成
- activated () {} // 如果页面有keep-alive缓存功能,这个函数会触发
- }
- </script>
- <style lang='less' scoped>
- .tab2Add {
- height: 100%;
- .conten {
- padding-bottom: 10px;
- overflow-y: auto;
- height: calc(100% - 32px);
- .con_top {
- margin-bottom: 12px;
- height: 40px;
- line-height: 40px;
- padding-left: 20px;
- background-color: #fbfbfb;
- }
- .biaoshi1::before {
- left: -64px;
- top: -10px;
- }
- .biaoshi2::before {
- left: -78px;
- }
- /deep/.el-icon-plus {
- border: 1px dashed #ccc;
- }
- .avatar-uploader .el-upload {
- border-radius: 6px;
- cursor: pointer;
- position: relative;
- overflow: hidden;
- }
- .avatar-uploader .el-upload:hover {
- border-color: #3e5eb3;
- }
- .avatar-uploader-icon {
- font-size: 28px;
- color: #8c939d;
- width: 178px;
- height: 178px;
- line-height: 178px;
- text-align: center;
- }
- #div1{
- width: 85%;
- margin: 0 auto;
- }
- .con_btn {
- width: 80px;
- margin: 15px auto 0;
- }
- }
- }
- </style>
|