yinghe-lowcode-zln
Version:
基于vue、ant-design-vue,datagrid的低代码平台
173 lines (168 loc) • 4.75 kB
JavaScript
import { packageRpcParam } from "../../../packages/utils/util";
import {
ctos3CommonApi,
genCodeApi,
commonApi,
getFormConfig } from "../../../packages/api/manage";
import moment from 'moment'
export default {
data() {
return {
pageId: '',
spinning: false,
/* table选中records */
packageRpcParam: packageRpcParam,
ctos3CommonApi: ctos3CommonApi,
commonApi: commonApi,
getFormConfig: getFormConfig,
genCodeApi: genCodeApi,
moment: moment,
selectedRowKeys: [],
defaultValue: {},
pageType: 'form',
defaultFilter: {},
dynamicVariable: {},
dynamicData: {
commonFunc: this.commonFunc,
},
// 搜素框配置
searchConfigJson: {},
//modal相关设置
modalServiceName: '',
modalPageId: '',
modalDialogWidth: '',
loading: false,
dialogType: 'dialog',
modalBaseCodeType: '',
modalUrl: {
add: 'save',
update: 'updateById',
},
modalDynamicData: {},
}
},
created() {
this.pageId = this.$route.meta.pageId
},
mounted() {
if (!this.pageId) {
return
}
if(this.callInMountedCustom) {
this.callInMountedCustom()
}
// if (result.searchConfigJson) {
// this.searchConfigJson = JSON.parse(result.searchConfigJson)
// }
},
methods: {
// 初始化值,为表单设计器预览页面
initData(jsonData, config) {
if(this.callInMountedCustom) {
this.callInMountedCustom()
}
// if (config.searchConfigJson) {
// this.searchConfigJson = JSON.parse(config.searchConfigJson)
// }
},
handleOk(operation, data) {
if(this.handleDialogBusinessCustom) {
this.handleDialogBusinessCustom(operation, data)
} else {
this.$emit('handleDialogBusiness', operation, data)
}
},
/**
* 右侧操作栏按钮点击后事件
* @param operation 操作方法
*/
handleBusiness(operation) {
},
/**
* 右侧查询栏查询按钮点击后事件
* @param value 查询参数
*/
searchQuery(value) {
this.defaultFilter = value
delete value.defaultFilter
if (!this.searchConfigJson || !this.searchConfigJson.interfaceName || !this.searchConfigJson.methodName) {
this.$message.error('未配置搜索后端接口和方法!')
return
}
if (!this.searchConfigJson.code) {
this.getFormData(value)
} else {
// 使用脚本触发事件
customCodeEvent(this.searchConfigJson.code, this)(value, this)
}
},
commonFunc(operation, methodConfig) {
if(this.dynamicFuncCustom) {
this.dynamicFuncCustom(operation)
} else {
this.$emit('dynamicFunc', operation)
}
if (methodConfig) {
this.btnEventFunc(methodConfig)
}
},
/**
* 调用默认搜索方法
* @param value 查询参数
*/
getFormData(value) {
const rpcParams = packageRpcParam(value, [], [])
this.loading = true
if (this.searchConfigJson.codeClasz) {
rpcParams.push(this.searchConfigJson.codeClasz)
}
ctos3CommonApi(this.searchConfigJson.interfaceName, this.searchConfigJson.methodName, rpcParams)
.then(result => {
if (result && result.responseData.statusCode === 0) {
this.setData({
data: result.responseData.resultData
})
}
})
.finally(() => {
this.loading = false
})
},
//通用处理事件按钮
btnEventFunc(item) {
let that = this;
if (item.eventType === "popoverConfirm") {
this.$confirm({
title: "确认操作",
content: "是否确认进行此操作 ?",
onOk: () => {
that.handleServiceRes(undefined, undefined, item)
},
});
} else if (item.eventType === "bizHandle") {
this.handleServiceRes(undefined, undefined, item)
} else if (item.eventType === "dialog") {
this.modalPageId = item.pageId;
let data = {};
data.pageId = item.pageId;
if (this.selectedRowsData.length === 0) {
this.$refs.modalForm.add(data);
} else {
data = this.selectedRowsData[0];
this.$refs.modalForm.edit(data);
}
} else if (item.eventType === "link") {
const path = item.linkUrl;
let param = {};
if (item.attribute) {
let data = this.selectedRowsData[0];
param[item.attribute] = data[item.attribute];
}
this.$router.push({
path: path,
query: param
});
}
},
}
}