Commit 26e37d74 by lanyulei

feat: 增加远程调用方法。

parent f137c1d3
......@@ -2,5 +2,5 @@
ENV = 'production'
# base api
VUE_APP_BASE_API = 'http://fdevops.com:8001'
VUE_APP_BASE_API = ''
......@@ -117,7 +117,7 @@
"serve-static": "^1.13.2",
"svg-sprite-loader": "4.1.3",
"svgo": "1.2.0",
"vue-template-compiler": "^2.6.14"
"vue-template-compiler": "2.7.8"
},
"engines": {
"node": ">=8.9",
......
......@@ -184,7 +184,6 @@ import CusDialog from './CusDialog'
import GenerateForm from './GenerateForm'
import Clipboard from 'clipboard'
import { basicComponents, layoutComponents, advanceComponents } from './componentsConfig.js'
import request from '../util/request.js'
import generateCode from './generateCode.js'
var ace = require('ace-builds/src-noconflict/ace')
......@@ -258,26 +257,7 @@ export default {
jsonVisible: false,
codeVisible: false,
uploadVisible: false,
remoteFuncs: {
func_test(resolve) {
setTimeout(() => {
const options = [
{ id: '1', name: '1111' },
{ id: '2', name: '2222' },
{ id: '3', name: '3333' }
]
resolve(options)
}, 2000)
},
funcGetToken(resolve) {
request.get('http://tools-server.xiaoyaoji.cn/api/uptoken').then(res => {
resolve(res.uptoken)
})
},
upload_callback(response, file, fileList) {
}
},
remoteFuncs: {},
widgetModels: {},
blank: '',
htmlTemplate: '',
......
......@@ -10,7 +10,7 @@
:label-width="data.config.labelWidth + 'px'"
>
<template v-for="item in data.list">
<template v-if="item.type == 'grid'">
<template v-if="item.type === 'grid'">
<el-row
:key="item.key"
type="flex"
......@@ -20,7 +20,7 @@
>
<el-col v-for="(col, colIndex) in item.columns" :key="colIndex" :span="col.span">
<template v-for="citem in col.list">
<el-form-item v-if="citem.type=='blank'" :key="citem.key" :label="citem.name" :prop="citem.model">
<el-form-item v-if="citem.type==='blank'" :key="citem.key" :label="citem.name" :prop="citem.model">
<slot :name="citem.model" :model="models" />
</el-form-item>
<genetate-form-item
......@@ -39,7 +39,7 @@
</el-row>
</template>
<template v-else-if="item.type == 'blank'">
<template v-else-if="item.type === 'blank'">
<el-form-item :key="item.key" :label="item.name" :prop="item.model">
<slot :name="item.model" :model="models" />
</el-form-item>
......@@ -201,7 +201,7 @@ export default {
} else {
if (genList[i].type === 'blank') {
this.$set(this.models, genList[i].model, genList[i].options.defaultType === 'String' ? '' : (genList[i].options.defaultType === 'Object' ? {} : []))
} if (genList[i].type === 'subform') {
} if (genList[i].type === 'subform') {
this.$set(this.models, genList[i].model, [])
} else {
this.models[genList[i].model] = genList[i].options.defaultValue
......
......@@ -10,7 +10,7 @@
<template v-if="widget.type === 'color'">
<div style="width: 32px; height: 20px; margin-top: 6px; border-radius: 3px" :style="{'background-color': dataModel}" />
</template>
<template v-else-if="widget.type=='switch'">
<template v-else-if="widget.type==='switch'">
<el-switch
v-model="dataModel"
:disabled="true"
......@@ -20,14 +20,14 @@
<div class="previewEditorDiv" v-html="dataModel" />
</template>
<template v-else-if="widget.type=='file'">
<template v-else-if="widget.type==='file'">
<div v-for="(uploadUrlItem, uploadUrlIndex) of dataModel" :key="uploadUrlIndex">
<i style="color: #909399;" class="el-icon-document" />
<a :href="uploadUrlItem.url" target="_blank">{{ uploadUrlItem.name }}</a>
</div>
</template>
<template v-else-if="widget.type=='imgupload'">
<template v-else-if="widget.type==='imgupload'">
<fm-upload
v-model="dataModel"
:style="{'width': widget.options.width}"
......@@ -36,7 +36,7 @@
:preview="preview"
/>
</template>
<template v-else-if="widget.type =='rate'">
<template v-else-if="widget.type ==='rate'">
<el-rate
v-model="dataModel"
:max="widget.options.max"
......@@ -71,6 +71,7 @@
:disabled="true"
:show-all-levels="widget.options.showAllLevels"
:options="widget.options.remote?widget.options.remoteOptions:widget.options.options"
:props="widget.options.props"
/>
</template>
<template v-else>
......@@ -178,7 +179,7 @@
/>
</template>
<template v-if="widget.type=='date'">
<template v-if="widget.type==='date'">
<el-date-picker
v-model="dataModel"
:type="widget.options.type"
......@@ -195,7 +196,7 @@
/>
</template>
<template v-if="widget.type =='rate'">
<template v-if="widget.type ==='rate'">
<el-rate
v-model="dataModel"
:max="widget.options.max"
......@@ -226,14 +227,14 @@
</el-select>
</template>
<template v-if="widget.type=='switch'">
<template v-if="widget.type==='switch'">
<el-switch
v-model="dataModel"
:disabled="widget.options.disabled"
/>
</template>
<template v-if="widget.type=='slider'">
<template v-if="widget.type==='slider'">
<el-slider
v-model="dataModel"
:min="widget.options.min"
......@@ -246,7 +247,7 @@
/>
</template>
<template v-if="widget.type=='imgupload'">
<template v-if="widget.type==='imgupload'">
<fm-upload
v-model="dataModel"
:disabled="widget.options.disabled"
......@@ -265,7 +266,7 @@
/>
</template>
<template v-if="widget.type=='file'">
<template v-if="widget.type==='file'">
<FileUpload :element="widget" :data-model="dataModel" @fileList="fileList" />
</template>
......@@ -286,6 +287,7 @@
:placeholder="widget.options.placeholder"
:style="{width: widget.options.width}"
:options="widget.options.remote?widget.options.remoteOptions:widget.options.options"
:props="widget.options.props"
/>
</template>
......@@ -385,15 +387,24 @@ export default {
}
},
created() {
if (this.widget.options.remote && this.remote[this.widget.options.remoteFunc]) {
this.remote[this.widget.options.remoteFunc]((data) => {
this.widget.options.remoteOptions = data.map(item => {
return {
value: item[this.widget.options.props.value],
label: item[this.widget.options.props.label],
children: item[this.widget.options.props.children]
if (this.widget.type !== 'cascader') {
if (this.widget.options.remote && this.remote[this.widget.options.remoteFunc]) {
this.remote[this.widget.options.remoteFunc]((data) => {
if (this.widget.type !== 'cascader') {
this.widget.options.remoteOptions = data.map(item => {
return {
value: item[this.widget.options.props.value],
label: item[this.widget.options.props.label],
children: item[this.widget.options.props.children]
}
})
}
})
}
} else {
this.remote[this.widget.options.remoteFunc](res=>{
this.widget.options.remoteOptions = res
this.cascaderChild(this.widget.options.remoteOptions)
})
}
......@@ -419,6 +430,15 @@ export default {
this.handleDisplayVerifiy()
},
methods: {
cascaderChild(options) {
options.forEach(i => {
if (i.children && i.children.length > 0) {
this.cascaderChild(i.children)
} else {
i.children = null
}
})
},
fileList(files) {
this.dataModel = files
},
......
......@@ -2,7 +2,7 @@
<div v-if="show">
<el-form label-position="top">
<!-- 字段标识 -->
<el-form-item v-if="data.type!='grid'" :label="$t('fm.config.widget.model')">
<el-form-item v-if="data.type!=='grid'" :label="$t('fm.config.widget.model')">
<el-input v-model="data.model" />
</el-form-item>
<!-- 标题 -->
......@@ -126,7 +126,7 @@
</div>
</template>
<template v-else>
<template v-if="data.type=='radio' || (data.type=='select'&&!data.options.multiple)">
<template v-if="data.type==='radio' || (data.type==='select'&&!data.options.multiple)">
<el-radio-group v-model="data.options.defaultValue">
<draggable
tag="ul"
......
<template>
<div>
<template v-if="element.type == 'input'">
<template v-if="element.type === 'input'">
<el-input
v-model="element.options.defaultValue"
:style="{width: element.options.width}"
......@@ -9,7 +9,7 @@
/>
</template>
<template v-if="element.type == 'textarea'">
<template v-if="element.type === 'textarea'">
<el-input
v-model="element.options.defaultValue"
type="textarea"
......@@ -20,7 +20,7 @@
/>
</template>
<template v-if="element.type == 'number'">
<template v-if="element.type === 'number'">
<el-input-number
v-model="element.options.defaultValue"
:disabled="element.options.disabled"
......@@ -29,7 +29,7 @@
/>
</template>
<template v-if="element.type == 'radio'">
<template v-if="element.type === 'radio'">
<el-radio-group
v-model="element.options.defaultValue"
:style="{width: element.options.width}"
......@@ -46,7 +46,7 @@
</el-radio-group>
</template>
<template v-if="element.type == 'checkbox'">
<template v-if="element.type === 'checkbox'">
<el-checkbox-group
v-model="element.options.defaultValue"
:style="{width: element.options.width}"
......@@ -63,7 +63,7 @@
</el-checkbox-group>
</template>
<template v-if="element.type == 'time'">
<template v-if="element.type === 'time'">
<el-time-picker
v-model="element.options.defaultValue"
:is-range="element.options.isRange"
......@@ -79,7 +79,7 @@
/>
</template>
<template v-if="element.type == 'date'">
<template v-if="element.type === 'date'">
<el-date-picker
v-model="element.options.defaultValue"
:type="element.options.type"
......@@ -95,7 +95,7 @@
/>
</template>
<template v-if="element.type == 'rate'">
<template v-if="element.type === 'rate'">
<el-rate
v-model="element.options.defaultValue"
:max="element.options.max"
......@@ -104,7 +104,7 @@
/>
</template>
<template v-if="element.type == 'color'">
<template v-if="element.type === 'color'">
<el-color-picker
v-model="element.options.defaultValue"
:disabled="element.options.disabled"
......@@ -112,7 +112,7 @@
/>
</template>
<template v-if="element.type == 'select'">
<template v-if="element.type === 'select'">
<el-select
v-model="element.options.defaultValue"
:disabled="element.options.disabled"
......@@ -125,14 +125,14 @@
</el-select>
</template>
<template v-if="element.type=='switch'">
<template v-if="element.type==='switch'">
<el-switch
v-model="element.options.defaultValue"
:disabled="element.options.disabled"
/>
</template>
<template v-if="element.type=='slider'">
<template v-if="element.type==='slider'">
<el-slider
v-model="element.options.defaultValue"
:min="element.options.min"
......@@ -145,7 +145,7 @@
/>
</template>
<template v-if="element.type=='imgupload'">
<template v-if="element.type==='imgupload'">
<fm-upload
v-model="element.options.defaultValue"
:disabled="element.options.disabled"
......@@ -157,11 +157,11 @@
/>
</template>
<template v-if="element.type=='file'">
<template v-if="element.type==='file'">
<FileUpload :element="element" />
</template>
<template v-if="element.type == 'cascader'">
<template v-if="element.type === 'cascader'">
<el-cascader
v-model="element.options.defaultValue"
:disabled="element.options.disabled"
......@@ -170,17 +170,18 @@
:placeholder="element.options.placeholder"
:style="{width: element.options.width}"
:options="element.options.remote?element.options.remoteOptions:element.options.options"
:props="element.options.props"
/>
</template>
<template v-if="element.type == 'editor'">
<template v-if="element.type === 'editor'">
<vue-editor
v-model="element.options.defaultValue"
:style="{width: element.options.width}"
/>
</template>
<template v-if="element.type=='blank'">
<template v-if="element.type==='blank'">
<div style="height: 50px;color: #999;background: #eee;line-height:50px;text-align:center;">{{ $t('fm.components.fields.blank') }}</div>
</template>
......@@ -222,7 +223,7 @@ import FmUpload from './Upload'
import FileUpload from './Upload/file'
export default {
name: 'WidgetFormFields',
/* eslint-disable */
/* eslint-disable */
props: ['element'],
components: {
FmUpload,
......
......@@ -74,6 +74,7 @@ import {
createWorkOrder
} from '@/api/process/work-order'
import { listUser } from '@/api/system/sysuser'
import { getDeptList } from '@/api/system/dept'
export default {
name: 'Create',
data() {
......@@ -106,13 +107,16 @@ export default {
},
remoteFunc: {
// 获取用户列表
userList(resolve) {
listUser({
async userList(resolve) {
const res = await listUser({
pageSize: 999999
}).then(response => {
const options = response.data.list
resolve(options)
})
const options = res.data.list
resolve(options)
},
async deptTreeList(resolve) {
const res = await getDeptList()
resolve(res.data)
}
}
}
......
......@@ -183,6 +183,7 @@ import {
import { listUser } from '@/api/system/sysuser'
import { mapGetters } from 'vuex'
import { getDeptList } from '@/api/system/dept'
export default {
data() {
return {
......@@ -215,13 +216,16 @@ export default {
},
remoteFunc: {
// 获取用户列表
userList(resolve) {
listUser({
async userList(resolve) {
const res = await listUser({
pageSize: 999999
}).then(response => {
const options = response.data.list
resolve(options)
})
const options = res.data.list
resolve(options)
},
async deptTreeList(resolve) {
const res = await getDeptList()
resolve(res.data)
}
}
}
......
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 sign in to comment