yangg 1 mese fa
parent
commit
dae2ebfffe

+ 47 - 6
src/views/system/borrow/approval/SpecialBorrowApp/index.vue

@@ -152,12 +152,18 @@
 	<SelectDeviceDialogApp v-model:visible="showSelectDeviceDialog" @confirm="onDeviceSelected" />
 	<!-- <SelectCatgory v-model:visible="showSelectDeviceDialog" @confirm="onDeviceSelected" /> -->
 	<RefuseNotification/>
+	<WarehouseSelectDialog 
+		v-model="showWarehouseDialog"
+		:formId="currentApprovalFormId"
+		@confirm="handleWarehouseConfirm"
+	/>
 </template>
 
 <script setup lang="ts">
 import { ref, inject,provide,watch, defineProps, defineEmits, onMounted,computed } from 'vue';
 import SelectDeviceDialogApp from './SelectDeviceDialogApp/index.vue';
 import RefuseNotification from '../RefuseNotification/index.vue';
+import WarehouseSelectDialog from '../components/WarehouseSelectDialog.vue';
 import dayjs from 'dayjs';
 import { ElMessage } from 'element-plus';
 import * as api from '../api';
@@ -222,6 +228,20 @@ const isView = computed(() => props.modelValue?.mode === 'view');
 const isAdd = computed(() => props.modelValue?.mode === 'add');
 
 const emit = defineEmits(['update:visible', 'update:modelValue', 'submit']);
+const showWarehouseDialog = ref(false);
+const currentApprovalFormId = ref<number | null>(null);
+
+function openWarehouseDialog() {
+	currentApprovalFormId.value = props.modelValue?.id ?? null;
+	showWarehouseDialog.value = true;
+}
+
+async function handleWarehouseConfirm(data: { formId: number; warehouseId: number }) {
+	await api.BorrowingReview(data.formId, "approve", "同意借用", data.warehouseId);
+	ElMessage.success("审批通过");
+	emit('update:visible', false);
+	crudExpose?.doRefresh();
+}
 const visible = ref(props.visible);
 const formRef = ref();
 
@@ -271,6 +291,30 @@ const handleCustomUpload = async ({ file, onProgress, onSuccess, onError }: any)
 
 // import { ElSteps } from 'element-plus';
 const steps = ref<any[]>([]);
+// 仓库映射(id -> name)
+const warehouseMap = ref<Record<string, string>>({});
+
+async function loadWarehouses() {
+	try {
+		const res = await request({
+			url: '/api/system/warehouse/',
+			method: 'get',
+			params: { page: 1, limit: 999 }
+		});
+		if (res?.code === 2000 && Array.isArray(res.data)) {
+			warehouseMap.value = Object.fromEntries(
+				res.data.map((w: any) => [String(w.id), w.name])
+			);
+		}
+	} catch (e) {
+		/* empty */
+	}
+}
+
+function getWarehouseName(id: any) {
+	const key = id != null ? String(id) : '';
+	return warehouseMap.value[key] ?? id;
+}
 const timeline = ref({
 	setpstatus:0,
 	create: '',
@@ -297,7 +341,7 @@ function buildSteps(data: any) {
   if (data.status >= 2 &&data.status!=3) {
     steps.value.push({
       title: '审批通过',
-      description: `审批人:${data.approver_info.name},时间:${data.approve_time}`,
+      description: `审批人:${data.approver_info.name},时间:${data.approve_time},仓库:${getWarehouseName(data.warehouse)||'暂无仓库'}`,
       status: 'finish'
     });
   } else if (data.status === 3) {
@@ -383,6 +427,7 @@ const rules = {
 
 // 自动填充用户信息
 onMounted(() => {
+	loadWarehouses()
 	try {
 		getAllUserList()
 		const bortype=props.modelValue.borrower_type;
@@ -498,11 +543,7 @@ async function onDanger(formId: number){
 }
 
 async function onSucess(){
-	const ids=props.modelValue.id;
-	await api.BorrowingReview(ids, "approve", "同意借用");
-	ElMessage.success("审批通过");
-	emit('update:visible', false);
-	crudExpose?.doRefresh();
+	openWarehouseDialog();
 }
 
 

+ 10 - 2
src/views/system/borrow/approval/api.ts

@@ -56,11 +56,19 @@ export function Switchspost(tenant_id:number) {
 }
 
 
-export function BorrowingReview(id:number,action:string,remark:string) {
+export function BorrowingReview(id:number,action:string,remark:string,warehouse?:number) {
 	return request({
 		url: `/api/system/borrow/application/${id}/review/`,
 		method: 'post',
-		data: {action,remark},
+		data: {action,remark,warehouse},
+	});
+}
+
+export function GetWarehouseList(query: {page: number, limit: number}) {
+	return request({
+		url: '/api/system/warehouse/',
+		method: 'get',
+		params: query,
 	});
 }
 

+ 146 - 0
src/views/system/borrow/approval/components/WarehouseSelectDialog.vue

@@ -0,0 +1,146 @@
+<template>
+  <el-dialog
+    v-model="visible"
+    title="选择仓库"
+    width="500px"
+    :before-close="handleClose"
+  >
+    <div class="warehouse-select-dialog">
+      <el-form :model="form" label-width="80px">
+        <el-form-item label="仓库选择" required>
+          <el-select
+            v-model="form.warehouseId"
+            placeholder="请选择仓库"
+            style="width: 100%"
+            filterable
+            clearable
+          >
+            <el-option
+              v-for="warehouse in warehouseList"
+              :key="warehouse.id"
+              :label="warehouse.name"
+              :value="warehouse.id"
+            />
+          </el-select>
+        </el-form-item>
+      </el-form>
+    </div>
+    
+    <template #footer>
+      <div class="dialog-footer">
+        <el-button @click="handleClose">取消</el-button>
+        <el-button type="primary" @click="handleConfirm" :disabled="!form.warehouseId">
+          确定
+        </el-button>
+      </div>
+    </template>
+  </el-dialog>
+</template>
+
+<script setup lang="ts">
+import { ref, reactive, watch } from 'vue'
+import { ElMessage } from 'element-plus'
+import { request } from '/@/utils/service'
+
+interface Warehouse {
+  id: number
+  name: string
+}
+
+interface Props {
+  modelValue: boolean
+  formId: number | null
+}
+
+interface Emits {
+  (e: 'update:modelValue', value: boolean): void
+  (e: 'confirm', data: { formId: number; warehouseId: number }): void
+}
+
+const props = defineProps<Props>()
+const emit = defineEmits<Emits>()
+
+const visible = ref(false)
+const warehouseList = ref<Warehouse[]>([])
+const loading = ref(false)
+
+const form = reactive({
+  warehouseId: null as number | null
+})
+
+// 获取仓库列表
+const getWarehouseList = async () => {
+  try {
+    loading.value = true
+    const response = await request({
+      url: '/api/system/warehouse/',
+      method: 'get',
+      params: {
+        page: 1,
+        limit: 20
+      }
+    })
+    
+    if (response.code === 2000) {
+      warehouseList.value = response.data || []
+    } else {
+      ElMessage.error('获取仓库列表失败')
+    }
+  } catch (error) {
+    console.error('获取仓库列表失败:', error)
+    ElMessage.error('获取仓库列表失败')
+  } finally {
+    loading.value = false
+  }
+}
+
+// 监听弹窗显示状态
+watch(() => props.modelValue, (newVal) => {
+  visible.value = newVal
+  if (newVal) {
+    getWarehouseList()
+    form.warehouseId = null
+  }
+})
+
+// 监听内部visible状态
+watch(visible, (newVal) => {
+  emit('update:modelValue', newVal)
+})
+
+// 关闭弹窗
+const handleClose = () => {
+  visible.value = false
+  form.warehouseId = null
+}
+
+// 确认选择
+const handleConfirm = () => {
+  if (!form.warehouseId) {
+    ElMessage.warning('请选择仓库')
+    return
+  }
+  
+  if (!props.formId) {
+    ElMessage.error('表单ID不存在')
+    return
+  }
+  
+  emit('confirm', {
+    formId: props.formId,
+    warehouseId: form.warehouseId
+  })
+  
+  handleClose()
+}
+</script>
+
+<style scoped>
+.warehouse-select-dialog {
+  padding: 20px 0;
+}
+
+.dialog-footer {
+  text-align: right;
+}
+</style>

+ 9 - 7
src/views/system/borrow/approval/curd.tsx

@@ -15,13 +15,15 @@ import * as api from './api';
 import { BorrowingReview, Switchspost } from './api';
 import { ElMessage , ElInput, ElDialog, ElButton } from 'element-plus';
 import dayjs from 'dayjs';
-import { h, ref, computed ,inject,defineAsyncComponent} from "vue";
+import { h, ref, computed ,inject,defineAsyncComponent, Ref} from "vue";
 // import ItemsList from './ItemsList/index.vue';
 
-export const createCrudOptions = function ({ crudExpose ,context, showRejectDialog, rejectReason, currentFormId,expose }: CreateCrudOptionsProps& {
+export const createCrudOptions = function ({ crudExpose ,context, showRejectDialog, rejectReason, currentFormId,expose, showWarehouseDialog, currentApprovalFormId }: CreateCrudOptionsProps& {
 	showRejectDialog: Ref<boolean>,
 	rejectReason: Ref<string>,
-	currentFormId: Ref<number | null>
+	currentFormId: Ref<number | null>,
+	showWarehouseDialog: Ref<boolean>,
+	currentApprovalFormId: Ref<number | null>
   }): CreateCrudOptionsRet {
 
 
@@ -61,6 +63,7 @@ export const createCrudOptions = function ({ crudExpose ,context, showRejectDial
 	const res = Switchspost(1);		
 
 
+
 	return {
 		crudOptions: {
 			request: {
@@ -79,10 +82,9 @@ export const createCrudOptions = function ({ crudExpose ,context, showRejectDial
 					ok: {
 						text: "通过", 
 						click: async (ctx: FormWrapperContext) => {
-						await api.BorrowingReview(ctx.form.id, "approve", "同意借用");
-						ElMessage.success("审批通过");
-						ctx.close();
-						crudExpose.doRefresh();
+							currentApprovalFormId.value = ctx.form.id;
+							showWarehouseDialog.value = true;
+							ctx.close();
 						}
 					},
 					reject: {

+ 27 - 5
src/views/system/borrow/approval/index.vue

@@ -6,6 +6,11 @@
       <!-- <ItemsList v-if="formData?.items" :itemss="formData.items" /> -->
 			<!-- <RefuseNotification/> -->
       <SpecialBorrowApp v-if="showSpecialBorrowDialogapp" v-model:visible="showSpecialBorrowDialogapp" :modelValue="borrowForm" @submit="handleBorrowSubmit" />
+      <WarehouseSelectDialog 
+        v-model="showWarehouseDialog" 
+        :formId="currentApprovalFormId" 
+        @confirm="handleWarehouseConfirm" 
+      />
 	</fs-page>
 </template>
 
@@ -19,12 +24,15 @@ import { BorrowingReview } from './api';
 import RefuseNotification from './RefuseNotification/index.vue';
 import ItemsList from './ItemsList/index.vue';
 import SpecialBorrowApp from './SpecialBorrowApp/index.vue';
+import WarehouseSelectDialog from './components/WarehouseSelectDialog.vue';
 // const { crudBinding, crudRef, crudExpose, crudOptions, resetCrudOptions } = useFs({ createCrudOptions });
 const showRejectDialog = ref(false);
 const rejectReason = ref('');
 const currentFormId = ref(null);
 const showSpecialBorrowDialogapp = ref(false);
 const borrowForm = ref({});
+const showWarehouseDialog = ref(false);
+const currentApprovalFormId = ref(null);
 
 
 
@@ -34,7 +42,9 @@ const { crudBinding, crudRef, crudExpose ,crudOptions} = useFs({
       ...props,
       showRejectDialog,
       rejectReason,
-      currentFormId
+      currentFormId,
+      showWarehouseDialog,
+      currentApprovalFormId
     })
 });
 
@@ -58,8 +68,9 @@ function onBorrowTypeSelected(type: number, mode: 'view' | 'edit' | 'add' |'coll
 	
 }
 
-async function handleView(e: CustomEvent) {
-	const row = e.detail;
+async function handleView(e: Event) {
+	const customEvent = e as CustomEvent;
+	const row = customEvent.detail;
 	onBorrowTypeSelected(row.borrow_type, 'view',row);
 }
 
@@ -84,6 +95,17 @@ async function handleBorrowSubmit(formData: any) {
 	}
 }
 
+async function handleWarehouseConfirm(data: { formId: number; warehouseId: number }) {
+	try {
+		await BorrowingReview(data.formId, "approve", "同意借用", data.warehouseId);
+		ElMessage.success("审批通过");
+		crudExpose.doRefresh();
+	} catch (error) {
+		console.error('审批失败:', error);
+		ElMessage.error("审批失败");
+	}
+}
+
 
 
 
@@ -95,13 +117,13 @@ const formData = ref<any>(null);
 
 onMounted(() => {
 	crudExpose.doRefresh();
-  window.addEventListener('approve-view', handleView);
+  window.addEventListener('approve-view', handleView as EventListener);
  
 
 });
 
 onBeforeUnmount(() => {
-	window.removeEventListener('approve-view', handleView);
+	window.removeEventListener('approve-view', handleView as EventListener);
 });
 
 

+ 27 - 1
src/views/system/borrow/component/CollectEquipment/index.vue

@@ -396,6 +396,7 @@ import * as deviceApi from '../../../device/api';
 import { CollectEquipment, ReturnEquipment } from '../../api';
 import type { TabsPaneContext } from 'element-plus';
 import { getUserInfo } from '../../../login/api';
+import { request } from '/@/utils/service';
 
 // 禁止选择今天之前的日期
 const disabledDate = (time: Date) => {
@@ -561,6 +562,30 @@ const selectedDevices = ref<DeviceListItem[]>([]); // 添加选中设备列表
 
 //审批步骤
 const steps = ref<any[]>([]);
+// 仓库映射(id -> name)
+const warehouseMap = ref<Record<string, string>>({});
+
+async function loadWarehouses() {
+	try {
+		const res = await request({
+			url: '/api/system/warehouse/',
+			method: 'get',
+			params: { page: 1, limit: 999 }
+		});
+		if (res?.code === 2000 && Array.isArray(res.data)) {
+			warehouseMap.value = Object.fromEntries(
+				res.data.map((w: any) => [String(w.id), w.name])
+			);
+		}
+	} catch (e) {
+		/* empty */
+	}
+}
+
+function getWarehouseName(id: any) {
+	const key = id != null ? String(id) : '';
+	return warehouseMap.value[key] ?? id;
+}
 
 // 添加结算单相关的状态
 const showSettlementDialog = ref(false);
@@ -599,7 +624,7 @@ function buildSteps(data: any) {
   if (data.status >= 2&&data.status!=3 && data.borrow_type!=1) {
     steps.value.push({
       title: '审批通过',
-      description: `审批人:${approverinfo.name},时间:${data.approve_time}`,
+      description: `审批人:${approverinfo.name},时 间:${data.approve_time},仓库:${getWarehouseName(data.warehouse)||'暂无仓库'}`,
       status: 'finish'
     });
   } else if (data.status === 3) {
@@ -945,6 +970,7 @@ const rules = {
 
 // 自动填充用户信息
 onMounted(() => {
+	loadWarehouses()
 	getAdminList()
 	getAllUserList()
 	try {

+ 26 - 1
src/views/system/borrow/component/SpecialBorrow/index.vue

@@ -256,6 +256,30 @@ const handleCustomUpload = async ({ file, onProgress, onSuccess, onError }: any)
 
 // import { ElSteps } from 'element-plus';
 const steps = ref<any[]>([]);
+// 仓库映射(id -> name)
+const warehouseMap = ref<Record<string, string>>({});
+
+async function loadWarehouses() {
+	try {
+		const res = await request({
+			url: '/api/system/warehouse/',
+			method: 'get',
+			params: { page: 1, limit: 999 }
+		});
+		if (res?.code === 2000 && Array.isArray(res.data)) {
+			warehouseMap.value = Object.fromEntries(
+				res.data.map((w: any) => [String(w.id), w.name])
+			);
+		}
+	} catch (e) {
+		/* empty */
+	}
+}
+
+function getWarehouseName(id: any) {
+	const key = id != null ? String(id) : '';
+	return warehouseMap.value[key] ?? id;
+}
 const timeline = ref({
 	setpstatus:0,
 	create: '',
@@ -282,7 +306,7 @@ function buildSteps(data: any) {
   if (data.status >= 2&&data.status!=3) {
     steps.value.push({
       title: '审批通过',
-      description: `审批人:${data.approver_info.name},时间:${data.approve_time}`,
+      description: `审批人:${data.approver_info.name},时间:${data.approve_time},仓库:${getWarehouseName(data.warehouse)||'暂无仓库'}`,
       status: 'finish'
     });
   } else if (data.status === 3) {
@@ -365,6 +389,7 @@ const rules = {
 
 // 自动填充用户信息
 onMounted(() => {
+	loadWarehouses()
 	getAdminList()
 	getAllUserList()
 	try {