@@ -1,34 +1,52 @@ | |||||
<template> | <template> | ||||
<transition name="el-fade-in-linear"> | |||||
<router-view /> | |||||
</transition> | |||||
<transition name="el-fade-in-linear"> | |||||
<router-view /> | |||||
</transition> | |||||
</template> | </template> | ||||
<style> | <style> | ||||
.el-table th.gutter{ | |||||
display: table-cell!important; | |||||
} | |||||
.el-table th.gutter { | |||||
display: table-cell !important; | |||||
} | |||||
</style> | </style> | ||||
<script> | <script> | ||||
import Cookies from 'js-cookie' | |||||
import { messages } from '@/i18n' | |||||
import Cookies from "js-cookie"; | |||||
import { messages } from "@/i18n"; | |||||
export default { | export default { | ||||
watch: { | |||||
'$i18n.locale': 'i18nHandle' | |||||
}, | |||||
created () { | |||||
this.i18nHandle(this.$i18n.locale) | |||||
}, | |||||
methods: { | |||||
i18nHandle (val, oldVal) { | |||||
Cookies.set('language', val) | |||||
document.querySelector('html').setAttribute('lang', val) | |||||
document.title = messages[val].brand.lg | |||||
// 非登录页面,切换语言刷新页面 | |||||
if (this.$route.name !== 'login' && oldVal) { | |||||
window.location.reload() | |||||
} | |||||
} | |||||
} | |||||
} | |||||
watch: { | |||||
"$i18n.locale": "i18nHandle", | |||||
}, | |||||
created() { | |||||
this.i18nHandle(this.$i18n.locale); | |||||
}, | |||||
methods: { | |||||
i18nHandle(val, oldVal) { | |||||
Cookies.set("language", val); | |||||
document.querySelector("html").setAttribute("lang", val); | |||||
document.title = messages[val].brand.lg; | |||||
// 非登录页面,切换语言刷新页面 | |||||
if (this.$route.name !== "login" && oldVal) { | |||||
window.location.reload(); | |||||
} | |||||
}, | |||||
}, | |||||
}; | |||||
</script> | </script> | ||||
<style> | |||||
::-webkit-scrollbar { | |||||
width: 12px !important; | |||||
} | |||||
::-webkit-scrollbar-track { | |||||
/* width: 100%; */ | |||||
} | |||||
::-webkit-scrollbar-thumb { | |||||
background: rgb(188, 188, 188); | |||||
} | |||||
::-webkit-scrollbar-button { | |||||
display: none; | |||||
} | |||||
</style> |
@@ -7,7 +7,9 @@ | |||||
> | > | ||||
<!-- title --> | <!-- title --> | ||||
<div slot="title" class="dialog-title"> | <div slot="title" class="dialog-title"> | ||||
<h1 class="">编辑</h1> | |||||
<h1 class=""> | |||||
{{ detailMode ? "查看详情" : dataForm.id ? "编辑" : "新增" }} | |||||
</h1> | |||||
</div> | </div> | ||||
<!-- menu --> | <!-- menu --> | ||||
<el-tabs v-model="activeMenu" type="card" @tab-click="handleTabClick"> | <el-tabs v-model="activeMenu" type="card" @tab-click="handleTabClick"> | ||||
@@ -201,6 +203,10 @@ export default { | |||||
/** init **/ | /** init **/ | ||||
init(id, detailMode) { | init(id, detailMode) { | ||||
if (this.$refs.dataForm && this.$refs.dataForm.length) { | |||||
// 当不是首次渲染dialog的时候,一开始就清空验证信息,本组件的循环里只有一个 dataForm 所以只用取 [0] 即可 | |||||
this.$refs.dataForm[0].clearValidate() | |||||
} | |||||
console.log("[dialog] DialogWithHead init():", id, detailMode); | console.log("[dialog] DialogWithHead init():", id, detailMode); | ||||
this.detailMode = detailMode ?? false; | this.detailMode = detailMode ?? false; | ||||
@@ -254,13 +260,13 @@ export default { | |||||
// }); | // }); | ||||
// } | // } | ||||
} | } | ||||
this.selfVisible = true; | |||||
}); | }); | ||||
} else { | } else { | ||||
// 如果不是编辑 | // 如果不是编辑 | ||||
this.selfVisible = true; | |||||
} | } | ||||
}); | }); | ||||
this.selfVisible = true; | |||||
}, | }, | ||||
/** handlers */ | /** handlers */ | ||||
@@ -149,8 +149,10 @@ export default { | |||||
}, | }, | ||||
init(id, isdetail = false) { | init(id, isdetail = false) { | ||||
this.detailMode = isdetail; | |||||
console.log("[small dialog] init", id, isdetail); | console.log("[small dialog] init", id, isdetail); | ||||
this.detailMode = isdetail; | |||||
if (this.$refs.dataForm) this.$refs.dataForm.clearValidate() | |||||
this.$nextTick(() => { | this.$nextTick(() => { | ||||
// this.$refs['dataForm'].resetFields(); | // this.$refs['dataForm'].resetFields(); | ||||
@@ -168,13 +170,13 @@ export default { | |||||
const dataFormKeys = Object.keys(this.dataForm); | const dataFormKeys = Object.keys(this.dataForm); | ||||
this.dataForm = __pick(res.data, dataFormKeys); | this.dataForm = __pick(res.data, dataFormKeys); | ||||
} | } | ||||
this.visible = true; | |||||
}); | }); | ||||
} else { | } else { | ||||
// 如果不是编辑 | // 如果不是编辑 | ||||
this.visible = true | |||||
} | } | ||||
}); | }); | ||||
this.visible = true; | |||||
}, | }, | ||||
handleSelectChange(col, event) {}, | handleSelectChange(col, event) {}, | ||||
@@ -190,13 +192,14 @@ export default { | |||||
break; | break; | ||||
case "add": | case "add": | ||||
case "update": { | case "update": { | ||||
console.log('update extraParam: ', this.configs.extraParam) | |||||
const method = payload.name === "add" ? "POST" : "PUT"; | const method = payload.name === "add" ? "POST" : "PUT"; | ||||
this.$http({ | this.$http({ | ||||
url: this.urls.subase, | url: this.urls.subase, | ||||
method, | method, | ||||
data: { | data: { | ||||
...this.dataForm, | ...this.dataForm, | ||||
[this.configs.extraParams]: this.relatedId, | |||||
[this.configs.extraParam]: this.relatedId, // this.configs.extraParam 只能是字符串 | |||||
}, | }, | ||||
}).then(({ data: res }) => { | }).then(({ data: res }) => { | ||||
console.log("[add&update] res is: ", res); | console.log("[add&update] res is: ", res); | ||||
@@ -67,7 +67,7 @@ export default { | |||||
// 可能需要验证权限,如 opt.permission 选项 | // 可能需要验证权限,如 opt.permission 选项 | ||||
// 注意:为空字符串或null/undefined都会不验证权限 | // 注意:为空字符串或null/undefined都会不验证权限 | ||||
if (!opt.permission || (opt.permission && this.$hasPermission(opt.permission))) { | if (!opt.permission || (opt.permission && this.$hasPermission(opt.permission))) { | ||||
console.log('[operation component]: ', opt.permission, this.$hasPermission(opt.permission)) | |||||
// console.log('[operation component]: ', opt.permission, this.$hasPermission(opt.permission)) | |||||
btns.push( | btns.push( | ||||
h('el-button', | h('el-button', | ||||
{ | { | ||||
@@ -235,6 +235,6 @@ export default { | |||||
min-height: inherit; | min-height: inherit; | ||||
border-radius: 6px; | border-radius: 6px; | ||||
padding: 16px; | padding: 16px; | ||||
box-shadow: 0 0 2px 1px rgba(0, 0, 0, 0.125); | |||||
box-shadow: 0 0 1.125px .125px rgba(0, 0, 0, 0.125); | |||||
} | } | ||||
</style> | </style> |
@@ -107,7 +107,7 @@ export default function () { | |||||
}, | }, | ||||
subDialog: { | subDialog: { | ||||
extraParams: 'stepId', | |||||
extraParam: 'stepId', | |||||
rows: [ | rows: [ | ||||
[ | [ | ||||
{ input: true, label: '步骤', prop: 'sort', rules: { required: true, message: 'not empty', trigger: 'blur' }, elparams: { placeholder: '请输入步骤' } }, | { input: true, label: '步骤', prop: 'sort', rules: { required: true, message: 'not empty', trigger: 'blur' }, elparams: { placeholder: '请输入步骤' } }, | ||||