diff --git a/.env.development b/.env.development index 86a6939..e5a5517 100644 --- a/.env.development +++ b/.env.development @@ -8,5 +8,5 @@ VUE_APP_BASE_API = '/api/v1' # 正式服 # TARGET_API = 'https://server.ceobecanteen.top' # 测试服 -TARGET_API = 'https://server-dev.ceobecanteen.top' -# TARGET_API = 'https://kitchen-dev.ceobecanteen.top' \ No newline at end of file +# TARGET_API = 'https://server-dev.ceobecanteen.top' +TARGET_API = 'http://kitchen-dev.ceobecanteen.top' \ No newline at end of file diff --git a/mock/toolLink.js b/mock/toolLink.js index 384d3ca..dc6f6b5 100644 --- a/mock/toolLink.js +++ b/mock/toolLink.js @@ -15,11 +15,26 @@ module.exports = [ platformTable[i] = Mock.mock({ id: i, - nickname: "name"+i, - avatar: "platform"+i, - jump_url: "url"+i, + icon_url: "platform"+i, + links: [], min_request_interval:minTime, - "has_datasource|1": true + "has_datasource|1": true, + localized_name: { + zh_CN: "name"+i, + en_US: "name"+i + }, + localized_description: { + zh_CN: "description"+i, + en_US: "description"+i + }, + localized_slogan: { + zh_CN: "slogan"+i, + en_US: "slogan"+i + }, + localized_tags: { + zh_CN: ["tags"+i], + en_US: ["tags"+i] + } }); } let data = { diff --git a/mock/user.js b/mock/user.js index 48cc846..7e6ad82 100644 --- a/mock/user.js +++ b/mock/user.js @@ -9,6 +9,9 @@ const userpassword = { }, architect: { password: 'architect-password' + }, + porter: { + password: 'porter-password' } }; @@ -21,6 +24,9 @@ const tokens = { }, architect: { token: 'architect-token' + }, + porter: { + token: 'porter-token' } }; @@ -36,6 +42,10 @@ const newUser = { architect: { username: 'architect1', password: 'architect1-password' + }, + porter: { + username: 'porter1', + password: 'porter1-password' } }; @@ -51,6 +61,10 @@ const users = { 'architect-token': { roles: ['architect'], name: 'architect' + }, + 'porter-token': { + roles: ['porter'], + name: 'porter' } }; @@ -205,7 +219,7 @@ module.exports = [ response: req => { console.log(req); const { page, size } = req.query; - let auth = ['chef','cooker','architect']; + let auth = ['chef','cooker','architect', 'porter']; let userTable = []; for(let i = 0; i < 28; i++) { let index = Math.floor(Math.random()*auth.length); diff --git a/src/api/toolLink.js b/src/api/toolLink.js index 9bdf632..dce9728 100644 --- a/src/api/toolLink.js +++ b/src/api/toolLink.js @@ -2,7 +2,7 @@ import request from '@/utils/request'; export function toolLinkList(token, data) { return request({ - url: '/admin/toolLink/list', + url: '/admin/toolLink/pageShow', method: 'get', headers: token, params: data @@ -11,7 +11,7 @@ export function toolLinkList(token, data) { export function createToolLink(token, data) { return request({ - url: '/admin/toolLink/create', + url: '/admin/toolLink/createOne', method: 'post', headers: token, data: data @@ -20,7 +20,7 @@ export function createToolLink(token, data) { export function updateToolLink(token, data) { return request({ - url: '/admin/toolLink/update', + url: '/admin/toolLink/updateOne', method: 'post', headers: token, data: data @@ -29,9 +29,9 @@ export function updateToolLink(token, data) { export function deleteToolLink(token, id) { return request({ - url: '/admin/toolLink/delete', + url: '/admin/toolLink/deleteOne', method: 'delete', headers: token, - data: id + params: id }); } \ No newline at end of file diff --git a/src/const/toolLinkConfig.js b/src/const/toolLinkConfig.js new file mode 100644 index 0000000..f01bf0e --- /dev/null +++ b/src/const/toolLinkConfig.js @@ -0,0 +1 @@ +export const REGION = [ 'CHINA_MAINLAND', 'EXCEPT_CHINA_MAINLAND' ]; \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index dab1de3..0ff2f18 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -74,13 +74,13 @@ export const asyncRoutes = [ path: 'changeUsername', name: '修改用户名', component: () => import('@/views/user/changeUsername/index'), - meta: { title: '修改用户名', icon: 'el-icon-s-custom', roles: ['chef', 'cooker', 'architect'] } + meta: { title: '修改用户名', icon: 'el-icon-s-custom', roles: ['chef', 'cooker', 'architect', 'porter'] } }, { path: 'changePassword', name: '修改密码', component: () => import('@/views/user/changePassword/index'), - meta: { title: '修改密码', icon: 'lock', roles: ['chef', 'cooker', 'architect'] } + meta: { title: '修改密码', icon: 'lock', roles: ['chef', 'cooker', 'architect', 'porter'] } }, { path: 'userList', @@ -95,49 +95,49 @@ export const asyncRoutes = [ name: 'canteen', component: Layout, redirect: '/canteen/announcement', - meta: { title: '小刻食堂运营信息', icon: 'form', roles: ['chef', 'cooker'] }, + meta: { title: '小刻食堂运营信息', icon: 'form' }, children: [ { path: 'announcement', name: '公告内容', component: () => import('@/views/canteen/announcement/index'), - meta: { title: '公告内容', icon: 'el-icon-message-solid' } + meta: { title: '公告内容', icon: 'el-icon-message-solid', roles: ['chef', 'cooker'] } }, { path: 'videolist', name: '视频链接', component: () => import('@/views/canteen/videoList/index'), - meta: { title: '视频链接', icon: 'el-icon-video-camera-solid' } + meta: { title: '视频链接', icon: 'el-icon-video-camera-solid', roles: ['chef', 'cooker'] } }, { path: 'resource', name: '资源时间管理', component: () => import('@/views/canteen/resource/index'), - meta: { title: '资源时间管理', icon: 'el-icon-files' } + meta: { title: '资源时间管理', icon: 'el-icon-files', roles: ['chef', 'cooker'] } }, { path: 'pluginVersion', name: '插件更新', component: () => import('@/views/canteen/pluginVersion/index'), - meta: { title: '插件更新', icon: 'el-icon-top' } + meta: { title: '插件更新', icon: 'el-icon-top', roles: ['chef', 'cooker'] } }, { path: 'phoneVersion', name: '手机更新', component: () => import('@/views/canteen/phoneVersion/index'), - meta: { title: '手机更新', icon: 'el-icon-mobile-phone' } + meta: { title: '手机更新', icon: 'el-icon-mobile-phone', roles: ['chef', 'cooker'] } }, { path: 'desktopVersion', name: '桌面更新', component: () => import('@/views/canteen/desktopVersion/index'), - meta: { title: '桌面更新', icon: 'el-icon-s-platform' } + meta: { title: '桌面更新', icon: 'el-icon-s-platform', roles: ['chef', 'cooker'] } }, { path: 'toolLink', name: '工具链接', component: () => import('@/views/canteen/toolLink/index'), - meta: { title: '工具链接', icon: 'el-icon-s-platform' } + meta: { title: '工具链接', icon: 'el-icon-s-platform', roles: ['chef', 'cooker', 'porter'] } } ] }, diff --git a/src/views/canteen/toolLink/editToolLink.vue b/src/views/canteen/toolLink/editToolLink.vue index 3b99e33..c3951be 100644 --- a/src/views/canteen/toolLink/editToolLink.vue +++ b/src/views/canteen/toolLink/editToolLink.vue @@ -12,23 +12,146 @@ ref="toolLinkForm" :model="toolLinkData" label-position="right" label-width="120px" - :rules="toolLinkRules" > - - + + - + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + import UploadImg from "@/components/UploadImg/index.vue"; +import { REGION } from "@/const/toolLinkConfig"; export default { name: "EditToolLink", @@ -65,23 +189,40 @@ export default { create: false, showDraw: false, url: "api/v1/admin/toolLink/uploadAvatar", - toolLinkData: {}, + toolLinkData: this.initToolLinkData(), toolLinkRules: { - nickname: { + name: { required: true, message: "请输入名字", trigger: "blur" }, - avatar: { + upload: { required: true, message: "请上传图片", trigger: "change" }, - jump_url: { - required: false, message: "请输入链接", trigger: "blur" + description: { + required: true, message: "请输入描述", trigger: "blur" }, - } + slogan: { + required: true, message: "请输入Slogan", trigger: "blur" + }, + tags: { + required: true, message: "标签不能为空", trigger: ["blur", "change"] + }, + links: { + required: true, message: "链接列表不能为空", trigger: "blur" + }, + url: { + required: true, message: "请输入链接", trigger: "blur" + }, + select: { + required: true, message: "此选项不能为空", trigger: "blur" + }, + }, + defaultTags: [], + linkRegionality: REGION, }; }, computed:{ fileList(){ - return this.toolLinkData.avatar?[{ name: '', url: this.toolLinkData.avatar }] : []; + return this.toolLinkData.icon_url?[{ name: '', url: this.toolLinkData.icon_url }] : []; } }, mounted() { @@ -89,7 +230,6 @@ export default { }, methods: { init() { - this.initToolLinkData(); }, // 清除表单验证 clearValidate() { @@ -98,11 +238,36 @@ export default { }); }, initToolLinkData() { - this.toolLinkData = { - nickname: "", - avatar: "", - jump_url: null, - config: {} + return { + localized_name: { + zh_CN: "", + en_US: "" + }, + icon_url: null, + localized_description: { + zh_CN: "", + en_US: "" + }, + localized_slogan: { + zh_CN: "", + en_US: "" + }, + localized_tags: { + zh_CN: [], + en_US: [] + }, + links: [] + }; + }, + initLinks() { + return { + primary: false, + regionality: REGION[0], + localized_name: { + zh_CN: "", + en_US: "" + }, + url: '' }; }, // 打开抽屉 @@ -110,6 +275,8 @@ export default { this.create = create; if(data) { this.toolLinkData = JSON.parse(JSON.stringify(data)); + } else { + this.toolLinkData = this.initToolLinkData(); } this.showDraw = true; }, @@ -120,59 +287,85 @@ export default { }, // 图片成功 onSuccess(data) { - this.toolLinkData.avatar = data?.data?.url; + this.toolLinkData.icon_url = data?.data?.url; }, // 删除图片 onRemove() { this.toolLinkData.avatar = ''; }, createData() { - this.$store - .dispatch("toolLink/createToolLink",this.toolLinkData) - .then(() => { - this.$message({ - showClose: true, - message: "创建成功", - type: "success", - }); - this.showDraw = false; - this.init(); - }).catch(() =>{ - this.$message({ - showClose: true, - message: "创建失败", - type: "error", + let allPass = true; + this.$refs["toolLinkForm"].validate((valid) => { + if (!valid) { + allPass = false; + return; + } + }); + if (allPass) { + + this.$store + .dispatch("toolLink/createToolLink",this.toolLinkData) + .then(() => { + this.$message({ + showClose: true, + message: "创建成功", + type: "success", + }); + this.showDraw = false; + this.init(); + }).catch(() =>{ + this.$message({ + showClose: true, + message: "创建失败", + type: "error", + }); + }).finally(()=>{ + this.$emit("uploadDone"); }); - }).finally(()=>{ - this.$emit("uploadDone"); - }); + + } + }, updateData() { - this.$store - .dispatch("toolLink/updateToolLink",this.toolLinkData) - .then(() => { - this.$message({ - showClose: true, - message: "修改成功", - type: "success", - }); - this.showDraw = false; - this.init(); - }).catch(() =>{ - this.$message({ - showClose: true, - message: "修改失败", - type: "error", + let allPass = true; + this.$refs["toolLinkForm"].validate((valid) => { + if (!valid) { + allPass = false; + return; + } + }); + if (allPass) + this.$store + .dispatch("toolLink/updateToolLink",this.toolLinkData) + .then(() => { + this.$message({ + showClose: true, + message: "修改成功", + type: "success", + }); + this.showDraw = false; + this.init(); + }).catch(() =>{ + this.$message({ + showClose: true, + message: "修改失败", + type: "error", + }); + }).finally(()=>{ + this.$emit("uploadDone"); }); - }).finally(()=>{ - this.$emit("uploadDone"); - }); }, // 更改跳转链接空为null changeEmptyToNull() { if (this.toolLinkData.jump_url.trim() == '') { this.toolLinkData.jump_url = null; } + }, + addLink() { + this.toolLinkData.links.push(this.initLinks()); + }, + removeLink(index) { + this.toolLinkData.links.splice(index, 1); } } }; @@ -187,4 +380,30 @@ export default { .pl-24 { padding-left: 24px; } + +.add-icon { + cursor: pointer; + font-size: 18px; + + &:hover { + color: #FFBA4B; + } +} + +.collapse-header { + display: flex; + justify-content: space-between; + margin-right: 10px; + width: 100%; +} + +.btn-add { + color: white; + background-color: #67C23A; +} + +.btn-delete { + color: white; + background-color: #F56C6C; +} \ No newline at end of file diff --git a/src/views/canteen/toolLink/index.vue b/src/views/canteen/toolLink/index.vue index 7ac6374..c87f7cb 100644 --- a/src/views/canteen/toolLink/index.vue +++ b/src/views/canteen/toolLink/index.vue @@ -1,25 +1,6 @@