From 80cfa6dbaf7b6eb191b35bbb8c1ef248e358eb8c Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 21 Nov 2025 14:31:27 +0800 Subject: [PATCH 01/15] =?UTF-8?q?feat:=20base=20=E6=B7=BB=E5=8A=A0auth?= =?UTF-8?q?=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 4 +++ utils/auth.js | 73 +++++++++++++++++++++++++++++++++++++++++++++ utils/directives.js | 36 ++++++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 utils/auth.js create mode 100644 utils/directives.js diff --git a/main.js b/main.js index cd2b1c3..5467b27 100644 --- a/main.js +++ b/main.js @@ -25,9 +25,13 @@ import App from './App.vue' import api from './utils/api' import check from './utils/check' import config from './utils/config.js' +import { authDirective } from '@/utils/directives.js' export function createApp() { const app = createSSRApp(App) + + app.directive('auth', authDirective) + app.config.globalProperties.$api = api app.config.globalProperties.$check = check app.config.globalProperties.$config = config diff --git a/utils/auth.js b/utils/auth.js new file mode 100644 index 0000000..3465c7e --- /dev/null +++ b/utils/auth.js @@ -0,0 +1,73 @@ +/** + * 权限管理类 + */ +class AuthManager { + constructor() { + this.permissions = uni.getStorageSync('userPermissions') || [] + } + + /** + * 设置用户权限 + * @param {Array} permissions - 权限数组 + */ + setPermissions(permissions) { + this.permissions = permissions + uni.setStorageSync('userPermissions', permissions) + console.log('权限已设置:', permissions) + } + + /** + * 清除权限 + */ + clearPermissions() { + this.permissions = [] + uni.removeStorageSync('userPermissions') + } + + /** + * 检查权限 + * @param {string|Array} permission - 单个权限或权限数组 + * @returns {boolean} + */ + check(permission) { + if (!permission) return true + + // 如果是数组,检查是否有任一权限 + if (Array.isArray(permission)) { + return permission.some(p => this.hasPermission(p)) + } + + // 单个权限检查 + return this.hasPermission(permission) + } + + /** + * 检查所有权限 + * @param {Array} permissions - 权限数组 + * @returns {boolean} + */ + checkAll(permissions) { + if (!Array.isArray(permissions)) return false + return permissions.every(p => this.hasPermission(p)) + } + + /** + * 内部权限检查方法 + * @param {string} permission + * @returns {boolean} + */ + hasPermission(permission) { + return this.permissions.includes(permission) + } + + /** + * 获取当前权限列表 + * @returns {Array} + */ + getPermissions() { + return [...this.permissions] + } +} + +// 创建单例实例 +export const auth = new AuthManager() \ No newline at end of file diff --git a/utils/directives.js b/utils/directives.js new file mode 100644 index 0000000..97acb97 --- /dev/null +++ b/utils/directives.js @@ -0,0 +1,36 @@ +import { auth } from '@/utils/auth.js' + +/** + * 权限指令 + * 使用方式: + * v-auth="'user:add'" // 单个权限 + * v-auth="['user:add', 'user:edit']" // 多个权限(满足其一即可) + */ +export const authDirective = { + mounted(el, binding) { + checkAuth(el, binding) + }, + updated(el, binding) { + checkAuth(el, binding) + } +} + +/** + * 权限检查逻辑 + */ +function checkAuth(el, binding) { + const hasAuth = auth.check(binding.value) + + if (!hasAuth) { + // 没有权限时隐藏元素 + el.style.display = 'none' + + // 或者完全移除元素(根据需求选择) + // if (el.parentNode) { + // el.parentNode.removeChild(el) + // } + } else { + // 有权限时确保显示 + el.style.display = '' + } +} \ No newline at end of file From ff7d51a463ae4870ee7f57c2e01bb51514e05755 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 21 Nov 2025 14:31:59 +0800 Subject: [PATCH 02/15] =?UTF-8?q?feat:=20=E9=A6=96=E9=A1=B5=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E6=A8=A1=E5=9D=97=E9=80=9A=E8=BF=87=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.json | 2 +- pages.json | 10 +- pages/auth/login.vue | 5 + pages/index/index.vue | 135 ++++++------------ pages/ofm/{booking.vue => mroombooking.vue} | 0 ...booking_form.vue => mroombooking_form.vue} | 0 .../{publicityForm.vue => publicity_form.vue} | 0 pages/ofm/{sealForm.vue => seal_form.vue} | 0 .../ofm/{vehicleForm.vue => vehicle_form.vue} | 0 utils/api.js | 1 + 10 files changed, 52 insertions(+), 101 deletions(-) rename pages/ofm/{booking.vue => mroombooking.vue} (100%) rename pages/ofm/{booking_form.vue => mroombooking_form.vue} (100%) rename pages/ofm/{publicityForm.vue => publicity_form.vue} (100%) rename pages/ofm/{sealForm.vue => seal_form.vue} (100%) rename pages/ofm/{vehicleForm.vue => vehicle_form.vue} (100%) diff --git a/manifest.json b/manifest.json index 85daf63..d3a2f0b 100644 --- a/manifest.json +++ b/manifest.json @@ -95,7 +95,7 @@ "vueVersion" : "3", "h5" : { "router" : { - "base" : "/h5/", + "base" : "/h5x/", "mode" : "hash" }, "devServer" : { diff --git a/pages.json b/pages.json index 3cc717f..481efec 100644 --- a/pages.json +++ b/pages.json @@ -27,21 +27,21 @@ } }, { - "path" : "pages/ofm/booking_form", + "path" : "pages/ofm/mroombooking_form", "style" : { "navigationBarTitleText" : "会议室预约" } }, { - "path" : "pages/ofm/sealForm", + "path" : "pages/ofm/seal_form", "style" : { "navigationBarTitleText" : "印章申请" } }, { - "path" : "pages/ofm/vehicleForm", + "path" : "pages/ofm/vehicle_form", "style" : { "navigationBarTitleText" : "用车申请" @@ -55,7 +55,7 @@ } }, { - "path" : "pages/ofm/publicityForm", + "path" : "pages/ofm/publicity_form", "style" : { "navigationBarTitleText" : "宣传报道" @@ -111,7 +111,7 @@ } }, { - "path" : "pages/ofm/booking", + "path" : "pages/ofm/mroombooking", "style" : { "navigationBarTitleText" : "预约记录", diff --git a/pages/auth/login.vue b/pages/auth/login.vue index 9b6f4e6..eccef4a 100644 --- a/pages/auth/login.vue +++ b/pages/auth/login.vue @@ -48,6 +48,7 @@ diff --git a/pages/ofm/booking.vue b/pages/ofm/mroombooking.vue similarity index 100% rename from pages/ofm/booking.vue rename to pages/ofm/mroombooking.vue diff --git a/pages/ofm/booking_form.vue b/pages/ofm/mroombooking_form.vue similarity index 100% rename from pages/ofm/booking_form.vue rename to pages/ofm/mroombooking_form.vue diff --git a/pages/ofm/publicityForm.vue b/pages/ofm/publicity_form.vue similarity index 100% rename from pages/ofm/publicityForm.vue rename to pages/ofm/publicity_form.vue diff --git a/pages/ofm/sealForm.vue b/pages/ofm/seal_form.vue similarity index 100% rename from pages/ofm/sealForm.vue rename to pages/ofm/seal_form.vue diff --git a/pages/ofm/vehicleForm.vue b/pages/ofm/vehicle_form.vue similarity index 100% rename from pages/ofm/vehicleForm.vue rename to pages/ofm/vehicle_form.vue diff --git a/utils/api.js b/utils/api.js index 35aef0c..8055946 100644 --- a/utils/api.js +++ b/utils/api.js @@ -16,6 +16,7 @@ export default { employeeList:(data) => http('/hrm/employee/', 'GET', data), + getWorkflow: (data) => http('/wf/workflow/', 'GET', data), getTicket:(data) => http('/wf/ticket/', 'GET', data), getTicketItem:(id) => http(`/wf/ticket/${id}/`, 'GET'), getTicketFlowLogs:(id) => http(`/wf/ticket/${id}/flowlogs/`, 'GET'), From 88688d0bb31ad7354e8d2c1eb31fac7b8af47c0c Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 21 Nov 2025 14:40:56 +0800 Subject: [PATCH 03/15] =?UTF-8?q?feat:=20=E6=96=87=E4=BB=B6=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E5=9C=B0=E5=9D=80=E4=BB=8Econfig=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/ofm/seal_form.vue | 3 ++- pages/srm/paperse_form.vue | 3 ++- pages/srm/patent_form.vue | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pages/ofm/seal_form.vue b/pages/ofm/seal_form.vue index 8bfd311..17bbdc1 100644 --- a/pages/ofm/seal_form.vue +++ b/pages/ofm/seal_form.vue @@ -43,6 +43,7 @@ diff --git a/pages/pum/supplieraudit_form.vue b/pages/pum/supplieraudit_form.vue index 294d4a1..8025740 100644 --- a/pages/pum/supplieraudit_form.vue +++ b/pages/pum/supplieraudit_form.vue @@ -14,7 +14,7 @@ - + @@ -25,8 +25,14 @@ - + + + @@ -39,6 +45,7 @@ import {actStateEnum} from "@/utils/enum.js" components: { ticketd_b, ticketd }, data(){ return{ + saveLoading: false, mode:"add", t_id: null, form:{ @@ -71,42 +78,28 @@ import {actStateEnum} from "@/utils/enum.js" that.t_id = options.t_id?options.t_id:null; if(that.mode != "add"){ if(that.t_id) { - that.form = await that.$api.pfItem(that.t_id); + that.form = await that.$api.supplierauditItem(that.t_id); if(that.form.ticket_.state_.type == 1 && that.form.create_by == uni.getStorageSync("userInfo").id ) { that.mode = "edit"; }else{ that.mode = "show"; } } - }else{ - that.getEmployee(); } }, methods:{ - async getEmployee(){ - let that = this; - let obj = {search:that.form.employee_name,page:0,query:'{name,id}'} - let res = await that.$api.employeeList(obj); - that.form.employee = res[0].id; - }, - uploadSuccess(type){ - console.log('type', type); + uploadSuccess(type, e){ + console.log('type', type, e); console.log('form.material_type',this.form.material_type) }, - async submit_b_func(id){ + async handleSave(id){ let that = this; that.$refs.customForm.validate().then(res => { }).catch(err => { console.log('err', err); }) - let res = await that.$api.pfCreate(that.form) - that.form.id = res.id; - }, - submitSuccess(){ - uni.navigateTo({ - url: "/pages/index/index" - }) + let res = await that.$api.supplierauditCreate(that.form) }, } } diff --git a/utils/api.js b/utils/api.js index 0518389..8d000bd 100644 --- a/utils/api.js +++ b/utils/api.js @@ -77,5 +77,7 @@ export default { resignationCreate:(data) => http(`/hrm/resignation/`, 'POST' , data), resignationItem:(id,data) => http(`/hrm/resignation/${id}/`, 'GET', data), resignationDelete:(id) => http(`/hrm/resignation/${id}/`, 'DELETE'), - + //供应商审核 + supplierauditCreate:(data) => http(`/pum/supplieraudit/`, 'POST' , data), + supplierauditItem:(id,data) => http(`/pum/supplieraudit/${id}/`, 'GET', data), } \ No newline at end of file