Commit f3ee9f97 by 彭祥礼

增加富文本编辑项

parent c9591a4d
...@@ -113,7 +113,8 @@ ...@@ -113,7 +113,8 @@
<a-form-item :labelCol="{span: 5}" :wrapperCol="{span: 9, offset: 1}" label="适用学校:"> <a-form-item :labelCol="{span: 5}" :wrapperCol="{span: 9, offset: 1}" label="适用学校:">
<a-select v-model="universityName" style="width: 330px"> <a-select v-model="universityName" style="width: 330px">
<a-select-option @click="universitySchoolName('请选择')" value="请选择">请选择</a-select-option> <a-select-option @click="universitySchoolName('请选择')" value="请选择">请选择</a-select-option>
<a-select-option @click="universitySchoolName(item)" v-for="item in universitySchool" :value="item.universityId"> <a-select-option @click="universitySchoolName(item)" v-for="item in universitySchool"
:value="item.universityId">
{{item.universityName}} {{item.universityName}}
</a-select-option> </a-select-option>
</a-select> </a-select>
...@@ -139,12 +140,16 @@ ...@@ -139,12 +140,16 @@
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-form-item :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}" label="产品情况:"> <a-form-item :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}" label="产品情况:">
<div v-html="productIntroduction"> <mavon-editor @save="saveProductIntroduction" ref="editor_a" v-model="productIntroduction">
</div> </mavon-editor>
</a-form-item> </a-form-item>
<a-form-item :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}" label="资费介绍:"> <a-form-item :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}" label="单宽资费介绍:">
<div v-html="productSetMealIntroduction"> <mavon-editor @save="saveProductSetMealIntroduction" ref="editor_b" v-model="productSetMealIntroduction">
</div> </mavon-editor>
</a-form-item>
<a-form-item :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}" label="融合资费介绍:">
<mavon-editor @save="saveProductRf2" ref="editor_c" v-model="productRf2">
</mavon-editor>
</a-form-item> </a-form-item>
</div> </div>
</a-form> </a-form>
...@@ -154,6 +159,8 @@ ...@@ -154,6 +159,8 @@
<script> <script>
import STable from '@/components/table'; import STable from '@/components/table';
import {mavonEditor} from "mavon-editor";
import "mavon-editor/dist/css/index.css";
import { import {
productList, productList,
productDelete, productDelete,
...@@ -166,13 +173,13 @@ ...@@ -166,13 +173,13 @@
export default { export default {
name: "product", name: "product",
components: { components: {
STable, STable, mavonEditor,
}, },
data() { data() {
return { return {
universityIdtrue: true, universityIdtrue: true,
universityName: '', universityName: '',
regularName: '', regularName: '请选择',
visibleT: false, visibleT: false,
visibleT2: false, visibleT2: false,
chouti: {}, chouti: {},
...@@ -185,6 +192,7 @@ ...@@ -185,6 +192,7 @@
add: true, add: true,
productIntroduction: "", productIntroduction: "",
productSetMealIntroduction: '', productSetMealIntroduction: '',
productRf2:'',
queryParam: { queryParam: {
productUniversity: '', //适用学校 productUniversity: '', //适用学校
productRegion: '', // 区域 productRegion: '', // 区域
...@@ -201,6 +209,9 @@ ...@@ -201,6 +209,9 @@
productRegion: '', productRegion: '',
productRate: '', productRate: '',
productId: '', productId: '',
productIntroduction:'',
productSetMealIntroduction:'',
productRf2:'',
productIntroductionPic2: '' productIntroductionPic2: ''
}, },
columns: [ columns: [
...@@ -268,6 +279,24 @@ ...@@ -268,6 +279,24 @@
} }
}, },
methods: { methods: {
saveProductIntroduction(markdown, html) {
// 此时会自动将 markdown 和 html 传递到这个方法中
console.log("markdown内容:" + markdown);
//alert("html内容:" + html);
this.productIntroduction = html;
},
saveProductSetMealIntroduction(markdown, html) {
// 此时会自动将 markdown 和 html 传递到这个方法中
console.log("markdown内容:" + markdown);
this.productSetMealIntroduction = html
//alert("html内容:" + html);
},
saveProductRf2(markdown, html) {
// 此时会自动将 markdown 和 html 传递到这个方法中
console.log("markdown内容:" + markdown);
this.productRf2 = html
//alert("html内容:" + html);
},
universitySchoolName(item) { universitySchoolName(item) {
if (item == '请选择') { if (item == '请选择') {
this.modelData.universityId = '' this.modelData.universityId = ''
...@@ -310,6 +339,7 @@ ...@@ -310,6 +339,7 @@
if (data != undefined) { if (data != undefined) {
this.productIntroduction = data.productIntroduction this.productIntroduction = data.productIntroduction
this.productSetMealIntroduction = data.productSetMealIntroduction this.productSetMealIntroduction = data.productSetMealIntroduction
this.productRf2 = data.productRf2
this.modelData.productMealPrice = data.productMealPrice this.modelData.productMealPrice = data.productMealPrice
this.modelData.productUniversity = data.productUniversity this.modelData.productUniversity = data.productUniversity
this.universityName = data.productUniversity this.universityName = data.productUniversity
...@@ -344,43 +374,49 @@ ...@@ -344,43 +374,49 @@
this.$notification.error({message: '请选择适用学校', duration: 4}) this.$notification.error({message: '请选择适用学校', duration: 4})
return return
} }
let that = this; let that = this;
that.Formtable.validateFields(['productMeal', 'productTitle', 'productPrice', 'productRegion', 'productRate', 'productState'], {force: true}, (err, values) => { that.Formtable.validateFields(
if (err) { [
return; 'productMeal', 'productTitle', 'productPrice', 'productRegion', 'productRate',
} 'productState', "productIntroduction", "productSetMealIntroduction", "productRf2"
that.modelData.productMeal = values.productMeal ], {force: true}, (err, values) => {
that.modelData.productTitle = values.productTitle if (err) {
that.modelData.productPrice = values.productPrice return;
that.modelData.productRegion = values.productRegion }
that.modelData.productRate = values.productRate that.modelData.productMeal = values.productMeal
that.modelData.productState = values.productState that.modelData.productTitle = values.productTitle
if (this.add) { that.modelData.productPrice = values.productPrice
let obj = that.modelData; that.modelData.productRegion = values.productRegion
delete obj.productId that.modelData.productRate = values.productRate
let product = JSON.stringify(obj); that.modelData.productState = values.productState
productInsert({product}).then((res) => { that.modelData.productIntroduction = this.$refs.editor_a.d_render;
this.modifyvisible = false; that.modelData.productSetMealIntroduction = this.$refs.editor_b.d_render;
this.clearmodel() that.modelData.productRf2 = this.$refs.editor_c.d_render;
if (res.state == "success") { if (this.add) {
this.$notification.success({message: res.data, description: '', duration: 4}) let obj = that.modelData;
} delete obj.productId
this.search() let product = JSON.stringify(obj);
}) productInsert({product}).then((res) => {
} else { this.modifyvisible = false;
let obj = that.modelData; this.clearmodel()
let product = JSON.stringify(obj); if (res.state == "success") {
productUpdate({product}).then((res) => { this.$notification.success({message: res.data, description: '', duration: 4})
this.modifyvisible = false; }
this.clearmodel() this.search()
if (res.state == "success") { })
this.$notification.success({message: res.data, description: '', duration: 4}) } else {
} let obj = that.modelData;
this.search() let product = JSON.stringify(obj);
}) productUpdate({product}).then((res) => {
} this.modifyvisible = false;
}) this.clearmodel()
if (res.state == "success") {
this.$notification.success({message: res.data, description: '', duration: 4})
}
this.search()
})
}
})
}, },
createfunctionCancel() { createfunctionCancel() {
this.modifyvisible = false; this.modifyvisible = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment