Explorar o código

修改添加更新职位状态

yangg hai 3 meses
pai
achega
96cdbe300b

+ 29 - 0
src/views/JobApplication/list/api.ts

@@ -45,3 +45,32 @@ export function GetPermission() {
         method: 'get',
     });
 }
+
+export function BulkUpdateStatus(data: {
+	application_ids: number[];
+	new_status: number;
+	note?: string;
+	tenant_id: string;
+}) {
+	return request({
+		url: '/api/system/job_applications/bulk_update_status/',
+		method: 'post',
+		data
+	});
+}
+
+export function updateBatchStatus(data: any) {
+	return request({
+		url: '/api/system/job_applications/bulk_update_status/',
+		method: 'post',
+		data
+	});
+}
+
+/* export function updateBatchTags(data) {
+	return request({
+		url: '/job-application/batch-update-tags',
+		method: 'post',
+		data
+	});
+} */

+ 153 - 0
src/views/JobApplication/list/components/index.vue

@@ -0,0 +1,153 @@
+<template>
+  <el-dialog
+    v-model="dialogVisible"
+    title="批量操作"
+    width="500px"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+  >
+    <el-form :model="form" label-width="100px">
+     <!--  <el-form-item label="操作类型">
+        <el-select v-model="form.operationType" placeholder="请选择操作类型" style="width: 100%">
+          <el-option label="修改状态" value="status"></el-option>
+          <el-option label="添加标签" value="tags"></el-option>
+        </el-select>
+      </el-form-item> -->
+
+      <el-form-item v-if="form.operationType === 'status'" label="状态">
+        <el-select v-model="form.status" placeholder="请选择状态" style="width: 100%">
+          <el-option label="待处理" :value="0"></el-option>
+          <el-option label="已通知面试" :value="1"></el-option>
+          <el-option label="已面试" :value="2"></el-option>
+          <el-option label="已录用" :value="3"></el-option>
+          <el-option label="已拒绝" :value="4"></el-option>
+        </el-select>
+      </el-form-item>
+
+      <el-form-item v-if="form.operationType === 'tags'" label="标签">
+        <el-select
+          v-model="form.tags"
+          multiple
+          filterable
+          allow-create
+          default-first-option
+          placeholder="请选择或创建标签"
+          style="width: 100%"
+        >
+          <el-option
+            v-for="tag in tagOptions"
+            :key="tag.value"
+            :label="tag.label"
+            :value="tag.value"
+          ></el-option>
+        </el-select>
+      </el-form-item>
+    </el-form>
+
+    <template #footer>
+      <span class="dialog-footer">
+        <el-button @click="dialogVisible = false">取消</el-button>
+        <el-button type="primary" @click="handleSubmit" :loading="loading">确定</el-button>
+      </span>
+    </template>
+  </el-dialog>
+</template>
+
+<script lang="ts" setup>
+import { ref, reactive } from 'vue';
+import { ElMessage } from 'element-plus';
+import { updateBatchStatus } from '../api';
+
+const props = defineProps({
+  crudExpose: {
+    type: Object,
+    required: true
+  }
+});
+
+const dialogVisible = ref(false);
+const loading = ref(false);
+const selectedItems = ref([]);
+
+const form = reactive({
+  operationType: 'status',
+  status: undefined,
+  tags: []
+});
+
+// 标签选项,可以根据实际需求从API获取
+const tagOptions = ref([
+  { value: '优质候选人', label: '优质候选人' },
+  { value: '有经验', label: '有经验' },
+  { value: '应届毕业生', label: '应届毕业生' },
+  { value: '技能熟练', label: '技能熟练' }
+]);
+
+// 打开对话框
+const open = (selection: any) => {
+  if (!selection || selection.length === 0) {
+    ElMessage.warning('请至少选择一条记录');
+    return;
+  }
+  
+  selectedItems.value = selection;
+  dialogVisible.value = true;
+  
+  // 重置表单
+  form.operationType = 'status';
+  form.status = undefined;
+  form.tags = [];
+};
+
+// 提交处理
+const handleSubmit = async () => {
+  
+  if (form.operationType === 'tags' && (!form.tags || form.tags.length === 0)) {
+    ElMessage.warning('请至少选择一个标签');
+    return;
+  }
+  
+  try {
+    loading.value = true;
+    const application_ids = selectedItems.value.map((item: any) => item.id);
+    
+    if (form.operationType === 'status') {
+      await updateBatchStatus({
+        application_ids,
+        new_status: form.status,
+        tenant_id: 1
+      });
+      ElMessage.success('批量更新状态成功');
+    } /* else if (form.operationType === 'tags') {
+      await updateBatchTags({
+        ids,
+        tags: form.tags
+      });
+      ElMessage.success('批量更新标签成功');
+    } */
+    
+    // 关闭对话框
+    dialogVisible.value = false;
+    
+    // 刷新列表
+    props.crudExpose.doRefresh();
+  } catch (error) {
+    console.error('批量操作失败:', error);
+    ElMessage.error('操作失败,请重试');
+  } finally {
+    loading.value = false;
+  }
+};
+
+// 暴露方法给父组件
+defineExpose({
+  open
+});
+</script>
+
+<style scoped>
+.dialog-footer {
+  display: flex;
+  justify-content: flex-end;
+}
+</style>

