Commit 58c907e7 authored by 何虹's avatar 何虹 💬

测试

parent 7c12db40
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
<div style="width:500px"> <div style="width:500px">
<hsSelectPlus <hsSelectPlus
ref='select' ref='select'
v-model="selectValue"
:allSourceData='allSourceData' :allSourceData='allSourceData'
:requestMethod='requestMethod'
></hsSelectPlus> ></hsSelectPlus>
<el-button @click="change1">change1</el-button> <el-button @click="change1">change1</el-button>
<el-button @click="change2">change2</el-button> <el-button @click="change2">change2</el-button>
...@@ -10,33 +12,37 @@ ...@@ -10,33 +12,37 @@
</template> </template>
<script> <script>
import uc from "./apiUc";
export default { export default {
mixins: [uc],
data() { data() {
return { return {
selectValue: "1052069380861628416",
allSourceData: { allSourceData: {
config: { config: {
url: "", url: "",
proxyTag: "commonUtilAPI", isInnerRequest: true,
ref: { proxyTag: "commonUtilAPI",
const_id: "0", ref: {
table_name: "im_store_group", const_id: "0",
columns: "id,name", table_name: "im_store_group",
remote_condition: "", columns: "id,name",
displayfield: "", remote_condition: "",
writebackfield: [] displayfield: "",
writebackfield: []
},
dyncQueryParms: {},
multiple: false,
disabled: false,
size: "mini",
clearable: true,
title: "标题",
placeholder: "请选择",
value: "id",
label: "name",
is_computed: false
}, },
dyncQueryParms: {}, sourceData: [],
multiple: false,
disabled: false,
size: "mini",
clearable: true,
title: "标题",
placeholder: "请选择",
value: "id",
label: "name",
is_computed: false
},
sourceData: []
}, },
show: false, show: false,
config: { config: {
...@@ -63,24 +69,13 @@ export default { ...@@ -63,24 +69,13 @@ export default {
} }
}; };
}, },
mounted() {
this.init();
},
methods: { methods: {
change1(){ change1() {
this.allSourceData.sourceData=[{value:1,label:2}] this.allSourceData.sourceData = [{ value: 1, label: 2 }];
},
change2(){
this.allSourceData.sourceData=[{value:2,label:3}]
}, },
init() { change2() {
// this.getData(); this.allSourceData.sourceData = [{ value: 2, label: 3 }];
}, },
async getData() {
const data = await this.get_options(this.config);
//this.allSourceData.config=this.config
this.allSourceData.sourceData=data
}
} }
}; };
</script> </script>
\ No newline at end of file
import axios from 'axios'
import _ from 'lodash'
export default {
data () {
return {
config: {
'url': '',
'ref': {
const_id: '0',
table_name: '',
columns: '',
remote_condition: '',
displayfield: '',
writebackfield: []
},
dyncQueryParms: {},
multiple: false,
disabled: false,
size: 'mini',
clearable: true,
title: '',
placeholder: '',
value: '',
label: '',
is_computed: false
}
}
},
methods: {
async requestMethod (config, value) {
const { ref, proxyTag, dyncQueryParms } = config || {}
const { const_id, table_name, columns, remote_condition } = ref || {}
const url_dynamic = `${proxyTag}/ref/table`
const url_static = `${proxyTag}/ref/items`
let real_url = ''
const url = ''
let remote_condition_ = remote_condition.trim()
let parms = ''
const dyncQueryParms_=_.cloneDeep(dyncQueryParms||{})
if (value) {
dyncQueryParms_[remote_condition_] = value.trim()
}
for (const key in dyncQueryParms_) {
if (key === remote_condition) {
parms += `&${key}=${encodeURIComponent('%' + dyncQueryParms_[key] + '%')}`
} else {
parms += `&${key}=${encodeURIComponent(dyncQueryParms_[key])}`
}
}
if (const_id !== '0' && Number(const_id)) {
// 常量id
real_url = `${url_static}/${const_id}/`
} else if (table_name) {// 表名字段名
// 字段查询
real_url = `${url_dynamic}/${table_name}/${columns}/`
} else if (url) {
real_url = url
}
if (real_url.includes('?')) {
real_url += parms
} else {
real_url += '?' + parms
}
if (!real_url) return []
const type = typeof value
if (type === 'undefined' && remote_condition) {// 远程搜索的时候
return []
} else {
const res = await axios.get(real_url)
const options = Array.isArray(res.data)
? this.tansLate(res.data, config)
: this.translate_json(res.data)
return options
}
},
tansLate (data, config) {
const arr = data
const list = []
const { value, label } = config
arr.forEach(element => {
const parm = {}
for (const pro in element) {
if (pro === value && value === label) {
parm.value = element[pro]
parm.label = element[pro]
} else if (pro === value) {
parm.value = element[pro]
} else if (pro === label) {
parm.label = element[label]
}
parm[pro] = element[pro]
}
list.push(parm)
})
return list
},
},
}
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
:readonly='disabled' :readonly='disabled'
:prop='item.prop' :prop='item.prop'
:containerType='type' :containerType='type'
:remoteMethod='item.remoteMethod' :requestMethod='item.requestMethod'
> >
</hsSelectPlus> </hsSelectPlus>
</template> </template>
......
...@@ -94,9 +94,8 @@ export default { ...@@ -94,9 +94,8 @@ export default {
dialogIframe dialogIframe
}, },
props: { props: {
remoteMethod: { requestMethod:{
type: Function, type: Function
default() {}
}, },
containerType: {}, containerType: {},
elInfo: { elInfo: {
...@@ -249,6 +248,7 @@ export default { ...@@ -249,6 +248,7 @@ export default {
// } // }
this.initData(newVal); this.initData(newVal);
this.initValue(this.value); this.initValue(this.value);
this.clientData();
}, },
deep: true deep: true
} }
...@@ -262,9 +262,20 @@ export default { ...@@ -262,9 +262,20 @@ export default {
this.title = this.elInfo.title; this.title = this.elInfo.title;
this.initData(this.allSourceData); this.initData(this.allSourceData);
this.initValue(this.value); this.initValue(this.value);
this.clientData();
}); });
}, },
methods: { methods: {
async clientData() {
const { config, sourceData } = this.allSourceData;
if (config && Object.keys(config).length > 0) {
const isInnerRequest = config.isInnerRequest;
if (isInnerRequest) {
const datas = await this.requestMethod(config);
this.options = datas || [];
}
}
},
closeDialog() { closeDialog() {
this.dialogIframeVisible = false; this.dialogIframeVisible = false;
}, },
...@@ -354,6 +365,7 @@ export default { ...@@ -354,6 +365,7 @@ export default {
if (this.configData.ref) { if (this.configData.ref) {
this.configData.remote = !!this.configData.ref.remote_condition; this.configData.remote = !!this.configData.ref.remote_condition;
this.configData.filterable = !!this.configData.ref.remote_condition; this.configData.filterable = !!this.configData.ref.remote_condition;
debugger
} }
const linkBtnUi = this.configData.linkBtnUi; const linkBtnUi = this.configData.linkBtnUi;
this.linkBtnUiVis = !!linkBtnUi; this.linkBtnUiVis = !!linkBtnUi;
...@@ -466,7 +478,7 @@ export default { ...@@ -466,7 +478,7 @@ export default {
// 节流 // 节流
remoteMethodsDebounce: _.debounce(async function(query) { remoteMethodsDebounce: _.debounce(async function(query) {
if (this.is_mock) return; if (this.is_mock) return;
const data = await this.remoteMethod(query, this.configData); const data = await this.requestMethod(this.configData, query);
this.options = this.tansLate(data || []); this.options = this.tansLate(data || []);
}, 1000), }, 1000),
async remoteMethod_(query) { async remoteMethod_(query) {
......
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
:elInfo='item.elInfo' :elInfo='item.elInfo'
:writeBackObject='formParms' :writeBackObject='formParms'
:readonly='disabled' :readonly='disabled'
:remoteMethod='remoteMethod' :requestMethod='item.requestMethod'
> >
</hsSelectPlus> </hsSelectPlus>
</template> </template>
...@@ -105,7 +105,6 @@ ...@@ -105,7 +105,6 @@
export default { export default {
name: 'dyncFormItemComponentChild_', name: 'dyncFormItemComponentChild_',
props: { props: {
remoteMethod: {},
item: {}, item: {},
formParms: {}, formParms: {},
jsoneditorOpenAfter: { jsoneditorOpenAfter: {
......
...@@ -93,7 +93,6 @@ ...@@ -93,7 +93,6 @@
<template v-else> <template v-else>
<!-- <span @click="cellClickItem(scope.row[column.prop],column.action)">{{scope.row[column.prop]}}</span> --> <!-- <span @click="cellClickItem(scope.row[column.prop],column.action)">{{scope.row[column.prop]}}</span> -->
<childItem <childItem
:remoteMethod="remoteMethod"
v-if="jumpItem(column.prop)" v-if="jumpItem(column.prop)"
:item='jumpItem(column.prop)' :item='jumpItem(column.prop)'
:prop="column.prop" :prop="column.prop"
...@@ -246,7 +245,6 @@ export default { ...@@ -246,7 +245,6 @@ export default {
}, },
name: 'hsTable', name: 'hsTable',
props: { props: {
remoteMethod: {},
importInfo: {// 导入信息 importInfo: {// 导入信息
type: Array, type: Array,
default() { default() {
......
const path = require('path') const path = require('path')
let api = '47.110.145.204:59168' // 代理服务器地址
const mainAPI = `http://${api}/Tool/api/`
const mockAPI = 'http://47.110.145.204:8082/mock/203'
const authAPI = `http://${api}/HSRight/api/`
const menuAPI = 'http://localhost:3000'
const GQLAPI = `http://${api}/GQL/api/`
const toolAPI = `http://${api}/Tool/api/`
const commonUtilAPI=`http://${api}/CommonUtil/api/`
const ipCommonAPI=`http://${api}/`
const fileresourceAPI=`http://${api}/fileresource/api/`
module.exports = { module.exports = {
// 部署应用包时的基本 URL,用法和 webpack 本身的 output.publicPath 一致 // 部署应用包时的基本 URL,用法和 webpack 本身的 output.publicPath 一致
publicPath: './', publicPath: './',
...@@ -58,6 +67,13 @@ module.exports = { ...@@ -58,6 +67,13 @@ module.exports = {
pathRewrite: { pathRewrite: {
'^/api': '' '^/api': ''
} }
},
'/commonUtilAPI': {
target: commonUtilAPI,
changeOrigin: true,
pathRewrite: {
'^/commonUtilAPI': ''
}
} }
}, },
before: (app) => {} before: (app) => {}
......
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