|
|
@@ -0,0 +1,334 @@
|
|
|
+
|
|
|
+<template>
|
|
|
+ <el-dialog
|
|
|
+ :visible.sync="showDialog"
|
|
|
+ :title="title"
|
|
|
+ :modal-append-to-body="false"
|
|
|
+ style="text-align: left"
|
|
|
+ @close="closeDialog"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ width="1400px"
|
|
|
+ >
|
|
|
+ <div class="user-panel" v-loading="loading">
|
|
|
+
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="14">
|
|
|
+ <div class="grid-content bg-purple">
|
|
|
+ <el-card class="box-card">
|
|
|
+ <div slot="header" class="clearfix">
|
|
|
+ <span>基本信息</span>
|
|
|
+ </div>
|
|
|
+ <div class="text item">
|
|
|
+ <el-form
|
|
|
+ ref="form"
|
|
|
+ :model="formModel"
|
|
|
+ :rules="ruleValidate"
|
|
|
+ :label-width="'100px'"
|
|
|
+ >
|
|
|
+ <el-form-item label="类别" prop="category">
|
|
|
+ <el-select v-model="formModel.category" placeholder="请选择" style="width: 90%">
|
|
|
+ <el-option
|
|
|
+ v-for="item in categoryList"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.value">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="标题" prop="title">
|
|
|
+ <el-input
|
|
|
+ v-model="formModel.title"
|
|
|
+ placeholder="请输入标题"
|
|
|
+ style="width: 90%"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="数量" prop="amount">
|
|
|
+ <el-input-number
|
|
|
+ v-model="formModel.amount"
|
|
|
+ placeholder="请输入数量"
|
|
|
+ style="width: 90%"
|
|
|
+ :min="1"
|
|
|
+ ></el-input-number>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="图片" prop="image">
|
|
|
+ <el-upload
|
|
|
+ style="width:300px"
|
|
|
+ class="avatar-uploader"
|
|
|
+ name="photoFile"
|
|
|
+ :action="uploadUrl"
|
|
|
+ :headers="headers"
|
|
|
+ :data="uploadData"
|
|
|
+ :show-file-list="false"
|
|
|
+ :on-success="handleAvatarSuccess">
|
|
|
+ <img v-if="fileUrl" :src="fileUrl" class="avatar">
|
|
|
+ <i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
|
|
+ </el-upload>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="作品简介" prop="introduction">
|
|
|
+ <mce-editor
|
|
|
+ ref="editor"
|
|
|
+ uploadName="upfile"
|
|
|
+ v-model="formModel.introduction"
|
|
|
+ :url="uploadUrl1"
|
|
|
+ style="width: 90%"
|
|
|
+ ></mce-editor>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="10">
|
|
|
+ <div class="grid-content bg-purple">
|
|
|
+ <el-card class="box-card" style="height:943px">
|
|
|
+ <div slot="header" class="clearfix">
|
|
|
+ <span>学生心愿</span>
|
|
|
+ </div>
|
|
|
+ <div class="text item">
|
|
|
+ <el-form ref="form2" :model="formModel" inline :rules="ruleValidate" :label-width="'100px'">
|
|
|
+ <el-table
|
|
|
+ class="compact-table"
|
|
|
+ :data="formModel.studentAspirationsList" >
|
|
|
+ <el-table-column prop="name" label="心愿">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-form-item
|
|
|
+ :prop="'studentAspirationsList.' + scope.$index + '.name'"
|
|
|
+ :rules="ruleValidate['name']"
|
|
|
+ >
|
|
|
+ <el-input placeholder="心愿" v-model="scope.row.name" size="mini">
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="studentName" label="学生姓名">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-form-item
|
|
|
+ :prop="'studentAspirationsList.' + scope.$index + '.studentName'"
|
|
|
+ :rules="ruleValidate['studentName']"
|
|
|
+ >
|
|
|
+ <el-input placeholder="学生" v-model="scope.row.studentName" size="mini">
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" width="100" fixed="right">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <el-form-item>
|
|
|
+ <i class="el-icon-delete my-font" @click="handleDelete(row)"></i>
|
|
|
+ <i class="el-icon-document-add my-font" @click="handleInsert(row)"></i>
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ <div class="el-table__empty-block">
|
|
|
+ <el-button icon="el-icon-circle-plus-outline" @click="handleAdd()">新增</el-button>
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="closeDialog">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="handleSubmit" :loading="submitting"
|
|
|
+ >确 定</el-button
|
|
|
+ >
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import Constant from "@/constant";
|
|
|
+import { getToken } from "@/utils/auth"; // get token from cookie
|
|
|
+import MceEditor from "@/components/Tinymce";
|
|
|
+import wishInfoApi from "@/api/base/wishInfo";
|
|
|
+import dataDictionaryApi from "@/api/sys/dataDictionary";
|
|
|
+
|
|
|
+export default {
|
|
|
+ props: ["businessKey", "title"],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ showPwd: true,
|
|
|
+ ruleValidate: {
|
|
|
+ category: [
|
|
|
+ { required: true, message: "类型不能为空", trigger: "blur" },
|
|
|
+ ],
|
|
|
+ title: [
|
|
|
+ { required: true, message: "标题不能为空", trigger: "blur" },
|
|
|
+ ],
|
|
|
+ amount: [
|
|
|
+ { required: true, message: "数量不能为空", trigger: "blur" },
|
|
|
+ ],
|
|
|
+ studentName: [
|
|
|
+ { required: true, message: "学生姓名不能为空", trigger: "blur" },
|
|
|
+ ],
|
|
|
+ studentType: [
|
|
|
+ { required: true, message: "学生类型不能为空", trigger: "blur" },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ roleList: [],
|
|
|
+ formModel: {
|
|
|
+ studentAspirationsList:[],
|
|
|
+ },
|
|
|
+ showDialog: true,
|
|
|
+ loading: false,
|
|
|
+ submitting: false,
|
|
|
+ categoryList:[],
|
|
|
+ //上传地址
|
|
|
+ uploadUrl: Constant.serverUrl + "/uploadPicture",
|
|
|
+ uploadData: {
|
|
|
+ subFolder: "love-donation",
|
|
|
+ },
|
|
|
+ fileUrl: "",
|
|
|
+ fileUrl1: "",
|
|
|
+ headers: {
|
|
|
+ Authorization: getToken(),
|
|
|
+ },
|
|
|
+ uploadUrl1: Constant.serverUrl + "/tinymce/upload?token=" + getToken(),
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ dataDictionaryApi.findByCatalogName({catalogName: "心愿类型",})
|
|
|
+ .then((response) => {
|
|
|
+ var jsonData = response.data;
|
|
|
+ this.categoryList = jsonData.data;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ closeDialog() {
|
|
|
+ this.$emit("close", false);
|
|
|
+ },
|
|
|
+ handleSubmit() {
|
|
|
+ var self = this;
|
|
|
+
|
|
|
+ this.$refs["form"].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ (function () {
|
|
|
+ var id = self.formModel.id;
|
|
|
+
|
|
|
+ if (id == null || id.length == 0) {
|
|
|
+ return wishInfoApi.add(self.formModel);
|
|
|
+ } else {
|
|
|
+ self.formModel.password = null;
|
|
|
+ return wishInfoApi.update(self.formModel);
|
|
|
+ }
|
|
|
+ })().then(function (response) {
|
|
|
+ var jsonData = response.data;
|
|
|
+
|
|
|
+ if (jsonData.result) {
|
|
|
+ self.$message({
|
|
|
+ message: "保存成功!",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+
|
|
|
+ self.$emit("close", true);
|
|
|
+ } else {
|
|
|
+ self.$message({
|
|
|
+ message: jsonData.message + "",
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+
|
|
|
+ self.$emit("close", false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleAvatarSuccess(res, file) {
|
|
|
+ var self = this;
|
|
|
+ self.formModel.image = res.data;
|
|
|
+
|
|
|
+ self.fileUrl =
|
|
|
+ res.data + "?x-oss-process=image/resize,m_lfit,h_300,w_300";
|
|
|
+ },
|
|
|
+ handleAdd() {
|
|
|
+ this.formModel.studentAspirationsList.push({
|
|
|
+ name: "",
|
|
|
+ studentName: "",
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleInsert(row) {
|
|
|
+ this.formModel.studentAspirationsList.push({
|
|
|
+ name: "",
|
|
|
+ studentName: "",
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleDelete(row) {
|
|
|
+ var studentAspirationsList = this.formModel.studentAspirationsList;
|
|
|
+
|
|
|
+ studentAspirationsList.splice(studentAspirationsList.indexOf(row), 1);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ async mounted() {
|
|
|
+ var self = this;
|
|
|
+ self.loading = true;
|
|
|
+
|
|
|
+ (function () {
|
|
|
+ if (self.businessKey != null && self.businessKey.length > 0) {
|
|
|
+ return wishInfoApi.edit(self.businessKey);
|
|
|
+ } else {
|
|
|
+ return wishInfoApi.create();
|
|
|
+ }
|
|
|
+ })()
|
|
|
+ .then((response) => {
|
|
|
+ var jsonData = response.data;
|
|
|
+
|
|
|
+ if (jsonData.result) {
|
|
|
+ self.formModel = jsonData.data;
|
|
|
+ self.showModal = true;
|
|
|
+
|
|
|
+ let image = self.formModel.image;
|
|
|
+ if (image != null) {
|
|
|
+ self.fileUrl = image
|
|
|
+ }
|
|
|
+
|
|
|
+ if (self.formModel.introduction != null) {
|
|
|
+ self.$refs.editor.setContent(self.formModel.introduction);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ self.$message.error(jsonData.message + "");
|
|
|
+ }
|
|
|
+
|
|
|
+ self.loading = false;
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ self.$message.error(error + "");
|
|
|
+ self.loading = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ components: {
|
|
|
+ // "el-select-tree": SelectTree
|
|
|
+ "mce-editor": MceEditor,
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style scoped>
|
|
|
+.user-panel {
|
|
|
+ margin: 10px auto;
|
|
|
+}
|
|
|
+.avatar-uploader .el-upload {
|
|
|
+ border: 1px dashed #d9d9d9;
|
|
|
+ border-radius: 6px;
|
|
|
+ cursor: pointer;
|
|
|
+ position: relative;
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
+ .avatar-uploader .el-upload:hover {
|
|
|
+ border-color: #409EFF;
|
|
|
+ }
|
|
|
+ .avatar-uploader-icon {
|
|
|
+ font-size: 28px;
|
|
|
+ color: #8c939d;
|
|
|
+ width: 178px;
|
|
|
+ height: 178px;
|
|
|
+ line-height: 178px;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+ .avatar {
|
|
|
+ width: 178px;
|
|
|
+ height: 178px;
|
|
|
+ display: block;
|
|
|
+ }
|
|
|
+</style>
|