瀏覽代碼

销毁codes

aexiaoliou 1 年之前
父節點
當前提交
2d8dbd1bd5
共有 3 個文件被更改,包括 25 次插入9 次删除
  1. 2 0
      h5/src/api/role/index.ts
  2. 2 1
      h5/src/components/role/codes.vue
  3. 21 8
      h5/src/views/admin/role/index.vue

+ 2 - 0
h5/src/api/role/index.ts

@@ -84,7 +84,9 @@ export const create = async (param: any) => {
  * @returns 更新后对象
  */
 export const update = async (param: any) => {
+    console.log("🚀 ~ file: index.ts:89 ~ update ~ role:", role)
     const res = await Http.post(role.update, param)
+    console.log("🚀 ~ file: index.ts:90 ~ update ~ role:", role)
     return res
 }
 /**

+ 2 - 1
h5/src/components/role/codes.vue

@@ -24,6 +24,7 @@ const { modelValue, role } = defineProps<{
     modelValue: boolean,
     role: Role
 }>()
+console.log(role)
 const emit = defineEmits(['update:modelValue'])
 
 const codes = ref()
@@ -54,7 +55,7 @@ const submitForm = throttle(async () => {
     submitLoading.value = true
     const result = await update(role)
     if (result.code != 0) {
-        return
+        return  
     }
     submitLoading.value = false
     ElMessage({ message: '更新成功' })

+ 21 - 8
h5/src/views/admin/role/index.vue

@@ -1,5 +1,5 @@
 <template>
-    <Codes v-model="isShowCodesEditForm" :role="editRole" />
+    <Codes v-if="isShowCodesEditForm" v-model="isShowCodesEditForm" :role="editRole" />
     <Edit v-model="isShowRoleEditForm" :role="editRole" :type="editType" />
     <div>
         <el-card class="box-card" v-loading="wholeLoading" element-loading-text="Loading..." style="height: 600px">
@@ -72,7 +72,7 @@ const columns: Column<any>[] = [
         dataKey: 'codes_cn',
         width: 400,
         cellRenderer: ({ cellData: codes_cn }) =>
-            <div style="overflow-y: auto; display: flex">
+            <div style="overflow-y: auto; display: flex" onWheel={handleWheel}>
                 {codes_cn?.map(cn => <ElTag style="margin-right: 5px">{cn}</ElTag>)}
             </div>
     },
@@ -98,15 +98,15 @@ const columns: Column<any>[] = [
         width: 400,
         fixed: TableV2FixedDir.RIGHT,
         flexGrow: 1,
-        cellRenderer: ({ rowData: row }) =>
+        cellRenderer: (props) =>
             <div>
-                <ElButton type={row.valid ? 'danger' : 'success'} onClick={() => updateValid(row)}>
-                    {row.valid ? '禁用' : '启用'}
+                <ElButton type={props.rowData.valid ? 'danger' : 'success'} onClick={() => updateValid(props.rowData)}>
+                    {props.rowData.valid ? '禁用' : '启用'}
                 </ElButton>
-                <ElButton type="primary" onClick={() => showPermissionDialog(row)}>
+                <ElButton type="primary" onClick={() => showPermissionDialog(props.rowData)}>
                     权限
                 </ElButton>
-                <ElButton type="primary" onClick={() => showEditDialog('update', row)}>
+                <ElButton type="primary" onClick={() => showEditDialog('update', props.rowData)}>
                     编辑
                 </ElButton>
             </div>
@@ -130,7 +130,20 @@ const updateValid = throttle((row: any) => {
     update(row)
 })
 
-
+/**
+ * 把tag中的鼠标事件改为横向滚动
+ * @param event 
+ */
+const handleWheel = (event) => {
+    // 判断滚轮事件是否是横向滚动
+    if (!event.shiftKey) {
+        // 取消默认的纵向滚动
+        event.preventDefault()
+        // 根据滚动方向进行横向滚动
+        const container = event.currentTarget
+        container.scrollLeft += event.deltaY
+    }
+}
 
 /**
  * 刷新