123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363 |
- <template>
- <div class="autoBox box">
- <div class="crumbs">
- <el-breadcrumb separator="/">
- <el-breadcrumb-item :to="{ path: 'home' }">{{
- $t("common.Home")
- }}</el-breadcrumb-item>
- <el-breadcrumb-item>{{ $t("common.Feedback") }}</el-breadcrumb-item>
- </el-breadcrumb>
- </div>
- <div class="suggess">
- <el-form ref="form" :model="form" :rules="formrules">
- <!-- 建议类型-->
- <el-form-item
- :label="$t('common.SuggestedType') + ':'"
- prop="suggestion"
- >
- <el-radio-group v-model="form.suggestion" style="width: 100%">
- <el-radio-button
- v-for="(item, index) in suggestype"
- :key="index"
- :label="item.value"
- border
- >{{ item.label }}</el-radio-button
- >
- </el-radio-group>
- </el-form-item>
- <!-- 反馈内容-->
- <el-form-item
- :label="$t('common.ContentFeedback') + ':'"
- prop="report"
- style="margin-top: 45px"
- >
- <el-input
- type="textarea"
- v-model="form.report"
- :autosize="{ minRows: 5, maxRows: 10 }"
- :placeholder="$t('common.PleaseInputFeedback')"
- maxlength="300"
- minlength="15"
- show-word-limit
- class="feedtext"
- ></el-input>
- </el-form-item>
- <!-- 上传图片-->
- <el-form-item style="margin-top: 50px">
- <div class="uploadText">{{ $t("common.ToUploadPictures") }}:</div>
- <div style="display: inline-block">
- <el-upload
- action="/api/file/upload/img?module=feedback"
- :headers="myHeaders"
- list-type="picture-card"
- :on-success="handleAvatarSuccess"
- :before-upload="beforeAvatarUpload"
- :limit="5"
- ref="upImage"
- >
- <i class="el-icon-plus"></i>
- </el-upload>
- </div>
- <span class="maxupload">{{ $t("common.UploadUupMaxPhotos") }}</span>
- </el-form-item>
- <!-- 联系方式-->
- <el-form-item
- :label="$t('common.ContactWay') + ':'"
- prop="phone"
- style="margin-top: 50px"
- >
- <el-input
- type="text"
- v-model="form.phone"
- style="width: 240px"
- ></el-input>
- </el-form-item>
- <!-- 提交反馈-->
- <el-form-item>
- <el-button
- type="primary"
- @click="onSubmit"
- style="margin-left: 155px"
- >{{ $t("common.SubmitFeedback") }}</el-button
- >
- </el-form-item>
- </el-form>
- </div>
- </div>
- </template>
- <script>
- import Base from "@/views/base/Base";
- import { getToken, resetToken } from "@/utils/auth";
- import { saveOrUpdate } from "@/api/feedback";
- import { getDicts } from "@/api/dict";
- import { addGrowth } from "@/utils/toCompleteTask";
- import { getUserPointPage } from "@/api/user";
- export default {
- name: "Feedback",
- extends: Base,
- data() {
- return {
- suggestype: [],
- dialogImageUrl: "",
- dialogVisible: false,
- form: {
- suggestion: "",
- report: "",
- picture: [],
- phone: "",
- },
- feedback: {
- suggestion: "",
- report: "",
- picture: [],
- phone: "",
- account_name: "",
- user_id: "",
- },
- myHeaders: { Authorization: "Bearer " + getToken() },
- user: {
- umsUser: {},
- },
- pointStatus: null,
- };
- },
- mounted() {
- this.getType();
- this.getUser();
- this.clearForm();
- this.initData();
- },
- computed: {
- formrules() {
- return {
- suggestion: [
- {
- required: true,
- message:
- this.$i18n.locale == "zh"
- ? "请选择建议类型"
- : "Please select the type of suggestion",
- trigger: "change",
- },
- ],
- report: [
- {
- required: true,
- message:
- this.$i18n.locale == "zh"
- ? "请输入反馈内容"
- : "Please enter feedback",
- trigger: "change",
- },
- {
- min: 15,
- message:
- this.$i18n.locale == "zh"
- ? "不得少于15字"
- : "No less than 15 words",
- trigger: "change",
- },
- ],
- phone: [
- {
- required: true,
- message:
- this.$i18n.locale == "zh"
- ? "请输入联系方式"
- : "Please enter your mobile phone number",
- trigger: "change",
- },
- {
- pattern: /^([0-9]*)$/,
- message:
- this.$i18n.locale == "zh"
- ? "请输入合法的手机号"
- : "Please enter a valid mobile phone number",
- },
- ],
- };
- },
- },
- watch: {
- "$i18n.locale"() {
- this.getType();
- this.getUser();
- },
- },
- methods: {
- initData() {
- getUserPointPage().then((res) => {
- this.pointStatus = res.data.umsUserPoints[0].pointStatus;
- });
- },
- //图片上传成功
- handleAvatarSuccess(res, file) {
- // console.log(this.form.picture)
- this.form.picture.push(res.data);
- // this.photoLength = this.form.picture.length;
- },
- //图片格式验证
- beforeAvatarUpload(file) {
- let photoStr = [];
- let photorules = ["jpg", "jpeg", "png", "webp"];
- let isJPG = false;
- photoStr = file.name.split(".")[1];
- if (photorules.indexOf(photoStr) == -1) {
- this.$message.error(this.$t("common.CorrectPictureFormat"));
- } else {
- isJPG = true;
- }
- return isJPG;
- },
- //清空对象集合
- clearForm() {
- this.$refs["form"].resetFields();
- this.$refs["upImage"].clearFiles();
- this.form = {
- suggestion: "",
- report: "",
- picture: [],
- phone: "",
- };
- },
- //获取建议类型
- getType() {
- if (this.$i18n.locale == "zh") {
- getDicts("SUGGESTION_DICT").then((res) => {
- this.suggestype = res.data[0];
- });
- } else if (this.$i18n.locale == "en") {
- getDicts("SUGGESTION_DICT_EN").then((res) => {
- this.suggestype = res.data[0];
- });
- }
- },
- //表单提交
- onSubmit(form) {
- this.$refs["form"].validate((valid) => {
- if (valid) {
- this.feedback.suggestion = this.form.suggestion;
- this.feedback.report = this.form.report;
- this.feedback.picture = this.form.picture;
- this.feedback.phone = this.form.phone;
- this.submitHandler((token) => {
- saveOrUpdate(JSON.stringify(this.feedback), token)
- .then((res) => {
- if (
- this.user.umsUser.userUsertypeDict !== "2" &&
- this.pointStatus == "y"
- ) {
- addGrowth("platform_problem_feedback");
- }
- this.$message({
- message:
- this.$i18n.locale.toUpperCase() == "ZH"
- ? "提交成功"
- : "Submitted successfully",
- type: "success",
- });
- this.resetToken();
- this.clearForm();
- })
- .catch((error) => {
- this.$notify.error({
- title: "common.Error",
- message: error.msg,
- });
- this.resetToken();
- this.clearForm();
- });
- });
- } else {
- console.log("error submit!!");
- return false;
- }
- });
- },
- //获取用户信息
- getUser() {
- let user = JSON.parse(window.localStorage.getItem("user"));
- this.feedback.account_name = user.username;
- this.feedback.user_id = user.userId;
- },
- //跳转链接
- toView(router, json) {
- this.$router.push({
- name: router,
- query: { key: json },
- });
- },
- },
- };
- </script>
- <style scoped>
- body {
- margin: 0;
- }
- .box {
- margin-top: 10px;
- background: #fff;
- /* height: 500px; */
- padding: 20px 0;
- }
- .crumbs {
- margin-left: 20px;
- }
- .suggess {
- padding: 10px 30px;
- margin-top: 20px;
- }
- .feedtext {
- width: 555px;
- display: block;
- }
- .el-form-item .el-form-item__label {
- font-size: 18px;
- color: black;
- font-weight: 600;
- }
- .el-radio-button {
- margin: 20px 40px 0 0;
- border: 1px solid rgba(204, 204, 204, 0.36);
- }
- .el-textarea__inner {
- height: 250px;
- }
- >>> .el-upload-list__item-actions {
- display: none;
- }
- .avatar-uploader .el-upload {
- border: 1px solid #d9d9d9;
- border-radius: 6px;
- cursor: pointer;
- position: relative;
- overflow: hidden;
- }
- .avatar-uploader .el-upload:hover {
- border-color: #409eff;
- }
- .uploadText {
- display: inline-block;
- }
- .maxupload {
- position: absolute;
- bottom: 0;
- margin-left: 10px;
- }
- .avatar-uploader-icon {
- font-size: 28px;
- color: #8c939d;
- width: 178px;
- height: 178px;
- line-height: 178px;
- text-align: center;
- }
- .avatar {
- width: 178px;
- height: 178px;
- display: inline-block;
- }
- </style>
|