Commit ef130325 authored by 何虹's avatar 何虹 💬

更新包

parent a3903c27
/build/
/config/
/dist/
examples/
src/packages/
public/
\ No newline at end of file
假设初始版本为0.1.0
➜ xxx git:(master) npm version preminor
v0.1.0-0
➜ xxx git:(master) npm version minor
v0.1.0
➜ xxx git:(master) npm version prepatch
v0.1.1-0
➜ xxx git:(master) npm version patch
v0.1.1
➜ xxx git:(master) npm version prerelease
v0.1.2-0
➜ xxx git:(master) npm version premajor
v1.0.0-0
➜ xxx git:(master) npm version major
v1.0.0
{
"name": "ui",
"name": "hs-sky-ui",
"version": "0.1.0",
"description": "hs组件库",
"main": "lib/hs-sky-ui.umd.min.js",
"keyword": "hscomponent hs-sky-ui",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
"lint": "vue-cli-service lint",
"build-bundle": "vue-cli-service build --target lib --name hs-sky-ui ./src/packages/index.js"
},
"dependencies": {
"axios": "^0.19.2",
"core-js": "^3.6.4",
"echarts": "^4.7.0",
"element-ui": "^2.13.1",
"hswebapp2frame": "^1.1.7",
"jsoneditor": "^8.6.5",
"lodash": "^4.17.15",
"moment": "^2.24.0",
"vue": "^2.6.11"
},
"devDependencies": {
......
<template>
<div id="app">
<img alt="Vue logo" src="./assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
<img
alt="Vue logo"
src='./assets/logo.png'
>
<HelloWorld msg="Welcome to Your Vue.js App" />
</div>
</template>
<script>
import HelloWorld from './components/HelloWorld.vue'
import HelloWorld from "./components/HelloWorld.vue";
export default {
name: 'App',
name: "App",
components: {
HelloWorld
}
}
};
</script>
<style>
......
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
<hsInput></hsInput>
</div>
</template>
......
import Vue from 'vue'
import App from './App.vue'
import './packages/index'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.config.productionTip = false
Vue.use(ElementUI)
new Vue({
render: h => h(App)
}).$mount('#app')
This diff is collapsed.
// dialog.js
import Vue from 'vue'
function makeDialog(option) {
var dom = document.createElement('div')
document.getElementsByTagName('body')[0].appendChild(dom)
const tpl = `
<el-dialog
:close-on-click-modal="false"
:custom-class="customClass"
:title="title"
:visible.sync="show"
:size="size"
:before-close="handleClose"
@close="close">
<dialogContent @close="closeDialog" @confirm="confirmDialog" v-model="dialogData"></dialogContent>
</el-dialog>`
var vue = new Vue({
el: dom,
data: function() {
return {
title: option.title,
size: option.size || 'small',
show: true,
dialogData: option.data
}
},
template: tpl,
computed: {
customClass() {
return `el-dialog--width-${option.size || 'auto'}`
}
},
methods: {
handleClose(done) {
if (option.beforeClose) {
option.beforeClose(done)
} else {
done()
}
},
close() {
if (option.close) {
option.close()
}
},
closeDialog() {
this.show = false
},
confirmDialog(result) {
this.show = false
option.confirm && option.confirm(result)
}
},
components: {
dialogContent: option.component
}
})
return vue
}
export default {
open(options) {
return makeDialog(options)
}
}
<template>
<el-dialog
title="导入"
:visible.sync="dialogVisible"
width="90%"
:before-close="handleClose"
:close-on-click-modal='false'
@open='open'
:append-to-body='true'
>
<iframe
name="zi"
:src='pageSrc'
style="width:100%;height:500px;padding-top:10px"
sandbox="allow-same-origin allow-scripts allow-forms allow-top-navigation allow-popups"
></iframe>
</el-dialog>
</template>
<script>
export default {
name: 'hsDialogIframe',
props: {
value: {
type: Boolean,
default: false
},
src: {
type: String,
default: ''
},
entityConfig: {},
currentImportItem: {},
entityManger: {}
},
watch: {
value(val) {
this.dialogVisible = val
},
dialogVisible(val) {
this.$emit('input', val)
}
},
data() {
return {
dialogVisiblePage: false,
pageSrc: '',
dialogVisible: false
}
},
beforeDestroy() {
window.removeEventListener('message', this.listenerMessageFun, false)
},
mounted() {
window.addEventListener(
'message',
this.listenerMessageFun,
false
)
},
methods: {
listenerMessageFun(event) {
const data_ = event.data
const { innerType, data, main, close } = data_
if (close) {
this.$emit('closeDialog')
} else {
if (innerType) {
switch (innerType) {
case 'dataImport':
case 'dataImportHdrDtl':
this.dataImport(data, this.entityConfig, main)
break
case 'selectPlugin':
this.selectPlugin(data)
break
}
}
}
},
// 参照弹出选择
selectPlugin(data) {
this.$emit('linkBtnUiBack', data)
},
// 单一列表的数据导入
async dataImport(data, config, main) {
if (!config) return
const type = this.entityManger.type // 实体类型
if (type === 'mainDtl') { // 详情的导入
this.dtlImport(data, config, main)
} else { // 列表上的导入
const ids = data.reduce((prve, curr) => {
prve.push(curr.id)
return prve
}, [])
const { table_name } = config
const { import_name, saveParms, _parms } = this.currentImportItem
const url_table_name = this.currentImportItem.table_name || table_name
let queryParms = saveParms || {}
if (_parms) {
queryParms = Object.assign({}, saveParms, _parms)
}
const data_ = {
ids: ids.join(),
data,
main,
type: 'import'
}
const parms_ = {
table_name: url_table_name,
import_name: import_name,
queryParms: queryParms
}
this.$API.importDataIframe(data_, parms_).then(res => {
this.$message.success('导入成功!')
this.$emit('importSuccess')
})
}
},
// 详情中的导入
async dtlImport(data, config, main) {
if (!config) return
const mainEntity = this.entityManger.mainEntity
const config_ = mainEntity.config
const primaryKey = config_.primaryKey
const mainData = mainEntity.data
if (mainData) {
const iUpdateStatus = mainData.iUpdateStatus
if (iUpdateStatus === 1) {
await mainEntity.save(true)
}
const ids = data.reduce((prve, curr) => {
prve.push(curr.id)
return prve
}, [])
const { table_name } = config
const { import_name, saveParms, _parms } = this.currentImportItem
const url_table_name = this.currentImportItem.table_name || table_name
let queryParms = saveParms || {}
if (_parms) {
queryParms = Object.assign({}, saveParms, _parms)
}
const data_ = {
ids: ids.join(),
data,
main,
type: 'import'
}
queryParms.bill_id = mainData[primaryKey]
const parms_ = {
table_name: url_table_name,
import_name: import_name,
queryParms: queryParms
}
this.$API.importDataIframe(data_, parms_).then(res => {
this.$message.success('导入成功!')
this.handleClose()
this.$emit('importSuccess', {
bill_id: mainData[primaryKey]
})
})
}
},
open() {
this.pageSrc = this.src
},
handleClose() {
this.dialogVisible = false
}
}
}
</script>
<template>
<el-dialog
title="导入"
:visible.sync="dialogVisible"
width="40%"
:before-close="handleClose"
:close-on-click-modal='false'
@open='open'
:append-to-body='true'
>
<el-upload
class="upload-demo"
:drag='false'
ref='uploadEl'
action="https://jsonplaceholder.typicode.com/posts/"
:auto-upload="false"
:on-change="handleChange"
:accept='accept'
:multiple='false'
:on-remove="handleRemove"
>
<!-- <i class="el-icon-upload"></i> -->
<!-- <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> -->
<el-button size="small" type="primary">选择文件</el-button>
<div class="el-upload__tip" slot="tip">只能上传xlsx/xls文件</div>
</el-upload>
<span slot="footer" class="dialog-footer">
<el-button size='mini' @click="dialogVisible = false">取 消</el-button>
<el-button size='mini' type="primary" @click="submit">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
export default {
name: 'hsDialogUpload',
props: {
value: {
type: Boolean,
default: false
},
entityConfig: {},
currentImportItem: {}
},
watch: {
value(val) {
this.dialogVisible = val
},
dialogVisible(val) {
this.$emit('input', val)
}
},
data() {
return {
dialogVisible: false,
fileList: [],
accept: 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
}
},
methods: {
handleRemove(file, fileList) {
if (!fileList.length) {
this.fileList = []
}
},
handleChange(file, fileList) {
const uploadFiles = this.$refs.uploadEl.uploadFiles.pop()
this.$refs.uploadEl.uploadFiles = [uploadFiles]
const file_ = [file]
this.fileList = file_
},
open() {
const r = this.$refs.uploadEl
this.fileList = []
if (r) { // 清空上传列表
r.clearFiles()
}
},
handleClose() {
this.dialogVisible = false
},
submit() {
if (!this.fileList.length) {
this.$message.error('请选择文件')
return
}
this.$emit('submit', this.fileList)
}
}
}
</script>
<style scoped>
.upload-demo{
text-align: center
}
</style>
.innerDialogBox>>> .el-dialog__body{
padding: 0 20px;
}
.innerDialogBox>>> .el-table td, .el-table th {
padding: 5px 0;
}
import Vue from 'vue'
export const EventBus = new Vue()
This diff is collapsed.
This diff is collapsed.
<template>
<div>
<el-table :data="gridData" max-height="350">
<el-table-column property="app_code" label="appCode" width="150"></el-table-column>
<el-table-column property="page_name" label="pageName" width="200"></el-table-column>
<el-table-column property="control_name" label="controlName"></el-table-column>
<el-table-column property="query_sql" label="querySql" :show-overflow-tooltip='true'></el-table-column>
<el-table-column property="version" label="version"></el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button
size="mini"
type="danger"
@click="revertVersion(scope.$index, scope.row)">回滚</el-button>
<el-button
type="success"
size="mini"
@click="showView(scope.$index, scope.row)">查看效果</el-button>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
export default {
name: 'lookPageLog',
props: {
elInfo: {
type: Object,
default() {
return {
dialogVisible: false
}
}
},
isrequest: {
type: Boolean,
default: false
}
},
data() {
return {
pageTitle: '',
dialogVisible: false,
gridData: []
}
},
watch: {
isrequest(value) {
this.dialogOpen()
}
},
mounted() {
this.dialogOpen()
},
methods: {
revertVersion(index, item) {
const parm = {
sAppCode: item.app_code,
sPage: item.page_name,
sControl: item.control_name,
version: item.version
}
this.$confirm('是否确定回滚到此版本!', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
this.$emit('revertVersion', parm)
})
.catch((e) => {
console.log(e)
this.$message({
type: 'info',
message: '已取消'
})
})
},
dialogOpen() {
const parm = {
sPage: this.elInfo.page,
sControl: this.elInfo.position
}
this.$API.getPageLog(parm).then(res => {
this.gridData = res
})
},
showView(index, item) {
const data = {
config: JSON.parse(item.json_config),
sourceData: JSON.parse(item.json_data),
sql: item.query_sql
}
this.$emit('showView', data)
}
}
}
</script>
<template>
<div>
<el-dialog
title="问号参数设置"
:visible="visible"
width="80%"
@open='open'
@close='close'
:append-to-body="true"
>
<el-table
:data="tableData"
style="width: 100%"
>
<el-table-column
prop="key"
label="变量名"
>
<template slot-scope="scope">
<el-input
size='mini'
v-model="scope.row.key"
></el-input>
</template>
</el-table-column>
<el-table-column
prop="type"
label="类型"
>
<template slot-scope="scope">
<el-select
v-model="scope.row.type"
size='mini'
clearable
>
<el-option
v-for="(option,index) in typeOptions"
:key="index"
:value='option.value'
:label='option.label'
>
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column
prop="default"
label="默认值"
>
<template slot-scope="scope">
<template v-if="scope.row.type=='select'">
<el-input
style="width:80px"
size='mini'
v-model="scope.row.default"
></el-input>
<el-button
size="mini"
@click="setRowOption(scope.row,scope.$index)"
>设置值</el-button>
</template>
<template v-else>
<el-input
size='mini'
v-model="scope.row.default"
></el-input>
</template>
</template>
</el-table-column>
<el-table-column
prop="remark"
label="备注"
>
<template slot-scope="scope">
<el-input
type="textarea"
:rows="1"
placeholder="请输入内容"
v-model="scope.row.remark"
>
</el-input>
</template>
</el-table-column>
<el-table-column
prop="handle"
label="操作"
>
<template slot-scope="scope">
<el-button
size='mini'
type="primary"
@click="add"
>新增</el-button>
<el-button
size='mini'
type="primary"
@click="deleteRow(scope.$index)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<div
slot="footer"
class="dialog-footer"
>
<el-button
size='mini'
type="primary"
@click="add"
>新增</el-button>
<el-button
size='mini'
type="primary"
@click="close"
>取 消</el-button>
<el-button
size='mini'
type="primary"
@click="submit"
>确定</el-button>
</div>
</el-dialog>
<el-dialog
title="设置下拉类型值"
:visible.sync="visibleSelect"
width="80%"
:append-to-body="true"
>
<el-table
:data="tableDataSelect"
style="width: 100%"
>
<el-table-column
prop="label"
label="label"
>
<template slot-scope="scope">
<el-input
size='mini'
v-model="scope.row.label"
></el-input>
</template>
</el-table-column>
<el-table-column
prop="value"
label="值"
>
<template slot-scope="scope">
<el-input
size='mini'
v-model="scope.row.value"
></el-input>
</template>
</el-table-column>
<el-table-column
prop="handle"
label="操作"
>
<template slot-scope="scope">
<el-button
size='mini'
type="primary"
@click="addSelect"
>新增</el-button>
<el-button
size='mini'
type="primary"
@click="deleteRowSelect(scope.$index)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<div
slot="footer"
class="dialog-footer"
>
<el-button
size='mini'
type="primary"
@click="addSelect"
>新增</el-button>
<el-button
size='mini'
type="primary"
@click="visibleSelect=false"
>取 消</el-button>
<el-button
size='mini'
type="primary"
@click="submitSelect"
>确定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
export default {
props: {
visible: {
type: Boolean,
default: false
}
},
data() {
return {
tableData: [{}],
elInfo: {
el: 'pageParams',
position: 'pageParams'
},
typeOptions: [
{
value: 'input',
label: '1输入框'
},
{
value: 'select',
label: '2下拉框'
}
],
visibleSelect: false,
tableDataSelect: [],
outRowIndex: 0
}
},
methods: {
submitSelect() {
this.tableData[this.outRowIndex].optionList = this.tableDataSelect
this.visibleSelect = false
},
addSelect() {
this.tableDataSelect.push({})
},
deleteRowSelect(index) {
this.tableDataSelect.splice(index, 1)
},
setRowOption(row, index) {
this.outRowIndex = index
this.visibleSelect = true
const optionList = row.optionList
if (Array.isArray(optionList)) {
this.tableDataSelect = optionList
} else {
this.tableDataSelect = [{}]
}
},
deleteRow(index) {
this.tableData.splice(index, 1)
},
add() {
this.tableData.push({})
},
async open() {
const data = {
control_name: 'pageParams',
return_type: 1
}
const res = await this.$API.getPageInfo(data)
if (!res.length) return
const json_config = JSON.parse(res[0].json_config)
this.tableData = json_config
},
close() {
this.$store.dispatch('menuParm/changeMenuDialogVisible', false)
},
submit() {
const data = {
sControl: 'pageParams',
sConfig: this.tableData,
sData: [],
sQuerySql: '',
elInfo: this.elInfo,
is_mock: 0
}
this.$API.runSave(data).then(() => {
this.$message.success('设置成功')
})
}
}
}
</script>
<template>
<el-dialog
@opened="dialogOpen"
title="系统布局配置"
:visible.sync="dialogVisible"
@closed="dialogClose" width="95%"
:append-to-body='true'
:close-on-click-modal='false'>
<div class="drawer-container">
<div>
<div class="drawer-item">
<span class="itemColor">系统主题颜色:</span>
<theme-picker @changeColor="themeChange" />
</div>
</div>
</div>
</el-dialog>
</template>
<script>
import ThemePicker from '../themePicker'
export default {
components: { ThemePicker },
props: {
value: Boolean
},
watch: {
value(val) {
this.dialogVisible = val
},
dialogVisible(val) {
this.$emit('input', val)
}
},
data() {
return {
dialogVisible: false
}
},
methods: {
themeChange(val) {
// this.$store.dispatch('setting/changeSetting', {
// key: 'theme',
// value: val
// })
const data = {
background: val
}
this.savePageConfig(data).then(() => {
sessionStorage['queryBiTheme'] = JSON.stringify(data)
})
},
// 保存queryBIView页面的配置信息
savePageConfig(data) {
const parms = {
sControl: 'systemSetting',
sConfig: {},
sData: data
}
return this.$API.runSave(parms)
},
dialogOpen() {
this.$store.commit('change_viewStatus', true)
},
dialogClose() {
this.$store.commit('change_viewStatus', false)
this.dialogVisible = false
}
}
}
</script>
<style scoped>
.drawer-container {
padding: 24px;
font-size: 14px;
line-height: 1.5;
word-wrap: break-word;
}
.drawer-title {
margin-bottom: 12px;
color: rgba(0, 0, 0, .85);
font-size: 14px;
line-height: 22px;
}
.drawer-item {
display: flex;
justify-content: start;
color: rgba(0, 0, 0, .65);
font-size: 14px;
padding: 12px 0;
}
.itemColor{
margin-right: 10px;
}
</style>
<template>
<el-dialog
:visible.sync="dialogVisible"
width="80%" title='列样式设置'
:append-to-body='true' :close-on-click-modal='false'>
<el-form :inline="true" :model="formInline" class="demo-form-inline" size='mini'>
<el-form-item label="字体颜色">
<el-select v-model="formInline.color" placeholder="颜色" clearable>
<el-option v-for="(item,index) in colorOptions" :key='index' :label="item.label" :value='item.value'></el-option>
</el-select>
</el-form-item>
<el-form-item label="字体大小">
<el-select v-model="formInline.fontSize" placeholder="字体大小" clearable>
<el-option v-for='(item,index) in fontSizeOptions' :key='index' :label="item.label" :value='item.value'>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="背景色">
<el-select v-model="formInline.background" placeholder="颜色" clearable>
<el-option v-for="(item,index) in colorOptions" :key='index' :label="item.label" :value='item.value'></el-option>
</el-select>
</el-form-item>
<el-form-item label="文本的修饰">
<el-select v-model="formInline['text-decoration']" placeholder="文本的修饰" clearable>
<el-option v-for="(item,index) in textDecorationOptions" :key='index' :label="item.label" :value='item.value'></el-option>
</el-select>
</el-form-item>
<el-form-item label="对齐方式">
<el-select v-model="formInline['text-align']" placeholder="对齐方式" clearable>
<el-option v-for="(item,index) in textAlignOptions" :key='index' :label="item.label" :value='item.value'></el-option>
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button size='mini' type="primary" @click="onSubmitStyle">确定</el-button>
</div>
</el-dialog>
</template>
<script>
export default {
props: {
formInline: {
default() {
return {}
}
},
value: Boolean
},
watch: {
value(val) {
this.dialogVisible = val
},
dialogVisible(val) {
this.$emit('input', val)
}
},
data() {
return {
dialogVisible: false,
fontSizeOptions: [
{ value: '10px', label: '10px' },
{ value: '12px', label: '12px' },
{ value: '14px', label: '14px' },
{ value: '16px', label: '16px' },
{ value: '18px', label: '18px' },
{ value: '20px', label: '20px' },
{ value: '22px', label: '22px' },
{ value: '24px', label: '24px' }
],
colorOptions: [
{ value: '#000000', label: '黑色' },
{ value: '#C0C0C0', label: '银色' },
{ value: '#808080', label: '灰色' },
{ value: '#FFFFFF', label: '白色' },
{ value: '#FF0000', label: '红色' },
{ value: '#800080', label: '紫色' },
{ value: '#FF00FF', label: '紫红' },
{ value: '#008000', label: '绿色' },
{ value: '#00FFFF', label: '浅绿' },
{ value: '#00FF00', label: '亮绿' },
{ value: '#808000', label: '橄榄' },
{ value: '#000080', label: '深蓝' },
{ value: '#0000FF', label: '蓝色' },
{ value: '#008080', label: '青色' }
],
textDecorationOptions: [
{ value: 'line-through', label: '删除线' },
{ value: 'underline', label: '下划线' },
{ value: 'overline', label: '上划线' }
],
textAlignOptions: [
{ value: 'left', label: '左对齐' },
{ value: 'right', label: '右对齐' },
{ value: 'center', label: '中间' }
]
}
},
methods: {
onSubmitStyle() {
this.$emit('submit', this.formInline)
}
}
}
</script>
This diff is collapsed.
import _ from 'lodash'
const emptyList = [undefined, null]
// 解析url的问号参数
function parseUrlQueryString() {
const host = decodeURIComponent(location.hash)
const queryObj = {}
if (host.includes('?')) {
const query = host.split('?')[1]
const queryList = query.split('&')
queryList.forEach(item => {
const iObj = item.split('=')
queryObj[iObj[0]] = iObj[1]
})
}
return queryObj
}
// 获取登录信息
function parseGlobalParams() {
const globalParam = {}
let user_info = sessionStorage['user_info']
if (user_info && user_info !== 'undefined') {
user_info = JSON.parse(user_info)
}
Object.assign(globalParam, user_info)
return globalParam
}
// 解析queryBi dync页面路由上的appCode 和pageName
function parseUrlQueryBIDyncAppcodePageName() {
const hash = decodeURIComponent(location.hash)
const hostSplit = hash.split('?')
let target = hostSplit[0]
// 如果说最后一位是‘/’ 则删除掉
if (target.endsWith('/')) {
target = target.substr(0, target.length - 1)
}
const targetSplit = target.split('/')
const length = targetSplit.length
let pagename = targetSplit[length - 1]
const appCode = targetSplit[length - 2]
if (pagename.includes('/')) {
pagename = pagename.split('/')[0]
}
if (pagename.includes('?')) {
pagename = pagename.split('?')[0]
}
return {
appCode: appCode,
pagename: pagename
}
}
// 解析动态菜单参数和全局参数MenuParams GlobalParams
function parseMenuGlobalParams(str, params) {
const { menuParam, globalParam, otherParam } = params
const empyt = [undefined]
if (typeof str !== 'string' || !str.includes('{') || !str.includes('}')) return str
const reg = /\{(.*?)\}/g // /(?<=\{).*?(?=\})/g
const strList = str.match(reg) || []// value_.match(/(?<=\{).*?(?=\})/g) || [] // value_.match(reg) || [] //
strList.forEach(p => {
const p_ = p.replace('{', '').replace('}', '')
const props = p_.split('.')
const sourceStr = props[0]
const propStr = props[1]
let pt = ''
if (sourceStr === 'menuParam') {
if (empyt.includes(menuParam[propStr])) {
pt = p
} else {
pt = menuParam[propStr]
}
} else if (sourceStr === 'globalParam') {
if (empyt.includes(globalParam[propStr])) {
pt = p
} else {
pt = globalParam[propStr]
}
} else {
if (empyt.includes(otherParam[propStr])) {
pt = p
} else {
pt = otherParam[propStr]
}
}
pt = decodeURIComponent(pt)
if (pt === 'false' || pt === 'true') {
str = pt !== 'false'// str.replace(`{${p_}}`, pt)
} else {
str = str.replace(`{${p_}}`, pt)
}
})
return str
}
// 递归替换动态参数
function recursiveDyncParam(obj, otherOBj = {}) {
const parseUrlQueryParams = parseUrlQueryString() || {}
const parseGlobalParams_ = parseGlobalParams() || {}
const parms = {
menuParam: parseUrlQueryParams, globalParam: parseGlobalParams_, otherParam: otherOBj
}
const objType = typeof obj
if (Array.isArray(obj)) {
obj.forEach((item, index) => {
if (typeof item === 'object') {
this.recursiveDyncParam(item, otherOBj)
} else {
obj[index] = parseMenuGlobalParams(item, parms)
}
})
} else if (objType === 'object') {
for (const prop in obj) {
if (typeof obj[prop] === 'object') {
this.recursiveDyncParam(obj[prop], otherOBj)
} else {
obj[prop] = parseMenuGlobalParams(obj[prop], parms)
}
}
} else {
return parseMenuGlobalParams(obj, parms)
}
}
function filterSingleRow(newObj, oldObj, prop = 'id') {
delete newObj.isSelected
delete oldObj.isSelected
const _newObj = _.cloneDeep(newObj)
const _oldObj = _.cloneDeep(oldObj)
const result = {}
for (const p in _newObj) {
if ((_oldObj[p] !== _newObj[p] && !emptyList.includes(_newObj[p])) || p === prop) {
result[p] = _newObj[p]
}
}
return result
}
// newData:当前数据.oldData:原始数据,primaryKey;主键id,reservedObj:保留字段
function comparisonArray(newData_, oldData_, primaryKey, reservedArray = []) {
const newData = _.cloneDeep(newData_)
const oldData = _.cloneDeep(oldData_)
const emptyValue = [undefined, 'undefined', '']
// 1,找出原始数据中所有的id
const old_ids = oldData.reduce((pre, curr) => {
const id = curr[primaryKey]
if (id) {
pre.push(id)
}
return pre
}, [])
// 2,找出新数据中所有项的id
const new_ids = newData.reduce((pre, curr) => {
const id = curr[primaryKey]
if (id) {
pre.push(id)
}
return pre
}, [])
// 3,找出删除项
const delete_ids = old_ids.filter(item => {
if (!new_ids.includes(item)) {
return item
}
})
const newItems = newData_.filter(item => {
if (item.iUpdateStatus === 1) {
return item
}
})
// 找出修改项目
const edit_item = newData.filter(item => {
delete item.isSelected
const id = item[primaryKey]
const curr_old_item = oldData.find(element => {
if (element[primaryKey] === id && item.iUpdateStatus !== 1) {
return element
}
})
if (id && curr_old_item) {
// 找出变化的字段 并且保留必要字段
for (const key in curr_old_item) {
const hasKey = key in item
if (!hasKey) { // 如果这个字段不在现有行中 则视为删除了
item[key] = ''
} else { // 如果字段对应的值相等 则视为 没更改 提交数据时把这个这段排除
if (curr_old_item[key] === item[key] && key !== primaryKey && !reservedArray.includes(key)) {
delete item[key]
}
}
}
const length1 = Object.keys(item).length
if (length1 > 1) {
return item
}
}
})
// 组装数据
// 为新增项加一个标示
newItems.forEach((item, index) => {
delete item.isSelected
// 删除空值
for (const key in item) {
const value = item[key]
if (emptyValue.includes(value)) {
delete item[key]
}
}
delete item._columns
})
// 筛选出非空项
const newItems_ = newItems.filter(item => Object.keys(item).length)
// 为修改项加标示
edit_item.filter(item => Object.keys(item).length).forEach(item => {
delete item.isSelected
for (const k in item) {
if (item[k] === undefined) {
item.k = ''
}
}
if (Object.keys(item).length > 1) {
item.iUpdateStatus = 2
}
})
const delete_items = []
delete_ids.forEach(item => {
const parm = {
iUpdateStatus: 4
}
parm[primaryKey] = item
delete_items.push(parm)
})
const result = [...edit_item, ...delete_items, ...newItems_]
return result
}
function comparisonJson(newData_, oldData_, primaryKey, reservedArray = []) {
const newData = _.cloneDeep(newData_)
const oldData = _.cloneDeep(oldData_)
const emptyValue = [undefined, 'undefined']
const iUpdateStatus = newData.iUpdateStatus
if (iUpdateStatus === 1) { // 新增
for (const key in newData) {
const value = newData[key]
if (emptyValue.includes(value)) {
delete newData[key]
}
}
} else { // 修改
for (const key in newData) {
if (key === '') {
debugger
delete newData[key]
}
if (newData[key] === oldData[key] && key !== primaryKey) {
delete newData[key]
}
newData.iUpdateStatus = 2
}
}
delete newData._columns
return newData
}
// 递归替换action 函数
function recursiveReplaceAction(obj, activeManager) {
for (const k in obj) {
const value = obj[k]
const type_k = typeof value
if (type_k === 'string') {
this.replaceItemAction(obj, activeManager)
} else if (type_k === 'object') {
this.recursiveReplaceAction(value, activeManager)
}
}
}
function replaceItemAction(item, activeManager) {
const actionProps = ['isHide', 'click', 'disabled', 'changed', 'cleared']
actionProps.forEach(k => {
const type = typeof item[k]
if (type === 'string' && !item[k].startsWith('$')) {
const funName = '$' + item[k]
item[k] = activeManager[funName]
}
})
}
export default {
parseUrlQueryString,
parseGlobalParams,
parseUrlQueryBIDyncAppcodePageName,
parseMenuGlobalParams,
recursiveDyncParam,
filterSingleRow,
comparisonJson,
comparisonArray,
_,
cloneDeep: _.cloneDeep, // 深拷贝
recursiveReplaceAction,
replaceItemAction
}
This diff is collapsed.
import { EleResize } from './ezresize'
import echarts from 'echarts'
export default function drawEcharts(id, option) { // id: chart所在块id, option: 配置项
const dom = document.getElementById(id)
const chart = echarts.init(dom)
chart.setOption(option)
const listener = _ => {
chart.resize()
}
EleResize.on(dom, listener)
return chart
}
const EleResize = {
_handleResize: function(e) {
const ele = e.target || e.srcElement
const trigger = ele.__resizeTrigger__
if (trigger) {
const handlers = trigger.__z_resizeListeners
if (handlers) {
const size = handlers.length
for (let i = 0; i < size; i++) {
const h = handlers[i]
const handler = h.handler
const context = h.context
handler.apply(context, [e])
}
}
}
},
_removeHandler: function(ele, handler, context) {
const handlers = ele.__z_resizeListeners
if (handlers) {
const size = handlers.length
for (let i = 0; i < size; i++) {
const h = handlers[i]
if (h.handler === handler && h.context === context) {
handlers.splice(i, 1)
return
}
}
}
},
_createResizeTrigger: function(ele) {
const obj = document.createElement('object')
obj.setAttribute('style',
'display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden;opacity: 0; pointer-events: none; z-index: -1;')
obj.onload = EleResize._handleObjectLoad
obj.type = 'text/html'
ele.appendChild(obj)
obj.data = 'about:blank'
return obj
},
_handleObjectLoad: function(evt) {
this.contentDocument.defaultView.__resizeTrigger__ = this.__resizeElement__
this.contentDocument.defaultView.addEventListener('resize', EleResize._handleResize)
}
}
if (document.attachEvent) { // ie9-10
EleResize.on = function(ele, handler, context) {
let handlers = ele.__z_resizeListeners
if (!handlers) {
handlers = []
ele.__z_resizeListeners = handlers
ele.__resizeTrigger__ = ele
ele.attachEvent('onresize', EleResize._handleResize)
}
handlers.push({
handler: handler,
context: context
})
}
EleResize.off = function(ele, handler, context) {
const handlers = ele.__z_resizeListeners
if (handlers) {
EleResize._removeHandler(ele, handler, context)
if (handlers.length === 0) {
ele.detachEvent('onresize', EleResize._handleResize)
delete ele.__z_resizeListeners
}
}
}
} else {
EleResize.on = function(ele, handler, context) {
let handlers = ele.__z_resizeListeners
if (!handlers) {
handlers = []
ele.__z_resizeListeners = handlers
if (getComputedStyle(ele, null).position === 'static') {
ele.style.position = 'relative'
}
const obj = EleResize._createResizeTrigger(ele)
ele.__resizeTrigger__ = obj
obj.__resizeElement__ = ele
}
handlers.push({
handler: handler,
context: context
})
}
EleResize.off = function(ele, handler, context) {
const handlers = ele.__z_resizeListeners
if (handlers) {
EleResize._removeHandler(ele, handler, context)
if (handlers.length === 0) {
const trigger = ele.__resizeTrigger__
if (trigger) {
trigger.contentDocument.defaultView.removeEventListener('resize', EleResize._handleResize)
ele.removeChild(trigger)
delete ele.__resizeTrigger__
}
delete ele.__z_resizeListeners
}
}
}
}
export { EleResize }
// 写一个递归方法把请求回来的数据 依次遍历 替换值
import commonUtility from '../funTools/commonUtility'
const parseUrlQueryParams = commonUtility.parseUrlQueryString() || {}
const parseGlobalParams = commonUtility.parseGlobalParams() || {}
function recursiveFun(obj) {
const objType = typeof obj
if (Array.isArray(obj)) {
obj.forEach((item) => {
recursiveFun(item)
})
} else if (objType === 'object') {
for (const prop in obj) {
recursiveFun(obj[prop])
}
} else {
obj = commonUtility.parseMenuGlobalParams(obj, parseUrlQueryParams, parseGlobalParams)
}
}
const obj = {
'init_data': {
'columns': {
'usable': 1,
'type': 100
},
'exec_sql': 'select bill_date=getdate()',
'exec_js': 'funcA'
},
'entity': {
'index': {
'isShowEdiAreaTree': true,
'defaultProps': {
'children': 'childs',
'label': 'equipment_type'
},
'isTree': false,
'table_name': 'emEquipmentType',
'primaryKey': 'id',
'queryMainParms': [
'equipment_type_id=id'
],
'indexTitle': '设备类型',
'dyncQueryParms': {
'ort': '11',
'bb_name': '{menuParam.name}'
}
},
'main': {
'table_name': 'emEquipmentModel',
'primaryKey': 'id',
'is_master_detail': true,
'dyncQueryParms': {
'number': '12312',
'th_name': '{menuParam.name}'
}
}
},
'new_default': {
'main': {
'copy_prerow': 'column1,column2',
'only_set_null_field': true,
'columns': {
'name': '{menuParam.name}',
'type': 100
},
'exec_sql': 'select bill_date=getdate()',
'exec_js': 'funcA'
}
},
'required_column': {
'columns': [
{
'name': 'column1',
'null_value': 0
},
{
'name': 'column2'
}
],
'exec_sql': 'select bill_date=getdate()',
'exec_js': 'funcA'
},
'custom': {
'bill_type': 100
}
}
recursiveFun(obj)
console.log(obj)
export default{
methods: {
getSelectKeyList(parmsList, position, prop = 'id') {
const data = this.layoutChagneDate[position]
if (!data || !data.length) {
this.$message.error('请勾选')
return
}
const list = []
this.layoutChagneDate[position].forEach(element => {
if (element[prop]) list.push(element[prop])
})
parmsList.length = 0
parmsList.push(...list)
return parmsList
}
}
}
This diff is collapsed.
this.active_manager.methodsObj.A.call(this.active_manager.pageThis);this.getSelectKeyList(this.param.keyList,'table1','订单号'); if(!this.param.keyList.length)return; this.execSqlFun(`exec HsMonitorCenter_Test.HsMonitorCenter_Test.HsMonitorCenter_Test.HsMonitorCenter_Test.HsMonitorCenter_Test.HsMonitorCenter_Test.HsMonitorCenter_Test.HsMonitorCenter_Test.HsMonitorCenter_Test.HsMonitorCenter_Test.HsMonitorCenter_Test.HsMonitorCenter_Test.HsMonitorCenter_Test.dbo.sppbXXXX @sIdList=${this.param.keyList}`).then(res=>{this.$message('操作成功');this.query()});
// 分理函数和sql
const spdoc = doc.split(';')
const spdoc0 = spdoc[0]
const execl = spdoc[1]
// 括号之间的所有内容 .* 或者 [\s\S]*
var regex1 = /\((.*)\)/
const r = spdoc0.match(regex1)[1]
const parms = r.split(',')
// 括号之前的内容 也就是函数名
var regex2 = /(.*)\(/
const fun = spdoc0.match(regex2)[1]
const sql = execl.match(regex1)[1]
this.actionConfig.result = parms[0]
this.actionConfig.getFun = fun
this.actionConfig.funParms = parms[2]
this.actionConfig.position = parms[1]
this.actionConfig.success = success || {}
if (spdoc[1].includes('exec')) {
this.actionConfig.execsql = sql
} else {
this.actionConfig.execFun = sql
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
import { EleResize } from '../funTools/self-adaption/ezresize.js'
import echarts from 'echarts'
export default {
data() {
return {
chart: null
}
},
beforeDestroy() {
this.offEchartsListener(this.elId, this.eachartResize)
},
methods: {
drawEcharts(id, option) {
const dom = document.getElementById(id)
this.chart = echarts.init(dom)
this.chart.setOption(option)
// const listener = _ => {
// chart.resize()
// }
// EleResize.on(dom, listener)
EleResize.on(dom, this.eachartResize)
return this.chart
},
eachartResize() {
this.chart.resize()
},
offEchartsListener(id, handle) {
const dom = document.getElementById(id)
EleResize.on(dom, handle)
}
}
}
This diff is collapsed.
This diff is collapsed.
import { EleResize } from '../funTools/self-adaption/ezresize.js'
import echarts from 'echarts'
export default {
data() {
return {
chart: null
}
},
beforeDestroy() {
this.offEchartsListener(this.elId, this.eachartResize)
},
methods: {
drawEcharts(id, option) {
const dom = document.getElementById(id)
this.chart = echarts.init(dom)
this.chart.setOption(option)
// const listener = _ => {
// chart.resize()
// }
// EleResize.on(dom, listener)
EleResize.on(dom, this.eachartResize)
return this.chart
},
eachartResize() {
this.chart.resize()
},
offEchartsListener(id, handle) {
const dom = document.getElementById(id)
EleResize.on(dom, handle)
}
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
const str = 'queryBiView/HsMonitorCenter_Test/designa2?id={_ids}'
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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