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

测试

parent 7c12db40
......@@ -2,7 +2,9 @@
<div style="width:500px">
<hsSelectPlus
ref='select'
v-model="selectValue"
:allSourceData='allSourceData'
:requestMethod='requestMethod'
></hsSelectPlus>
<el-button @click="change1">change1</el-button>
<el-button @click="change2">change2</el-button>
......@@ -10,33 +12,37 @@
</template>
<script>
import uc from "./apiUc";
export default {
mixins: [uc],
data() {
return {
selectValue: "1052069380861628416",
allSourceData: {
config: {
url: "",
proxyTag: "commonUtilAPI",
ref: {
const_id: "0",
table_name: "im_store_group",
columns: "id,name",
remote_condition: "",
displayfield: "",
writebackfield: []
url: "",
isInnerRequest: true,
proxyTag: "commonUtilAPI",
ref: {
const_id: "0",
table_name: "im_store_group",
columns: "id,name",
remote_condition: "",
displayfield: "",
writebackfield: []
},
dyncQueryParms: {},
multiple: false,
disabled: false,
size: "mini",
clearable: true,
title: "标题",
placeholder: "请选择",
value: "id",
label: "name",
is_computed: false
},
dyncQueryParms: {},
multiple: false,
disabled: false,
size: "mini",
clearable: true,
title: "标题",
placeholder: "请选择",
value: "id",
label: "name",
is_computed: false
},
sourceData: []
sourceData: [],
},
show: false,
config: {
......@@ -63,24 +69,13 @@ export default {
}
};
},
mounted() {
this.init();
},
methods: {
change1(){
this.allSourceData.sourceData=[{value:1,label:2}]
},
change2(){
this.allSourceData.sourceData=[{value:2,label:3}]
change1() {
this.allSourceData.sourceData = [{ value: 1, label: 2 }];
},
init() {
// this.getData();
change2() {
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>
\ 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 @@
:readonly='disabled'
:prop='item.prop'
:containerType='type'
:remoteMethod='item.remoteMethod'
:requestMethod='item.requestMethod'
>
</hsSelectPlus>
</template>
......
......@@ -94,9 +94,8 @@ export default {
dialogIframe
},
props: {
remoteMethod: {
type: Function,
default() {}
requestMethod:{
type: Function
},
containerType: {},
elInfo: {
......@@ -249,6 +248,7 @@ export default {
// }
this.initData(newVal);
this.initValue(this.value);
this.clientData();
},
deep: true
}
......@@ -262,9 +262,20 @@ export default {
this.title = this.elInfo.title;
this.initData(this.allSourceData);
this.initValue(this.value);
this.clientData();
});
},
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() {
this.dialogIframeVisible = false;
},
......@@ -354,6 +365,7 @@ export default {
if (this.configData.ref) {
this.configData.remote = !!this.configData.ref.remote_condition;
this.configData.filterable = !!this.configData.ref.remote_condition;
debugger
}
const linkBtnUi = this.configData.linkBtnUi;
this.linkBtnUiVis = !!linkBtnUi;
......@@ -466,7 +478,7 @@ export default {
// 节流
remoteMethodsDebounce: _.debounce(async function(query) {
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 || []);
}, 1000),
async remoteMethod_(query) {
......
......@@ -94,7 +94,7 @@
:elInfo='item.elInfo'
:writeBackObject='formParms'
:readonly='disabled'
:remoteMethod='remoteMethod'
:requestMethod='item.requestMethod'
>
</hsSelectPlus>
</template>
......@@ -105,7 +105,6 @@
export default {
name: 'dyncFormItemComponentChild_',
props: {
remoteMethod: {},
item: {},
formParms: {},
jsoneditorOpenAfter: {
......
......@@ -93,7 +93,6 @@
<template v-else>
<!-- <span @click="cellClickItem(scope.row[column.prop],column.action)">{{scope.row[column.prop]}}</span> -->
<childItem
:remoteMethod="remoteMethod"
v-if="jumpItem(column.prop)"
:item='jumpItem(column.prop)'
:prop="column.prop"
......@@ -246,7 +245,6 @@ export default {
},
name: 'hsTable',
props: {
remoteMethod: {},
importInfo: {// 导入信息
type: Array,
default() {
......
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 = {
// 部署应用包时的基本 URL,用法和 webpack 本身的 output.publicPath 一致
publicPath: './',
......@@ -58,6 +67,13 @@ module.exports = {
pathRewrite: {
'^/api': ''
}
},
'/commonUtilAPI': {
target: commonUtilAPI,
changeOrigin: true,
pathRewrite: {
'^/commonUtilAPI': ''
}
}
},
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