code stringlengths 1 1.05M | repo_name stringlengths 6 83 | path stringlengths 3 242 | language stringclasses 222 values | license stringclasses 20 values | size int64 1 1.05M |
|---|---|---|---|---|---|
<template>
<div class="userinfo">
<div class="box">
<div class="title-box">个人信息</div>
<div class="info">
<el-avatar
:size="50"
:src="userInfo.wxAvatar != '' ? userInfo.wxAvatar : require('@/static/df_avatar_nan.png')"
></el-avatar>
<div class="info-other">
<div style="font-weight:700;">
头像
<label class="gh" for="upload">上传</label>
<input
type="file"
ref="upload"
id="upload"
style="position:absolute; clip:rect(0 0 0 0);"
accept="image/png, image/jpeg, image/gif, image/jpg"
@change="uploadImg($event)"
/>
</div>
<div style="font-size:12px;margin-top:6px;">您可以使用AI作品,版权作品为头像</div>
</div>
</div>
</div>
<div class="box">
<div class="title-box">*用户名称</div>
<el-input
type="textarea"
clearable
:maxlength="20"
:show-word-limit="true"
placeholder="请输入名称"
v-model="name"
resize="none"
></el-input>
</div>
<div class="box">
<div class="title-box">个性签名</div>
<el-input
type="textarea"
clearable
:maxlength="40"
:show-word-limit="true"
placeholder="请输入个性签名"
v-model="signatureText"
></el-input>
</div>
<div class="qrgh" @click="editInfoData">确认更换</div>
<el-dialog :visible.sync="cropperShow" width="30%">
<div class="show-info">
<div class="test">
<vueCropper
ref="cropper"
:img="option.img "
:outputSize="option.size"
:info="option.info"
:canScale="option.canScale"
:autoCrop="option.autoCrop"
:autoCropWidth="option.autoCropWidth"
:autoCropHeight="option.autoCropHeight"
:fixed="option.fixed"
:fixedNumber="option.fixedNumber"
:enlarge="4"
></vueCropper>
</div>
<div class="qrgh-box">
<div class="qrgh" @click="finish2">裁剪</div>
<div class="qrgh" @click="editTopData">确认更换</div>
</div>
</div>
</el-dialog>
</div>
</template>
<script>
import { mapGetters, mapActions } from 'vuex'
import { editInfoDataApi } from '@/api/user'
import { uploadImage } from '@/api/system'
import { VueCropper } from 'vue-cropper'
export default {
name: 'userinfo',
components: {
VueCropper,
},
data() {
return {
name: '', // 名字
signatureText: '', //用户签名
cropperShow: false, // 是否开启剪切
option: {
//img的路径自行修改
img: '',
info: true,
size: 1,
canScale: true,
autoCrop: true,
// 只有自动截图开启 宽度高度才生效
autoCropWidth: 300,
autoCropHeight: 300,
fixed: true,
// 真实的输出宽高
infoTrue: true,
fixedNumber: [4, 4],
},
}
},
computed: {
...mapGetters(['isLogin', 'userInfo']),
},
mounted() {
if (this.isLogin) {
this.name = this.userInfo.wxName
this.signatureText = this.userInfo.sign
}
},
methods: {
...mapActions(['getUserInfoActions']),
async editTopData() {
this.$showLoading({
text: '更换中',
})
const imgBlob = await fetch(this.option.img).then((r) => r.blob())
const imgFile = new File([imgBlob], 'avatar', { type: imgBlob.type })
const formData = new FormData()
formData.append('file', imgFile)
formData.append('type', 'avatar')
uploadImage(formData)
.then((res) => {
let data = {
wxAvatar: res.data.link,
}
editInfoDataApi(data)
.then((res) => {
this.cropperShow = false
this.option.img = ''
this.getUserInfoActions()
this.$hideLoading({
message: '更换成功',
type: 'success',
})
})
.catch((err) => {
this.cropperShow = false
this.$hideLoading({
message: '更换失败',
type: 'error',
})
})
})
.catch(() => {
this.cropperShow = false
this.$hideLoading({
message: '更换失败',
type: 'error',
})
})
},
editInfoData() {
let data = {
wxName: this.name,
sign: this.signatureText,
}
this.$showLoading({
text: '正在修改',
})
editInfoDataApi(data)
.then((res) => {
this.getUserInfoActions()
this.$hideLoading({
message: '修改成功',
type: 'success',
})
})
.catch((err) => {
this.$hideLoading({
message: '修改失败',
type: 'error',
})
})
},
finish2() {
this.$refs.cropper.getCropBlob((data) => {
//裁剪后的图片显示
this.option.img = window.URL.createObjectURL(new Blob([data]))
})
},
uploadImg(e) {
//上传图片
this.option.img = ''
var file = e.target.files[0]
if (!/\.(gif|jpg|jpeg|png|bmp|GIF|JPG|PNG)$/.test(e.target.value)) {
alert('图片类型必须是.gif,jpeg,jpg,png,bmp中的一种')
return false
}
var reader = new FileReader()
reader.onload = (e) => {
let data
data = e.target.result
if (typeof e.target.result === 'object') {
// 把Array Buffer转化为blob 如果是base64不需要
data = window.URL.createObjectURL(new Blob([e.target.result]))
}
this.option.img = data
this.cropperShow = true
}
e.target.value = ''
// 转化为base64
// reader.readAsDataURL(file)
// 转化为blobcs
reader.readAsArrayBuffer(file)
},
},
}
</script>
<style lang="scss" scoped>
.el-textarea__inner {
max-height: 100px;
}
// 公共
.box {
display: flex;
flex-direction: column;
}
.userinfo {
// height: 100%;
}
.title-box {
padding: 24px 0;
font-size: 16px;
font-weight: 700;
}
.info {
display: flex;
align-items: center;
.info-other {
margin-left: 10px;
display: flex;
flex-direction: column;
justify-content: space-between;
.gh {
display: inline-block;
width: 60px;
height: 26px;
margin-left: 10px;
line-height: 26px;
text-align: center;
background: #ffffff;
border: 1px solid #666666;
border-radius: 16px;
font-size: 12px;
cursor: pointer;
}
}
}
.qrgh {
width: 198px;
height: 44px;
margin-top: 40px;
line-height: 44px;
text-align: center;
border-radius: 10px;
background-color: #960a0f;
color: #ffffff;
cursor: pointer;
}
.show-info {
// margin-bottom: 50px;
}
.show-info h2 {
margin: 0;
}
/*.title, .title:hover, .title-focus, .title:visited {
color: black;
}*/
.title {
display: block;
text-decoration: none;
text-align: center;
line-height: 1.5;
margin: 20px 0px;
background-image: -webkit-linear-gradient(left, #3498db, #f47920 10%, #d71345 20%, #f7acbc 30%, #ffd400 40%, #3498db 50%, #f47920 60%, #d71345 70%, #f7acbc 80%, #ffd400 90%, #3498db);
color: transparent;
background-size: 200% 100%;
animation: slide 5s infinite linear;
font-size: 40px;
}
.test {
height: 285px;
}
.model {
position: fixed;
z-index: 10;
width: 100vw;
height: 100vh;
overflow: auto;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.8);
}
.model-show {
display: flex;
justify-content: center;
align-items: center;
width: 100vw;
height: 100vh;
}
.model-show {
display: flex;
justify-content: center;
align-items: center;
width: 100vw;
height: 100vh;
}
.model img {
display: block;
margin: auto;
max-width: 80%;
user-select: none;
background-position: 0px 0px, 10px 10px;
background-size: 20px 20px;
background-image: linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee 100%), linear-gradient(45deg, #eee 25%, white 25%, white 75%, #eee 75%, #eee 100%);
}
.c-item {
display: block;
padding: 10px 0;
user-select: none;
}
@keyframes slide {
0% {
background-position: 0 0;
}
100% {
background-position: -100% 0;
}
}
@media screen and (max-width: 1000px) {
.content {
max-width: 90%;
margin: auto;
}
.test {
height: 400px;
}
}
.qrgh-box {
display: flex;
justify-content: space-around;
align-content: center;
.qrgh {
width: 198px;
margin: 10px 0;
// height: 44px;
// line-height: 44px;
text-align: center;
border-radius: 10px;
background-color: #960a0f;
color: #ffffff;
cursor: pointer;
}
}
</style> | 2301_78526554/springboot-openai-chatgpt | chatgpt_pc/src/views/user/userinfo.vue | Vue | apache-2.0 | 9,025 |
<template>
<div>
<div class="box-top"></div>
<div class="user">
<el-container style="width:1200px;">
<el-aside width="200px" class="aside">
<el-menu
:default-active="activeIndex"
class="el-menu-vertical-demo"
active-text-color="#960A0F"
:router="true"
@select="handleSelect"
>
<div v-for="(item, index) in navMenuList" :key="index">
<el-menu-item :index="item.path" style="text-align: center;">
<span class="iconfont" :class="item.icon"></span>
<span style="margin-left:6px;">{{ item.title }}</span>
</el-menu-item>
</div>
</el-menu>
</el-aside>
<el-main style="background:#FFFFFF;border-radius: 10px;">
<router-view></router-view>
</el-main>
</el-container>
</div>
</div>
</template>
<script>
export default {
name: 'user',
data() {
return {
activeIndex: '/index/user/userinfo',
navMenuList: [
{ path: '/index/user/equity-center', title: '权益中心', icon: 'icon-huiyuan' },
{ path: '/index/user/userinfo', title: '个人信息', icon: 'icon-yonghu' },
{ path: '/index/user/share', title: '邀请好友', icon: 'icon-fenxiang' },
{ path: '/index/user/setting', title: '账号设置', icon: 'icon-shezhi' },
{ path: '/index/user/rl-detail', title: '积分明细', icon: 'icon-jiangcheng' },
{ path: '/index/user/platform', title: '关于平台', icon: 'icon-cengji' },
],
}
},
watch: {
// 监听路由变化,改变当前激活菜单的 index
$route(to, from) {
this.activeIndex = to.path
}
},
mounted() {
this.activeIndex = this.$route.path
},
methods: {
handleSelect(key, keyPath) {
console.log(key, keyPath)
}
},
}
</script>
<style lang="scss">
.el-main {
padding: 20px;
}
.box-top {
padding-top: calc((100vh - 650px) / 2);
}
.user {
width: 1300px;
height: 580px;
margin: 10px auto;
display: flex;
justify-content: center;
}
.aside {
background-color: #fff;
margin-right: 20px;
border-radius: 10px;
}
</style> | 2301_78526554/springboot-openai-chatgpt | chatgpt_pc/src/views/user.vue | Vue | apache-2.0 | 2,161 |
[class^="icon-"]{
font-family: "iconfont" !important;
/* 以下内容参照第三方图标库本身的规则 */
font-size: 18px !important;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.el-menu-item [class^=icon-] {
margin-right: 5px;
width: 24px;
text-align: center;
font-size: 18px;
vertical-align: middle;
}
.el-submenu [class^=icon-] {
vertical-align: middle;
margin-right: 5px;
width: 24px;
text-align: center;
font-size: 18px;
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/public/cdn/iconfont/1.0.0/index.css | CSS | apache-2.0 | 532 |
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta http-equiv="X-UA-Compatible" content="chrome=1"/>
<link rel="stylesheet" href="<%= BASE_URL %>cdn/element-ui/2.15.6/theme-chalk/index.css">
<link rel="stylesheet" href="<%= BASE_URL %>cdn/animate/3.5.2/animate.css">
<link rel="stylesheet" href="<%= BASE_URL %>cdn/iconfont/1.0.0/index.css">
<link rel="stylesheet" href="<%= BASE_URL %>cdn/avue/2.9.5/index.css">
<script src="<%= BASE_URL %>cdn/xlsx/FileSaver.min.js"></script>
<script src="<%= BASE_URL %>cdn/xlsx/xlsx.full.min.js"></script>
<script src="<%= BASE_URL %>cdn/sortable/Sortable.min.js"></script>
<script src="https://cdn.staticfile.org/Sortable/1.10.0-rc2/Sortable.min.js"></script>
<script>
window.chatgpt_title='超级AI大脑管理系统'
</script>
<link rel="icon" href="<%= BASE_URL %>favicon.png">
<title>超级AI大脑管理系统</title>
<style>
html,
body,
#app {
height: 100%;
margin: 0;
padding: 0;
}
.avue-home {
background-color: #303133;
height: 100%;
display: flex;
flex-direction: column;
}
.avue-home__main {
user-select: none;
width: 100%;
flex-grow: 1;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.avue-home__footer {
width: 100%;
flex-grow: 0;
text-align: center;
padding: 1em 0;
}
.avue-home__footer > a {
font-size: 12px;
color: #ABABAB;
text-decoration: none;
}
.avue-home__loading {
height: 32px;
width: 32px;
margin-bottom: 20px;
}
.avue-home__title {
color: #FFF;
font-size: 14px;
margin-bottom: 10px;
}
.avue-home__sub-title {
color: #ABABAB;
font-size: 12px;
}
</style>
</head>
<body>
<noscript>
<strong>
很抱歉,如果没有 JavaScript 支持,网站将不能正常工作。请启用浏览器的 JavaScript 然后继续。
</strong>
</noscript>
<div id="app">
<div class="avue-home">
<div class="avue-home__main">
<img class="avue-home__loading" src="<%= BASE_URL %>svg/loading-spin.svg" alt="loading">
<div class="avue-home__title">
正在加载资源
</div>
<div class="avue-home__sub-title d">
初次加载资源可能需要较多时间 请耐心等待
</div>
</div>
</div>
</div>
<!-- built files will be auto injected -->
<script src="<%= BASE_URL %>util/aes.js" charset="utf-8"></script>
<script src="<%= BASE_URL %>cdn/vue/2.6.10/vue.min.js" charset="utf-8"></script>
<script src="<%= BASE_URL %>cdn/vuex/3.1.1/vuex.min.js" charset="utf-8"></script>
<script src="<%= BASE_URL %>cdn/vue-router/3.0.1/vue-router.min.js" charset="utf-8"></script>
<script src="<%= BASE_URL %>cdn/axios/1.0.0/axios.min.js" charset="utf-8"></script>
<script src="<%= BASE_URL %>cdn/element-ui/2.15.6/index.js" charset="utf-8"></script>
<script src="<%= BASE_URL %>cdn/avue/2.9.5/avue.min.js" charset="utf-8"></script>
</body>
</html>
| 2301_78526554/springboot-openai-chatgpt | mng_web/public/index.html | HTML | apache-2.0 | 3,475 |
.el-tip {
position: fixed;
left: 50%;
top: 50%;
width: 500px;
padding: 8px 16px;
margin: 0;
margin-left: -250px;
margin-top: -60px;
box-sizing: border-box;
border-radius: 4px;
position: relative;
background-color: #fff;
overflow: hidden;
opacity: 1;
display: flex;
align-items: center;
transition: opacity .2s;
}
.el-tip--warning {
background-color: #fdf6ec;
color: #e6a23c;
}
.el-tip__title {
line-height: 18px;
}
.el-tip_img img{
width: 80px;
height: 80px;
} | 2301_78526554/springboot-openai-chatgpt | mng_web/public/util/screen/screen.css | CSS | apache-2.0 | 550 |
function util() {
this.flag = true;
var body = document.body;
var safe = this;
var validVersion = function() {
var browser = navigator.appName
var b_version = navigator.appVersion
var version = b_version.split(";");
var trim_Version = version[1].replace(/[ ]/g, "");
if (trim_Version == 'WOW64') {
safe.flag = false
} else if (browser == "Microsoft Internet Explorer" && trim_Version == "MSIE6.0") {
safe.flag = false
} else if (browser == "Microsoft Internet Explorer" && trim_Version == "MSIE7.0") {
safe.flag = false
} else if (browser == "Microsoft Internet Explorer" && trim_Version == "MSIE8.0") {
safe.flag = false
} else if (browser == "Microsoft Internet Explorer" && trim_Version == "MSIE9.0") {
safe.flag = false
}
}
this.setBody = function() {
var str = '<div class="el-tip el-tip--warning" id="tip">' +
'<div class="el-tip_content">' +
'<span class="el-tip__title">' +
'您乘坐的浏览器版本太低了,你可以把浏览器从兼容模式调到极速模式' +
'<br /> 实在不行就换浏览器吧;' +
'</span>' +
'<div class="el-tip_img">' +
'<img src="/util/screen/huohu.png" alt="">' +
'<img src="/util/screen/guge.png" alt="">' +
'</div>' +
'</div>' +
'</div>';
body.innerHTML = str + body.innerHTML
}
this.init = function() {
validVersion(); //检测浏览器的版本
return this;
}
}
var creen = new util().init();
var flag = creen.flag;
if (!flag) {
creen.setBody();
} | 2301_78526554/springboot-openai-chatgpt | mng_web/public/util/screen/screen.js | JavaScript | apache-2.0 | 1,740 |
<template>
<div id="app">
<router-view />
</div>
</template>
<script>
export default {
name: "app",
data() {
return {};
},
watch: {},
created() {
},
methods: {},
computed: {}
};
</script>
<style lang="scss">
#app {
width: 100%;
height: 100%;
overflow: hidden;
}
.avue--detail .el-col{
margin-bottom: 0;
}
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/App.vue | Vue | apache-2.0 | 352 |
import request from '@/router/axios';
export const getList = (current, size, params) => {
return request({
url: '/api/blade-system/region/list',
method: 'get',
params: {
...params,
current,
size,
}
})
}
export const getLazyTree = (parentCode, params) => {
return request({
url: '/api/blade-system/region/lazy-tree',
method: 'get',
params: {
...params,
parentCode
}
})
}
export const getDetail = (code) => {
return request({
url: '/api/blade-system/region/detail',
method: 'get',
params: {
code
}
})
}
export const remove = (id) => {
return request({
url: '/api/blade-system/region/remove',
method: 'post',
params: {
id,
}
})
}
export const submit = (row) => {
return request({
url: '/api/blade-system/region/submit',
method: 'post',
data: row
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/base/region.js | JavaScript | apache-2.0 | 892 |
import request from '@/router/axios';
export const getList = (current, size, params) => {
return request({
url: '/api/blade-desk/notice/list',
method: 'get',
params: {
...params,
current,
size,
},
cryptoToken: false,
})
}
export const remove = (ids) => {
return request({
url: '/api/blade-desk/notice/remove',
method: 'post',
params: {
ids,
},
cryptoToken: false,
})
}
export const add = (row) => {
return request({
url: '/api/blade-desk/notice/submit',
method: 'post',
data: row,
cryptoToken: false,
})
}
export const update = (row) => {
return request({
url: '/api/blade-desk/notice/submit',
method: 'post',
data: row,
cryptoToken: false,
})
}
export const getNotice = (id) => {
return request({
url: '/api/blade-desk/notice/detail',
method: 'get',
params: {
id
},
cryptoToken: false,
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/desk/notice.js | JavaScript | apache-2.0 | 940 |
import request from '@/router/axios';
export const getUsualList = (current, size) => {
return request({
url: '/api/blade-log/usual/list',
method: 'get',
params: {
current,
size
}
})
}
export const getApiList = (current, size) => {
return request({
url: '/api/blade-log/api/list',
method: 'get',
params: {
current,
size
}
})
}
export const getErrorList = (current, size) => {
return request({
url: '/api/blade-log/error/list',
method: 'get',
params: {
current,
size
}
})
}
export const getUsualLogs = (id) => {
return request({
url: '/api/blade-log/usual/detail',
method: 'get',
params: {
id,
}
})
}
export const getApiLogs = (id) => {
return request({
url: '/api/blade-log/api/detail',
method: 'get',
params: {
id,
}
})
}
export const getErrorLogs = (id) => {
return request({
url: '/api/blade-log/error/detail',
method: 'get',
params: {
id,
}
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/logs.js | JavaScript | apache-2.0 | 1,029 |
import request from '@/router/axios';
export const getList = (current, size, params) => {
return request({
url: '/api/blade-report/report/rest/list',
method: 'get',
params: {
...params,
current,
size,
}
})
}
export const remove = (ids) => {
return request({
url: '/api/blade-report/report/rest/remove',
method: 'post',
params: {
ids,
}
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/report/report.js | JavaScript | apache-2.0 | 406 |
import request from '@/router/axios';
import { apiRequestHead } from '@/config/url.js';
//表单开发 获取每个数据详情
export const getDetails = (headId) => {
return request({
url: `/api/${apiRequestHead}/cgform-api/detail/listByHeadId`,
method: 'get',
params: {
headId,
}
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/research/code.js | JavaScript | apache-2.0 | 314 |
import request from '@/router/axios';
import { apiRequestHead } from '@/config/url.js';
//获取表头信息
export const getFormHeadApi = (params) => {
return request({
url: `/api/${apiRequestHead}/cgform-api/getColumns/${params.headId}`,
method: 'get',
params
})
}
//获取字段信息
export const getFormFieldApi = (params) => {
return request({
url: `/api/${apiRequestHead}/cgform-api/getFormItem/${params.headId}`,
method: 'get',
params
})
}
//获取数据列表 pageSzie = -521 不分页
export const getDataApi = (headId, params) => {
// 排序
if (!params.column && !params.order) {
params.column = 'id'
params.order = 'desc'
}
return request({
url: `/api/${apiRequestHead}/cgform-api/getData/${headId}`,
method: 'get',
params
})
}
//获取树表格数据列表
export const getTreeDataApi = (headId, params) => {
return request({
url: `/api/${apiRequestHead}/cgform-api/getTreeData/${headId}`,
method: 'get',
params
})
}
//获取树结构的所有数据
export const getTreeAllDataApi = (params) => {
return request({
url: `/api/${apiRequestHead}/sys/loadTreeData`,
method: 'get',
params
})
}
//获取树结构当前节点显示文本名
export const getTreeItemDataApi = (params) => {
return request({
url: `/api/${apiRequestHead}/sys/sys/dictitem/loadDictItem/${params.tableName},${params.tableLine},${params.rowKey}`,
method: 'get',
params: {
key: params.key
}
})
}
//获取树结构数据包涵所有子节点
export const getAllTreeDataApi = (params) => {
return request({
url: `/api/${apiRequestHead}/cgform-api/treeAllData/${params}`,
method: 'get',
})
}
//获取字典数据
export const getDicTableData = (dictCode) => {
return request({
url: `/api/${apiRequestHead}/sys/sys/dict/getDictItems/${dictCode}`,
method: 'get',
params: {}
})
}
//获取表格字典数据
export const getTableDicData = (table, label, value) => {
return request({
url: `/api/${apiRequestHead}/sys/sys/dict/getDict/${table},${label},${value}`,
method: 'get',
params: {
keyword: '',
}
})
}
//获取数据详情
export const getDataDetailApi = (headId, id, params) => {
return request({
url: `/api/${apiRequestHead}/cgform-api/detailData/${headId}/${id}`,
method: 'get',
params,
})
}
//新增数据
export const addDataApi = (headId, data) => {
return request({
url: `/api/${apiRequestHead}/cgform-api/addData/${headId}`,
method: 'post',
data
})
}
//编辑数据
export const editDataApi = (headId, data) => {
return request({
url: `/api/${apiRequestHead}/cgform-api/editData/${headId}`,
method: 'post',
data
})
}
// 删除数据
export const delDataApi = (headId, ids) => {
return request({
url: `/api/${apiRequestHead}/cgform-api/delete/form/${headId}/${ids}`,
method: 'post',
data: {}
})
}
//导出
export const exportDataApi = (headId, params) => {
return request({
url: `/api/${apiRequestHead}/excel-api/exportXls/${headId}`,
method: 'get',
responseType: 'blob',
params,
})
}
//导入
export const importDataApi = (headId, formData) => {
return request({
url: `/api/${apiRequestHead}/excel-api/importXls/${headId}`,
method: 'post',
headers: { "Content-Type": "multipart/form-data" },
data: formData,
})
}
//导入模板
export const importDataTemplateApi = (headId) => {
return request({
url: `/api/${apiRequestHead}/excel-api/exportXlsTemplate/${headId}`,
method: 'get',
responseType: 'blob',
params: {},
})
}
//上传文件
export const uploadeFileApi = (data) => {
return request({
url: `/api/${apiRequestHead}/cgform-api/upload/file`,
method: 'post',
data,
})
}
//获取上传文件接口名
export const getUploadeFileNameApi = (link) => {
return request({
url: `/api/${apiRequestHead}/cgform-api/get/original/name`,
method: 'get',
params: {
link
},
})
}
// sql增强触发接口
export const touchSqlEnhanceApi = (data) => {
return request({
url: `/api/${apiRequestHead}/cgform-java/cgformenhance/doButton`,
method: 'post',
data,
})
}
//获取附表erp配置
export const getErpColumnsApi = (headId) => {
return request({
url: `/api/${apiRequestHead}/cgform-api/getErpColumns/${headId}`,
method: 'get',
params: {},
})
}
//获取所有数据
export const getActionApi = (url, params) => {
return request({
url: `/api/${url}`,
method: 'get',
...params
})
}
//新增
export const postActionApi = (url, params) => {
return request({
url: `/api/${url}`,
method: 'post',
...params
})
}
//删除
export const deleteActionApi = (url, params) => {
return request({
url: `/api/${url}`,
method: 'delete',
...params
})
} | 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/research/codelist.js | JavaScript | apache-2.0 | 4,849 |
import request from '@/router/axios';
import { apiRequestHead } from '@/config/url.js';
//获取字典列表
export const getDicDataApi = (current, size, params) => {
return request({
url: `/api/${apiRequestHead}/sys/sys/dict/list`,
method: 'get',
params: {
...params,
current,
size
}
})
}
//添加字典
export const addDicDataApi = (data) => {
return request({
url: `/api/${apiRequestHead}/sys/sys/dict/save`,
method: 'post',
data
})
}
//修改字典
export const editDicDataApi = (data) => {
return request({
url: `/api/${apiRequestHead}/sys/sys/dict/update`,
method: 'post',
data
})
}
//删除字典
export const delDicDataApi = (ids) => {
return request({
url: `/api/${apiRequestHead}/sys/sys/dict/remove`,
method: 'post',
params: {
ids
}
})
}
//获取字典配置列表
export const getDicListDataApi = (current, size, params) => {
return request({
url: `/api/${apiRequestHead}/sys/sys/dictitem/list`,
method: 'get',
params: {
...params,
current,
size
}
})
}
//添加字典配置
export const addDicListDataApi = (data) => {
return request({
url: `/api/${apiRequestHead}/sys/sys/dictitem/save`,
method: 'post',
data
})
}
//修改字典配置
export const editDicListDataApi = (data) => {
return request({
url: `/api/${apiRequestHead}/sys/sys/dictitem/update`,
method: 'post',
data
})
}
//删除字典配置
export const delDicListDataApi = (ids) => {
return request({
url: `/api/${apiRequestHead}/sys/sys/dictitem/remove`,
method: 'post',
params: {
ids
}
})
}
//获取分类字典列表
export const getTreeDicDataApi = (current, size, params) => {
return request({
url: `/api/${apiRequestHead}/sys/sys/category/list`,
method: 'get',
params: {
...params,
current,
size
}
})
}
//添加分类字典
export const addTreeDicDataApi = (data) => {
return request({
url: `/api/${apiRequestHead}/sys/sys/category/save`,
method: 'post',
data
})
}
//修改分类字典
export const editTreeDicDataApi = (data) => {
return request({
url: `/api/${apiRequestHead}/sys/sys/category/update`,
method: 'post',
data
})
}
//删除分类字典
export const delTreeDicDataApi = (ids) => {
return request({
url: `/api/${apiRequestHead}/sys/sys/category/remove`,
method: 'post',
params: {
ids
}
})
}
//查询分类字典子集
export const getTreeChildeDicDataApi = (params) => {
return request({
url: `/api/${apiRequestHead}/sys/sys/category/childList`,
method: 'get',
params
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/research/datadic.js | JavaScript | apache-2.0 | 2,688 |
import request from '@/router/axios';
import { apiRequestHead } from '@/config/url.js';
// 根据表单code查询表单id
export const getFormIdApi = (code) => {
return request({
url: `/api/${apiRequestHead}/desform-api/desform/code/${code}`,
method: 'get',
data: {},
})
}
//获取当前表单详情数据
export const getdetailDataApi = (headId, lock) => {
let params = {}
if (lock) {
params.lock = lock
}
return request({
url: `/api/${apiRequestHead}/desform-api/desform/${headId}`,
method: 'get',
params,
})
}
//远程取值
export const getRemoteValuesApi = (url) => {
return request({
url,
method: 'get',
params: {}
})
}
//填值规则
export const executeRuleByApi = (data) => {
return request({
url: `/api/${apiRequestHead}/sys/executeRuleByCodeBatch`,
method: 'put',
data
})
}
//获取选择字段远端数据
export const getSelectRemoteDataApi = (url) => {
if (url.indexOf('/api/') == 0) {
url = url.replace('/api/', `/api/${apiRequestHead}/`)
}
return request({
url: url,
method: 'get',
params: {}
})
}
//js/css外部增强
export const getJsOrCssStrApi = (url) => {
return request({
url,
method: 'get',
params: {}
})
}
export const getActionApi = (url, params = {}, config = {}) => {
return request({
url,
method: 'get',
params,
...config
})
}
export const postActionApi = (url, data, config = {}) => {
return request({
url,
method: 'post',
data,
...config
})
}
export const putActionApi = (url, data, config = {}) => {
return request({
url,
method: 'put',
data,
...config
})
}
export const deleteActionApi = (url, data, config = {}) => {
return request({
url,
method: 'delete',
data,
...config
})
}
export const requestActionApi = (url, data, method) => {
let obj = {
url,
method,
}
if (method == 'get') {
obj.params = data
} else {
obj.data = data
}
return request(obj)
} | 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/research/form.js | JavaScript | apache-2.0 | 2,013 |
import request from '@/router/axios';
export const getList = (current, size, params) => {
return request({
url: '/api/blade-system/client/list',
method: 'get',
params: {
...params,
current,
size,
}
})
}
export const getDetail = (id) => {
return request({
url: '/api/blade-system/client/detail',
method: 'get',
params: {
id
}
})
}
export const remove = (ids) => {
return request({
url: '/api/blade-system/client/remove',
method: 'post',
params: {
ids,
}
})
}
export const add = (row) => {
return request({
url: '/api/blade-system/client/submit',
method: 'post',
data: row
})
}
export const update = (row) => {
return request({
url: '/api/blade-system/client/submit',
method: 'post',
data: row
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/system/client.js | JavaScript | apache-2.0 | 825 |
import request from '@/router/axios';
export const getList = (current, size, params) => {
return request({
url: '/api/blade-system/dept/list',
method: 'get',
params: {
...params,
current,
size,
}
})
}
export const remove = (ids) => {
return request({
url: '/api/blade-system/dept/remove',
method: 'post',
params: {
ids,
}
})
}
export const add = (row) => {
return request({
url: '/api/blade-system/dept/submit',
method: 'post',
data: row
})
}
export const update = (row) => {
return request({
url: '/api/blade-system/dept/submit',
method: 'post',
data: row
})
}
export const getDept = (id) => {
return request({
url: '/api/blade-system/dept/detail',
method: 'get',
params: {
id,
}
})
}
export const getDeptTree = (tenantId) => {
return request({
url: '/api/blade-system/dept/tree',
method: 'get',
params: {
tenantId,
}
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/system/dept.js | JavaScript | apache-2.0 | 977 |
import request from '@/router/axios';
export const getList = (current, size, params) => {
return request({
url: '/api/blade-system/dict/list',
method: 'get',
params: {
...params,
current,
size,
}
})
}
export const remove = (ids) => {
return request({
url: '/api/blade-system/dict/remove',
method: 'post',
params: {
ids,
}
})
}
export const add = (row) => {
return request({
url: '/api/blade-system/dict/submit',
method: 'post',
data: row
})
}
export const update = (row) => {
return request({
url: '/api/blade-system/dict/submit',
method: 'post',
data: row
})
}
export const getDict = (id) => {
return request({
url: '/api/blade-system/dict/detail',
method: 'get',
params: {
id,
}
})
}
export const getDictTree = () => {
return request({
url: '/api/blade-system/dict/tree?code=DICT',
method: 'get'
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/system/dict.js | JavaScript | apache-2.0 | 942 |
import request from '@/router/axios';
export const getList = (current, size, params) => {
return request({
url: '/api/blade-system/menu/list',
method: 'get',
params: {
...params,
current,
size,
}
})
}
export const remove = (ids) => {
return request({
url: '/api/blade-system/menu/remove',
method: 'post',
params: {
ids,
}
})
}
export const add = (row) => {
return request({
url: '/api/blade-system/menu/submit',
method: 'post',
data: row
})
}
export const update = (row) => {
return request({
url: '/api/blade-system/menu/submit',
method: 'post',
data: row
})
}
export const getMenu = (id) => {
return request({
url: '/api/blade-system/menu/detail',
method: 'get',
params: {
id,
}
})
}
export const getLazyMenuList = (parentId, params) => {
return request({
url: '/api/blade-system/menu/lazy-menu-list',
method: 'get',
params: {
...params,
parentId
}
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/system/menu.js | JavaScript | apache-2.0 | 1,015 |
import request from '@/router/axios';
export const getList = (current, size, params) => {
return request({
url: '/api/blade-system/param/list',
method: 'get',
params: {
...params,
current,
size,
}
})
}
export const remove = (ids) => {
return request({
url: '/api/blade-system/param/remove',
method: 'post',
params: {
ids,
}
})
}
export const add = (row) => {
return request({
url: '/api/blade-system/param/submit',
method: 'post',
data: row
})
}
export const update = (row) => {
return request({
url: '/api/blade-system/param/submit',
method: 'post',
data: row
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/system/param.js | JavaScript | apache-2.0 | 665 |
import request from '@/router/axios';
export const getList = (current, size, params) => {
return request({
url: '/api/blade-system/post/list',
method: 'get',
params: {
...params,
current,
size,
}
})
}
export const getPostList = (tenantId) => {
return request({
url: '/api/blade-system/post/select',
method: 'get',
params: {
tenantId
}
})
}
export const getDetail = (id) => {
return request({
url: '/api/blade-system/post/detail',
method: 'get',
params: {
id
}
})
}
export const remove = (ids) => {
return request({
url: '/api/blade-system/post/remove',
method: 'post',
params: {
ids,
}
})
}
export const add = (row) => {
return request({
url: '/api/blade-system/post/submit',
method: 'post',
data: row
})
}
export const update = (row) => {
return request({
url: '/api/blade-system/post/submit',
method: 'post',
data: row
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/system/post.js | JavaScript | apache-2.0 | 981 |
import request from '@/router/axios';
export const getList = (current, size, params) => {
return request({
url: '/api/blade-system/role/list', //ok
method: 'get',
params: {
...params,
current,
size,
}
})
}
export const grantTree = () => {
return request({
url: '/api/blade-system/menu/grant-tree', //ok
method: 'get',
})
}
export const grant = (roleIds, menuIds, dataScopeIds) => {
return request({
url: '/api/blade-system/role/grant',
method: 'post',
data: {
roleIds,
menuIds,
dataScopeIds
}
})
}
export const remove = (ids) => {
return request({
url: '/api/blade-system/role/remove', //ok
method: 'post',
params: {
ids,
}
})
}
export const add = (row) => {
return request({
url: '/api/blade-system/role/submit', //ok
method: 'post',
data: row
})
}
export const update = (row) => {
return request({
url: '/api/blade-system/role/submit',//ok
method: 'post',
data: row
})
}
export const getRole = (roleIds) => {
return request({
url: '/api/blade-system/menu/role-tree-keys', //ok
method: 'get',
params: {
roleIds,
}
})
}
export const getRoleTree = (tenantId) => {
return request({
url: '/api/blade-system/role/tree', //ok
method: 'get',
params: {
tenantId,
}
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/system/role.js | JavaScript | apache-2.0 | 1,369 |
import request from '@/router/axios';
export const getListDataScope = (current, size, params) => {
return request({
url: '/api/blade-system/data-scope/list',
method: 'get',
params: {
...params,
current,
size,
}
})
}
export const removeDataScope = (ids) => {
return request({
url: '/api/blade-system/data-scope/remove',
method: 'post',
params: {
ids,
}
})
}
export const addDataScope = (row) => {
return request({
url: '/api/blade-system/data-scope/submit',
method: 'post',
data: row
})
}
export const updateDataScope = (row) => {
return request({
url: '/api/blade-system/data-scope/submit',
method: 'post',
data: row
})
}
export const getMenuDataScope = (id) => {
return request({
url: '/api/blade-system/data-scope/detail',
method: 'get',
params: {
id,
}
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/system/scope.js | JavaScript | apache-2.0 | 889 |
import request from '@/router/axios';
export const getList = (current, size, params) => {
return request({
url: '/api/blade-system/tenant/list',
method: 'get',
params: {
...params,
current,
size,
}
})
}
export const remove = (ids) => {
return request({
url: '/api/blade-system/tenant/remove',
method: 'post',
params: {
ids,
}
})
}
export const add = (row) => {
return request({
url: '/api/blade-system/tenant/submit',
method: 'post',
data: row
})
}
export const update = (row) => {
return request({
url: '/api/blade-system/tenant/submit',
method: 'post',
data: row
})
}
export const info = (domain) => { //OK
return request({
url: '/api/blade-system/tenant/info',
method: 'get',
params: {
domain
}
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/system/tenant.js | JavaScript | apache-2.0 | 829 |
import request from '@/router/axios';
export const getList = (current, size, params) => {
return request({
url: '/api/blade-user/list', //ok
method: 'get',
params: {
...params,
current,
size,
}
})
}
export const remove = (ids) => {
return request({
url: '/api/blade-user/remove', //ok
method: 'post',
params: {
ids,
}
})
}
export const add = (row) => {
return request({
url: '/api/blade-user/submit', //ok
method: 'post',
data: row
})
}
export const update = (row) => {
return request({
url: '/api/blade-user/update', //ok
method: 'post',
data: row
})
}
export const grant = (userIds, roleIds) => {
return request({
url: '/api/blade-user/grant', //ok
method: 'post',
params: {
userIds,
roleIds,
}
})
}
export const getUser = (id) => {
return request({
url: '/api/blade-user/detail', //ok
method: 'get',
params: {
id,
}
})
}
export const getUserInfo = () => {
return request({
url: '/api/blade-user/info', //ok
method: 'get',
})
}
export const resetPassword = (userIds) => {
return request({
url: '/api/blade-user/reset-password', //ok
method: 'post',
params: {
userIds,
}
})
}
export const updatePassword = (oldPassword, newPassword, newPassword1) => {
return request({
url: '/api/blade-user/update-password', //ok
method: 'post',
params: {
oldPassword,
newPassword,
newPassword1,
}
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/system/user.js | JavaScript | apache-2.0 | 1,528 |
import request from '@/router/axios';
export const getList = (current, size, params) => {
return request({
url: '/api/blade-develop/code/list',
method: 'get',
params: {
...params,
current,
size
}
})
}
export const build = (ids) => {
return request({
url: '/api/blade-develop/code/gen-code',
method: 'post',
params: {
ids,
system: 'open-cjaidn'
}
})
}
export const remove = (ids) => {
return request({
url: '/api/blade-develop/code/remove',
method: 'post',
params: {
ids,
}
})
}
export const add = (row) => {
return request({
url: '/api/blade-develop/code/submit',
method: 'post',
data: row
})
}
export const update = (row) => {
return request({
url: '/api/blade-develop/code/submit',
method: 'post',
data: row
})
}
export const copy = (id) => {
return request({
url: '/api/blade-develop/code/copy',
method: 'post',
params: {
id,
}
})
}
export const getCode = (id) => {
return request({
url: '/api/blade-develop/code/detail',
method: 'get',
params: {
id,
}
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/tool/code.js | JavaScript | apache-2.0 | 1,147 |
import request from '@/router/axios';
export const getList = (current, size, params) => {
return request({
url: '/api/blade-develop/datasource/list',
method: 'get',
params: {
...params,
current,
size,
}
})
}
export const getDetail = (id) => {
return request({
url: '/api/blade-develop/datasource/detail',
method: 'get',
params: {
id
}
})
}
export const remove = (ids) => {
return request({
url: '/api/blade-develop/datasource/remove',
method: 'post',
params: {
ids,
}
})
}
export const add = (row) => {
return request({
url: '/api/blade-develop/datasource/submit',
method: 'post',
data: row
})
}
export const update = (row) => {
return request({
url: '/api/blade-develop/datasource/submit',
method: 'post',
data: row
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/tool/datasource.js | JavaScript | apache-2.0 | 850 |
import request from "@/router/axios";
import website from "@/config/website";
export const loginByUsername = (tenantId, account, password, type, key, code) =>
request({
url: "/api/blade-auth/token", //OK
method: "post",
headers: {
"Captcha-Key": key,
"Captcha-Code": code,
},
params: {
grantType: website.captchaMode ? "captcha" : "password",
tenantId,
account,
password,
type,
},
});
export const loginBySocial = (tenantId, source, code, state) =>
request({
url: "/api/blade-auth/token",
method: "post",
headers: {
"Tenant-Id": tenantId,
},
params: {
tenantId,
source,
code,
state,
grantType: "social",
scope: "all",
},
});
export const getButtons = () =>
request({
url: "/api/blade-system/menu/buttons",
method: "get",
});
export const getUserInfo = () =>
request({
url: "/user/getUserInfo",
method: "get",
});
export const refreshToken = (refreshToken) =>
request({
url: "/api/blade-auth/token",
method: "post",
params: {
refreshToken,
grantType: "refresh_token",
scope: "all",
},
});
export const registerGuest = (form, oauthId) =>
request({
url: "/api/blade-user/register-guest",
method: "post",
params: {
tenantId: form.tenantId,
name: form.name,
account: form.account,
password: form.password,
oauthId,
},
});
export const getMenu = (id) => {
return request({
url: "/api/blade-system/menu/routes",
method: "get",
});
};
export const getCaptcha = () => //OK
request({
url: "/api/blade-auth/captcha",
method: "get",
});
export const getTopMenu = () =>
request({
url: "/user/getTopMenu",
method: "get",
});
export const sendLogs = (list) =>
request({
url: "/user/send-logs",
method: "post",
data: list,
});
export const logout = () =>
request({
url: "/api/blade-auth/logout",
method: "get",
});
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/user.js | JavaScript | apache-2.0 | 2,027 |
import request from '@/router/axios';
// =====================参数===========================
export const historyFlowList = (processInstanceId) => {
return request({
url: '/api/blade-flow/process/history-flow-list',
method: 'get',
params: {
processInstanceId
}
})
}
// =====================请假流程===========================
export const leaveProcess = (data) => {
return request({
url: '/api/blade-desk/process/leave/start-process',
method: 'post',
data
})
}
export const leaveDetail = (businessId) => {
return request({
url: '/api/blade-desk/process/leave/detail',
method: 'get',
params: {
businessId
}
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/work/process.js | JavaScript | apache-2.0 | 692 |
import request from '@/router/axios';
export const startList = (current, size, params) => {
return request({
url: '/api/blade-flow/work/start-list',
method: 'get',
params: {
...params,
current,
size,
}
})
}
export const claimList = (current, size, params) => {
return request({
url: '/api/blade-flow/work/claim-list',
method: 'get',
params: {
...params,
current,
size,
}
})
}
export const todoList = (current, size, params) => {
return request({
url: '/api/blade-flow/work/todo-list',
method: 'get',
params: {
...params,
current,
size,
}
})
}
export const sendList = (current, size, params) => {
return request({
url: '/api/blade-flow/work/send-list',
method: 'get',
params: {
...params,
current,
size,
}
})
}
export const doneList = (current, size, params) => {
return request({
url: '/api/blade-flow/work/done-list',
method: 'get',
params: {
...params,
current,
size,
}
})
}
export const claimTask = (taskId) => {
return request({
url: '/api/blade-flow/work/claim-task',
method: 'post',
params: {
taskId
}
})
}
export const completeTask = (data) => {
return request({
url: '/api/blade-flow/work/complete-task',
method: 'post',
data
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/api/work/work.js | JavaScript | apache-2.0 | 1,380 |
<template>
<div class="basic-container">
<el-card>
<slot></slot>
</el-card>
</div>
</template>
<script>
export default {
name: "basicContainer"
};
</script>
<style lang="scss">
.basic-container {
padding: 10px 6px;
border-radius: 10px;
box-sizing: border-box;
.el-card {
width: 100%;
}
&:first-child {
padding-top: 0;
}
}
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/components/basic-container/main.vue | Vue | apache-2.0 | 375 |
<template>
<div class="error-page">
<div class="img"
style=" background-image: url('/img/bg/403.svg');"></div>
<div class="content">
<h1>403</h1>
<div class="desc">抱歉,你无权访问该页面</div>
<div class="actions">
<router-link :to="{path:'/'}">
<el-button type="primary">返回首页</el-button>
</router-link>
</div>
</div>
</div>
</template>
<script>
export default {
name: "error-403"
};
</script>
<style lang="scss" scoped>
@import "./style.scss";
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/components/error-page/403.vue | Vue | apache-2.0 | 551 |
<template>
<div class="error-page">
<div class="img"
style=" background-image: url('/img/bg/404.svg');"></div>
<div class="content">
<h1>404</h1>
<div class="desc">抱歉,你访问的页面不存在</div>
<div class="actions">
<router-link :to="{path:'/'}">
<el-button type="primary">返回首页</el-button>
</router-link>
</div>
</div>
</div>
</template>
<script>
export default {
name: "error-404"
};
</script>
<style lang="scss" scoped>
@import "./style.scss";
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/components/error-page/404.vue | Vue | apache-2.0 | 554 |
<template>
<div class="error-page">
<div class="img"
style=" background-image: url('/img/bg/500.svg');"></div>
<div class="content">
<h1>500</h1>
<div class="desc">抱歉,服务器出错了</div>
<div class="actions">
<router-link :to="{path:'/'}">
<el-button type="primary">返回首页</el-button>
</router-link>
</div>
</div>
</div>
</template>
<script>
export default {
name: "error-500"
};
</script>
<style lang="scss" scoped>
@import "./style.scss";
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/components/error-page/500.vue | Vue | apache-2.0 | 545 |
.error-page {
background: #f0f2f5;
margin-top: -30px;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
.img {
margin-right: 80px;
height: 360px;
width: 100%;
max-width: 430px;
background-repeat: no-repeat;
background-position: 50% 50%;
background-size: contain;
}
.content {
h1 {
color: #434e59;
font-size: 72px;
font-weight: 600;
line-height: 72px;
margin-bottom: 24px;
}
.desc {
color: rgba(0, 0, 0, 0.45);
font-size: 20px;
line-height: 28px;
margin-bottom: 16px;
}
}
} | 2301_78526554/springboot-openai-chatgpt | mng_web/src/components/error-page/style.scss | SCSS | apache-2.0 | 615 |
<template>
<basic-container>
<iframe :src="src"
class="iframe"
ref="iframe"></iframe>
</basic-container>
</template>
<script>
import { mapGetters } from "vuex";
import NProgress from "nprogress"; // progress bar
import "nprogress/nprogress.css"; // progress bar style
export default {
name: "AvueIframe",
data() {
return {
urlPath: this.getUrlPath() //iframe src 路径
};
},
created() {
NProgress.configure({ showSpinner: false });
},
mounted() {
this.load();
this.resize();
},
props: ["routerPath"],
watch: {
$route: function() {
this.load();
},
routerPath: function() {
// 监听routerPath变化,改变src路径
this.urlPath = this.getUrlPath();
}
},
computed: {
...mapGetters(["screen"]),
src() {
return this.$route.query.src
? this.$route.query.src.replace("$", "#")
: this.urlPath;
}
},
methods: {
// 显示等待框
show() {
NProgress.start();
},
// 隐藏等待狂
hide() {
NProgress.done();
},
// 加载浏览器窗口变化自适应
resize() {
window.onresize = () => {
this.iframeInit();
};
},
// 加载组件
load() {
this.show();
var flag = true; //URL是否包含问号
if (this.$route.query.src.indexOf("?") == -1) {
flag = false;
}
var list = [];
for (var key in this.$route.query) {
if (key != "src" && key != "name" && key != "i18n") {
list.push(`${key}= this.$route.query[key]`);
}
}
list = list.join("&").toString();
if (flag) {
this.$route.query.src = `${this.$route.query.src}${
list.length > 0 ? `&list` : ""
}`;
} else {
this.$route.query.src = `${this.$route.query.src}${
list.length > 0 ? `?list` : ""
}`;
}
//超时3s自动隐藏等待狂,加强用户体验
let time = 3;
const timeFunc = setInterval(() => {
time--;
if (time == 0) {
this.hide();
clearInterval(timeFunc);
}
}, 1000);
this.iframeInit();
},
//iframe窗口初始化
iframeInit() {
const iframe = this.$refs.iframe;
const clientHeight =
document.documentElement.clientHeight - (screen > 1 ? 200 : 130);
if (!iframe) return;
iframe.style.height = `${clientHeight}px`;
if (iframe.attachEvent) {
iframe.attachEvent("onload", () => {
this.hide();
});
} else {
iframe.onload = () => {
this.hide();
};
}
},
getUrlPath: function() {
//获取 iframe src 路径
let url = window.location.href;
url = url.replace("/myiframe", "");
return url;
}
}
};
</script>
<style lang="scss">
.iframe {
width: 100%;
height: 100%;
border: 0;
overflow: hidden;
box-sizing: border-box;
}
</style> | 2301_78526554/springboot-openai-chatgpt | mng_web/src/components/iframe/main.vue | Vue | apache-2.0 | 2,982 |
<template>
<el-dialog title="账号注册"
append-to-body
:visible.sync="accountBox"
:close-on-click-modal="false"
:close-on-press-escape="false"
:show-close="false"
width="20%">
<el-form :model="form" ref="form" label-width="80px">
<el-form-item label="租户编号">
<el-input v-model="form.tenantId" placeholder="请输入租户编号"></el-input>
</el-form-item>
<el-form-item label="用户姓名">
<el-input v-model="form.name" placeholder="请输入用户姓名"></el-input>
</el-form-item>
<el-form-item label="账号名称">
<el-input v-model="form.account" placeholder="请输入账号名称"></el-input>
</el-form-item>
<el-form-item label="账号密码">
<el-input v-model="form.password" placeholder="请输入账号密码"></el-input>
</el-form-item>
<el-form-item label="确认密码">
<el-input v-model="form.password2" placeholder="请输入确认密码"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" :loading="loading" @click="handleRegister">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import {mapGetters} from "vuex";
import {validatenull} from "@/util/validate";
import {registerGuest} from "@/api/user";
export default {
name: "thirdRegister",
data() {
return {
form: {
tenantId: '',
name: '',
account: '',
password: '',
password2: '',
},
loading: false,
accountBox: false,
};
},
computed: {
...mapGetters(["userInfo"]),
},
created() {
},
mounted() {
// 若未登录则弹出框进行绑定
if (validatenull(this.userInfo.userId) || this.userInfo.userId < 0) {
this.form.name = this.userInfo.account;
this.form.account = this.userInfo.account;
this.accountBox = true;
}
},
methods: {
handleRegister() {
if (this.form.tenantId === '') {
this.$message.warning("请先输入租户编号");
return;
}
if (this.form.account === '') {
this.$message.warning("请先输入账号名称");
return;
}
if (this.form.password === '' || this.form.password2 === '') {
this.$message.warning("请先输入密码");
return;
}
if (this.form.password !== this.form.password2) {
this.$message.warning("两次密码输入不一致");
return;
}
this.loading = true;
registerGuest(this.form, this.userInfo.oauthId).then(res => {
this.loading = false;
const data = res.data;
if (data.success) {
this.accountBox = false;
this.$alert("注册申请已提交,请耐心等待管理员通过!", '注册提示').then(() => {
this.$store.dispatch("LogOut").then(() => {
this.$router.push({path: "/login"});
});
})
} else {
this.$message.error(data.msg || '提交失败');
}
}, error => {
window.console.log(error);
this.loading = false;
});
},
},
};
</script>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/components/third-register/main.vue | Vue | apache-2.0 | 3,397 |
// 配置编译环境和线上环境之间的切换
let baseUrl = '';
let iconfontVersion = ['567566_pwc3oottzol', '1066523_6bvkeuqao36'];
let iconfontUrl = `//at.alicdn.com/t/font_$key.css`;
let codeUrl = `${baseUrl}/code`
const env = process.env
if (env.NODE_ENV == 'development') {
baseUrl = ``; // 开发环境地址
} else if (env.NODE_ENV == 'production') {
baseUrl = ``; //生产环境地址
} else if (env.NODE_ENV == 'test') {
baseUrl = ``; //测试环境地址
}
export {
baseUrl,
iconfontUrl,
iconfontVersion,
codeUrl,
env
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/config/env.js | JavaScript | apache-2.0 | 569 |
export default [
{
label: "通用图标",
list: [
"iconfont iconicon_roundadd",
"iconfont iconicon_compile",
"iconfont iconicon_glass",
"iconfont iconicon_roundclose",
"iconfont iconicon_roundreduce",
"iconfont iconicon_delete",
"iconfont iconicon_shakehands",
"iconfont iconicon_task_done",
"iconfont iconicon_voipphone",
"iconfont iconicon_safety",
"iconfont iconicon_work",
"iconfont iconicon_study",
"iconfont iconicon_task",
"iconfont iconicon_subordinate",
"iconfont iconicon_star",
"iconfont iconicon_setting",
"iconfont iconicon_sms",
"iconfont iconicon_share",
"iconfont iconicon_secret",
"iconfont iconicon_scan_namecard",
"iconfont iconicon_principal",
"iconfont iconicon_group",
"iconfont iconicon_send",
"iconfont iconicon_scan",
"iconfont iconicon_search",
"iconfont iconicon_refresh",
"iconfont iconicon_savememo",
"iconfont iconicon_QRcode",
"iconfont iconicon_im_keyboard",
"iconfont iconicon_redpacket",
"iconfont iconicon_photo",
"iconfont iconicon_qq",
"iconfont iconicon_wechat",
"iconfont iconicon_phone",
"iconfont iconicon_namecard",
"iconfont iconicon_notice",
"iconfont iconicon_next_arrow",
"iconfont iconicon_left",
"iconfont iconicon_more",
"iconfont iconicon_details",
"iconfont iconicon_message",
"iconfont iconicon_mobilephone",
"iconfont iconicon_im_voice",
"iconfont iconicon_GPS",
"iconfont iconicon_ding",
"iconfont iconicon_exchange",
"iconfont iconicon_cspace",
"iconfont iconicon_doc",
"iconfont iconicon_dispose",
"iconfont iconicon_discovery",
"iconfont iconicon_community_line",
"iconfont iconicon_cloud_history",
"iconfont iconicon_coinpurse_line",
"iconfont iconicon_airplay",
"iconfont iconicon_at",
"iconfont iconicon_addressbook",
"iconfont iconicon_boss",
"iconfont iconicon_addperson",
"iconfont iconicon_affiliations_li",
"iconfont iconicon_addmessage",
"iconfont iconicon_addresslist",
"iconfont iconicon_add",
"iconfont icongithub",
"iconfont icongitee2",
]
},
{
label: "系统图标",
list: [
"iconfont icon-zhongyingwen",
"iconfont icon-caidan",
"iconfont icon-rizhi1",
"iconfont icon-zhuti",
"iconfont icon-suoping",
"iconfont icon-bug",
"iconfont icon-qq1",
"iconfont icon-weixin1",
"iconfont icon-shouji",
"iconfont icon-mima",
"iconfont icon-yonghu",
"iconfont icon-yanzhengma",
"iconfont icon-canshu",
"iconfont icon-dongtai",
"iconfont icon-iconset0265",
"iconfont icon-shujuzhanshi2",
"iconfont icon-tuichuquanping",
"iconfont icon-rizhi",
"iconfont icon-cuowutishitubiao",
"iconfont icon-debug",
"iconfont icon-iconset0216",
"iconfont icon-quanxian",
"iconfont icon-quanxian",
"iconfont icon-shuaxin",
"iconfont icon-bofangqi-suoping",
"iconfont icon-quanping",
"iconfont icon-navicon",
"iconfont icon-biaodan",
"iconfont icon-liuliangyunpingtaitubiao08",
"iconfont icon-caidanguanli",
"iconfont icon-cuowu",
"iconfont icon-wxbgongju",
"iconfont icon-tuichu",
"iconfont icon-daohanglanmoshi02",
"iconfont icon-changyonglogo27",
"iconfont icon-biaoge",
"iconfont icon-baidu1",
"iconfont icon-tubiao",
"iconfont icon-souhu",
"iconfont icon-msnui-360",
"iconfont icon-iframe",
"iconfont icon-huanyingye",
]
}
]
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/config/iconList.js | JavaScript | apache-2.0 | 3,738 |
// export const apiRequestHead = 'mjkj-bladex' //公共后端请求头
export const apiRequestHead = 'mjkj-chat' //公共后端请求头
// export const apiRequestHead = 'mjkj-bladex-zt' //公共后端请求头
export const fileApiRequestHead = "mjkj-chat"
//网站地址 用于第三方登录失败后重新访问登录页面
export const originUrl = 'https://www.zhckxt.com'
//文件预览html访问路径
export const fileViewUrl = 'http://file.view.mj.ink/view.html'
//报表访问基础路径
export const statementBaseUrl = 'http://ureport.zhckxt.com/ureport/preview'
//大屏访问基础路径
export const dataViewUrl = 'http://localhost:8848/view'
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/config/url.js | JavaScript | apache-2.0 | 660 |
/**
* 全局配置文件
*/
export default {
title: window.chatgpt_title,
indexTitle: window.chatgpt_title,
clientId: 'open-cjaidn', // 客户端id
clientSecret: 'open-cjaidn_secret', // 客户端密钥
tenantMode: true, // 是否开启租户模式
captchaMode: true, // 是否开启验证码模式
logo: "S",
key: 'open-cjaidn',//配置主键,目前用于存储
lockPage: '/lock',
tokenTime: 100,
//http的status默认放行不才用统一处理的,
statusWhiteList: [],
//配置首页不可关闭
isFirstPage: false,
fistPage: {
label: "首页",
value: "/wel/index",
params: {},
query: {},
meta: {
i18n: 'dashboard'
},
group: [],
close: false
},
//配置菜单的属性
menu: {
iconDefault: 'iconfont icon-caidan',
props: {
label: 'name',
path: 'path',
icon: 'source',
children: 'children'
}
},
// 授权地址
authUrl: 'http://localhost/blade-auth/oauth/render',
// 报表设计器地址(cloud端口为8108,boot端口为80)
reportUrl: 'http://localhost:8108/ureport',
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/config/website.js | JavaScript | apache-2.0 | 1,095 |
export default {
tabs: true,
tabsActive: 1,
group: [
{
label: '个人信息',
prop: 'info',
column: [{
label: '头像',
type: 'upload',
listType: 'picture-img',
propsHttp: {
res: 'data',
url: 'link',
},
canvasOption: {
text: 'blade',
ratio: 0.1
},
action: '/api/blade-resource/oss/endpoint/put-file',
tip: '只能上传jpg/png用户头像,且不超过500kb',
span: 12,
row: true,
prop: 'avatar'
}, {
label: '姓名',
span: 12,
row: true,
prop: 'name'
}, {
label: '用户名',
span: 12,
row: true,
prop: 'realName'
}, {
label: '手机号',
span: 12,
row: true,
prop: 'phone'
}, {
label: '邮箱',
prop: 'email',
span: 12,
row: true,
}]
},
{
label: '修改密码',
prop: 'password',
column: [{
label: '原密码',
span: 12,
row: true,
type: 'password',
prop: 'oldPassword'
}, {
label: '新密码',
span: 12,
row: true,
type: 'password',
prop: 'newPassword'
}, {
label: '确认密码',
span: 12,
row: true,
type: 'password',
prop: 'newPassword1'
}]
}
],
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/const/user/info.js | JavaScript | apache-2.0 | 1,447 |
FROM nginx
VOLUME /tmp
ENV LANG en_US.UTF-8
ADD ./dist/ /usr/share/nginx/html/
EXPOSE 80
EXPOSE 443 | 2301_78526554/springboot-openai-chatgpt | mng_web/src/docker/Dockerfile | Dockerfile | apache-2.0 | 99 |
import Vue from 'vue';
import store from './store'
Vue.config.errorHandler = function(err, vm, info) {
Vue.nextTick(() => {
store.commit('ADD_LOGS', {
type: 'error',
message: err.message,
stack: err.stack,
info
})
if (process.env.NODE_ENV === 'development') {
console.group('>>>>>> 错误信息 >>>>>>')
console.groupEnd();
console.group('>>>>>> Vue 实例 >>>>>>')
console.groupEnd();
console.group('>>>>>> Error >>>>>>')
console.groupEnd();
}
})
} | 2301_78526554/springboot-openai-chatgpt | mng_web/src/error.js | JavaScript | apache-2.0 | 649 |
export default {
title: 'open-cjaidn Admin',
logoutTip: 'Exit the system, do you want to continue?',
submitText: 'submit',
cancelText: 'cancel',
search: 'Please input search content',
menuTip: 'none menu list',
common: {
condition: 'condition',
display: 'display',
hide: 'hide'
},
tip: {
select: 'Please select',
input: 'Please input'
},
upload: {
upload: 'upload',
tip: 'Drag files here,/'
},
date: {
start: 'Start date',
end: 'End date',
t: 'today',
y: 'yesterday',
n: 'nearly 7',
a: 'whole'
},
form: {
printBtn: 'print',
mockBtn: 'mock',
submitBtn: 'submit',
emptyBtn: 'empty'
},
crud: {
filter: {
addBtn: 'add',
clearBtn: 'clear',
resetBtn: 'reset',
cancelBtn: 'cancel',
submitBtn: 'submit'
},
column: {
name: 'name',
hide: 'hide',
fixed: 'fixed',
filters: 'filters',
sortable: 'sortable',
index: 'index',
width: 'width'
},
tipStartTitle: 'Currently selected',
tipEndTitle: 'items',
editTitle: 'edit',
copyTitle: 'copy',
addTitle: 'add',
viewTitle: 'view',
filterTitle: 'filter',
showTitle: 'showTitle',
menu: 'menu',
addBtn: 'add',
show: 'show',
hide: 'hide',
open: 'open',
shrink: 'shrink',
printBtn: 'print',
excelBtn: 'excel',
updateBtn: 'update',
cancelBtn: 'cancel',
searchBtn: 'search',
emptyBtn: 'empty',
menuBtn: 'menu',
saveBtn: 'save',
viewBtn: 'view',
editBtn: 'edit',
copyBtn: 'copy',
delBtn: 'delete'
},
login: {
title: 'Login ',
info: 'BladeX Development Platform',
tenantId: 'Please input tenantId',
username: 'Please input username',
password: 'Please input a password',
wechat: 'Wechat',
qq: 'QQ',
github: 'github',
gitee: 'gitee',
phone: 'Please input a phone',
code: 'Please input a code',
submit: 'Login',
userLogin: 'userLogin',
phoneLogin: 'phoneLogin',
thirdLogin: 'thirdLogin',
ssoLogin: 'ssoLogin',
msgText: 'send code',
msgSuccess: 'reissued code',
},
navbar: {
info: 'info',
logOut: 'logout',
userinfo: 'userinfo',
switchDept : 'switch dept',
dashboard: 'dashboard',
lock: 'lock',
bug: 'none bug',
bugs: 'bug',
screenfullF: 'exit screenfull',
screenfull: 'screenfull',
language: 'language',
notice: 'notice',
theme: 'theme',
color: 'color'
},
tagsView: {
search: 'Search',
menu: 'menu',
clearCache: 'Clear Cache',
closeOthers: 'Close Others',
closeAll: 'Close All'
}
};
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/lang/en.js | JavaScript | apache-2.0 | 2,660 |
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import elementEnLocale from 'element-ui/lib/locale/lang/en' // element-ui lang
import elementZhLocale from 'element-ui/lib/locale/lang/zh-CN'// element-ui lang
import enLocale from './en'
import zhLocale from './zh'
import { getStore } from '@/util/store'
Vue.use(VueI18n)
const Avue = window.AVUE;
const messages = {
en: {
...enLocale,
...elementEnLocale,
...Avue.locale.en,
},
zh: {
...zhLocale,
...elementZhLocale,
...Avue.locale.zh,
}
}
const i18n = new VueI18n({
locale: getStore({ name: 'language' }) || 'zh',
messages
})
export default i18n | 2301_78526554/springboot-openai-chatgpt | mng_web/src/lang/index.js | JavaScript | apache-2.0 | 638 |
export default {
title: '超级AI大脑企业管理平台',
logoutTip: '退出系统, 是否继续?',
submitText: '确定',
cancelText: '取消',
search: '请输入搜索内容',
menuTip: '没有发现菜单',
common: {
condition: '条件',
display: '显示',
hide: '隐藏'
},
tip: {
select: '请选择',
input: '请输入'
},
upload: {
upload: '点击上传',
tip: '将文件拖到此处,或'
},
date: {
start: '开始日期',
end: '结束日期',
t: '今日',
y: '昨日',
n: '近7天',
a: '全部'
},
form: {
printBtn: '打 印',
mockBtn: '模 拟',
submitBtn: '提 交',
emptyBtn: '清 空'
},
crud: {
filter: {
addBtn: '新增条件',
clearBtn: '清空数据',
resetBtn: '清空条件',
cancelBtn: '取 消',
submitBtn: '确 定'
},
column: {
name: '列名',
hide: '隐藏',
fixed: '冻结',
filters: '过滤',
sortable: '排序',
index: '顺序',
width: '宽度'
},
tipStartTitle: '当前表格已选择',
tipEndTitle: '项',
editTitle: '编 辑',
copyTitle: '复 制',
addTitle: '新 增',
viewTitle: '查 看',
filterTitle: '过滤条件',
showTitle: '列显隐',
menu: '操作',
addBtn: '新 增',
show: '显 示',
hide: '隐 藏',
open: '展 开',
shrink: '收 缩',
printBtn: '打 印',
excelBtn: '导 出',
updateBtn: '修 改',
cancelBtn: '取 消',
searchBtn: '搜 索',
emptyBtn: '清 空',
menuBtn: '功 能',
saveBtn: '保 存',
viewBtn: '查 看',
editBtn: '编 辑',
copyBtn: '复 制',
delBtn: '删 除'
},
login: {
title: '登录 ',
info: 'BladeX 企业级开发平台',
tenantId: '请输入租户ID',
username: '请输入账号',
password: '请输入密码',
wechat: '微信',
qq: 'QQ',
github: 'github',
gitee: '码云',
phone: '请输入手机号',
code: '请输入验证码',
submit: '登录',
userLogin: '账号密码登录',
phoneLogin: '手机号登录',
thirdLogin: '第三方系统登录',
ssoLogin: '单点系统登录',
msgText: '发送验证码',
msgSuccess: '秒后重发',
},
navbar: {
logOut: '退出登录',
userinfo: '个人信息',
switchDept : '部门切换',
dashboard: '首页',
lock: '锁屏',
bug: '没有错误日志',
bugs: '条错误日志',
screenfullF: '退出全屏',
screenfull: '全屏',
language: '中英文',
notice: '消息通知',
theme: '主题',
color: '换色'
},
tagsView: {
search: '搜索',
menu: '更多',
clearCache: '清除缓存',
closeOthers: '关闭其它',
closeAll: '关闭所有'
}
};
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/lang/zh.js | JavaScript | apache-2.0 | 2,811 |
import Vue from 'vue';
import axios from './router/axios';
import VueAxios from 'vue-axios';
import App from './App';
import router from './router/router';
import './permission'; // 权限
import './error'; // 日志
import store from './store';
import { loadStyle } from './util/util'
import * as urls from '@/config/env';
import Element from 'element-ui';
import {
iconfontUrl,
iconfontVersion
} from '@/config/env';
import i18n from './lang' // Internationalization
import './styles/common.scss';
import basicContainer from './components/basic-container/main'
import thirdRegister from './components/third-register/main'
import avueUeditor from 'avue-plugin-ueditor';
import website from '@/config/website';
// markdown编辑器
import mavonEditor from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'
//引入图标库
import '@/assets/css/font-awesome.min.css'
//表单设计
import formCustom from './research/components/form-custom/form-custom.vue';
//表单开发
import codeTestList from './research/views/tool/codetestlist.vue'
Vue.use(router)
Vue.use(VueAxios, axios)
Vue.use(Element, {
i18n: (key, value) => i18n.t(key, value)
})
Vue.use(window.AVUE, {
size: 'small',
tableSize: 'small',
calcHeight: 65,
i18n: (key, value) => i18n.t(key, value)
})
Vue.use(mavonEditor)
//注册全局容器
Vue.component('basicContainer', basicContainer)
Vue.component('thirdRegister', thirdRegister);
Vue.component('avueUeditor', avueUeditor);
Vue.component('formCustom', formCustom);
Vue.component('codeTestList', codeTestList);
Vue.prototype.website = website;
// 加载相关url地址
Object.keys(urls).forEach(key => {
Vue.prototype[key] = urls[key];
})
// 动态加载阿里云字体库
iconfontVersion.forEach(ele => {
loadStyle(iconfontUrl.replace('$key', ele));
})
Vue.config.productionTip = false;
new Vue({
router,
store,
i18n,
render: h => h(App)
}).$mount('#app')
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/main.js | JavaScript | apache-2.0 | 1,913 |
import { mapGetters } from "vuex";
const version = require("element-ui/package.json").version; // element-ui version from node_modules
const ORIGINAL_THEME = "#409EFF"; // default color
export default function () {
return {
data() {
return {
themeVal: ORIGINAL_THEME
}
},
created() {
this.themeVal = this.colorName;
},
watch: {
themeVal(val, oldVal) {
this.$store.commit("SET_COLOR_NAME", val);
this.updateTheme(val, oldVal);
}
},
computed: {
...mapGetters(["colorName"])
},
methods: {
updateTheme(val, oldVal) {
if (typeof val !== "string") return;
const head = document.getElementsByTagName("head")[0];
const themeCluster = this.getThemeCluster(val.replace("#", ""));
const originalCluster = this.getThemeCluster(oldVal.replace("#", ""));
const getHandler = (variable, id) => {
return () => {
const originalCluster = this.getThemeCluster(
ORIGINAL_THEME.replace("#", "")
);
const newStyle = this.updateStyle(
this[variable],
originalCluster,
themeCluster
);
let styleTag = document.getElementById(id);
if (!styleTag) {
styleTag = document.createElement("style");
styleTag.setAttribute("id", id);
head.appendChild(styleTag);
}
styleTag.innerText = newStyle;
};
};
const chalkHandler = getHandler("chalk", "chalk-style");
if (!this.chalk) {
const url = `https://unpkg.com/element-ui@${version}/lib/theme-chalk/index.css`;
this.getCSSString(url, chalkHandler, "chalk");
} else {
chalkHandler();
}
const link = [].slice.call(
document.getElementsByTagName("head")[0].getElementsByTagName("link")
);
for (let i = 0; i < link.length; i++) {
const style = link[i];
if (style.href.includes('css')) {
this.getCSSString(style.href, innerText => {
const originalCluster = this.getThemeCluster(
ORIGINAL_THEME.replace("#", "")
);
const newStyle = this.updateStyle(
innerText,
originalCluster,
themeCluster
);
let styleTag = document.getElementById(i);
if (!styleTag) {
styleTag = document.createElement("style");
styleTag.id = i;
styleTag.innerText = newStyle;
head.appendChild(styleTag);
}
});
}
}
const styles = [].slice.call(document.querySelectorAll("style"))
styles.forEach(style => {
const {
innerText
} = style;
if (typeof innerText !== "string") return;
style.innerText = this.updateStyle(
innerText,
originalCluster,
themeCluster
);
});
},
updateStyle(style, oldCluster, newCluster) {
let newStyle = style;
oldCluster.forEach((color, index) => {
newStyle = newStyle.replace(new RegExp(color, "ig"), newCluster[index]);
});
return newStyle;
},
getCSSString(url, callback, variable) {
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
if (xhr.readyState === 4 && xhr.status === 200) {
if (variable) {
this[variable] = xhr.responseText.replace(/@font-face{[^}]+}/, "");
}
callback(xhr.responseText);
}
};
xhr.open("GET", url);
xhr.send();
},
getThemeCluster(theme) {
const tintColor = (color, tint) => {
let red = parseInt(color.slice(0, 2), 16);
let green = parseInt(color.slice(2, 4), 16);
let blue = parseInt(color.slice(4, 6), 16);
if (tint === 0) {
// when primary color is in its rgb space
return [red, green, blue].join(",");
} else {
red += Math.round(tint * (255 - red));
green += Math.round(tint * (255 - green));
blue += Math.round(tint * (255 - blue));
red = red.toString(16);
green = green.toString(16);
blue = blue.toString(16);
return `#${red}${green}${blue}`;
}
};
const shadeColor = (color, shade) => {
let red = parseInt(color.slice(0, 2), 16);
let green = parseInt(color.slice(2, 4), 16);
let blue = parseInt(color.slice(4, 6), 16);
red = Math.round((1 - shade) * red);
green = Math.round((1 - shade) * green);
blue = Math.round((1 - shade) * blue);
red = red.toString(16);
green = green.toString(16);
blue = blue.toString(16);
return `#${red}${green}${blue}`;
};
const clusters = [theme];
for (let i = 0; i <= 9; i++) {
clusters.push(tintColor(theme, Number((i / 10).toFixed(2))));
}
clusters.push(shadeColor(theme, 0.1));
return clusters;
}
}
}
} | 2301_78526554/springboot-openai-chatgpt | mng_web/src/mixins/color.js | JavaScript | apache-2.0 | 5,318 |
import user from './user';
import menu from './menu';
/**
* 模拟数据mock
*
* mock是否开启模拟数据拦截
*/
user({mock: true});
menu({mock: true});
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/mock/index.js | JavaScript | apache-2.0 | 166 |
import Mock from 'mockjs'
const top = [{
label: "首页",
path: "/wel/index",
icon: 'el-icon-menu',
meta: {
i18n: 'dashboard',
},
parentId: 0
},
{
label: "测试",
icon: 'el-icon-document',
path: "/test/index",
meta: {
i18n: 'test',
},
parentId: 3
}]
export default ({mock}) => {
if (!mock) return;
Mock.mock('/user/getTopMenu', 'get', () => {
return {
data: top
}
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/mock/menu.js | JavaScript | apache-2.0 | 442 |
import Mock from 'mockjs'
export default ({ mock }) => {
if (!mock) return;
// 用户登录
Mock.mock('/user/login', 'post', {
data: new Date().getTime() + ''
});
//用户退出
Mock.mock('/user/logout', 'get', {
data: true,
});
//刷新token
Mock.mock('/user/refesh', 'post', {
data: new Date().getTime() + ''
});
//获取表格数据
Mock.mock('/user/getTable', 'get', () => {
let list = []
for (let i = 0; i < 5; i++) {
list.push(Mock.mock({
id: '@increment',
name: Mock.mock('@cname'),
username: Mock.mock('@last'),
type: [0, 2],
checkbox: [0, 1],
'number|0-100': 0,
datetime: 1532932422071,
'sex|0-1': 0,
moreselect: [0, 1],
"grade": 0,
address: Mock.mock('@cparagraph(1, 3)'),
check: [1, 3, 4]
}))
}
return {
data: {
total: 11,
pageSize: 10,
tableData: list
}
}
})
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/mock/user.js | JavaScript | apache-2.0 | 1,178 |
<template>
<div class="avue-contail"
:class="{'avue--collapse':isCollapse}">
<div class="avue-header">
<!-- 顶部导航栏 -->
<top />
</div>
<div class="avue-layout">
<div class="avue-left">
<!-- 左侧导航栏 -->
<sidebar />
</div>
<div class="avue-main">
<!-- 顶部标签卡 -->
<tags />
<!-- 主体视图层 -->
<el-scrollbar style="height:100%">
<keep-alive>
<router-view class="avue-view"
:key="$route.fullPath"
v-if="$route.meta.keepAlive" />
</keep-alive>
<router-view class="avue-view"
:key="$route.fullPath"
v-if="!$route.meta.keepAlive" />
</el-scrollbar>
</div>
</div>
<!-- <el-footer class="avue-footer">
<img src="/svg/logo.svg"
alt=""
class="logo">
<p class="copyright">© 2018 Avue designed by smallwei</p>
</el-footer> -->
<div class="avue-shade"
@click="showCollapse"></div>
</div>
</template>
<script>
import { mapGetters } from "vuex";
import tags from "./tags";
import top from "./top/";
import sidebar from "./sidebar/";
import admin from "@/util/admin";
import {validatenull} from "@/util/validate";
import {calcDate} from "@/util/date.js";
import {getStore} from "@/util/store.js";
export default {
components: {
top,
tags,
sidebar
},
name: "index",
data() {
return {
//刷新token锁
refreshLock: false,
//刷新token的时间
refreshTime: ""
};
},
created() {
//实时检测刷新token
this.refreshToken();
},
mounted() {
this.init();
},
computed: mapGetters(["isLock", "isCollapse", "website"]),
props: [],
methods: {
showCollapse() {
this.$store.commit("SET_COLLAPSE");
},
// 屏幕检测
init() {
this.$store.commit("SET_SCREEN", admin.getScreen());
window.onresize = () => {
setTimeout(() => {
this.$store.commit("SET_SCREEN", admin.getScreen());
}, 0);
};
},
// 定时检测一次token
refreshToken() {
this.refreshTime = setInterval(() => {
const token = getStore({
name: "token",
debug: true
}) || {};
const date = calcDate(token.datetime, new Date().getTime());
if (validatenull(date)) return;
if (date.seconds >= this.website.tokenTime && !this.refreshLock) {
this.refreshLock = true;
this.$store
.dispatch("RefreshToken")
.then(() => {
this.refreshLock = false;
})
.catch(() => {
this.refreshLock = false;
});
}
}, 1000);
}
}
};
</script>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/index/index.vue | Vue | apache-2.0 | 2,820 |
<template>
<router-view></router-view>
</template> | 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/index/layout.vue | Vue | apache-2.0 | 52 |
<template>
<div class="avue-logo">
<transition name="fade">
<span v-if="keyCollapse"
class="avue-logo_subtitle"
key="0">
<img src="img/bg/img-logo.png"
width="30" />
</span>
</transition>
<transition-group name="fade">
<template v-if="!keyCollapse">
<span class="avue-logo_title"
key="1">
<div>
<img src="img/bg/img-logo.png"
width="30"
alt="">{{website.indexTitle}}</div>
</span>
</template>
</transition-group>
</div>
</template>
<script>
import { mapGetters } from "vuex";
export default {
name: "logo",
data() {
return {};
},
created() {},
computed: {
...mapGetters(["website", "keyCollapse"])
},
methods: {}
};
</script>
<style lang="scss">
.fade-leave-active {
transition: opacity 0.2s;
}
.fade-enter-active {
transition: opacity 2.5s;
}
.fade-enter,
.fade-leave-to {
opacity: 0;
}
.avue-logo {
position: fixed;
top: 0;
left: 0;
width: 240px;
height: 64px;
line-height: 64px;
background-color: #20222a;
font-size: 20px;
overflow: hidden;
box-sizing: border-box;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.15);
color: rgba(255, 255, 255, 0.8);
z-index: 1024;
&_title {
display: block;
text-align: center;
font-weight: 300;
font-size: 16px;
div {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
img {
margin-right: 5px;
}
}
}
&_subtitle {
padding-top: 10px;
display: block;
text-align: center;
font-size: 18px;
font-weight: bold;
color: #fff;
}
}
</style> | 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/index/logo.vue | Vue | apache-2.0 | 1,713 |
export default {
propsDefault: {
label: 'label',
path: 'path',
icon: 'icon',
children: 'children'
}
} | 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/index/sidebar/config.js | JavaScript | apache-2.0 | 141 |
<template>
<div class="avue-sidebar">
<logo></logo>
<el-scrollbar style="height:100%">
<div v-if="validatenull(menu)"
class="avue-sidebar--tip">{{$t('menuTip')}}</div>
<el-menu unique-opened
:default-active="nowTagValue"
mode="vertical"
:show-timeout="200"
:collapse="keyCollapse">
<sidebar-item :menu="menu"
:screen="screen"
first
:props="website.menu.props"
:collapse="keyCollapse"></sidebar-item>
</el-menu>
</el-scrollbar>
</div>
</template>
<script>
import { mapGetters } from "vuex";
import logo from "../logo";
import sidebarItem from "./sidebarItem";
export default {
name: "sidebar",
components: { sidebarItem, logo },
data() {
return {};
},
created() {
this.$store.dispatch("GetMenu").then(data => {
if (data.length === 0) return;
this.$router.$avueRouter.formatRoutes(data, true);
});
},
computed: {
...mapGetters(["website", "menu", "tag", "keyCollapse", "screen"]),
nowTagValue: function() {
return this.$router.$avueRouter.getValue(this.$route);
}
},
mounted() {},
methods: {}
};
</script>
<style lang="scss" scoped>
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/index/sidebar/index.vue | Vue | apache-2.0 | 1,305 |
<template>
<div class="menu-wrapper">
<template v-for="item in menu">
<el-menu-item v-if="validatenull(item[childrenKey]) && vaildRoles(item)"
:index="item[pathKey]"
@click="open(item)"
:key="item[labelKey]"
:class="{'is-active':vaildAvtive(item)}">
<i :class="item[iconKey]"></i>
<span slot="title"
:alt="item[pathKey]">{{generateTitle(item)}}</span>
</el-menu-item>
<el-submenu v-else-if="!validatenull(item[childrenKey])&&vaildRoles(item)"
:index="item[pathKey]"
:key="item[labelKey]">
<template slot="title">
<i :class="item[iconKey]"></i>
<span slot="title"
:class="{'el-menu--display':collapse && first}">{{generateTitle(item)}}</span>
</template>
<template v-for="(child,cindex) in item[childrenKey]">
<el-menu-item :index="child[pathKey],cindex"
@click="open(child)"
:class="{'is-active':vaildAvtive(child)}"
v-if="validatenull(child[childrenKey])"
:key="child[labelKey]">
<i :class="child[iconKey]"></i>
<span slot="title">{{generateTitle(child)}}</span>
</el-menu-item>
<sidebar-item v-else
:menu="[child]"
:key="cindex"
:props="props"
:screen="screen"
:collapse="collapse"></sidebar-item>
</template>
</el-submenu>
</template>
</div>
</template>
<script>
import { mapGetters } from "vuex";
import { validatenull } from "@/util/validate";
import config from "./config.js";
export default {
name: "sidebarItem",
data() {
return {
config: config
};
},
props: {
menu: {
type: Array
},
screen: {
type: Number
},
first: {
type: Boolean,
default: false
},
props: {
type: Object,
default: () => {
return {};
}
},
collapse: {
type: Boolean
}
},
created() {},
mounted() {},
computed: {
...mapGetters(["roles"]),
labelKey() {
return this.props.label || this.config.propsDefault.label;
},
pathKey() {
return this.props.path || this.config.propsDefault.path;
},
iconKey() {
return this.props.icon || this.config.propsDefault.icon;
},
childrenKey() {
return this.props.children || this.config.propsDefault.children;
},
nowTagValue() {
return this.$router.$avueRouter.getValue(this.$route);
}
},
methods: {
generateTitle(item) {
return this.$router.$avueRouter.generateTitle(
item[this.labelKey],
(item.meta || {}).i18n
);
},
vaildAvtive(item) {
const groupFlag = (item["group"] || []).some(ele =>
this.$route.path.includes(ele)
);
return this.nowTagValue === item[this.pathKey] || groupFlag;
},
vaildRoles(item) {
item.meta = item.meta || {};
return item.meta.roles ? item.meta.roles.includes(this.roles) : true;
},
validatenull(val) {
return validatenull(val);
},
open(item) {
if (this.screen <= 1) this.$store.commit("SET_COLLAPSE");
this.$router.$avueRouter.group = item.group;
this.$router.$avueRouter.meta = item.meta;
this.$router.push({
path: this.$router.$avueRouter.getPath({
name: item[this.labelKey],
src: item[this.pathKey],
i18n: (item.meta || {}).i18n
}),
query: {
...item.query
}
});
}
}
};
</script>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/index/sidebar/sidebarItem.vue | Vue | apache-2.0 | 3,754 |
<template>
<div class="avue-tags"
v-if="showTag">
<!-- tag盒子 -->
<div v-if="contextmenuFlag"
class="avue-tags__contentmenu"
:style="{left:contentmenuX+'px',top:contentmenuY+'px'}">
<div class="item"
@click="closeOthersTags">{{$t('tagsView.closeOthers')}}</div>
<div class="item"
@click="closeAllTags">{{$t('tagsView.closeAll')}}</div>
</div>
<div class="avue-tags__box"
:class="{'avue-tags__box--close':!website.isFirstPage}">
<el-tabs v-model="active"
type="card"
@contextmenu.native="handleContextmenu"
:closable="tagLen!==1"
@tab-click="openTag"
@edit="menuTag">
<el-tab-pane :key="item.value"
v-for="item in tagList"
:label="generateTitle(item)"
:name="item.value">
</el-tab-pane>
</el-tabs>
<el-dropdown class="avue-tags__menu">
<el-button type="primary"
size="mini">
{{$t('tagsView.menu')}}
<i class="el-icon-arrow-down el-icon--right"></i>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item @click.native="closeOthersTags">{{$t('tagsView.closeOthers')}}</el-dropdown-item>
<el-dropdown-item @click.native="closeAllTags">{{$t('tagsView.closeAll')}}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</div>
</template>
<script>
import { mapGetters, mapState } from "vuex";
export default {
name: "tags",
data() {
return {
active: "",
contentmenuX: "",
contentmenuY: "",
contextmenuFlag: false
};
},
created() {},
mounted() {
this.setActive();
},
watch: {
tag() {
this.setActive();
},
contextmenuFlag() {
window.addEventListener("mousedown", this.watchContextmenu);
}
},
computed: {
...mapGetters(["tagWel", "tagList", "tag", "website"]),
...mapState({
showTag: state => state.common.showTag
}),
tagLen() {
return this.tagList.length || 0;
}
},
methods: {
generateTitle(item) {
return this.$router.$avueRouter.generateTitle(
item.label,
(item.meta || {}).i18n
);
},
watchContextmenu(event) {
if (!this.$el.contains(event.target) || event.button !== 0) {
this.contextmenuFlag = false;
}
window.removeEventListener("mousedown", this.watchContextmenu);
},
handleContextmenu(event) {
let target = event.target;
// 解决 https://github.com/d2-projects/d2-admin/issues/54
let flag = false;
if (target.className.indexOf("el-tabs__item") > -1) flag = true;
else if (target.parentNode.className.indexOf("el-tabs__item") > -1) {
target = target.parentNode;
flag = true;
}
if (flag) {
event.preventDefault();
event.stopPropagation();
this.contentmenuX = event.clientX;
this.contentmenuY = event.clientY;
this.tagName = target.getAttribute("aria-controls").slice(5);
this.contextmenuFlag = true;
}
},
//激活当前选项
setActive() {
this.active = this.tag.value;
},
menuTag(value, action) {
if (action === "remove") {
let { tag, key } = this.findTag(value);
this.$store.commit("DEL_TAG", tag);
if (tag.value === this.tag.value) {
tag = this.tagList[key === 0 ? key : key - 1]; //如果关闭本标签让前推一个
this.openTag(tag);
}
}
},
openTag(item) {
let tag;
if (item.name) {
tag = this.findTag(item.name).tag;
} else {
tag = item;
}
this.$router.push({
path: this.$router.$avueRouter.getPath({
name: tag.label,
src: tag.value,
i18n: tag.meta.i18n
}),
query: tag.query
});
},
closeOthersTags() {
this.contextmenuFlag = false;
this.$store.commit("DEL_TAG_OTHER");
},
findTag(value) {
let tag, key;
this.tagList.map((item, index) => {
if (item.value === value) {
tag = item;
key = index;
}
});
return { tag: tag, key: key };
},
closeAllTags() {
this.contextmenuFlag = false;
this.$store.commit("DEL_ALL_TAG");
this.$router.push({
path: this.$router.$avueRouter.getPath({
src: this.tagWel.value
}),
query: this.tagWel.query
});
}
}
};
</script>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/index/tags.vue | Vue | apache-2.0 | 4,609 |
<template>
<div class="avue-top">
<div class="top-bar__left">
<div class="avue-breadcrumb"
:class="[{ 'avue-breadcrumb--active': isCollapse }]"
v-if="showCollapse">
<i class="icon-navicon"
@click="setCollapse"></i>
</div>
</div>
<div class="top-bar__title">
<div class="top-bar__item top-bar__item--show"
v-if="showMenu">
<top-menu></top-menu>
</div>
<span class="top-bar__item"
v-if="showSearch">
<top-search></top-search>
</span>
</div>
<div class="top-bar__right">
<el-tooltip v-if="showColor"
effect="dark"
:content="$t('navbar.color')"
placement="bottom">
<div class="top-bar__item">
<top-color></top-color>
</div>
</el-tooltip>
<el-tooltip v-if="showDebug"
effect="dark"
:content="logsFlag?$t('navbar.bug'):logsLen+$t('navbar.bugs')"
placement="bottom">
<div class="top-bar__item">
<top-logs></top-logs>
</div>
</el-tooltip>
<el-tooltip v-if="showLock"
effect="dark"
:content="$t('navbar.lock')"
placement="bottom">
<div class="top-bar__item">
<top-lock></top-lock>
</div>
</el-tooltip>
<el-tooltip v-if="showTheme"
effect="dark"
:content="$t('navbar.theme')"
placement="bottom">
<div class="top-bar__item top-bar__item--show">
<top-theme></top-theme>
</div>
</el-tooltip>
<el-tooltip effect="dark"
:content="$t('navbar.language')"
placement="bottom">
<div class="top-bar__item top-bar__item--show">
<top-lang></top-lang>
</div>
</el-tooltip>
<el-tooltip v-if="showFullScren"
effect="dark"
:content="isFullScren?$t('navbar.screenfullF'):$t('navbar.screenfull')"
placement="bottom">
<div class="top-bar__item">
<i :class="isFullScren?'icon-tuichuquanping':'icon-quanping'"
@click="handleScreen"></i>
</div>
</el-tooltip>
<img class="top-bar__img"
:src="userInfo.avatar">
<el-dropdown>
<span class="el-dropdown-link">
{{userInfo.userName}}
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item>
<router-link to="/">{{$t('navbar.dashboard')}}</router-link>
</el-dropdown-item>
<el-dropdown-item>
<router-link to="/info/index">{{$t('navbar.userinfo')}}</router-link>
</el-dropdown-item>
<el-dropdown-item @click.native="logout"
divided>{{$t('navbar.logOut')}}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</div>
</template>
<script>
import { mapGetters, mapState } from "vuex";
import { fullscreenToggel, listenfullscreen } from "@/util/util";
import topLock from "./top-lock";
import topMenu from "./top-menu";
import topSearch from "./top-search";
import topTheme from "./top-theme";
import topLogs from "./top-logs";
import topColor from "./top-color";
import topLang from "./top-lang";
export default {
components: {
topLock,
topMenu,
topSearch,
topTheme,
topLogs,
topColor,
topLang
},
name: "top",
data() {
return {};
},
filters: {},
created() {},
mounted() {
listenfullscreen(this.setScreen);
},
computed: {
...mapState({
showDebug: state => state.common.showDebug,
showTheme: state => state.common.showTheme,
showLock: state => state.common.showLock,
showFullScren: state => state.common.showFullScren,
showCollapse: state => state.common.showCollapse,
showSearch: state => state.common.showSearch,
showMenu: state => state.common.showMenu,
showColor: state => state.common.showColor
}),
...mapGetters([
"userInfo",
"isFullScren",
"tagWel",
"tagList",
"isCollapse",
"tag",
"logsLen",
"logsFlag"
])
},
methods: {
handleScreen() {
fullscreenToggel();
},
setCollapse() {
this.$store.commit("SET_COLLAPSE");
},
setScreen() {
this.$store.commit("SET_FULLSCREN");
},
logout() {
this.$confirm(this.$t("logoutTip"), this.$t("tip"), {
confirmButtonText: this.$t("submitText"),
cancelButtonText: this.$t("cancelText"),
type: "warning"
}).then(() => {
this.$store.dispatch("LogOut").then(() => {
this.$router.push({ path: "/login" });
});
});
}
}
};
</script>
<style lang="scss" scoped>
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/index/top/index.vue | Vue | apache-2.0 | 4,942 |
<template>
<el-color-picker size="mini"
style="padding-top:18px;"
class="theme-picker"
popper-class="theme-picker-dropdown"
v-model="themeVal"></el-color-picker>
</template>
<script>
import color from "@/mixins/color";
export default {
name: "topColor",
mixins: [color()],
data() {
return {
chalk: ""
};
}
};
</script>
<style>
.theme-picker .el-color-picker__trigger {
vertical-align: middle;
}
.theme-picker-dropdown .el-color-dropdown__link-btn {
display: none;
}
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/index/top/top-color.vue | Vue | apache-2.0 | 582 |
<template>
<el-dropdown trigger="click"
@command="handleSetLanguage">
<i class="icon-zhongyingwen"></i>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :disabled="language==='zh'"
command="zh">中文
</el-dropdown-item>
<el-dropdown-item :disabled="language==='en'"
command="en">English
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
<script>
import {mapGetters} from "vuex";
export default {
name: "top-lang",
data() {
return {};
},
created() {
},
mounted() {
},
computed: {
...mapGetters(["language", "tag"])
},
props: [],
methods: {
handleSetLanguage(lang) {
this.$i18n.locale = lang;
this.$store.commit("SET_LANGUAGE", lang);
let tag = this.tag;
let title = this.$router.$avueRouter.generateTitle(
tag.label,
(tag.meta || {}).i18n
);
//根据当前的标签也获取label的值动态设置浏览器标题
this.$router.$avueRouter.setTitle(title);
}
}
};
</script>
<style lang="scss" scoped>
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/index/top/top-lang.vue | Vue | apache-2.0 | 1,189 |
<template>
<span>
<i class="icon-suoping"
@click="handleLock"></i>
<el-dialog title="设置锁屏密码"
:visible.sync="box"
width="30%"
append-to-body>
<el-form :model="form"
ref="form"
label-width="80px">
<el-form-item label="锁屏密码"
prop="passwd"
:rules="[{ required: true, message: '锁屏密码不能为空'}]">
<el-input v-model="form.passwd"
placeholder="请输入锁屏密码"></el-input>
</el-form-item>
</el-form>
<span slot="footer"
class="dialog-footer">
<el-button type="primary"
@click="handleSetLock">确 定</el-button>
</span>
</el-dialog>
</span>
</template>
<script>
import { validatenull } from "@/util/validate";
import { mapGetters } from "vuex";
export default {
name: "top-lock",
data() {
return {
box: false,
form: {
passwd: ""
}
};
},
created() {},
mounted() {},
computed: {
...mapGetters(["lockPasswd"])
},
props: [],
methods: {
handleSetLock() {
this.$refs["form"].validate(valid => {
if (valid) {
this.$store.commit("SET_LOCK_PASSWD", this.form.passwd);
this.handleLock();
}
});
},
handleLock() {
if (validatenull(this.lockPasswd)) {
this.box = true;
return;
}
this.$store.commit("SET_LOCK");
setTimeout(() => {
this.$router.push({ path: "/lock" });
}, 100);
}
},
components: {}
};
</script>
<style lang="scss" scoped>
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/index/top/top-lock.vue | Vue | apache-2.0 | 1,694 |
<template>
<span @click="logsFlag?'':handleOpen()">
<el-badge :value="logsFlag?'':logsLen"
:max="99">
<i class="icon-rizhi1"></i>
</el-badge>
<el-dialog title="日志"
fullscreen
:visible.sync="box"
width="100%"
append-to-body>
<logs></logs>
</el-dialog>
</span>
</template>
<script>
import { mapGetters } from "vuex";
import logs from "@/page/logs/index";
export default {
name: "top-logs",
components: { logs },
data() {
return {
box: false
};
},
created() {},
mounted() {},
computed: {
...mapGetters(["logsFlag", "logsLen"])
},
props: [],
methods: {
handleOpen() {
this.box = true;
}
}
};
</script>
<style lang="scss" scoped>
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/index/top/top-logs.vue | Vue | apache-2.0 | 800 |
<template>
<div class="top-menu">
<el-menu :default-active="activeIndex"
mode="horizontal"
text-color="#333">
<template v-for="(item,index) in items">
<el-menu-item :index="item.parentId+''"
@click.native="openMenu(item)"
:key="index">
<template slot="title">
<i :class="item.icon"></i>
<span>{{generateTitle(item)}}</span>
</template>
</el-menu-item>
</template>
</el-menu>
</div>
</template>
<script>
import { mapGetters } from "vuex";
export default {
name: "top-menu",
data() {
return {
activeIndex: "0",
items: []
};
},
created() {
this.getMenu();
},
computed: {
...mapGetters(["tagCurrent", "menu"])
},
methods: {
getMenu() {
this.$store.dispatch("GetTopMenu").then(res => {
this.items = res;
});
},
generateTitle(item) {
return this.$router.$avueRouter.generateTitle(
item.label,
(item.meta || {}).i18n
);
},
openMenu(item) {
this.$store.dispatch("GetMenu", item.parentId).then(data => {
if (data.length !== 0) {
this.$router.$avueRouter.formatRoutes(data, true);
}
let itemActive,
childItemActive = 0;
if (item.path) {
itemActive = item;
} else {
if (this.menu[childItemActive].length == 0) {
itemActive = this.menu[childItemActive];
} else {
itemActive = this.menu[childItemActive].children[childItemActive];
}
}
this.$router.push({
path: this.$router.$avueRouter.getPath({
name: itemActive.label,
src: itemActive.path,
i18n: itemActive.meta.i18n
})
});
});
}
}
};
</script> | 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/index/top/top-menu.vue | Vue | apache-2.0 | 1,872 |
<template>
<el-autocomplete class="top-search"
popper-class="my-autocomplete"
v-model="value"
:fetch-suggestions="querySearch"
:placeholder="$t('search')"
@select="handleSelect">
<template slot-scope="{ item }">
<i :class="[item[iconKey],'icon']"></i>
<div class="name">{{ item[labelKey] }}</div>
<div class="addr">{{ item[pathKey] }}</div>
</template>
</el-autocomplete>
</template>
<script>
import config from "../sidebar/config.js";
import { mapGetters } from "vuex";
export default {
data() {
return {
config: config,
value: "",
menuList: []
};
},
created() {
this.getMenuList();
},
watch: {
menu() {
this.getMenuList();
}
},
computed: {
labelKey() {
return this.website.menu.props.label || this.config.propsDefault.label;
},
pathKey() {
return this.website.menu.props.path || this.config.propsDefault.path;
},
iconKey() {
return this.website.menu.props.icon || this.config.propsDefault.icon;
},
childrenKey() {
return (
this.website.menu.props.children || this.config.propsDefault.children
);
},
...mapGetters(["menu", "website"])
},
methods: {
getMenuList() {
const findMenu = list => {
for (let i = 0; i < list.length; i++) {
const ele = Object.assign({}, list[i]);
if (this.validatenull(ele[this.childrenKey])) {
this.menuList.push(ele);
} else {
findMenu(ele[this.childrenKey]);
}
}
};
this.menuList = [];
findMenu(this.menu);
},
querySearch(queryString, cb) {
var restaurants = this.menuList;
var results = queryString
? restaurants.filter(this.createFilter(queryString))
: restaurants;
// 调用 callback 返回建议列表的数据
cb(results);
},
createFilter(queryString) {
return restaurant => {
return (
restaurant.label.toLowerCase().indexOf(queryString.toLowerCase()) ===
0
);
};
},
handleSelect(item) {
this.value = "";
this.$router.push({
path: this.$router.$avueRouter.getPath({
name: item[this.labelKey],
src: item[this.pathKey],
i18n: (item.meta || {}).i18n
}),
query: item.query
});
}
}
};
</script>
<style lang="scss">
.my-autocomplete {
li {
line-height: normal;
padding: 7px;
.icon {
margin-right: 5px;
display: inline-block;
vertical-align: middle;
}
.name {
display: inline-block;
text-overflow: ellipsis;
overflow: hidden;
vertical-align: middle;
}
.addr {
padding-top: 5px;
width: 100%;
font-size: 12px;
color: #b4b4b4;
}
.highlighted .addr {
color: #ddd;
}
}
}
</style> | 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/index/top/top-search.vue | Vue | apache-2.0 | 2,981 |
<template>
<div>
<el-dialog title="选择"
:visible.sync="box"
width="50%">
<el-radio-group v-model="text"
class="list">
<el-row :span="24">
<el-col v-for="(item,index) in list"
:key="index"
:md="4"
:xs="12"
:sm="4">
<el-radio :label="item.value">{{item.name}}</el-radio>
</el-col>
</el-row>
</el-radio-group>
</el-dialog>
<span>
<i class="icon-zhuti"
@click="open"></i>
</span>
</div>
</template>
<script>
import { setTheme } from "@/util/util";
import { mapGetters } from "vuex";
export default {
data() {
return {
box: false,
text: "",
list: [
{
name: "默认主题",
value: "default"
},
{
name: "白色主题",
value: "theme-white"
},
{
name: "炫彩主题",
value: "theme-star"
},
{
name: "iview主题",
value: "theme-iview"
},
{
name: "d2主题",
value: "theme-d2"
},
{
name: "hey主题",
value: "theme-hey"
}
]
};
},
watch: {
text: function(val) {
this.$store.commit("SET_THEME_NAME", val);
setTheme(val);
}
},
computed: {
...mapGetters(["themeName"])
},
mounted() {
this.text = this.themeName;
if (!this.text) {
this.text = "";
}
},
methods: {
open() {
this.box = true;
}
}
};
</script>
<style lang="scss" scoped>
.list {
width: 100%;
}
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/index/top/top-theme.vue | Vue | apache-2.0 | 1,703 |
<template>
<div class="lock-container">
<div class="lock-form animated bounceInDown">
<div class="animated"
:class="{'shake':passwdError,'bounceOut':pass}">
<h3 class="title">{{userInfo.username}}</h3>
<el-input placeholder="请输入登录密码"
type="password"
class="input-with-select animated"
v-model="passwd"
@keyup.enter.native="handleLogin">
<el-button slot="append"
icon="icon-bofangqi-suoping"
@click="handleLogin"></el-button>
<el-button slot="append"
icon="icon-tuichu"
@click="handleLogout"></el-button>
</el-input>
</div>
</div>
</div>
</template>
<script>
import { mapGetters, mapState } from "vuex";
export default {
name: "lock",
data() {
return {
passwd: "",
passwdError: false,
pass: false
};
},
created() {},
mounted() {},
computed: {
...mapState({
userInfo: state => state.user.userInfo
}),
...mapGetters(["tag", "lockPasswd"])
},
props: [],
methods: {
handleLogout() {
this.$confirm("是否退出系统, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.$store.dispatch("LogOut").then(() => {
this.$router.push({ path: "/login" });
});
});
},
handleLogin() {
if (this.passwd != this.lockPasswd) {
this.passwd = "";
this.$message({
message: "解锁密码错误,请重新输入",
type: "error"
});
this.passwdError = true;
setTimeout(() => {
this.passwdError = false;
}, 1000);
return;
}
this.pass = true;
setTimeout(() => {
this.$store.commit("CLEAR_LOCK");
this.$router.push({
path: this.$router.$avueRouter.getPath({ src: this.tag.value })
});
}, 1000);
}
},
components: {}
};
</script>
<style lang="scss">
.lock-container {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
position: relative;
.title {
margin-bottom: 8px;
color: #333;
}
}
.lock-container::before {
z-index: -999;
content: "";
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-image: url("/img/bg/login.png");
background-size: cover;
}
.lock-form {
width: 300px;
}
</style> | 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/lock/index.vue | Vue | apache-2.0 | 2,566 |
<template>
<div></div>
</template>
<script>
export default {
name: 'authredirect',
created () {
window.close()
const params = this.$route.query
const state = params.state
const code = params.code
window.opener.location.href = `${window.location.origin}/#/login?state=${state}&code=${code}`
}
}
</script>
<style>
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/login/authredirect.vue | Vue | apache-2.0 | 352 |
<template>
<el-form class="login-form"
status-icon
:rules="loginRules"
ref="loginForm"
:model="loginForm"
label-width="0">
<el-form-item prop="phone">
<el-input size="small"
@keyup.enter.native="handleLogin"
v-model="loginForm.phone"
auto-complete="off"
:placeholder="$t('login.phone')">
<i slot="prefix"
class="icon-shouji"/>
</el-input>
</el-form-item>
<el-form-item prop="code">
<el-input size="small"
@keyup.enter.native="handleLogin"
v-model="loginForm.code"
auto-complete="off"
:placeholder="$t('login.code')">
<i slot="prefix"
class="icon-yanzhengma"
style="margin-top:6px;"/>
<template slot="append">
<span @click="handleSend"
class="msg-text"
:class="[{display:msgKey}]">{{msgText}}</span>
</template>
</el-input>
</el-form-item>
<el-form-item>
<el-button size="small"
type="primary"
@click.native.prevent="handleLogin"
class="login-submit">{{$t('login.submit')}}</el-button>
</el-form-item>
</el-form>
</template>
<script>
import { isvalidatemobile } from "@/util/validate";
import { mapGetters } from "vuex";
export default {
name: "codelogin",
data() {
const validatePhone = (rule, value, callback) => {
if (isvalidatemobile(value)[0]) {
callback(new Error(isvalidatemobile(value)[1]));
} else {
callback();
}
};
const validateCode = (rule, value, callback) => {
if (value.length !== 4) {
callback(new Error("请输入4位数的验证码"));
} else {
callback();
}
};
return {
msgText: "",
msgTime: "",
msgKey: false,
loginForm: {
phone: "",
code: ""
},
loginRules: {
phone: [{ required: true, trigger: "blur", validator: validatePhone }],
code: [{ required: true, trigger: "blur", validator: validateCode }]
}
};
},
created() {
this.msgText = this.config.MSGINIT;
this.msgTime = this.config.MSGTIME;
},
mounted() {},
computed: {
...mapGetters(["tagWel"]),
config() {
return {
MSGINIT: this.$t("login.msgText"),
MSGSCUCCESS: this.$t("login.msgSuccess"),
MSGTIME: 60
};
}
},
props: [],
methods: {
handleSend() {
if (this.msgKey) return;
this.msgText = this.msgTime + this.config.MSGSCUCCESS;
this.msgKey = true;
const time = setInterval(() => {
this.msgTime--;
this.msgText = this.msgTime + this.config.MSGSCUCCESS;
if (this.msgTime === 0) {
this.msgTime = this.config.MSGTIME;
this.msgText = this.config.MSGINIT;
this.msgKey = false;
clearInterval(time);
}
}, 1000);
},
handleLogin() {
this.$refs.loginForm.validate(valid => {
if (valid) {
this.$store.dispatch("LoginByPhone", this.loginForm).then(() => {
this.$router.push({ path: this.tagWel.value });
});
}
});
}
}
};
</script>
<style>
.msg-text {
display: block;
width: 60px;
font-size: 12px;
text-align: center;
cursor: pointer;
}
.msg-text.display {
color: #ccc;
}
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/login/codelogin.vue | Vue | apache-2.0 | 3,477 |
<template>
<div class="login-container" ref="login" @keyup.enter.native="handleLogin">
<top-color v-show="false"></top-color>
<div class="login-weaper animated bounceInDown">
<!-- <div class="login-left">
<div class="login-time">{{time}}</div>
<p class="title">{{ $t('login.info') }}</p>
<img class="img" src="/img/bg/login-bg.png" alt />
</div>-->
<div class="login-border">
<div class="login-main">
<h4 class="login-title">
{{ $t('login.title') }}{{website.title}}
<!-- <top-lang></top-lang> -->
</h4>
<userLogin v-if="activeName==='user'"></userLogin>
<codeLogin v-else-if="activeName==='code'"></codeLogin>
<thirdLogin v-else-if="activeName==='third'"></thirdLogin>
<div class="login-menu">
<a href="#" @click.stop="activeName='user'">{{ $t('login.userLogin') }}</a>
<!--<a href="#" @click.stop="activeName='code'">{{ $t('login.phoneLogin') }}</a>-->
<a href="#" @click.stop="activeName='third'">{{ $t('login.thirdLogin') }}</a>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import userLogin from './userlogin'
import codeLogin from './codelogin'
import thirdLogin from './thirdlogin'
import { mapGetters, mapMutations } from 'vuex'
import { dateFormat } from '@/util/date'
import { validatenull } from '@/util/validate'
import topLang from '@/page/index/top/top-lang'
import topColor from '@/page/index/top/top-color'
import { getQueryString, getTopUrl } from '@/util/util'
import { originUrl } from '@/config/url'
export default {
name: 'login',
components: {
userLogin,
codeLogin,
thirdLogin,
topLang,
topColor,
},
data() {
return {
time: '',
activeName: 'user',
socialForm: {
tenantId: '000000',
source: '',
code: '',
state: '',
},
}
},
watch: {
$route() {
this.handleLogin()
},
},
created() {
this.handleLogin()
this.getTime()
},
mounted() {
//清除本地缓存的菜单
this.SET_MENU_ALL_NULL()
this.SET_MENU([])
},
computed: {
...mapGetters(['website', 'tagWel']),
},
props: [],
methods: {
...mapMutations(['SET_MENU_ALL_NULL', 'SET_MENU']),
getTime() {
setInterval(() => {
this.time = dateFormat(new Date())
}, 1000)
},
handleLogin() {
const topUrl = getTopUrl()
const redirectUrl = '/oauth/redirect/'
this.socialForm.source = getQueryString('source')
this.socialForm.code = getQueryString('code')
this.socialForm.state = getQueryString('state')
if (
validatenull(this.socialForm.source) &&
topUrl.includes(redirectUrl)
) {
let source = topUrl.split('?')[0]
source = source.split(redirectUrl)[1]
this.socialForm.source = source
}
if (
!validatenull(this.socialForm.source) &&
!validatenull(this.socialForm.code) &&
!validatenull(this.socialForm.state)
) {
const loading = this.$loading({
lock: true,
text: '第三方系统登录中,请稍后。。。',
spinner: 'el-icon-loading',
})
this.$store
.dispatch('LoginBySocial', this.socialForm)
.then(() => {
window.location.href = topUrl.split(redirectUrl)[0]
this.$router.push({ path: this.tagWel.value })
loading.close()
})
.catch(() => {
loading.close()
window.location.href = originUrl + '/#/login'
})
}
},
},
}
</script>
<style lang="scss">
@import '@/styles/login.scss';
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/login/index.vue | Vue | apache-2.0 | 3,766 |
<template>
<div class="social-container">
<!-- <div @click="handleClick('github')">
<span class="container" :style="{backgroundColor:'#61676D'}">
<i icon-class="github" class="iconfont icongithub"></i>
</span>
<p class="title">{{$t('login.github')}}</p>
</div>
<div @click="handleClick('gitee')">
<span class="container" :style="{backgroundColor:'#c35152'}">
<i icon-class="gitee" class="iconfont icongitee2"></i>
</span>
<p class="title">{{$t('login.gitee')}}</p>
</div>-->
<div @click="handleClick('wechat_open')">
<span class="container" :style="{backgroundColor:'#8dc349'}">
<i icon-class="wechat" class="iconfont icon-weixin" />
</span>
<p class="title">{{$t('login.wechat')}}</p>
</div>
<!-- <div @click="handleClick('qq')">
<span class="container" :style="{backgroundColor:'#6ba2d6'}">
<i icon-class="qq" class="iconfont icon-qq"/>
</span>
<p class="title">{{$t('login.qq')}}</p>
</div>-->
</div>
</template>
<script>
import website from '@/config/website'
export default {
name: 'thirdLogin',
methods: {
handleClick(source) {
window.location.href = `${website.authUrl}/${source}`
},
},
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.social-container {
margin: 20px 0;
display: flex;
align-items: center;
justify-content: space-around;
.iconfont {
color: #fff;
font-size: 30px;
}
.container {
$height: 50px;
cursor: pointer;
display: inline-block;
width: $height;
height: $height;
line-height: $height;
text-align: center;
border-radius: 4px;
margin-bottom: 10px;
}
.title {
text-align: center;
}
}
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/login/thirdlogin.vue | Vue | apache-2.0 | 1,762 |
<template>
<el-form
class="login-form"
status-icon
:rules="loginRules"
ref="loginForm"
:model="loginForm"
label-width="0"
>
<el-form-item v-if="tenantMode" prop="tenantId">
<el-input
size="small"
@keyup.enter.native="handleLogin"
v-model="loginForm.tenantId"
auto-complete="off"
:placeholder="$t('login.tenantId')"
>
<i slot="prefix" class="icon-quanxian" />
</el-input>
</el-form-item>
<el-form-item prop="username">
<el-input
size="small"
@keyup.enter.native="handleLogin"
v-model="loginForm.username"
auto-complete="off"
:placeholder="$t('login.username')"
>
<i slot="prefix" class="icon-yonghu" />
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input
size="small"
@keyup.enter.native="handleLogin"
:type="passwordType"
v-model="loginForm.password"
auto-complete="off"
:placeholder="$t('login.password')"
>
<i class="el-icon-view el-input__icon" slot="suffix" @click="showPassword" />
<i slot="prefix" class="icon-mima" />
</el-input>
</el-form-item>
<el-form-item v-if="this.website.captchaMode" prop="code">
<el-row :span="24">
<el-col :span="16">
<el-input
size="small"
@keyup.enter.native="handleLogin"
v-model="loginForm.code"
auto-complete="off"
:placeholder="$t('login.code')"
>
<i slot="prefix" class="icon-yanzhengma" />
</el-input>
</el-col>
<el-col :span="8">
<div class="login-code">
<img :src="loginForm.image" class="login-code-img" @click="refreshCode" />
</div>
</el-col>
</el-row>
</el-form-item>
<el-form-item>
<el-button
type="primary"
size="small"
@click.native.prevent="handleLogin"
class="login-submit"
>{{ $t("login.submit") }}</el-button
>
</el-form-item>
<el-dialog title="用户信息选择" append-to-body :visible.sync="userBox" width="350px">
<avue-form :option="userOption" v-model="userForm" @submit="submitLogin" />
</el-dialog>
</el-form>
</template>
<script>
import { mapGetters } from "vuex";
import { info } from "@/api/system/tenant";
import { getCaptcha } from "@/api/user";
import { getTopUrl } from "@/util/util";
export default {
name: "userlogin",
data() {
return {
tenantMode: this.website.tenantMode,
loginForm: {
//租户ID
tenantId: "000000",
//部门ID
deptId: "",
//角色ID
roleId: "",
//用户名
username: "",
//密码
password: "",
//账号类型
type: "account",
//验证码的值
code: "",
//验证码的索引
key: "",
//预加载白色背景
image:
"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
},
loginRules: {
tenantId: [{ required: false, message: "请输入租户ID", trigger: "blur" }],
username: [{ required: true, message: "请输入用户名", trigger: "blur" }],
password: [
{ required: true, message: "请输入密码", trigger: "blur" },
{ min: 1, message: "密码长度最少为6位", trigger: "blur" },
],
},
passwordType: "password",
userBox: false,
userForm: {
deptId: "",
roleId: "",
},
userOption: {
labelWidth: 70,
submitBtn: true,
emptyBtn: false,
submitText: "登录",
column: [
{
label: "部门",
prop: "deptId",
type: "select",
props: {
label: "deptName",
value: "id",
},
dicUrl: "/api/blade-system/dept/select",
span: 24,
display: false,
rules: [
{
required: true,
message: "请选择部门",
trigger: "blur",
},
],
},
{
label: "角色",
prop: "roleId",
type: "select",
props: {
label: "roleName",
value: "id",
},
dicUrl: "/api/blade-system/role/select",
span: 24,
display: false,
rules: [
{
required: true,
message: "请选择角色",
trigger: "blur",
},
],
},
],
},
};
},
created() {
this.getTenant();
this.refreshCode();
},
mounted() {},
watch: {
"loginForm.deptId"() {
const column = this.findObject(this.userOption.column, "deptId");
if (this.loginForm.deptId.includes(",")) {
column.dicUrl = `/api/blade-system/dept/select?deptId=${this.loginForm.deptId}`;
column.display = true;
} else {
column.dicUrl = "";
}
},
"loginForm.roleId"() {
const column = this.findObject(this.userOption.column, "roleId");
if (this.loginForm.roleId.includes(",")) {
column.dicUrl = `/api/blade-system/role/select?roleId=${this.loginForm.roleId}`;
column.display = true;
} else {
column.dicUrl = "";
}
},
},
computed: {
...mapGetters(["tagWel", "userInfo"]),
},
props: [],
methods: {
refreshCode() {
if (this.website.captchaMode) {
getCaptcha().then((res) => {
if (res.data.code == 200) {
const data = res.data.data;
this.loginForm.key = data.key;
this.loginForm.image = data.image;
}
});
}
},
showPassword() {
this.passwordType === ""
? (this.passwordType = "password")
: (this.passwordType = "");
},
submitLogin(form, done) {
if (form.deptId !== "") {
this.loginForm.deptId = form.deptId;
}
if (form.roleId !== "") {
this.loginForm.roleId = form.roleId;
}
this.handleLogin();
done();
},
handleLogin() {
this.$refs.loginForm.validate((valid) => {
if (valid) {
const loading = this.$loading({
lock: true,
text: "登录中,请稍后。。。",
spinner: "el-icon-loading",
});
this.$store
.dispatch("LoginByUsername", this.loginForm)
.then(() => {
if (this.website.switchMode) {
const deptId = this.userInfo.dept_id;
const roleId = this.userInfo.role_id;
if (deptId.includes(",") || roleId.includes(",")) {
this.loginForm.deptId = deptId;
this.loginForm.roleId = roleId;
this.userBox = true;
this.$store.dispatch("LogOut").then(() => {
loading.close();
});
return false;
}
}
this.$router.push({ path: this.tagWel.value });
loading.close();
})
.catch(() => {
loading.close();
this.refreshCode();
});
}
});
},
getTenant() {
let domain = getTopUrl();
// 临时指定域名,方便测试
//domain = "https://bladex.vip";
info(domain).then((res) => {
const data = res.data;
if (data.success && data.data.tenantId) {
this.tenantMode = false;
this.loginForm.tenantId = data.data.tenantId;
// this.$parent.$refs.login.style.backgroundImage = `url(${data.data.backgroundUrl})`
}
});
},
},
};
</script>
<style></style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/login/userlogin.vue | Vue | apache-2.0 | 7,953 |
<template>
<avue-crud :data="logsList"
:option="option">
<template slot="menuLeft">
<el-button type="primary"
size="small"
icon="el-icon-upload"
@click="send">上传服务器</el-button>
<el-button type="danger"
size="small"
icon="el-icon-delete"
@click="clear">清空本地日志</el-button>
</template>
<template slot-scope="scope"
slot="type">
<el-tag type="danger"
size="small">{{scope.label}}</el-tag>
</template>
<template slot-scope="props"
slot="expand">
<pre class="code">
{{props.row.stack}}
</pre>
</template>
</avue-crud>
</template>
<script>
import { mapGetters } from "vuex";
export default {
name: "errLogs",
data() {
return {
option: {
menu: false,
addBtn: false,
page: false,
border: true,
expand: true,
refreshBtn: false,
headerAlign: "center",
column: [
{
label: "类型",
prop: "type",
width: 80,
align: "center",
solt: true,
dicData: [
{
label: "bug",
value: "error"
}
]
},
{
label: "地址",
width: 200,
prop: "url",
overHidden: true
},
{
label: "内容",
prop: "message",
overHidden: true
},
{
label: "错误堆栈",
prop: "stack",
hide: true
},
{
label: "时间",
align: "center",
prop: "time",
width: 200
}
]
}
};
},
created() {},
mounted() {},
computed: {
...mapGetters(["logsList"])
},
props: [],
methods: {
send() {
this.$confirm("确定上传本地日志到服务器?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
this.$store.dispatch("SendLogs").then(() => {
this.$parent.$parent.box = false;
this.$message({
type: "success",
message: "发送成功!"
});
});
})
.catch(() => {});
},
clear() {
this.$confirm("确定清空本地日志记录?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
this.$store.commit("CLEAR_LOGS");
this.$parent.$parent.box = false;
this.$message({
type: "success",
message: "清空成功!"
});
})
.catch(() => {});
}
}
};
</script>
<style lang="scss" scoped>
.code {
font-size: 12px;
display: block;
font-family: monospace;
white-space: pre;
margin: 1em 0px;
}
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/page/logs/index.vue | Vue | apache-2.0 | 3,085 |
/**
* 全站权限配置
*
*/
import router from './router/router'
import store from './store'
import {validatenull} from '@/util/validate'
import {getToken} from '@/util/auth'
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
NProgress.configure({showSpinner: false});
const lockPage = store.getters.website.lockPage; //锁屏页
router.beforeEach((to, from, next) => {
const meta = to.meta || {};
const isMenu = meta.menu === undefined ? to.query.menu : meta.menu;
store.commit('SET_IS_MENU', isMenu === undefined);
if (getToken()) {
if (store.getters.isLock && to.path !== lockPage) { //如果系统激活锁屏,全部跳转到锁屏页
next({path: lockPage})
} else if (to.path === '/login') { //如果登录成功访问登录页跳转到主页
next({path: '/'})
} else {
//如果用户信息为空则获取用户信息,获取用户信息失败,跳转到登录页
if (store.getters.token.length === 0) {
store.dispatch('FedLogOut').then(() => {
next({path: '/login'})
})
} else {
const value = to.query.src || to.fullPath;
const label = to.query.name || to.name;
const meta = to.meta || router.$avueRouter.meta || {};
const i18n = to.query.i18n;
if (meta.isTab !== false && !validatenull(value) && !validatenull(label)) {
store.commit('ADD_TAG', {
label: label,
value: value,
params: to.params,
query: to.query,
meta: (() => {
if (!i18n) {
return meta
}
return {
i18n: i18n
}
})(),
group: router.$avueRouter.group || []
});
}
next()
}
}
} else {
//判断是否需要认证,没有登录访问去登录页
if (meta.isAuth === false) {
next()
} else {
next('/login')
}
}
})
router.afterEach(() => {
NProgress.done();
let title = store.getters.tag.label;
let i18n = store.getters.tag.meta.i18n;
title = router.$avueRouter.generateTitle(title, i18n)
//根据当前的标签也获取label的值动态设置浏览器标题
router.$avueRouter.setTitle(title);
});
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/permission.js | JavaScript | apache-2.0 | 2,305 |
<template>
<div class="code-sbulist-form">
<avue-form
ref="form"
v-if="avueFormBool"
v-loading="loading"
v-model="tableForm"
:option="formOption"
:upload-after="uploadAfter"
:upload-exceed="uploadExceedFun"
>
<!-- 自定义用户控件 -->
<template
v-for="(item, index) in viewUserControlArr"
:slot="item.fieldUserName"
slot-scope="scope"
>
<user-control
:key="index"
:tableItemVal="scope.value"
:tableItemName="item.fieldName"
:disabled="scope.disabled"
:tableItemScope="scope"
@set-form-val="setTableFormValue"
></user-control>
</template>
<!-- 自定义部门控件 -->
<template
v-for="(item, index) in viewDepartControlArr"
:slot="item.fieldDepartName"
slot-scope="scope"
>
<depart-control
:key="index"
:tableItemVal="scope.value"
:tableItemName="item.fieldName"
:disabled="scope.disabled"
:tableItemScope="scope"
@set-form-val="setTableFormValue"
></depart-control>
</template>
<!-- 自定义文件名 -->
<template
v-for="(item, index) in viewFileArr"
:slot="item.fieldName + 'Type'"
slot-scope="scope"
>
<div :key="index" style="cursor: pointer; display: flex; align-items: center">
<i class="el-icon-link"></i>
<a
style="flex: 1"
:href="scope.file.url"
>{{ viewFileNameObj[scope.file.url]?viewFileNameObj[scope.file.url]:scope.file.url }}</a>
<i
class="el-icon-close"
@click.capture.stop="codeFileControlDelFun(item.fieldName, scope)"
></i>
</div>
</template>
<!-- 自定义markdown控件表单 -->
<template
v-for="(item, index) in viewMarkdownArr"
slot-scope="scope"
:slot="item.fieldMarkDownName"
>
<mavon-editor
:ref="'moavonEditor_' + index"
@imgAdd="(pos, $file) => moavonEditorImgAdd(pos, $file, index)"
v-model="scope.value"
:key="index"
:editable="!scope.disabled"
></mavon-editor>
</template>
</avue-form>
</div>
</template>
<script>
let validateRulesAll = []
import { getDetails } from '@/api/research/code'
import DepartControl from '@/research/components/general-control/depart-control'
import UserControl from '@/research/components/general-control/user-control'
import { getUploadeFileNameApi, uploadeFileApi } from '@/api/research/codelist'
import { apiRequestHead } from '@/config/url.js'
export default {
components: {
DepartControl,
UserControl,
},
props: [
'tableType',
'boxType',
'tableAllColumnRules',
'disabled',
'tableTabName',
'tableKey',
'currDataList',
'allChangeFun',
'tableClassName',
'getParentFieldValue',
'setParentFieldValue',
'simpleDateFormat',
'tableColumnDic',
'tabObj',
'addSubRows',
'clearSubRows',
'clearThenAddRows',
],
filters: {},
data() {
return {
form: {},
loading: false,
avueFormBool: false,
tableForm: {},
formOption: {
submitBtn: false,
emptyBtn: false,
column: [],
},
allUserData: [],
allDepartData: [],
tableNeetRules: ['text', 'password', 'textarea', 'umeditor', 'markdown'], //可以校验的控件
//表单 单独占一行的控件
fieldSpanOneLine: ['image', 'file'],
// 需要字典数据的控件
viewListSelect: ['list', 'radio', 'switch', 'list_multi'],
//所有文件控件
viewFileArr: [],
viewListTreeAllData: [],
viewUserControlArr: [],
viewDepartControlArr: [],
viewFileNameObj: {},
viewMarkdownArr: [],
}
},
async mounted() {
this.loading = true
if (this.tableType == 'tab') {
let columns = this.deepClone(this.tabObj.column).filter((item) => {
if (item.prop == 'vue_info') {
return false
}
return true
})
this.viewMarkdownArr = this.tabObj.viewMarkdownArr
this.viewFileArr = this.tabObj.viewFileArr
this.viewUserControlArr = this.tabObj.viewUserControlArr
this.viewDepartControlArr = this.tabObj.viewDepartControlArr
this.formOption.column = columns.map((item) => {
if (item.alterDisplay) {
item.display = true
}
return item
})
} else {
let columns = await getDetails(this.tableTabName)
columns = columns.data.data.fieldList
let columnsObj = {}
columns.forEach((item) => {
columnsObj[item.dbFieldName] = item
})
if (this.currDataList && this.currDataList.length > 0) {
this.tableForm = this.currDataList[0]
}
this.formOption.column = this.setTableDataFun(columns, 24)
}
//处理文件名
if (this.viewFileArr.length > 0) {
this.viewFileArr.forEach((item) => {
let fieldUrl = this.tableForm[item.fieldName]
if (fieldUrl) {
let fileArr = fieldUrl.split(',')
fileArr.forEach(async (fileArrItem) => {
let fileRes = await getUploadeFileNameApi(fileArrItem)
let fileName = fileArrItem.split('/')
fileName = fileName[fileName.length - 1]
if (fileRes.data.success && fileRes.data.data) {
fileName = fileRes.data.data
}
this.viewFileNameObj = {
...this.viewFileNameObj,
[fileArrItem]: fileName,
}
})
}
})
}
this.avueFormBool = true
// 获取某个字段的下拉数据
this.form.getSelectOptions = (field) => {
let column = this.findObject(this.formOption.column, field)
if (column != -1) {
let fieldColumn = this.deepClone(column)
if (fieldColumn.dicData) {
return fieldColumn.dicData
} else {
return []
}
} else {
return []
}
}
// 设置某个字段的下拉数据
this.form.changeOptions = (field, options) => {
let column = this.findObject(this.formOption.column, field)
if (column != -1) {
if (column.props && column.props.label && column.props.value) {
let label = column.props.label
let value = column.props.value
column.dicData = options.map((item) => {
return {
[label]: item.label,
[value]: item.value,
}
})
}
}
}
// 设置表单数据
this.form.setFieldsValue = (param) => {
if (param instanceof Object && !(param instanceof Array)) {
this.tableForm = {
...this.tableForm,
...param,
}
}
}
//获取所有表单数据
this.form.getAllFieldValue = () => {
return this.tableForm
}
// 获取某个表单字段数据
this.form.getFieldValue = (field) => {
if (typeof field == 'string') {
return this.tableForm[field]
} else {
return ''
}
}
try {
let allChangeFun = this.allChangeFun
for (let key in allChangeFun) {
let column = this.findObject(this.formOption.column, key)
if (column != -1) {
let timer = ''
column.change = (event) => {
if (this.loading) {
return false
}
if (timer) {
clearTimeout(timer)
}
timer = setTimeout(() => {
try {
event.row = this.tableForm
allChangeFun[key](this, event)
} catch (error) {
console.warn(
`js增强:${this.tableKey}_onlChange方法中<${key}>字段监听异常`,
error
)
}
}, 300)
}
}
}
} catch (error) {
console.warn(error)
}
// 延迟 等待赋值完毕
setTimeout(() => {
this.loading = false
}, 1500)
},
methods: {
codeFileControlDelFun(fileName, obj) {
let arr = []
if (this.tableForm[fileName] instanceof Array) {
arr = this.tableForm[fileName]
} else {
arr = this.tableForm[fileName].split(',')
}
let fileStr = arr.filter((item) => {
return item != obj.file.url
})
fileStr.join(',')
this.tableForm[fileName] = fileStr.join(',')
},
//下载文件
downloadFile(url, name) {
var aEle = document.createElement('a') // 创建a标签
aEle.download = name // 设置下载文件的文件名
aEle.href = url // content为后台返回的下载地址
aEle.click() // 设置点击事件
},
//markdown控件上传图片方法
moavonEditorImgAdd(pos, $file, index) {
const loading = this.$loading({
lock: true,
text: '正在上传图片,请耐心等待一会~',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)',
})
var formdata = new FormData()
formdata.append('file', $file)
formdata.append('type', 0)
uploadeFileApi(formdata)
.then((res) => {
let url = res.data.data.link
this.$refs['moavonEditor_' + index][0].$img2Url(pos, url)
loading.close()
})
.catch(() => {
this.$message.error('上传图片失败,请重新上传~')
loading.close()
})
},
//校验表单方法
verifyFormFun() {
let formattingFormData = {}
for (let key in this.tableForm) {
if (this.tableForm[key] instanceof Array) {
formattingFormData[key] = this.tableForm[key].join(',')
} else {
formattingFormData[key] = this.tableForm[key]
}
}
return new Promise((resolve) => {
this.$refs.form.validate((valid, done) => {
done()
let obj = {
res: valid,
tabName: this.tableTabName,
type: this.tableType,
}
if (this.tableType == 'tab') {
obj.data = formattingFormData
} else {
obj.data = { [this.tableKey]: formattingFormData }
}
resolve(obj)
})
})
},
//设置表格弹窗表单值
setTableFormValue(obj) {
this.tableForm[obj.fieldName] = obj.value
},
//监听文件上传
uploadAfter(res, done) {
this.viewFileNameObj = {
...this.viewFileNameObj,
[res.link]: res.originalName,
}
done()
},
//文件、图片上传超过限制上传数 提示
uploadExceedFun(limit, files, fileList, column) {
this.$message({
showClose: true,
message: `<${column.label}>只允许上传${limit}个文件`,
type: 'warning',
})
},
//表格格式数据处理
setTableDataFun(obj, formSpan) {
//先对obj排序
let untreatedColumn = []
let unllOrderNum = []
for (let key in obj) {
let value = obj[key]
value.prop = key
if (value.orderNum) {
untreatedColumn.push(value)
} else {
unllOrderNum.push(value)
}
}
untreatedColumn.sort((a, b) => {
return a.orderNum - b.orderNum
})
untreatedColumn = [...untreatedColumn, ...unllOrderNum]
let tableColumn = []
untreatedColumn.forEach((item, index) => {
// 文本框 单选框 开关 日期(yyyy-MM-dd) 日期(yyyy-MM-dd HH:mm:ss) 文件 图片 下拉框 下拉多选框
// 下拉搜索框 popup弹出框 部门选择 用户选择
let columnItem = {
label: item.dbFieldTxt, //文本
prop: item.dbFieldName, //字段名
span: formSpan,
value: item.dbDefaultVal, //默认值
// 配置默认字段(防止动态修改不生效)
display: true,
hide: false,
}
if (this.disabled) {
columnItem.disabled = this.disabled
}
//单独占一行
if (this.fieldSpanOneLine.includes(item.fieldShowType)) {
columnItem.span = 24
}
columnItem.order = untreatedColumn.length - index
if (item.isReadOnly === 1) {
//只读
columnItem.readonly = true
}
if (item.isShowForm === 0) {
//表单不显示
columnItem.display = false
tableColumn.push(columnItem)
return false
}
/* ====== 控件处理 ===== */
//数据格式化
if (
[
'checkbox',
'radio',
'switch',
'list_multi',
'sel_search',
'sel_depart',
'sel_user',
].includes(item.fieldShowType)
) {
if (item.dbType == 'int') {
columnItem.dataType = 'number'
} else {
columnItem.dataType = 'string'
}
}
//配置字典
if (this.viewListSelect.includes(item.fieldShowType)) {
columnItem.props = {
label: 'title',
value: 'value',
}
if (this.tableColumnDic[item.dbFieldName]) {
columnItem.dicData = this.tableColumnDic[item.dbFieldName]
} else {
columnItem.dicData = []
}
//开关
if (item.fieldShowType == 'switch') {
columnItem.props = {}
columnItem.activeIconClass = '无'
columnItem.inactiveIconClass = '无'
let extend = ''
//判断是否自定义保存参数
if (item.fieldExtendJson) {
try {
extend = JSON.parse(item.fieldExtendJson)
} catch (error) {
console.warn(
`<${item.dbFieldTxt}>自定义参数配置错误,需要符合json格式`
)
}
}
if (extend instanceof Array && extend.length == 2) {
columnItem.dicData = [
{
label: '否',
value: extend[1],
},
{
label: '是',
value: extend[0],
},
]
} else {
columnItem.dicData = [
{
label: '否',
value: 'N',
},
{
label: '是',
value: 'Y',
},
]
}
columnItem.value = 'N'
}
}
//下拉搜索配置
if (item.fieldShowType == 'sel_search') {
//表名 存储字段值 显示字段值
if (
item.dictTable != '' &&
item.dictField != '' &&
item.dictText != ''
) {
columnItem = {
...columnItem,
dicUrl: `/api/${apiRequestHead}/sys/sys/dict/getDict/${item.dictTable},${item.dictText},${item.dictField}`,
dicFlag: true,
dicQuery: {
keyword: '',
},
props: {
label: 'title',
value: 'value',
},
dicFormatter: (res) => {
return res.data
},
}
} else {
this.$message({
message: `<${item.dbFieldTxt}>下拉搜索控件的字典配置错误,需要完整配置字典table、字典code、字典text`,
type: 'warning',
})
columnItem.dicData = []
}
}
//文件 图片
if (['image', 'file'].includes(item.fieldShowType)) {
columnItem.type = 'upload'
columnItem.action = `api/${apiRequestHead}/cgform-api/upload/file`
columnItem.propsHttp = {
res: 'data',
url: 'link',
name: 'originalName', //阿里云限制死了文件名 此配置无效 文件名只能是阿里云上的文件名 需要逻辑替换
}
columnItem.dataType = 'string'
if (item.fieldShowType == 'image') {
columnItem.listType = 'picture-card'
columnItem.accept = 'image/*'
columnItem.data = {
type: 0,
}
}
if (item.fieldShowType == 'file') {
columnItem.data = {
type: 1,
}
columnItem.slot = true
this.viewFileArr.push({
fieldName: item.dbFieldName,
})
}
}
//用户控件
if (item.fieldShowType == 'sel_user') {
columnItem = {
...columnItem,
type: 'select',
formslot: true,
multiple: true,
dicData: this.allUserData,
props: {
label: 'realName',
value: 'id',
},
}
this.viewUserControlArr.push({
fieldName: item.dbFieldName, //字段名
fieldUserName: item.dbFieldName, //字段名
})
}
//部门控件
if (item.fieldShowType == 'sel_depart') {
columnItem = {
...columnItem,
multiple: true,
type: 'select',
formslot: true,
dicData: this.allDepartData,
props: {
label: 'deptName',
value: 'id',
},
}
this.viewDepartControlArr.push({
fieldName: item.dbFieldName, //字段名
fieldDepartName: item.dbFieldName, //字段名
})
}
//处理字段类型
switch (item.fieldShowType) {
case 'text':
//文本框
columnItem.maxlength = item.dbLength
if (['Integer', 'Double'].includes(item.dbType)) {
columnItem.type = 'number'
}
break
case 'list':
columnItem.type = 'select'
//下拉框
break
case 'radio':
columnItem.type = 'radio'
//单选框
break
case 'switch':
columnItem.type = 'switch'
//开关
break
case 'date':
columnItem.type = 'date'
columnItem.format = 'yyyy-MM-dd'
columnItem.valueFormat = 'yyyy-MM-dd'
//日期(yyyy-MM-dd)
break
case 'datetime':
columnItem.type = 'datetime'
columnItem.format = 'yyyy-MM-dd HH:mm:ss'
columnItem.valueFormat = 'yyyy-MM-dd HH:mm:ss'
//日期(yyyy-MM-dd HH:mm:ss)
break
case 'list_multi':
columnItem.type = 'select'
columnItem.multiple = true
//下拉多选框
break
case 'sel_search':
columnItem.type = 'select'
columnItem.filterable = true
//下拉搜索框
break
default:
break
}
//扩展参数
if (item.fieldExtendJson && !['switch'].includes(item.fieldShowType)) {
let extend = ''
let extendBool = true
try {
extend = JSON.parse(item.fieldExtendJson)
} catch (error) {
extendBool = false
}
for (let key in extend) {
if (
key == 'uploadnum' &&
['image', 'file'].includes(item.fieldShowType)
) {
//限制上传文件或者图片个数
columnItem.limit = extend[key] - 0
} else {
columnItem[key] = extend[key]
}
}
if (!extendBool) {
this.$message({
message:
'请为<' +
item.dbFieldTxt +
'>配置正确格式的扩展参数(例:{"uploadnum":2})',
duration: 5000,
type: 'warning',
})
}
}
//处理校验规则
columnItem.rules = []
if (item.fieldValidType) {
let rules = this.tableAllColumnRules[item.fieldValidType]
? this.tableAllColumnRules[item.fieldValidType]
: {}
if (
rules.pattern != 'only' &&
this.tableNeetRules.includes(item.fieldShowType) &&
rules.type.includes(item.dbType)
) {
let reg = new RegExp(rules.pattern)
validateRulesAll[item.dbFieldName] = (rule, value, callback) => {
if (!reg.test(value)) {
callback(new Error(rules.msg))
} else {
callback()
}
}
} else {
validateRulesAll[item.dbFieldName] = (rule, value, callback) => {
callback()
}
}
columnItem.rules = [
{
validator: validateRulesAll[item.dbFieldName],
trigger: 'blur',
},
]
}
if (item.fieldMustInput == '1') {
columnItem.rules.push({
required: true,
trigger: 'blur',
message: '值不能为空',
})
}
//处理字典
tableColumn.push(columnItem)
})
return tableColumn
},
//添加数据
addSubListData(rows) {
this.tableForm = {
...this.tableForm,
...rows,
}
},
//清除数据
clearSubListData() {
for (let key in this.tableForm) {
this.tableForm[key] = ''
}
},
},
}
</script>
<style>
</style> | 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/components/code-list/code-sublist-form.vue | Vue | apache-2.0 | 21,872 |
<template>
<div class="code-sbulist-table" :class="{'code-sbulist-table-height':tableType=='expand'}">
<avue-crud
ref="crud"
:option="tableOption"
:data="tableData"
:search.sync="tableQueryData"
:page.sync="tablePage"
:permission="tablePermission"
:row-class-name="tableRowClassNameFun"
:table-loading="loading"
@selection-change="selectionChangeFun"
@row-click="tableRowClickFun"
@current-change="currentChangeFun"
@size-change="sizeChangeFun"
@row-save="rowSaveFun"
@row-update="rowUpdateFun"
>
<!-- 菜单自定义(表格上面的按钮栏) -->
<template slot="menuLeft">
<!-- 左边按钮插槽 -->
<el-button
v-for="item in customButtonTop"
:key="item.id"
size="small"
type="primary"
@click="
allCustomButtonFun(item.buttonCode, item.buttonStyle, item.optType, that)
"
>
<i v-if="item.buttonIcon" :class="item.buttonIcon" style="margin-right:5px"></i>
{{ item.buttonName }}
</el-button>
<el-button
size="small"
type="primary"
icon="el-icon-delete"
@click="deleteAllSelectData"
v-show="tableSelectIndex.length"
>批量删除</el-button>
</template>
<!-- 操作列按钮插槽 -->
<template slot-scope="scope" slot="menu">
<el-button
v-for="item in customButtonLink"
:key="item.id"
type="text"
:icon="item.buttonIcon"
size="small"
@click.stop="moreButtonCommand({
type: item.buttonCode,
row: scope.row,
index: scope.index,
buttonCode: item.buttonCode,
buttonStyle: item.buttonStyle,
optType: item.optType,
that,
})"
>{{ item.buttonName }}</el-button>
</template>
<!-- 自定义图片控件 -->
<template
v-for="(item, index) in viewImageArr"
:slot="item.fieldImageName + 'Form'"
slot-scope="scope"
>
<div :key="index" class="code-sbulist-custom-image-box">
<div
class="box-btn"
v-if="scope.row[item.fieldName]==undefined || scope.row[item.fieldName].length <= 0"
>
<div v-if="disabled">无图片</div>
<el-upload
v-else
:action="item.column.action"
:before-upload="(file)=>customUploadFun(file,scope,item,'image')"
>
<el-button size="small" plain icon="el-icon-upload">上传图片</el-button>
</el-upload>
</div>
<div class="box-content" v-else @click="opentDialogUploadeFun('image', item, scope.row)">
<div class="content-img">
<img :src="scope.row[item.fieldName].split(',')[0]" alt />
</div>
<div
class="content-num"
v-if="scope.row[item.fieldName].split(',').length > 1"
>+{{ scope.row[item.fieldName].split(',').length - 1 }}</div>
<div class="content-icon">
<i class="el-icon-setting"></i>
</div>
</div>
</div>
</template>
<!-- 自定义文件控件 -->
<template
v-for="(item, index) in viewFileArr"
:slot="item.fieldFileName + 'Form'"
slot-scope="scope"
>
<div :key="index" class="code-sbulist-custom-file-box">
<div
class="box-btn"
v-if="scope.row[item.fieldName]==undefined ||scope.row[item.fieldName].length <= 0"
>
<div v-if="disabled">无文件</div>
<el-upload
v-else
:action="item.column.action"
:before-upload="(file)=>customUploadFun(file,scope,item,'file')"
>
<el-button size="small" plain icon="el-icon-upload">上传文件</el-button>
</el-upload>
</div>
<div class="box-content" v-else @click="opentDialogUploadeFun('file', item, scope.row)">
<i class="el-icon-link"></i>
<span
class="content-txt"
>{{ scope.row['$Name'+item.fieldName]?scope.row['$Name'+item.fieldName][0]:scope.row[item.fieldName]}}</span>
<span
class="content-num"
v-if="scope.row[item.fieldName].split(',').length > 1"
>+{{ scope.row[item.fieldName].split(',').length - 1 }}</span>
<i class="el-icon-setting"></i>
</div>
</div>
</template>
<!-- 自定义用户控件 -->
<template
v-for="(item, index) in viewUserControlArr"
:slot="item.fieldUserName + 'Form'"
slot-scope="scope"
>
<user-control
:key="index"
:tableItemVal="scope.row[item.fieldName]"
:tableItemName="item.fieldName"
:allUser="allUserData"
:disabled="disabled"
:allDepart="allDepartData"
:tableItemScope="scope"
exhibitionType="tableEdit"
@set-form-val="(obj) => setTableFormValue(obj, scope.row.$index)"
></user-control>
</template>
<!-- 自定义部门控件 -->
<template
v-for="(item, index) in viewDepartControlArr"
:slot="item.fieldDepartName + 'Form'"
slot-scope="scope"
>
<depart-control
:key="index"
:tableItemVal="scope.row[item.fieldName]"
:tableItemName="item.fieldName"
:allDepart="allDepartData"
:disabled="disabled"
:tableItemScope="scope"
@set-form-val="(obj) => setTableFormValue(obj, scope.row.$index)"
></depart-control>
</template>
</avue-crud>
<table-tree
ref="table_tree"
v-if="isTableTreeControl"
:optionData="tableTreeControlOption"
:treeControlFun="treeControlFun.bind(this)"
></table-tree>
<table-select
ref="table_select"
v-if="isTableSelectControl"
:optionData="tableSelectControlOption"
:selectControlFun="selectControlFun.bind(this)"
></table-select>
<form-view
ref="form_view"
v-if="isFormViewControl"
:formOptionData="FormViewControlOption"
:formViewControlFun="formViewControlFun.bind(this)"
></form-view>
<el-dialog
v-dialogdrag
:title="dialogTitle"
:visible.sync="isDialog"
class="sbulist-table-dialog-box"
:modal-append-to-body="false"
:append-to-body="true"
:before-close="dialogBeforeClose"
width="655px"
>
<avue-form
v-model="dialogFormData"
:option="dialogFormOption"
:upload-after="uploadAfter"
:upload-exceed="uploadExceedFun"
>
<template
v-if="dialogFormOption.column[0].accept != 'image/*'"
:slot="dialogFormOption.column[0].prop + 'Type'"
slot-scope="scope"
>
<div @click="downloadFile(scope.file.url,scope.file.name)" style="cursor: pointer">
<i class="el-icon-link"></i>
<span
style="flex: 1"
>{{dialogFormData['$Name'+dialogFormOption.column[0].prop]?dialogFormData['$Name'+dialogFormOption.column[0].prop][scope.file.uid]:dialogFormData[dialogFormOption.column[0].prop]}}</span>
<i
class="el-icon-close"
v-if="!disabled"
@click.capture.stop="
codeFileControlDelFun(dialogFormOption.column[0].prop, scope)
"
></i>
</div>
</template>
</avue-form>
<div slot="footer" class="dialog-footer">
<el-button @click="isDialog = false">取 消</el-button>
<el-button type="primary" @click="saveDialogUploadeDataFun">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
let validateRulesAll = []
let viewFileNameObj = {} //存储所有文件名
import { analysisFunction } from '@/research/util/myUtil.js'
import { apiRequestHead } from '@/config/url.js'
import { getDetails } from '@/api/research/code'
import {
getFormHeadApi,
getActionApi,
postActionApi,
deleteActionApi,
} from '@/api/research/codelist'
import { uploadeFileApi, getUploadeFileNameApi } from '@/api/research/codelist'
import DepartControl from '@/research/components/general-control/depart-control'
import UserControl from '@/research/components/general-control/user-control'
import TableTree from '@/research/components/general-control/table-tree.vue'
import TableSelect from '@/research/components/general-control/table-select.vue'
import FormView from '@/research/components/general-control/form-view.vue'
export default {
components: {
DepartControl,
UserControl,
TableTree,
TableSelect,
FormView,
},
props: [
'boxType',
'tableAllColumnRules',
'disabled',
'tableTabName',
'tableKey',
'currDataList',
'allChangeFun',
'getParentFieldValue',
'setParentFieldValue',
'simpleDateFormat',
'tableColumnDic',
'tableColumn',
'tableType',
'showMenu',
'sortCustomButtonFun',
'opentJsEnhance',
'formParentDataId',
],
filters: {},
data() {
return {
that: null,
apiHeadData: {},
tablePermission: {}, //权限控制
loading: false,
table: {},
tableData: [],
tableAllData: [],
tableOption: {
addBtn: false,
addRowBtn: true,
menu: false,
border: true,
columnBtn: false,
refreshBtn: false,
index: true, //开启序号
selection: true, //开启选择框
reserveSelection: true, //保留之前的勾选
tip: false,
dialogFullscreen: false, //是否全屏
rowKey: '$index',
column: [],
},
tableIsPage: false,
tablePage: {},
// 自定义搜索
searchFormOption: {
column: [],
},
tableQueryData: {}, //搜索条件
currRow: {},
allUserData: [],
allDepartData: [],
tableNeetRules: ['text', 'password', 'textarea', 'umeditor', 'markdown'], //可以校验的控件
//表单 单独占一行的控件
fieldSpanOneLine: ['image', 'file'],
// 需要字典数据的控件
viewListSelect: ['list', 'radio', 'switch', 'list_multi', 'sel_search'],
//所有图片
viewImageArr: [],
//所有文件控件
viewFileArr: [],
viewListTreeAllData: [],
viewUserControlArr: [],
viewDepartControlArr: [],
//弹窗
isDialog: false,
dialogTitle: '上传图片',
dialogFormOption: {
submitBtn: false,
emptyBtn: false,
column: [{}],
},
dialogFormData: {},
currentDialogField: {}, //当前弹窗操作的字段
validateIndex: 0,
rowClassNameBeginIndex: 2,
tableSelectData: [],
tableSelectIndex: [],
//自定义按钮
customButtonTop: [],
customButtonLink: [],
customOnlineEnhanceJsList: {}, //js增强list所有方法
//js增强方法名
customOnlineEnhanceJsName: {
list: [],
},
//用于显示树表格组件
isTableTreeControl: false,
tableTreeControlOption: {
tableId: '',
defaultTree: [],
stopTree: [],
isDialog: false,
defaultProps: {},
defaulKey: '',
title: '',
addType: {
type: '',
tableId: '',
},
asyncTableName: '',
},
//用于显示表格选择组件
isTableSelectControl: false,
tableSelectControlOption: {
title: '',
isDialog: false,
width: '',
tableId: '',
option: {},
multiple: '',
isPage: '',
addType: {
type: '',
tableId: '',
isCell: '',
},
},
//用于显示表单显示组件
isFormViewControl: false,
FormViewControlOption: {
viewObj: {},
formId: '',
formOpenType: '',
actionData: {},
btnPermissions: {},
},
}
},
async mounted() {
this.loading = true
this.that = this
let detailsRes = ''
if (this.tableType == 'expand') {
detailsRes = this.tableColumn
} else {
detailsRes = await getDetails(this.tableTabName)
}
let columns = detailsRes.data.data.fieldList
let headData = detailsRes.data.data.head
let columnsObj = {}
columns.forEach((item) => {
columnsObj[item.dbFieldName] = item
})
if (this.currDataList && this.tableType != 'expand') {
if (!this.disabled && !this.showMenu) {
this.tableData = this.currDataList.map((item) => {
item.$cellEdit = true
return item
})
} else {
this.tableData = this.deepClone(this.currDataList)
}
}
//判断是否需要显示头部按钮 操作列
if (this.showMenu) {
this.tableOption = {
...this.tableOption,
menu: true,
columnBtn: false,
addBtn: true,
addRowBtn: false,
}
}
let headObjKeys = Object.keys(headData)
let formSpan = 24 //表单列布局 span属性
headObjKeys.forEach((item) => {
let value = headData[item]
switch (item) {
case 'formTemplate':
formSpan = formSpan / (value - 0)
break
case 'isCheckbox':
if (value === 'Y' && this.tableType != 'expand') {
this.tableOption.selection = true
this.tableOption.reserveSelection = true
} else {
this.tableOption = {
...this.tableOption,
index: false,
selection: false,
reserveSelection: false,
}
}
break
case 'isPage':
if (value === 'Y' && this.tableType == 'expand') {
this.tableIsPage = true
this.tablePage = {
total: 0,
currentPage: 1,
pageSize: 5,
pageSizes: [5],
background: true,
layout: 'sizes, prev, pager, next, jumper,total',
}
}
break
case 'isDesForm':
if (value === 'Y') {
this.tableOption.addBtn = false
}
break
case 'hideHeader':
if (value === 'Y') {
this.tableOption.header = false
}
break
case 'hideMenu':
if (value === 'Y') {
this.tableOption.menu = false
}
break
default:
break
// desFormCode 表单编码 作用未知
}
})
if (this.tableType == 'expand') {
await new Promise((resolve) => {
setInterval(() => {
if (this.currDataList != undefined) {
resolve(true)
}
}, 500)
})
this.tableAllData = this.currDataList
this.tablePage.total = this.tableAllData.length
this.tablePageFun()
}
if (this.showMenu) {
this.tableOption.column = this.setTableDataFun(
columnsObj,
formSpan,
false
)
} else {
this.tableOption.column = this.setTableDataFun(columnsObj, formSpan)
}
// 数据处理
let fileArr = []
if (this.viewFileArr.length > 0) {
this.viewFileArr.forEach((item) => {
fileArr.push(item.fieldName)
})
}
this.tableData.forEach((item, index) => {
//处理文件名
if (fileArr.length > 0) {
fileArr.forEach((fileItem) => {
if (item[fileItem] != '' && item[fileItem] != undefined) {
this.tableData[index]['$Name' + fileItem] = []
item[fileItem].split(',').forEach(async (resItem) => {
let fileRes = await getUploadeFileNameApi(resItem)
let fileName = resItem.split('/')
fileName = fileName[fileName.length - 1]
if (fileRes.data.success && fileRes.data.data) {
fileName = fileRes.data.data
}
this.tableData[index]['$Name' + fileItem] = [
...this.tableData[index]['$Name' + fileItem],
fileName,
]
this.$refs.crud.columnInit()
})
}
})
}
})
if (this.disabled) {
this.tableOption.header = false
this.tableOption.addRowBtn = false
}
let allChangeFun = this.allChangeFun
// js增强 值变化方法
if (allChangeFun instanceof Object) {
for (let key in allChangeFun) {
let column = this.findObject(this.tableOption.column, key)
if (column != -1) {
let timer = ''
column.change = (event) => {
if (this.loading) {
return false
}
if (timer) {
clearTimeout(timer)
}
timer = setTimeout(() => {
try {
let currRow = this.deepClone(this.currRow)
event.row = currRow.row
event.target = currRow.event
allChangeFun[key](this, event)
} catch (error) {
console.warn(
`js增强:${this.tableKey}_onlChange方法中<${key}>字段监听异常`,
error
)
}
}, 300)
}
}
}
}
this.table.setFieldsValue = (param, index) => {
if (
param instanceof Object &&
!(param instanceof Array) &&
index < this.tableData.length
) {
this.tableData = this.tableData.map((item) => {
if (item.$index == index) {
item = {
...item,
...param,
}
}
return item
})
}
}
if (this.showMenu || this.opentJsEnhance) {
getFormHeadApi({ headId: this.tableTabName }).then((res) => {
// 获取自定义按钮
let columsData = res.data.data
this.apiHeadData = columsData
let allCustomButton = []
if (columsData.cgButtonList) {
allCustomButton = [...allCustomButton, ...columsData.cgButtonList]
}
if (allCustomButton.length >= 0) {
let buttonObj = this.sortCustomButtonFun(allCustomButton)
this.customButtonTop = buttonObj.top
this.customButtonLink = buttonObj.link
}
// 获取自定义js增强
this.initOnlineEnhanceJs(columsData.enhanceJs)
})
}
setTimeout(() => {
this.loading = false
}, 1500)
},
methods: {
//分页逻辑
tablePageFun() {
let { pageSize, currentPage } = this.tablePage
if (!this.tableIsPage || this.tablePage.total <= pageSize) {
this.tableData = this.tableAllData
return false
}
let num = currentPage * pageSize - 1
let numArr = []
for (let index = num - (pageSize - 1); index <= num; index++) {
numArr.push(index)
}
this.tableData = []
this.tableAllData.forEach((item, index) => {
if (numArr.includes(index)) {
this.tableData.push(item)
}
})
},
// 切换页
currentChangeFun(page) {
this.tablePage.currentPage = page
this.tablePageFun()
},
// 切换每页显示数
sizeChangeFun(pageSize) {
this.tablePage.currentPage = 1
this.tablePage.pageSize = pageSize
this.tablePageFun()
},
codeFileControlDelFun(fileName, obj) {
let arr = []
if (this.dialogFormData[fileName] instanceof Array) {
arr = this.dialogFormData[fileName]
} else {
arr = this.dialogFormData[fileName].split(',')
}
let fileStr = arr.filter((item) => {
return item != obj.file.url
})
fileStr.join(',')
this.dialogFormData[fileName] = fileStr.join(',')
},
//当前点击行数据方法
tableRowClickFun(row, column, event) {
setTimeout(() => {
this.currRow = {
row,
column,
event,
}
}, 300)
},
//下载文件
downloadFile(url, name) {
var aEle = document.createElement('a') // 创建a标签
aEle.download = name // 设置下载文件的文件名
aEle.href = url // content为后台返回的下载地址
aEle.click() // 设置点击事件
},
//上传文件 图片
customUploadFun(file, scope, item, type) {
let formdata = new FormData()
formdata.append('file', file)
if (type == 'file') {
formdata.append('type', 1)
} else {
formdata.append('type', 0)
}
uploadeFileApi(formdata)
.then((res) => {
let url = res.data.data.link
let name = res.data.data.originalName
this.tableData[scope.row.$index][item.column.prop] = url
if (type == 'file') {
this.tableData[scope.row.$index]['$Name' + item.column.prop] = [
name,
]
}
})
.catch(() => {
this.$message.error(
`上传${type == 'file' ? '文件' : '图片'}失败,请重新上传~`
)
})
return false
},
//设置所有文件名
setAllFileNameFun() {
this.viewFileArr.forEach(async (item) => {
this.tableData.forEach(async (dataItem) => {
let fieldUrl = dataItem[item.fieldName]
if (fieldUrl) {
let fileRes = await getUploadeFileNameApi(fieldUrl)
let fileName = fieldUrl.split('/')
fileName = fileName[fileName.length - 1]
if (fileRes.data.success && fileRes.data.data) {
fileName = fileRes.data.data
}
viewFileNameObj[fieldUrl] = fileName
}
})
})
},
//批量删除
deleteAllSelectData() {
if (this.tableSelectIndex.length <= 0) {
this.$message({
message: '请先选择需要删除的数据~',
type: 'warning',
})
return false
}
this.tableData = this.tableData.filter((item) => {
if (this.tableSelectIndex.includes(item.$index)) {
return false
} else {
return true
}
})
this.$refs.crud.toggleSelection('')
},
//选择
selectionChangeFun(column) {
// column 所有选择数据的数组
this.tableSelectData = column
let indexArr = []
column.forEach((item) => {
indexArr.push(item.$index)
})
this.tableSelectIndex = indexArr
},
tableRowClassNameFun({ rowIndex }) {
return `code-sublist-table-row-${rowIndex}`
},
//关闭弹窗前 重置表单数据
dialogBeforeClose(done) {
this.dialogFormData[this.currentDialogField.fieldName] = []
done()
},
//保存弹窗上传的文件或图片方法
saveDialogUploadeDataFun() {
let fileArr = this.deepClone(
this.dialogFormData[this.currentDialogField.fieldName]
)
if (fileArr instanceof Array) {
fileArr = fileArr.join(',')
}
this.tableData[this.currentDialogField.index][
this.currentDialogField.fieldName
] = fileArr
if (this.currentDialogField.type == 'file') {
let fileNameArr = this.deepClone(
this.dialogFormData['$Name' + this.currentDialogField.fieldName]
)
this.tableData[this.currentDialogField.index][
'$Name' + this.currentDialogField.fieldName
] = fileNameArr
}
this.isDialog = false
},
//打开图片或文件 弹窗
opentDialogUploadeFun(type, item, row) {
this.dialogFormOption.column = []
this.dialogFormData[item.fieldName] = this.deepClone(row[item.fieldName])
this.dialogFormData['$Name' + item.fieldName] = this.deepClone(
row['$Name' + item.fieldName]
)
this.currentDialogField = {
fieldName: item.fieldName,
index: row.$index,
type,
}
this.dialogFormOption.column = [
...this.dialogFormOption.column,
item.column,
]
if (type == 'image') {
this.dialogTitle = '上传图片'
}
if (type == 'file') {
this.dialogTitle = '上传文件'
}
this.isDialog = true
},
//图片上传成功
customImgUploadSuccessFun(response, scope, fieldName) {
this.tableData[scope.row.$index][fieldName] = [response.result.data.lj]
},
//图片上传失败
customImgUploadErrorFun(err, file, fileList) {
},
//校验表格数据方法
verifyFormFun() {
return new Promise((resolve) => {
if (this.tableData.length <= 0) {
resolve({
res: true,
tabName: this.tableTabName,
data: { [this.tableKey]: [] },
})
return false
}
let resObj = {}
this.$refs.crud.validateCellForm().then((res) => {
let resJson = JSON.stringify(res)
if (resJson == '{}' || this.showMenu) {
//校验成功
resObj.res = true
} else {
//校验失败
resObj.res = false
}
let allData = this.deepClone(this.tableData)
allData = allData.map((item) => {
let formattingFormData = {}
for (let key in item) {
if (item[key] instanceof Array) {
formattingFormData[key] = item[key].join(',')
} else {
formattingFormData[key] = item[key]
}
}
return formattingFormData
})
resObj = {
...resObj,
tabName: this.tableTabName,
data: { [this.tableKey]: allData },
}
resolve(resObj)
})
})
},
//设置表格弹窗表单值
setTableFormValue(obj, index) {
this.tableData[index][obj.fieldName] = obj.value
},
//监听文件上传
uploadAfter(res, done, loading, column) {
if (column.accept == '*/*') {
if (this.dialogFormData['$Name' + column.prop] instanceof Array) {
this.dialogFormData['$Name' + column.prop].push(res.originalName)
} else {
this.dialogFormData['$Name' + column.prop] = [res.originalName]
}
}
done()
},
//文件、图片上传超过限制上传数 提示
uploadExceedFun(limit, files, fileList, column) {
this.$message({
showClose: true,
message: `<${column.label}>只允许上传${limit}个文件`,
type: 'warning',
})
},
//表格格式数据处理
setTableDataFun(obj, formSpan, isCell = true) {
//先对obj排序
let untreatedColumn = []
let unllOrderNum = []
for (let key in obj) {
let value = obj[key]
value.prop = key
if (value.orderNum) {
untreatedColumn.push(value)
} else {
unllOrderNum.push(value)
}
}
untreatedColumn.sort((a, b) => {
return a.orderNum - b.orderNum
})
untreatedColumn = [...untreatedColumn, ...unllOrderNum]
let tableColumn = []
untreatedColumn.forEach((item, index) => {
// 文本框 单选框 开关 日期(yyyy-MM-dd) 日期(yyyy-MM-dd HH:mm:ss) 文件 图片 下拉框 下拉多选框
// 下拉搜索框 popup弹出框 部门选择 用户选择
let columnItem = {
label: item.dbFieldTxt, //文本
prop: item.dbFieldName, //字段名
span: formSpan,
value: item.fieldDefaultValue, //默认值
minWidth: item.fieldLength,
// 配置默认字段(防止动态修改不生效)
display: true,
hide: false,
}
if (isCell) {
columnItem.cell = true
}
if (this.disabled) {
columnItem.disabled = this.disabled
}
columnItem.order = untreatedColumn.length - index
if (item.isReadOnly === 1) {
//只读
columnItem.readonly = true
}
//表单不显示
if (item.isShowForm === 0 && this.showMenu == true) {
columnItem.display = false
}
if (item.isShowList === 0) {
//列表不显示
columnItem.hide = true
if (!this.showMenu) {
tableColumn.push(columnItem)
return false
}
}
/* ====== 控件处理 ===== */
//数据格式化
if (
[
'radio',
'switch',
'list_multi',
'sel_search',
'sel_depart',
'sel_user',
].includes(item.fieldShowType)
) {
if (item.dbType == 'int') {
columnItem.dataType = 'number'
} else {
columnItem.dataType = 'string'
}
}
//配置字典
if (this.viewListSelect.includes(item.fieldShowType)) {
columnItem.props = {
label: 'title',
value: 'value',
}
if (this.tableColumnDic[item.dbFieldName]) {
columnItem.dicData = this.tableColumnDic[item.dbFieldName]
} else {
columnItem.dicData = []
}
//开关
if (item.fieldShowType == 'switch') {
if (
columnItem.value !== '' &&
columnItem.value !== undefined &&
typeof columnItem.value == 'string'
) {
columnItem.value = Number(columnItem.value)
}
columnItem.props = {}
columnItem.activeIconClass = '无'
columnItem.inactiveIconClass = '无'
let extend = ''
//判断是否自定义保存参数
if (item.fieldExtendJson) {
try {
extend = JSON.parse(item.fieldExtendJson)
} catch {
console.warn(
`<${item.dbFieldTxt}>自定义参数配置错误,需要符合json格式`
)
}
}
if (extend instanceof Array && extend.length == 2) {
columnItem.dicData = [
{
label: '否',
value: extend[1],
},
{
label: '是',
value: extend[0],
},
]
if (columnItem.value === '' || columnItem.value === undefined) {
columnItem.value = extend[0]
}
} else {
columnItem.dicData = [
{
label: '否',
value: 'N',
},
{
label: '是',
value: 'Y',
},
]
if (columnItem.value === '' || columnItem.value === undefined) {
columnItem.value = 'N'
}
}
}
}
//用户控件
if (item.fieldShowType == 'sel_user') {
columnItem = {
...columnItem,
type: 'select',
formslot: true,
multiple: true,
dicData: this.allUserData,
props: {
label: 'realName',
value: 'id',
},
minWidth: 150,
}
this.viewUserControlArr.push({
fieldName: item.dbFieldName, //字段名
fieldUserName: item.dbFieldName, //字段名
})
}
//部门控件
if (item.fieldShowType == 'sel_depart') {
columnItem = {
...columnItem,
multiple: true,
type: 'select',
formslot: true,
dicData: this.allDepartData,
props: {
label: 'deptName',
value: 'id',
},
minWidth: 150,
}
this.viewDepartControlArr.push({
fieldName: item.dbFieldName, //字段名
fieldDepartName: item.dbFieldName, //字段名
})
}
//处理字段类型
switch (item.fieldShowType) {
case 'text':
//文本框
columnItem.maxlength = item.dbLength
if (['int', 'Double'].includes(item.dbType)) {
columnItem.type = 'number'
}
break
case 'list':
columnItem.type = 'select'
columnItem.minWidth = 150
//下拉框
break
case 'textarea':
columnItem.type = 'textarea'
columnItem.minRows = 2
if (this.showMenu) {
columnItem.span = 24
}
//下拉框
break
case 'radio':
columnItem.type = 'radio'
columnItem.minWidth = 110
//单选框
break
case 'switch':
columnItem.type = 'switch'
//开关
break
case 'date':
columnItem.type = 'date'
columnItem.format = 'yyyy-MM-dd'
columnItem.valueFormat = 'yyyy-MM-dd'
columnItem.minWidth = 160
//日期(yyyy-MM-dd)
break
case 'datetime':
columnItem.type = 'datetime'
columnItem.format = 'yyyy-MM-dd HH:mm:ss'
columnItem.valueFormat = 'yyyy-MM-dd HH:mm:ss'
columnItem.minWidth = 210
//日期(yyyy-MM-dd HH:mm:ss)
break
case 'list_multi':
columnItem.type = 'select'
columnItem.multiple = true
columnItem.minWidth = 150
//下拉多选框
break
case 'sel_search':
columnItem.type = 'select'
columnItem.filterable = true
columnItem.minWidth = 150
//下拉搜索框
break
default:
break
}
//扩展参数
if (item.fieldExtendJson && !['switch'].includes(item.fieldShowType)) {
let extend = ''
let extendBool = true
try {
extend = JSON.parse(item.fieldExtendJson)
} catch (error) {
extend = {}
extendBool = false
}
for (let key in extend) {
if (
key == 'uploadnum' &&
['image', 'file'].includes(item.fieldShowType)
) {
//限制上传文件或者图片个数
columnItem.limit = extend[key] - 0
} else {
columnItem[key] = extend[key]
if (key == 'searchValue') {
this.tableQueryData[columnItem.prop] = extend[key]
}
}
}
if (!extendBool) {
this.$message({
message:
'请为<' +
item.dbFieldTxt +
'>配置正确格式的扩展参数(例:{"uploadnum":2})',
duration: 5000,
type: 'warning',
})
}
}
//处理校验规则
columnItem.rules = []
if (item.fieldValidType) {
let rules = this.tableAllColumnRules[item.fieldValidType]
? this.tableAllColumnRules[item.fieldValidType]
: {}
if (
rules.pattern != 'only' &&
this.tableNeetRules.includes(item.fieldShowType) &&
rules.type.includes(item.dbType)
) {
let reg = new RegExp(rules.pattern)
validateRulesAll[item.dbFieldName] = (rule, value, callback) => {
if (!reg.test(value)) {
callback(new Error(`${rules.msg}`))
} else {
callback()
}
}
} else if (rules.pattern == 'only') {
validateRulesAll[item.dbFieldName] = (rule, value, callback) => {
let valueShowNum = 0
this.tableData.forEach((tableDataItem) => {
if (value == tableDataItem[item.dbFieldName]) {
valueShowNum++
}
})
if (valueShowNum == 1) {
callback()
} else {
callback(new Error(`值不可用,系统中已存在!`))
}
}
}
if (validateRulesAll[item.dbFieldName]) {
columnItem.rules = [
{
validator: validateRulesAll[item.dbFieldName],
trigger: 'blur',
},
]
}
}
if (item.fieldMustInput == '1') {
columnItem.rules.push({
required: true,
trigger: 'blur',
message: '值不能为空',
})
}
// 校验存储长度
if (
!['date', 'datetime', 'time'].includes(item.fieldShowType) &&
!['Text'].includes(item.dbType)
) {
columnItem.rules.push({
validator: (rule, value, callback) => {
if (value && value.length > item.dbLength) {
callback(new Error('超过最大长度'))
} else {
callback()
}
},
trigger: 'blur',
})
}
//文件 图片
if (['image', 'file'].includes(item.fieldShowType)) {
columnItem.type = 'upload'
columnItem.slot = true
columnItem.action = `api/${apiRequestHead}/cgform-api/upload/file`
columnItem.propsHttp = {
res: 'data',
url: 'link',
name: 'originalName',
}
columnItem.dataType = 'string'
if (item.fieldShowType == 'file') {
columnItem.minWidth = 120
columnItem.data = {
type: 1,
}
columnItem.accept = '*/*'
this.viewFileArr.push({
fieldName: item.dbFieldName,
fieldFileName: item.dbFieldName,
column: columnItem,
})
} else {
columnItem.listType = 'picture-card'
columnItem.minWidth = 120
columnItem.accept = 'image/*'
columnItem.data = {
type: 0,
}
this.viewImageArr.push({
fieldName: item.dbFieldName,
fieldImageName: item.dbFieldName,
column: columnItem,
})
}
}
//处理字典
tableColumn.push(columnItem)
})
return tableColumn
},
//添加数据 新值行
addSubListData(rows) {
let includeId = {}
let noIncludeId = []
let alreadyUpdata = []
let defaultItem = {}
this.tableOption.column.forEach((item) => {
defaultItem[item.prop] = ''
})
rows.forEach((item) => {
item.$cellEdit = true
if (this.viewImageArr.length > 0) {
this.viewImageArr.forEach((imgItem) => {
if (item[imgItem.fieldName] === undefined) {
item[imgItem.fieldName] = []
}
})
}
if (item.id) {
includeId[item.id] = item
} else {
noIncludeId.push(item)
}
})
this.tableData = this.tableData.map((item) => {
if (includeId[item.id]) {
alreadyUpdata.push(item.id)
item = {
...item,
...includeId[item.id],
}
}
return item
})
for (let key in includeId) {
if (!alreadyUpdata.includes(key)) {
noIncludeId.push(includeId[key])
}
}
noIncludeId = noIncludeId.map((item) => {
return {
...defaultItem,
...item,
}
})
this.tableData = [...this.tableData, ...noIncludeId]
},
//清除数据
clearSubListData() {
this.tableData = []
},
//新增数据
rowSaveFun(row, done) {
// row.id = row.$index
this.tableData.push(row)
done()
},
//编辑数据
rowUpdateFun(row, index, done) {
this.tableData = this.tableData.map((item, i) => {
if (i == index) {
item = row
}
return item
})
done()
},
//自定义按钮触发的方法
async allCustomButtonFun(btnCode, btnType, enhanceType, that, row) {
/* console.log(
'触发自定义按钮' + btnCode,
btnCode,
btnType,
enhanceType,
that,
row
) */
//触发js增强方法
if (enhanceType == 'js') {
if (
btnType == 'button' &&
this.customOnlineEnhanceJsList[btnCode] != undefined
) {
try {
this.customOnlineEnhanceJsList[btnCode](that)
} catch (error) {
console.warn(error)
}
}
if (
btnType == 'link' &&
this.customOnlineEnhanceJsList[btnCode] != undefined
) {
try {
this.customOnlineEnhanceJsList[btnCode](that, row)
} catch (error) {
console.warn(error)
}
}
}
//触发sql增强
if (enhanceType == 'action') {
let apiData = {
buttonCode: btnCode,
formId: this.currCodeId,
}
if (btnType == 'link') {
apiData.dataId = row.id
}
if (btnType == 'button') {
if (this.tableSelectId.length == 1) {
apiData.dataId = this.tableSelectId[0]
} else {
this.$message({
message: '请选择一条数据!',
type: 'warning',
})
return false
}
}
if (btnType == 'form') {
apiData.uiFormData = row
}
//访问接口 接口处理完才执行下面代码
// await touchSqlEnhanceApi(apiData)
// if (btnType == 'link' || btnType == 'button') {
// this.$refs.codeTestList.selectClear()
// //重新获取页面数据
// this.initTableData({
// currentPage: this.tablePage.currentPage,
// pageSize: this.tablePage.pageSize,
// })
// }
}
},
//初始化js增强部分默认方法
initOnlineEnhanceJs(listJs) {
let OnlineEnhanceJsList = undefined
if (listJs) {
OnlineEnhanceJsList = analysisFunction(listJs)
if (OnlineEnhanceJsList !== false) {
try {
this.customOnlineEnhanceJsList = OnlineEnhanceJsList(
getActionApi,
postActionApi,
deleteActionApi
)
this.customOnlineEnhanceJsName.list = Object.keys(
this.customOnlineEnhanceJsList
)
if (this.customOnlineEnhanceJsList == undefined) {
this.customOnlineEnhanceJsList = {}
}
if (this.customOnlineEnhanceJsName.list.includes('mounted')) {
try {
this.customOnlineEnhanceJsList.mounted(this.that)
} catch (error) {
console.warn(error)
}
}
} catch (error) {
console.warn(error)
}
} else {
console.warn('请检查子表js增强(list)编写是否有误~')
}
}
},
//操作栏更多
async moreButtonCommand(command) {
this.currentRowDataObj = command.row
if (command.buttonCode) {
this.allCustomButtonFun(
command.buttonCode,
command.buttonStyle,
command.optType,
command.that,
command.row
)
}
},
//树组件通用方法
async treeControlFun(type, obj) {
//type 方法类型 dialog:显隐弹窗 apiAdd:通过api批量新增数据 subDataAdd:子表数据新增
if (type == 'dialog') {
this.tableTreeControlOption.isDialog = obj.bool
}
//父表数据存储
if (type == 'dataAdd') {
this.addSubListData(obj.data)
this.tableTreeControlOption.isDialog = false
}
},
//表格选择组件通用方法
selectControlFun(type, obj) {
//type 方法类型 dialog:显隐弹窗
if (type == 'dialog') {
this.tableSelectControlOption.isDialog = obj.bool
}
//父表数据存储
if (type == 'dataAdd') {
this.addSubListData(obj.data)
this.tableSelectControlOption.isDialog = false
}
},
//表单控件通用方法
formViewControlFun(type) {
//type 方法类型 hide:隐藏弹窗
if (type == 'hide') {
this.FormViewControlOption.viewObj.isShow = false
}
},
},
}
</script>
<style lang="scss">
.code-sbulist-table-height {
height: 320px;
}
.code-sbulist-custom-image-box {
.box-content {
display: flex;
cursor: pointer;
.content-img {
width: 32px;
height: 32px;
}
.content-num {
width: 32px;
height: 32px;
background-color: rgba($color: #999, $alpha: 0.7);
margin-left: 5px;
color: #fff;
line-height: 32px;
text-align: center;
border-radius: 2px;
}
.content-icon {
line-height: 32px;
font-size: 14px;
padding-left: 8px;
}
img {
width: 32px;
height: 32px;
}
}
}
.code-sbulist-custom-file-box {
.box-content {
display: flex;
align-items: center;
cursor: pointer;
i {
font-size: 14px;
}
.content-txt {
max-width: 100px;
padding: 0 5px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.content-num {
flex: 0 0 28px;
width: 28px;
height: 28px;
background-color: rgba($color: #999, $alpha: 0.7);
color: #fff;
line-height: 28px;
text-align: center;
margin-right: 6px;
border-radius: 2px;
}
}
}
.sbulist-table-dialog-box {
.el-dialog__header {
border-bottom: 1px solid #f1f1f1;
}
.avue-form__menu--center {
display: none;
}
.el-dialog__body {
padding-bottom: 0px;
}
}
.code-sbulist-table {
.depart-control {
position: relative;
}
.cell {
.code-sublist-table-msg {
position: fixed;
left: 0;
top: 0;
display: none;
z-index: 999;
.code-sublist-table-msg-icon {
position: absolute;
font-size: 16px;
top: -14px;
left: 14px;
color: rgba(0, 0, 0, 0.75);
}
.code-sublist-table-msg-text {
padding: 6px 8px;
color: #fff;
text-align: left;
text-decoration: none;
word-wrap: break-word;
background-color: rgba(0, 0, 0, 0.75);
border-radius: 4px;
}
}
}
}
.code-sbulist-table-disabled {
.avue-crud__menu {
min-height: 0;
}
}
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/components/code-list/code-sublist-table.vue | Vue | apache-2.0 | 47,203 |
<template>
<!-- 表单开发 自定义表单按钮-->
<div class="menu-form-btns-box">
<el-button
v-for="item in that.customButtonFormEnd"
:key="item.id"
type="primary"
size="small"
@click="
that.allCustomButtonFun(
item.buttonCode,
item.buttonStyle,
item.optType,
that,
that.tableForm
)
"
>
<i v-if="item.buttonIcon" :class="item.buttonIcon"></i>
{{ item.buttonName }}
</el-button>
<el-button
v-if="that.tableCrudType == 'add'"
:loading="scope.disabled"
type="primary"
size="small"
@click="that.$refs.codeTestList.rowSave()"
>
<i class="el-icon-circle-plus-outline" v-show="!scope.disabled"></i>
{{ that.tableOption.saveBtnText ? that.tableOption.saveBtnText : "保 存" }}
</el-button>
<el-button
v-if="that.tableCrudType == 'edit'"
:loading="scope.disabled"
type="primary"
size="small"
@click="that.$refs.codeTestList.rowUpdate()"
>
<i class="el-icon-circle-check" v-show="!scope.disabled"></i>
{{
that.tableOption.updateBtnText ? that.tableOption.updateBtnText : "修 改"
}}
</el-button>
<el-button size="small" @click="that.$refs.codeTestList.closeDialog()">
<i class="el-icon-circle-close"></i>
{{
that.tableOption.cancelBtnText ? that.tableOption.cancelBtnText : "取 消"
}}
</el-button>
</div>
</template>
<script>
export default {
props: {
scope: Object,
that: Object,
},
}
</script>
<style lang="scss" scoped>
.menu-form-btns-box {
width: 100%;
display: inline;
}
</style> | 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/components/code-list/menu-form-btns.vue | Vue | apache-2.0 | 1,734 |
<template>
<div class="menu-left-btns-box">
<!-- 表单设计引用的新增 -->
<el-button
size="small"
type="primary"
icon="el-icon-plus"
@click="that.formDesignButtonTriggerFun('add')"
v-if="!that.tableOption.addBtn && that.tablePermission.addBtn"
>{{that.tableOption.addBtnText ? that.tableOption.addBtnText : "新增"}}</el-button>
<!-- 表单开发自定义按钮 -->
<el-button
v-for="item in that.customButtonTop"
:key="item.id"
size="small"
type="primary"
@click="that.allCustomButtonFun(item.buttonCode,item.buttonStyle,item.optType,that)"
>
<i v-if="item.buttonIcon" :class="item.buttonIcon" style="margin-right: 5px"></i>
{{ item.buttonName }}
</el-button>
<!-- 导出 -->
<el-button
size="small"
type="primary"
icon="el-icon-upload2"
@click="that.carryTableButtonFun('export')"
v-if="that.tablePermission.exportBtn"
>{{that.tableOption.excelBtnText ? that.tableOption.excelBtnText : "导出"}}</el-button>
<!-- 导入 -->
<el-button
size="small"
type="primary"
icon="el-icon-download"
@click="that.carryTableButtonFun('inport')"
v-if="that.tablePermission.inportBtn"
>{{that.tableOption.inportBtnText ? that.tableOption.inportBtnText : "导入"}}</el-button>
<!-- 批量删除 -->
<el-button
size="small"
type="primary"
icon="el-icon-search"
@click="that.searchChangeFun(that.tableQueryData,()=>{})"
v-if="that.tableSearchType=='interior'"
>搜索</el-button>
<el-button
size="small"
type="primary"
icon="el-icon-refresh-right"
@click="that.searchResetFun"
v-if="that.tableSearchType=='interior'"
>清空搜索</el-button>
<el-button
size="small"
icon="el-icon-delete"
@click="that.deleteAllSelectData"
v-show="that.tableSelectId.length &&that.themeTemplate != 'erp' &&that.tablePermission.allDelBtn"
>批量删除</el-button>
</div>
</template>
<script>
export default {
props: {
that: Object,
},
}
</script>
<style lang="scss" scoped>
.menu-left-btns-box {
width: 100%;
display: inline;
}
</style> | 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/components/code-list/menu-left-btns.vue | Vue | apache-2.0 | 2,226 |
<template>
<!-- 表单开发操作列按钮 -->
<div class="menu-btns-box">
<div class="menu-btn-list" v-if="!that.isLinkPullDown && !that.isOperationNullFun(scope.row)">
<span
class="btn-span"
:class="{ 'btn-span-null': that.customButtonLink.length <= 0 }"
v-for="item in that.customButtonLink"
v-show="scope.row['$link$' + item.buttonCode]"
:key="item.id"
>
<!-- 自定义按钮 -->
<el-button
v-if="scope.row['$link$' + item.buttonCode]"
:icon="item.buttonIcon"
@click="
that.moreButtonCommand({
type: item.buttonCode,
row: scope.row,
index: scope.index,
buttonCode: item.buttonCode,
buttonStyle: item.buttonStyle,
optType: item.optType,
that
})
"
type="text"
size="small"
>{{ item.buttonName }}</el-button>
</span>
<span class="btn-span" v-if="that.tablePermission.editBtn">
<el-button
type="text"
size="small"
@click.stop="that.operationRowFun(scope.row, scope.index, 'edit')"
>
{{
that.tableOption.editBtnText ? that.tableOption.editBtnText : "编辑"
}}
</el-button>
</span>
<span
class="btn-span"
v-for="item in that.tableColumnMoreButton"
:key="item.type"
v-show="that.tablePermission[item.permissionName]"
>
<el-button
v-if="that.tablePermission[item.permissionName]"
:icon="item.buttonIcon"
@click="
that.moreButtonCommand({
type: item.type,
row: scope.row,
index: scope.index
})
"
type="text"
size="small"
>{{ item.text }}</el-button>
</span>
</div>
<el-button
type="text"
icon="el-icon-edit"
size="small"
@click.stop="that.operationRowFun(scope.row, scope.index, 'edit')"
v-if="that.tablePermission.editBtn&&that.isLinkPullDown"
>
{{
that.tableOption.editBtnText ? that.tableOption.editBtnText : "编辑"
}}
</el-button>
<el-dropdown
class="code-test-list-menu-more-button"
@command="that.moreButtonCommand"
v-if="isOperationMore"
>
<span class="el-dropdown-link">
更多
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<div
v-for="item in that.customButtonLink"
:key="item.id"
v-show="scope.row['$link$' + item.buttonCode]"
>
<el-dropdown-item
v-if="scope.row['$link$' + item.buttonCode]"
:command="{
type: item.buttonCode,
row: scope.row,
index: scope.index,
buttonCode: item.buttonCode,
buttonStyle: item.buttonStyle,
optType: item.optType,
that
}"
>
<i v-if="item.buttonIcon" :class="item.buttonIcon"></i>
{{ item.buttonName }}
</el-dropdown-item>
</div>
<div v-for="item in that.tableColumnMoreButton" :key="item.type">
<el-dropdown-item
:command="{
type: item.type,
row: scope.row,
index: scope.index
}"
v-if="that.tablePermission[item.permissionName]"
>{{ item.text }}</el-dropdown-item>
</div>
</el-dropdown-menu>
</el-dropdown>
<el-button type="text" size="small" v-if="that.isOperationNullFun(scope.row)">-</el-button>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
props: {
scope: Object,
that: Object,
},
computed: {
...mapGetters(['permission']),
// 操作列 更多 是否显示
isOperationMore() {
if (!this.that.isLinkPullDown) {
return false
}
if (
this.that.tablePermission.moreViewBtn ||
this.that.tablePermission.moreDelBtn
) {
return true
}
let bool = false
this.that.customButtonLink.forEach((item) => {
if (this.that.isAuthBtn) {
if (
this.permission[
`${item.buttonCode}_${this.currCodeId}${this.currCodeType}`
] &&
this.scope.row['$link$' + item.buttonCode]
) {
bool = true
}
} else {
if (this.scope.row['$link$' + item.buttonCode]) {
bool = true
}
}
})
return bool
},
},
}
</script>
<style lang="scss" scoped>
.menu-btns-box {
width: 100%;
display: inline;
.menu-btn-list {
.btn-span {
padding-right: 5px;
}
.btn-span:nth-last-of-type(1) {
padding-right: 0px;
}
.btn-span-null {
padding-right: 0px;
}
}
.code-test-list-menu-more-button {
font-size: 12px;
.el-dropdown-link {
color: #409eff;
margin-left: 10px;
i {
margin-left: 0;
}
}
}
}
</style> | 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/components/code-list/menu-link-btns.vue | Vue | apache-2.0 | 5,352 |
<template>
<div class="form-control" :class="'form-control-box-' + formOption.prop">
<avue-form ref="form" v-model="form" :option="option">
<!-- 自定义按钮组 -->
<template
v-for="(btnListItem, btnListIndex) in btnListOption"
slot-scope="scope"
:slot="btnListItem.prop"
>
<div class="form-custom-btn-list" :class="scope.column.class" :key="btnListIndex">
<div
class="btn-box"
v-for="(childData,childIndex) in scope.column.children.column"
:key="childIndex"
>
<div
class="form-custom-button"
v-if="childData.display"
:class="childData.class"
:style="{margin:`0 ${scope.column.params.margin}px`}"
>
<el-button
:size="childData.size"
:type="childData.buttonType"
:plain="childData.plain"
:round="childData.round"
:circle="childData.circle"
:disabled="childData.disabled"
:icon="childData.buttonIcon"
@click="customButtonFun(childData.clickFun)"
>{{ childData.buttonText }}</el-button>
</div>
</div>
</div>
</template>
<!-- 自定义评分 -->
<template
v-for="(rateItem, rateIndex) in rateOption"
slot-scope="scope"
:slot="rateItem.prop"
>
<div class="form-control-text" :class="scope.column.class" :key="rateIndex">
<el-rate
:size="scope.size"
v-model="form[scope.column.prop]"
:allow-half="scope.column.allowHalf"
:max="scope.column.max"
></el-rate>
</div>
</template>
<!-- 自定义文本 -->
<template
v-for="(textItem, textIndex) in textOption"
slot-scope="scope"
:slot="textItem.prop"
>
<div class="form-control-text" :class="scope.column.class" :key="textIndex">
<div class="custon-text" :style="scope.column.styles">{{ scope.column.textValue }}</div>
</div>
</template>
<!-- 自定义分隔符 -->
<template
v-for="(separatorItem, separatorIndex) in separatorOption"
slot-scope="scope"
:slot="separatorItem.prop"
>
<div class="form-control-separator" :class="scope.column.class" :key="separatorIndex">
<el-divider
v-if="scope.column.direction != 'empty'"
:content-position="scope.column.contentPosition"
:direction="scope.column.direction"
>
<i v-if="scope.column.textIcon" :class="scope.column.textIcon"></i>
{{ scope.value }}
</el-divider>
<div v-else style="height: 25px"></div>
</div>
</template>
<!-- 自定义按钮 -->
<template
v-for="(buttonItem, buttonIndex) in buttonOption"
slot-scope="scope"
:slot="buttonItem.prop"
>
<div class="form-control-button" :class="scope.column.class" :key="buttonIndex">
<el-button
:size="scope.size"
:type="scope.column.buttonType"
:plain="scope.column.plain"
:round="scope.column.round"
:circle="scope.column.circle"
:disabled="scope.disabled"
:icon="scope.column.buttonIcon"
@click="customButtonFun(scope.column.clickFun)"
>{{ scope.column.buttonText }}</el-button>
</div>
</template>
<!-- 自定义用户 -->
<template
v-for="(userItem, userIndex) in userOption"
:slot="userItem.prop"
slot-scope="scope"
>
<user-control
:style="scope.column.style"
:class="scope.column.class"
:key="userIndex"
:tableItemVal="scope.value"
:tableItemName="scope.column.prop"
:disabled="scope.disabled"
:tableItemScope="scope"
:multiple="scope.column.params.multiple"
@set-form-val="setFormValue"
></user-control>
</template>
<!-- 自定义部门 -->
<template
v-for="(departItem, departIndex) in departOption"
:slot="departItem.prop"
slot-scope="scope"
>
<depart-control
:style="scope.column.style"
:class="scope.column.class"
:key="departIndex"
:tableItemVal="scope.value"
:tableItemName="scope.column.prop"
:disabled="scope.disabled"
:tableItemScope="scope"
:multiple="scope.column.params.multiple"
@set-form-val="setFormValue"
></depart-control>
</template>
<!-- 自定义代码编辑器 -->
<template
v-for="(monacoEditorItem, monacoEditorIndex) in monacoEditorOption"
:slot="monacoEditorItem.prop"
slot-scope="scope"
>
<monaco-editor
ref="monacoEditor"
v-model="form[monacoEditorItem.prop]"
:isSetData="true"
:keyIndex="monacoEditorIndex"
:key="monacoEditorIndex"
:language="monacoEditorItem.params.language"
:height="monacoEditorItem.params.height"
></monaco-editor>
</template>
<!-- 自定义表格选择控件 -->
<template
v-for="(tableSelectItem, tableSelectIndex) in tableSelectOption"
:slot="tableSelectItem.prop"
slot-scope="scope"
>
<table-select-control
:style="scope.column.style"
:class="scope.column.class"
:key="tableSelectIndex"
:tableItemVal="scope.value"
:tableItemName="scope.column.prop"
:disabled="scope.disabled"
:tableItemScope="scope"
:setFormValueFun="setFormValue.bind(this)"
v-bind="scope.column.params"
:allDepart="allDepartData"
:allUserObj="allUserData"
></table-select-control>
</template>
<!-- 自定义子表(table) -->
<template
v-for="(tableItem, tableIndex) in tableOption"
:slot="tableItem.prop"
slot-scope="scope"
>
<table-control
ref="tableControl"
:key="tableIndex"
:style="scope.column.style"
:class="scope.column.class"
:tableColumn="scope.column"
:tableValue="scope.value"
:formOpenType="formOpenType"
:getCurrPacDataTextFun="getCurrPacDataTextFun"
:lazyLoadFun="lazyLoadFun"
:allFormListData="allFormListData"
></table-control>
</template>
</avue-form>
</div>
</template>
<script>
import { getStrDataFunction } from '@/research/util/myUtil.js'
import { getDicTableData, uploadeFileApi } from '@/api/research/codelist'
import form from '@/research/mixins/form'
import { apiRequestHead } from '@/config/url.js'
import DepartControl from '@/research/components/general-control/depart-control'
import UserControl from '@/research/components/general-control/user-control'
import TableSelectControl from '@/research/components/general-control/table-select-control.vue'
import TableControl from '@/research/components/form-custom/table-control'
import MonacoEditor from '@/packages/utils/monaco-editor'
import Vue from 'vue';
export default {
props: [
'formOption',
'currTabsValue',
'currTabsProp',
'formOpenType',
'allExecuteRule',
'setJsEnhanceFun',
'getCurrPacDataTextFun',
'lazyLoadFun',
'allFormListData',
],
components: {
DepartControl,
UserControl,
TableControl,
TableSelectControl,
MonacoEditor,
},
mixins: [form],
computed: {},
data() {
return {
apiRequestHead: '',
valueToload: false,
optinsToLoad: false,
form: {},
option: {},
rateOption: [], //评分字段
separatorOption: [], //分隔符
textOption: [], //文本
btnListOption: [],
buttonOption: [], //按钮
userOption: [], //用户
departOption: [], //部门
monacoEditorOption: [], //代码编辑器
tableSelectOption: [], //表格选择
initSelfDefinedArr:[],//已经注册的自定义组件
tableOption: [], // 子表
provincesOption: [], //省市区,
selectRemoteAll: [],
selectDicAll: [],
}
},
async mounted() {
this.apiRequestHead = apiRequestHead
let currOption = this.setFormOptionDataFun(this.formOption)
this.option = {
...this.option,
...currOption,
}
if (['add', 'add_no'].includes(this.formOpenType)) {
setTimeout(() => {
//延迟配置默认值失效,重新设置默认值
this.$refs.form.dataFormat()
}, 0)
}
this.optinsToLoad = true
this.setRemoteDataDicFun()
if (['add', 'add_no'].includes(this.formOpenType)) {
this.getApiDataFun()
} else {
this.valueToload = true
}
if (
['edit', 'view', 'noButton', 'add_router'].includes(this.formOpenType)
) {
this.setCurrentFormDataFun()
}
setTimeout(() => {
this.setCustomText()
}, 0)
},
methods: {
//设置当前表单数据
setCurrentFormDataFun() {
if (this.option.column) {
this.option.column.forEach((item) => {
if (item.type != 'table') {
this.form = {
...this.form,
[item.prop]: this.allFormListData[item.prop],
}
}
})
}
setTimeout(() => {
//防止数据不更新
this.$refs.form.dataFormat()
}, 0)
},
//初始化树控件/联集文本
setCustomText() {
if (this.provincesOption && this.provincesOption.length > 0) {
this.provincesOption.forEach((item) => {
this.setProvincesTextFun(this.form[item], item)
})
}
},
//修改省市区文本方法
setProvincesTextFun(value, prop) {
let text = this.getCurrPacDataTextFun(value)
let dom = document.querySelector(
`.form-control-box-${this.formOption.prop} label[for=${prop}]`
)
if (dom) {
dom.parentNode.querySelector('input').value = text ? text : ''
} else {
// 处理字表省市区文本
let dom = document.querySelector(
`.form-control-control-provinces__${prop}`
)
dom = dom.parentNode.parentNode.parentNode.parentNode.querySelector(
'.el-form-item__content .el-input input'
)
if (dom) {
dom.value = text
}
}
},
//清空所有数据
clearAllDataFun() {
this.$refs.form.clearValidate()
this.$refs.form.clearVal()
if (this.$refs.tableControl) {
this.$refs.tableControl.forEach((item) => {
item.clearAllDataFun()
})
}
this.option.column.forEach((item) => {
if (item.formCustomType && item.formCustomType == 'provinces') {
this.setProvincesTextFun('', item.prop)
}
})
},
//处理表单设计器配置数据
setFormOptionDataFun(option) {
let optinos = this.deepClone(option)
delete optinos.disabled
if (optinos.label) {
optinos.label = ''
}
if (optinos.prop) {
optinos.prop = ''
}
//column处理
if (optinos.column == undefined) {
optinos.column = []
} else {
optinos.column = optinos.column.map((item) => {
return this.setOptionCloumnFun(item, optinos)
})
}
optinos.menuBtn = false
return optinos
},
setOptionCloumnFun(item, optinos) {
if (optinos.labelWidth && item.labelWidth === undefined) {
item.labelWidth = optinos.labelWidth
}
// if (!['tabs', 'title', 'separator', 'button'].includes(item.type)) {
// this.form[item.prop] = item.value
// }
//清除长度限制
if (
(item.isMaxLength !== undefined && item.isMaxLength === false) ||
(item.isMaxLength !== true && item.maxlength === 0)
) {
delete item.maxlength
}
if (['view', 'noButton'].includes(this.formOpenType)) {
item.disabled = true
}
//评分
if (item.type == 'rate') {
this.rateOption.push(item)
}
//文本
if (item.type == 'title') {
this.textOption.push(item)
}
//按钮组
if (item.type == 'btn-list') {
this.btnListOption.push(item)
}
//按钮
if (item.type == 'button') {
this.buttonOption.push(item)
}
//分隔符
if (item.type == 'separator') {
this.separatorOption.push(item)
}
//用户
if (item.type == 'user') {
this.userOption.push(item)
}
//部门
if (item.type == 'depart') {
this.departOption.push(item)
}
//表格选择
if (item.type == 'table-select') {
this.tableSelectOption.push(item)
}
//自定义控件
if(item.type=='self-defined'){
if(typeof item.params =='string'){
item.params=getStrDataFunction(item.params)
}
if(!this.initSelfDefinedArr.includes(item.component)){
try {
Vue.component(item.component, res => require([`@/${item.componentPath}`], res))
this.initSelfDefinedArr.push(item.component)
} catch (error) {
console.warn(`${item.component}自定义组件注册异常,${error}`);
}
}
}
if (item.type == 'monaco-editor') {
this.monacoEditorOption.push(item)
}
//子表
if (item.type == 'table') {
this.tableOption.push(item)
}
//省市区联动
if (item.type == 'provinces') {
item.type = 'cascader'
item.lazyLoad = (node, resolve) =>
this.lazyLoadFun(node, resolve, item.provType)
item.formCustomType = 'provinces'
item.class =
`form-control-control-provinces__${item.prop}` + ' ' + item.class
this.provincesOption.push(item.prop)
}
//判断时间/日期选择器是否开启范围选择
if (item.type == 'date' && item.isRange) {
item.type = 'daterange'
item.dataType = 'string'
}
if (item.type == 'time' && item.isRange) {
item.type = 'timerange'
item.dataType = 'string'
}
//对宽度进行拼接
if (item.style && item.style.width) {
item.style.width = item.style.width + ' !important'
}
//需要把数组处理成字符串的数据
if (item.type == 'select' && item.multiple) {
item.dataType = 'string'
}
if (
['checkbox', 'user', 'depart', 'upload', 'provinces'].includes(
item.type
)
) {
item.dataType = 'string'
}
if (item.type == 'upload') {
item.action = item.action.replace('apiRequestHead', this.apiRequestHead)
}
//对MarkDown组件赋上传图片方法
if (item.component == 'mavon-editor') {
item.event = {
imgAdd: (pos, $file) => {
const loading = this.$loading({
lock: true,
text: '正在上传图片,请耐心等待一会~',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)',
})
var formdata = new FormData()
formdata.append('file', $file)
formdata.append('type', 0)
uploadeFileApi(formdata)
.then((res) => {
let url = res.data.result.data.lj
this.$refs.form
.getPropRef(item.prop)
.$refs.temp.$img2Url(pos, url)
loading.close()
})
.catch(() => {
this.$message.error('上传图片失败,请重新上传~')
loading.close()
})
},
}
}
//提取需要远端数据的选择字段
if (['select', 'checkbox', 'radio'].includes(item.type)) {
if (item.oldDicOption == 'remote') {
item.dicData = []
this.selectRemoteAll.push(item.prop)
}
if (item.oldDicOption == 'dic') {
this.selectDicAll.push(item.prop)
}
}
//默认字段事件
item = {
...item,
change: () => {},
click: () => {},
focus: () => {},
blur: () => {},
enter: () => {},
control: () => {
return {}
},
}
return item
},
//远程取值方法
async getApiDataFun() {
let apiColumn = []
if (this.option.column) {
apiColumn = [...apiColumn, ...this.option.column]
}
let formData = await this.mixinGetApiData(apiColumn)
for (let key in formData.formObj) {
if (formData.formObj[key] instanceof Array) {
formData.formObj[key] = formData.formObj[key].join(',')
}
}
this.form = {
...this.form,
...formData.formObj,
}
for (let key in formData.specialObj) {
if (formData.specialObj[key].type == 'title') {
let column = null
if (this.option.column) {
column = this.findObject(this.option.column, key)
}
if (column) {
column.textValue = formData.specialObj[key].data
}
}
}
//
this.valueToload = true
},
//选择字段远端数据处理和数据字典逻辑
setRemoteDataDicFun() {
//远端数据
if (this.selectRemoteAll.length > 0) {
this.selectRemoteAll.forEach(async (item) => {
let column = this.findObject(this.option.column, item)
if (column.dicUrl) {
let dicData = await this.mixinGetSelectRemoteData(
column.dicUrl,
column.dicDataFormat
)
if (column.excludeStr) {
let excludeArr = column.excludeStr.split(',')
dicData = dicData.filter((item) => {
if (excludeArr.includes(item.value)) {
return false
}
return true
})
}
column.dicData = dicData
if (column.isOneDefaultValue && dicData.length > 0) {
column.value = dicData[0].id
}
}
})
}
//数据字典
if (this.selectDicAll.length > 0) {
this.selectDicAll.forEach(async (item) => {
let column = this.findObject(this.option.column, item)
if (column.queryFormName) {
let dicRes = await getDicTableData(column.queryFormName)
if (dicRes.data.success) {
if (column.excludeStr) {
let excludeArr = column.excludeStr.split(',')
dicRes.data.data = dicRes.data.data.filter((item) => {
if (excludeArr.includes(item.value)) {
return false
}
return true
})
}
column.dicData = dicRes.data.data
} else {
column.dicData = []
}
}
})
}
},
//获取表单数据
getFormData() {
return new Promise(async (resolve) => {
try {
let res = true
let formData = await this.verifyFormFun()
let resData = {
...formData.data,
}
let promiseArr = []
if (this.$refs.tableControl) {
this.$refs.tableControl.forEach((item) => {
promiseArr.push(item.getTableData())
})
}
let tableDataArr = await Promise.all(promiseArr)
if (!formData.res) {
res = false
}
tableDataArr.forEach((item) => {
if (!item.res) {
res = false
}
resData = {
...resData,
[item.prop]: item.data,
}
})
resolve({
res,
tabsValue: this.currTabsValue,
tabsProp: this.currTabsProp,
data: resData,
})
} catch (error) {
resolve({
res: false,
tabsValue: this.currTabsValue,
tabsProp: this.currTabsProp,
data: {},
})
}
})
},
//不校验获取表单数据
getFormDataNullVerify() {
let formData = {
...this.form,
}
if (this.$refs.tableControl) {
this.$refs.tableControl.forEach((item) => {
formData = {
...formData,
...item.tableDataItemDefault,
[item.tableProp]: item.tableData,
}
})
}
return formData
},
//获取当前组件所有字段配置
getFormColumnData() {
let column = [...this.option.column]
if (this.$refs.tableControl) {
this.$refs.tableControl.forEach((item) => {
column = [...column, ...item.tableOption.column]
})
}
return column
},
//校验表单方法
verifyFormFun() {
return new Promise((resolve) => {
this.$refs.form.validate((valid, done) => {
done()
resolve({
res: valid,
prop: false,
data: this.form,
})
})
})
},
//按钮绑定方法
customButtonFun(funText) {
this.setJsEnhanceFun(funText, 'button')
// this.getFunction(funText)
},
//解析函数
getFunction(fun) {
if (!this.validatenull(fun)) {
//后台获取是需要注释
fun = fun.replace(/↵/g, '\n')
//后台获取是需要注释
fun = fun.replace(/\/\*{1,2}[\s\S]*?\*\//gis, '')
// fun = fun.replace(/(?:^|\n|\r)\s*\/\*[\s\S]*?\*\/\s*(?:\r|\n|$)/g, '')
fun = fun.replace(/(?:^|\n|\r)\s*\/\/.*(?:\r|\n|$)/g, '')
try {
if (eval(`(${fun})`)) {
return eval(`(${fun})`)
} else {
return () => {}
}
} catch {
console.warn('请检查js增强编写是否有误~')
return () => {}
}
}
},
//设置表单值{fieldName:'',value:''}
setFormValue(obj) {
if (obj.value instanceof Array) {
obj.value = obj.value.join(',')
}
this.form = {
...this.form,
[obj.fieldName]: obj.value,
}
},
//js增强设置表单值
setJsFormDataFun(obj) {
let forKey = Object.keys(this.form)
let tableKey = this.tableOption.map((item) => item.prop)
if (forKey.includes(obj.fieldName) && !tableKey.includes(obj.fieldName)) {
this.setFormValue(obj)
}
if (this.$refs.tableControl) {
this.$refs.tableControl.forEach((item) => {
item.setJsFormDataFun(obj)
})
}
},
//js增强设置控件配置
setFormOptionsFun(key, optionsKey, optionsValue) {
this.$nextTick(() => {
let column = ''
if (this.option.column) {
column = this.findObject(this.option.column, key)
}
if (column && column != -1) {
column[optionsKey] = optionsValue
}
if (this.$refs.tableControl) {
this.$refs.tableControl.forEach((item) => {
item.setFormOptionsFun(key, optionsKey, optionsValue)
})
}
})
},
//js增强设置控件显示/隐藏
setFormControlStateFun(key, value) {
this.$nextTick(() => {
key.forEach((keyItem) => {
let column = ''
if (this.option.column) {
column = this.findObject(this.option.column, keyItem)
}
if (column && column != -1) {
column.display = value
}
})
if (this.$refs.tableControl) {
this.$refs.tableControl.forEach((item) => {
item.setFormControlStateFun(key, value)
})
}
})
},
//js增强设置控件值监听
setWatchFun(watchItems) {
this.$nextTick(() => {
let tableKey = this.tableOption.map((item) => item.prop)
let keyArr = Object.keys(watchItems)
let formKey = Object.keys(this.form)
keyArr.forEach((keyItem) => {
if (formKey.includes(keyItem) && !tableKey.includes(keyItem)) {
let watchName = 'form.' + keyItem
this.$watch(watchName, watchItems[keyItem])
}
})
})
},
//
//设置填值规则的值
setFormExecuteRuleFun(rule) {
let column = []
if (this.option.column) {
column = [...this.option.column]
}
let formData = {}
column.forEach((item) => {
if (item.fillRuleCode) {
formData[item.prop] = rule[item.fillRuleCode]
}
})
this.form = {
...this.form,
...formData,
}
if (this.$refs.tableControl) {
this.$refs.tableControl.forEach((item) => {
item.setFormExecuteRuleFun(rule)
})
}
},
},
}
</script>
<style lang="scss" scoped>
.form-custom {
.form-custom-rate {
padding-top: 10px;
}
}
.form-custom-btn-list {
display: flex;
align-items: center;
margin-bottom: -8px;
.form-custom-button {
margin-left: 0px !important;
&:last-child(1) {
margin-right: 0 !important;
}
}
}
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/components/form-custom/form-control.vue | Vue | apache-2.0 | 25,451 |
<template>
<div
:class="[
{ 'avue-form-work-style': option.formStyle == 'work' },
{ 'avue-form-form-style': option.formStyle != 'work' },
{
'avue-form-form-null-menu':
!btnPermissions.clearBtn &&
!btnPermissions.cancelBtn &&
!btnPermissions.submitBtn,
},
]"
v-loading="loading"
>
<div class="form-custom-print-box" v-if="option.isShowPrint">
<el-button type="text" style @click="opentPrinterFun" icon="el-icon-printer"></el-button>
</div>
<avue-form
id="test-print"
ref="form"
class="form-custom"
:class="{ 'avue--detail': isDetailStyle || option.formStyle == 'detail' }"
v-model="formData"
:option="option"
:upload-after="uploadAfter"
:upload-exceed="uploadExceedFun"
@submit="formHandleSubmitFun"
>
<!-- 自定义按钮 -->
<template slot="menuForm">
<el-button
@click="clearAllDataFun"
v-if="btnPermissions.clearBtn == true"
icon="el-icon-delete"
>清空</el-button>
<el-button
@click="cancelBtnFun"
v-if="btnPermissions.cancelBtn == true"
icon="el-icon-circle-close"
>取消</el-button>
</template>
<!-- tabs自定义 -->
<template v-for="(tabItem, tabIndex) in tabsOption" slot-scope="scope" :slot="tabItem.prop">
<div
class="form-custom-tabs"
:class="scope.column.class"
:key="tabIndex"
:style="{ width: scope.column.width }"
>
<el-tabs
class="widget-form-tabs-box"
:type="scope.column.styleType"
:tab-position="scope.column.location"
v-model="tabItem.tabsValue"
:size="scope.size"
@tab-click="(tab) => setTabsSwitchFun(tab, scope.column.prop)"
>
<el-tab-pane
v-for="(paneItem, paneIndex) in scope.column.children.column"
:key="paneIndex"
:label="paneItem.label"
:name="paneItem.prop"
:disabled="paneItem.disabled"
>
<span slot="label">
<i v-if="paneItem.icon" :class="paneItem.icon"></i>
{{ paneItem.label }}
</span>
<form-control
ref="formControl"
:formOption="paneItem"
:currTabsValue="paneItem.prop"
:currTabsProp="scope.column.prop"
:formOpenType="formOpenType"
:allExecuteRule="allExecuteRule"
:setJsEnhanceFun="setJsEnhanceFun.bind(this)"
:getCurrPacDataTextFun="getCurrPacDataTextFun.bind(this)"
:lazyLoadFun="lazyLoadFun.bind(this)"
:allFormListData="allFormListData"
></form-control>
</el-tab-pane>
</el-tabs>
</div>
</template>
<!-- 自定义按钮组 -->
<template
v-for="(btnListItem, btnListIndex) in btnListOption"
slot-scope="scope"
:slot="btnListItem.prop"
>
<div
class="form-custom-btn-list"
:class="scope.column.class"
:key="btnListIndex"
v-if="btnListItem.display"
>
<div
class="btn-box"
v-for="(childData,childIndex) in scope.column.children.column"
:key="childIndex"
>
<div
class="form-custom-button"
v-if="childData.display"
:class="childData.class"
:style="{margin:`0 ${scope.column.params.margin}px`}"
>
<el-button
:size="childData.size"
:type="childData.buttonType"
:plain="childData.plain"
:round="childData.round"
:circle="childData.circle"
:disabled="childData.disabled"
:icon="childData.buttonIcon"
@click="customButtonFun(childData.clickFun)"
>{{ childData.buttonText }}</el-button>
</div>
</div>
</div>
</template>
<!-- 自定义评分 -->
<template
v-for="(rateItem, rateIndex) in rateOption"
slot-scope="scope"
:slot="rateItem.prop"
>
<div class="form-custom-rate" :class="scope.column.class" :key="rateIndex">
<el-rate
:size="scope.size"
v-model="formData[scope.column.prop]"
:allow-half="scope.column.allowHalf"
:disabled="scope.disabled"
:max="scope.column.max"
></el-rate>
</div>
</template>
<!-- 自定义文本 -->
<template
v-for="(textItem, textIndex) in textOption"
slot-scope="scope"
:slot="textItem.prop"
>
<div class="form-custom-text" :class="scope.column.class" :key="textIndex">
<div class="custon-text" :style="scope.column.styles">{{ scope.column.textValue }}</div>
</div>
</template>
<!-- 自定义分隔符 -->
<template
v-for="(separatorItem, separatorIndex) in separatorOption"
slot-scope="scope"
:slot="separatorItem.prop"
>
<div
class="form-custom-separator"
:class="scope.column.class"
:style="scope.column.style"
:key="separatorIndex"
>
<el-divider
v-if="scope.column.direction != 'empty'"
:content-position="scope.column.contentPosition"
:direction="scope.column.direction"
>
<i v-if="scope.column.textIcon" :class="scope.column.textIcon"></i>
{{ scope.column.textValue }}
</el-divider>
<div v-else style="height: 25px"></div>
</div>
</template>
<!-- 自定义按钮 -->
<template
v-for="(buttonItem, buttonIndex) in buttonOption"
slot-scope="scope"
:slot="buttonItem.prop"
>
<div class="form-custom-button" :class="scope.column.class" :key="buttonIndex">
<el-button
:size="scope.size"
:type="scope.column.buttonType"
:plain="scope.column.plain"
:round="scope.column.round"
:circle="scope.column.circle"
:disabled="scope.disabled"
:icon="scope.column.buttonIcon"
@click="customButtonFun(scope.column.clickFun)"
>{{ scope.column.buttonText }}</el-button>
</div>
</template>
<!-- 自定义用户 -->
<template
v-for="(userItem, userIndex) in userOption"
:slot="userItem.prop"
slot-scope="scope"
>
<user-control
:style="scope.column.style"
:class="scope.column.class"
:key="userIndex"
:tableItemVal="scope.value"
:tableItemName="scope.column.prop"
:disabled="scope.disabled"
:tableItemScope="scope"
:multiple="scope.column.params.multiple"
@set-form-val="setFormValue"
:allDepart="allDepartData"
:allUserObj="allUserData"
></user-control>
</template>
<!-- 自定义部门 -->
<template
v-for="(departItem, departIndex) in departOption"
:slot="departItem.prop"
slot-scope="scope"
>
<depart-control
:style="scope.column.style"
:class="scope.column.class"
:key="departIndex"
:tableItemVal="scope.value"
:tableItemName="scope.column.prop"
:disabled="scope.disabled"
:tableItemScope="scope"
:multiple="scope.column.params.multiple"
@set-form-val="setFormValue"
></depart-control>
</template>
<!-- 自定义代码编辑器 -->
<template
v-for="(monacoEditorItem, monacoEditorIndex) in monacoEditorOption"
:slot="monacoEditorItem.prop"
slot-scope="scope"
>
<monaco-editor
ref="monacoEditor"
v-model="formData[monacoEditorItem.prop]"
:isSetData="true"
:keyIndex="monacoEditorIndex"
:key="monacoEditorIndex"
:language="monacoEditorItem.params.language"
:height="monacoEditorItem.params.height"
></monaco-editor>
</template>
<!-- 自定义表格选择控件 -->
<template
v-for="(tableSelectItem, tableSelectIndex) in tableSelectOption"
:slot="tableSelectItem.prop"
slot-scope="scope"
>
<table-select-control
:style="scope.column.style"
:class="scope.column.class"
:key="tableSelectIndex"
:tableItemVal="scope.value"
:tableItemName="scope.column.prop"
:disabled="scope.disabled"
:tableItemScope="scope"
:setFormValueFun="setFormValue.bind(this)"
v-bind="scope.column.params"
:allDepart="allDepartData"
:allUserObj="allUserData"
></table-select-control>
</template>
<!-- 自定义子表(table) -->
<template
v-for="(tableItem, tableIndex) in tableOption"
:slot="tableItem.prop"
slot-scope="scope"
>
<table-control
v-show="scope.column.display"
ref="tableControl"
:key="tableIndex"
:style="scope.column.style"
:class="scope.column.class"
:tableColumn="scope.column"
:tableValue="scope.value"
:formOpenType="formOpenType"
:allExecuteRule="allExecuteRule"
:getCurrPacDataTextFun="getCurrPacDataTextFun.bind(this)"
:lazyLoadFun="lazyLoadFun.bind(this)"
:allFormListData="allFormListData"
:allDepart="allDepartData"
:allUserObj="allUserData"
></table-control>
</template>
<!-- 自定义文件列表 -->
<template
v-for="(fileItem, fileIndex) in fileOption"
:slot="fileItem.prop + 'Type'"
slot-scope="scope"
>
<div
:key="fileIndex"
@click="downloadFile(scope.file.url, scope.file.name)"
style="cursor: pointer"
>
<i class="el-icon-link"></i>
<span style="flex: 1">
{{
formData["$Name" + fileItem.prop]
? formData["$Name" + fileItem.prop][scope.file.uid]
: formData[fileItem.prop]
}}
</span>
<i
class="el-icon-close"
v-if="!scope.disabled"
@click.capture.stop="codeFileControlDelFun(fileItem.prop, scope)"
></i>
</div>
</template>
</avue-form>
<table-view
ref="tableView"
v-if="isTableView"
:tableViewOptionData="tableViewOptionData"
:beforeClose="tableViewBeforeCloseFun.bind(this)"
></table-view>
<!-- 表格选择控件 -->
<table-select
ref="table_select"
v-if="isTableSelectControl"
:optionData="tableSelectControlOption"
:selectControlFun="tableViewBeforeCloseFun.bind(this)"
></table-select>
<!-- 其他表单 -->
<form-view
ref="formView"
v-if="isFormControl"
:formViewControlFun="formViewSubmitFun"
:formOptionData="formControlData"
></form-view>
</div>
</template>
<script>
import {
analysisFunction,
getCurrentDateFun,
getStrDataFunction,
} from '@/research/util/myUtil.js'
import { cityObj } from '@/research/util/city'
import { apiRequestHead } from '@/config/url.js'
import { getDeptTree } from '@/api/system/dept'
import { getList, getAllList } from '@/api/system/user'
import form from '@/research/mixins/form'
import {
addDataApi,
editDataApi,
uploadeFileApi,
getDicTableData,
getUploadeFileNameApi,
} from '@/api/research/codelist'
import DepartControl from '@/research/components/general-control/depart-control'
import UserControl from '@/research/components/general-control/user-control'
import TableSelectControl from '@/research/components/general-control/table-select-control.vue'
import FormControl from '@/research/components/form-custom/form-control'
import TableControl from '@/research/components/form-custom/table-control'
import TableView from '@/research/components/general-control/table-view.vue'
import TableSelect from '@/research/components/general-control/table-select.vue'
import FormView from '@/research/components/general-control/form-view.vue'
import MonacoEditor from '@/packages/utils/monaco-editor'
import { mapGetters, mapMutations } from 'vuex'
import Vue from 'vue'
export default {
name: 'FormCustom',
props: {
formOption: {
//表单配置
tpye: Object,
default: () => ({}),
},
isPreview: {
//是否预览
type: Boolean,
default: false,
},
isDetailStyle: {
type: Boolean,
default: false,
},
formOpenType: {
/*
表单类型 add:新增 edit:编辑 view:查看
流程:noButton、add_no
add_router:路由配置跳转表单新增
*/
type: String,
default: 'add',
},
actionData: {
type: Object,
},
//所有数据
allFormListData: {
type: Object,
},
//关闭dialog方法
closeDialogForm: {
type: Function,
},
//其他页面或控件传递的方法方法
transmitFun: {
type: Function,
},
// 流程提交方法
flowSubmit: {
type: Function,
},
//当前流程表单 唯一id
flowResourceId: {
type: String,
},
//表单设计绑定的表单开发id
onlineFormId: {
type: String,
},
//权限
btnPermissions: {
type: Object,
default: () => ({
clearBtn: true,
cancelBtn: false,
submitBtn: true,
}),
},
},
components: {
DepartControl,
UserControl,
FormControl,
TableControl,
TableView,
TableSelect,
TableSelectControl,
FormView,
MonacoEditor,
},
mixins: [form],
computed: {
...mapGetters(['provinces', 'userInfo']),
},
watch: {},
data() {
return {
random: `${new Date().getTime()}${Math.floor(Math.random() * 10000)}`,
getCurrentDateFun: getCurrentDateFun,
loading: false,
apiRequestHead: apiRequestHead,
isClearCss: true,
timer: null,
isOptinsToLoad: false,
isValueToload: false,
optinsToLoad: false,
valueToload: false,
formData: {},
defaultFormData: {}, //表单默认值
option: {
emptyBtn: false,
},
tabsOption: [], //tabs字段
btnListOption: [], //按钮组
rateOption: [], //评分字段
separatorOption: [], //分隔符
textOption: [], //文本
buttonOption: [], //按钮
userOption: [], //用户
isUserControl: false, //是否有用户控件
isDepartControl: false, //是否有部门控件
departOption: [], //部门
monacoEditorOption: [], //代码编辑器
tableSelectOption: [], //表格选择
initSelfDefinedArr: [], //已经注册的自定义组件
tableOption: [], // 子表
fileOption: [], //文件
provincesOption: [], //省市区
allDepartData: [], //所有的部门信息
allUserData: {
allList: [],
list: [],
total: 0,
}, //所有的用户信息
selectRemoteAll: {
column: [],
group: [],
}, //需要远端数据的选择字段
selectDicAll: {
column: [],
group: [],
},
allExecuteRule: {}, //所有的填值规则
executeObj: {}, //执行
jsEnhanceApi: {}, //js增强所有的api
beforeSubmit: '', //表单提交前触发的函数
disposeFormDataEnhance: '', //表单提交前触发数据处理增强
submitFormDataEnhance: '', //表单提交数据成功后处理增强
// 表单设计的路由配置
routerFormCode: '',
routerType: 'false',
redirectsUrl: '',
//表格弹窗控件
isTableView: false,
tableViewOptionData: {
viewObj: {
type: '',
title: '',
isShow: false,
width: '80%',
},
tableId: '',
hideHeader: true,
searchObj: {},
},
//表格选择
isTableSelectControl: false,
tableSelectControlOption: {
title: '',
isDialog: false,
width: '',
tableId: '',
option: {},
multiple: '',
isPage: '',
addType: {
type: '',
tableId: '',
isCell: '',
},
},
formDynamicFun: (type, data) => {
},
// 其他表单
isFormControl: false,
formControlData: {},
}
},
async mounted() {
this.loading = true
let formOption = await this.transformToAvueOptions(this.formOption)
let currOption = this.setFormOptionDataFun(formOption)
//设置用户、部门相关数据
if (this.isUserControl || this.isDepartControl) {
this.setDepartAndUserDataFun()
}
this.option = {
...currOption,
...this.option,
}
if (this.btnPermissions.submitBtn === false) {
this.option.submitBtn = false
}
if (this.formOpenType == 'edit') {
this.option.submitText = '修改'
}
if (['view', 'noButton', 'add_no'].includes(this.formOpenType)) {
this.option.menuBtn = false
}
if (this.formOption.jsIncidentEnhanceStr) {
try {
this.setJsEnhanceFun(
this.formOption.jsIncidentEnhanceStr,
'initEnhance'
)
} catch (error) {
console.warn(error)
}
}
if (['add', 'add_no'].includes(this.formOpenType)) {
setTimeout(() => {
//延迟配置默认值失效,重新设置默认值
this.$refs.form.dataFormat()
}, 0)
}
this.optinsToLoad = true
//获取选择字段远端数据
this.setRemoteDataDicFun()
//只有新增才会执行远程取值
if (['add', 'add_no'].includes(this.formOpenType)) {
this.getApiDataFun()
} else {
this.valueToload = true
}
//css增强
if (this.formOption.cssEnhanceStr) {
this.loadStyleString(this.formOption.cssEnhanceStr)
}
if (this.formOption.cssEnhanceUrl) {
let res = await this.mixinExternalEnhance(this.formOption.cssEnhanceUrl)
this.setJsEnhanceFun(res, 'external')
}
if (
['edit', 'view', 'noButton', 'add_router'].includes(this.formOpenType)
) {
this.setCurrentFormDataFun()
}
if (['add', 'add_no'].includes(this.formOpenType)) {
setTimeout(() => {
if (this.allFormListData) {
this.$refs.form.setForm(this.allFormListData)
}
}, 0)
}
setTimeout(() => {
this.setCustomText()
this.setBorderHideFun()
this.getFileNameFun()
//判断组件初始化是否完毕
this.timer = setInterval(async () => {
let valueToload = true
let optinsToLoad = true
//获取表单数据 表单配置
if (this.$refs.formControl) {
this.$refs.formControl.forEach((item) => {
if (!item.valueToload) {
valueToload = false
}
if (!item.optinsToLoad) {
optinsToLoad = false
}
})
}
if (this.$refs.tableControl) {
this.$refs.tableControl.forEach((item) => {
if (!item.valueToload) {
valueToload = false
}
if (!item.optinsToLoad) {
optinsToLoad = false
}
})
}
if (this.formOpenType != 'add') {
this.valueToload = true
}
if (valueToload && this.valueToload && !this.isValueToload) {
this.isValueToload = true
this.executeAllRuleFun()
}
if (optinsToLoad && this.optinsToLoad && !this.isOptinsToLoad) {
this.isOptinsToLoad = true
this.setJsEnhanceFun(this.formOption.jsEnhanceStr)
if (this.formOption.jsEnhanceUrl) {
let res = await this.mixinExternalEnhance(
this.formOption.jsEnhanceUrl
)
this.setJsEnhanceFun(res, 'external')
}
}
if (this.isValueToload && this.isOptinsToLoad) {
if (this && this.$refs.form && this.$refs.form.clearValidate) {
this.$refs.form.clearValidate()
}
clearInterval(this.timer)
}
this.loading = false
}, 1000)
}, 0)
},
methods: {
...mapMutations(['SET_PROVINCES']),
//下载文件
downloadFile(url, name) {
var aEle = document.createElement('a') // 创建a标签
aEle.download = name // 设置下载文件的文件名
aEle.href = url // content为后台返回的下载地址
aEle.click() // 设置点击事件
},
//文件、图片上传超过限制上传数 提示
uploadExceedFun(limit, files, fileList, column) {
this.$message({
showClose: true,
message: `<${column.label}>只允许上传${limit}个文件`,
type: 'warning',
})
},
//监听文件上传
uploadAfter(res, done, loading, column) {
if (column.uploadType == 'file') {
if (this.formData['$Name' + column.prop] instanceof Array) {
this.formData['$Name' + column.prop].push(res.originalName)
} else {
this.formData['$Name' + column.prop] = [res.originalName]
}
}
done()
},
codeFileControlDelFun(fileName, obj) {
let arr = []
if (this.formData[fileName] instanceof Array) {
arr = this.formData[fileName]
} else {
arr = this.formData[fileName].split(',')
}
let fileStr = arr.filter((item, index) => {
if (item == obj.file.url) {
this.formData['$Name' + fileName] = this.formData[
'$Name' + fileName
].filter((item, i) => index != i)
return false
}
return true
})
fileStr.join(',')
this.formData[fileName] = fileStr.join(',')
},
//初始化文件名
getFileNameFun() {
let fileArr = []
if (this.fileOption.length > 0) {
this.fileOption.forEach((item) => {
fileArr.push(item.prop)
})
}
//处理文件名
if (fileArr.length > 0) {
fileArr.forEach((fileItem) => {
if (
this.formData[fileItem] != '' &&
this.formData[fileItem] != undefined
) {
this.formData['$Name' + fileItem] = []
this.formData[fileItem].split(',').forEach(async (resItem) => {
let fileRes = await getUploadeFileNameApi(resItem)
let fileName = resItem.split('/')
fileName = fileName[fileName.length - 1]
if (fileRes.data.success && fileRes.data.data) {
fileName = fileRes.data.data
}
let fileNameArr = [...this.formData['$Name' + fileItem], fileName]
this.formData = {
...this.formData,
['$Name' + fileItem]: fileNameArr,
}
})
}
})
}
},
cancelBtnFun() {
this.closeDialogForm()
},
//设置隐藏边框
setBorderHideFun() {
let hideDom = document.querySelectorAll(
'.avue-form-work-style .el-collapse-item__content .form-border-hide'
)
if (hideDom.length > 0) {
hideDom.forEach((item) => {
item.style.height = '33px'
let itemDom = item.parentNode.parentNode.parentNode
if (itemDom.className.indexOf('el-form-item') != -1) {
itemDom.style.border = '0 solid #000'
}
})
}
let leftDom = document.querySelectorAll(
'.avue-form-work-style .el-collapse-item__content .form-border-left-show'
)
if (leftDom.length > 0) {
leftDom.forEach((item) => {
let itemDom = item.parentNode.parentNode.parentNode
if (itemDom.className.indexOf('el-form-item') != -1) {
itemDom.style.borderLeft = '1px solid #000'
}
})
}
let bottomDom = document.querySelectorAll(
'.avue-form-work-style .el-collapse-item__content .form-border-bottom-show'
)
if (bottomDom.length > 0) {
bottomDom.forEach((item) => {
let itemDom = item.parentNode.parentNode.parentNode
if (itemDom.className.indexOf('el-form-item') != -1) {
itemDom.style.borderBottom = '1px solid #000'
}
})
}
let topDom = document.querySelectorAll(
'.avue-form-work-style .el-collapse-item__content .form-border-top-show'
)
if (topDom.length > 0) {
topDom.forEach((item) => {
let itemDom = item.parentNode.parentNode.parentNode
if (itemDom.className.indexOf('el-form-item') != -1) {
itemDom.style.borderTop = '1px solid #000'
}
})
}
let leftDomHide = document.querySelectorAll(
'.avue-form-work-style .el-collapse-item__content .form-border-left-hide'
)
if (leftDomHide.length > 0) {
leftDomHide.forEach((item) => {
let itemDom = item.parentNode.parentNode.parentNode
if (itemDom.className.indexOf('el-form-item') != -1) {
itemDom.style.borderLeft = '0px solid #000'
}
})
}
let bottomDomHide = document.querySelectorAll(
'.avue-form-work-style .el-collapse-item__content .form-border-bottom-hide'
)
if (bottomDomHide.length > 0) {
bottomDomHide.forEach((item) => {
let itemDom = item.parentNode.parentNode.parentNode
if (itemDom.className.indexOf('el-form-item') != -1) {
itemDom.style.borderBottom = '0px solid #000'
}
})
}
let topDomHide = document.querySelectorAll(
'.avue-form-work-style .el-collapse-item__content .form-border-top-hide'
)
if (topDomHide.length > 0) {
topDomHide.forEach((item) => {
let itemDom = item.parentNode.parentNode.parentNode
if (itemDom.className.indexOf('el-form-item') != -1) {
itemDom.style.borderTop = '0px solid #000'
}
})
}
},
//打印
opentPrinterFun() {
this.$Print(this.$refs.form)
},
//触发表单提交前的方法
triggerBeforeSubmit() {
return new Promise(async (resolve) => {
try {
if (this.beforeSubmit !== '') {
this.beforeSubmit()
.then(() => {
resolve({ success: true })
})
.catch((err) => {
resolve({ success: false, msg: err })
})
} else {
resolve({ success: true })
}
} catch (error) {
resolve({ success: true })
console.warn('表单提交前触发方法错误', error)
}
})
},
//设置当前表单数据
setCurrentFormDataFun() {
let allProp = []
if (this.option.column) {
this.option.column.forEach((item) => {
if (item.type != 'table') {
allProp.push(item.prop)
}
})
}
if (this.option.group) {
this.option.group.forEach((item) => {
item.column.forEach((col) => {
if (col.type != 'table' && col.type != 'tabs') {
allProp.push(col.prop)
}
})
})
}
let formData = {}
if (this.formOpenType == 'add_router') {
formData = this.allFormListData
} else {
allProp.forEach((item) => {
if (this.allFormListData) {
formData[item] =
this.allFormListData[item] == undefined
? ''
: this.allFormListData[item]
}
})
}
this.$refs.form.setForm(formData)
},
//省市区懒加载方法
lazyLoadFun(node, resolve, type) {
if (!this.provinces.province) {
this.SET_PROVINCES({
...cityObj,
})
}
let level = node.level
let data = node.data || {}
let area_id = data.area_id
let list = []
let callback = () => {
resolve(
(list || []).map((ele) => {
if ((type == 1 && level == 1) || (type == 2 && level == 0)) {
return Object.assign(ele, {
leaf: true,
})
} else {
return Object.assign(ele, {
leaf: ele.leaf,
})
}
})
)
}
if (level == 0) {
list = this.provinces.province
callback()
} else if (level == 1) {
list = this.provinces.city[area_id]
callback()
} else if (level == 2) {
list = this.provinces.district[area_id]
callback()
}
},
//初始化树控件/联集文本
setCustomText() {
if (this.provincesOption && this.provincesOption.length > 0) {
this.provincesOption.forEach((item) => {
this.setProvincesTextFun(this.formData[item], item)
})
}
},
//修改省市区文本方法
setProvincesTextFun(value, prop) {
let text = this.getCurrPacDataTextFun(value)
let dom = document.querySelector(`.form-custom label[for=${prop}]`)
if (dom) {
dom.parentNode.querySelector('input').value = text ? text : ''
} else {
// 处理字表省市区文本
let dom = document.querySelector(
`.form-custom-control-provinces__${prop}`
)
dom = dom.parentNode.parentNode.parentNode.parentNode.querySelector(
'.el-form-item__content .el-input input'
)
if (dom) {
dom.value = text
}
}
},
//获取当前省市区数据文本
getCurrPacDataTextFun(key) {
if (!key) {
return ''
}
let value = key instanceof Array ? key : key.split(',')
let strArr = []
value.forEach((item, index) => {
if (
index == 0 &&
this.provinces.provinceData &&
this.provinces.provinceData[item]
) {
strArr.push(this.provinces.provinceData[item].area_name)
}
if (
index == 1 &&
this.provinces.cityData &&
this.provinces.cityData[item]
) {
strArr.push(this.provinces.cityData[item].area_name)
}
if (
index == 2 &&
this.provinces.districtData &&
this.provinces.districtData[item]
) {
strArr.push(this.provinces.districtData[item].area_name)
}
})
return strArr.join(' / ')
},
//清空所有数据
clearAllDataFun() {
this.$refs.form.clearValidate()
this.$refs.form.resetForm()
if (this.$refs.formControl) {
this.$refs.formControl.forEach((item) => {
item.clearAllDataFun()
})
}
if (this.$refs.tableControl) {
this.$refs.tableControl.forEach((item) => {
item.clearAllDataFun()
})
}
this.option.column.forEach((item) => {
if (item.formCustomType && item.formCustomType == 'provinces') {
this.setProvincesTextFun('', item.prop)
}
})
},
// 表单设计器配置项 转化为 Avue配置项
transformToAvueOptions(obj) {
return new Promise((resolve, reject) => {
try {
const data = this.deepClone(obj)
if (data.column) {
for (let i = 0; i < data.column.length; i++) {
const col = data.column[i]
if (
col.type == 'dynamic' &&
col.children &&
col.children.column &&
col.children.column.length > 0
) {
const c = col.children.column
c.forEach((item) => {
delete item.subfield
})
this.transformToAvueOptions(col.children).then((res) => {
col.children = res
})
} else if (col.type == 'group') {
if (!data.group) data.group = []
const group = {
label: col.label,
icon: col.icon,
prop: col.prop,
arrow: col.arrow,
collapse: col.collapse,
display: col.display,
}
this.transformToAvueOptions(col.children).then((res) => {
group.column = res.column
data.group.push(group)
})
data.column.splice(i, 1)
i--
} else if (
['checkbox', 'radio', 'tree', 'cascader', 'select'].includes(
col.type
)
) {
delete col.dicOption
}
if (col.change) col.change = eval(col.change)
else delete col.change
if (col.click) col.click = eval(col.click)
else delete col.click
if (col.focus) col.focus = eval(col.focus)
else delete col.focus
if (col.blur) col.blur = eval(col.blur)
else delete col.blur
}
}
resolve(data)
} catch (e) {
reject(e)
}
})
},
//处理表单设计器配置数据
setFormOptionDataFun(option) {
let optinos = this.deepClone(option)
//column处理
if (optinos.column == undefined) {
optinos.column = []
} else {
optinos.column = [
...optinos.column.map((item) => {
item = this.setOptionCloumnFun(
item,
'column',
optinos.formStyle == 'work',
optinos
)
return item
}),
]
}
if (optinos.group) {
optinos.group.forEach((item, index) => {
optinos.group[index].column = optinos.group[index].column.map(
(item) => {
item = this.setOptionCloumnFun(
item,
'group',
optinos.formStyle == 'work',
optinos
)
return item
}
)
})
}
return optinos
},
//数据处理方法
setOptionCloumnFun(item, type, isWork, optinos) {
if (optinos.labelWidth && item.labelWidth === undefined) {
item.labelWidth = optinos.labelWidth
}
if (isWork) {
item.placeholder = ' '
}
if (item.type == 'separator') {
item.textValue = item.value
}
if (['view', 'noButton'].includes(this.formOpenType)) {
item.disabled = true
}
//清除长度限制
if (
(item.isMaxLength !== undefined && item.isMaxLength === false) ||
(item.isMaxLength !== true && item.maxlength === 0)
) {
delete item.maxlength
}
//tabs
if (item.type == 'tabs') {
item.label = ''
item.labelWidth = 0
item.tabsValue = item.children.column[0].prop
this.tabsOption.push(item)
}
if (item.type == 'btn-list') {
this.btnListOption.push(item)
}
//评分
if (item.type == 'rate') {
this.rateOption.push(item)
}
//文本
if (item.type == 'title') {
this.textOption.push(item)
}
//按钮
if (item.type == 'button') {
this.buttonOption.push(item)
}
//分隔符
if (item.type == 'separator') {
this.separatorOption.push(item)
}
//用户
if (item.type == 'user') {
this.isUserControl = true
this.userOption.push(item)
}
//部门
if (item.type == 'depart') {
this.isDepartControl = true
this.departOption.push(item)
}
//表格选择
if (item.type == 'table-select') {
this.tableSelectOption.push(item)
}
//自定义控件
if (item.type == 'self-defined') {
if (typeof item.params == 'string') {
item.params = getStrDataFunction(item.params)
}
if (!this.initSelfDefinedArr.includes(item.component)) {
try {
Vue.component(item.component, (res) =>
require([`@/${item.componentPath}`], res)
)
this.initSelfDefinedArr.push(item.component)
} catch (error) {
console.warn(`${item.component}自定义组件注册异常,${error}`)
}
}
}
//代码编辑器
if (item.type == 'monaco-editor') {
this.monacoEditorOption.push(item)
}
//子表
if (item.type == 'table') {
item.isWork = isWork
if (item.jsEnhanceFun) {
try {
let jsStr = `function jsEnhanceFun(that,parentThat){${item.jsEnhanceFun}}`
item.jsEnhanceFun = analysisFunction(jsStr)
item.getParentFun = () => {
return this
}
if (!item.jsEnhanceFun) {
throw new Error()
}
} catch (error) {
console.warn(`子表《${item.prop}》初始化之前js增强解析错误`)
}
}
if (item.assigJsEnhance) {
try {
let assigJsStr = `function jsEnhanceFun(that,parentThat){${item.assigJsEnhance}}`
item.assigJsEnhance = analysisFunction(assigJsStr)
if (!item.getParentFun) {
item.getParentFun = () => {
return this
}
}
if (!item.assigJsEnhance) {
throw new Error()
}
} catch (error) {
console.warn(`子表《${item.prop}》赋值后js增强解析错误`)
}
}
this.tableOption.push(item)
this.findUserAndDepartFun(item.children.column)
}
//省市区联动
if (item.type == 'provinces') {
item.type = 'cascader'
item.lazyLoad = (node, resolve) =>
this.lazyLoadFun(node, resolve, item.provType)
item.formCustomType = 'provinces'
item.class =
`form-custom-control-provinces__${item.prop}` + ' ' + item.class
this.provincesOption.push(item.prop)
}
//判断时间/日期选择器是否开启范围选择
if (item.type == 'date' && item.isRange) {
item.type = 'daterange'
item.dataType = 'string'
}
if (item.type == 'time' && item.isRange) {
item.type = 'timerange'
item.dataType = 'string'
}
//文件上传
if (item.uploadType == 'file') {
this.fileOption.push(item)
}
//图片上传
if (item.uploadType == 'img' && item.limit == 1) {
item.listType = 'picture-img'
delete item.limit
}
//对宽度进行拼接
if (item.style && item.style.width) {
item.style.width = item.style.width + ' !important'
}
//需要把数组处理成字符串的数据
if (item.type == 'select' && item.multiple) {
item.dataType = 'string'
}
if (item.type == 'slider' && item.range) {
item.dataType = 'string'
}
if (
['checkbox', 'user', 'depart', 'upload', 'cascader'].includes(item.type)
) {
item.dataType = 'string'
}
if (item.type == 'upload') {
item.action = item.action.replace('apiRequestHead', this.apiRequestHead)
}
//对MarkDown组件赋上传图片方法
if (item.component == 'mavon-editor') {
item.event = {
imgAdd: (pos, $file) => {
const loading = this.$loading({
lock: true,
text: '正在上传图片,请耐心等待一会~',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)',
})
var formdata = new FormData()
formdata.append('file', $file)
formdata.append('type', 0)
uploadeFileApi(formdata)
.then((res) => {
let url = res.data.result.data.lj
this.$refs.form
.getPropRef(item.prop)
.$refs.temp.$img2Url(pos, url)
loading.close()
})
.catch(() => {
this.$message.error('上传图片失败,请重新上传~')
loading.close()
})
},
}
}
//提取需要远端数据的选择字段
if (['select', 'checkbox', 'radio'].includes(item.type)) {
if (item.oldDicOption == 'remote') {
item.dicData = []
if (type == 'column') {
this.selectRemoteAll.column.push(item.prop)
}
if (type == 'group') {
this.selectRemoteAll.group.push(item.prop)
}
}
if (item.oldDicOption == 'dic') {
if (type == 'column') {
this.selectDicAll.column.push(item.prop)
}
if (type == 'group') {
this.selectDicAll.group.push(item.prop)
}
}
}
if (item.type == 'switch') {
item.dicData = [
{
label: '', //关闭
value: item.inactiveText ? item.inactiveText : '0',
},
{
label: '', //开启
value: item.activeText ? item.activeText : '1',
},
]
}
//处理一开始执行校验问题
if (item.rules && item.rules.length > 0) {
item.rules = item.rules.map((rulesItem) => {
if (!rulesItem.trigger) {
rulesItem.trigger = 'blur'
}
return rulesItem
})
}
//默认字段事件
item = {
...item,
change: () => {},
click: () => {},
focus: () => {},
blur: () => {},
enter: () => {},
control: () => {
return {}
},
}
return item
},
findUserAndDepartFun(column) {
column.forEach((item) => {
if (item.type == 'user') {
this.isUserControl = true
}
if (item.type == 'depart') {
this.isDepartControl = true
}
})
},
//设置用户部门 数据
setDepartAndUserDataFun() {
if (this.isUserControl) {
getDeptTree().then((res) => {
let data = res.data.data
this.allDepartData = data
})
getAllList().then((res) => {
this.allUserData.allList = res.data.data
})
getList(1, 10, {}, '').then((res) => {
let data = res.data.data
this.allUserData.list = data.records
this.allUserData.total = data.total
})
} else {
getDeptTree().then((res) => {
let data = res.data.data
this.allDepartData = data
})
}
},
//远程取值方法
async getApiDataFun() {
let apiColumn = []
if (this.option.column) {
apiColumn = [...apiColumn, ...this.option.column]
}
if (this.option.group) {
this.option.group.forEach((item) => {
apiColumn = [...apiColumn, ...item.column]
})
}
let formData = await this.mixinGetApiData(apiColumn)
for (let key in formData.formObj) {
if (formData.formObj[key] instanceof Array) {
formData.formObj[key] = formData.formObj[key].join(',')
}
}
this.formData = {
...this.formData,
...formData.formObj,
}
for (let key in formData.specialObj) {
if (formData.specialObj[key].type == 'title') {
let column = null
let group = null
if (this.option.column) {
column = this.findObject(this.option.column, key)
}
if (this.option.group) {
this.option.group.forEach((item, index) => {
group = this.findObject(this.option.group[index].column, key)
})
}
if (column && column != -1) {
column.textValue = formData.specialObj[key].data
} else {
group.textValue = formData.specialObj[key].data
}
}
}
this.valueToload = true
},
//选择字段远端数据和数据字典处理逻辑
setRemoteDataDicFun() {
//远端数据
if (
this.selectRemoteAll.column.length > 0 ||
this.selectRemoteAll.group.length > 0
) {
this.selectRemoteAll.column.forEach(async (item) => {
let column = this.findObject(this.option.column, item)
if (column.dicUrl) {
let dicData = await this.mixinGetSelectRemoteData(
column.dicUrl,
column.dicDataFormat
)
if (column.excludeStr) {
let excludeArr = column.excludeStr.split(',')
dicData = dicData.filter((item) => {
if (excludeArr.includes(item.value)) {
return false
}
return true
})
}
column.dicData = dicData
if (column.isOneDefaultValue && dicData.length > 0) {
column.value = dicData[0].id
}
}
})
this.selectRemoteAll.group.forEach(async (item) => {
if (this.option.group) {
this.option.group.forEach(async (groupItem, index) => {
let group = this.findObject(this.option.group[index].column, item)
if (group.dicUrl) {
let dicData = await this.mixinGetSelectRemoteData(
group.dicUrl,
group.dicDataFormat
)
if (group.excludeStr) {
let excludeArr = group.excludeStr.split(',')
dicData = dicData.filter((item) => {
if (excludeArr.includes(item.value)) {
return false
}
return true
})
}
group.dicData = dicData
if (group.isOneDefaultValue && dicData.length > 0) {
group.value = dicData[0].id
}
}
})
}
})
}
//字典逻辑
if (
this.selectDicAll.column.length > 0 ||
this.selectDicAll.group.length > 0
) {
this.selectDicAll.column.forEach(async (item) => {
let column = this.findObject(this.option.column, item)
if (column && column.queryFormName) {
let dicRes = await getDicTableData(column.queryFormName)
if (dicRes.data.success) {
if (column.excludeStr) {
let excludeArr = column.excludeStr.split(',')
dicRes.data.data = dicRes.data.data.filter((item) => {
if (excludeArr.includes(item.value)) {
return false
}
return true
})
}
column.dicData = dicRes.data.data
} else {
column.dicData = []
}
}
})
this.selectDicAll.group.forEach((item) => {
if (this.option.group) {
this.option.group.forEach(async (groupItem, index) => {
let group = this.findObject(this.option.group[index].column, item)
if (group && group.queryFormName) {
let dicRes = await getDicTableData(group.queryFormName)
if (dicRes.data.success) {
if (group.excludeStr) {
let excludeArr = group.excludeStr.split(',')
dicRes.data.data = dicRes.data.data.filter((item) => {
if (excludeArr.includes(item.value)) {
return false
}
return true
})
}
group.dicData = dicRes.data.data
} else {
group.dicData = []
}
}
})
}
})
}
},
//保存
formHandleSubmitFun(form, done) {
return new Promise(async (resolve) => {
let submitRes = await this.triggerBeforeSubmit()
if (submitRes.success == false) {
let msg = submitRes.msg ? submitRes.msg : '提交失败,参数不符合条件'
if (submitRes.msg != false) {
this.$message.error(msg)
}
done()
return false
}
form = {
...this.allFormListData,
...form,
...this.formData,
}
let promiseArr = []
if (this.$refs.formControl) {
this.$refs.formControl.forEach((item) => {
promiseArr.push(item.getFormData())
})
}
if (this.$refs.tableControl) {
this.$refs.tableControl.forEach((item) => {
promiseArr.push(item.getTableData())
})
}
let formDataArr = await Promise.all(promiseArr)
let isCheckFailure = false //是否校验失败
let tabsIndexArr = []
formDataArr.forEach((item) => {
if (!item.res) {
isCheckFailure = true
if (item.tabsValue && item.tabsProp) {
//切换到校验失败的tab
let tabsItem = this.findObject(this.tabsOption, item.tabsProp)
let index = this.findArray(this.tabsOption, item.tabsProp, 'prop')
if (tabsIndexArr.includes(index)) {
return false
}
tabsItem.tabsValue = item.tabsValue
tabsIndexArr.push(index)
}
}
//整合所有数据
if (item.prop) {
form = {
...form,
[item.prop]: item.data,
}
} else {
form = {
...form,
...item.data,
}
}
})
for (let key in form) {
if (form[key] == '[]') {
form[key] = ''
}
}
if (isCheckFailure) {
if (this.actionData && this.actionData.type == 'flow') {
this.$message('请完善信息~')
}
done()
return false
}
if (this.disposeFormDataEnhance) {
form = await this.disposeFormDataEnhance(form)
}
// 预览
if (this.isPreview) {
this.$alert(form, '表单数据', {
confirmButtonText: '确定',
customClass: 'form-custom-preview-form-data-alert',
})
if (this.submitFormDataEnhance) {
await this.submitFormDataEnhance(form)
}
done()
}
//单独修改表单设计数据
if (this.actionData && this.actionData.type == 'onlineEdit') {
let data = {
...form,
id: this.allFormListData.id,
}
try {
await editDataApi(this.onlineFormId, data)
} catch (error) {
done()
return false
}
if (this.submitFormDataEnhance) {
await this.submitFormDataEnhance(form, data.id)
}
if (this.actionData.isMessage) {
this.$message({
message: '修改成功',
type: 'success',
})
}
if (this.actionData.closeType) {
this.closeDialogForm(this.actionData.closeType)
} else {
this.closeDialogForm()
}
done()
}
//单独保存表单设计数据
if (this.actionData && this.actionData.type == 'onlineAdd') {
let data = {
...form,
}
let codeListDataId = ''
try {
let resData = await addDataApi(this.onlineFormId, data)
codeListDataId = resData.data.data
} catch (error) {
done()
return false
}
if (this.submitFormDataEnhance) {
await this.submitFormDataEnhance(form, codeListDataId)
}
if (this.actionData.isMessage) {
this.$message({
message: '保存成功',
type: 'success',
})
}
if (this.actionData.closeType) {
this.closeDialogForm(this.actionData.closeType)
} else {
this.closeDialogForm()
}
done()
}
//只返回数据不做任何处理
if (this.actionData && this.actionData.type == 'returnData') {
let data = {
...form,
}
if (this.formOpenType == 'edit') {
data = {
...data,
id: this.allFormListData.id,
}
}
let idKey = this.onlineFormId ? this.onlineFormId : 'data'
this.$refs.form.validate((valid, done) => {
done()
let bool = true
if (!valid) {
bool = false
}
console.log({
valid: bool,
[idKey]: data,
})
resolve({
valid: bool,
[idKey]: data,
dataKey: idKey,
})
})
}
//只调用关闭方法做不处理
if (this.actionData && this.actionData.type == 'callClose') {
this.closeDialogForm()
}
//只调用关闭方法传递表单数据
if (this.actionData && this.actionData.type == 'callCloseData') {
this.$refs.form.validate((valid, done) => {
if (!valid) {
done()
return false
} else {
this.closeDialogForm(done, form)
}
})
}
})
},
//按钮绑定方法
customButtonFun(funText) {
this.setJsEnhanceFun(funText, 'button')
},
//设置表单值{fieldName:'',value:''}
setFormValue(obj) {
if (obj.value instanceof Array) {
obj.value = obj.value.join(',')
}
this.formData[obj.fieldName] = obj.value
},
//tabs切换事件
setTabsSwitchFun(tab, prop) {
let tabsItem = this.findObject(this.tabsOption, prop)
tabsItem.tabsValue = tab.name
if (tabsItem.tabClick) {
tabsItem.tabClick(tab)
}
},
//执行填值规则
async executeAllRuleFun() {
let dataObj = this.getFormAllConfigAsDataAsControlFun()
//执行填值规则
let res = await this.mixinGetExecuteRule(
dataObj.columnData,
dataObj.formData
)
if (res) {
this.allExecuteRule = res
this.setFormExecuteRuleFun(res)
dataObj.controlArr.forEach((item) => {
item.setFormExecuteRuleFun(res)
})
}
},
//设置填值规则的值
setFormExecuteRuleFun(rule) {
let column = []
if (this.option.column) {
column = [...column, ...this.option.column]
}
if (this.option.group) {
this.option.group.forEach((item) => {
column = [...column, ...item.column]
})
}
let formData = {}
column.forEach((item) => {
if (item.fillRuleCode) {
formData[item.prop] = rule[item.fillRuleCode]
}
})
this.formData = {
...this.formData,
...formData,
}
},
//获取表单所有的配置、数据 组件
getFormAllConfigAsDataAsControlFun() {
let formData = {
...this.formData,
}
let columnData = [...this.option.column]
if (this.option.group) {
this.option.group.forEach((item) => {
columnData = [...columnData, ...item.column]
})
}
let controlArr = []
//获取表单数据 表单配置
if (this.$refs.formControl) {
this.$refs.formControl.forEach((item) => {
controlArr.push(item)
columnData = [...columnData, ...item.getFormColumnData()]
formData = {
...formData,
...item.getFormDataNullVerify(),
}
})
}
if (this.$refs.tableControl) {
this.$refs.tableControl.forEach((item) => {
controlArr.push(item)
columnData = [...columnData, ...item.tableOption.column]
formData = {
...formData,
...item.tableDataItemDefault,
[item.tableProp]: item.tableData,
}
})
}
for (let key in formData) {
if (formData[key] === undefined) {
formData[key] = ''
}
}
return {
formData,
columnData,
controlArr,
}
},
//js增强处理
setJsEnhanceFun(jsStr, type) {
if (!jsStr) {
return false
}
jsStr = `function jsEnhanceFun(that,api){${jsStr}}`
let fun = analysisFunction(jsStr)
this.jsEnhanceApi = {
getFormData: (key) => this.getFormDataFun(key), //获取form表单的值,如果 key 为空,则返回所有的Data,如果 key 为数组,则返回Data对象
setFormData: (key, value, bool = false) =>
this.setFormDataFun(key, value, bool), //设置form表单的值
setFormOptions: (key, optionsKey, optionsValue) =>
this.setFormOptionsFun(key, optionsKey, optionsValue), //设置字段的配置key:数据绑定Key optionsKey:配置key optionsValue:配置值 例:setFormOptions('select_1','dicData',[{label: '男',value: '1'} ,{label: '女',value: '2'}])
setFormMoreOptions: (key, options, other) =>
this.setFormMoreOptionsFun(key, options, other),
show: (key) => this.setFormControlStateFun(key, 'show'), //显示一个或多个组件 例: 'input_1' / ['input_1','input_2']
hide: (key) => this.setFormControlStateFun(key, 'hide'), // 隐藏一个或多个组件
watch: (watchItems, bool) => this.setWatchFun(watchItems, bool), //监听key值的变化 子表暂不支持监听
get: (url, parameter, config) =>
this.mixinRequestData(url, parameter, 'get', false, config), //发送Get请求 可以是http(s)协议的绝对地址,也可以是相对于后台的地址(以/开头)。
post: (url, parameter, config) =>
this.mixinRequestData(url, parameter, 'post', false, config), // 发送Post请求
put: (url, parameter, config) =>
this.mixinRequestData(url, parameter, 'put', false, config), //发送Put请求
delete: (url, parameter, config) =>
this.mixinRequestData(url, parameter, 'delete', false, config), //发送Put请求
request: (url, parameter, method) =>
this.mixinRequestData(url, parameter, method, 'request'), // 发送请求
executeAllFillRule: () => this.executeAllRuleFun(), // 重新执行所有的填值规则
//表单提交前触发方法
beforeSubmit: (fun) => {
this.beforeSubmit = fun
},
disposeFormDataEnhance: (fun) => {
this.disposeFormDataEnhance = fun
},
submitFormDataEnhance: (fun) => {
this.submitFormDataEnhance = fun
},
}
if (fun !== false) {
try {
fun(this, this.jsEnhanceApi)
} catch (error) {
console.warn(`表单设计增强执行异常${type}`+error)
}
} else {
console.warn(`表单设计增强编写异常${type}`)
}
},
//js增强获取form表单的值
getFormDataFun(key) {
let { formData } = this.getFormAllConfigAsDataAsControlFun()
if (key) {
if (key instanceof Array) {
let obj = {}
key.forEach((item) => {
obj[item] = formData[item]
})
return obj
} else {
return formData[key]
}
} else {
return formData
}
},
//js增强设置from表单的值
setFormDataFun(key, value, bool) {
this.$nextTick(() => {
if (bool) {
let dataObj = { fieldName: key, value }
this.setFormValue(dataObj)
} else {
let { controlArr } = this.getFormAllConfigAsDataAsControlFun()
let forKey = Object.keys(this.formData)
let dataObj = { fieldName: key, value }
let tableKey = this.tableOption.map((item) => item.prop)
if (forKey.includes(key) && !tableKey.includes(key)) {
this.setFormValue(dataObj)
}
controlArr.forEach((item) => {
item.setJsFormDataFun(dataObj)
})
}
})
},
//js增强设置控件配置
setFormOptionsFun(key, optionsKey, optionsValue) {
this.$nextTick(() => {
let { controlArr } = this.getFormAllConfigAsDataAsControlFun()
let column = ''
let group = ''
if (this.option.column) {
column = this.findObject(this.option.column, key)
}
if (this.option.group) {
this.option.group.forEach((item, index) => {
if (this.option.group[index].column.length > 0) {
let currGroup = this.findObject(
this.option.group[index].column,
key
)
if (currGroup != -1) {
group = this.findObject(this.option.group[index].column, key)
}
}
})
}
if (column && column != -1) {
column[optionsKey] = optionsValue
}
if (group && group != -1) {
group[optionsKey] = optionsValue
}
controlArr.forEach((item) => {
item.setFormOptionsFun(key, optionsKey, optionsValue)
})
})
},
setFormMoreOptionsFun(key, options, other) {
if (other === undefined) {
let column = ''
let group = ''
if (this.option.column) {
column = this.findObject(this.option.column, key)
}
if (this.option.group) {
this.option.group.forEach((item, index) => {
if (this.option.group[index].column.length > 0) {
let currGroup = this.findObject(
this.option.group[index].column,
key
)
if (currGroup != -1) {
group = this.findObject(this.option.group[index].column, key)
}
}
})
}
if (column && column != -1) {
for (let key in options) {
column[key] = options[key]
}
}
if (group && group != -1) {
for (let key in options) {
group[key] = options[key]
}
}
} else {
let type = 'formControl'
let optionName = 'option'
if (other.type == 'table') {
type = 'tableControl'
optionName = 'tableOption'
}
let column = this.findObject(
this.$refs[type][other.index][optionName].column,
key
)
for (let key in options) {
column[key] = options[key]
}
if (other.type == 'table') {
setTimeout(() => {
this.$refs[type][other.index].$refs.crud.init()
}, 0)
}
}
},
//js增强设置控件显示/隐藏 type:'show'/'hide'
setFormControlStateFun(key, type) {
this.$nextTick(() => {
let { controlArr } = this.getFormAllConfigAsDataAsControlFun()
if (!(key instanceof Array)) {
key = [key]
}
let optionsKey = 'display'
let optionsValue = ''
if (type == 'show') {
optionsValue = true
}
if (type == 'hide') {
optionsValue = false
}
key.forEach((keyItem) => {
let column = ''
let group = ''
if (this.option.column) {
column = this.findObject(this.option.column, keyItem)
}
if (this.option.group) {
this.option.group.forEach((item, index) => {
if (this.option.group[index].column.length > 0) {
group = this.findObject(
this.option.group[index].column,
keyItem
)
}
})
}
if (column && column != -1) {
column[optionsKey] = optionsValue
}
if (group && group != -1) {
group[optionsKey] = optionsValue
}
})
controlArr.forEach((item) => {
item.setFormControlStateFun(key, optionsValue)
})
})
},
//js增强设置控件值监听
setWatchFun(watchItems, bool = true) {
if (bool) {
if (watchItems instanceof Object && !(watchItems instanceof Array)) {
this.$nextTick(() => {
let tableKey = this.tableOption.map((item) => item.prop)
let keyArr = Object.keys(watchItems)
let formKey = Object.keys(this.formData)
keyArr.forEach((keyItem) => {
if (formKey.includes(keyItem) && !tableKey.includes(keyItem)) {
let watchName = 'formData.' + keyItem
this.$watch(watchName, watchItems[keyItem])
}
})
if (this.$refs.formControl) {
this.$refs.formControl.forEach((item) => {
item.setWatchFun(watchItems)
})
}
})
}
} else {
let keyArr = Object.keys(watchItems)
keyArr.forEach((keyItem) => {
this.$watch(keyItem, watchItems[keyItem])
})
}
},
loadStyleString(cssText) {
if (document.querySelector(`style[id=formremovecss_${this.random}]`)) {
document
.querySelector(`style[id=formremovecss_${this.random}]`)
.remove()
}
var style = document.createElement('style')
style.id = 'formremovecss_' + this.random
try {
// firefox、safari、chrome和Opera
style.appendChild(document.createTextNode(cssText))
} catch (ex) {
// IE早期的浏览器 ,需要使用style元素的stylesheet属性的cssText属性
style.styleSheet.cssText = cssText
}
document.getElementsByTagName('head')[0].appendChild(style)
},
//获取所有控件数量
getControlNum() {
let num = 1
//获取表单数据 表单配置
if (this.$refs.formControl) {
this.$refs.formControl.forEach((item) => {
num = num + 1
if (item.$refs.tableControl) {
item.$refs.tableControl.forEach(() => {
num = num + 1
})
}
})
}
if (this.$refs.tableControl) {
this.$refs.tableControl.forEach(() => {
num = num + 1
})
}
return num
},
//组件触发
tableViewBeforeCloseFun(type, data) {
if (type == 'refreshDic') {
this.$refs.form.dicInit()
} else if (type == 'dialog') {
this.tableSelectControlOption.isDialog = data.bool
} else {
this.tableSelectControlOption.isDialog = false
this.formDynamicFun(type, data)
}
},
//其他表单提交后执行
formViewSubmitFun(done, data) {
if (typeof type == 'function') {
if (this.formControlData.submitFun) {
try {
this.formControlData
.submitFun(data)
.then(() => {
done()
this.formControlData.viewObj.isShow = false
})
.catch(() => {
done()
})
} catch (error) {
done()
console.warn('子表其他表单提交方法异常' + error)
}
}
}else{
this.formControlData.viewObj.isShow = false
}
},
},
beforeDestroy() {
if (this.timer) {
clearInterval(this.timer)
}
if (
document.querySelector(`style[id=formremovecss_${this.random}]`) &&
this.isClearCss
) {
document.querySelector(`style[id=formremovecss_${this.random}]`).remove()
}
},
}
</script>
<style lang="scss" scoped>
.form-custom-print-box {
display: flex;
justify-content: flex-end;
.el-button {
font-size: 20px;
color: #ccc;
display: flex;
width: 42px;
justify-content: flex-end;
height: 22px;
padding: 0;
margin-bottom: 20px;
padding-right: 20px;
}
}
.form-custom {
.form-custom-rate {
padding-top: 10px;
}
.form-custom-tabs {
/deep/.el-tabs__nav {
.el-tabs__item.is-top:nth-child(2) {
padding-left: 20px;
}
}
}
&.avue--detail {
/deep/.el-form-item__label {
padding-right: 10px;
padding-left: 10px;
}
/deep/.el-form-item__content {
.avue-upload--list {
padding-top: 10px;
}
}
}
}
/deep/textarea {
resize: none;
}
/deep/.el-input-number input {
text-align: center !important;
}
/* 禁用时隐藏placeholder */
/deep/.el-form .is-disabled {
input::-webkit-input-placeholder,
textarea::-webkit-input-placeholder {
opacity: 0;
}
input::-moz-placeholder,
textarea::-moz-placeholder {
/* Mozilla Firefox 19+ */
opacity: 0;
}
input:-moz-placeholder,
textarea:-moz-placeholder {
/* Mozilla Firefox 4 to 18 */
opacity: 0;
}
input:-ms-input-placeholder,
textarea:-ms-input-placeholder {
/* Internet Explorer 10-11 */
opacity: 0;
}
}
.control-align-center {
text-align: center;
}
.control-align-left {
text-align: left;
}
.control-align-right {
text-align: right;
}
/deep/.el-form-item__content {
.avue-upload--list {
.el-upload--picture-img {
.avue-upload__icon {
display: flex;
justify-content: center;
align-items: center;
width: 148px;
height: 148px;
}
}
}
}
.form-custom-btn-list {
display: flex;
align-items: center;
margin-bottom: -8px;
.form-custom-button {
margin-left: 0px !important;
&:last-child(1) {
margin-right: 0 !important;
}
}
}
</style>
<style lang="scss">
.form-custom-preview-form-data-alert {
height: 90%;
.el-message-box__header {
border-bottom: 1px solid #f1f1f1;
}
.el-message-box__content {
overflow: auto;
height: calc(100% - 75px);
}
}
</style>
<style lang="scss" scoped>
@import '@/research/styles/form.scss';
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/components/form-custom/form-custom.vue | Vue | apache-2.0 | 70,792 |
<template>
<div
class="table-control"
:class="[
'table-control-box-' + tableColumn.prop,
{ 'table-control-menu-top-hide': !tableOption.isAddRowBtn && meunButtonList.length<=0 },
{ 'table-control-page': tableOption.isSelect },
'table-control_' + random,
]"
v-if="isInit"
>
<div class="table-control-avue-crud" v-if="!tableOption.isBigData">
<avue-crud
ref="crud"
v-model="form"
:option="tableOption"
:data="tableData"
:row-style="rowStyle"
:page.sync="tablePage"
:search.sync="searchData"
@search-change="moreFunObj.searchChange"
@selection-change="selectionChangeFun"
@size-change="moreFunObj.sizeChange"
@current-change="moreFunObj.currentChange"
>
<!-- 菜单自定义(表格上面的按钮栏) -->
<template slot="menuLeft">
<!-- 左边按钮插槽 -->
<el-button
size="small"
type="primary"
icon="el-icon-plus"
v-if="tableOption.isAddRowBtn && formOpenType != 'view'"
@click="rowCellAddFun"
>新 增</el-button>
<el-button
v-for="(item,index) in meunButtonList"
:key="index"
size="small"
:type="item.type?item.type:'primary'"
:icon="item.icon"
v-bind="item.params"
@click="item.clickFun"
>{{item.text}}</el-button>
<el-button
size="small"
type="primary"
icon="el-icon-delete"
@click="deleteAllSelectData"
v-show="tableSelectIndex.length"
>批量删除</el-button>
</template>
<!-- 操作列按钮插槽 -->
<template slot-scope="scope" slot="menu">
<el-button
v-for="(item,index) in linkButtonList"
:key="index"
size="small"
:type="item.type?item.type:'text'"
:icon="item.icon"
v-bind="item.params"
@click="item.clickFun(scope.row,scope.index)"
>{{item.text}}</el-button>
</template>
<!-- 自定义评分 -->
<template
v-for="(rateItem, rateIndex) in rateOption"
slot-scope="scope"
:slot="rateItem.prop + 'Form'"
>
<div class="form-custom-rate" :class="rateItem.class" :key="rateIndex">
<el-rate
:size="scope.size"
v-model="scope.row[rateItem.prop]"
:allow-half="rateItem.allowHalf"
:max="rateItem.max"
></el-rate>
</div>
</template>
<!-- 自定义用户 -->
<template
v-for="(userItem, userIndex) in userOption"
:slot="userItem.prop + 'Form'"
slot-scope="scope"
>
<user-control
:style="userItem.style"
:class="userItem.class"
:key="userIndex"
:tableItemVal="scope.row[userItem.prop]"
:tableItemName="userItem.prop"
:disabled="scope.disabled"
:tableItemScope="Object.assign(scope,{selectable:userItem.selectable})"
exhibitionType="tableEdit"
:multiple="userItem.params.multiple"
@set-form-val="(obj) => setTableFormValue(obj, scope.row.$index)"
:allDepart="allDepart"
:allUserObj="allUserObj"
></user-control>
</template>
<!-- 自定义部门 -->
<template
v-for="(departItem, departIndex) in departOption"
:slot="departItem.prop + 'Form'"
slot-scope="scope"
>
<depart-control
:style="departItem.style"
:class="departItem.class"
:key="departIndex"
:tableItemVal="scope.row[departItem.prop]"
:tableItemName="departItem.prop"
:disabled="scope.disabled"
:tableItemScope="scope"
:multiple="departItem.params.multiple"
@set-form-val="(obj) => setTableFormValue(obj, scope.row.$index)"
></depart-control>
</template>
<!-- 自定义图片控件 -->
<template
v-for="(imgItem, imgIndex) in imgOption"
:slot="imgItem.prop + 'Form'"
slot-scope="scope"
>
<div :key="imgIndex" class="code-sbulist-custom-image-box">
<div
class="box-btn"
v-if="
scope.row[imgItem.prop] == undefined ||
scope.row[imgItem.prop].length <= 0
"
>
<div v-if="scope.disabled">无图片</div>
<el-upload
v-else
:action="imgItem.action"
multiple
:limit="imgItem.limit ? imgItem.limit : 0"
:accept="imgItem.accept"
:before-upload="(file) => customUploadFun(file, scope, imgItem, 'file')"
>
<el-button size="small" plain icon="el-icon-upload">上传图片</el-button>
</el-upload>
</div>
<div
class="box-content"
v-else
@click="opentDialogUploadeFun('image', imgItem.prop, scope.row, imgItem)"
>
<div class="content-img">
<img :src="scope.row[imgItem.prop].split(',')[0]" alt />
</div>
<div
class="content-num"
v-if="scope.row[imgItem.prop].split(',').length > 1"
>+{{ scope.row[imgItem.prop].split(",").length - 1 }}</div>
<div class="content-icon">
<i class="el-icon-setting"></i>
</div>
</div>
</div>
</template>
<!-- 自定义文件控件 -->
<template
v-for="(fileItem, fileIndex) in fileOption"
:slot="fileItem.prop + 'Form'"
slot-scope="scope"
>
<div :key="fileIndex" class="code-sbulist-custom-file-box">
<div
class="box-btn"
v-if="
scope.row[fileItem.prop] == undefined ||
scope.row[fileItem.prop].length <= 0
"
>
<div v-if="scope.disabled">无文件</div>
<el-upload
v-else
:action="fileItem.action"
multiple
:limit="fileItem.limit ? fileItem.limit : 0"
:accept="fileItem.accept"
:before-upload="(file) => customUploadFun(file, scope, fileItem, 'file')"
>
<el-button size="small" plain icon="el-icon-upload">上传文件</el-button>
</el-upload>
</div>
<div
class="box-content"
v-else
@click="opentDialogUploadeFun('file', fileItem.prop, scope.row, fileItem)"
>
<i class="el-icon-link"></i>
<span class="content-txt">
{{
scope.row["$Name" + fileItem.prop]
? scope.row["$Name" + fileItem.prop][0]
: scope.row[fileItem.prop]
}}
</span>
<span
class="content-num"
v-if="scope.row[fileItem.prop].split(',').length > 1"
>+{{ scope.row[fileItem.prop].split(",").length - 1 }}</span>
<i class="el-icon-setting"></i>
</div>
</div>
</template>
<template
v-for="(fileItem, fileIndex) in fileOption"
:slot="fileItem.prop"
slot-scope="scope"
>
<div :key="fileIndex" class="code-sbulist-custom-file-box">
<div
class="box-btn"
v-if="
scope.row[fileItem.prop] == undefined ||
scope.row[fileItem.prop].length <= 0
"
>
<div v-if="scope.disabled || formOpenType == 'view'">无文件</div>
<el-upload
v-else
:action="fileItem.action"
multiple
:limit="fileItem.limit ? fileItem.limit : 0"
:accept="fileItem.accept"
:before-upload="(file) => customUploadFun(file, scope, fileItem, 'file')"
>
<el-button size="small" plain icon="el-icon-upload">上传文件</el-button>
</el-upload>
</div>
<div
class="box-content"
v-else
@click="opentDialogUploadeFun('file', fileItem.prop, scope.row, fileItem)"
>
<i class="el-icon-link"></i>
<span class="content-txt">
{{
scope.row["$Name" + fileItem.prop]
? scope.row["$Name" + fileItem.prop][0]
: scope.row[fileItem.prop]
}}
</span>
<span
class="content-num"
v-if="scope.row[fileItem.prop].split(',').length > 1"
>+{{ scope.row[fileItem.prop].split(",").length - 1 }}</span>
<i class="el-icon-setting"></i>
</div>
</div>
</template>
<!-- 自定义省市区 -->
<template
v-for="(rovItem, rovIndex) in provincesOption"
:slot="rovItem.prop + 'Form'"
slot-scope="scope"
>
<avue-cascader
:key="rovIndex"
:class="[
rovItem.class,
'table-control-row-cascader__' + rovItem.prop + '__' + scope.row.$index,
]"
v-model="scope.row[rovItem.prop]"
lazy
:lazy-load="lazyLoadFun"
:props="rovItem.props"
:style="rovItem.style"
></avue-cascader>
</template>
</avue-crud>
</div>
<div class="table-control-avue-crud-big-data" v-else>
<avue-crud
:key="reload"
ref="crud"
v-model="form"
:option="tableOption"
:data="filteredData"
v-loadmore="handelLoadmore"
:data-size="tableData.length"
:row-style="rowStyle"
@selection-change="selectionChangeFun"
>
<!-- 菜单自定义(表格上面的按钮栏) -->
<template slot="menuLeft">
<!-- 左边按钮插槽 -->
<el-button
size="small"
type="primary"
icon="el-icon-plus"
v-if="tableOption.isAddRowBtn && formOpenType != 'view'"
@click="rowCellAddFun"
>新 增</el-button>
<el-button
size="small"
type="primary"
icon="el-icon-delete"
@click="deleteAllSelectData"
v-show="tableSelectIndex.length"
>批量删除</el-button>
</template>
<!-- 自定义限制文本长度 -->
<template
v-for="(item, index) in viewCustomEllipsisArr"
:slot="item.fieldName"
slot-scope="scope"
>
<avue-text-ellipsis
:key="index"
:text="scope.row[item.fieldName]"
:height="40"
:width="item.lengths"
use-tooltip
placement="top"
>
<small slot="more">...</small>
</avue-text-ellipsis>
</template>
</avue-crud>
</div>
<!-- 文件上传 -->
<el-dialog
v-dialogdrag
:title="dialogTitle"
:visible.sync="isDialog"
class="sbulist-table-dialog-box"
:modal-append-to-body="false"
:append-to-body="true"
:before-close="dialogBeforeClose"
width="530px"
>
<avue-form
v-model="dialogFormData"
:option="dialogFormOption"
:upload-after="uploadAfter"
:upload-exceed="uploadExceedFun"
>
<template
v-if="dialogFormOption.column[0].accept != 'image/*'"
:slot="dialogFormOption.column[0].prop + 'Type'"
slot-scope="scope"
>
<div @click="downloadFile(scope.file.url, scope.file.name)" style="cursor: pointer">
<i class="el-icon-link"></i>
<span style="flex: 1">
{{
dialogFormData["$Name" + dialogFormOption.column[0].prop]
? dialogFormData["$Name" + dialogFormOption.column[0].prop][
scope.file.uid
]
: dialogFormData[dialogFormOption.column[0].prop]
}}
</span>
<i
class="el-icon-close"
v-if="!scope.disabled"
@click.capture.stop="
codeFileControlDelFun(dialogFormOption.column[0].prop, scope)
"
></i>
</div>
</template>
</avue-form>
<div slot="footer" class="dialog-footer">
<el-button @click="isDialog = false">取 消</el-button>
<el-button type="primary" @click="saveDialogUploadeDataFun">确 定</el-button>
</div>
</el-dialog>
<!-- 用户选择 -->
<el-dialog
:title="userControlData.title"
v-dialogdrag
:visible.sync="userControlData.isShow"
v-if="isUserControl"
class="user_dialog_box"
:modal-append-to-body="true"
:append-to-body="true"
width="1200px"
top="20px"
>
<div class="user_dialog_content">
<div class="content-left-tree">
<el-tree
ref="userDepartTree"
:props="userControlData.departProps"
:check-strictly="true"
node-key="value"
:data="userControlData.deptData"
@node-click="userControlData.treeNodeClickFun"
></el-tree>
</div>
<div class="content-right-table">
<avue-crud
ref="userControlTable"
:option="userControlData.tableOption"
:data="userControlData.userData"
:page.sync="userControlData.pageData"
:search.sync="userControlData.searchData"
:table-loading="userControlData.loading"
@selection-change="userControlData.selectionChangeFun"
@current-change="userControlData.currentChangeFun"
@size-change="userControlData.sizeChangeFun"
@search-change="userControlData.searchChangeFun"
@search-reset="userControlData.searchResetFun"
></avue-crud>
</div>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="userControlData.isShow = false">取 消</el-button>
<el-button type="primary" @click="userControlData.submitUserDataFun">确 定</el-button>
</div>
</el-dialog>
<!-- 其他表单 -->
<form-view
ref="formView"
v-if="isFormControl"
:formViewControlFun="formViewSubmitFun"
:formOptionData="formControlData"
></form-view>
</div>
</template>
<script>
import { getStrDataFunction } from '@/research/util/myUtil.js'
import {
getDicTableData,
uploadeFileApi,
getUploadeFileNameApi,
} from '@/api/research/codelist'
import form from '@/research/mixins/form'
import { getDeptTree } from '@/api/system/dept'
import { getList } from '@/api/system/user'
import { apiRequestHead } from '@/config/url.js'
import UserControl from '@/research/components/general-control/user-control'
import DepartControl from '@/research/components/general-control/depart-control'
import FormView from '@/research/components/general-control/form-view.vue'
import Vue from 'vue';
export default {
props: [
'tableColumn',
'tableValue',
'formOpenType',
'allExecuteRule',
'getCurrPacDataTextFun',
'lazyLoadFun',
'allFormListData',
'allDepart',
'allUserObj',
],
components: {
UserControl,
DepartControl,
FormView,
},
computed: {
filteredData() {
let list = this.tableData.filter((item, index) => {
if (index < this.currentStartIndex) {
return false
} else if (index > this.currentEndIndex) {
return false
} else {
return true
}
})
return list
},
},
filters: {
fileNameFilters(value) {
let fileName = value.split('/')
fileName = fileName[fileName.length - 1].split('-').slice(1).join('-')
return fileName
},
},
mixins: [form],
watch: {
isUserControl(newVal) {
if (newVal) {
this.initUserControlDataFun()
}
},
},
data() {
return {
isInit: false,
reload: Math.random(),
random: `${new Date().getTime()}${Math.floor(Math.random() * 10000)}`,
apiRequestHead: '',
valueToload: false,
optinsToLoad: false,
form: {},
allTableData: [],
allArrTableData: [],
searchAllTableData: [],
searchAllArrTableData: [],
tableData: [],
tableDataItemDefault: {},
tableOption: {
align: 'left',
addBtn: false,
columnBtn: false,
refreshBtn: false,
addRowBtn: false,
menu: false,
cellBtn: true,
saveBtn: false,
cancelBtn: false,
index: true, //开启序号
selection: true, //开启选择框
reserveSelection: true, //保留之前的勾选
tip: false,
column: [],
selectable: (row, index) => {
return true
},
},
tablePage: {
total: 0,
currentPage: 1,
pageSize: 10,
pageSizes: [10, 20, 30],
background: true,
layout: 'sizes, prev, pager, next, jumper,total',
},
searchData: {},
tableProp: '',
tableSelectData: [],
tableSelectIndex: [],
meunButtonList: [],
linkButtonList: [],
rateOption: [], //评分
userOption: [], //用户
departOption: [], //部门
imgOption: [], //图片
fileOption: [], //文件
selectRemoteAll: [],
selectDicAll: [],
provincesOption: [], //省市区
viewCustomEllipsisArr: [],
initSelfDefinedArr:[],//已经注册的自定义组件
//弹窗
isDialog: false,
dialogTitle: '上传图片',
dialogFormOption: {
submitBtn: false,
emptyBtn: false,
column: [{}],
},
dialogFormData: {},
// 大数据显示
currentStartIndex: 0,
currentEndIndex: 12,
fieldWidth: [],
//其他方法
moreFunObj: {
sizeChange: () => {},
currentChange: () => {},
searchChange: () => {},
},
// 用户选择
isUserControl: false,
userControlData: {
isShow: false,
multiple: true,
skip: false,
loading: false,
title: '选择用户',
deptData: [],
departProps: {
children: 'children',
label: 'title',
value: 'id',
},
userData: [],
userProps: {
label: 'realName',
value: 'id',
},
searchData: {},
tableOption: {
rowKey: 'id',
selection: true,
reserveSelection: true,
menu: false,
addBtn: false,
columnBtn: false,
refreshBtn: false,
searchMenuSpan: 8,
selectable: () => {
return true
},
column: [
{
prop: 'account',
label: '用户账号',
search: true,
searchSpan: 8,
},
{
prop: 'realName',
label: '用户姓名',
search: true,
searchSpan: 8,
},
{
prop: 'deptName',
label: '部门',
},
],
},
pageData: {
total: 0,
currentPage: 1,
pageSize: 5,
pageSizes: [5, 10, 20, 30],
background: true,
layout: 'sizes, prev, pager, next, jumper,total',
},
},
// 其他表单
isFormControl: false,
formControlData: {},
}
},
mounted() {
this.apiRequestHead = apiRequestHead
this.setTableOptionFun()
this.optinsToLoad = true
this.setRemoteDataDicFun()
this.getApiDataFun()
if (
['edit', 'view', 'noButton', 'add_router'].includes(this.formOpenType)
) {
this.setCurrentTableData()
}
setTimeout(() => {
this.setCustomText()
this.getFileNameFun()
if (this.tableColumn.assigJsEnhance) {
try {
let parentThat = this.tableColumn.getParentFun()
this.tableColumn.assigJsEnhance(this, parentThat)
} catch (error) {
console.warn(
`子表《${this.tableColumn.prop}》赋值后js增强执行错误:${error}`
)
}
}
}, 300)
},
methods: {
rowStyle() {},
//设置当前表格数据
setCurrentTableData() {
let tableDataArr = []
if (this.allFormListData && this.allFormListData[this.tableColumn.prop]) {
tableDataArr = this.allFormListData[this.tableColumn.prop]
}
if (tableDataArr && tableDataArr.length > 0) {
this.tableData = tableDataArr.map((item) => {
if (this.formOpenType == 'edit' && !this.tableOption.isSelect) {
item.$cellEdit = true
}
return item
})
}
},
//初始化树控件/联集文本
setCustomText() {
if (this.provincesOption && this.provincesOption.length > 0) {
this.provincesOption.forEach((item) => {
this.tableData.forEach((dataItem, index) => {
this.setProvincesTextFun(dataItem[item.prop], item.prop, index)
})
})
}
},
//初始化文件名
getFileNameFun() {
let fileArr = []
if (this.fileOption.length > 0) {
this.fileOption.forEach((item) => {
fileArr.push(item.prop)
})
}
this.tableData.forEach((item, index) => {
//处理文件名
if (fileArr.length > 0) {
fileArr.forEach((fileItem) => {
if (item[fileItem] != '' && item[fileItem] != undefined) {
this.tableData[index]['$Name' + fileItem] = []
item[fileItem].split(',').forEach(async (resItem) => {
let fileRes = await getUploadeFileNameApi(resItem)
let fileName = resItem.split('/')
fileName = fileName[fileName.length - 1]
if (fileRes.data.success && fileRes.data.data) {
fileName = fileRes.data.data
}
this.tableData[index]['$Name' + fileItem] = [
...this.tableData[index]['$Name' + fileItem],
fileName,
]
})
}
})
}
})
},
//修改省市区文本方法
setProvincesTextFun(value, propName, index) {
let text = this.getCurrPacDataTextFun(value)
let dom = document.querySelector(
`.table-control-row-cascader__${propName}__${index} input`
)
if (dom) {
dom.value = text ? text : ''
}
},
//清空所有数据
clearAllDataFun() {
this.tableData = []
},
//新增数据
rowCellAddFun() {
this.$refs.crud.rowCellAdd()
setTimeout(() => {
this.tableData = this.tableData.map((item, index) => {
if (index == this.tableData.length - 1) {
item = {
...item,
...this.tableDataItemDefault,
}
}
return item
})
if (this.provincesOption && this.provincesOption.length > 0) {
this.provincesOption.forEach((item) => {
let index = this.tableData.length - 1
this.setProvincesTextFun(
this.tableData[index][item.prop],
item.prop,
index
)
})
}
}, 0)
},
//处理表格配置数据
setTableOptionFun() {
this.tableProp = this.tableColumn.prop
this.tableColumn.children.column = this.tableColumn.children.column.map(
(item) => {
if (!['view', 'noButton'].includes(this.formOpenType)) {
item.cell = true
}
item.minWidth = this.tableColumn.minWidth
return item
}
)
if (this.tableColumn.children.height) {
delete this.tableColumn.children.height
}
this.tableOption = {
...this.tableOption,
...this.tableColumn.children,
}
//选择模式
if (this.tableOption.isSelect) {
this.tableOption = {
...this.tableOption,
selection: true,
reserveSelection: true,
tip: true,
searchMenuSpan: 4,
emptyBtn: false,
searchBtnText: '过滤',
}
}
if (['view', 'noButton'].includes(this.formOpenType)) {
this.tableOption.selection = false
}
if (
this.tableColumn.defaultDataNum > 0 &&
['add', 'add_no'].includes(this.formOpenType)
) {
for (let index = 0; index < this.tableColumn.defaultDataNum; index++) {
this.tableData.push({
$cellEdit: true,
})
}
}
if (this.isBigData && !this.tableOption.maxHeight) {
this.tableOption.maxHeight = 410
}
this.tableOption.column = this.tableOption.column.map((item) => {
this.form[item.prop] = item.value
if (this.tableColumn.isWork) {
item.placeholder = ' '
}
//是否隐藏列
if (!item.display) {
item.hide = true
}
//清除长度限制
if (
(item.isMaxLength !== undefined && item.isMaxLength === false) ||
(item.isMaxLength !== true && item.maxlength === 0)
) {
delete item.maxlength
}
// 设置最小宽度
if (item.style.width) {
try {
item.width = item.style.width.split('px')[0] - 0 + 20
} catch (error) {
console.warn('设置最小宽度失败', error)
}
}
//评分
if (item.type == 'rate') {
this.rateOption.push(item)
}
//用户
if (item.type == 'user') {
item.dicData = []
// item.dataType="string"
item.type = 'select'
if (item.params.multiple) {
item.multiple = true
}
item.props = {
label: 'name',
value: 'id',
}
this.userOption.push(item)
}
//部门
if (item.type == 'depart') {
this.departOption.push(item)
}
//自定义控件
if(item.type=='self-defined'){
if(typeof item.params =='string'){
item.params=getStrDataFunction(item.params)
}
if(!this.initSelfDefinedArr.includes(item.component)){
try {
Vue.component(item.component, res => require([`@/${item.componentPath}`], res))
this.initSelfDefinedArr.push(item.component)
} catch (error) {
console.warn(`${item.component}自定义组件注册异常,${error}`);
}
}
}
//图片
if (item.uploadType == 'img') {
this.imgOption.push(item)
}
//文件
if (item.uploadType == 'file') {
this.fileOption.push(item)
}
//省市区联动
if (item.type == 'provinces') {
item.type = 'cascader'
item.lazyLoad = (node, resolve) =>
this.lazyLoadFun(node, resolve, item.provType)
this.provincesOption.push(item)
}
//判断时间/日期选择器是否开启范围选择
if (item.type == 'date' && item.isRange) {
item.type = 'daterange'
item.dataType = 'string'
}
if (item.type == 'time' && item.isRange) {
item.type = 'timerange'
item.dataType = 'string'
}
//对宽度进行拼接
if (item.style && item.style.width) {
item.style.width = item.style.width + ' !important'
}
//需要把数组处理成字符串的数据
if (item.type == 'select' && item.multiple) {
item.dataType = 'string'
}
if (
['checkbox', 'user', 'depart', 'upload', 'provinces'].includes(
item.type
)
) {
item.dataType = 'string'
}
if (item.type == 'upload') {
item.action = item.action.replace(
'apiRequestHead',
this.apiRequestHead
)
}
//提取需要远端数据的选择字段
if (['select', 'checkbox', 'radio'].includes(item.type)) {
if (item.oldDicOption == 'remote') {
item.dicData = []
this.selectRemoteAll.push(item.prop)
}
if (item.oldDicOption == 'dic') {
this.selectDicAll.push(item.prop)
}
}
if (this.tableOption.isBigData) {
this.viewCustomEllipsisArr.push({
fieldName: item.prop,
lengths: this.tableColumn.minWidth - 20,
})
item.slot = true
// item.width = this.tableColumn.minWidth
}
item = {
...item,
change: () => {},
click: () => {},
focus: () => {},
blur: () => {},
enter: () => {},
control: () => {
return {}
},
}
return item
})
for (let key in this.form) {
if (this.form[key] === undefined) {
this.form[key] = ''
}
}
this.tableDataItemDefault = this.deepClone(this.form)
//获取table字段宽度
if (this.tableOption.isBigData) {
setTimeout(() => {
this.setBigTableColWidth()
}, 1000)
}
if (this.tableColumn.jsEnhanceFun) {
try {
let parentThat = this.tableColumn.getParentFun()
this.tableColumn.jsEnhanceFun(this, parentThat)
} catch (error) {
console.warn(
`子表《${this.tableColumn.prop}》初始化之前js增强执行错误:${error}`
)
}
}
// 对所有用户控件添加字典
if (this.userOption.length > 0) {
let timer = setInterval(() => {
if (this.allUserObj.allList && this.allUserObj.allList.length > 0) {
this.userOption.forEach((item) => {
let column = this.findObject(this.tableOption.column, item.prop)
if (column != -1) {
column.dicData = this.allUserObj.allList
}
})
clearInterval(timer)
}
}, 1000)
}
//表格初始化配置完毕
this.isInit = true
},
//大数据隐藏字段显示处理
setBigTableColWidth() {
let col = document.querySelectorAll(
`.table-control_${this.random} .el-table__header-wrapper colgroup col`
)
let filterNum = 0
if (this.tableOption.selection) {
filterNum++
}
if (this.tableOption.index) {
filterNum++
}
col.forEach((item, index) => {
if (filterNum <= index && index < col.length - 2) {
this.fieldWidth.push(item.getAttribute('width') - 20)
}
})
this.fieldWidth.forEach((item, index) => {
this.viewCustomEllipsisArr[index].lengths = item
})
},
//远程取值方法
async getApiDataFun() {
let apiColumn = []
if (this.tableOption.column) {
apiColumn = [...apiColumn, ...this.tableOption.column]
}
let formData = await this.mixinGetApiData(apiColumn)
for (let key in formData.formObj) {
if (formData.formObj[key] instanceof Array) {
formData.formObj[key] = formData.formObj[key].join(',')
}
}
this.tableDataItemDefault = {
...this.tableDataItemDefault,
...formData.formObj,
}
//预留处理特殊情况
// for (let key in formData.specialObj) {
// }
//修改表格默认值
if (['add', 'add_no'].includes(this.formOpenType)) {
this.tableData = this.tableData.map((item) => {
item = {
...item,
...this.tableDataItemDefault,
}
return item
})
}
//
this.valueToload = true
},
//选择字段远端数据和数据字典处理逻辑
setRemoteDataDicFun() {
//远端数据
if (this.selectRemoteAll.length > 0) {
this.selectRemoteAll.forEach(async (item) => {
let column = this.findObject(this.tableOption.column, item)
if (column.dicUrl) {
let dicData = await this.mixinGetSelectRemoteData(
column.dicUrl,
column.dicDataFormat
)
if (column.excludeStr) {
let excludeArr = column.excludeStr.split(',')
dicData = dicData.filter((item) => {
if (excludeArr.includes(item.value)) {
return false
}
return true
})
}
column.dicData = dicData
if (column.isOneDefaultValue && dicData.length > 0) {
column.value = dicData[0].id
}
}
})
}
//字典处理
if (this.selectDicAll.length > 0) {
this.selectDicAll.forEach(async (item) => {
let column = this.findObject(this.tableOption.column, item)
if (column.queryFormName) {
let dicRes = await getDicTableData(column.queryFormName)
if (dicRes.data.success) {
if (column.excludeStr) {
let excludeArr = column.excludeStr.split(',')
dicRes.data.data = dicRes.data.data.filter((item) => {
if (excludeArr.includes(item.value)) {
return false
}
return true
})
}
column.dicData = dicRes.data.data
} else {
column.dicData = []
}
}
})
}
},
//js增强设置表单值
setJsFormDataFun({ fieldName, value }) {
setTimeout(() => {
if (fieldName == this.tableProp) {
if (value instanceof Array) {
value = value.map((item) => {
item.$cellEdit = true
return item
})
this.tableData = value
}
} else {
if (value instanceof Array) {
value = value.join(',')
}
let tableKey = this.tableOption.column.map((item) => item.prop)
if (tableKey.includes(fieldName)) {
this.tableData = this.tableData.map((item) => {
item[fieldName] = value
return item
})
}
}
}, 0)
},
//js增强设置控件配置
setFormOptionsFun(key, optionsKey, optionsValue) {
this.$nextTick(() => {
let column = ''
if (this.tableOption.column) {
column = this.findObject(this.tableOption.column, key)
}
if (column && column != -1) {
column[optionsKey] = optionsValue
this.$refs.crud.init()
}
})
},
//设置字段多个配置
setFormMoreOptionsFun(key, options) {
let column = ''
if (this.tableOption.column) {
column = this.findObject(this.tableOption.column, key)
}
if (column && column != -1) {
for (let key in options) {
column[key] = options[key]
}
}
},
//js增强设置控件显示/隐藏
setFormControlStateFun(key, value) {
this.$nextTick(() => {
key.forEach((keyItem) => {
let column = ''
if (this.tableOption.column) {
column = this.findObject(this.tableOption.column, keyItem)
}
if (column && column != -1) {
column.hide = !value
this.$refs.crud.columnInit()
}
})
})
},
//选择
selectionChangeFun(column) {
// column 所有选择数据的数组
this.tableSelectData = column
let indexArr = []
column.forEach((item) => {
indexArr.push(item.$index)
})
this.tableSelectIndex = indexArr
},
//批量删除
deleteAllSelectData() {
if (this.tableSelectIndex.length <= 0) {
this.$message({
message: '请先选择需要删除的数据~',
type: 'warning',
})
return false
}
this.tableData = this.tableData.filter((item) => {
if (this.tableSelectIndex.includes(item.$index)) {
return false
} else {
return true
}
})
this.$refs.crud.toggleSelection('')
},
//获取并校验表格数据方法
getTableData() {
return new Promise((resolve) => {
if (this.tableData.length <= 0) {
resolve({
res: true,
prop: this.tableProp,
data: [],
})
return false
}
let resObj = {}
this.$refs.crud.validateCellForm().then((res) => {
let resJson = JSON.stringify(res)
if (resJson == '{}' || resJson === undefined) {
//校验成功
resObj.res = true
} else {
//校验失败
resObj.res = false
}
let allData = this.deepClone(this.tableData)
allData = allData.map((item) => {
let formattingFormData = {}
for (let key in item) {
if (item[key] instanceof Array) {
formattingFormData[key] = item[key].join(',')
} else {
formattingFormData[key] = item[key]
}
}
return formattingFormData
})
resObj = {
...resObj,
prop: this.tableProp,
data: allData,
}
resolve(resObj)
})
})
},
//设置填值规则的值
setFormExecuteRuleFun(rule) {
let column = [...this.tableOption.column]
this.tableData = this.tableData.map((item) => {
let formData = {}
column.forEach((columnItem) => {
if (columnItem.fillRuleCode) {
formData[columnItem.prop] = rule[columnItem.fillRuleCode]
}
})
item = {
...item,
...formData,
}
return item
})
},
//设置表格弹窗表单值
setTableFormValue(obj, index) {
this.tableData[index][obj.fieldName] = obj.value
},
//关闭弹窗前 重置表单数据
dialogBeforeClose(done) {
this.dialogFormData[this.currentDialogField.fieldName] = []
done()
},
//保存弹窗上传的文件或图片方法
saveDialogUploadeDataFun() {
let fileArr = this.deepClone(
this.dialogFormData[this.currentDialogField.fieldName]
)
this.tableData[this.currentDialogField.index][
this.currentDialogField.fieldName
] = fileArr
this.isDialog = false
},
//打开图片或文件弹窗
opentDialogUploadeFun(type, fieldName, row, columnItem) {
this.dialogFormOption.column = []
this.dialogFormData = this.deepClone(row)
this.currentDialogField = {
fieldName,
index: row.$index,
}
if (this.formOpenType == 'view') {
columnItem.disabled = true
}
if (type == 'image') {
this.dialogTitle = '上传图片'
this.isDialog = true
// this.dialogFormOption.column.push({
// accept: 'image/*',
// action: 'api/mjkj-water/cgform-api/upload/file',
// dataType: 'string',
// label: '',
// listType: 'picture-card',
// order: 1,
// prop: fieldName,
// propsHttp: {
// res: 'data',
// url: 'link',
// name: 'originalName',
// },
// data: {
// type: 0,
// },
// span: 24,
// type: 'upload',
// value: '',
// labelWidth: 0,
// disabled: this.disabled,
// })
}
if (type == 'file') {
this.dialogTitle = '上传文件'
this.isDialog = true
// this.dialogFormOption.column.push({
// action: 'api/alioss/uploadFiles',
// dataType: 'array',
// label: '',
// order: 1,
// prop: fieldName,
// propsHttp: {
// name: 'name',
// res: 'result.data',
// url: 'lj',
// },
// span: 24,
// type: 'upload',
// value: '',
// labelWidth: 0,
// disabled: this.disabled,
// })
}
this.dialogFormOption.column.push(columnItem)
},
//图片上传成功
customImgUploadSuccessFun(response, scope, fieldName) {
this.tableData[scope.row.$index][fieldName] = [response.result.data.lj]
},
//监听文件上传
uploadAfter(res, done, loading, column) {
if (column.accept == '*/*') {
if (this.dialogFormData['$Name' + column.prop] instanceof Array) {
this.dialogFormData['$Name' + column.prop].push(res.originalName)
} else {
this.dialogFormData['$Name' + column.prop] = [res.originalName]
}
}
done()
},
codeFileControlDelFun(fileName, obj) {
let arr = []
if (this.dialogFormData[fileName] instanceof Array) {
arr = this.dialogFormData[fileName]
} else {
arr = this.dialogFormData[fileName].split(',')
}
let fileStr = arr.filter((item, index) => {
if (item == obj.file.url) {
this.dialogFormData['$Name' + fileName] = this.dialogFormData[
'$Name' + fileName
].filter((item, i) => index != i)
return false
}
return true
})
fileStr.join(',')
this.dialogFormData[fileName] = fileStr.join(',')
},
//下载文件
downloadFile(url, name) {
var aEle = document.createElement('a') // 创建a标签
aEle.download = name // 设置下载文件的文件名
aEle.href = url // content为后台返回的下载地址
aEle.click() // 设置点击事件
},
//文件、图片上传超过限制上传数 提示
uploadExceedFun(limit, files, fileList, column) {
this.$message({
showClose: true,
message: `<${column.label}>只允许上传${limit}个文件`,
type: 'warning',
})
},
//上传文件 图片
customUploadFun(file, scope, item, type) {
this.$message('正在上传....')
let formdata = new FormData()
formdata.append('file', file)
if (type == 'file') {
formdata.append('type', 1)
} else {
formdata.append('type', 0)
}
uploadeFileApi(formdata)
.then((res) => {
let url = res.data.data.link
let name = res.data.data.originalName
this.tableData = this.tableData.map((tableItem, index) => {
if (index == scope.row.$index) {
tableItem[item.prop] = url
if (type == 'file') {
tableItem['$Name' + item.prop] = [name]
}
}
return tableItem
})
/* this.tableData[scope.row.$index][item.prop] = url
if (type == 'file') {
this.tableData[scope.row.$index]['$Name' + item.prop] = [name]
} */
this.$message({
message: '上传成功',
type: 'success',
})
})
.catch(() => {
this.$message.error(
`上传${type == 'file' ? '文件' : '图片'}失败,请重新上传~`
)
})
return false
},
handelLoadmore(currentStartIndex, currentEndIndex) {
this.currentStartIndex = currentStartIndex
this.currentEndIndex = currentEndIndex
},
//处理手动分页数据
setTableDataPageDataFun(num) {
this.allArrTableData = []
let currArr = []
this.allTableData.forEach((item, index) => {
let i = index + 1
currArr.push(item)
if (i % num == 0 || i == this.allTableData.length) {
this.allArrTableData.push(currArr)
currArr = []
}
})
},
setSearchTableDataPageDataFun(num) {
this.searchAllArrTableData = []
let currArr = []
this.searchAllTableData.forEach((item, index) => {
let i = index + 1
currArr.push(item)
if (i % num == 0 || i == this.searchAllTableData.length) {
this.searchAllArrTableData.push(currArr)
currArr = []
}
})
},
//初始化用户控件相关数据
initUserControlDataFun() {
this.userControlData.tableOption.selectable = (row, index) => {
if (this.userControlData.selectable) {
return this.userControlData.selectable(row, index)
} else {
return true
}
}
this.userControlData.getDeptFun = () => {
getDeptTree().then((deptRes) => {
this.userControlData.deptData = deptRes.data.data
})
}
this.userControlData.getDeptFun()
this.userControlData.getUserFun = (search = {}) => {
this.userControlData.loading = true
let { pageSize, currentPage, currentdepartId } =
this.userControlData.pageData
getList(
currentPage,
pageSize,
Object.assign(this.userControlData.searchData, search),
currentdepartId
).then((userRes) => {
let userData = userRes.data.data
this.userControlData.userData = userData.records
this.userControlData.pageData.total = userData.total
this.userControlData.loading = false
})
}
this.userControlData.getUserFun()
this.userControlData.treeNodeClickFun = (data) => {
this.userControlData.pageData.currentPage = 1
this.userControlData.pageData.currentdepartId = data.id
this.userControlData.getUserFun()
}
this.userControlData.selectionChangeFun = (column) => {
if (!this.userControlData.multiple) {
if (this.userControlData.skip) {
return false
}
this.userControlData.skip = true
this.$refs.userControlTable.toggleSelection('')
let currRow = []
if (column.length > 0) {
currRow.push(column[column.length - 1])
}
this.$refs.userControlTable.toggleSelection(currRow)
setTimeout(() => {
if (currRow.length >= 1) {
this.userControlData.selectData = [currRow[0]]
} else {
this.userControlData.selectData = []
}
this.userControlData.skip = false
}, 0)
} else {
this.userControlData.selectData = column
}
}
this.userControlData.currentChangeFun = (page) => {
this.userControlData.pageData.currentPage = page
this.userControlData.getUserFun()
}
this.userControlData.sizeChangeFun = (pageSize) => {
this.userControlData.pageData.pageSize = pageSize
this.userControlData.getUserFun()
}
this.userControlData.searchChangeFun = (params, done) => {
this.userControlData.searchData = params
this.userControlData.getUserFun()
done()
}
this.userControlData.searchResetFun = () => {
this.userControlData.getUserFun()
}
this.userControlData.submitUserDataFun = () => {
this.userControlData.loading = true
this.userControlData
.submitFun(this.userControlData.selectData)
.then(() => {
this.userControlData.loading = false
this.userControlData.isShow = false
})
.catch(() => {
this.userControlData.loading = false
})
}
},
//其他表单提交后执行
formViewSubmitFun(done, data) {
if (this.formControlData.submitFun) {
try {
this.formControlData
.submitFun(data)
.then(() => {
done()
this.formControlData.viewObj.isShow = false
})
.catch(() => {
done()
})
} catch (error) {
done()
console.warn('子表其他表单提交方法异常' + error)
}
}
},
},
directives: {
loadmore: {
componentUpdated: function (el, binding, vnode, oldVnode) {
// 设置默认溢出显示数量
var spillDataNum = 12
// 设置隐藏函数
var timeout = false
let setRowDisableNone = function (topNum, showRowNum, binding) {
if (timeout) {
clearTimeout(timeout)
}
timeout = setTimeout(() => {
binding.value.call(null, topNum, topNum + showRowNum + spillDataNum)
})
}
setTimeout(() => {
let newScrollTop = ''
let oldScrollTop = ''
const dataSize = vnode.data.attrs['data-size']
const oldDataSize = oldVnode.data.attrs['data-size']
if (dataSize === oldDataSize) return
const selectWrap = el.querySelector('.el-table__body-wrapper')
const selectTbody = selectWrap.querySelector('table tbody')
const selectRow = selectWrap.querySelector('table tr')
if (!selectRow) {
return
}
const rowHeight = selectRow.clientHeight
let showRowNum = Math.round(selectWrap.clientHeight / rowHeight)
const createElementTR = document.createElement('tr')
let createElementTRHeight =
(dataSize - showRowNum - spillDataNum) * rowHeight
createElementTR.setAttribute(
'style',
`height: ${createElementTRHeight}px;`
)
selectTbody.append(createElementTR)
// 监听滚动后事件
selectWrap.addEventListener('scroll', function () {
if (
oldScrollTop &&
newScrollTop &&
oldScrollTop == this.scrollTop
) {
return false
}
oldScrollTop = newScrollTop
newScrollTop = this.scrollTop
let topPx = this.scrollTop - spillDataNum * rowHeight
let topNum = Math.round(topPx / rowHeight)
let minTopNum = dataSize - spillDataNum - showRowNum
if (topNum > minTopNum) {
topNum = minTopNum
}
if (topNum < 0) {
topNum = 0
topPx = 0
}
selectTbody.setAttribute(
'style',
`transform: translateY(${topPx}px)`
)
createElementTR.setAttribute(
'style',
`height: ${
createElementTRHeight - topPx > 0
? createElementTRHeight - topPx
: 0
}px;`
)
setRowDisableNone(topNum, showRowNum, binding)
})
})
},
},
},
activated() {
if (this.tableOption.isBigData)
this.$nextTick(() => {
// this.$refs.crud.doLayout()
})
},
}
</script>
<style lang="scss" scope>
.table-control {
.avue-crud__pagination {
display: none;
}
.avue-crud__empty {
padding: 16px 0;
.avue-empty__desc {
margin-bottom: 0;
}
}
.el-table__row {
.el-form-item {
.avue-checkbox {
.el-checkbox-group {
.el-checkbox:last-child {
margin-right: 10px;
}
}
}
.avue-radio {
.el-radio-group {
.el-radio:last-child {
margin-right: 10px;
}
}
}
.el-cascader {
input {
box-sizing: border-box;
height: 32px;
}
}
}
}
}
.table-control-page {
.avue-crud__pagination {
display: block;
}
}
</style>
<style lang="scss">
.code-sbulist-custom-image-box {
.box-content {
display: flex;
cursor: pointer;
.content-img {
width: 32px;
height: 32px;
}
.content-num {
width: 32px;
height: 32px;
background-color: rgba($color: #999, $alpha: 0.7);
margin-left: 5px;
color: #fff;
line-height: 32px;
text-align: center;
border-radius: 2px;
}
.content-icon {
line-height: 32px;
font-size: 14px;
padding-left: 8px;
}
img {
width: 32px;
height: 32px;
}
}
}
.code-sbulist-custom-file-box {
.box-content {
display: flex;
align-items: center;
cursor: pointer;
i {
font-size: 14px;
}
.content-txt {
max-width: 100px;
padding: 0 5px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.content-num {
width: 28px;
height: 28px;
background-color: rgba($color: #999, $alpha: 0.7);
color: #fff;
line-height: 28px;
text-align: center;
margin-right: 6px;
border-radius: 2px;
}
}
}
.sbulist-table-dialog-box {
.el-dialog__header {
border-bottom: 1px solid #f1f1f1;
}
.avue-form__menu--center {
display: none;
}
.el-dialog__body {
padding-bottom: 0px;
}
}
.table-control-menu-top-hide {
.avue-crud__menu {
display: none;
}
}
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/components/form-custom/table-control.vue | Vue | apache-2.0 | 53,954 |
<template>
<!-- 组件显示 -->
<div>
<el-dialog
v-dialogdrag
element-loading-background="transparent"
v-if="formOptionData.viewObj.type == 'dialog'"
:title="formOptionData.viewObj.title"
:visible.sync="formOptionData.viewObj.isShow"
:destroy-on-close="formOptionData.viewObj.destroy ? true : false"
:modal-append-to-body="false"
:close-on-click-modal="false"
:append-to-body="true"
:width="formOptionData.viewObj.width"
v-bind="formOptionData.viewObj.params"
>
<div
v-if="
formOptionData.viewObj.destroy ? formOptionData.viewObj.isShow : true
"
>
<component
:ref="`${formOptionData.type}`"
:is="formOptionData.type"
:defaultData="formOptionData.defaultData"
:params="formOptionData.params"
:controlViewFun="controlViewFun.bind(this)"
:isShow="formOptionData.viewObj.isShow"
></component>
</div>
<span slot="footer" class="dialog-footer"></span>
</el-dialog>
<el-drawer
v-if="formOptionData.viewObj.type == 'drawer'"
element-loading-background="rgba(255,255,255,0.3)"
:title="formOptionData.viewObj.title"
:size="formOptionData.viewObj.width"
:visible.sync="formOptionData.viewObj.isShow"
:destroy-on-close="formOptionData.viewObj.destroy ? true : false"
:modal-append-to-body="false"
:close-on-click-modal="false"
:append-to-body="true"
v-bind="formOptionData.viewObj.params"
>
<div
v-if="
formOptionData.viewObj.destroy ? formOptionData.viewObj.isShow : true
"
>
<component
:ref="`${formOptionData.type}`"
:is="formOptionData.type"
:defaultData="formOptionData.defaultData"
:params="formOptionData.params"
:controlViewFun="controlViewFun.bind(this)"
:isShow="formOptionData.viewObj.isShow"
></component>
</div>
</el-drawer>
</div>
</template>
<script>
export default {
name: "controlView",
data() {
return {};
},
watch: {},
props: [
"formOptionData",
/*
'viewObj':{
isShow:false, //是否显示
type:'drawer', //弹窗类型 表单:view 抽屉:drawer 弹窗:dialog
title:'编辑', //抽屉、弹窗的标题文本
width:1100, //弹窗宽度
}, //展示类型配置
type:'',//组件类型
defaultData:{ //默认的数据
},
*/
"controlViewFun",
],
mounted() {
this.init();
},
methods: {
async init() {},
},
};
</script>
<style lang="scss">
.el-drawer__body {
overflow: auto;
}
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/components/general-control/control-view.vue | Vue | apache-2.0 | 2,707 |
<template>
<div class="depart-control">
<div class="depart-control-box" :class="{ 'depart-control-box-disabled': disabled }">
<!-- <div class="depart-control-icon">
<svg
viewBox="64 64 896 896"
data-icon="cluster"
width="1em"
height="1em"
fill="currentColor"
aria-hidden="true"
focusable="false"
class
>
<path
d="M888 680h-54V540H546v-92h238c8.8 0 16-7.2 16-16V168c0-8.8-7.2-16-16-16H240c-8.8 0-16 7.2-16 16v264c0 8.8 7.2 16 16 16h238v92H190v140h-54c-4.4 0-8 3.6-8 8v176c0 4.4 3.6 8 8 8h176c4.4 0 8-3.6 8-8V688c0-4.4-3.6-8-8-8h-54v-72h220v72h-54c-4.4 0-8 3.6-8 8v176c0 4.4 3.6 8 8 8h176c4.4 0 8-3.6 8-8V688c0-4.4-3.6-8-8-8h-54v-72h220v72h-54c-4.4 0-8 3.6-8 8v176c0 4.4 3.6 8 8 8h176c4.4 0 8-3.6 8-8V688c0-4.4-3.6-8-8-8zM256 805.3c0 1.5-1.2 2.7-2.7 2.7h-58.7c-1.5 0-2.7-1.2-2.7-2.7v-58.7c0-1.5 1.2-2.7 2.7-2.7h58.7c1.5 0 2.7 1.2 2.7 2.7v58.7zm288 0c0 1.5-1.2 2.7-2.7 2.7h-58.7c-1.5 0-2.7-1.2-2.7-2.7v-58.7c0-1.5 1.2-2.7 2.7-2.7h58.7c1.5 0 2.7 1.2 2.7 2.7v58.7zM288 384V216h448v168H288zm544 421.3c0 1.5-1.2 2.7-2.7 2.7h-58.7c-1.5 0-2.7-1.2-2.7-2.7v-58.7c0-1.5 1.2-2.7 2.7-2.7h58.7c1.5 0 2.7 1.2 2.7 2.7v58.7zM360 300a40 40 0 1 0 80 0 40 40 0 1 0-80 0z"
/>
</svg>
</div>-->
<avue-input-tree
:key="treeKey"
v-model="tableItemVal"
placeholder="请选择 部门"
type="tree"
:multiple="multiple"
:checkStrictly="true"
:dic="allDepartData"
:props="departProps"
:size="tableItemScope ? tableItemScope.size : ''"
:disabled="true"
@click="openDepartDialogFun(tableItemVal, tableItemName,!disabled)"
></avue-input-tree>
</div>
<el-dialog
v-dialogdrag
:title="this.disabled ? '部门' : '选择部门'"
:visible.sync="departDialog"
class="depart_dialog_box"
:modal-append-to-body="false"
:append-to-body="true"
width="450px"
>
<div style="margin-bottom: 5px">
<el-input placeholder="输入部门名称进行搜索" v-model="filterText"></el-input>
</div>
<el-tree
ref="departTree"
:props="departProps"
show-checkbox
:check-strictly="true"
:default-expand-all="true"
node-key="id"
:data="allDepartData"
:filter-node-method="filterNode"
@check-change="handleClick"
@node-click="nodeClick"
></el-tree>
<div slot="footer" class="dialog-footer">
<el-button @click="departDialog = false">取 消</el-button>
<el-button type="primary" @click="setDepartInputValueFun">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { getDeptTree } from '@/api/system/dept'
export default {
props: [
'tableItemVal',
'tableItemName',
'disabled',
'tableItemScope',
'setFormValueFun',
'multiple',
],
data() {
return {
filterText: '',
allDepartData: [],
departProps: {
children: 'children',
label: 'title',
value: 'id',
},
departDialog: false,
}
},
watch: {
filterText(val) {
this.$refs.departTree.filter(val)
},
},
computed: {
treeKey() {
if (this.tableItemVal && this.tableItemVal instanceof Array) {
return this.tableItemVal.join('')
}
return 0
},
},
mounted() {
//获取部门数据
getDeptTree().then((res) => {
this.allDepartData = res.data.data
})
// 禁用
if (this.disabled) {
this.departProps.disabled = () => {
return true
}
}
},
methods: {
//单选逻辑
handleClick(data, checked) {
if (checked == true && !this.multiple) {
this.$refs.departTree.setCheckedNodes([data])
}
},
nodeClick(data) {
if (!this.multiple) {
this.$refs.departTree.setCheckedNodes([data])
}
},
// 过滤
filterNode(value, data) {
if (!value) return true
return data.label.indexOf(value) !== -1
},
//打开部门选择弹窗
openDepartDialogFun(value, fieldName, bool) {
if (!bool) {
return false
}
if (!(value instanceof Array)) {
if (value && typeof value == 'string') {
value = value.split(',')
} else {
value = []
}
}
this.departDialog = true
setTimeout(() => {
this.$refs.departTree.setCheckedKeys(value)
}, 0)
this.setParentFormValFun({
fieldName,
value,
})
},
//设置部门控件值
setDepartInputValueFun() {
this.setParentFormValFun({
fieldName: this.tableItemName,
value: [],
})
setTimeout(() => {
this.setParentFormValFun({
fieldName: this.tableItemName,
value: this.$refs.departTree.getCheckedKeys(),
})
this.departDialog = false
}, 0)
},
//调用父组件设置表单值方法{fieldName:'',value:''}
setParentFormValFun(obj) {
if (obj.value && obj.value instanceof Array) {
obj.value = obj.value.join(',')
} else {
obj.value = ''
}
if (this.setFormValueFun) {
this.setFormValueFun(obj)
}
this.$emit('set-form-val', obj)
},
},
}
</script>
<style lang="scss">
.depart_dialog_box {
.el-dialog__header {
border-bottom: 1px solid #f1f1f1;
}
}
.depart-control-box {
.el-select__tags {
// padding-left: 22px;
}
input::-webkit-input-placeholder {
opacity: 1 !important;
}
input::-moz-placeholder {
/* Mozilla Firefox 19+ */
opacity: 1 !important;
}
input:-moz-placeholder {
/* Mozilla Firefox 4 to 18 */
opacity: 1 !important;
}
input:-ms-input-placeholder {
/* Internet Explorer 10-11 */
opacity: 1 !important;
}
input {
background-color: #fff !important;
cursor: pointer !important;
color: #565c69 !important;
// padding-left: 28px !important;
// padding-right: 15px !important;
}
.el-input__suffix {
cursor: pointer;
display: none;
}
.depart-control-icon {
position: absolute;
left: 8px;
top: 50%;
transform: translateY(-50%);
margin-top: 2px;
z-index: 999;
}
}
.depart-control-box-disabled {
cursor: pointer !important;
input::-webkit-input-placeholder {
opacity: 0 !important;
}
input::-moz-placeholder {
/* Mozilla Firefox 19+ */
opacity: 0 !important;
}
input:-moz-placeholder {
/* Mozilla Firefox 4 to 18 */
opacity: 0 !important;
}
input:-ms-input-placeholder {
/* Internet Explorer 10-11 */
opacity: 0 !important;
}
input {
background-color: #f5f7fa !important;
}
}
.avue--detail {
.depart-control-box-disabled {
input {
background-color: #fff !important;
}
}
}
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/components/general-control/depart-control.vue | Vue | apache-2.0 | 6,923 |
<template>
<div
:class="{ 'form-view-min-height': loading }"
v-loading="loading && formOptionData.viewObj.type == 'view'"
>
<form-custom
v-if="isShow && formOptionData.viewObj.type == 'view'"
ref="formCustom"
:formOption="widgetFormPreview"
:formOpenType="formOptionData.formOpenType"
:actionData="formOptionData.actionData"
:onlineFormId="formOptionData.onlineFormId"
:allFormListData="formData"
:btnPermissions="formOptionData.btnPermissions"
:closeDialogForm="performHiedViewFun.bind(this)"
:isDetailStyle="formOptionData.isDetailStyle"
></form-custom>
<el-dialog
v-loading="loading"
element-loading-background="transparent"
v-if="formOptionData.viewObj.type == 'dialog'"
top="10vh"
:title="formOptionData.viewObj.title"
:visible.sync="formOptionData.viewObj.isShow"
:destroy-on-close="formOptionData.viewObj.destroy?true:false"
:modal-append-to-body="true"
:close-on-click-modal="false"
:append-to-body="true"
:width="formOptionData.viewObj.width"
v-bind="formOptionData.viewObj.params"
custom-class="dialog-form-view-min-height"
>
<form-custom
v-if="isShow"
ref="formCustom"
:formOption="widgetFormPreview"
:formOpenType="formOptionData.formOpenType"
:actionData="formOptionData.actionData"
:onlineFormId="formOptionData.onlineFormId"
:allFormListData="formData"
:closeDialogForm="performHiedViewFun.bind(this)"
:btnPermissions="formOptionData.btnPermissions"
:isDetailStyle="formOptionData.isDetailStyle"
></form-custom>
<span slot="footer" class="dialog-footer"></span>
</el-dialog>
<el-drawer
v-loading="loading"
v-if="formOptionData.viewObj.type == 'drawer'"
element-loading-background="rgba(255,255,255,0.3)"
:title="formOptionData.viewObj.title"
:size="formOptionData.viewObj.width"
:visible.sync="formOptionData.viewObj.isShow"
:destroy-on-close="formOptionData.viewObj.destroy?true:false"
:modal-append-to-body="false"
:close-on-click-modal="false"
:append-to-body="true"
v-bind="formOptionData.viewObj.params"
>
<form-custom
v-if="isShow"
ref="formCustom"
:formOption="widgetFormPreview"
:formOpenType="formOptionData.formOpenType"
:actionData="formOptionData.actionData"
:onlineFormId="formOptionData.onlineFormId"
:allFormListData="formData"
:closeDialogForm="performHiedViewFun.bind(this)"
:btnPermissions="formOptionData.btnPermissions"
:isDetailStyle="formOptionData.isDetailStyle"
></form-custom>
</el-drawer>
</div>
</template>
<script>
import { getdetailDataApi } from '@/api/research/form'
import { getDataApi, getDataDetailApi } from '@/api/research/codelist'
export default {
name: 'FormView',
data() {
return {
isInit: false,
loading: false,
timer: null,
isShow: false,
widgetFormPreview: '', //表单配置
desFormData: {},
formData: {},
}
},
watch: {
formOptionData: {
handler(newVal) {
if (this.isInit == false) {
if (newVal.defaultData && !newVal.viewObj.isGetData) {
this.formData = {
...newVal.defaultData,
}
}
if (newVal.viewObj.isGetData) {
this.getFormDataFun(newVal.tableId)
}
} else if (newVal.viewObj.isShow) {
//表单显示的时候执行
// 赋予默认值
if (newVal.defaultData && !newVal.viewObj.isGetData) {
this.isShow = false
this.loading = true
this.formData = {
...newVal.defaultData,
}
if (!newVal.viewObj.carryInit && !newVal.viewObj.isGetData) {
setTimeout(() => {
this.isShow = true
this.loading = false
}, 200)
}
}
if (newVal.viewObj.carryInit) {
this.init()
}
if (newVal.viewObj.isGetData) {
this.getFormDataFun(newVal.tableId)
}
}
},
immediate: true, //一开始先执行一次handler
deep: true, //深监听
},
},
props: [
'formOptionData',
/*
formId:'表单设计id',
onlineFormId:'表单开发id',
params:{},//数据接口请求参数
formOpenType:'当前弹窗类型',
actionData:{
type:'接口存储类型',
noRouter:true,//不启用路由配置
closeType:,//关闭类型
isMessage:,//是否提示
},
btnPermissions:{ //表单按钮权限配置
clearBtn: true,
cancelBtn: false,
submitBtn: true,
},
'viewObj':{
isShow:false, //是否显示表单
type:'drawer', //弹窗类型 表单:view 抽屉:drawer 弹窗:dialog
title:'编辑', //抽屉、弹窗的标题文本
width:1100, //弹窗宽度
isGetData:false,//是否需要获取数据
carryInit:false,//是否需要重新初始化表单配置
isExternalSearch:true,//是否需要合并外部搜索
}, //展示类型配置
defaultData:{ //默认的数据
},
isDetailData:true,//是否获取父子表数据
dataId:,//父子表数据的数据id
*/
'formViewControlFun',
'params', //搜索参数
],
mounted() {
if (this.formOptionData.formId && this.formOptionData.isLazy !== true) {
this.init()
}
},
methods: {
async performHiedViewFun(type, data) {
if (typeof type == 'function') {
if (this.formOptionData.submitFun) {
try {
this.formOptionData
.submitFun(data)
.then(() => {
type()
this.formViewControlFun('hide')
})
.catch(() => {
type()
})
} catch (error) {
type()
console.warn('表单自定义提交方法异常' + error)
}
} else {
type()
console.warn('请配置自定义提交方法 submitFun')
}
}
if (type) {
return this.formViewControlFun(type, data)
} else {
this.formViewControlFun('hide')
}
},
async init() {
this.isShow = false
this.loading = true
this.widgetFormPreview = ''
//获取表单配置
let detailRes = await getdetailDataApi(this.formOptionData.formId)
let options = {}
this.desFormData = detailRes.data.data
if (detailRes.data.success && detailRes.data.data.formDesignJson) {
options = detailRes.data.data.formDesignJson
}
if (typeof options == 'string') {
try {
options = eval('(' + options + ')')
} catch (e) {
console.error('非法配置')
options = { column: [] }
}
}
this.widgetFormPreview = this.deepClone(options)
if (!this.formOptionData.viewObj.isGetData) {
this.isInit = true
this.isShow = true
this.loading = false
}
},
getFormDataFun() {
//获取表单数据
this.loading = true
this.isShow = false
if (this.timer) {
clearTimeout(this.timer)
}
this.timer = setTimeout(async () => {
if (this.formOptionData.defaultData) {
this.formData = {
...this.formOptionData.defaultData,
}
} else {
this.formData = {}
}
//判断搜索配置是否有值
let searchObj = {
...this.formOptionData.params,
}
if (
this.params &&
this.formOptionData.viewObj.isExternalSearch !== false
) {
searchObj = {
...searchObj,
...this.params,
}
}
let objKey = Object.keys(searchObj)
let bool = true
objKey.forEach((item) => {
let value = searchObj[item]
if (value === undefined || value === '' || value === null) {
bool = false
}
})
let isGetDataInfo = false
//通过搜索取第一条数据赋值给表单
if (this.formOptionData.isDetailData != true) {
let params = {}
if (bool) {
params = searchObj
}
let tableDataRes = await getDataApi(
this.formOptionData.onlineFormId,
params
)
let data = tableDataRes.data.data
if (data && data.records && data.records.length > 0) {
this.formData = {
...this.formData,
...data.records[0],
}
}
isGetDataInfo = true
} else {
//通过数据id取数据赋值给表单
//获取父子表数据
let tableDataRes = await getDataDetailApi(
this.formOptionData.onlineFormId,
this.formOptionData.dataId,
searchObj
)
let data = tableDataRes.data.data
if (data) {
this.formData = {
...this.formData,
...data,
}
}
isGetDataInfo = true
}
// 等待表单配置获取完成后显示表单
let timer = setInterval(() => {
this.isShow = false
if (this.widgetFormPreview != '' && isGetDataInfo === true) {
clearInterval(timer)
console.log(
'form-view======>数据显示',
timer,
this.deepClone(this.formData),
this.isShow
)
this.isInit = true
this.isShow = true
this.loading = false
}
}, 1000)
}, 1000)
},
},
}
</script>
<style lang="scss" scoped>
.form-view-min-height {
min-height: 100px;
}
</style>
<style lang="scss">
.el-drawer__body {
overflow: auto;
/* overflow-x: auto; */
}
.department-declare-info {
.btn {
text-align: right;
padding-right: 20px;
}
}
.dialog-form-view-min-height {
.el-dialog__body {
min-height: 100px;
}
}
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/components/general-control/form-view.vue | Vue | apache-2.0 | 10,325 |
<template>
<div class="select-control">
<div class="select-control-box">
<avue-select
ref="tableSelect"
v-model="selectValue"
:placeholder="'请选择 ' + selecText"
type="tree"
:props="tableProps"
:multiple="true"
:dic="allTableData"
:size="tableItemScope ? tableItemScope.size : ''"
:disabled="true"
@click="openTableSelectDialogFun(tableItemVal, tableItemName, true)"
></avue-select>
</div>
<el-dialog
:title="'请选择 ' + selecText"
v-dialogdrag
:visible.sync="selectDialog"
v-if="selectDialog"
class="user_dialog_box"
:modal-append-to-body="true"
:append-to-body="true"
width="1200px"
top="20px"
>
<div class="user_dialog_content" v-loading="isTableLoading">
<div class="content-left-tree" v-if="isTree">
<el-tree
ref="userDepartTree"
:props="treeProps"
:check-strictly="true"
node-key="value"
:data="allTreeData"
@node-click="treeNodeClickFun"
></el-tree>
</div>
<div class="content-right-table">
<avue-crud
ref="tableControl"
:option="tableOption"
:data="tableData"
:page.sync="tablePage"
:table-loading="loading"
:search.sync="tableQueryData"
@selection-change="selectionChangeFun"
@current-change="currentChangeFun"
@size-change="sizeChangeFun"
@search-change="searchChangeFun"
@search-reset="searchResetFun"
></avue-crud>
</div>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="selectDialog = false">
{{ disabled ? "关闭" : "取 消" }}
</el-button>
<el-button type="primary" @click="setInputValueFun" v-if="!disabled"
>确 定</el-button
>
</div>
</el-dialog>
</div>
</template>
<script>
import { apiRequestHead } from "@/config/url.js";
import { setTreeDataUtil } from "@/research/util/myUtil";
import {
getDataApi,
getTreeDataApi,
getActionApi,
postActionApi,
} from "@/api/research/codelist";
export default {
props: [
"tableItemVal", //当前选择数据值
"tableItemName", //当前控件字段名
"disabled", //是否禁用
"size", //控件大小
"tableItemScope", //控件配置
"setFormValueFun", //设置值的方法
"multiple", //是否多选
"selecText", //文本
"configJson", //其他配置函数
"isTree", //是否开启树筛选
"treeDataUrl", //树数据请求路径
"treeTableId", //树数据表单开发id
"treeParams", //树数据请求参数
"treeMethod", //树数据请求方法
"treeFormatt", //树数据格式化
"tableId", //表格数据 表单开发id
"treeApiMode", //数据获取方式 table 表单开发 custom 自定义
],
data() {
return {
getActionApi,
postActionApi,
apiRequestHead,
outherObj: {
searchObj: {}, //默认搜索值
},
tableQueryData: {}, //搜索参数
isTableLoading: false,
skip: false,
loading: false,
selectDialog: false,
tableProps: {
label: "label",
value: "id",
},
treeProps: {
children: "children",
label: "label",
value: "id",
searchProp: "id",
},
allTableData: [],
allTreeData: [],
allTableSelectId: [], //用户选择的数据id
tableOption: {
rowKey: "id",
selection: true,
reserveSelection: true,
menu: false,
addBtn: false,
columnBtn: false,
refreshBtn: false,
searchMenuSpan: 8,
column: [],
},
tableData: [], //当前表格页数据
tablePage: {
total: 0,
currentPage: 1,
pageSize: 10,
pageSizes: [10, 20, 30],
background: true,
layout: "sizes, prev, pager, next, jumper,total",
currentTreeId: "",
},
};
},
watch: {},
computed: {
selectValue: {
get() {
if (this.tableItemVal && this.tableItemVal instanceof Array) {
if (this.tableItemVal.length > 0) {
return this.tableItemVal;
}
return "";
} else {
if (this.tableItemVal) {
return this.tableItemVal.split(",");
}
return "";
}
},
set() {},
},
},
async mounted() {
this.init();
//禁用选择
if (this.disabled) {
this.tableOption.selectable = () => {
return false;
};
}
},
methods: {
//初始化项目
async init() {
let bool = true;
if (this.tableItemScope) {
let column = this.tableItemScope.column;
if (column && column.dicData && column.dicData.length > 0) {
this.allTableData = column.dicData;
bool = false;
}
}
this.isTableLoading = true;
try {
let getDataFun = `function getDataFun(that){${this.configJson}}`;
getDataFun = this.getFunction(getDataFun);
let data = getDataFun();
for (let key in data) {
if (key == "tablecolumn") {
this.tableOption.column = data[key];
} else {
this[key] = data[key];
}
}
} catch (error) {
console.warn("其他配置格式异常");
}
this.allTreeData = await this.getTreeDataFun();
if (bool) {
this.allTableData = await this.getTableDataFun("all");
}
this.isTableLoading = false;
await this.getTableDataFun();
},
//获取树表格数据
getTreeDataFun() {
return new Promise((resolve) => {
if (!this.isTree) {
resolve([]);
return false;
}
if (this.treeTableId && this.treeApiMode == "table") {
getTreeDataApi(this.treeTableId).then((res) => {
try {
let data = res.data.data.records;
data = setTreeDataUtil(data, "pid");
resolve(data);
} catch (error) {
resolve([]);
}
});
} else if (this.treeDataUrl && this.treeApiMode == "custom") {
let url = this.treeDataUrl;
if (url.indexOf("/") == 0) {
url = url.replace("/api/", this.apiRequestHead + "/");
} else {
url = url.replace("api/", "");
}
let params = {};
try {
params = {
...JSON.parse(this.treeParams),
};
} catch (error) {
console.warn("表格选择控件,请求参数配置异常");
}
let apiType = "getActionApi";
if (this.treeMethod == "post") {
apiType = "postActionApi";
}
this[apiType](url, {
...params,
}).then((res) => {
resolve(this.dataFormatting(res, this.treeFormatt));
});
} else {
resolve([]);
}
});
},
//获取表格数据
getTableDataFun(type) {
return new Promise((resolve) => {
if (this.tableId) {
let params = {
pageNo: this.tablePage.currentPage,
pageSize: type == "all" ? -521 : this.tablePage.pageSize,
};
if (type != "all") {
params = {
...params,
...this.outherObj.searchObj,
...this.tableQueryData,
};
if (this.tablePage.currentTreeId) {
params = {
...params,
[this.treeProps.searchProp]: this.tablePage.currentTreeId,
};
}
}
this.loading = true;
getDataApi(this.tableId, params).then((res) => {
try {
if (type != "all") {
this.tableData = res.data.data.records;
this.tablePage.total = res.data.data.total;
}
resolve(res.data.data.records);
this.loading = false;
} catch (error) {
resolve([]);
this.loading = false;
}
});
} else {
resolve([]);
}
});
},
//格式化数据
dataFormatting(res, formatt) {
if (!formatt) {
return res;
}
formatt = formatt.split(".");
formatt.forEach((item) => {
res = res[item];
});
return res;
},
//解析函数
getFunction(fun) {
if (fun) {
fun = fun.replace(/↵/g, "\n");
fun = fun.replace(/\/\*{1,2}[\s\S]*?\*\//gis, "");
// fun = fun.replace(/(?:^|\n|\r)\s*\/\*[\s\S]*?\*\/\s*(?:\r|\n|$)/g, '')
fun = fun.replace(/(?:^|\n|\r)\s*\/\/.*(?:\r|\n|$)/g, "");
try {
if (eval(`(${fun})`)) {
return eval(`(${fun})`);
} else {
return () => {};
}
} catch {
console.warn("请检查其他配置编写是否有误~");
return () => {};
}
}
},
//打开表格选择弹窗
openTableSelectDialogFun(value, fieldName, bool) {
if (!bool) {
return false;
}
this.selectDialog = true;
setTimeout(() => {
this.$refs.tableControl.toggleSelection("");
let selectCheckedArr = [];
this.allTableData.forEach((item) => {
if (value != undefined && value.includes(item.id)) {
selectCheckedArr.push(item);
}
});
this.$refs.tableControl.toggleSelection(selectCheckedArr);
}, 0);
this.tablePage.currentPage = 1;
this.tablePage.pageSize = 10;
this.tablePage.currentTreeId = "";
this.getTableDataFun();
},
//设置选择控件值
setInputValueFun() {
this.setParentFormValFun({
fieldName: this.tableItemName,
value: this.allTableSelectId,
});
this.selectDialog = false;
},
//表格选择
selectionChangeFun(column) {
if (!this.multiple) {
//单选
if (this.skip) {
return false;
}
this.skip = true;
this.$refs.tableControl.toggleSelection("");
let currRow = [];
if (column.length > 0) {
currRow.push(column[column.length - 1]);
}
this.$refs.tableControl.toggleSelection(currRow);
setTimeout(() => {
if (currRow.length >= 1) {
this.allTableSelectId = [currRow[0].id];
} else {
this.allTableSelectId = [];
}
this.skip = false;
}, 0);
} else {
//多选
let idArr = [];
column.forEach((item) => {
idArr.push(item.id);
});
this.allTableSelectId = idArr;
}
},
//用户控件表格搜索
searchChangeFun(params, done) {
this.tableQueryData = params;
done();
},
//用户控件表格清空搜索
searchResetFun() {
this.tableQueryData = {};
this.tablePage.currentPage = 1;
this.getTableDataFun();
},
//表格切换页
currentChangeFun(page) {
this.tablePage.currentPage = page;
this.getTableDataFun();
},
//表格每页显示数
sizeChangeFun(pageSize) {
this.tablePage.currentPage = 1;
this.tablePage.pageSize = pageSize;
this.getTableDataFun();
},
//点击部门树触发
treeNodeClickFun(data) {
this.tablePage.currentPage = 1;
this.tablePage.currentTreeId = data[this.treeProps.value]
? data[this.treeProps.value]
: "id";
this.getTableDataFun();
},
//调用父组件设置表单值方法{fieldName:'',value:''}
setParentFormValFun(obj) {
if (obj.value && obj.value instanceof Array) {
obj.value = obj.value.join(",");
}
this.setFormValueFun(obj);
},
},
};
</script>
<style lang="scss">
.user_dialog_box {
.user_dialog_content {
padding: 10px;
display: flex;
background-color: rgb(236, 236, 236);
.content-left-tree {
background-color: #fff;
flex: 0 0 290px;
box-sizing: border-box;
padding: 24px;
margin-right: 10px;
border-radius: 5px;
}
.content-right-table {
flex: 1;
box-sizing: border-box;
background-color: #fff;
border-radius: 5px;
padding: 24px;
.avue-crud__menu {
margin-bottom: 0px;
display: none;
}
}
}
}
.user_dialog_box {
.el-dialog__header {
border-bottom: 1px solid #f1f1f1;
}
}
.select-control-box {
display: flex;
align-items: center;
input::-webkit-input-placeholder {
opacity: 1 !important;
}
input::-moz-placeholder {
/* Mozilla Firefox 19+ */
opacity: 1 !important;
}
input:-moz-placeholder {
/* Mozilla Firefox 4 to 18 */
opacity: 1 !important;
}
input:-ms-input-placeholder {
/* Internet Explorer 10-11 */
opacity: 1 !important;
}
input {
border-radius: 4px;
border-right: 1px solid #e4e7ed;
cursor: pointer !important;
background-color: #f5f7fa !important;
}
input {
background-color: #fff !important;
cursor: pointer !important;
color: #606266 !important;
padding-right: 15px !important;
}
.el-input__suffix {
display: none;
}
}
.select-control-box-yes {
display: flex;
align-items: center;
.el-button {
border-radius: 0px 3px 3px 0;
}
input {
border-radius: 4px 0px 0px 4px;
border-right: 0;
cursor: text !important;
}
// &.select-control-border-show {
// input {
// border-radius: 4px;
// border-right: 1px solid #e4e7ed;
// cursor: pointer !important;
// }
// }
&.select-control-border-show {
input::-webkit-input-placeholder {
opacity: 0 !important;
}
input::-moz-placeholder {
/* Mozilla Firefox 19+ */
opacity: 0 !important;
}
input:-moz-placeholder {
/* Mozilla Firefox 4 to 18 */
opacity: 0 !important;
}
input:-ms-input-placeholder {
/* Internet Explorer 10-11 */
opacity: 0 !important;
}
input {
border-radius: 4px;
border-right: 1px solid #e4e7ed;
cursor: pointer !important;
background-color: #f5f7fa !important;
}
}
&.select-control-border-view {
input {
border: none;
}
}
}
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/components/general-control/table-select-control.vue | Vue | apache-2.0 | 14,561 |
<template>
<div class="table-select-box">
<el-dialog
v-dialogdrag
:title="optionData.title"
:visible.sync="optionData.isDialog"
:destroy-on-close="optionData.destroy?true:false"
:modal-append-to-body="false"
:close-on-click-modal="false"
:append-to-body="true"
:before-close="handleClose"
:width="optionData.width"
>
<avue-crud
ref="tableSelectControl"
v-if="optionData.isDialog"
:option="optionData.option"
:data="tableData"
:search.sync="searchData"
:page.sync="tablePage"
:table-loading="isTableLoading"
@search-change="searchChangeFun"
@search-reset="searchResetFun"
@current-change="currentChangeFun"
@size-change="sizeChangeFun"
@selection-change="selectionChangeFun"
>
<template slot="searchMenu" slot-scope="scope">
<el-button size="small" v-if="optionData.randomBtn" @click="randomExtractFun">随机抽取</el-button>
</template>
</avue-crud>
<span slot="footer" class="dialog-footer">
<el-button @click="setDialog(false)">取 消</el-button>
<el-button type="primary" @click="getCurrSelectDataFun()" :loading="buttomLoading">确 定</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import { getDataApi } from '@/api/research/codelist'
export default {
data() {
return {
buttomLoading:false,
tableData: [],
tablePage: {
total: 0,
currentPage: 1,
pageSize: 10,
pageSizes: [10, 20, 30],
background: true,
layout: 'sizes, prev, pager, next, jumper,total',
},
searchData: {},
isTableLoading: false,
tableQueryData: {},
tableSelectData: [],
skip: false,
}
},
watch: {
optionData: {
handler(newVal) {
if (newVal.isDialog) {
//搜索赋值
if (newVal.isCarrySearch) {
newVal.option.column.forEach((item) => {
if (item.search && item.searchValue !== undefined) {
this.tableQueryData[item.prop] = item.searchValue
}
})
}
this.getTableDataFun(newVal.tableId)
}
},
immediate: true, //先执行一次handler
deep: true,
},
},
props: [
'optionData',
/*
title:'标题',
isDialog:'显示隐藏弹窗',
width:'表格宽度',
tableId:'表格id',
option:'表格配置',
multiple:'是否多选',
isPage:'是否分页',
addType:{
type:'添加方法类型',
tableId:'添加数据表格id',
isCell:'是否可以编辑',
},
asyncTableName:'存储同步表id的字段名',async_id 返回的数据{async_id:选择表格数据对象里面的可以为id的值}
asyncTableIdName:'同步表的数据唯一id字段名' id
isCarrySearch:'一开始是否执行搜索'
randomBtn:'',//随机抽取按钮
searchRandomData:'',//随机抽取数据查询条件
randomFilteName:'',//随机抽取过滤数据key名
defaultData:{},//数据新增默认值
searchData:{},默认搜索数据
carryData:{}//点击确定后默认携带的数据
noDisposeData:true,//不需要数据处理
*/
'selectControlFun',
],
methods: {
//关闭弹窗
setDialog(bool) {
this.$refs.tableSelectControl.selectClear()
this.selectControlFun('dialog', { bool })
},
//获取当前表格数据
async getTableDataFun(tableId, page) {
if (page === undefined && this.optionData.isPage) {
page = {
currentPage: this.tablePage.currentPage,
pageSize: this.tablePage.pageSize,
}
}
if (this.optionData.searchData) {
this.tableQueryData = {
...this.tableQueryData,
...this.optionData.searchData,
}
}
this.isTableLoading = true
//通过接口获取所有树表格数据
let tableQueryData = {}
for (let key in this.tableQueryData) {
if (this.tableQueryData[key] instanceof Array) {
tableQueryData[key] = this.tableQueryData[key].join(',')
} else if (
this.tableQueryData[key] !== '' &&
this.tableQueryData[key] !== undefined
) {
tableQueryData[key] = this.tableQueryData[key]
}
}
let data = {
...tableQueryData,
}
if (this.optionData.isPage) {
data.pageNo = page.currentPage
data.pageSize = page.pageSize
} else {
data.pageSize = -521
}
let tableDataRes = await getDataApi(tableId, data)
tableDataRes = tableDataRes.data.data
this.tableData = tableDataRes.records
if (this.optionData.isPage) {
this.tablePage.total = tableDataRes.total
}
this.isTableLoading = false
},
//获取当前选择的数据
getCurrSelectDataFun() {
if (this.tableSelectData.length <= 0) {
if (this.optionData.messageText) {
this.$message(this.optionData.messageText)
} else {
this.$message('请勾选需要添加的数据~')
}
return false
}
let checkArr = []
if (this.optionData.noDisposeData) {
checkArr = this.tableSelectData
} else {
this.tableSelectData.forEach((item) => {
//添加数据表的id
let obj = {}
if (this.optionData.asyncTableIdName) {
obj[this.optionData.asyncTableName] =
item[this.optionData.asyncTableIdName]
} else {
obj[this.optionData.asyncTableName] = item.id
}
let dataKey = Object.keys(item)
dataKey.forEach((key) => {
if (key != 'id') {
obj[key] = item[key]
}
})
if (this.optionData.addType.isCell) {
obj.$cellEdit = true
}
if (this.optionData.defaultData) {
obj = {
...obj,
...this.optionData.defaultData,
}
}
checkArr.push(obj)
})
}
this.selectControlFun(this.optionData.addType.type, {
data: checkArr,
carryData: this.optionData.carryData,
})
},
handleClose(done) {
done()
},
//表格选择事件触发
selectionChangeFun(column) {
// column 所有选择数据的数组
if (!this.optionData.multiple) {
//单选
if (this.skip) {
return false
}
this.skip = true
this.$refs.tableSelectControl.toggleSelection('')
let currRow = []
if (column.length > 0) {
currRow.push(column[column.length - 1])
}
this.$refs.tableSelectControl.toggleSelection(currRow)
setTimeout(() => {
if (currRow.length >= 1) {
this.tableSelectData = currRow[0]
} else {
this.tableSelectData = []
}
this.skip = false
}, 0)
} else {
this.tableSelectData = column
}
},
//随机抽取
randomExtractFun() {
this.$prompt('请输入随机抽取数量', '随机抽取', {
confirmButtonText: '确定',
cancelButtonText: '取消',
})
.then(async ({ value }) => {
value = Number(value)
if (value > 0) {
this.tableSelectData = []
let data = {
pageNo: 1,
pageSize: -521,
...this.tableQueryData,
...this.optionData.searchRandomData,
}
let tableDataRes = await getDataApi(this.optionData.tableId, data)
let randomData = tableDataRes.data.data.records
console.log(
this.optionData.nullSelect,
this.optionData,
this.optionData.randomFilteName
)
randomData = randomData.filter((item) => {
if (
this.optionData.nullSelect.includes(
item[this.optionData.randomFilteName]
)
) {
return false
}
return true
})
if (randomData.length <= value) {
this.tableSelectData = randomData
} else {
let indexArr = []
while (indexArr.length < value) {
let index = Math.floor(Math.random() * randomData.length)
if (!indexArr.includes(index)) {
indexArr.push(index)
this.tableSelectData.push(randomData[index])
}
}
}
if (this.tableSelectData.length <= 0) {
this.$message('抽取失败,没有可抽取数据~')
} else {
this.getCurrSelectDataFun()
this.$message({
type: 'success',
message: '抽取成功~',
})
}
} else {
this.$message('请输入正确的抽取数量~')
}
})
.catch(() => {})
},
// 搜索
searchChangeFun(params, done) {
this.tableQueryData = params
this.tablePage.currentPage = 1
this.getTableDataFun(this.optionData.tableId)
done()
},
// 清除搜索
searchResetFun() {
this.tableQueryData = {}
this.tablePage.currentPage = 1
this.getTableDataFun(this.optionData.tableId)
},
// 切换页
currentChangeFun(page) {
this.tablePage.currentPage = page
this.getTableDataFun(this.optionData.tableId)
},
// 切换每页显示数
sizeChangeFun(pageSize) {
this.tablePage.currentPage = 1
this.tablePage.pageSize = pageSize
this.getTableDataFun(this.optionData.tableId)
},
},
}
</script>
<style></style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/components/general-control/table-select.vue | Vue | apache-2.0 | 9,965 |
<template>
<div class="table-tree-box">
<el-dialog
v-dialogdrag
:title="optionData.title"
:visible.sync="optionData.isDialog"
:destroy-on-close="optionData.destroy?true:false"
:modal-append-to-body="false"
:close-on-click-modal="false"
:append-to-body="true"
:before-close="handleClose"
width="500px"
v-loading="loading"
>
<el-input placeholder="输入关键字进行过滤" v-model="filterText"></el-input>
<el-tree
ref="elTree"
:data="treeData"
show-checkbox
default-expand-all
:default-checked-keys="optionData.defaultTree"
:node-key="optionData.defaulKey"
:filter-node-method="filterNode"
:check-strictly="optionData.checkStrictly"
highlight-current
:props="treeProps"
@check-change="parentModules"
></el-tree>
<span slot="footer" class="dialog-footer">
<el-button @click="setDialog(false)">取 消</el-button>
<el-button type="primary" @click="getCurrSelectTreeFun()">确 定</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import {
getAllTreeDataApi,
getDataApi,
getActionApi,
postActionApi,
} from '@/api/research/codelist'
export default {
data() {
return {
filterText: '',
treeData: [],
treeProps: {},
uniqueValue: '',
loading: false,
getActionApi,
postActionApi,
}
},
watch: {
filterText(val) {
this.$refs.elTree.filter(val)
},
optionData: {
handler(newVal, oldVal) {
if (
oldVal == undefined ||
(oldVal && (newVal.tableId != oldVal.tableId || newVal.isRefresh))
) {
this.getTableDataFun(newVal.tableId)
}
if (oldVal == undefined) {
//多选
this.treeProps.disabled = this.stopTreeFun
this.treeProps = {
...this.treeProps,
...newVal.defaultProps,
}
}
},
immediate: true, //先执行一次handler
deep: true,
},
},
props: [
'optionData',
/* 'tableId', //表单开发id
apiName:'',//接口名
'defaultTree', //默认勾选的值
'stopTree',//禁用勾选值
'isDialog', //是否显示
'defaultProps', //显示字段
'defaulKey', //树绑定key
'title', //标题
'addType',//新增方式(对象) {type:新增类型,tableId:新增表单id}
'asyncTableName',//存储同步表id的字段名
asyncTableIdName:'同步表的数据唯一id字段名'
radio:true, //单选
*/
'treeControlFun',
],
methods: {
//节点过滤
filterNode(value, data) {
if (!value) return true
return data.label.indexOf(value) !== -1
},
//关闭弹窗
setDialog(bool) {
this.$refs.elTree.setCheckedKeys([])
this.treeControlFun('dialog', { bool })
},
//获取当前tree数据
getTableDataFun(tableId) {
//通过接口获取所有树表格数据
if (this.optionData.apiName == 'getData') {
getDataApi(tableId, { pageSzie: -521, pageNo: 1 }).then((res) => {
if (res.data.success) {
this.treeData = res.data.data.records
}
})
} else if (this.optionData.apiName == 'getTreeData') {
getAllTreeDataApi(tableId).then((res) => {
if (res.data.success) {
this.treeData = res.data.data
}
})
} else if (this.optionData.apiName == 'externalData') {
this.treeData = this.optionData.treeData
}
},
//获取当前选择的数据
async getCurrSelectTreeFun() {
let checkArr = this.$refs.elTree.getCheckedNodes(true)
//排除禁用节点
checkArr = checkArr.filter((item) => {
if (
this.optionData.stopTree.includes(item[this.optionData.defaulKey])
) {
return false
}
return true
})
if (checkArr.length <= 0) {
this.$message('请勾选需要添加的数据~')
return false
}
let tableArr = []
checkArr.forEach((item) => {
let obj = {}
if (this.optionData.asyncTableIdName) {
if (this.optionData.apiName == 'getData') {
obj[this.optionData.asyncTableName] =
item[this.optionData.asyncTableIdName]
} else {
obj[this.optionData.asyncTableName] =
item.data[this.optionData.asyncTableIdName]
}
} else if (this.optionData.asyncTableName) {
if (this.optionData.apiName == 'getData') {
obj[this.optionData.asyncTableName] = item.id
} else {
obj[this.optionData.asyncTableName] = item.data.id
}
}
let dataKey = []
if (this.optionData.apiName == 'getData') {
dataKey = Object.keys(item)
} else {
dataKey = Object.keys(item.data)
}
dataKey.forEach((key) => {
if (key != 'id') {
if (this.optionData.apiName == 'getData') {
obj[key] = item[key]
} else {
obj[key] = item.data[key]
}
}
})
if (this.optionData.addType.isCell) {
obj.$cellEdit = true
}
tableArr.push(obj)
})
this.treeControlFun(this.optionData.addType.type, {
data: tableArr,
tableId: this.optionData.addType.tableId,
})
this.$refs.elTree.setCheckedKeys([])
},
//设置禁用节点
stopTreeFun(data) {
let stopKey = this.optionData.stopDefaulKey
stopKey = stopKey ? stopKey : this.optionData.defaulKey
if (data.disabled) {
return true
}
return this.optionData.stopTree.includes(data[stopKey])
},
handleClose(done) {
this.$refs.elTree.setCheckedKeys([])
done()
},
//单选方法
parentModules(data, checkbox) {
if (this.optionData.radio) {
if (checkbox) {
this.$refs.elTree.setCheckedKeys([data.id])
this.uniqueValue = this.$refs.elTree.getCheckedKeys().toString()
} else {
this.uniqueValue = this.$refs.elTree.getCheckedKeys().toString()
if (this.uniqueValue.length == 0) {
this.uniqueValue = ''
}
}
}
},
},
}
</script>
<style></style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/components/general-control/table-tree.vue | Vue | apache-2.0 | 6,415 |
<template>
<div class="table-view-box">
<el-dialog
v-dialogdrag
element-loading-background="transparent"
v-if="tableViewOptionData.viewObj.type == 'dialog'"
:title="tableViewOptionData.viewObj.title"
:visible.sync="tableViewOptionData.viewObj.isShow"
:destroy-on-close="tableViewOptionData.viewObj.destroy?true:false"
:modal-append-to-body="false"
:close-on-click-modal="false"
:append-to-body="true"
:width="tableViewOptionData.viewObj.width"
:before-close="tableViewDeclareFun"
v-bind="tableViewOptionData.viewObj.params"
>
<code-test-list
v-if="tableViewOptionData.viewObj.isShow"
ref="codeView"
:tableId="tableViewOptionData.tableId"
:searchObj="tableViewOptionData.searchObj"
:tableView="true"
v-bind="tableViewOptionData.params"
></code-test-list>
<span slot="footer" class="dialog-footer"></span>
</el-dialog>
<el-drawer
v-if="tableViewOptionData.viewObj.type == 'drawer'"
element-loading-background="rgba(255,255,255,0.3)"
:title="tableViewOptionData.viewObj.title"
:size="tableViewOptionData.viewObj.width"
:visible.sync="tableViewOptionData.viewObj.isShow"
:modal-append-to-body="false"
:close-on-click-modal="false"
:modal="false"
:append-to-body="true"
:before-close="tableViewDeclareFun"
v-bind="tableViewOptionData.viewObj.params"
>
<code-test-list
v-if="tableViewOptionData.viewObj.isShow"
ref="codeView"
:tableId="tableViewOptionData.tableId"
:searchObj="tableViewOptionData.searchObj"
:tableView="true"
v-bind="tableViewOptionData.params"
></code-test-list>
</el-drawer>
</div>
</template>
<script>
export default {
name: 'tableView',
props: ['tableViewOptionData', 'beforeClose'],
data() {
return {
/* tableViewOptionData:{
viewObj: {
type:'',
title:'',
isShow:false,
width:'80%'
},
tableId: '',
hideHeader:true,
searchObj: {},
} */
}
},
methods: {
tableViewDeclareFun(done) {
this.tableViewOptionData.viewObj.isShow = false
let type = 'close'
if (this.tableViewOptionData.closeType) {
type = this.tableViewOptionData.closeType
}
if (this.beforeClose) {
this.beforeClose(type)
}
done()
},
},
}
</script>
<style>
</style> | 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/components/general-control/table-view.vue | Vue | apache-2.0 | 2,511 |
<template>
<div>
<el-dialog
custom-class="tabs-view-dialog-box"
element-loading-background="transparent"
v-if="tabOptionData.viewObj.type == 'dialog'"
top="10vh"
:title="tabOptionData.viewObj.title"
:visible.sync="tabOptionData.viewObj.isShow"
:destroy-on-close="tabOptionData.viewObj.destroy ? true : false"
:modal-append-to-body="false"
:close-on-click-modal="false"
:append-to-body="true"
:modal="false"
:width="tabOptionData.viewObj.width"
v-bind="tabOptionData.viewObj.params"
>
<div class="tab-view-box">
<el-tabs
v-model="tabsActiveName"
@tab-click="tabsHandleClick"
v-bind="tabOptionData.tabsParams"
>
<el-tab-pane
v-for="item in tableData"
:key="item.tabName"
:label="item.title"
:name="item.tabName"
>
<!-- 表格 -->
<div v-if="item.type == 'table' && item.id">
<code-test-list
:ref="item.tabName + '_table'"
:tranTableId="item.id"
v-bind="item.params"
></code-test-list>
</div>
<!-- 表单 -->
<div v-else-if="item.type == 'form'">
<div class="form-btn-box" v-if="item.btnData">
<div v-for="(btn, index) in item.btnData" :key="index">
<div class="btn-box" v-if="btn.show !== false">
<el-button v-bind="btn.params" @click="btn.clickFun(that)">
{{
btn.btnName
}}
</el-button>
</div>
</div>
</div>
<form-view
:ref="item.tabName"
:formViewControlFun="formViewFun"
:formOptionData="item.params"
:params="tabOptionData.allSearchObj"
></form-view>
</div>
<!-- tabs -->
<el-tabs
v-else-if="item.type == 'tabs'"
v-model="item.activeName"
@tab-click="childTabsHandleClick"
v-bind="item.tabsParams"
>
<el-tab-pane
v-for="child in item.tabsData"
:key="child.tabName"
:label="child.title"
:name="child.tabName"
>
<!-- 表格 -->
<div v-if="child.type == 'table' && child.id">
<code-test-list
class="tabs-view-child-table-box"
:ref="child.tabName + '_child_table'"
:tranTableId="child.id"
v-bind="child.params"
></code-test-list>
</div>
<!-- 表单 -->
<div v-else-if="child.type == 'form'">
<div class="form-btn-box" v-if="child.btnData">
<div
class="btn-box"
v-for="(childBtn, childBtnIndex) in child.btnData"
:key="childBtnIndex"
>
<el-button
v-if="child.show !== false"
v-bind="childBtn.params"
@click="childBtn.clickFun(that)"
>{{ childBtn.btnName }}</el-button>
</div>
</div>
<form-view
:ref="child.tabName"
:formViewControlFun="formViewFun"
:formOptionData="child.params"
:params="tabOptionData.allSearchObj"
></form-view>
</div>
</el-tab-pane>
</el-tabs>
</el-tab-pane>
</el-tabs>
</div>
<span slot="footer" class="dialog-footer"></span>
</el-dialog>
<table-view
v-if="isTableView"
:tableViewOptionData="tableViewOptionData"
:beforeClose="tableViewDeclareFun"
></table-view>
</div>
</template>
<script>
import FormView from '@/research/components/general-control/form-view.vue'
import tableView from '@/research/components/general-control/table-view.vue'
export default {
name: 'TabsView',
components: { FormView, tableView },
data() {
return {
tabsActiveName: '',
tabsData: [],
that: this,
//表格弹窗
isTableView: false,
tableViewOptionData: {
viewObj: {},
tableId: '',
searchObj: {},
},
}
},
watch: {
'tabOptionData.viewObj.isShow': function (value) {
if (value && this.tabOptionData.openIndex != undefined) {
try {
this.tabsActiveName =
this.tabOptionData.tabsData[this.tabOptionData.openIndex].tabName
} catch (error) {
this.tabsActiveName = ''
}
}
if (value && this.tabsActiveName) {
setTimeout(() => {
this.anewCurrTabsData(this.tabsActiveName)
}, 0)
}
},
tabOptionData: {
handler(newVal, oldVal) {
},
deep: true, //深监听
},
//监听tab切换 查看是否需要刷新表格
tabsActiveName(newVal) {
this.anewCurrTabsData(newVal)
},
tableViewDeclareFun() {},
},
props: [
'tabOptionData',
/*
viewObj:{
title:'',
type:'',
isShow:'',
width:'100%',
},
tabsParams:{}, //tab相关配置
openIndex:0,//默认打开下标值为tab的页面
tabsData:[
{
id:'',//表单开发id
title:'',//tab标题
tabName:'',//tabkey 唯一
type:'',//控件类型 table form
isRefresh:false,//切换tab时是否刷新表格数据
params:{
//表单
viewObj:{
isShow:true,
type:"view"
},
formId:"1474639164730269698",
onlineFormId:"",
formOpenType:"edit",
actionData:{
type:"returnData",
isMessage:false,
noRouter:true
},
params:{},
btnPermissions:{
clearBtn:false,
submitBtn:false
}
//表格
codetestlist props参数配置
}, //其他参数配置
}
]
*/
'tabViewControlFun',
],
computed: {
tableData() {
let data = this.deepClone(this.tabOptionData.tabsData)
data = data.map((item, index) => {
if (item.type == 'table') {
item.params = this.tableBindFun(
this.tabOptionData.allSearchObj,
item.params
)
}
if (item.type !== 'tabs') {
//默认开启懒加载
if (item.params === undefined) {
item.params = {}
}
if (item.params.isLazy !== false) {
item.params.isLazy = index != 0
}
}
if (item.type == 'tabs') {
item.tabsData = item.tabsData.map((child) => {
if (child.type == 'table') {
child.params = this.tableBindFun(
this.tabOptionData.allSearchObj,
child.params
)
}
//默认开启懒加载
if (child.params === undefined) {
child.params = {}
}
if (child.params.isLazy !== false) {
child.params.isLazy = true
}
return child
})
}
return item
})
return data
},
},
mounted() {
this.init()
},
methods: {
async init() {},
anewCurrTabsData(newVal) {
if (!newVal) {
return false
}
this.tableData.forEach((item) => {
if (item.tabName != newVal) {
return false
}
if (item.type == 'table') {
try {
let dom = this.$refs[`${newVal}_table`][0]
if (item.params.isLazy && !dom.isTableCrud) {
dom.init()
return false
}
if (item.isRefresh) {
setTimeout(() => {
this.$refs[`${newVal}_table`][0].tableRefreshChangeFun()
}, 1000)
}
} catch (error) {}
}
if (item.type == 'form') {
try {
let dom = this.$refs[newVal][0]
if (item.params.isLazy && !dom.isInit) {
dom.init()
return false
}
if (item.isRefresh) {
if (item.initFun) item.initFun()
if (item.params.viewObj.isGetData) dom.getFormDataFun()
}
} catch (error) {}
}
if (item.type == 'tabs') {
item.tabsData.forEach((child) => {
if (!item.activeName) {
return false
}
if (child.tabName != item.activeName) {
return false
}
if (child.type == 'table') {
let childDom = this.$refs[`${child.tabName}_child_table`][0]
console.log(
'table=======',
child.params.isLazy,
childDom.isTableCrud
)
if (child.params.isLazy && !childDom.isTableCrud) {
childDom.init()
return false
}
if (child.isRefresh) {
childDom.tableRefreshChangeFun()
}
}
if (child.type == 'form') {
let childDom = this.$refs[child.tabName][0]
if (child.params.isLazy && !childDom.isInit) {
childDom.init()
return false
}
if (child.isRefresh) {
if (child.initFun) child.initFun()
childDom.getFormDataFun()
}
}
})
}
})
},
tabsHandleClick() {},
childTabsHandleClick(dom) {
this.anewCurrTabsData(this.tabsActiveName)
},
tableBindFun(allSearchObj, params) {
let length =
typeof allSearchObj == 'object' ? Object.keys(allSearchObj).length : 0
if (length > 0) {
if (params && params.searchObj) {
params.searchObj = {
...allSearchObj,
...params.searchObj,
}
} else {
params = {
...params,
searchObj: allSearchObj,
}
}
}
return params
},
},
}
</script>
<style lang="scss">
.el-drawer__body {
overflow: auto;
}
.tab-view-box {
.form-btn-box {
background-color: #f1f1f1;
padding: 10px;
margin-bottom: 10px;
display: flex;
align-items: center;
.btn-box {
padding-left: 10px;
}
& > div:nth-child(1) {
.btn-box {
padding-left: 0px;
}
}
}
}
.tabs-view-dialog-box {
.el-dialog__body {
padding: 5px 20px;
}
}
.tabs-view-child-table-box {
.test-box-list {
padding-top: 0px !important;
}
}
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/components/general-control/tabs-view.vue | Vue | apache-2.0 | 11,168 |
<template>
<div class="user-control">
<div class="user-control-box">
<avue-select
v-if="multiple"
v-model="selectValue"
placeholder="请选择 用户"
type="tree"
ref="avueSelect"
:props="userProps"
:multiple="multiple"
:dic="allUserData"
:size="tableItemScope ? tableItemScope.size : ''"
:disabled="true"
@click="openUserDialogFun(tableItemVal, tableItemName, !disabled)"
></avue-select>
<avue-select
v-else
v-model="tableItemVal"
placeholder="请选择 用户"
type="tree"
ref="avueSelect"
:props="userProps"
:dic="allUserData"
:size="tableItemScope ? tableItemScope.size : ''"
:disabled="true"
@click="openUserDialogFun(tableItemVal, tableItemName, !disabled)"
></avue-select>
</div>
<el-dialog
title="根据部门选择用户"
v-dialogdrag
:visible.sync="userDialog"
v-if="userDialog"
class="user_dialog_box"
:modal-append-to-body="true"
:append-to-body="true"
width="1200px"
top="20px"
>
<div class="user_dialog_content">
<div class="content-left-tree">
<el-tree
ref="userDepartTree"
:props="departProps"
:check-strictly="true"
node-key="value"
:data="allDepartData"
@node-click="userControlNodeClickFun"
></el-tree>
</div>
<div class="content-right-table">
<avue-crud
ref="userControlTable"
:option="userControlTableOption"
:data="userControlTableData"
:page.sync="userControlTablePage"
:table-loading="loading"
:search.sync="searchData"
@selection-change="userControlSelectionChangeFun"
@current-change="userControlCurrentChangeFun"
@size-change="userControlSizeChangeFun"
@search-change="userControlSearchChangeFun"
@search-reset="userControlSearchResetFun"
></avue-crud>
</div>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="userDialog = false">
{{
disabled ? "关闭" : "取 消"
}}
</el-button>
<el-button type="primary" @click="setUserInputValueFun" v-if="!disabled">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { getList } from '@/api/system/user'
export default {
props: [
'tableItemVal',
'tableItemName',
'disabled',
'size',
'tableItemScope',
'setFormValueFun',
'multiple',
'allDepart',
'allUserObj',
],
data() {
return {
skip: false,
loading: false,
userDialog: false,
searchData: {},
userProps: {
label: 'realName',
value: 'id',
},
departProps: {
children: 'children',
label: 'title',
value: 'id',
},
allUserData: [], //所有用户数据
allDepartData: [], //所有部门数据
userControlTableSelectId: [], //用户选择的数据id
userControlTableOption: {
rowKey: 'id',
selection: true,
reserveSelection: true,
menu: false,
addBtn: false,
columnBtn: false,
refreshBtn: false,
searchMenuSpan: 8,
column: [
{
prop: 'account',
label: '用户账号',
search: true,
searchSpan: 8,
},
{
prop: 'realName',
label: '用户姓名',
search: true,
searchSpan: 8,
},
/* {
prop: 'sex',
label: '性别',
type: 'radio',
dicData: [
{ label: '男', value: 1 },
{ label: '女', value: 0 },
],
},
{
prop: 'phone',
label: '手机',
}, */
{
prop: 'deptName',
label: '部门',
},
],
},
userControlTableData: [], //当前表格页数据
userControlTablePage: {
total: 0,
currentPage: 1,
pageSize: 5,
pageSizes: [5, 10, 20, 30],
background: true,
layout: 'sizes, prev, pager, next, jumper,total',
currentdepartId: '',
},
}
},
watch: {
allDepart: {
deep: true,
immediate: true, //先执行一次handler
handler: function (newV) {
this.allDepartData = newV
},
},
allUserObj: {
deep: true,
immediate: true, //先执行一次handler
handler: function (newV) {
if (newV) {
this.allUserData = newV.allList
this.userControlTablePage.total = newV.total
this.userControlTableData = newV.list
}
},
},
},
computed: {
selectValue: {
get() {
if (this.tableItemVal && this.tableItemVal instanceof Array) {
if (this.tableItemVal.length > 0) {
return this.tableItemVal
}
return ''
} else {
if (this.tableItemVal) {
return this.tableItemVal.split(',')
}
return ''
}
},
set() {},
},
},
async mounted() {
this.userControlTableOption = {
...this.userControlTableOption,
selectable: (row, index) => {
if (this.tableItemScope.selectable) {
return this.tableItemScope.selectable(row, index)
} else if (
this.tableItemScope.column &&
this.tableItemScope.column.selectable
) {
return this.tableItemScope.column.selectable(row, index)
} else {
return true
}
},
}
if (this.disabled) {
this.userControlTableOption.tip = false
this.userControlTableOption.selectable = () => {
return false
}
}
},
methods: {
//获取所有用户
async getAllUserInfoFun(search = {}) {
search = {
...this.searchData,
...search,
}
this.loading = true
let { currentPage, pageSize, currentdepartId } = this.userControlTablePage
let userRes = await getList(
currentPage,
pageSize,
search,
currentdepartId
)
let data = userRes.data.data
this.userControlTablePage.total = data.total
this.userControlTableData = data.records
this.loading = false
},
//打开用户选择弹窗
openUserDialogFun(value, fieldName, bool) {
if (!bool) {
return false
}
this.userDialog = true
setTimeout(() => {
this.$refs.userControlTable.toggleSelection('')
let userCheckedArr = []
this.allUserData.forEach((item) => {
if (value != undefined && value.includes(item.id)) {
userCheckedArr.push(item)
}
})
this.$refs.userControlTable.toggleSelection(userCheckedArr)
}, 0)
/* this.setParentFormValFun({
fieldName,
value,
}); */
this.userControlTablePage.currentPage = 1
this.userControlTablePage.pageSize = 5
this.userControlTablePage.currentdepartId = ''
this.userControlSearchResetFun()
},
//设置用户控件值
setUserInputValueFun() {
this.setParentFormValFun({
fieldName: this.tableItemName,
value: [],
})
this.setParentFormValFun({
fieldName: `$${this.tableItemName}`,
value: '',
})
setTimeout(() => {
this.setParentFormValFun({
fieldName: this.tableItemName,
value: this.userControlTableSelectId,
})
let text = ''
if (this.userControlTableSelectId) {
this.allUserData.forEach((item) => {
if (
this.userControlTableSelectId.includes(item[this.userProps.value])
) {
if (text) {
text = `${text},${item[this.userProps.label]}`
} else {
text = item[this.userProps.label]
}
}
})
}
console.log('设置用户', {
fieldName: `$${this.tableItemName}`,
value: text,
})
this.setParentFormValFun({
fieldName: `$${this.tableItemName}`,
value: text,
})
this.userDialog = false
}, 0)
},
//用户控件表格选择
userControlSelectionChangeFun(column) {
if (!this.multiple) {
//单选
if (this.skip) {
return false
}
this.skip = true
this.$refs.userControlTable.toggleSelection('')
let currRow = []
if (column.length > 0) {
currRow.push(column[column.length - 1])
}
this.$refs.userControlTable.toggleSelection(currRow)
setTimeout(() => {
if (currRow.length >= 1) {
this.userControlTableSelectId = [currRow[0].id]
} else {
this.userControlTableSelectId = []
}
this.skip = false
}, 0)
} else {
//多选
let idArr = []
column.forEach((item) => {
idArr.push(item.id)
})
this.userControlTableSelectId = idArr
}
},
//用户控件表格搜索
userControlSearchChangeFun(params, done) {
this.searchData = params
this.getAllUserInfoFun()
done()
},
//用户控件表格清空搜索
userControlSearchResetFun() {
this.getAllUserInfoFun()
},
//用户控件表格切换页
userControlCurrentChangeFun(page) {
this.userControlTablePage.currentPage = page
this.getAllUserInfoFun()
},
//用户控件表格每页显示数
userControlSizeChangeFun(pageSize) {
this.userControlTablePage.pageSize = pageSize
this.getAllUserInfoFun()
},
//用户控件 点击部门树触发
userControlNodeClickFun(data) {
this.userControlTablePage.currentPage = 1
this.userControlTablePage.currentdepartId = data.id
this.getAllUserInfoFun()
},
//调用父组件设置表单值方法{fieldName:'',value:''}
setParentFormValFun(obj) {
if (obj.value && obj.value instanceof Array) {
obj.value = obj.value.join(',')
}
if (this.setFormValueFun) {
this.setFormValueFun(obj)
}
this.$emit('set-form-val', obj)
},
},
}
</script>
<style lang="scss">
.user_dialog_box {
.user_dialog_content {
padding: 10px;
display: flex;
background-color: rgb(236, 236, 236);
.content-left-tree {
background-color: #fff;
flex: 0 0 290px;
box-sizing: border-box;
padding: 24px;
margin-right: 10px;
border-radius: 5px;
}
.content-right-table {
flex: 1;
box-sizing: border-box;
background-color: #fff;
border-radius: 5px;
padding: 24px;
.avue-crud__menu {
margin-bottom: 0px;
display: none;
}
}
}
}
.user_dialog_box {
.el-dialog__header {
border-bottom: 1px solid #f1f1f1;
}
}
.user-control-box {
display: flex;
align-items: center;
input::-webkit-input-placeholder {
opacity: 1 !important;
}
input::-moz-placeholder {
/* Mozilla Firefox 19+ */
opacity: 1 !important;
}
input:-moz-placeholder {
/* Mozilla Firefox 4 to 18 */
opacity: 1 !important;
}
input:-ms-input-placeholder {
/* Internet Explorer 10-11 */
opacity: 1 !important;
}
input {
border-radius: 4px;
border-right: 1px solid #e4e7ed;
cursor: pointer !important;
background-color: #f5f7fa !important;
}
input {
background-color: #fff !important;
cursor: pointer !important;
color: #606266 !important;
padding-right: 15px !important;
}
.el-input__suffix {
display: none;
}
}
.user-control-box-yes {
display: flex;
align-items: center;
.el-button {
border-radius: 0px 3px 3px 0;
}
input {
border-radius: 4px 0px 0px 4px;
border-right: 0;
cursor: text !important;
}
// &.user-control-border-show {
// input {
// border-radius: 4px;
// border-right: 1px solid #e4e7ed;
// cursor: pointer !important;
// }
// }
&.user-control-border-show {
input::-webkit-input-placeholder {
opacity: 0 !important;
}
input::-moz-placeholder {
/* Mozilla Firefox 19+ */
opacity: 0 !important;
}
input:-moz-placeholder {
/* Mozilla Firefox 4 to 18 */
opacity: 0 !important;
}
input:-ms-input-placeholder {
/* Internet Explorer 10-11 */
opacity: 0 !important;
}
input {
border-radius: 4px;
border-right: 1px solid #e4e7ed;
cursor: pointer !important;
background-color: #f5f7fa !important;
}
}
&.user-control-border-view {
input {
border: none;
}
}
}
</style>
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/components/general-control/user-control.vue | Vue | apache-2.0 | 13,024 |
//存储tabs页面数据表id
export const tabsTableId = "1514806825113739266"
//存储form页面数据表id
export const formTableId = "1514808209976451074"
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/config/index.js | JavaScript | apache-2.0 | 159 |
import { apiRequestHead } from '@/config/url.js'
// 表单设计基础控件
import MenuLeftBtns from '@/research/components/code-list/menu-left-btns.vue'
import MenuFormBtns from '@/research/components/code-list/menu-form-btns.vue'
import MenuLinkBtns from '@/research/components/code-list/menu-link-btns.vue'
// 其他控件
import CodeSublistForm from '@/research/components/code-list/code-sublist-form'
import CodeSublistTable from '@/research/components/code-list/code-sublist-table'
import DepartControl from '@/research/components/general-control/depart-control'
import UserControl from '@/research/components/general-control/user-control'
import TableSelectControl from '@/research/components/general-control/table-select-control'
import tableView from "@/research/components/general-control/table-view.vue"
import TableTree from '@/research/components/general-control/table-tree.vue'
import FormView from '@/research/components/general-control/form-view.vue'
import TableSelect from '@/research/components/general-control/table-select.vue'
import ControlView from '@/research/components/general-control/control-view.vue'
import TabsView from '@/research/components/general-control/tabs-view.vue'
// 代码编辑器
import MonacoEditor from '@/packages/utils/monaco-editor'
export default {
components: {
// 基础
MenuLeftBtns,
MenuFormBtns,
MenuLinkBtns,
// 其他
CodeSublistForm,
CodeSublistTable,
DepartControl,
UserControl,
TableSelectControl,
tableView,
TableTree,
FormView,
TableSelect,
ControlView,
TabsView,
MonacoEditor,
},
data () {
return {
random: `${Math.random()}`.substring(3),
isAvueTableLoading: '',//avue表格loading
currDateTime: '',//当前时间
isAuthBtn: false, //是否开启系统按钮权限 控制按钮显隐
isOneGetData: true, //是否第一次获取数据
selectionTime: null,
apiRequestHead: apiRequestHead,
isLinkPullDown: true, //自定义按钮 link是否下拉显示
isTableGetData: true, //是否一开始加载数据
subDataIdKey: 'id', //字表的需要的数据id字段名
tableSearchType: '',
tablePermission: {
addBtn: false,
allDelBtn: false,
editBtn: false,
exportBtn: false,
inportBtn: false,
moreDelBtn: false,
moreViewBtn: false,
moreChildBtn: false,
}, //权限控制
maps: new Map(), //存储树表格用于数据回显
themeTemplate: '', //当前主题
timerInte: [], //定时器
tableDescribe: '', //表描述
that: null,
drawer: true,
isTableLoading: false, //操作button加载
tableCrudType: '',
currCodeId: '', //当前表单id
currCodeType: '', //当前表单其他参数
tableName: '', //数据库表名
tableIsPage: false, //是否分页
isOpentForm: false, //是否打开了表单弹窗
tableInportDialog: false, //导入弹窗
tableQueryData: {}, //搜索实时条件
tableQueryClickData: {}, //点击查询后的搜索条件
tableOtherQueryData: {},//其他搜索条件(清除搜索不会清空)
tableAdvancedQueryData: {}, //高级查询条件
isTableCrud: false, //一开始隐藏表格
subShowMenu: '', //子表是否显示操作按钮和操作列
sortData: {
column: 'id',
order: 'desc',
},
// 表格table配置
tableOption: {
align: 'center',
dialogDrag: true,
dialogTop: '0%',
dialogClickModal: false,
delBtn: false,
editBtn: false,
dialogWidth: '80%',
menuWidth: '200',
border: true, //开启边框
columnBtn: true, //隐藏列显示隐藏按钮
saveBtn: false,
cancelBtn: false,
updateBtn: false,
addBtn: true,
header: true,
search: false,
searchMenuSpan: 6,
searchMenuPosition: 'left',
searchIndex: 3,
searchIcon: true,
searchShowBtn: false,
expandRowKeys: [],
column: [],
lazy: true, //暂时只能先设置 avue
selectable: (row, index) => {
//通过增强配置是否可以选择
if (
this.customOnlineEnhanceJsName &&
this.customOnlineEnhanceJsName.list.includes('selectable')
) {
try {
return this.customOnlineEnhanceJsList.selectable(row, index)
} catch (error) {
console.warn(error)
}
} else {
return true
}
},
},
tableForm: {},
tableColumnMoreButton: [
{
type: 'view',
text: '详情',
permissionName: 'moreViewBtn',
},
{
type: 'del',
text: '删除',
permissionName: 'moreDelBtn',
},
], //默认操作列按钮
tableSelectData: [], //表格选中的数据
tableSelectId: [], //表格选中的数据Id
tableData: [], //表格数据
tablePage: {}, //表格分页
tableDataIsTree: false, //是否使用 树结构数据处理方式
tableTreeParentIdName: '', //树结构数据 父id的key名
tableTreeUnfoldName: '', //树结构数据展开列
tableTreeChildern: '', //树结构数据是否有子集
tableColumnDic: {},
tableColumnItemForm: {},
tableAllColumnRules: [], //所有校验规则
columHeaderArr: [],//自定义表头搜索
tableNeetRules: ['text', 'password', 'textarea', 'umeditor', 'markdown'], //可以校验的控件
// 需要字典数据的控件
viewListSelect: [
'list',
'radio',
'checkbox',
'switch',
'list_multi',
'pca',
],
//需要字典数据的控件,并且以树形式展示
viewListTree: ['sel_tree', 'cat_tree'],
viewAllTreeKey: [],
//是否有省市区控件
isProvinces: false,
//表单 单独占一行的控件
fieldSpanOneLine: ['textarea', 'markdown', 'umeditor', 'image', 'file', 'monaco-editor'],
//所有的省市区联动控件
viewPcaArr: [],
//所有markdown控件
viewMarkdownArr: [],
//所有文件控件
viewFileArr: [],
//所有联动控件
viewLinkDownArr: [],
// 所有联动控件关联字段
viewLinkDownFieldArr: [],
//联表查询字段
uniteFormKeyObj: {},
//所有联动控件字典
viewLinkDownDicObj: {},
viewFileNameObj: {}, //存储所有文件名
viewPcaNameObj: {}, //存储所有省市区id对应的文本
//需要自定义搜索的字典处理
customSearchArr: [],
//当前操作的列的数据
currentRowDataObj: {},
// 部门
allDepartData: {}, //所有部门数据
viewDepartControlArr: [], //所有部门控件
// 用户
viewUserControlArr: [], //所有用户控件
//所有表格选择控件
viewTableSelectArr: [],
//所有的代码编辑器控件
viewMonacoEditor: [],
initSelfDefinedArr: [],
viewMapArr: [], //所有地图控件
allUserData: {}, //所有用户数据
allUserObj: {},
isTableInfo: false, //是否存在主附表
// 父子表tabs切换配置
tabsOption: {
column: [],
},
tabsType: {}, //当前tabs
listTabsOption: {
column: [],
},
//自定义按钮
customButtonTop: [], //表格顶部操作栏按钮
customButtonLink: [], //表格操作列按钮
customButtonFormEnd: [], //表单操作菜单 底部
customButtonFormSide: [], //表单操作菜单 侧面
dicAllData: {},
//end 高级查询
customOnlineEnhanceJsList: {}, //js增强list所有方法
customOnlineEnhanceJsForm: {}, //js增强form所有方法
//js增强方法名
customOnlineEnhanceJsName: {
list: [],
form: [],
},
form: {
getSelectOptions: null,
changeOptions: null,
triggleChangeValues: null,
getAllFieldValue: null,
getFieldValue: null,
},
otherPortId:false,//其他导入 导出 下载模板表id
// 导入
inportOption: {
column: [
{
label: '',
prop: 'inportexcel',
type: 'upload',
accept:
' application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
span: 24,
labelWidth: 0,
labelslot: true,
multiple: false,
limit: 1,
propsHttp: {
res: 'data',
},
tip: '只能上传 xls / xlsx 文件',
},
],
},
inportForm: {
inportexcel: [],
inportList: [],
},
//表单设计 配置值
widgetFormPreview: {},
isDialogFormDesign: false,
isFormFullscreenDesign: false,
formOpenType: 'add',
formActionData: {
type: 'formlist',
},
formBtnPermissions: {},
allFormListData: {},
dialogFormTitle: '新增',
//erp
tableErpRadioId: '', //当前erp主题选择数据的id
tableErpRadioObj: {}, //当前erp主题选择数据
erpControlsArr: [
'text',
'radio',
'switch',
'date',
'datetime',
'file',
'image',
'list_multi',
'sel_search',
'list',
'popup',
'sel_depart',
'sel_user',
],
//innerTable
expandObj: {},
listTabsType: {}, //列表tabs
//树选择控件配置
isTableTreeControl: false,
tableTreeControlOption: {
tableId: '',
defaultTree: [],
stopTree: [],
isDialog: false,
defaultProps: {},
defaulKey: '',
title: '',
addType: {
type: '',
tableId: '',
},
asyncTableName: '',
},
//其他表单控件配置
isFormViewControl: false,
FormViewControlOption: {
viewObj: {},
formId: '',
formOpenType: '',
actionData: {},
btnPermissions: {},
customFun: () => { }
},
//组件配置
isControlView: false,
controlViewOption: {
type: '',
viewObj: {},
params: {},
defaultData: {},
customFun: () => { }
},
// 资源审核
isZyscControl: false,
//表格选择控件配置
isTableSelectControl: false,
tableSelectControlOption: {
title: '',
isDialog: false,
width: '',
tableId: '',
option: {},
multiple: '',
isPage: '',
addType: {
type: '',
tableId: '',
isCell: '',
},
submitFun: () => { },
},
//tabs显示控件
isTabsView: false,
tabsOptionData: {
viewObj: {
title: '',
type: 'dialog',
isShow: false,
width: '90%',
},
tabsParams: {},
openIndex: 0,
tabsData: [],
},
//其他表格弹窗控件配置
isTableView: false,
tableViewOptionData: {
viewObj: {},
tableId: '',
searchObj: {},
},
//子表是否需要js增强和自定义按钮
subOpentJsEnhance: '',
isInitEnhance: false, //判断增强是否初始化完毕
// 大数据展示方式
displayModeType: 'normal',
currentStartIndex: 0,
currentEndIndex: 50,
isOpentAuthFocus: false, //是否开启自动聚焦
authFocusObj: {
//自动聚焦配置
currBigDataTrEl: '',
inputAttr: '',
},
}
},
filters: {
// 时间格式化
dateFilter (date, format) {
date = new Date(date)
format = format || 'yyyy-MM-dd hh:mm:ss'
if (date != 'Invalid Date') {
let o = {
'M+': date.getMonth() + 1, //month
'd+': date.getDate(), //day
'h+': date.getHours(), //hour
'H+': date.getHours(), //hour
'm+': date.getMinutes(), //minute
's+': date.getSeconds(), //second
'q+': Math.floor((date.getMonth() + 3) / 3), //quarter
S: date.getMilliseconds(), //millisecond
}
if (/(y+)/.test(format))
format = format.replace(
RegExp.$1,
(date.getFullYear() + '').substr(4 - RegExp.$1.length)
)
for (let k in o)
if (new RegExp('(' + k + ')').test(format))
format = format.replace(
RegExp.$1,
RegExp.$1.length === 1
? o[k]
: ('00' + o[k]).substr(('' + o[k]).length)
)
return format
}
return ''
},
},
watch: {
subShowMenu (val) {
let arr = val.split('/')
this.tabsOption.column = this.tabsOption.column.map((item) => {
if (item.key == arr[0]) {
item.showMenu = arr[1] == 'true' ? true : false
}
return item
})
},
subOpentJsEnhance (val) {
let arr = val.split('/')
this.tabsOption.column = this.tabsOption.column.map((item) => {
if (item.key == arr[0]) {
item.opentJsEnhance = arr[1] == 'true' ? true : false
}
return item
})
},
currMainDataId (val) {
if (this.tableId) {
if (val) {
this.tableOption.header = true
} else {
this.tableOption.header = false
}
setTimeout(() => {
this.initTableData()
}, 300)
}
},
},
computed: {
filteredData () {
let list = this.tableData.filter((item, index) => {
if (index < this.currentStartIndex) {
return false
} else if (index > this.currentEndIndex) {
return false
} else {
return true
}
})
return list
},
},
props: {
//erp附表id
tableId: {
type: String,
default: '',
},
//不通过路由传递的表id
tranTableId: {
type: String,
default: '',
},
currMainDataId: {
type: String,
default: '',
},
currMainDataObj: {
type: Object,
default: () => { },
},
foreignKeys: {
type: Array,
default: () => [],
},
tableType: {
type: String,
default: '',
},
//默认搜索值(表格初始化后只执行一次)
defaultSearchObj: {
//对象里面的值为空则不获取表格数据:{key:''}
type: Object,
default: () => { },
},
//默认搜索值(每次都执行)
searchObj: {
type: Object,
default: () => { },
},
tableView: {
type: Boolean,
default: false,
},
hideHeader: {
type: Boolean,
default: true,
},
//其他页面或控件传递的方法方法
transmitFun: {
type: Function,
},
//其他参数
otherParams: {
type: Object,
default: () => { },
},
//开启懒加载
isLazy: {
type: Boolean,
default: false,
}
},
methods: {
//创建dom方法
createDomFun (domName, htmlText, type = 'end', nextDom) {
let timer = setInterval(() => {
let dom = document.querySelector(domName)
if (dom) {
clearInterval(timer)
let div = document.createElement('div')
if (type == 'end') {
dom.appendChild(div)
} else {
if (nextDom) {
dom.insertBefore(div, nextDom)
}
dom.insertBefore(div, dom.childNodes[0])
}
div.style.width = "100%"
div.innerHTML = htmlText
}
}, 300);
}
},
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/mixins/codetestlist.js | JavaScript | apache-2.0 | 15,895 |
/*
当前mixins使用于表单设计器
*/
// import request from '@/router/axios';
import { getRemoteValuesApi, executeRuleByApi, getSelectRemoteDataApi, getJsOrCssStrApi, getActionApi, postActionApi, putActionApi, deleteActionApi, requestActionApi } from "@/api/research/form";
export default {
data() {
return {
}
},
mounted() {
},
methods: {
//远程接口取值 column:所有的字段配置
mixinGetApiData(column) {
return new Promise(async (resolve) => {
let formObj = {}
let specialObj = {} //特殊的
let formKey = []
let promiseArr = []
column.forEach(item => {
if (item.getValueApiName) {
let url = item.getValueApiName
if (url.indexOf('/') == 0) {
url = '/api' + url
}
formKey.push({
prop: item.prop,
type: item.type
})
promiseArr.push(
getRemoteValuesApi(url)
)
}
});
let resArr = await Promise.all(promiseArr)
resArr.forEach((item, index) => {
if (!['title'].includes(formKey[index].type)) {
formObj[formKey[index].prop] = item.data
} else {
specialObj[formKey[index].prop] = {
data: item.data,
type: formKey[index].type
}
}
})
resolve({ formObj, specialObj })
})
},
//填值规则 column:所有的字段配置 commonFormData:表单的所有值
mixinGetExecuteRule(column, commonFormData) {
return new Promise(async (resolve) => {
let rules = []
column.forEach(item => {
if (item.fillRuleCode) {
rules.push({
ruleCode: item.fillRuleCode,
})
}
})
if (rules.length == 0) {
resolve(false)
return false
}
let res = await executeRuleByApi({
rules,
commonFormData
})
let ruleResObj = {}
res.data.data.forEach(item => {
ruleResObj[item.ruleCode] = item.result
})
if (res.data.success) {
resolve(ruleResObj)
} else {
resolve(false)
}
})
},
//选择字段远端数据
mixinGetSelectRemoteData(url, format) {
return new Promise(async (resolve) => {
if (url.indexOf('/') == 0) {
url = '/api' + url
}
let res = await getSelectRemoteDataApi(url)
let data = res.data
try {
if (format) {
format = format.split('.')
format.forEach(item => {
data = data[item]
})
}
} catch (error) {
console.warn('字段远端数据值格式配置异常,url:', url)
}
resolve(data)
})
},
//js增强 接口请求api
mixinRequestData(url, parameter, method, type, config) {
return new Promise(async (resolve, reject) => {
if (url.indexOf('/') == 0) {
url = '/api' + url
}
if (type == 'request') {
requestActionApi(url, parameter, method).then(res => {
resolve(res.data)
}).catch(err => {
reject(err)
})
}
if (method == 'get' && !type) {
getActionApi(url, parameter, config).then(res => {
resolve(res.data)
}).catch(err => {
reject(err)
})
}
if (method == 'post' && !type) {
postActionApi(url, parameter, config).then(res => {
resolve(res.data)
}).catch(err => {
reject(err)
})
}
if (method == 'put' && !type) {
putActionApi(url, parameter, config).then(res => {
resolve(res.data)
}).catch(err => {
reject(err)
})
}
if (method == 'delete' && !type) {
deleteActionApi(url, parameter, config).then(res => {
resolve(res.data)
}).catch(err => {
reject(err)
})
}
})
},
//js/css外部增强
mixinExternalEnhance(url) {
return new Promise(async (resolve) => {
let res = {}
if (url.indexOf('/') == 0) {
url = '/api' + url
}
res = await getJsOrCssStrApi(url)
resolve(res.data)
})
},
},
} | 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/mixins/form.js | JavaScript | apache-2.0 | 4,463 |
import Layout from '@/page/index/'
export default [
{
path: '/tool/codetestlist',
component: Layout,
children: [{
path: ":id",
name: 'AUTO在线表单',
component: () =>
import( /* webpackChunkName: "views" */ '@/research/views/tool/codetestlist.vue'),
props: true
}]
},
{
path: '/tool/codetesttabs',
component: Layout,
children: [{
path: ":code",
name: 'AUTO在线表单tabs',
component: () =>
import( /* webpackChunkName: "views" */ '@/research/views/tool/codetesttabs.vue'),
props: true
}]
}
] | 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/router/index.js | JavaScript | apache-2.0 | 601 |
const researchGetters = {
provinces: state => state.research.provinces,
remoteValues: state => state.research.remoteValues,
allOptinsAcc: state => state.research.allOptinsAcc,
allDicListData: state => state.research.allDicListData,
wxBindCode: state => state.user.wxBindCode,
tenantId: state => state.user.tenantId,
tenantName: state => state.user.tenantName,
}
export default researchGetters | 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/store/getters.js | JavaScript | apache-2.0 | 406 |
const research = {
state: {
// 基础
provinces: {}, //省市区数据
// 表单
remoteValues: [], //远程取值是否完成
allOptinsAcc: [],//所有的配置是否处理完成
allDicListData: [],//所有字典列表
},
mutations: {
SET_PROVINCES: (state, provinces) => {
state.provinces = provinces;
},
SET_REMOTE_VAKUES: (state, data) => {
if (data.type == 'del') {
state.remoteValues = []
} else {
state.remoteValues.push(data.bool);
}
},
SET_ALL_OPTINS_ACC: (state, data) => {
if (data.type == 'del') {
state.allOptinsAcc = []
} else {
state.allOptinsAcc.push(data.bool);
}
},
SET_ALL_DIC_LIST_DATA: (state, data) => {
state.allDicListData = data
},
},
actions: {},
}
export default research | 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/store/research.js | JavaScript | apache-2.0 | 844 |
.avue-form-work-style {
/deep/.el-collapse-item__content {
padding: 1px 1px 0 1px;
}
/deep/.avue-form__group {
border: 0;
// border: 1px solid #000;
// border-width: 1px 0 0 1px;
// border-right-color: #fff;
// border-bottom-color: #fff;
.avue-form__row {
padding: 0 !important;
margin-bottom: 0;
.el-form-item {
margin-bottom: 0;
border: 1px solid #000;
margin-top: -1px;
margin-left: -1px;
textarea {
border: 0;
}
input {
border: 0;
}
.el-input-number {
span {
height: 30px;
line-height: 30px;
i {
height: 30px;
line-height: 30px;
}
}
}
.el-switch {
padding-left: 10px;
&::after {
content: "";
line-height: 32px;
height: 32px;
}
}
.avue-checkbox {
line-height: normal !important;
.el-checkbox-group {
padding-left: 10px;
display: flex;
flex-wrap: wrap;
// display: inline-block;
// line-height: 1;
// vertical-align: middle;
.el-checkbox {
display: flex;
align-items: center;
}
label {
height: 32px !important;
line-height: 32px !important;
}
}
}
.avue-radio {
line-height: normal !important;
.el-radio-group {
padding-left: 10px;
label {
height: 32px;
line-height: 32px;
}
}
}
.form-custom-rate {
padding: 0 0 0 10px;
height: 32px;
display: flex;
align-items: center;
.el-rate {
height: 32px !important;
.el-rate__item {
i {
height: 32px;
line-height: 32px;
}
}
}
}
.avue-input-color {
.el-input-group__append {
border: 0;
}
}
.el-slider {
height: 32px;
display: flex;
align-items: center;
padding: 0 10px;
}
.el-divider {
.el-divider__text {
line-height: 31px;
}
}
.avue-upload[uploadtype="file"],
.avue-upload[uploadtype="img"] {
padding: 8px 0 0 8px;
}
.avue-upload[uploadtype="img"] {
.avue-upload {
height: 155px;
.el-upload-list__item {
margin-bottom: 0;
}
}
.el-upload--picture-card {
i {
height: 146px;
line-height: 146px;
}
}
}
.avue-ueditor {
.w-e-toolbar {
box-sizing: border-box !important;
border-style: #000 #000 #eee #000;
border-width: 0 0 1px 0 !important;
.w-e-menu {
display: block !important;
text-align: center !important;
line-height: 40px !important;
height: 40px !important;
i {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
}
}
.w-e-text-container {
border: 0 !important;
height: 299px !important;
line-height: 299px !important;
.w-e-text {
min-height: 299px !important;
height: 299px !important;
line-height: 299px !important;
}
}
}
.markdown-body {
box-shadow: none !important;
padding-bottom: 1px;
.v-note-op {
padding: 0;
border-radius: 0;
}
}
.form-custom-separator {
// &::after {
// display: block;
// content: "";
// line-height: 32px;
// height: 32px;
// }
.el-divider {
margin: 15.5px 0 !important;
&::after {
content: "";
display: block;
position: absolute;
left: 0;
top: 0;
height: 1px;
line-height: 1px;
background-color: #dcdfe6;
width: 100%;
}
.el-divider__text {
z-index: 999;
}
}
}
}
.avue-crud {
.avue-crud__menu {
padding: 10px 0 0 10px;
}
.el-form-item {
border: 0;
margin: 0;
input {
border: 1px solid #dcdfe6;
}
textarea {
border: 1px solid #dcdfe6;
}
}
}
}
.avue-form__menu {
width: calc(100% + 2px);
border-left: 1px solid #fff;
border-right: 1px solid #fff;
// border-top: 1px solid #000;
margin: -1px -1px 0px -1px;
}
}
/deep/.table-control {
.el-form {
font-size: 0;
}
.has-gutter {
th {
background-color: #fff;
border-bottom-color: #000;
border-right: 1px solid #000;
&:nth-last-child(1) {
border-right: 0;
border-bottom: 1px solid #000;
}
&:nth-last-child(2) {
display: none;
border-right: 0;
}
&:nth-last-child(3) {
border-right: 0;
}
}
}
.el-table--enable-row-hover .el-table__body tr:hover > td {
background-color: #fff;
}
.el-table__body-wrapper {
.el-table__row {
td {
border-bottom: 1px solid #000;
border-right: 1px solid #000;
&:nth-last-child(1) {
border-right: 0;
}
&:nth-last-child(2) {
border-right: 0;
}
.el-input__inner,
.el-textarea__inner {
border: 0 !important;
}
}
}
}
}
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/styles/form.scss | SCSS | apache-2.0 | 6,262 |
//******************************** Input框 正则表达式验证 **********************************
//inpu框,只能输入数字和小数点,【两位小数,正数】
export const clearNum = (obj) => {
obj.value = obj.value.replace(/[^\d.]/g, '').replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3');
}
//inpu框,只能输入数字和小数点,【三位小数,正数】
export const clearNumThreeDecimal = (obj) => {
obj.value = obj.value.replace(/[^\d.]/g, '').replace(/^(\-)*(\d+)\.(\d\d\d).*$/, '$1$2.$3');
}
//inpu框,只能输入数字和小数点,【两位小数,正、负数】
export const clearNumMin = (obj) => {
obj.value = obj.value.replace(/[^-*\d.]/g, '').replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3');
}
//inpu框,只能输入数字和小数点,【两位小数,正、负数】
export const clearNumMinNoPer = (obj) => {
obj.value = obj.value.replace(/[^-*\d.]/g, '').replace(/^(\-)*(\d+)\.(\d+).*$/, '$1$2.$3');
}
//inpu框,只能输入数字,【正整数和零】
export const clearNumIntegar = (obj) => {
obj.value = obj.value.replace(/\D/g, '');
}
//inpu框,只能输入数字,【正整数(大于零)】
export const clearNumPosIntegar = (obj) => {
if (obj.value.length == 1) {
obj.value = obj.value.replace(/[^1-9]/g, '');
}
else {
obj.value = obj.value.replace(/\D/g, '');
}
}
//inpu框,只能输入数字,【正整数(大于零)】
export const clearNumPosIntegarOne = (obj) => {
if (obj.value.length == 1) {
obj.value = obj.value.replace(/[^1-9]/g, '1');
}
else {
obj.value = obj.value.replace(/\D/g, '1');
}
}
//inpu框,只能输入数字英文
export const clearNumCap = (obj) => {
obj.value = obj.value.replace(/[^A-Z0-9]/g, '');
}
export const clearNumCap2 = (obj) => {
obj.value = obj.value.replace(/[^a-zA-Z0-9]/g, '');
}
//只能输入数字英文中文
export const clearSpecialAll = (obj) => {
obj.value = obj.value.replace(/[^\u4E00-\u9FA5A-Za-z0-9]/g, '');
}
//inpu框,不能输入特殊字符
export const clearSpecial = (obj) => {
obj.value = obj.value.replace(/[\。\,\、\’\;\:\“\”\_\‘\’\!\,\.\!\|\~\`\(\)\#\@\%\+\=\/\'\$\%\^\&\*\{\}\:\;\"\<\>\?\\]/g, '');
}
//不能输入英文双引号
export const CheckContent = (obj) => {
obj.value = obj.value.replace(/[\"]/g, '');
}
export const clearInputAll = (obj) => {
obj.value = '';
}
//********************************** 为空和NULL的处理 ****************************
//为空数值处理
export const IsNullEmptyNum = (str, nullRtnStr, isRtnStr) => {
if (str == null || str == "" || str == "null" || str == "undefined" || str == undefined) {
if (isRtnStr) {
return nullRtnStr;
}
return 0;
}
return str;
}
//为空文字处理
export const IsNullEmpty = (str, nullRtnStr, isRtnStr) => {
if (str == null || str == "null" || str == "undefined" || str == undefined) {
if (isRtnStr) {
return nullRtnStr;
}
return "";
}
return str;
}
//时间为空处理(精确到:分)
export const IsNullEmptyDataTime = (str, nullRtnStr, isRtnStr) => {
if (str == null || str == "" || str == "undefined" || str == undefined) {
if (isRtnStr) {
return nullRtnStr;
}
return "";
}
return str.replace('T', ' ').substring(0, 16);
}
//时间为空处理(精确到:秒)
export const IsNullEmptyDataTimeSecond = (str, nullRtnStr, isRtnStr) => {
if (str == null || str == "" || str == "undefined" || str == undefined) {
if (isRtnStr) {
return nullRtnStr;
}
return "";
}
return str.replace('T', ' ').substring(0, 19);
}
//时间为空处理(精确到:天)
export const IsNullEmptyDataTimeDay = (str, nullRtnStr, isRtnStr) => {
if (str == null || str == "" || str == "undefined" || str == undefined) {
if (isRtnStr) {
return nullRtnStr;
}
return "";
}
return str.replace('T', ' ').substring(0, 10);
}
//时间为空处理(精确到:天 空格)
export const IsNullEmptyDataTimeDayKg = (str, nullRtnStr, isRtnStr) => {
if (str == null || str == "" || str == "undefined" || str == undefined) {
if (isRtnStr) {
return nullRtnStr;
}
return "";
}
var aa = str.replace('T', ' ').substring(0, 10);
aa = aa.replace(/-/g, ' ');
return aa;
}
//时间为空处理(精确到:天 空格1)
export const IsNullEmptyDataTimeDayKg1 = (str, nullRtnStr, isRtnStr) => {
if (str == null || str == "" || str == "undefined" || str == undefined) {
if (isRtnStr) {
return nullRtnStr;
}
return "";
}
return str.replace('T', ' ').substring(0, 10).replace(/-/g, ' ');
}
//时间为空处理(精确到:月)
export const IsNullEmptyDataTimeMonth = (str, nullRtnStr, isRtnStr) => {
if (str == null || str == "" || str == "undefined" || str == undefined) {
if (isRtnStr) {
return nullRtnStr;
}
return "";
}
return str.replace('T', ' ').substring(0, 7);
}
//时间为空处理(精确到:年)
export const IsNullEmptyDataTimeYear = (str, nullRtnStr, isRtnStr) => {
if (str == null || str == "" || str == "undefined" || str == undefined) {
if (isRtnStr) {
return nullRtnStr;
}
return "";
}
return str.substring(0, 4);
}
//时间为空处理(精确到:月-日-小时-分,格式:MM-dd HH:mm)
export const IsNullEmptyDataTimeMonthMinute = (str, nullRtnStr, isRtnStr) => {
if (str == null || str == "" || str == "undefined" || str == undefined) {
if (isRtnStr) {
return nullRtnStr;
}
return "";
}
return str.replace('T', ' ').substring(5, 16);
}
//时间为空处理(精确到:小时-分,格式:HH:mm)
export const IsNullEmptyDataTimeHoureMinute = (str, nullRtnStr, isRtnStr) => {
if (str == null || str == "" || str == "undefined" || str == undefined) {
if (isRtnStr) {
return nullRtnStr;
}
return "";
}
return str.replace('T', ' ').substring(11, 16);
}
export const timeSplictYMD = (startDate) => {
var times = IsNullEmptyDataTimeDay(startDate);
if (times != "") {
var startTimeList = times.split("-");
if (startTimeList.length == 3) {
times = startTimeList[0] + "年" + startTimeList[1] + "月" + startTimeList[2] + "日";
}
}
return times;
}
//创建唯一字符串
export const newGuid = () => {
//var guid = "";
//var n = (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
//for (var i = 1; i <= 8; i++) {
// guid += n;
//}
//return guid;
var guid = "";
for (var i = 1; i <= 32; i++) {
var n = Math.floor(Math.random() * 16.0).toString(16);
guid += n;
//if (isMiddline && (i == 8 || i == 12 || i == 16 || i == 20)) {
// guid += "-";
//}
}
return guid;
}
//邮箱验证
export const fChkMail = (szMail) => {
var szReg = /^([\.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
//var szReg = /^[A-Za-zd]+([-_.][A-Za-zd]+)*@([A-Za-zd]+[-.])+[A-Za-zd]{2,5}$/;
//var szReg = /w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
var bChk = szReg.test(szMail);
return bChk;
}
//去除字符串两端空格
export const StrTirm = (Str) => {
//.replace(/^\s+|\s+$/g, "")
if (Str.length > 0) {
return Str.replace(/^\s+|\s+$/g, "");
}
return Str;
}
/******************* 身份证号验证 Start ***********************/
//身份证号码验证
export const isIdCardNo = (num) => {
num = num.toUpperCase();
var factorArr = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1);
var parityBit = new Array("1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2");
var varArray = new Array();
var intValue;
var lngProduct = 0;
var intCheckDigit;
var intStrLen = num.length;
var idNumber = num;
// initialize
if ((intStrLen != 15) && (intStrLen != 18)) {
return false;
}
// check and set value
for (i = 0; i < intStrLen; i++) {
varArray[i] = idNumber.charAt(i);
if ((varArray[i] < '0' || varArray[i] > '9') && (i != 17)) {
return false;
} else if (i < 17) {
varArray[i] = varArray[i] * factorArr[i];
}
}
if (intStrLen == 18) {
//check date
var date8 = idNumber.substring(6, 14);
if (isDate8(date8) == false) {
return false;
}
// calculate the sum of the products
for (i = 0; i < 17; i++) {
lngProduct = lngProduct + varArray[i];
}
// calculate the check digit
intCheckDigit = parityBit[lngProduct % 11];
// check last digit
if (varArray[17] != intCheckDigit) {
return false;
}
}
else { //length is 15
//check date
var date6 = idNumber.substring(6, 12);
if (isDate6(date6) == false) {
return false;
}
}
return true;
}
export const isDate6 = (sDate) => {
if (!/^[0-9]{6}$/.test(sDate)) {
return false;
}
var year, month, day;
year = sDate.substring(0, 4);
month = sDate.substring(4, 6);
if (year < 1700 || year > 2500) return false
if (month < 1 || month > 12) return false
return true
}
export const isDate8 = (sDate) => {
if (!/^[0-9]{8}$/.test(sDate)) {
return false;
}
var year, month, day;
year = sDate.substring(0, 4);
month = sDate.substring(4, 6);
day = sDate.substring(6, 8);
var iaMonthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if (year < 1700 || year > 2500) return false
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) iaMonthDays[1] = 29;
if (month < 1 || month > 12) return false
if (day < 1 || day > iaMonthDays[month - 1]) return false
return true
}
/******************** 身份证号验证 END ******************************/
/**---------金额大写转换(转化为中文)------------**/
export const ToCapitalized = (n) => { //金额大写转换函数
if (n <= 0) {
return "";
}
var unit = "仟佰拾亿仟佰拾万仟佰拾元角分", str = "";
n += "00";
var p = n.indexOf('.');
if (p >= 0)
n = n.substring(0, p) + n.substr(p + 1, 2);
unit = unit.substr(unit.length - n.length);
for (var i = 0; i < n.length; i++) {
str += '零壹贰叁肆伍陆柒捌玖'.charAt(n.charAt(i)) + unit.charAt(i);
}
return str.replace(/零(仟|佰|拾|角)/g, "零").replace(/(零)+/g, "零").replace(/零(万|亿|元)/g, "$1").replace(/(亿)万|(拾)/g, "$1$2").replace(/^元零?|零分/g, "").replace(/元$/g, "元整");
}
export const ToCapitalizedDe = (n) => { //金额大写转换函数
if (n <= 0) {
return "";
}
var str = "";
n += "00";
var p = n.indexOf('.');
if (p >= 0)
n = n.substring(0, p) + n.substr(p + 1, 2);
for (var i = 0; i < (9 - n.length); i++) {
str += '零 ';
}
for (var i = 0; i < n.length; i++) {
str += '零壹贰叁肆伍陆柒捌玖'.charAt(n.charAt(i)) + ' ';
}
return str;
}
export const ToCapitalizedCb = (n) => { //金额大写转换函数
if (n <= 0) {
return "";
}
var dxMongy = "";
var str = "";
n += "00";
var p = n.indexOf('.');
if (p >= 0)
n = n.substring(0, p) + n.substr(p + 1, 2);
for (var i = 0; i < (8 - n.length); i++) {
dxMongy += '零';
}
for (var i = 0; i < n.length; i++) {
dxMongy += '零壹贰叁肆伍陆柒捌玖'.charAt(n.charAt(i));// + ' ';
}
for (var i = 0; i < dxMongy.length; i++) {
if (i < 5) {
str += dxMongy[i] + ' ';
} else {
str += dxMongy[i] + ' ';
}
}
return str;
}
//手机和电话验证
export const IsTelPhone = (str) => {
var mobile = /^1[3-9]+\d{9}$/;
var phone = /^(0\d{2,3})?-?\d{7,8}$/;
if (mobile.test(str) || phone.test(str)) {
return true;
} else {
return false;
}
}
//表号验证 (数字英文横杠)
export const IsMeterNo = (str) => {
var regx = /^[A-Za-z0-9/-]+$/;
if (regx.test(str)) {
return true;
} else {
return false;
}
}
export const IsNumber = (val) => {
var regPos = /^\d+(\.\d+)?$/; //非负浮点数
if (regPos.test(val)) {
return true;
} else {
return false;
}
}
//开始时间 stime
//结束时间 etime
export const CheckTimeOneYear = (stime, etime) => {
var timemils = Date.parse(delimiterConvert(etime)) - Date.parse(delimiterConvert(stime)); //开始时间到结束时间的时间差。
if (timemils < 0) {
return false;
}
var yearmils = (1000 * 60 * 60 * 24 * 366);//一年的时间差
if (timemils > yearmils) {
return false;
}
return true;
}
export const delimiterConvert = (val) => { //格式话数据
return val.replace('-', '/').replace('-', '/')
}
//获取时间
//时间 PassTime 无值时,去当前时间
//时间格式 FormatType 0 yyyy-MM-dd,1 yyyy-MM-dd HH:mm:ss
//差距年份 YearNum 0是当前年 1是加1年 -1 是减1年
///getFormatDate("",0,-1);//前面一年的时间
///getFormatDate("", 0, 0);//当前时间
export const getFormatDate = (PassTime, FormatType, YearNum) => {
var nowDate = new Date();
if (IsNullEmpty(PassTime) != "") {
nowDate = new Date(PassTime);
}
var year = nowDate.getFullYear() + parseInt(IsNullEmptyNum(YearNum));
var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1) : nowDate.getMonth() + 1;
var date = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate.getDate();
var hour = nowDate.getHours() < 10 ? "0" + nowDate.getHours() : nowDate.getHours();
var minute = nowDate.getMinutes() < 10 ? "0" + nowDate.getMinutes() : nowDate.getMinutes();
var second = nowDate.getSeconds() < 10 ? "0" + nowDate.getSeconds() : nowDate.getSeconds();
var retime = year + "-" + month + "-" + date;
if (FormatType == 1) {
retime = year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;;
}
return retime;
}
| 2301_78526554/springboot-openai-chatgpt | mng_web/src/research/util/Validation.js | JavaScript | apache-2.0 | 13,607 |