⚡优化Vue2功能
This commit is contained in:
parent
5375b9e308
commit
f05dec13da
@ -3,7 +3,7 @@
|
|||||||
"description": "ZrAdmnin.NET后台管理",
|
"description": "ZrAdmnin.NET后台管理",
|
||||||
"author": "ZR",
|
"author": "ZR",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vue-cli-service serve",
|
"dev": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
|
||||||
"build:prod": "vue-cli-service build",
|
"build:prod": "vue-cli-service build",
|
||||||
"build:stage": "vue-cli-service build --mode staging"
|
"build:stage": "vue-cli-service build --mode staging"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -5,7 +5,7 @@ export function listArticle(query) {
|
|||||||
return request({
|
return request({
|
||||||
url: '/Article/list',
|
url: '/Article/list',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: query
|
params: query,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 查询最新列表
|
// 查询最新列表
|
||||||
@ -13,7 +13,7 @@ export function listNewArticle(query) {
|
|||||||
return request({
|
return request({
|
||||||
url: '/Article/newList',
|
url: '/Article/newList',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: query
|
params: query,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ export function updateArticle(data) {
|
|||||||
return request({
|
return request({
|
||||||
url: '/Article/edit',
|
url: '/Article/edit',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data: data
|
data: data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,20 +47,20 @@ export function updateArticle(data) {
|
|||||||
export function delArticle(id) {
|
export function delArticle(id) {
|
||||||
return request({
|
return request({
|
||||||
url: '/Article/' + id,
|
url: '/Article/' + id,
|
||||||
method: 'delete'
|
method: 'delete',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 查询菜单目录
|
// 查询菜单目录
|
||||||
export function listArticleCategory() {
|
export function listArticleCategory() {
|
||||||
return request({
|
return request({
|
||||||
url: '/Article/CategoryList',
|
url: '/Article/CategoryList',
|
||||||
method: 'get'
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 查询菜单目录树
|
// 查询菜单目录树
|
||||||
export function listArticleCategoryTree(){
|
export function listArticleCategoryTree() {
|
||||||
return request({
|
return request({
|
||||||
url: '/Article/CategoryTreeList',
|
url: '/Article/ArticleCategory/treeList',
|
||||||
menubar: 'get'
|
menubar: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,14 @@ export function listMenu(query) {
|
|||||||
return request({
|
return request({
|
||||||
url: '/system/menu/list',
|
url: '/system/menu/list',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: query
|
params: query,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
export function listTreeMenu(query) {
|
||||||
|
return request({
|
||||||
|
url: '/system/menu/treelist',
|
||||||
|
method: 'get',
|
||||||
|
params: query,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 查询菜单列表
|
// 查询菜单列表
|
||||||
@ -27,7 +34,7 @@ export function getMenu(menuId) {
|
|||||||
export function treeselect() {
|
export function treeselect() {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/Menu/treeSelect',
|
url: '/system/Menu/treeSelect',
|
||||||
method: 'get'
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +60,7 @@ export function updateMenu(data) {
|
|||||||
return request({
|
return request({
|
||||||
url: '/system/Menu/edit',
|
url: '/system/Menu/edit',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: data
|
data: data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +68,7 @@ export function updateMenu(data) {
|
|||||||
export function delMenu(menuId) {
|
export function delMenu(menuId) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/Menu/' + menuId,
|
url: '/system/Menu/' + menuId,
|
||||||
method: 'delete'
|
method: 'delete',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +77,7 @@ export function changeMenuSort(data) {
|
|||||||
return request({
|
return request({
|
||||||
url: '/system/Menu/ChangeSort',
|
url: '/system/Menu/ChangeSort',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: data
|
params: data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,6 +86,6 @@ export const getRouters = (query) => {
|
|||||||
return request({
|
return request({
|
||||||
url: '/getRouters',
|
url: '/getRouters',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: query
|
params: query,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,7 +64,7 @@ export function importTable(data) {
|
|||||||
return request({
|
return request({
|
||||||
url: '/tool/gen/importTable',
|
url: '/tool/gen/importTable',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
params: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 删除表数据
|
// 删除表数据
|
||||||
|
|||||||
@ -13,7 +13,6 @@ const whiteList = ['/login', '/auth-redirect', '/bind', '/register', '/demo']
|
|||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
NProgress.start()
|
NProgress.start()
|
||||||
console.log('path=' + to.path);
|
|
||||||
|
|
||||||
if (getToken()) {
|
if (getToken()) {
|
||||||
to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
|
to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
|
||||||
|
|||||||
@ -9,52 +9,53 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :lg="12">
|
<el-col :lg="12">
|
||||||
<el-form-item label="文章分类" prop="category_id">
|
<el-form-item label="文章分类" prop="categoryId">
|
||||||
<treeselect v-model="form.category_id" :options="categoryOptions" :normalizer="normalizer" :show-count="true" />
|
<treeselect v-model="form.categoryId" :options="categoryOptions" :normalizer="normalizer" :show-count="true" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :lg="24">
|
<el-col :lg="24">
|
||||||
<el-form-item label="文章标签">
|
<el-form-item label="文章标签">
|
||||||
<el-tag size="large" :key="tag" v-for="tag in form.dynamicTags" closable :disable-transitions="false" @close="handleCloseTag(tag)">
|
<el-tag size="large" :key="tag" v-for="tag in form.dynamicTags" closable :disable-transitions="false" @close="handleCloseTag(tag)">
|
||||||
{{tag}}
|
{{ tag }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
<el-input class="input-new-tag" v-if="inputVisible" v-model="inputValue" ref="saveTagInput" size="small"
|
<el-input
|
||||||
@keyup.enter.native="handleInputConfirm" @blur="handleInputConfirm">
|
class="input-new-tag"
|
||||||
|
v-if="inputVisible"
|
||||||
|
v-model="inputValue"
|
||||||
|
ref="saveTagInput"
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleInputConfirm"
|
||||||
|
@blur="handleInputConfirm"
|
||||||
|
>
|
||||||
</el-input>
|
</el-input>
|
||||||
<el-button v-else class="button-new-tag" size="small" @click="showInput">+ 文章标签</el-button>
|
<el-button v-else class="button-new-tag" size="small" @click="showInput">+ 文章标签</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :lg="24">
|
<el-col :lg="24">
|
||||||
<el-form-item prop="content" label="文章内容">
|
<el-form-item prop="content" label="文章内容">
|
||||||
<mavon-editor v-model="form.content" ref="md" @imgAdd="$imgAdd" @change="change" style="min-height: 400px;width:100%" />
|
<mavon-editor v-model="form.content" ref="md" @imgAdd="$imgAdd" @change="change" style="min-height: 400px; width: 100%" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :lg="24">
|
<el-col :lg="24">
|
||||||
<el-form-item label="" style="text-align:right;">
|
<el-form-item label="" style="text-align: right">
|
||||||
<el-button size="mini" @click="handlePublish('1')">发布文章</el-button>
|
<el-button size="mini" @click="handlePublish('1')">发布文章</el-button>
|
||||||
<el-button type="success" size="mini" @click="handlePublish('2')">存为草稿</el-button>
|
<el-button type="success" size="mini" @click="handlePublish('2')">存为草稿</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import {
|
import { addArticle, updateArticle, listArticleCategoryTree, getArticle } from '@/api/system/article.js'
|
||||||
addArticle,
|
import { upload } from '@/api/common.js'
|
||||||
updateArticle,
|
import { mavonEditor } from 'mavon-editor'
|
||||||
listArticleCategoryTree,
|
import 'mavon-editor/dist/css/index.css'
|
||||||
getArticle,
|
import Treeselect from '@riophae/vue-treeselect'
|
||||||
} from "@/api/system/article.js";
|
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||||
import { upload } from "@/api/common.js";
|
|
||||||
import { mavonEditor } from "mavon-editor";
|
|
||||||
import "mavon-editor/dist/css/index.css";
|
|
||||||
import Treeselect from "@riophae/vue-treeselect";
|
|
||||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "articlepublish",
|
name: 'articlepublish',
|
||||||
components: {
|
components: {
|
||||||
mavonEditor,
|
mavonEditor,
|
||||||
Treeselect,
|
Treeselect,
|
||||||
@ -64,44 +65,45 @@ export default {
|
|||||||
// 表单参数
|
// 表单参数
|
||||||
form: {
|
form: {
|
||||||
dynamicTags: [],
|
dynamicTags: [],
|
||||||
fmt_type: "markdown",
|
fmt_type: 'markdown',
|
||||||
tags: undefined,
|
tags: undefined,
|
||||||
cid: undefined,
|
cid: undefined,
|
||||||
content: undefined,
|
content: undefined,
|
||||||
|
categoryId: undefined,
|
||||||
},
|
},
|
||||||
// 文章目录下拉框
|
// 文章目录下拉框
|
||||||
categoryOptions: [],
|
categoryOptions: [],
|
||||||
// 提交按钮是否显示
|
// 提交按钮是否显示
|
||||||
btnSubmitVisible: true,
|
btnSubmitVisible: true,
|
||||||
inputVisible: false,
|
inputVisible: false,
|
||||||
inputValue: "",
|
inputValue: '',
|
||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {
|
rules: {
|
||||||
title: [{ required: true, message: "标题不能为空", trigger: "blur" }],
|
title: [{ required: true, message: '标题不能为空', trigger: 'blur' }],
|
||||||
content: [{ required: true, message: "内容不能为空", trigger: "blur" }],
|
content: [{ required: true, message: '内容不能为空', trigger: 'blur' }],
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
"form.cid": function (newVal, oldVal) {
|
'form.cid': function (newVal, oldVal) {
|
||||||
getArticle(newVal).then((res) => {
|
getArticle(newVal).then((res) => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
var data = res.data;
|
var data = res.data
|
||||||
this.form = {
|
this.form = {
|
||||||
fmt_type: data.fmt_type,
|
fmt_type: data.fmt_type,
|
||||||
cid: parseInt(newVal),
|
cid: parseInt(newVal),
|
||||||
title: data.title,
|
title: data.title,
|
||||||
content: data.content,
|
content: data.content,
|
||||||
category_id: data.category_id,
|
categoryId: data.categoryId,
|
||||||
dynamicTags: data.tags != null && data.tags.length > 0 ? data.tags.split(",") : [],
|
dynamicTags: data.tags != null && data.tags.length > 0 ? data.tags.split(',') : [],
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.form.cid = this.$route.query.cid;
|
this.form.cid = this.$route.query.cid
|
||||||
this.getCategoryTreeselect();
|
this.getCategoryTreeselect()
|
||||||
},
|
},
|
||||||
mounted() {},
|
mounted() {},
|
||||||
methods: {
|
methods: {
|
||||||
@ -109,88 +111,84 @@ export default {
|
|||||||
getCategoryTreeselect() {
|
getCategoryTreeselect() {
|
||||||
listArticleCategoryTree().then((res) => {
|
listArticleCategoryTree().then((res) => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
this.categoryOptions = res.data;
|
this.categoryOptions = res.data
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
/** 转换菜单数据结构 */
|
/** 转换菜单数据结构 */
|
||||||
normalizer(node) {
|
normalizer(node) {
|
||||||
if (node.children && !node.children.length) {
|
if (node.children && !node.children.length) {
|
||||||
delete node.children;
|
delete node.children
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
id: node.category_Id,
|
id: node.categoryId,
|
||||||
label: node.name,
|
label: node.name,
|
||||||
children: node.children,
|
children: node.children,
|
||||||
};
|
}
|
||||||
},
|
},
|
||||||
// 将图片上传到服务器,返回地址替换到md中
|
// 将图片上传到服务器,返回地址替换到md中
|
||||||
$imgAdd(pos, $file) {
|
$imgAdd(pos, $file) {
|
||||||
var formdata = new FormData();
|
var formdata = new FormData()
|
||||||
formdata.append("file", $file);
|
formdata.append('file', $file)
|
||||||
upload(formdata).then((res) => {
|
upload(formdata).then((res) => {
|
||||||
console.log(JSON.stringify(res));
|
console.log(JSON.stringify(res))
|
||||||
this.$refs.md.$img2Url(pos, res.data.url);
|
this.$refs.md.$img2Url(pos, res.data.url)
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
change(value, render) {
|
change(value, render) {
|
||||||
// render 为 markdown 解析后的结果
|
// render 为 markdown 解析后的结果
|
||||||
this.html = render;
|
this.html = render
|
||||||
},
|
},
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
handlePublish: function (status) {
|
handlePublish: function (status) {
|
||||||
this.form.status = status;
|
this.form.status = status
|
||||||
this.form.tags = this.form.dynamicTags.toString();
|
this.form.tags = this.form.dynamicTags.toString()
|
||||||
|
|
||||||
this.$refs["form"].validate((valid) => {
|
this.$refs['form'].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
if (this.form.cid != undefined) {
|
if (this.form.cid != undefined) {
|
||||||
updateArticle(this.form).then((res) => {
|
updateArticle(this.form).then((res) => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
this.msgSuccess("修改文章成功");
|
this.msgSuccess('修改文章成功')
|
||||||
this.$tab.closeOpenPage({ path: '/tool/article/index' });
|
this.$tab.closeOpenPage({ path: '/tool/article/index' })
|
||||||
} else {
|
} else {
|
||||||
this.msgError("修改文章失败");
|
this.msgError('修改文章失败')
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
} else {
|
} else {
|
||||||
addArticle(this.form).then((res) => {
|
addArticle(this.form).then((res) => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
this.msgSuccess("发布文章成功");
|
this.msgSuccess('发布文章成功')
|
||||||
this.$tab.closeOpenPage({ path: '/tool/article/index' });
|
this.$tab.closeOpenPage({ path: '/tool/article/index' })
|
||||||
} else {
|
} else {
|
||||||
this.msgError("发布文章失败");
|
this.msgError('发布文章失败')
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
handleCloseTag(tag) {
|
handleCloseTag(tag) {
|
||||||
this.form.dynamicTags.splice(this.form.dynamicTags.indexOf(tag), 1);
|
this.form.dynamicTags.splice(this.form.dynamicTags.indexOf(tag), 1)
|
||||||
},
|
},
|
||||||
showInput() {
|
showInput() {
|
||||||
this.inputVisible = true;
|
this.inputVisible = true
|
||||||
this.$nextTick((_) => {
|
this.$nextTick((_) => {
|
||||||
this.$refs.saveTagInput.$refs.input.focus();
|
this.$refs.saveTagInput.$refs.input.focus()
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
handleInputConfirm() {
|
handleInputConfirm() {
|
||||||
let inputValue = this.inputValue.trim();
|
let inputValue = this.inputValue.trim()
|
||||||
|
|
||||||
if (
|
if (inputValue && inputValue.length > 0 && this.form.dynamicTags.length < 4) {
|
||||||
inputValue &&
|
this.form.dynamicTags.push(inputValue)
|
||||||
inputValue.length > 0 &&
|
|
||||||
this.form.dynamicTags.length < 4
|
|
||||||
) {
|
|
||||||
this.form.dynamicTags.push(inputValue);
|
|
||||||
}
|
}
|
||||||
this.inputVisible = false;
|
this.inputVisible = false
|
||||||
this.inputValue = "";
|
this.inputValue = ''
|
||||||
},
|
},
|
||||||
handleTreeSelect() {},
|
handleTreeSelect() {},
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.el-tag + .el-tag {
|
.el-tag + .el-tag {
|
||||||
|
|||||||
@ -256,7 +256,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { queryColumnInfo } from '@/api/tool/gen'
|
import { queryColumnInfo } from '@/api/tool/gen'
|
||||||
import { listMenu } from '@/api/system/menu'
|
import { listTreeMenu } from '@/api/system/menu'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'BasicInfoForm',
|
name: 'BasicInfoForm',
|
||||||
@ -366,7 +366,7 @@ export default {
|
|||||||
/** 查询菜单下拉树结构 */
|
/** 查询菜单下拉树结构 */
|
||||||
getMenuTreeselect() {
|
getMenuTreeselect() {
|
||||||
/** 查询菜单下拉列表 */
|
/** 查询菜单下拉列表 */
|
||||||
listMenu({ menuTypeIds: 'M,C' }).then((response) => {
|
listTreeMenu({ menuTypeIds: 'M,C' }).then((response) => {
|
||||||
this.menuOptions = response.data
|
this.menuOptions = response.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@ -72,7 +72,7 @@ export default {
|
|||||||
},
|
},
|
||||||
// 多选框选中数据
|
// 多选框选中数据
|
||||||
handleSelectionChange(selection) {
|
handleSelectionChange(selection) {
|
||||||
this.tables = selection.map((item) => item.name);
|
this.tables = selection//.map((item) => item.name);
|
||||||
},
|
},
|
||||||
// 查询表数据
|
// 查询表数据
|
||||||
getList() {
|
getList() {
|
||||||
@ -105,7 +105,7 @@ export default {
|
|||||||
console.log(JSON.stringify(this.tables));
|
console.log(JSON.stringify(this.tables));
|
||||||
|
|
||||||
importTable({
|
importTable({
|
||||||
tables: this.tables.join(","),
|
tables: this.tables,
|
||||||
dbName: this.queryParams.dbName,
|
dbName: this.queryParams.dbName,
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
this.msgSuccess(res.msg);
|
this.msgSuccess(res.msg);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user