|
@@ -0,0 +1,163 @@
|
|
|
+<!-- eslint-disable vue/no-v-html -->
|
|
|
+<template>
|
|
|
+ <div class="imageText-preview" :style="getAreaStyle()">
|
|
|
+ <SerialNumberPosition v-if="isEnable(data.property.sn_display_mode)" :property="data.property" />
|
|
|
+
|
|
|
+ <div
|
|
|
+ class="img-box"
|
|
|
+ :style="{
|
|
|
+ background: image_url ? 'url(' + image_url + ') center / contain no-repeat' : '#DCDFE6',
|
|
|
+ width: data.image_width + 'px',
|
|
|
+ height: data.image_height + 'px',
|
|
|
+ border: '1px dotted #DCDFE6',
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ <!-- 如果是查看答案模式 v-if 下面画画的vue-esign不显示 -->
|
|
|
+ <!-- <img :src="answer.answer_list[0].answer" alt="" /> -->
|
|
|
+ <vue-esign
|
|
|
+ ref="esign-drawing"
|
|
|
+ class="esign-canvas"
|
|
|
+ :width="data.image_width"
|
|
|
+ :height="data.image_height"
|
|
|
+ :is-crop="isCrop"
|
|
|
+ :line-width="lineWidth"
|
|
|
+ :line-color="lineColor"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div class="footer">
|
|
|
+ <div class="pen">
|
|
|
+ <!-- 选择颜色 -->
|
|
|
+ <el-color-picker v-model="lineColor"></el-color-picker>
|
|
|
+ <!-- 清除一笔 -->
|
|
|
+ <!-- <img @click="removeOne" class="clean-btn" src="@/assets/drawing-back.png" /> -->
|
|
|
+ <!-- 清空画板 -->
|
|
|
+ <img @click="handleReset" class="clean-btn" src="@/assets/icon-clean.png" />
|
|
|
+ <img :src="penIndex == 0 ? thinpenActive : thinpen" @click="changePen(0)" class="pen-img" />
|
|
|
+ <img :src="penIndex == 1 ? thickpenActive : thickpen" @click="changePen(1)" class="pen-img" />
|
|
|
+ <img :src="penIndex == 2 ? thicskpenActive : thicskpen" @click="changePen(2)" class="pen-img" />
|
|
|
+ <div class="save" @click="handleGenerate">Save</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import PreviewMixin from '../common/PreviewMixin';
|
|
|
+import { getDrawingData } from '@/views/book/courseware/data/drawing';
|
|
|
+import { GetFileURLMap } from '@/api/app';
|
|
|
+import vueEsign from 'vue-esign';
|
|
|
+export default {
|
|
|
+ name: 'DrawingPreview',
|
|
|
+
|
|
|
+ components: { vueEsign },
|
|
|
+ mixins: [PreviewMixin],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ data: getDrawingData(),
|
|
|
+ penIndex: 0,
|
|
|
+ image_url: '',
|
|
|
+ lineWidth: 2,
|
|
|
+ lineColor: '#000000',
|
|
|
+ bgColor: '#f7f8fa',
|
|
|
+ isCrop: false,
|
|
|
+ weightList: [2, 4, 8],
|
|
|
+ thinpen: require('@/assets/thin-pen.png'), //细笔
|
|
|
+ thinpenActive: require('@/assets/thin-pen-active.png'),
|
|
|
+ thickpen: require('@/assets/thick-pen.png'),
|
|
|
+ thickpenActive: require('@/assets/thick-pen-active.png'),
|
|
|
+ thicskpen: require('@/assets/thicks-pen.png'),
|
|
|
+ thicskpenActive: require('@/assets/thicks-pen-active.png'),
|
|
|
+ resultImg: null,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.initData();
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.audio_width = document.getElementsByClassName('imageText-preview')[0].clientWidth - 150;
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ initData() {
|
|
|
+ if (!this.isJudgingRightWrong) {
|
|
|
+ this.answer.answer_list = [];
|
|
|
+ let obj = {
|
|
|
+ answer: '',
|
|
|
+ };
|
|
|
+ this.answer.answer_list.push(obj);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.data.image_list.forEach((item) => {
|
|
|
+ GetFileURLMap({ file_id_list: [item.file_id] }).then(({ url_map }) => {
|
|
|
+ this.image_url = url_map[item.file_id];
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 保存图片
|
|
|
+ handleGenerate() {
|
|
|
+ console.log(this.$refs['esign-drawing']);
|
|
|
+ this.$refs['esign-drawing']
|
|
|
+ .generate()
|
|
|
+ .then((res) => {
|
|
|
+ this.resultImg = res;
|
|
|
+ this.answer.answer_list[0].answer = res;
|
|
|
+ this.$message.success('保存成功');
|
|
|
+ })
|
|
|
+ .catch((err) => {});
|
|
|
+ },
|
|
|
+ changePen(index) {
|
|
|
+ this.penIndex = index;
|
|
|
+ this.lineWidth = this.weightList[this.penIndex];
|
|
|
+ },
|
|
|
+ handleReset() {
|
|
|
+ this.$refs['esign-drawing'].reset(false);
|
|
|
+ },
|
|
|
+ // 删除最后一笔
|
|
|
+ removeOne() {
|
|
|
+ console.log(this.$refs['esign-drawing']);
|
|
|
+ // this.$refs['esign-drawing'].removelastOne();
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+@use '@/styles/mixin.scss' as *;
|
|
|
+
|
|
|
+.img-box {
|
|
|
+ position: relative;
|
|
|
+ margin: 20px auto;
|
|
|
+}
|
|
|
+
|
|
|
+.pen {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: flex-end;
|
|
|
+
|
|
|
+ .save {
|
|
|
+ box-sizing: border-box;
|
|
|
+ width: 65px;
|
|
|
+ height: 32px;
|
|
|
+ margin-left: 16px;
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: 400;
|
|
|
+ line-height: 32px;
|
|
|
+ color: #000;
|
|
|
+ text-align: center;
|
|
|
+ cursor: pointer;
|
|
|
+ background: rgba(0, 0, 0, 5%);
|
|
|
+ border: 1px solid rgba(0, 0, 0, 10%);
|
|
|
+ border-radius: 6px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .save:hover {
|
|
|
+ background: rgba(0, 0, 0, 25%);
|
|
|
+ }
|
|
|
+
|
|
|
+ > img {
|
|
|
+ width: 24px;
|
|
|
+ height: 24px;
|
|
|
+ margin: 0 8px;
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|