Pārlūkot izejas kodu

✨ feat: 关闭自动化规则的部分新建模板; 角色管理添加;

WanGxC 1 gadu atpakaļ
vecāks
revīzija
d04a262488

+ 3 - 1
src/utils/columnPermission.ts

@@ -4,6 +4,8 @@ type permissionType = 'is_create' | 'is_query' | 'is_update';
 
 export const columnPermission = (key: string, type: permissionType): boolean => {
 	const permissions = useColumnPermission().permission || [];
-
+	// console.log("查看当前权限列表", permissions);  // 查看当前权限列表
+	const result = !!permissions.some((i) => i.field_name === key && i[type]);
+	// console.log(key, type, result); // 查看传入的字段名、权限类型和计算结果
 	return !!permissions.some((i) => i.field_name === key && i[type]);
 };

+ 27 - 27
src/views/adManage/sp/campaigns/campaignDetail/automation/index.vue

@@ -27,33 +27,33 @@
       </template>
       <SwitchCampaign :data="baseData" :RuleStatusButton="RuleStatusButton" @refresh="refresh(3)" v-if="activeTab === 3" />
     </el-tab-pane>
-    <el-tab-pane label="定向规则" :name="4">
-      <template #label>
-        <div class="tab-label">
-          <el-switch size="small" v-model="RuleStatusButton['4']" :disabled="RuleStatusButton['4'] === '-'"></el-switch>
-          <span>定向规则</span>
-        </div>
-      </template>
-      <TargetRule :data="baseData" :RuleStatusButton="RuleStatusButton" @refresh="refresh(4)" v-if="activeTab === 4"></TargetRule>
-    </el-tab-pane>
-    <el-tab-pane label="添加搜索词" :name="5">
-      <template #label>
-        <div class="tab-label">
-          <el-switch size="small" v-model="RuleStatusButton['5']" :disabled="RuleStatusButton['5'] === '-'"></el-switch>
-          <span>添加搜索词</span>
-        </div>
-      </template>
-      <SearchTermRule :data="baseData" :RuleStatusButton="RuleStatusButton" @refresh="refresh(5)" v-if="activeTab === 5"></SearchTermRule>
-    </el-tab-pane>
-    <el-tab-pane label="添加否定词" :name="6">
-      <template #label>
-        <div class="tab-label">
-          <el-switch size="small" v-model="RuleStatusButton['6']" :disabled="RuleStatusButton['6'] === '-'"></el-switch>
-          <span>添加否定词</span>
-        </div>
-      </template>
-      <NegKeywordRule :data="baseData" :RuleStatusButton="RuleStatusButton" @refresh="refresh(6)" v-if="activeTab === 6"></NegKeywordRule>
-    </el-tab-pane>
+    <!--<el-tab-pane label="定向规则" :name="4">-->
+    <!--  <template #label>-->
+    <!--    <div class="tab-label">-->
+    <!--      <el-switch size="small" v-model="RuleStatusButton['4']" :disabled="RuleStatusButton['4'] === '-'"></el-switch>-->
+    <!--      <span>定向规则</span>-->
+    <!--    </div>-->
+    <!--  </template>-->
+    <!--  <TargetRule :data="baseData" :RuleStatusButton="RuleStatusButton" @refresh="refresh(4)" v-if="activeTab === 4"></TargetRule>-->
+    <!--</el-tab-pane>-->
+    <!--<el-tab-pane label="添加搜索词" :name="5">-->
+    <!--  <template #label>-->
+    <!--    <div class="tab-label">-->
+    <!--      <el-switch size="small" v-model="RuleStatusButton['5']" :disabled="RuleStatusButton['5'] === '-'"></el-switch>-->
+    <!--      <span>添加搜索词</span>-->
+    <!--    </div>-->
+    <!--  </template>-->
+    <!--  <SearchTermRule :data="baseData" :RuleStatusButton="RuleStatusButton" @refresh="refresh(5)" v-if="activeTab === 5"></SearchTermRule>-->
+    <!--</el-tab-pane>-->
+    <!--<el-tab-pane label="添加否定词" :name="6">-->
+    <!--  <template #label>-->
+    <!--    <div class="tab-label">-->
+    <!--      <el-switch size="small" v-model="RuleStatusButton['6']" :disabled="RuleStatusButton['6'] === '-'"></el-switch>-->
+    <!--      <span>添加否定词</span>-->
+    <!--    </div>-->
+    <!--  </template>-->
+    <!--  <NegKeywordRule :data="baseData" :RuleStatusButton="RuleStatusButton" @refresh="refresh(6)" v-if="activeTab === 6"></NegKeywordRule>-->
+    <!--</el-tab-pane>-->
   </el-tabs>
 </template>
 