+ 39 - 3
src/views/JobApplication/list/crud.tsx

@@ -1,13 +1,13 @@
 import * as api from './api';
 import { dict, UserPageQuery, AddReq, DelReq, EditReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet } from '@fast-crud/fast-crud';
 import { dictionary } from '/@/utils/dictionary';
-import { successMessage } from '/@/utils/message';
+import { successMessage,warningMessage } from '/@/utils/message';
 import { auth } from '/@/utils/authFunction';
 import tableSelector from '/@/components/tableSelector/index.vue';
 import { shallowRef } from 'vue';
 import { useRouter } from 'vue-router';
 
-export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
+export const createCrudOptions = function ({ crudExpose, context}: CreateCrudOptionsProps): CreateCrudOptionsRet {
 	const router = useRouter();
 	
 	const pageRequest = async (query: UserPageQuery) => {
@@ -48,6 +48,26 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 					add: {
 						show: false,//auth('area:Create'),
 					},
+					// 添加批量操作按钮
+					// 添加批量绑定标签按钮
+					batchBindTags: {
+						text: '批量绑定标签',
+						type: 'primary',
+						show: true,
+						order: 2,
+						click: () => {
+							// 使用正确的方法获取选中行
+							const selection = context.selectedRows || [];
+							console.log('选中的行:', selection);
+							
+							if (!selection || selection.length === 0) {
+								warningMessage('请先选择要操作的申请');
+								return;
+							}
+							// 打开批量绑定标签对话框
+							context.openBatchTagsDialog(selection);
+						},
+					},
 				},
 			},
 			rowHandle: {
@@ -83,7 +103,11 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 				show: true,
 			},
 			table: {
-				rowKey: 'id',
+				selection: true,
+				onSelectionChange: (selection: any[]) => {
+					// 存储选中的行到一个全局变量中
+					context.selectedRows = selection;
+				},
 			},
 			search: {
 				show: true,
@@ -104,6 +128,17 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 				}
 			},
 			columns: {
+				_selection: {
+					title: '选择',
+					form: { show: false },
+					column: {
+						type: 'selection',
+						align: 'center',
+						width: 50,
+						fixed: 'left',
+						columnSetDisabled: true,
+					},
+				},
 				_index: {
 					title: '序号',
 					form: { show: false },
@@ -268,6 +303,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 					},
 				},
 			},
+			
 		},
 	};
 };

+ 14 - 4
src/views/JobApplication/list/index.vue

@@ -84,9 +84,12 @@
 				</div>
 			</div>
 			<div class="content">
-				<fs-crud ref="crudRef" v-bind="crudBinding"> </fs-crud>
+				<fs-crud ref="crudRef" v-bind="crudBinding">
+					<!-- 可以添加自定义插槽,如果需要 -->
+				</fs-crud>
 			</div>
 		</div>
+		<BatchTagsDialog ref="batchTagsDialogRef" :crudExpose="crudExpose" />
 	</fs-page>
 </template>
 
@@ -97,8 +100,17 @@ import { createCrudOptions } from './crud';
 import { GetPermission } from './api';
 import { handleColumnPermission } from '/@/utils/columnPermission';
 import { Grid, Clock, ArrowRight, Check, RefreshRight, Briefcase } from '@element-plus/icons-vue';
+import BatchTagsDialog from './components/index.vue';
+const { crudBinding, crudRef, crudExpose, crudOptions, resetCrudOptions } = useFs({ 
+	createCrudOptions,
+	context: {
+		openBatchTagsDialog: (selection: any) => {
+			batchTagsDialogRef.value.open(selection);
+		}
+	}
+});
 
-const { crudBinding, crudRef, crudExpose, crudOptions, resetCrudOptions } = useFs({ createCrudOptions });
+const batchTagsDialogRef = ref();
 
 // 状态计数
 const totalCount = ref(0);
@@ -113,8 +125,6 @@ const statusCounts = reactive<Record<number, number>>({
 const showPositionList = ref(true);
 const positions = ref<Array<{id: number|string, title: string, count?: number}>>([
 	{ id: 1, title: '流水线操作工', count: 0 },
-	{ id: 2, title: '咖啡师', count: 0 },
-	{ id: 3, title: '餐厅服务员', count: 0 }
 ]);
 
 // 切换职位列表显示