Commit 26e37d74 by lanyulei

feat: 增加远程调用方法。

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