+ 1 - 1
src/views/demo/index.vue

@@ -41,7 +41,7 @@ async function handleWeComLogin(query) {
 
 <template>
   <div>
-    <!--<el-button type="primary" @click="createWXQRCode" class="m-2.5">发送</el-button>-->
+    <el-button type="primary" @click="createWXQRCode" class="m-2.5">发送</el-button>
   </div>
   <div id="wx_qrcode" style="height: 300px; width: 300px"></div>
 </template>

+ 3 - 3
src/views/efTools/utils/enum.ts

@@ -2,7 +2,7 @@ export const TemplateType = [
   { label: '分时调价', value: 1 },
   { label: '分时预算', value: 2 },
   { label: '广告活动', value: 3 },
-  { label: '定向规则', value: 4 },
-  { label: '添加搜索词', value: 5 },
-  { label: '添加否定词', value: 6 },
+//   { label: '定向规则', value: 4 },
+//   { label: '添加搜索词', value: 5 },
+//   { label: '添加否定词', value: 6 },
 ]

+ 10 - 7
src/views/productCenter/productList/components/DataTable.vue

@@ -92,12 +92,12 @@ async function fetchTableData(type) {
     searchItem: searchItem.value,
   }
 
-  // 要用引号扩住key '产品线'
+  // 要用引号扩住key '产品线', 不扩也行 会自动转义
   const typeToApiAndColumns = {
-    产品线: { api: getTableDataForProductLine, columns: productLineColumns },
-    父ASIN: { api: getTableDataForParentASIN, columns: parentAsinColumns },
-    ASIN: { api: getTableDataForASIN, columns: asinColumns },
-    SKU: { api: getTableDataForSKU, columns: skuColumns },
+    '产品线': { api: getTableDataForProductLine, columns: productLineColumns },
+    '父ASIN': { api: getTableDataForParentASIN, columns: parentAsinColumns },
+    'ASIN': { api: getTableDataForASIN, columns: asinColumns },
+    'SKU': { api: getTableDataForSKU, columns: skuColumns },
   }
   // 根据类型获取对应的API函数和列配置
   const { api: apiFunction, columns } = typeToApiAndColumns[type] || {}
@@ -105,6 +105,7 @@ async function fetchTableData(type) {
   // 确保apiFunction和columns都存在,否则直接返回
   if (!apiFunction || !columns) return
 
+  // 若返回的数据没有对应的 列字段, 则会进入catch导致页面不更新
   try {
     const response = await apiFunction(query)
     Object.keys(summaryFormats).forEach((field) => {
@@ -121,16 +122,18 @@ async function fetchTableData(type) {
   }
 }
 
+// 监听tablePage变化,重新获取数据
 function handlePageChange({ currentPage, pageSize }) {
   tablePage.currentPage = currentPage
   tablePage.pageSize = pageSize
   fetchTableData(activeButton.value)
 }
 
-watch([activeButton, productlineId, dateRange, searchItem], () => {
+// 监听activeButton, productlineId, dateRange, searchItem变化,重新获取数据
+watch([activeButton, productlineId, dateRange, searchItem], async () => {
   tablePage.currentPage = 1
   isCompare.value = true
-  fetchTableData(activeButton.value)
+  await fetchTableData(activeButton.value)
 })
 </script>
 

+ 297 - 287
src/views/system/role/crud.tsx

@@ -1,297 +1,307 @@
-import { CrudOptions, AddReq, DelReq, EditReq, dict, CrudExpose, compute } from '@fast-crud/fast-crud';
-import * as api from './api';
-import { dictionary } from '/@/utils/dictionary';
-import { columnPermission } from '../../../utils/columnPermission';
-import { successMessage } from '../../../utils/message';
+import { CrudOptions, AddReq, DelReq, EditReq, dict, CrudExpose, compute } from '@fast-crud/fast-crud'
+import * as api from './api'
+import { dictionary } from '/@/utils/dictionary'
+import { columnPermission } from '../../../utils/columnPermission'
+import { successMessage } from '../../../utils/message'
 
 interface CreateCrudOptionsTypes {
-	output: any;
-	crudOptions: CrudOptions;
+  output: any
+  crudOptions: CrudOptions
 }
 
 //此处为crudOptions配置
 export const createCrudOptions = function ({
-	crudExpose,
-	rolePermission,
-	handleDrawerOpen,
-	hasPermissions,
+  crudExpose,
+  rolePermission,
+  handleDrawerOpen,
+  hasPermissions,
 }: {
-	crudExpose: CrudExpose;
-	rolePermission: any;
-	handleDrawerOpen: Function;
-	hasPermissions: Function;
+  crudExpose: CrudExpose
+  rolePermission: any
+  handleDrawerOpen: Function
+  hasPermissions: Function
 }): CreateCrudOptionsTypes {
-	const pageRequest = async (query: any) => {
-		return await api.GetList(query);
-	};
-	const editRequest = async ({ form, row }: EditReq) => {
-		form.id = row.id;
-		return await api.UpdateObj(form);
-	};
-	const delRequest = async ({ row }: DelReq) => {
-		return await api.DelObj(row.id);
-	};
-	const addRequest = async ({ form }: AddReq) => {
-		return await api.AddObj(form);
-	};
+  const pageRequest = async (query: any) => {
+    return await api.GetList(query)
+  }
+  const editRequest = async ({ form, row }: EditReq) => {
+    form.id = row.id
+    return await api.UpdateObj(form)
+  }
+  const delRequest = async ({ row }: DelReq) => {
+    return await api.DelObj(row.id)
+  }
+  const addRequest = async ({ form }: AddReq) => {
+    return await api.AddObj(form)
+  }
 
-	//权限判定
+  //权限判定
 
-	// @ts-ignore
-	// @ts-ignore
-	return {
-		crudOptions: {
-			request: {
-				pageRequest,
-				addRequest,
-				editRequest,
-				delRequest,
-			},
-			rowHandle: {
-				//固定右侧
-				fixed: 'right',
-				width: 320,
-				buttons: {
-					view: {
-						show: true,
-					},
-					edit: {
-						show: hasPermissions('role:Update'),
-					},
-					remove: {
-						show: hasPermissions('role:Delete'),
-					},
-					/* custom: {
-						type: 'primary',
-						text: '权限配置',
-						show: hasPermissions('role:Update'),
-						tooltip: {
-							placement: 'top',
-							content: '权限配置',
-						},
-						click: (context: any): void => {
-							const { row } = context;
-							// eslint-disable-next-line no-mixed-spaces-and-tabs
-							rolePermission.value.drawer = true;
-							rolePermission.value.editedRoleInfo = row;
-							rolePermission.value.initGet();
-						},
-					}, */
-					customNew: {
-						type: 'primary',
-						text: '权限配置',
-						show: hasPermissions('role:Update'),
-						tooltip: {
-							placement: 'top',
-							content: '权限配置',
-						},
-						click: (context: any): void => {
-							const { row } = context;
-							handleDrawerOpen(row);
-						},
-					},
-				},
-			},
-			form: {
-				col: { span: 24 },
-				labelWidth: '100px',
-				wrapper: {
-					is: 'el-dialog',
-					width: '600px',
-				},
-			},
-			columns: {
-				_index: {
-					title: '序号',
-					form: { show: false },
-					column: {
-						type: 'index',
-						align: 'center',
-						width: '70px',
-						columnSetDisabled: true, //禁止在列设置中选择
-					},
-				},
-				id: {
-					title: 'ID',
-					type: 'text',
-					column: { show: false },
-					search: { show: false },
-					form: { show: false },
-				},
-				name: {
-					title: '角色名称',
-					type: 'text',
-					search: { show: true },
-					column: {
-						minWidth: 120,
-						sortable: 'custom',
-						show: columnPermission('name', 'is_query'),
-					},
-					addForm: {
-						show: columnPermission('name', 'is_create'),
-					},
-					editForm: {
-						show: columnPermission('name', 'is_update'),
-					},
-					form: {
-						rules: [{ required: true, message: '角色名称必填' }],
-						component: {
-							placeholder: '请输入角色名称',
-						},
-					},
-				},
-				key: {
-					title: '权限标识',
-					type: 'text',
-					search: { show: false },
-					column: {
-						minWidth: 120,
-						sortable: 'custom',
-						show: columnPermission('key', 'is_query'),
-						columnSetDisabled: true,
-					},
-					addForm: {
-						show: columnPermission('key', 'is_create'),
-					},
-					editForm: {
-						show: columnPermission('key', 'is_update'),
-					},
-					form: {
-						rules: [{ required: true, message: '权限标识必填' }],
-						component: {
-							placeholder: '输入权限标识',
-						},
-					},
-				},
-				sort: {
-					title: '排序',
-					search: { show: false },
-					type: 'number',
-					column: {
-						minWidth: 90,
-						sortable: 'custom',
-						show: columnPermission('sort', 'is_query'),
-					},
-					addForm: {
-						show: columnPermission('sort', 'is_create'),
-					},
-					editForm: {
-						show: columnPermission('sort', 'is_update'),
-					},
-					form: {
-						rules: [{ required: true, message: '排序必填' }],
-						value: 1,
-					},
-				},
-				admin: {
-					title: '是否管理员',
-					search: { show: false },
-					type: 'dict-radio',
-					dict: dict({
-						data: [
-							{
-								label: '是',
-								value: true,
-								color: 'success',
-							},
-							{
-								label: '否',
-								value: false,
-								color: 'danger',
-							},
-						],
-					}),
-					column: {
-						minWidth: 130,
-						sortable: 'custom',
-						show: columnPermission('admin', 'is_query'),
-					},
-					addForm: {
-						show: columnPermission('admin', 'is_create'),
-					},
-					editForm: {
-						show: columnPermission('admin', 'is_update'),
-					},
-					form: {
-						rules: [{ required: true, message: '是否管理员必填' }],
-						value: false,
-					},
-				},
-				status: {
-					title: '状态',
-					search: { show: true },
-					type: 'dict-radio',
-					column: {
-						width: 100,
-						component: {
-							name: 'fs-dict-switch',
-							activeText: '',
-							inactiveText: '',
-							style: '--el-switch-on-color: var(--el-color-primary); --el-switch-off-color: #dcdfe6',
-							onChange: compute((context) => {
-								return () => {
-									api.UpdateObj(context.row).then((res: APIResponseData) => {
-										successMessage(res.msg as string);
-									});
-								};
-							}),
-						},
-						show: columnPermission('status', 'is_query'),
-					},
-					addForm: {
-						show: columnPermission('status', 'is_create'),
-					},
-					editForm: {
-						show: columnPermission('status', 'is_update'),
-					},
-					dict: dict({
-						data: dictionary('button_status_bool'),
-					}),
-				},
-				update_datetime: {
-					title: '更新时间',
-					type: 'text',
-					search: { show: false },
-					column: {
-						minWidth: 170,
-						sortable: 'custom',
-						show: columnPermission('update_datetime', 'is_query'),
-					},
-					form: {
-						show: false,
-						component: {
-							placeholder: '输入关键词搜索',
-						},
-					},
-				},
-				create_datetime: {
-					title: '创建时间',
-					type: 'text',
-					search: { show: false },
-					column: {
-						sortable: 'custom',
-						minWidth: 170,
-						show: columnPermission('create_datetime', 'is_query'),
-					},
-					form: {
-						show: false,
-						component: {
-							placeholder: '输入关键词搜索',
-						},
-					},
-				},
-				// description: {
-				//     title: '备注',
-				//     type: 'textarea',
-				//     search: {show: false},
-				//     form: {
-				//         component: {
-				//             maxlength: 200,
-				//             placeholder: '输入备注',
-				//         },
-				//     },
-				// },
-			},
-		},
-	};
-};
+  // @ts-ignore
+  // @ts-ignore
+  return {
+    crudOptions: {
+      request: {
+        pageRequest,
+        addRequest,
+        editRequest,
+        delRequest,
+      },
+      rowHandle: {
+        //固定右侧
+        fixed: 'right',
+        width: 320,
+        buttons: {
+          view: {
+            show: true,
+          },
+          edit: {
+            show: hasPermissions('role:Update'),
+          },
+          remove: {
+            show: hasPermissions('role:Delete'),
+          },
+          /* custom: {
+            type: 'primary',
+            text: '权限配置',
+            show: hasPermissions('role:Update'),
+            tooltip: {
+              placement: 'top',
+              content: '权限配置',
+            },
+            click: (context: any): void => {
+              const { row } = context;
+              // eslint-disable-next-line no-mixed-spaces-and-tabs
+              rolePermission.value.drawer = true;
+              rolePermission.value.editedRoleInfo = row;
+              rolePermission.value.initGet();
+            },
+          }, */
+          customNew: {
+            type: 'primary',
+            text: '权限配置',
+            show: hasPermissions('role:Update'),
+            tooltip: {
+              placement: 'top',
+              content: '权限配置',
+            },
+            click: (context: any): void => {
+              const { row } = context
+              handleDrawerOpen(row)
+            },
+          },
+        },
+      },
+      form: {
+        col: { span: 24 },
+        labelWidth: '100px',
+        wrapper: {
+          is: 'el-dialog',
+          width: '600px',
+        },
+      },
+      columns: {
+        _index: {
+          title: '序号',
+          form: { show: false },
+          column: {
+            type: 'index',
+            align: 'center',
+            width: '70px',
+            columnSetDisabled: true, //禁止在列设置中选择
+          },
+        },
+        id: {
+          title: 'ID',
+          type: 'text',
+          column: { show: false },
+          search: { show: false },
+          form: { show: true },
+        },
+        name: {
+          title: '角色名称',
+          type: 'text',
+          search: { show: true },
+          column: {
+            minWidth: 120,
+            sortable: 'custom',
+            show: columnPermission('name', 'is_query'),
+          },
+          // addForm: {
+          //   show: columnPermission('name', 'is_create'),
+          // },
+          // editForm: {
+          //   show: columnPermission('name', 'is_update'),
+          // },
+          //  TODO: addForm 和 editForm 会合并到form中 但是columnPermission得到的永远都是false
+          form: {
+            show: true,
+            rules: [{ required: true, message: '角色名称必填' }],
+            component: {
+              placeholder: '请输入角色名称',
+            },
+          },
+        },
+        key: {
+          title: '权限标识',
+          type: 'text',
+          search: { show: false },
+          column: {
+            minWidth: 120,
+            sortable: 'custom',
+            show: columnPermission('key', 'is_query'),
+            columnSetDisabled: true,
+          },
+          // addForm: {
+          //   show: columnPermission('key', 'is_create'),
+          // },
+          // editForm: {
+          //   show: columnPermission('key', 'is_update'),
+          // },
+          form: {
+            show: true,
+            rules: [{ required: true, message: '权限标识必填' }],
+            component: {
+              placeholder: '输入权限标识',
+            },
+          },
+        },
+        sort: {
+          title: '排序',
+          search: { show: false },
+          type: 'number',
+          column: {
+            minWidth: 90,
+            sortable: 'custom',
+            show: columnPermission('sort', 'is_query'),
+          },
+          // addForm: {
+          //   show: columnPermission('sort', 'is_create'),
+          // },
+          // editForm: {
+          //   show: columnPermission('sort', 'is_update'),
+          // },
+          form: {
+            show: true,
+            rules: [{ required: true, message: '排序必填' }],
+            value: 1,
+          },
+        },
+        admin: {
+          title: '是否管理员',
+          search: { show: false },
+          type: 'dict-radio',
+          dict: dict({
+            data: [
+              {
+                label: '是',
+                value: true,
+                color: 'success',
+              },
+              {
+                label: '否',
+                value: false,
+                color: 'danger',
+              },
+            ],
+          }),
+          column: {
+            minWidth: 130,
+            sortable: 'custom',
+            show: columnPermission('admin', 'is_query'),
+          },
+          addForm: {
+            show: columnPermission('admin', 'is_create'),
+          },
+          editForm: {
+            show: columnPermission('admin', 'is_update'),
+          },
+          form: {
+            rules: [{ required: true, message: '是否管理员必填' }],
+            value: false,
+          },
+        },
+        status: {
+          title: '状态',
+          search: { show: true },
+          type: 'dict-radio',
+          column: {
+            width: 100,
+            component: {
+              name: 'fs-dict-switch',
+              activeText: '',
+              inactiveText: '',
+              style: '--el-switch-on-color: var(--el-color-primary); --el-switch-off-color: #dcdfe6',
+              onChange: compute((context) => {
+                return () => {
+                  api.UpdateObj(context.row).then((res: APIResponseData) => {
+                    successMessage(res.msg as string)
+                  })
+                }
+              }),
+            },
+            show: columnPermission('status', 'is_query'),
+          },
+          // addForm: {
+          //   show: columnPermission('status', 'is_create'),
+          // },
+          // editForm: {
+          //   show: columnPermission('status', 'is_update'),
+          // },
+          form: {
+            show: true,
+            // component: {
+            //   placeholder: '输入关键词搜索',
+            // },
+          },
+          dict: dict({
+            data: dictionary('button_status_bool'),
+          }),
+        },
+        update_datetime: {
+          title: '更新时间',
+          type: 'text',
+          search: { show: false },
+          column: {
+            minWidth: 170,
+            sortable: 'custom',
+            show: columnPermission('update_datetime', 'is_query'),
+          },
+          form: {
+            show: false,
+            component: {
+              placeholder: '输入关键词搜索',
+            },
+          },
+        },
+        create_datetime: {
+          title: '创建时间',
+          type: 'text',
+          search: { show: false },
+          column: {
+            sortable: 'custom',
+            minWidth: 170,
+            show: columnPermission('create_datetime', 'is_query'),
+          },
+          form: {
+            show: false,
+            component: {
+              placeholder: '输入关键词搜索',
+            },
+          },
+        },
+        // description: {
+        //     title: '备注',
+        //     type: 'textarea',
+        //     search: {show: false},
+        //     form: {
+        //         component: {
+        //             maxlength: 200,
+        //             placeholder: '输入备注',
+        //         },
+        //     },
+        // },
+      },
+    },
+  }
+}