Commit 7180ee9f by 无尘

fix: 修改自定义模板

parent b10d2954
......@@ -219,7 +219,6 @@ export default {
that.isDragging = false;
that.selectKey = '';
that.selectKey = evt.clone.dataset.name;
console.log(evt.clone.dataset)
// 判断中间是否已经添加
that.tempaletDataList.forEach(function(ele, index) {
if (ele.name == that.selectKey) {
......
......@@ -84,7 +84,7 @@ export default {
status: !!that.setData.status ? '1' : '0',
time: that.setData.time
};
postRequest('/haoban-app-daily-web/daily/get-setting', para)
postRequest('/haoban-app-daily-web/daily/create-setting', para)
.then(res => {
let resData = res.data;
if (resData.errorCode == 1) {
......@@ -112,8 +112,8 @@ export default {
.then(res => {
let resData = res.data;
if (resData.errorCode == 1) {
that.setData.status = !!resData.status ? true : false;
that.setData.time = resData.time;
that.setData.status = resData.result.status == 1 ? true : false;
that.setData.time = resData.result.time;
return;
}
errMsg.errorMsg(resData);
......@@ -130,13 +130,14 @@ export default {
brandId: function(newData, oldData) {
const that = this;
that.activeBrand = newData;
that.getData();
}
},
mounted() {
let that = this;
document.documentElement.style.backgroundColor = '#f0f2f5';
that.$emit('showTab', '22');
that.getData();
// that.getData();
},
destroyed() {
document.documentElement.style.backgroundColor = '#fff';
......
......@@ -22,7 +22,7 @@
<el-tab-pane label="系统字段" name="first">
<div class="filed-item-title">交易</div>
<ul>
<draggable id="list1" :list="tradeInfo" class="compenent" :options="leftOption" :move="onMove" @start="isDragging = true" @end="itemMoveEnd"
<draggable id="list1" :list="tradeInfo" class="compenent" :options="leftOption" :clone="cloneItem" :move="onMove" @start="isDragging = true" @end="itemMoveEnd"
><!-- @end="itemMoveEnd" -->
<li :class="['compenent-item', item.fixed == true ? 'fixed-item' : '']" :data-name="item.name" v-for="(item, index) in tradeInfo" :key="index" aria-hidden="true">
<span>{{ item.title }}</span>
......@@ -31,7 +31,7 @@
</ul>
<div class="filed-item-title">人员</div>
<ul>
<draggable id="list2" :list="personInfo" class="compenent" :options="leftOption" :move="onMove" @start="isDragging = true" @end="itemMoveEnd">
<draggable id="list2" :list="personInfo" class="compenent" :options="leftOption" :clone="cloneItem" :move="onMove" @start="isDragging = true" @end="itemMoveEnd">
<li :class="['compenent-item', item.fixed == true ? 'fixed-item' : '']" :data-name="item.name" v-for="(item, index) in personInfo" :key="index">
<span>{{ item.title }}</span>
</li>
......@@ -39,7 +39,7 @@
</ul>
<div class="filed-item-title">商品</div>
<ul>
<draggable id="list3" :list="goodsInfo" class="compenent" :options="leftOption" :move="onMove" @start="isDragging = true" @end="itemMoveEnd">
<draggable id="list3" :list="goodsInfo" class="compenent" :options="leftOption" :clone="cloneItem" :move="onMove" @start="isDragging = true" @end="itemMoveEnd">
<li :class="['compenent-item', item.fixed == true ? 'fixed-item' : '']" :data-name="item.name" v-for="(item, index) in goodsInfo" :key="index">
<span>{{ item.title }}</span>
</li>
......@@ -47,7 +47,7 @@
</ul>
<div class="filed-item-title">竞品</div>
<ul>
<draggable id="list4" :list="competeInfo" class="compenent" :options="leftOption" :move="onMove" @start="isDragging = true" @end="itemMoveEnd">
<draggable id="list4" :list="competeInfo" class="compenent" :options="leftOption" :clone="cloneItem" :move="onMove" @start="isDragging = true" @end="itemMoveEnd">
<li :class="['compenent-item', item.fixed == true ? 'fixed-item' : '']" :data-name="item.name" v-for="(item, index) in competeInfo" :key="index">
<span>{{ item.title }}</span>
</li>
......@@ -57,7 +57,7 @@
<el-tab-pane label="自定义字段" name="second">
<div class="filed-item-title"><!-- 其他信息 --></div>
<ul>
<draggable id="list5" :list="defineInfo" class="compenent" :options="leftDefineOption" :move="onChildMove" @start="isDragging = true" @end="itemMoveEnd">
<draggable id="list5" :list="defineInfo" class="compenent" :options="leftDefineOption" :clone="cloneItem" :move="onChildMove" @start="isDragging = true" @end="itemMoveEnd">
<li :class="['compenent-item', item.fixed == true ? 'fixed-item' : '', item.type == 11 ? 'block-class' : '']" :data-type="item.fieldCode" v-for="(item, index) in defineInfo" :key="index">
<span v-if="item.type == 0">{{ item.title }}</span>
<span v-if="item.type == 1">{{ item.title }}</span>
......@@ -102,7 +102,7 @@
<span v-if="item.fieldCode != 'baseInfo'" class="item-close p-item-close" @click.stop="deleteItem(item.name, item.parentCode, index, item)">
<i class="el-icon-close"></i>
</span>
<div v-if="!(!item.systemFlag && item.name == 'groupc7')">
<div v-if="!!item.systemFlag || !item.name.includes('groupc')">
<!-- 输入 -->
<input-com v-if="item.type == 1 || item.type == 2 || item.type == 3 || item.type == 10 || item.type == 9" :childItem="item"></input-com>
<!-- 选择 -->
......@@ -115,7 +115,7 @@
<block-com v-if="item.type == '11'" :childItem="item"></block-com>
</div>
<template>
<div class="block" v-if="item.name == 'groupc7'">
<div class="block" v-if="item.name.includes('groupc')">
<div class="block-head">
<div :class="['opencard-item-title', item.title.length >= 6 ? 'title-pre-wrap' : '']">{{ item.title }}</div>
</div>
......@@ -179,7 +179,7 @@
</div>
</template>
<!-- 提示 组块 日期,图片没有-->
<template v-if="currentIndex == index && !item.systemFlag && (item.name != 'groupc7' && item.type != 5 && item.type != 7)">
<template v-if="currentIndex == index && !item.systemFlag && (item.type != 11 && item.type != 5 && item.type != 7)">
<div class="edit-item test-title limit-w-340" :key="'child1' + index">
<div class="edit-item-title">提示文字最多20个字</div>
<limitInput :inputWidth="340" :limitClass="'limit-color'" :inputValue.sync="item.placeholder" :holder="''" :disflag="false" :getByType="'char'" :maxLength="20"> </limitInput>
......@@ -237,7 +237,7 @@
</div>
</template>
<!-- 验证 组块没有-->
<template v-if="currentIndex == index && item.name != 'groupc7'">
<template v-if="currentIndex == index && !item.name.includes('groupc')">
<div class="edit-item m-b-10" :key="'parent2' + index">
<div class="edit-item-title edit-title-padding">验证</div>
<el-checkbox v-model="item.isMust" @change="changeMust($event, !!item.list, item)">必填</el-checkbox>
......@@ -255,7 +255,7 @@
</div>
</template>
<!-- 记忆 组块没有-->
<template v-if="currentIndex == index && item.name != 'groupc7'">
<template v-if="currentIndex == index && !item.name.includes('groupc')">
<div class="edit-item " :key="'parent3' + index">
<div class="edit-item-title edit-title-padding">记忆</div>
<el-checkbox v-model="item.memory">是否记忆</el-checkbox>
......@@ -397,21 +397,7 @@
</div>
</div>
</div>
<div class="qr-dialog-content" style="opacity: 1;" v-show="dialogVisible">
<div class="qr-mask" @click.stop="closeDialog"></div>
<div class="qr-dialog">
<div class="qr-dialog__hd">
<strong class="qr-dialog__title">预览</strong>
<i class="el-icon-close" @click.stop="closeDialog"></i>
</div>
<div class="qr-dialog__bd">
<div id="qrcode"></div>
<div class="qr-dialog__p">请使用好办 APP 扫一扫预览</div>
</div>
<div class="qr--dialog__ft"></div>
</div>
</div>
<qrcode-dialog ref="qrcodePreview" v-model="dialogVisible"></qrcode-dialog>
<!-- <vue-gic-footer></vue-gic-footer> -->
</div>
</template>
......@@ -424,7 +410,7 @@ import selectCom from './template/select.vue';
import dateRangeCom from './template/date-range.vue';
import inputCom from './template/input.vue';
import blockCom from './template/block.vue';
import QRCode from 'qrcodejs2';
import qrcodeDialog from '@/components/app/qrcode-dialog.vue';
import showMsg from '@/common/js/showmsg';
import errMsg from '@/common/js/error';
// import strLength from '@/common/js/strlen';
......@@ -456,6 +442,7 @@ export default {
},
templateId: '', // 模板 id
oparateType: '', // 编辑: edit;复制: copy
counter: 1, // 计数器
// rightOption
selectKey: '',
// 交易信息
......@@ -511,10 +498,7 @@ export default {
name: '托管门店',
disabled: false
}
],
// 二维码
qrcodeCase: '', // 二维码实例
qrcodeNum: ''
]
};
},
methods: {
......@@ -525,6 +509,45 @@ export default {
let that = this;
that.changeRoute(`/customReport?brandId=${that.brandId}`);
},
cloneItem(original) {
let that = this;
original.cid = `c${that.counter}`;
console.log('original:', original);
if (!original.systemFlag) {
if (original.name.includes('textc')) {
original.name = `textc${that.counter}`;
}
if (original.name.includes('paragraphc')) {
original.name = `paragraphc${that.counter}`;
}
if (original.name.includes('numberc')) {
original.name = `numberc${that.counter}`;
}
if (original.name.includes('checkboxesOrRadioc')) {
original.name = `checkboxesOrRadioc${that.counter}`;
}
if (original.name.includes('datec')) {
original.name = `datec${that.counter}`;
}
if (original.name.includes('dateareac')) {
original.name = `dateareac${that.counter}`;
}
if (original.name.includes('picc')) {
original.name = `picc${that.counter}`;
}
if (original.name.includes('introductionc')) {
original.name = `introductionc${that.counter}`;
}
if (original.name.includes('pricec')) {
original.name = `pricec${that.counter}`;
}
if (original.name.includes('groupc')) {
original.name = `groupc${that.counter}`;
}
}
return original;
},
/**
* move{relatedContext, draggedContext}
*/
......@@ -582,9 +605,11 @@ export default {
}
});
}
console.log(evt,that.tempaletDataList)
that.selectKey = '';
that.tempaletDataList = JSON.parse(JSON.stringify(that.tempaletDataList));
that.$forceUpdate();
that.counter = that.counter + 1;
},
// 中间部分方法
/**
......@@ -607,7 +632,7 @@ export default {
}
// 如果是自定义的判断是不是组块
if (!item.systemFlag) {
if (item.name == 'groupc7' && !!item.children.length) {
if (item.name.includes('groupc') && !!item.children.length) {
// 设置系统的可选择
item.children.forEach(ele => {
if (!!ele.systemFlag) {
......@@ -620,13 +645,14 @@ export default {
})
}
return false;
}else {
// 删除后重新设置 fixed 值
that[pCode].forEach(function(ele, index) {
if (ele.name == key) {
ele.fixed = false;
}
});
}
// 删除后重新设置 fixed 值
that[pCode].forEach(function(ele, index) {
if (ele.name == key) {
ele.fixed = false;
}
});
},
/**
* 添加 child
......@@ -751,15 +777,16 @@ export default {
tag.filedFlag = true;
tag.filedRepeat = false;
let filedArr = [];
data.forEach(function(ele, index) {
data.forEach(function(ele) {
if (ele.title == '') {
tag.filedFlag = false;
tag.name = ele.title || '';
return false;
}
filedArr.push(ele.title);
// 判断子级
if ( ele.hasOwnProperty('children') && !!ele.children.length) {
ele.children.forEach(function(el, index) {
ele.children.forEach(function(el) {
if (!!el.systemFlag && el.title == '') {
tag.filedFlag = false;
tag.name = el.title || '';
......@@ -858,8 +885,14 @@ export default {
// 兼容老数据 把新字段复制给老字段
ele.list = ele.children;
}
});
if (!data.length) {
that.$message.error({
duration: 1000,
message: '请先配置字段'
});
return false;
}
// console.log(JSON.stringify(data))
if (opt === 'save') {
that.saveAllData(data);
......@@ -915,8 +948,9 @@ export default {
let resData = res.data;
if (resData.errorCode == 1) {
// 生成二维码需要的 url
let enterpriseId = JSON.parse(localStorage.getItem('userInfo')).enterpriseId;
let webUrl = `${window.location.origin}/office-mobile/#/staffRecordsTemplate?enterpriseId=${enterpriseId}&templateId=${resData.result}&brandId=${that.brandId}`;
that.qrcode(webUrl);
that.$refs.qrcodePreview.qrcode(webUrl);
that.dialogVisible = true;
return;
}
......@@ -931,30 +965,6 @@ export default {
},
/**
* 生成二维码
*/
qrcode(text) {
const that = this;
if (!!that.qrcodeCase) {
document.getElementById('qrcode').innerHTML = '';
that.qrcodeCase.clear(); // 先清除原有的
}
let qrObj = {
type: 'record',
data: text
};
that.qrcodeCase = new QRCode('qrcode', {
width: 210,
height: 210, // 高度
text: JSON.stringify(qrObj), // 二维码内容 //
//render: 'canvas', // 设置渲染方式(有两种方式 table和canvas,默认是canvas) //
//background: '#f0f',
//foreground: '#ff0'
correctLevel : 3
});
},
/**
* 关闭预览窗口
*/
closeDialog() {
......@@ -1019,7 +1029,7 @@ export default {
}else {
ele.systemFlag = true;
}
if (ele.name == 'groupc7') {
if (ele.name.includes('groupc')) {
ele.children = [];
}
})
......@@ -1131,15 +1141,19 @@ export default {
handleGetInfo(result) {
const that = this;
let data = JSON.parse(JSON.stringify(result));
that.setParent = [];
that.cids = []; // 设置计数器
that.setParent = [];// 设置 fixed
data.forEach(function(ele, index) {
ele.title = (ele.title).trim(); // 返回字段有空格
ele.isMust = !!ele.isMust ? true : false;
ele.memory = !!ele.memory ? true : false;
// 兼容老数据,增加字段
if (that.defineInfoFields.includes(ele.name)) {
// 自定义
ele.systemFlag = false;
ele.parentCode = 'defineInfo';
}else {
that.setParent.push(ele.name);
ele.systemFlag = true;
if (ele.classify == 1) {
ele.parentCode = 'tradeInfo';
......@@ -1160,7 +1174,7 @@ export default {
if (ele.hasOwnProperty('list') && !!ele.list && !!ele.list.length) {
ele.list.forEach(child => {
child.isMust = !!child.isMust ? true : false;
if (ele.name == 'groupc7') {
if (ele.name.includes('groupc')) {
child.title = (child.title).trim(); // 返回字段有空格
child.isMust = !!child.isMust ? true : false;
child.memory = !!child.memory ? true : false;
......@@ -1168,6 +1182,7 @@ export default {
if (that.defineInfoFields.includes(child.name)) {
child.systemFlag = false;
}else {
that.setParent.push(child.name);
child.systemFlag = true;
if (child.classify == 1) {
child.parentCode = 'tradeInfo';
......@@ -1183,41 +1198,42 @@ export default {
}
}
})
if (ele.name.includes('groupc')) {
ele.children = ele.list;
}
}
that.cids.push(Number.parseInt(ele.cid.match(/\d+/g)));
if (ele.hasOwnProperty('children')) {
ele.children.forEach(child => {
child.title = (child.title).trim(); // 返回字段有空格
child.isMust = !!child.isMust ? true : false;
child.memory = !!child.memory ? true : false;
that.cids.push(Number.parseInt(child.cid.match(/\d+/g)));
})
}
// 设置禁止拖拽
if (!!ele.systemFlag && ele.parentCode == 0) {
that.setParent.push(ele.fieldCode);
}
if (!!ele.systemFlag && ele.parentCode != 0) {
that.setList.push(ele.fieldCode);
}
});
// console.log(JSON.stringify(that.treeData(data)))
// 找出最大值,设置计数器
that.counter = Math.max(...that.cids);
// console.log(JSON.stringify(data))
that.tempaletDataList = data;
/* setTimeout(function() {
setTimeout(function() {
that.setFixed();
}, 100); */
}, 500);
},
/**
* 设置禁止拖拽
*/
setFixed() {
const that = this;
that.setParent.forEach(function(ele, index) {
that[ele].forEach(function(obj, key) {
if (that.setList.includes(obj.fieldCode)) {
obj.fixed = true;
let that = this;
let arr = ['tradeInfo','personInfo','goodsInfo','competeInfo'];
arr.forEach(el => {
that[el].forEach( ele => {
if (that.setParent.includes(ele.name)) {
ele.fixed = true;
}
});
});
})
}
},
watch: {
......@@ -1240,7 +1256,8 @@ export default {
selectCom,
dateRangeCom,
inputCom,
blockCom
blockCom,
qrcodeDialog
},
mounted() {
......
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