var _this; var nowTime = new Date().getTime(); var periodChart, typeChart; new Vue({ el: '#app', filters: { getImgList(key){ return [fileUrl+key]; } }, data: function() { return { queryParams: { pageNum: 1, pageSize: 10, orderByColumn: "certificateEffectiveDate", isAsc: "descending", createBy: "31" }, imgUrl: '', rules: { deptId: [{ required: true, message: "所属部门不能为空", trigger: "blur" }], certificateName: [{ required: true, message: "证书名称不能为空", trigger: "blur" }], certificateIssueDate: [{ required: true, message: "签发日期不能为空", trigger: "blur" }], }, certificateList: [], allTotal: 0, open: false, title: "", cerForm: {}, certificate_category: [], defaultProps: { children: 'children', label: 'label' }, deptOptions: [], upHeaders: {} } }, created() { _this = this; _this.imgUrl = fileUrl; _this.upHeaders = { "Authorization": "Bearer " + getCookie("tzToken") } // setFileLogin() let _obj = getUseDict("certificate_category") setTimeout(()=>{ _this.certificate_category = _obj["certificate_category"]; }, 500); this.getList(); this.getTree(); }, mounted:function(){ }, methods: { getList(){ getCertificateList(_this.queryParams).then((response) => { _this.certificateList = response.rows; _this.allTotal = response.total; }) }, getTree(){ getDeptList().then((response) => { _this.deptOptions = response.data; }) }, handleQuery() { _this.queryParams.pageNum = 1; this.getList(); }, resetQuery() { _this.queryParams = { pageNum: 1, pageSize: 10, orderByColumn: "certificateEffectiveDate", isAsc: "descending" } this.handleQuery(); }, handleCurrentChange(val) { if(val != _this.queryParams.pageNum){ _this.queryParams.pageNum = val; this.getList(); } }, handleDelete(row) { const certificateIds = row.certificateId; this.$confirm('是否确认删除证书编号为"' + certificateIds + '"的数据项?').then(function () { return DelCertificate(certificateIds); }).then(() => { this.getList(); this.$message({ showClose: true, message: "删除成功", type: 'success' }); }).catch(() => { }); }, handleUpdate(row) { this.reset(); var certificateId = row.certificateId; getCertificateDetail(certificateId).then(response => { _this.cerForm = response.data; _this.open = true; setTimeout(()=>{ this.$refs.treeSele.setCurrentKey(_this.cerForm.deptId); },500); _this.title = "修改证书"; }); }, handleAdd() { this.reset(); _this.open = true; _this.title = "添加证书"; }, reset() { _this.cerForm = { certificateId: null, deptId: null, deptName: "请选择", certificateName: null, certificateIssueDate: null, certificateType: null, certificateNextDate: null, certificateEffectiveDate: null, certificateTerm: null, certificatePositve: "", certificateContent: null, certificateState: null, certificateRemarks: null, createBy: null, createTime: null, certificateCategory: '1', isRemind: '1' }; }, nodeClick(_e){ _this.cerForm.deptName = _e.label, _this.cerForm.deptId = _e.id this.$refs.conSelect.blur(); }, /** 提交按钮 */ submitForm() { if (_this.cerForm.certificateId != null) { updateCertificate(_this.cerForm).then(response => { this.$message({ showClose: true, message: "修改成功", type: 'success' }); _this.open = false; this.getList(); }); } else { addCertificate(_this.cerForm).then(response => { this.$message({ showClose: true, message: "新增成功", type: 'success' }); _this.open = false; this.getList(); }); } }, handleAvatarSuccess(res, file) { _this.cerForm.certificatePositve = res.fileName; }, beforeAvatarUpload(file) { const fileType = ["png", "jpg", "jpeg"]; const isLt2M = file.size / 1024 / 1024 < 5; let fileExtension = ""; if (file.name.lastIndexOf(".") > -1) { fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1); } isImg = fileType.some(type => { if (file.type.indexOf(type) > -1) return true; if (fileExtension && fileExtension.indexOf(type) > -1) return true; return false; }); if (!isImg) { this.$message.error('上传头像图片只能是 "png", "jpg", "jpeg" 格式!'); } if (!isLt2M) { this.$message.error('上传头像图片大小不能超过 5MB!'); } return isImg && isLt2M; } } })