From ef37c59e055a990ce247b265b27d3fcef430a243 Mon Sep 17 00:00:00 2001 From: 杨磊 <505174330@qq.com> Date: 星期五, 15 八月 2025 10:19:18 +0800 Subject: [PATCH] first submit --- src/views/personalCenter/components/authorContribution.vue | 731 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 731 insertions(+), 0 deletions(-) diff --git a/src/views/personalCenter/components/authorContribution.vue b/src/views/personalCenter/components/authorContribution.vue new file mode 100644 index 0000000..816ca1c --- /dev/null +++ b/src/views/personalCenter/components/authorContribution.vue @@ -0,0 +1,731 @@ +<template> + <div class="content"> + <div v-if="!submissionStatus" style="min-height: 600px" v-loading="loading"> + <template> + <el-button + type="primary" + class="btn" + @click="changeSubmissionStatus" + plain + >鎶曠</el-button + > + </template> + <el-empty + description="鏆傛棤鏁版嵁" + class="empty" + :image-size="200" + v-if="tableData.length == 0 && !loading" + ></el-empty> + <template v-if="tableData.length > 0 && !loading"> + <el-table + :header-cell-style="rowClass" + :data="tableData" + border + style="width: 100%" + > + <el-table-column + align="center" + prop="date" + type="index" + label="搴忓彿" + width="60" + > + <template slot-scope="scope"> + {{ + (paginationData.page - 1) * paginationData.limit + + scope.$index + + 1 + }} + </template> + </el-table-column> + <el-table-column label="浣滃搧鍚嶇О"> + <span class="ellipsis" slot-scope="scope"> + {{ scope.row.contribute_workName || "-" }} + </span> + </el-table-column> + <el-table-column label="浣滃搧鎻忚堪"> + <span class="ellipsis" slot-scope="scope"> + {{ scope.row.contribute_workDescription || "-" }} + </span> + </el-table-column> + <el-table-column label="鏌ョ湅" width="60" align="center"> + <span + class="see" + slot-scope="scope" + @click="viewContributions(scope.row.content)" + > + 鏌ョ湅 + </span> + </el-table-column> + </el-table> + <!-- 鍒嗛〉 --> + <div class="pageinateBox" v-if="tableData.length > 0"> + <el-pagination + @size-change=" + (val) => { + paginationData.limit = val; + getAuthorContribution(); + } + " + @current-change=" + (val) => { + paginationData.page = val; + getAuthorContribution(); + } + " + background="" + :current-page="paginationData.page - 0" + :page-size="paginationData.limit" + prev-text="涓婁竴椤�" + next-text="涓嬩竴椤�" + layout="total, prev, pager, next, slot, jumper" + :total="paginationData.totalCount" + > + </el-pagination> + </div> + </template> + </div> + <div v-else> + <el-form + :model="ruleForm" + :rules="rules" + ref="form" + :disabled="disabled" + class="demo-ruleForm" + label-position="left" + label-suffix=":" + label-width="140px" + > + <el-form-item label="浣滃搧鍚嶇О" prop="contribute_workName"> + <el-input + v-model="ruleForm.contribute_workName" + placeholder="璇疯緭鍏ヤ綔鍝佸悕绉�" + ></el-input> + </el-form-item> + <el-form-item label="鐢靛瓙閭" prop="contribute_email"> + <el-input + v-model="ruleForm.contribute_email" + placeholder="璇疯緭鍏ユ偍鐨勯偖绠卞湴鍧�" + ></el-input> + </el-form-item> + <el-form-item label="鑱旂郴鏂瑰紡" prop="contribute_contact"> + <el-input + v-model="ruleForm.contribute_contact" + placeholder="璇疯緭鍏ユ墜鏈哄彿" + ></el-input> + </el-form-item> + <el-form-item label="鐩稿叧璇佷欢" prop="contribute_workCertificates"> + <div class="lecturingSpecixalty"> + <el-upload + :file-list="ruleForm.contribute_workCertificates" + action="" + :limit="5" + :on-exceed=" + () => { + this.$message({ + message: '鏈�澶氫笂浼�5涓枃浠讹紝璇风Щ闄ゅ叾浠栨枃浠跺悗鍐嶄笂浼犮��', + type: 'warning', + }); + } + " + :http-request="beforeRead" + :multiple="false" + list-type="picture-card" + :before-remove="beforeDelimg" + :on-preview="handlePictureCardPreview" + :on-success="uploadSucceeded" + :on-error="uploadFailed" + :on-remove="handleRemove" + > + <i class="el-icon-plus"></i> + </el-upload> + </div> + </el-form-item> + <div class="notice"> + 娉細鎺ㄨ崘浼樺厛涓婁紶鎮ㄧ殑鏁欏笀璇佺數瀛愮増鎴栨牎鍥崱鎴栧伐浣滆瘉鎴栬韩浠借瘉 + 鏀寔涓婁紶jpg銆乸ng鏂囦欢 + </div> + <el-form-item label="浣滃搧鎻忚堪" prop="contribute_workDescription"> + <el-input + class="" + type="textarea" + v-model="ruleForm.contribute_workDescription" + :autosize="{ minRows: 5, maxRows: 15 }" + placeholder="璇峰浣滃搧鍋氬ぇ姒傜畝浠�" + ></el-input> + </el-form-item> + <el-form-item label="浣滃搧" prop="contribute_works"> + <el-upload + :http-request="uploadFile" + action="" + :on-remove="handleRemoveFile" + :on-error="uploadFailed" + :on-success="fileuploadSucceeded" + :before-remove="beforeRemove" + multiple + :limit="3" + :on-exceed=" + () => { + this.$message({ + message: '鏈�澶氫笂浼�5涓枃浠讹紝璇风Щ闄ゅ叾浠栨枃浠跺悗鍐嶄笂浼犮��', + type: 'warning', + }); + } + " + :file-list="ruleForm.contribute_works" + > + <el-button size="small" type="primary">鐐瑰嚮涓婁紶</el-button> + </el-upload> + </el-form-item> + <span class="notice">娉細浣滃搧澶у皬涓嶅緱瓒呰繃 30Mb </span> + <div class="agreement" v-if="!disabled"> + <span + class="choose" + @click=" + () => { + this.agreement = !this.agreement; + } + " + > + <img + v-show="agreement" + src="@/assets/images/personalCenter/choose.png" + alt="" + /> + </span> + <span class="infoTxt"> + 宸查槄璇诲苟鍚屾剰<span class="textpro" @click.stop="onPrivacy" + >銆婇殣绉佹潈鏀跨瓥銆�</span + ><span class="textpro" @click.stop="onStatement">銆婃硶寰嬪0鏄庛��</span> + </span> + </div> + </el-form> + <div> + <div + v-if="!disabled" + class="basic addAddressButton greenButton" + type="primary" + @click="authorContribution()" + > + 鎻愪氦 + </div> + <div class="basic addAddressButton delete" @click="cancel">杩斿洖</div> + </div> + <el-dialog :visible.sync="dialogImageState"> + <img width="100%" :src="dialogImageUrl" alt="" /> + </el-dialog> + <el-dialog + :title="dialogName" + :visible.sync="centerDialogVisible" + width="40%" + center + > + <p class="protocolBox" v-html="dialoagContent"></p> + <span slot="footer" class="dialog-footer"> + <el-button type="primary" @click="onCancel">纭� 瀹�</el-button> + </span> + </el-dialog> + </div> + </div> +</template> +<script> +import { mapState } from "vuex"; +import { getPublicImage } from "@/assets/js/middleGround/tool"; + +export default { + data() { + return { + dialogName: "", + centerDialogVisible: false, + disabled: false, + ruleForm: { + contribute_workName: "", + contribute_email: "", + contribute_contact: "", + contribute_workCertificates: [], + contribute_workDescription: "", + contribute_works: [], + }, + rules: { + contribute_workName: [ + { required: true, message: "璇峰~鍐欎綔鍝佸悕绉�", trigger: "blur" }, + ], + contribute_email: [ + { required: true, message: "璇峰~鍐欓偖绠�", trigger: "blur" }, + { + pattern: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/, + message: "閭鏍煎紡鏍¢獙澶辫触锛岃杈撳叆閭", + trigger: "blur", + }, + ], + contribute_contact: [ + { required: true, message: "璇疯緭鍏ユ墜鏈哄彿", trigger: "blur" }, + { + pattern: + /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/, + message: "璇疯緭鍏ユ纭墜鏈哄彿", + trigger: "blur", + }, + ], + contribute_workCertificates: [ + { required: true, message: "璇蜂笂浼犳偍鐨勮瘉浠�", trigger: "blur" }, + ], + contribute_workDescription: [ + { required: true, message: "璇峰~鍐欐偍鐨勪綔鍝佹弿杩�", trigger: "blur" }, + ], + contribute_works: [ + { required: true, message: "璇蜂笂浼犳偍鐨勪綔鍝�", trigger: "change" }, + ], + }, + agreement: false, + lecturingSpecialty: "", + file: "", + pictrueList: [], + // 鏌ョ湅宸查�変腑鐨勫浘鐗� + dialogImageUrl: "", + // 鏌ョ湅宸查�変腑鐨勫浘鐗� 鏄剧ず鐘舵�� + dialogImageState: false, + certificatesImg: "", + loading: false, + paginationData: { + page: 1, + totalCount: 0, + limit: 10, + totalPage: 0, + }, + tableData: [], + worksInfo: [], + submissionStatus: false, // 鍒囨崲鏄剧ず 琛ㄥ崟鍒楄〃 銆� 鎻愪氦琛ㄥ崟 + protocolPrivacyTxt: "", + protocolStatementTxt: "", + dialoagContent: "", + }; + }, + computed: { + ...mapState(["userInfo"]), + }, + created() { + this.getAuthorContribution(); + this.getTypeItem(); + this.getPrivacy(); + }, + methods: { + onCancel() { + this.dialoagContent = ""; + this.centerDialogVisible = false; + }, + onPrivacy() { + this.dialogName = "銆婇殣绉佹潈鏀跨瓥銆�"; + this.dialoagContent = this.protocolPrivacyTxt + ? this.protocolPrivacyTxt + : "鏆傛棤鍗忚"; + this.centerDialogVisible = true; + }, + onStatement() { + this.dialogName = "銆婃硶寰嬪0鏄庛��"; + this.dialoagContent = this.protocolStatementTxt + ? this.protocolStatementTxt + : "鏆傛棤鍗忚"; + this.centerDialogVisible = true; + }, + getPrivacy() { + var that = this; + that.MG.resource + .getItem({ + path: this.config.refCodes.Privacy, + fields: { + caupress_content: [], + }, + }) + .then((res) => { + try { + const authorPrivacyPolic = res.datas.find( + (e) => e.refCode == "caupress_authorPrivacyPolicy" + ); + const legalNotices = res.datas.find( + (e) => e.refCode == "caupress_legalNotices" + ); + this.protocolPrivacyTxt = authorPrivacyPolic + ? authorPrivacyPolic.caupress_content + : "鏆傛棤鍗忚"; + this.protocolStatementTxt = legalNotices + ? legalNotices.caupress_content + : "鏆傛棤鍗忚"; + } catch (error) { + this.protocolPrivacyTxt = "鏆傛棤鍗忚"; + this.protocolStatementTxt = "鏆傛棤鍗忚"; + } + }); + }, + getStatement() {}, + rowClass() { + //琛ㄦ牸鏁版嵁灞呬腑鏄剧ず + return "text-align:center"; + }, + // 鍒囨崲 鎻愪氦琛ㄥ崟 銆� 琛ㄥ崟鍒楄〃 + changeSubmissionStatus(openEdit) { + if (this.userInfo.phoneNumber) { + this.submissionStatus = !this.submissionStatus; + // 鍒囨崲鍒板垪琛ㄩ〉閲嶆柊鑾峰彇鏁版嵁 + if (!openEdit) { + // 涓嶈缂栬緫 閫変腑鍗忚 + this.disabled = true; + } else { + this.disabled = false; + } + if (!this.submissionStatus) { + this.paginationData.page = 1; + this.getAuthorContribution(); + } + } else { + this.$message({ + message: "璇峰厛缁戝畾鎵嬫満鍙凤紒", + type: "warning", + }); + } + }, + // 鑾峰彇鎵�鏈変綔鑰呮姇绋� + getAuthorContribution() { + this.loading = true; + let { limit, page } = this.paginationData; + + let query = { + start: limit * page - limit, + size: limit, + sort: { + field: "createDate", + type: "Desc", + }, + appRefCode: this.config.appRefCode, + topicIdOrRefCode: "contribution", + }; + this.MG.ugc.getTopicMessageList(query).then((res) => { + this.loading = false; + this.paginationData.totalCount = res.totalSize; + this.tableData = []; + res.datas.map((item) => { + let content = JSON.parse(item.content); + this.tableData.push({ + contribute_workName: content.contribute_workName, + contribute_workDescription: content.contribute_workDescription, + content: content, + }); + }); + }); + }, + handlePictureCardPreview(file) { + this.dialogImageState = true; + this.dialogImageUrl = file.url; + }, + // 绉婚櫎鍥剧墖鍚庣殑澶勭悊 + handleRemove(file, filelist) { + this.ruleForm.contribute_workCertificates = filelist; + }, + // 绉婚櫎涓婁紶鏂囦欢鍚庣殑澶勭悊 + handleRemoveFile(file, filelist) { + this.ruleForm.contribute_works = filelist; + }, + // 涓婁紶浣滃搧 + uploadFile(file) { + this.isLoding = true; + return new Promise((resolve, reject) => { + const FileName = file.file.name.split(".")[0]; + const Extension = file.file.name.split(".")[1]; + const FileType = file.file.type; + // 濡傛灉鏂囦欢澶т簬 30mb 鎻愮ず鏂囦欢杩囧ぇ锛屼笉鍏佽涓婁紶 + if (file.file.size > 30000000) { + this.$message({ + message: "浣滃搧澶у皬瓒呰繃30Mb,璇蜂笂浼犲皬浜�30Mb澶у皬鐨勪綔鍝�", + type: "error", + }); + return reject(); + } + let size = 1024; + this.tool + .getFileMd5(file.file, size * 1024) + .then((e) => { + const imgData = new FormData(); + this.fileMd5 = e; + imgData.append("Md5", e); + imgData.append("FileName", FileName); + imgData.append("Extension", Extension); + imgData.append("FileType", FileType); + imgData.append("MetaData", null); + imgData.append("file", file.file); + this.MG.file.upload(imgData).then((res) => { + this.$message({ + message: "浣滃搧涓婁紶鎴愬姛", + type: "success", + }); + return resolve(e); + }); + }) + .catch((e) => { + this.isLoding = false; + console.error(e); + return reject(); + }); + }); + }, + // 浣滃搧涓婁紶鎴愬姛鍚庣殑澶勭悊 + fileuploadSucceeded(res, file, filelist) { + filelist[filelist.length - 1].md5 = res; + this.ruleForm.contribute_works = filelist; + this.$refs["form"].validateField("contribute_works"); + }, + // 鑾峰彇FormTypeItem + getTypeItem() { + const data = { + refCodes: ["contributedWorks"], + }; + this.MG.resource.getCmsTypeByRefCode(data).then((res) => { + this.worksInfo = res[0].cmsTypeLinks[0].children; + }); + }, + // 鎻愪氦浣滆�呮姇绋� + authorContribution() { + this.$refs["form"].validate((valid) => { + if (valid) { + // 鍒ゆ柇鏄惁鍚屾剰浜嗗崗璁� + if (this.agreement) { + this.loading = true; + this.teacherRegisterLoading = true; + + // 绉婚櫎鍥剧墖涓嶇浉鍏冲睘鎬� + this.ruleForm.contribute_workCertificates.map((item) => { + delete item.status; + delete item.uid; + delete item.url; + delete item.percentage; + delete item.raw; + delete item.response; + delete item.size; + }); + // 绉婚櫎鏂囦欢涓嶇浉鍏冲睘鎬� + this.ruleForm.contribute_works.map((item) => { + delete item.status; + delete item.uid; + delete item.url; + delete item.percentage; + delete item.raw; + delete item.response; + delete item.size; + }); + + const data = { + topicIdOrRefCode: "contribution", + name: this.ruleForm.contribute_workName, + content: JSON.stringify(this.ruleForm), + state: "Normal", + type: "authorOfSubmission", + cmsTypeRefCode: this.config.refCodes.Contribution, + newDataListRequest: this.tool.worksDataBytool( + this.worksInfo, + this.ruleForm, + this.ruleForm.contribute_workCertificates + ), + }; + this.MG.ugc.newTopicMessage(data).then((res) => { + if (res) { + // 鎭㈠榛樿鍊� + for (const key in this.ruleForm) { + this.ruleForm[key] = Array.isArray(this.ruleForm[key]) + ? [] + : ""; + } + this.$message({ + message: "鎶曠鎴愬姛", + type: "success", + }); + this.loading = false; + this.changeSubmissionStatus(); + } else { + this.$message.error("鎶曠澶辫触锛岃绋嶅悗閲嶈瘯"); + } + }); + } else { + this.$message({ + message: "璇峰嬀閫夛紝宸查槄璇诲苟鍚屾剰銆婇殣绉佹潈鏀跨瓥銆嬨�婃硶寰嬪0鏄庛��", + type: "warning", + }); + } + } else { + return false; + } + }); + }, + // 鍙栨秷鎶曠 + cancel() { + this.changeSubmissionStatus(); + // 鎭㈠榛樿鍊� + for (const key in this.ruleForm) { + this.ruleForm[key] = Array.isArray(this.ruleForm[key]) ? [] : ""; + } + }, + // 涓婁紶鍥剧墖 + beforeRead(file) { + this.isLoding = true; + return new Promise((resolve, reject) => { + const FileName = file.file.name.split(".")[0]; + const Extension = file.file.name.split(".")[1]; + const FileType = file.file.type; + if (FileType != "image/jpeg" && FileType != "image/png") { + this.$message({ + message: "鏂囦欢鏍煎紡涓嶅厑璁革紝鍙厑璁镐笂浼犲浘鐗囨牸寮�", + type: "error", + }); + return reject(); + } + let size = 1024; + this.tool + .getFileMd5(file.file, size * 1024) + .then((e) => { + this.isLoding = false; + const imgData = new FormData(); + this.fileMd5 = e; + imgData.append("Md5", e); + imgData.append("FileName", FileName); + imgData.append("Extension", Extension); + imgData.append("FileType", FileType); + imgData.append("MetaData", null); + imgData.append("file", file.file); + this.MG.file.upload(imgData).then((res) => { + if (res == "鏂囦欢涓婁紶鎴愬姛") { + this.$message({ + message: "鍥剧墖涓婁紶鎴愬姛", + type: "success", + }); + return resolve(e); + } else { + return reject(); + } + }); + }) + .catch((e) => { + this.isLoding = false; + console.error(e); + return reject(); + }); + }); + }, + // 涓婁紶鍥剧墖鎴愬姛鍚庣殑澶勭悊 + uploadSucceeded(res, file, filelist) { + filelist[filelist.length - 1].md5 = res; + this.ruleForm.contribute_workCertificates = filelist; + this.$refs["form"].validateField("contribute_workCertificates"); + }, + // 鍒犻櫎鍥剧墖鏂囦欢涔嬪墠鐨勯挬瀛� + beforeDelimg() { + return this.$confirm(`纭畾绉婚櫎璇佷欢鐓у悧锛焋); + }, + // 涓婁紶澶辫触 + uploadFailed() { + this.$message.error("鏂囦欢涓婁紶澶辫触锛岃绋嶅悗閲嶈瘯"); + }, + // 绉婚櫎涓婁紶鐨勬枃浠� + beforeRemove() { + return this.$confirm(`纭畾绉婚櫎浣滃搧鍚楋紵`); + }, + // 鏌ョ湅鎶曠 + viewContributions(ele) { + ele.contribute_workCertificates?.map((item) => { + item.url = getPublicImage(item.md5); + }); + Object.assign(this.ruleForm, ele); + this.changeSubmissionStatus(false); + }, + }, +}; +</script> +<style lang="less" scoped> +.protocolBox { + text-align: left; + line-height: 23px; + z-index: 1; + height: 500px; + overflow-y: auto; + margin-top: -20px; + box-sizing: border-box; + padding: 10px; +} +.content { + padding: 40px; + overflow: hidden; + .btn { + margin-bottom: 20px; + } + .see { + cursor: pointer; + } + .notice { + font-size: 14px; + color: #b3b3b3; + margin-left: 140px; + margin-bottom: 20px; + } + .lecturingSpecixalty { + display: flex; + border: 1px solid #dcdfe6; + border-radius: 4px; + padding: 20px; + min-height: 148px; + } + .agreement { + display: flex; + padding: 40px 0; + height: 20px; + align-items: center; + .choose { + display: inline-block; + border: 1px solid #e2e2e2; + width: 13px; + height: 13px; + margin-right: 10px; + cursor: pointer; + img { + margin-left: 2px; + margin-bottom: 2px; + } + } + .infoTxt { + .textpro { + color: #00873c; + cursor: pointer; + } + } + } + .basic { + width: 120px; + height: 40px; + border-radius: 4px; + color: #fff; + font-size: 16px; + text-align: center; + line-height: 40px; + cursor: pointer; + } + .addAddressButton { + float: right; + margin-right: 20px; + } + .greenButton { + background: linear-gradient(0deg, #00873c 0%, #00aa4c 100%); + } + .delete { + color: #00873c; + background-color: #fff; + border: 1px solid #00873c; + border-radius: 4px; + } + .pageinateBox { + text-align: center; + padding: 40px 0 0 0; + :deep(.el-pagination.is-background .btn-next) { + padding: 0 10px; + } + :deep(.el-pagination.is-background .btn-prev) { + padding: 0 10px; + } + } +} +</style> -- Gitblit v1.9.1