diff --git a/src/views/finance/purchasingrequisition/implement.vue b/src/views/finance/purchasingrequisition/implement.vue
index 5741ffc..a0fdb2d 100644
--- a/src/views/finance/purchasingrequisition/implement.vue
+++ b/src/views/finance/purchasingrequisition/implement.vue
@@ -8,33 +8,37 @@
-
- 采购文件版本
-
-
-
- V{{ $index + 1 }}
-
-
-
-
- {{ formatCreateTime(row.createTime) }}
-
-
-
- 下载
-
-
-
-
- 可继续上传新版本(保留原文件,格式 doc/docx/pdf,单文件不超过 5MB):
-
+
+
+ 分配代理
+
+
+ 指定代理
+ 随机分配
+
+
+
+
+
+
+
+
+
+ {{ rollingAgentName }}
+ 已分配:{{ assignedAgentName }}
+ 点击下方按钮进行随机分配
+
+
+
+ {{ applyRow.agentName }}
+
+
+ 指定代理
+
+
+ 随机分配
+
+
@@ -59,37 +63,25 @@
diff --git a/src/views/finance/purchasingrequisition/index.vue b/src/views/finance/purchasingrequisition/index.vue
index d876537..4d4625f 100644
--- a/src/views/finance/purchasingrequisition/index.vue
+++ b/src/views/finance/purchasingrequisition/index.vue
@@ -292,63 +292,52 @@
-
+
+
+
+
-
-
-
- 指定
- 随机
+
+
+
+ 指定采购代表人
+ 部门多人系统抽取
-
+
-
+
-
- {{ assignAgentCurrentRow.agentName }}
+
+
+
+
-
- 取消
-
- 随机分配
-
-
- 确定
-
-
+ 取消
+ 确定
-
-
-
@@ -356,14 +345,19 @@
import { ref, reactive, defineAsyncComponent, onMounted, computed } from 'vue'
import { useRouter } from 'vue-router'
import { BasicTableProps, useTable } from "/@/hooks/table";
-import { getPage, delObj, submitObj, getArchiveDownloadUrl, getApplyTemplateDownloadUrl, getFileApplyTemplateDownloadUrl, assignAgent } from "/@/api/finance/purchasingrequisition";
-import { getPage as getAgentPage } from '/@/api/finance/purchaseagent';
+import { getPage, delObj, submitObj, getArchiveDownloadUrl, getApplyTemplateDownloadUrl, getFileApplyTemplateDownloadUrl, getDeptMembers, saveRepresentor } from "/@/api/finance/purchasingrequisition";
import { useMessage, useMessageBox } from "/@/hooks/message";
import { useAuth } from '/@/hooks/auth';
import { getDicts } from '/@/api/admin/dict';
import { getTree } from '/@/api/finance/purchasingcategory';
-import { List, Document, DocumentCopy, Search, Collection, Money, CircleCheck, InfoFilled, Calendar, OfficeBuilding, Warning, DocumentChecked, Edit, Delete, Upload, FolderOpened, Download } from '@element-plus/icons-vue'
+import { List, Document, DocumentCopy, Search, Money, CircleCheck, InfoFilled, Calendar, OfficeBuilding, Warning, DocumentChecked, Edit, Delete, Upload, FolderOpened, Download, User } from '@element-plus/icons-vue'
import other from '/@/utils/other'
+import { Session } from '/@/utils/storage'
+
+// 角色常量
+const PURCHASE_DEPT_AUDIT_ROLE_CODE = 'PURCHASE_DEPT_AUDIT'
+const roleCode = computed(() => Session.getRoleCode() || '')
+const isDeptAuditRole = computed(() => roleCode.value === PURCHASE_DEPT_AUDIT_ROLE_CODE)
// 引入组件
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
@@ -400,72 +394,54 @@ const currFlowCommentType = ref<'apply' | 'file'>('apply')
const implementFormRef = ref()
-/** 分配代理弹窗 */
-const assignAgentDialogVisible = ref(false)
-const assignAgentCurrentRow = ref(null)
-const assignAgentForm = reactive({ mode: 'designated' as 'designated' | 'random', agentId: '' })
-const agentList = ref([])
-const agentListLoading = ref(false)
-const assignAgentSubmitting = ref(false)
+/** 采购代表弹窗 */
+const representorDialogVisible = ref(false)
+const representorCurrentRow = ref(null)
+const representorForm = reactive({ mode: 'single' as 'single' | 'multi', teacherNo: '', multiIds: [] as string[] })
+const representorDeptMembers = ref([])
+const representorSubmitting = ref(false)
-const openAssignAgentDialog = async (row: any) => {
- assignAgentCurrentRow.value = row
- assignAgentForm.mode = 'designated'
- assignAgentForm.agentId = ''
- assignAgentDialogVisible.value = true
- agentListLoading.value = true
+const openRepresentorDialog = async (row: any) => {
+ representorCurrentRow.value = row
+ representorForm.mode = 'single'
+ representorForm.teacherNo = ''
+ representorForm.multiIds = []
+ representorDialogVisible.value = true
try {
- const res = await getAgentPage({ size: 500, current: 1 })
- const records = res?.data?.records ?? res?.records ?? []
- agentList.value = Array.isArray(records) ? records : []
+ const res = await getDeptMembers()
+ representorDeptMembers.value = res?.data || []
} catch (_) {
- agentList.value = []
- } finally {
- agentListLoading.value = false
+ representorDeptMembers.value = []
}
}
-const handleAssignAgentRandom = async () => {
- const row = assignAgentCurrentRow.value
+const handleSaveRepresentor = async () => {
+ const row = representorCurrentRow.value
const id = row?.id ?? row?.purchaseId
if (id == null || id === '') {
useMessage().warning('无法获取申请单ID')
return
}
- assignAgentSubmitting.value = true
- try {
- await assignAgent(Number(id), 'random')
- useMessage().success('随机分配代理成功')
- assignAgentDialogVisible.value = false
- getDataList()
- } catch (e: any) {
- useMessage().error(e?.msg || '随机分配代理失败')
- } finally {
- assignAgentSubmitting.value = false
- }
-}
-
-const handleAssignAgentDesignated = async () => {
- const row = assignAgentCurrentRow.value
- const id = row?.id ?? row?.purchaseId
- if (id == null || id === '') {
- useMessage().warning('无法获取申请单ID')
+ if (representorForm.mode === 'single' && !representorForm.teacherNo) {
+ useMessage().warning('请选择采购代表人')
return
}
- if (!assignAgentForm.agentId) {
- useMessage().warning('请选择招标代理')
+ if (representorForm.mode === 'multi' && !representorForm.multiIds.length) {
+ useMessage().warning('请选择部门多人')
return
}
- assignAgentSubmitting.value = true
+ representorSubmitting.value = true
try {
- await assignAgent(Number(id), 'designated', assignAgentForm.agentId)
- useMessage().success('指定代理成功')
- assignAgentDialogVisible.value = false
+ const teacherNo = representorForm.mode === 'single' ? representorForm.teacherNo : undefined
+ const multiIds = representorForm.mode === 'multi' ? representorForm.multiIds.join(',') : undefined
+ await saveRepresentor(Number(id), teacherNo, multiIds)
+ useMessage().success('保存采购代表成功')
+ representorDialogVisible.value = false
getDataList()
} catch (e: any) {
- useMessage().error(e?.msg || '指定代理失败')
+ useMessage().error(e?.msg || '保存采购代表失败')
} finally {
- assignAgentSubmitting.value = false
+ representorSubmitting.value = false
}
}
@@ -648,18 +624,18 @@ const getActionMenuItems = (row: any) => {
icon: Download,
visible: () => true,
},
+ {
+ command: 'representor',
+ label: '采购代表',
+ icon: User,
+ visible: () => isDeptAuditRole.value,
+ },
// {
// command: 'downloadFileApply',
// label: '下载文件审批表',
// icon: Download,
// visible: () => true,
// },
- {
- command: 'assignAgent',
- label: '分配代理',
- icon: Collection,
- visible: () => row?.purchaseMode === '2' || (row?.purchaseMode === '0' && row?.purchaseType === '4'),
- }
// {
// command: 'docAudit',
// label: '采购文件审核',
@@ -703,12 +679,12 @@ const handleMoreCommand = (command: string, row: any) => {
case 'downloadFileApply':
handleDownloadFileApply(row);
break;
- case 'assignAgent':
- openAssignAgentDialog(row);
- break;
case 'docAudit':
handleDocAudit(row);
break;
+ case 'representor':
+ openRepresentorDialog(row);
+ break;
}
};