Browse Source

合并李文轩分支

yjf_v3
超级管理员 2 years ago
parent
commit
7fd0995638
  1. 76
      src/components/DesignForm/assembly/index.ts
  2. 2659
      src/components/DesignForm/formControlAttr.vue
  3. 5
      src/components/DesignForm/public/form/formGroup.vue
  4. 7
      src/widget/index.ts
  5. 181
      src/widget/lowcodeimage/index.vue
  6. 147
      src/widget/lowcodeimage/lowcodeImage.vue
  7. 181
      src/widget/lowcodetransfer/index.vue
  8. 394
      src/widget/lowcodetransfer/lowcodeTransfer.vue

76
src/components/DesignForm/assembly/index.ts

@ -438,6 +438,7 @@ const selectOption: any = [
component: '' // 根据template注入的组件*/ component: '' // 根据template注入的组件*/
}, },
{ {
<<<<<<< HEAD
type: 'upload', type: 'upload',
label: '图片/文件', label: '图片/文件',
icon: 'image', icon: 'image',
@ -451,6 +452,16 @@ const selectOption: any = [
labelStyle:{}, labelStyle:{},
inputStyle:{} inputStyle:{}
} }
=======
type: 'upload',
label: '图片/文件',
icon: 'image',
iconFont: 'fa-file-image-o',
control: {
modelValue: '' // 也可以是[{name:'',url:''}]形式
},
config: {}
>>>>>>> liwenxuan_v4
}, },
{ {
type: 'tinymce', type: 'tinymce',
@ -522,6 +533,7 @@ const selectOption: any = [
interval:2000, interval:2000,
} }
}, },
<<<<<<< HEAD
config: {}, config: {},
styles:{ styles:{
divStyle:{}, divStyle:{},
@ -529,6 +541,70 @@ const selectOption: any = [
inputStyle:{} inputStyle:{}
} }
} }
=======
config: {}
},
{
type: 'lowcodeTransfer',
label: '穿梭框',
icon: '',
iconFont: 'fa-arrows-h',
control: {
modelValue: '',
fixedOptions: [{
id: 'thefirstrootnode',
label: '根节点1',
disabled: false,
children: []
},
{
id: 'thesecondrootnode',
label: '根节点2',
disabled: false,
children: []
}]
},
config: {
transferName:'穿梭框',
transferDataSource:'固定选项',
apiUrl:'/javasys/lowCode/transfer/getOrgAndManTree',
method:'post',
}
},
{
type: 'lowcodeImage',
label: '图片',
icon: '',
iconFont: 'fa-photo',
control: {
modelValue: '',
uploadFlag:false,
imgId:'',
imgUrl: '',
link: '',
fit:1,
radius:false,
radiusNum:5,
boderAndShadow:false,
showMode:'自定义像素值',
pxWidth:448,
pxHeight:252,
widthPercent:90,
heightPercent:90,
mt:0,
mb:0,
ml:0,
mr:0,
pt:0,
pb:0,
pl:0,
pr:0,
floatFlag:false,
floatValue:'left',
},
config: {}
},
>>>>>>> liwenxuan_v4
] ]
}, },
{ {

2659
src/components/DesignForm/formControlAttr.vue

File diff suppressed because it is too large

5
src/components/DesignForm/public/form/formGroup.vue

@ -458,9 +458,14 @@ const getFormItemLableStyle = (ele: any) => {
</div> </div>
</template> </template>
<<<<<<< HEAD
<DigitPage v-else-if="element.type === 'digitpage'" :data="element" /> <DigitPage v-else-if="element.type === 'digitpage'" :data="element" />
=======
<LowcodeImage v-else-if="element.type === 'lowcodeImage'" :data="element" />
<LowcodeTransfer v-else-if="element.type === 'lowcodeTransfer'" :data="element" />
>>>>>>> liwenxuan_v4
<VideoUpAndPlay v-else-if="element.type === 'videoUpAndPlay'" :data="element" /> <VideoUpAndPlay v-else-if="element.type === 'videoUpAndPlay'" :data="element" />
<LowcodeCarsusel v-else-if="element.type === 'lowcodeCarsusel'" :data="element" /> <LowcodeCarsusel v-else-if="element.type === 'lowcodeCarsusel'" :data="element" />
<SignatureMap v-else-if="element.type === 'signaturemap'" :data="element" /> <SignatureMap v-else-if="element.type === 'signaturemap'" :data="element" />

7
src/widget/index.ts

@ -12,6 +12,8 @@ import digitPage from './digitpage/index.vue'
import signatureMap from './writingboard/index.vue' import signatureMap from './writingboard/index.vue'
import videoUpAndPlay from './videoupload/index.vue' import videoUpAndPlay from './videoupload/index.vue'
import lowcodeCarsusel from './carousel/index.vue' import lowcodeCarsusel from './carousel/index.vue'
import lowcodeTransfer from './lowcodetransfer/index.vue'
import lowcodeImage from './lowcodeimage/index.vue'
export default (app: any) => { export default (app: any) => {
@ -26,5 +28,10 @@ export default (app: any) => {
app.component('SignatureMap', signatureMap) app.component('SignatureMap', signatureMap)
app.component('VideoUpAndPlay',videoUpAndPlay) app.component('VideoUpAndPlay',videoUpAndPlay)
app.component('LowcodeCarsusel',lowcodeCarsusel) app.component('LowcodeCarsusel',lowcodeCarsusel)
<<<<<<< HEAD
=======
app.component('LowcodeTransfer',lowcodeTransfer)
app.component('LowcodeImage',lowcodeImage)
>>>>>>> liwenxuan_v4
} }

181
src/widget/lowcodeimage/index.vue

@ -0,0 +1,181 @@
<!--
@ 作者: 李文轩
@ 时间: 2024-03-14 13:49:57
@ 备注:
-->
<template>
<el-form-item
v-bind="data.item"
:prop="tProp || data.name"
:class="config.className"
:rules="itemRules as any"
:label="getLabel(data.item as FormItem)"
>
<input v-model="value" type="hidden" >
</el-form-item>
<LowcodeImage :data="props.data"></LowcodeImage>
</template>
<script lang='ts' setup>
import LowcodeImage from './lowcodeImage.vue';
import {
constControlChange,
constFormProps,
} from '@/api/DesignForm/utils'
import validate from '@/api/DesignForm/validate'
import { FormItem, FormList } from '@/api/DesignForm/types'
const props = withDefaults(
defineProps<{
data: FormList
tablekey: any
numrun?: number
modelValue?: any //
tProp?: string // form-itemprop
}>(),
{}
)
const emits = defineEmits<{
(e: 'update:modelValue', numVal: any): void
}>()
const formProps = inject(constFormProps, {}) as any
const type = computed(() => {
return formProps.value.type
})
const config = computed(() => {
return props.data.config || {}
})
const changeEvent = inject(constControlChange, '') as any
const value = computed({
get() {
if (props.tProp) {
//
return props.modelValue
} else {
return formProps.value.model[props.data.name]
}
},
set(newVal: any) {
if (props.tProp) {
emits('update:modelValue', newVal)
}
updateModel(newVal)
}
})
const updateModel = (val: any) => {
let controlAttribute = ""
if(props.data.control){
if(props.data.control.type){
controlAttribute = props.data.control.type
}
}
changeEvent &&
changeEvent({
key: props.data.name,
value: val,
data: props.data,
tProp: props.tProp,
type: props.data.type,
attribute: controlAttribute
})
}
const getLabel = (ele: FormItem) => {
const showColon = formProps.value.showColon ? ':' : ''
if (ele) {
return ele.showLabel ? '' : ele.label + showColon
} else {
return ''
}
}
// item
const itemRules = computed(() => {
let temp
const itemR: any = props.data.item?.rules || []
const customR = formatCustomRules()
// undefined
if (itemR?.length || customR?.length) {
temp = [...customR, ...itemR]
}
return temp
})
// customRulesrules
const formatCustomRules = () => {
const rulesReg: any = {}
validate &&
validate.forEach(item => {
rulesReg[item.type] = item.regExp
})
// 使provide
const temp: any = []
props.data.customRules?.forEach((item: any) => {
if (!item.message && item.type !== 'methods') {
return //
}
let obj = {}
if (item.type === 'required') {
obj = { required: true }
} else if (item.type === 'rules') {
//
obj = { pattern: item.rules }
} else if (item.type === 'methods') {
//
const methods: any = item.methods
if (methods) {
obj = { validator: inject(methods, {}) }
}
} else if (item.type) {
obj = { pattern: rulesReg[item.type as string] }
}
// push
let message: any = { message: item.message }
if (!item.message) {
// 使validatormessage使 callback(new Error('x'));
message = {}
}
temp.push(
Object.assign(
{
trigger: item.trigger || 'blur'
},
obj,
message
)
)
})
return temp
}
</script>
<style lang='scss' scoped>
.imgbox{
padding: 0 5px;
max-width: 300px;
max-height: 200px;
width: 100%;
height: 200px;
.image-slot {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
background: var(--el-fill-color-light);
color: var(--el-text-color-secondary);
font-size: 30px;
}
}
</style>

147
src/widget/lowcodeimage/lowcodeImage.vue

@ -0,0 +1,147 @@
<template>
<img referrerpolicy="no-referrer" :src="url" :style="styleObject" :fit="fit" :class="[boderAndShadowClassIsActive ? boderAndShadowClass : '', radiusClassIsActive ? radiusClass : '',mp, floatFlag ? floatStyle : '']" @click="handleLink(props.data?.control)" />
</template>
<script setup >
import errimg from '@/assets/404_images/imgNotFound.png'
const props = defineProps({
// eslint-disable-next-line vue/require-default-prop
data: {
type: Object,
}
})
/*
*/
let styleObject = {
}
let url = props.data?.control.imgUrl
if(props.data?.control.imgUrl===''){
url = errimg
}else{
url = props.data?.control.imgUrl
}
const fitNum = props.data?.control.fit
let fit= ''
switch (fitNum) {
case 1:
fit = "fill";
break;
case 2:
fit = "contain";
break;
case 3:
fit = "cover";
break;
case 4:
fit = "none";
break;
case 5:
fit = "scale-down";
break;
}
const showMode = props.data?.control.showMode
if (showMode==='自定义像素值') {
const pxWidth = props.data?.control.pxWidth
const pxHeight = props.data?.control.pxHeight
styleObject.width = pxWidth+'px';
styleObject.height = pxHeight+'px';
}else{
const widthPercent = props.data?.control.widthPercent
const heightPercent = props.data?.control.heightPercent
styleObject.width = widthPercent+'%';
styleObject.height = heightPercent+'%';
}
const radius = props.data?.control.radius
const radiusClass = ref('');
let radiusClassIsActive = false
let radiusNum = props.data?.control.radiusNum+'px'
if(radius === true ){
radiusClass.value = 'radius'
radiusClassIsActive = true
}
const mt = props.data?.control.mt+'px'
const mb = props.data?.control.mb+'px'
const ml = props.data?.control.ml+'px'
const mr = props.data?.control.mr+'px'
const pt = props.data?.control.pt+'px'
const pb = props.data?.control.pb+'px'
const pl = props.data?.control.pl+'px'
const pr = props.data?.control.pr+'px'
const mp = ref('mp')
const floatStyle = ref('floatStyle')
const floatFlag = props.data?.control.floatFlag
const floatValue = props.data?.control.floatValue
const boderAndShadowClass = ref('');
const boderAndShadow = props.data?.control.boderAndShadow
let boderAndShadowClassIsActive = false
if(boderAndShadow === true ){
boderAndShadowClass.value = 'boderAndShadow'
boderAndShadowClassIsActive = true
}
function handleLink(item){
console.log("handleLink")
let url = "";
let urlStart = 'http://'
// http:// 7
//https:// 8
if (item.link.length < 7) {
if (item.link == '') {
alert("未配置跳转地址")
return
}
url = urlStart + "" + item.link
} else {
const linkStartComplete1 = item.link.startsWith("http://")
const linkStartComplete2 = item.link.startsWith("https://")
if (linkStartComplete1 || linkStartComplete2) {
url = item.link
} else {
url = urlStart + "" + item.link
}
}
window.open(url, '_blank')
}
</script>
<style>
.boderAndShadow {
box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
}
.radius {
border-radius: v-bind(radiusNum);
}
.mp {
margin-top: v-bind(mt);
margin-bottom: v-bind(mb);
margin-left:v-bind(ml);
margin-right:v-bind(mr);
padding-top: v-bind(pt);
padding-bottom: v-bind(pb);
padding-left: v-bind(pl);
padding-right: v-bind(pr);
}
.floatStyle {
float: v-bind(floatValue);
}
</style>

181
src/widget/lowcodetransfer/index.vue

@ -0,0 +1,181 @@
<!--
@ 作者: 李文轩
@ 时间: 2024-02-07 13:49:57
@ 备注:
-->
<template>
<el-form-item
v-bind="data.item"
:prop="tProp || data.name"
:class="config.className"
:rules="itemRules as any"
:label="getLabel(data.item as FormItem)"
>
<input v-model="value" type="hidden" >
</el-form-item>
<LowcodeTransfer :data="props.data"></LowcodeTransfer>
</template>
<script lang='ts' setup>
import LowcodeTransfer from './lowcodeTransfer.vue';
import {
constControlChange,
constFormProps,
} from '@/api/DesignForm/utils'
import validate from '@/api/DesignForm/validate'
import { FormItem, FormList } from '@/api/DesignForm/types'
const props = withDefaults(
defineProps<{
data: FormList
tablekey: any
numrun?: number
modelValue?: any //
tProp?: string // form-itemprop
}>(),
{}
)
const emits = defineEmits<{
(e: 'update:modelValue', numVal: any): void
}>()
const formProps = inject(constFormProps, {}) as any
const type = computed(() => {
return formProps.value.type
})
const config = computed(() => {
return props.data.config || {}
})
const changeEvent = inject(constControlChange, '') as any
const value = computed({
get() {
if (props.tProp) {
//
return props.modelValue
} else {
return formProps.value.model[props.data.name]
}
},
set(newVal: any) {
if (props.tProp) {
emits('update:modelValue', newVal)
}
updateModel(newVal)
}
})
const updateModel = (val: any) => {
let controlAttribute = ""
if(props.data.control){
if(props.data.control.type){
controlAttribute = props.data.control.type
}
}
changeEvent &&
changeEvent({
key: props.data.name,
value: val,
data: props.data,
tProp: props.tProp,
type: props.data.type,
attribute: controlAttribute
})
}
const getLabel = (ele: FormItem) => {
const showColon = formProps.value.showColon ? ':' : ''
if (ele) {
return ele.showLabel ? '' : ele.label + showColon
} else {
return ''
}
}
// item
const itemRules = computed(() => {
let temp
const itemR: any = props.data.item?.rules || []
const customR = formatCustomRules()
// undefined
if (itemR?.length || customR?.length) {
temp = [...customR, ...itemR]
}
return temp
})
// customRulesrules
const formatCustomRules = () => {
const rulesReg: any = {}
validate &&
validate.forEach(item => {
rulesReg[item.type] = item.regExp
})
// 使provide
const temp: any = []
props.data.customRules?.forEach((item: any) => {
if (!item.message && item.type !== 'methods') {
return //
}
let obj = {}
if (item.type === 'required') {
obj = { required: true }
} else if (item.type === 'rules') {
//
obj = { pattern: item.rules }
} else if (item.type === 'methods') {
//
const methods: any = item.methods
if (methods) {
obj = { validator: inject(methods, {}) }
}
} else if (item.type) {
obj = { pattern: rulesReg[item.type as string] }
}
// push
let message: any = { message: item.message }
if (!item.message) {
// 使validatormessage使 callback(new Error('x'));
message = {}
}
temp.push(
Object.assign(
{
trigger: item.trigger || 'blur'
},
obj,
message
)
)
})
return temp
}
</script>
<style lang='scss' scoped>
.imgbox{
padding: 0 5px;
max-width: 300px;
max-height: 200px;
width: 100%;
height: 200px;
.image-slot {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
background: var(--el-fill-color-light);
color: var(--el-text-color-secondary);
font-size: 30px;
}
}
</style>

394
src/widget/lowcodetransfer/lowcodeTransfer.vue

@ -0,0 +1,394 @@
<template>
<div v-if="dataFinished" class="transfer">
<div class="leftArea">
<div class="transferName">{{ transferConfig.transferName }}</div>
<div style="padding-left: 15px; padding-right: 25px;margin-top: 10px;margin-bottom: 8px;">
<ElInput v-model="keyword" placeholder="搜索">
<template #prefix>
<ElIcon class="el-input__icon">
<Search />
</ElIcon>
</template>
</ElInput>
</div>
<div class="leftScroll">
<ElScrollbar height="100%">
<ElTree
ref="treeRef" node-key="id" empty-text="暂无数据" :data="userList" :props="treeProps" show-checkbox
highlight-current :default-expand-all="isExpandAll" :filter-node-method="filterNode"
@check="handleCheckList" @check-change="getCheckedList" />
</ElScrollbar>
</div>
</div>
<div class="rigthArea">
<div style="margin-bottom: 8px;">
<div class="transferName"><span>已选: {{ checkList.length }}</span><ElButton link style="float: right;margin-right: 5px;" @click="clearCheckList" >清空</ElButton></div>
</div>
<ElScrollbar height="calc(100% - 50px)">
<ElTag v-for="user in checkList" :key="user.id" style="display: block; font-size: 13px; letter-spacing: 1.5px;text-align: center;margin-top: 8px;height: 30px;width: 75%;margin-left:40px;padding-top: 6px;" closable @close="handleCloseTag(user)">
{{
user.label
}}[{{
user.parent.data.label
}}]
</ElTag>
</ElScrollbar>
</div>
</div>
</template>
<script setup name="MultiTreeSelector">
import { ref, watch, onMounted } from 'vue'
import request from '@/utils/request';
const props = defineProps({
// eslint-disable-next-line vue/require-default-prop
data: {
type: Object,
}
})
const fixedOptions = props.data?.control.fixedOptions
const transferConfig = props.data?.config
const treeProps = {
value: 'id',
label: 'label',
disabled: 'disabled',
children: 'children'
}
let dataFinished = false
const treeRef = ref()
const isExpandAll = ref(true) //
const keyword = ref('') //
const checkList = ref([]) // list
const userList = ref([])
let checkedIdList = ["302697","ceshi","301625"];
checkedIdList = [];
const url = transferConfig.apiUrl;/* '/javasys/lowCode/transfer/getOrgAndManTree' */
function getDetail() {
//console.log(11111)
if(transferConfig.transferDataSource==="数据源"){
return request({
url: url,
method: transferConfig.method,
});
}
}
if(transferConfig.transferDataSource==="数据源"){
getDetail().then(({ data }) => {
//console.log(`穿`);
let resData = ref(data.children)
// 2: node
userList.value = [{
id: '全选',
label: '全选',
children: [...resData.value]
}]
treeRef.value.setCheckedKeys(checkedIdList,true)
setTimeout(() => {
checkedIdList.forEach(element => {
const _node = treeRef?.value?.getNode(element)
if (!_node) return
const _checkList = checkList.value
if (_node.checked) { //
if (_node.checked && _node.childNodes.length === 0) {
_checkList.push(_node)
}
// new Set()
checkList.value = Array.from(new Set(_checkList))
// ,,
if (_node.childNodes.length > 0) {
_node.childNodes.map(item => handleCheckList(item.data))
}
} else if (!_node.checked) { //
checkList.value = checkList.value.filter(item => item.checked)
}
});
}, 50);
});
}
const getCheckedList = () => {
checkedIdList = treeRef.value.getCheckedKeys(true)
}
let resData1 = ref([
{
id: '3',
label: '营销部',
children: [
{
id: '3-1',
label: '威震天'
},
{
id: '3-2',
label: '嫦娥'
}
]
},
{
id: '2',
label: '业务部',
children: [
{
id: '2-1-1',
label: '业务部子部1',
children: [
{
id: '2-1-0001',
label: '李白'
},
{
id: '2-1-0002',
label: '萧峰'
}
]
},
{
id: '2-2-1',
label: '业务部子部2',
children: [
{
id: '2-2-00006',
label: '武则天'
},
{
id: '2-2-00005',
label: '拿破仑'
}
]
}
]
},
{
id: '4',
label: '软件开发部',
children: [
{
id: '5-3',
label: '张辽'
},
{
id: '5-9',
label: '吕布'
},
{
id: '5-0',
label: '许褚'
},
]
}
])
//
const handleCheckList = (val) => {
const valId = val.id;
const _node = treeRef?.value?.getNode(valId)
if (!_node) return
const _checkList = checkList.value
if (_node.checked) { //
if (_node.checked && _node.childNodes.length === 0) {
_checkList.push(_node)
}
// new Set()
checkList.value = Array.from(new Set(_checkList))
// ,,
if (_node.childNodes.length > 0) {
_node.childNodes.map(item => handleCheckList(item.data))
}
} else if (!_node.checked) { //
checkList.value = checkList.value.filter(item => item.checked)
}
}
/*
* @node 当前节点
* @result 存结果的数组
* @key
* */
const getParentNode = (node, result, key) => {
let isPass = node?.data?.label?.indexOf(key) !== -1
isPass ? result.push(isPass) : ''
if (!isPass && node.level !== 1 && node.parent) {
return getParentNode(node.parent, result, key)
}
}
/*
* @value 过滤的关键字
* @data 被过滤的tree
* @node
* */
const filterNode = (value, data, node) => {
if (!value) {
data.disabled = false
return true
} else {
//,
// array.map(k => (!k.disabled) && (_childArr.push(k)))
(data.children) && (data.disabled = true)
}
let _arr = []
getParentNode(node, _arr, value)
let result = false
_arr.forEach(item => {
result = result || item
})
return result
}
// tag
const handleCloseTag = (tag) => {
if (!treeRef?.value) return
checkList.value = checkList.value.filter(item => {
treeRef.value.setChecked(tag, false)
if (!item?.data) return
return item.data.id !== tag.data.id
})
}
// CheckList
const clearCheckList = () => {
if (!treeRef?.value) return
treeRef.value.setCheckedKeys([])
while (checkList.value.length > 0) {
checkList.value.pop()
}
}
// /
const handleCheckAll = (array) => {
treeRef.value.setCheckedNodes(array)
array.map(item => {
handleCheckList(item)
})
}
// /
const expandAll = () => {
const nodesMap = treeRef.value.store.nodesMap
for (let key in nodesMap) {
nodesMap[key].expanded = isExpandAll.value
}
}
// tree
watch(keyword, (newVal) => {
treeRef.value.filter(newVal)
})
//
if(transferConfig.transferDataSource==="固定选项"){
setTimeout(() => {
// 2: node
userList.value = [{
id: '全选',
label: '全选',
children: fixedOptions
}]
//console.log(treeRef)
treeRef.value.setCheckedKeys(checkedIdList,true)
setTimeout(() => {
checkedIdList.forEach(element => {
const _node = treeRef?.value?.getNode(element)
if (!_node) return
const _checkList = checkList.value
if (_node.checked) { //
if (_node.checked && _node.childNodes.length === 0) {
_checkList.push(_node)
}
// new Set()
checkList.value = Array.from(new Set(_checkList))
// ,,
if (_node.childNodes.length > 0) {
_node.childNodes.map(item => handleCheckList(item.data))
}
} else if (!_node.checked) { //
checkList.value = checkList.value.filter(item => item.checked)
}
});
}, 50);
}, 50);
dataFinished = true
}else{
getDetail
dataFinished = true
}
onMounted(() => {
})
</script>
<style scoped>
.transfer {
display: flex;
}
.transferName {
height: 30px;
padding-top: 8px;
background-color: #F5F7FA;
padding-left: 10px;
border-radius: 5px 5px 0 0;
border-bottom: 1px solid gainsboro;
}
.buttonArea {
display: flex;
flex-direction: row;
align-items: center;
}
.buttonArea2 {
height: 33px;
}
.leftScroll {
height: 367px;
}
.leftArea {
border: 1px solid gainsboro;
width: 300px;
border-radius: 5px;
height: 456px;
position: relative;
background-color: white;
}
.rigthArea {
border: 1px solid gainsboro;
width: 300px;
border-radius: 5px;
height: 456px;
background-color: white;
}</style>
Loading…
Cancel
Save