|
@@ -8,7 +8,7 @@
|
|
|
@close="cancel">
|
|
|
<div class="form-dialog-box" v-loading="loading" :element-loading-text="loadingText"
|
|
|
element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0)">
|
|
|
- <div class="form-make" :style="{ '--crad-zm': form.mainBg ? `url(${form.mainBg})`:none }">
|
|
|
+ <div class="form-make" :style="{ '--crad-zm': form.mainBg ? `url(${form.mainBg})`:'none' }">
|
|
|
<div class="form-make_zm">
|
|
|
<div class="form-make_zm-title">正面</div>
|
|
|
<div class="form-make_zm-info">
|
|
@@ -30,12 +30,55 @@
|
|
|
>
|
|
|
<el-button size="small" type="primary">上传底图</el-button>
|
|
|
</el-upload>
|
|
|
- <el-button style="margin-left: 10px;" size="small" type="primary" @click="addText('zm')">添加文本</el-button>
|
|
|
- <el-button size="small" type="primary" @click="addImage('zm')">添加图片</el-button>
|
|
|
- <el-button size="small" type="primary" @click="addQR('zm')">添加二维</el-button>
|
|
|
+ <el-button style="margin-left: 10px;" size="small" type="primary" @click="centerDialogVisibleOpen('addText','zm')">添加文本</el-button>
|
|
|
+ <!-- <el-button size="small" type="primary" @click="centerDialogVisibleOpen('addImage','zm')">添加图片</el-button> -->
|
|
|
+ <el-button size="small" type="primary" @click="centerDialogVisibleOpen('addQR','zm')">添加二维</el-button>
|
|
|
</div>
|
|
|
<!-- 样式 -->
|
|
|
<div class="form-make_zm-style">
|
|
|
+ <div class="form-make_zm-style-bgm"></div>
|
|
|
+ <div ref="styleInfo" id="styleInfo" class="form-make_zm-style-info">
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div style="padding: 20px;">
|
|
|
+ <span>编辑</span>
|
|
|
+ <div id="styleInfo_list">
|
|
|
+ <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
|
|
|
+ <div v-if="ruleForm.type == 'text'">
|
|
|
+ <el-form-item label="文本名称" prop="textInfo">
|
|
|
+ <el-input v-model="ruleForm.textInfo"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="字体大小" prop="size">
|
|
|
+ <el-input-number v-model="ruleForm.size" controls-position="right" :min="12" :max="100"></el-input-number>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="字体颜色" prop="color">
|
|
|
+ <el-color-picker v-model="ruleForm.color"></el-color-picker>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ <div v-if="editFun == 'addQR'">
|
|
|
+ <el-form-item label="宽度" prop="width">
|
|
|
+ <el-input-number v-model="ruleForm.width" controls-position="right" :min="1"></el-input-number>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="高度" prop="height">
|
|
|
+ <el-input-number v-model="ruleForm.height" controls-position="right" :min="1"></el-input-number>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ <el-form-item label="关联字段" prop="replace">
|
|
|
+ <el-select v-model="ruleForm.replace" placeholder="请选择关联字段">
|
|
|
+ <el-option
|
|
|
+ v-for="item in dict.type.tourism_make_key"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click="updateFun('ruleForm')">更新</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -53,6 +96,51 @@
|
|
|
</el-button>
|
|
|
</span>
|
|
|
<!-- 添加或修改对话框 End -->
|
|
|
+
|
|
|
+ <el-dialog
|
|
|
+ :title="addTitle"
|
|
|
+ :visible.sync="centerDialogVisible"
|
|
|
+ width="30%"
|
|
|
+ append-to-body
|
|
|
+ center>
|
|
|
+ <div>
|
|
|
+ <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
|
|
|
+ <div v-if="editFun == 'addText'">
|
|
|
+ <el-form-item label="文本名称" prop="textInfo">
|
|
|
+ <el-input v-model="ruleForm.textInfo"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="字体大小" prop="size">
|
|
|
+ <el-input-number v-model="ruleForm.size" controls-position="right" :min="12" :max="100"></el-input-number>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="字体颜色" prop="color">
|
|
|
+ <el-color-picker v-model="ruleForm.color"></el-color-picker>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ <div v-if="editFun == 'addQR'">
|
|
|
+ <el-form-item label="宽度" prop="width">
|
|
|
+ <el-input-number v-model="ruleForm.width" controls-position="right" :min="1"></el-input-number>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="高度" prop="height">
|
|
|
+ <el-input-number v-model="ruleForm.height" controls-position="right" :min="1"></el-input-number>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ <el-form-item label="关联字段" prop="replace">
|
|
|
+ <el-select v-model="ruleForm.replace" placeholder="请选择关联字段">
|
|
|
+ <el-option
|
|
|
+ v-for="item in dict.type.tourism_make_key"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="centerDialogVisible = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="centerDialogVisiblePush">确 定</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
</el-dialog>
|
|
|
</template>
|
|
|
|
|
@@ -65,6 +153,7 @@ import {
|
|
|
|
|
|
export default {
|
|
|
name: "addAndEdit",
|
|
|
+ dicts: ['tourism_make_key'],
|
|
|
data() {
|
|
|
return {
|
|
|
title: "",
|
|
@@ -84,10 +173,27 @@ export default {
|
|
|
mainBg: null,
|
|
|
backBg: null,
|
|
|
},
|
|
|
- rules: {},
|
|
|
// 上传文件
|
|
|
actionUrl: process.env.VUE_APP_BASE_API + process.env.VUE_APP_UPLOAD_IMAGE,
|
|
|
actionUrlLoading: false,
|
|
|
+
|
|
|
+ addTitle: '添加文本',
|
|
|
+ centerDialogVisible: false,
|
|
|
+ ruleForm: {},
|
|
|
+ rules: {
|
|
|
+ textInfo: [
|
|
|
+ { required: true, message: '请输入文本内容', trigger: ['blur', 'change'] },
|
|
|
+ ],
|
|
|
+ size: [
|
|
|
+ { required: true, message: '请输入字体大小', trigger: ['blur', 'change'] },
|
|
|
+ ],
|
|
|
+ color: [
|
|
|
+ { required: true, message: '请输入字体颜色', trigger: ['blur', 'change'] },
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ editType: '',
|
|
|
+ editFun: '',
|
|
|
+
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
@@ -231,13 +337,104 @@ export default {
|
|
|
},
|
|
|
|
|
|
addText(type){
|
|
|
-
|
|
|
+ let div = document.createElement('div')
|
|
|
+ div.setAttribute('class', 'form-make_zm-style-item');
|
|
|
+ div.setAttribute('id', 'text_'+ Number((new Date()).getTime()));
|
|
|
+ div.setAttribute('replace', 'text_'+ this.ruleForm.replace);
|
|
|
+
|
|
|
+ div.setAttribute('draggable', 'true');
|
|
|
+ div.style.color = this.ruleForm.color
|
|
|
+ div.style.fontSize = this.ruleForm.size + 'px'
|
|
|
+ div.style.backgroundColor = '#fff'
|
|
|
+ div.innerHTML = this.ruleForm.textInfo
|
|
|
+ div.addEventListener('dragend',this.dragendFun)
|
|
|
+ div.addEventListener('click',this.clickFun)
|
|
|
+ let box = document.getElementById('styleInfo')
|
|
|
+ box.appendChild(div)
|
|
|
+ this.centerDialogVisible = false
|
|
|
},
|
|
|
addImage(type){
|
|
|
|
|
|
},
|
|
|
addQR(type){
|
|
|
+ let div = document.createElement('div')
|
|
|
+ div.setAttribute('class', 'form-make_zm-style-item');
|
|
|
+ div.setAttribute('id', 'qr_'+ Number((new Date()).getTime()));
|
|
|
+ div.setAttribute('replace', 'qr_'+ this.ruleForm.replace);
|
|
|
+
|
|
|
+ div.setAttribute('draggable', 'true');
|
|
|
+ div.style.width = this.ruleForm.width + 'px'
|
|
|
+ div.style.height = this.ruleForm.height + 'px'
|
|
|
+ div.style.backgroundColor = '#fff'
|
|
|
+ div.innerHTML = "二维码位置"
|
|
|
+ div.style.color = '#000'
|
|
|
+ div.style.fontSize = '16px'
|
|
|
+ div.addEventListener('dragend',this.dragendFun)
|
|
|
+ div.addEventListener('click',this.clickFun)
|
|
|
+ let box = document.getElementById('styleInfo')
|
|
|
+
|
|
|
+ box.appendChild(div)
|
|
|
+ // let box1 = document.getElementById('styleInfo_list')
|
|
|
+ // box1.appendChild(div)
|
|
|
+ this.centerDialogVisible = false
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 拖拽事件 */
|
|
|
+ dragendFun(e){
|
|
|
+ let draggedItem = document.getElementById(e.target.id);
|
|
|
+ let dropzone = document.getElementById('styleInfo');
|
|
|
+ // 获取元素相对于父元素的位置
|
|
|
+ let rect = draggedItem.getBoundingClientRect();
|
|
|
+ let parentRect = dropzone.getBoundingClientRect();
|
|
|
+
|
|
|
+ // 计算元素在父元素中的位置
|
|
|
+ let left =e.clientX - parentRect.x;
|
|
|
+ let top =e.clientY - parentRect.y;
|
|
|
+ console.log("dragend事件====",e.clientX,e.clientY)
|
|
|
+ // 设置元素的新位置
|
|
|
+ draggedItem.style.left = left + 'px';
|
|
|
+ draggedItem.style.top = top + 'px';
|
|
|
+ },
|
|
|
+ clickFun(e) {
|
|
|
+ let draggedItem = document.getElementById(e.target.id);
|
|
|
+ let content = draggedItem.getAttribute('replace')
|
|
|
+ let info = draggedItem.innerHTML
|
|
|
+ if(content.indexOf('text_') > -1) {
|
|
|
+ this.$set(this,'ruleForm',{
|
|
|
+ id: e.target.id,
|
|
|
+ type: 'text',
|
|
|
+ textInfo: info,
|
|
|
+ size: Number(draggedItem.style.fontSize.replace('px','')),
|
|
|
+ color: draggedItem.style.color,
|
|
|
+ replace: content.replace('text_','')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if(content.indexOf('qr_') > -1) {
|
|
|
|
|
|
+ }
|
|
|
+ console.log(this.ruleForm)
|
|
|
+ },
|
|
|
+ /** */
|
|
|
+ centerDialogVisibleOpen(fun,type) {
|
|
|
+ this.editType = type
|
|
|
+ this.editFun = fun
|
|
|
+ this.centerDialogVisible = true
|
|
|
+ },
|
|
|
+ centerDialogVisiblePush() {
|
|
|
+ switch(this.editFun){
|
|
|
+ case 'addText' : this.addText(this.editType); break;
|
|
|
+ case 'addImage' : this.addImage(this.editType); break;
|
|
|
+ case 'addQR' : this.addQR(this.editType); break;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ updateFun() {
|
|
|
+ let div = document.getElementById(this.ruleForm.id)
|
|
|
+ if(this.ruleForm.type == 'text') {
|
|
|
+ div.setAttribute('replace', 'text_'+ this.ruleForm.replace);
|
|
|
+ div.style.color = this.ruleForm.color
|
|
|
+ div.style.fontSize = this.ruleForm.size
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
},
|
|
|
};
|
|
@@ -439,9 +636,28 @@ export default {
|
|
|
height: var(--crad-h);
|
|
|
border: 1px dashed #000;
|
|
|
border-radius: 20px;
|
|
|
- background-image: var(--crad-zm);
|
|
|
- background-size: 100% 100%;
|
|
|
- background-repeat: no-repeat;
|
|
|
+ box-sizing: border-box;
|
|
|
+ overflow: hidden;
|
|
|
+ position: relative;
|
|
|
+ .form-make_zm-style-bgm {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ background-image: var(--crad-zm);
|
|
|
+ background-size: 100% 100%;
|
|
|
+ background-repeat: no-repeat;
|
|
|
+ border-radius: 20px;
|
|
|
+ }
|
|
|
+ .form-make_zm-style-info {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ position: absolute;
|
|
|
+ z-index: 9;
|
|
|
+ top: 0;
|
|
|
+ left: 0;
|
|
|
+ border-radius: 20px;
|
|
|
+ box-sizing: border-box;
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -454,4 +670,17 @@ export default {
|
|
|
.custom-class-box {
|
|
|
z-index: 999999 !important;
|
|
|
}
|
|
|
+.form-make_zm-style-item {
|
|
|
+ position: absolute;
|
|
|
+ top: 30px;
|
|
|
+ left: 30px;
|
|
|
+ color: #000;
|
|
|
+ font-size: 16px;
|
|
|
+ cursor: pointer;
|
|
|
+ white-space: nowrap;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ flex-shrink: 0;
|
|
|
+}
|
|
|
</style>
|