confirm.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. <!--
  2. * @Author: wanglj wanglijie@dashoo.cn
  3. * @Date: 2025-02-27 14:50:41
  4. * @LastEditors: wanglj wanglijie@dashoo.cn
  5. * @LastEditTime: 2025-03-06 18:28:53
  6. * @Description: file content
  7. * @FilePath: \labsop_backup2\frontend\packages\platform\src\views\entry\components\confirm.vue
  8. -->
  9. <template>
  10. <div class="facilities-dialog-container">
  11. <el-dialog :title="state.dialog.title" @close="onCancel" :close-on-click-modal="false" v-model="state.dialog.isShowDialog" width="90%">
  12. <header class="mb8">
  13. <span>确认</span>
  14. <el-form inline size="mini" label-width="0">
  15. <el-form-item>
  16. <el-radio-group v-model="resClass" v-if="cellType.length > 1" size="small" @change="filterOutList">
  17. <el-radio label="">全部</el-radio>
  18. <el-radio v-for="item in cellType" :key="item.dictValue" :label="item.dictValue">{{ item.dictLabel }}</el-radio>
  19. </el-radio-group>
  20. </el-form-item>
  21. <el-form-item class="ml12">
  22. <el-button color="#2c78ff" @click="autoConfirm()" size="default" :loading="autoFlag">自动确认</el-button>
  23. </el-form-item>
  24. </el-form>
  25. </header>
  26. <div class="table-container">
  27. <div class="out-table">
  28. <el-alert :title="`下个月出室人员(共${state.outList.length}人)`" type="warning" :closable="false" class="mb8" />
  29. <van-list finished-text="没有更多了">
  30. <van-cell v-for="item in state.outList" :key="item">
  31. <template #default>
  32. <div class="list">
  33. <p class="inst-title">
  34. <span>出室人员</span>
  35. <span class="title ml8">{{ item.userName }}</span>
  36. </p>
  37. <p class="inst-title">
  38. <span>联系方式</span>
  39. <span class="title ml8">{{ item.memberPhone }}</span>
  40. </p>
  41. <p class="inst-title">
  42. <span>预约平台</span>
  43. <span class="title ml8">
  44. {{ item.platformName }}
  45. </span>
  46. </p>
  47. <p class="inst-title">
  48. <span>分配类型</span>
  49. <span class="title ml8">
  50. {{ item.resClass }}
  51. </span>
  52. </p>
  53. <p class="inst-title">
  54. <span>分配房间</span>
  55. <span class="title ml8">
  56. {{ item.resName }}
  57. </span>
  58. </p>
  59. <p class="inst-title">
  60. <span>入室日期</span>
  61. <span class="title ml8"> {{ item.startTime }}个月 </span>
  62. </p>
  63. <p class="inst-title">
  64. <span>出室日期</span>
  65. <span class="title ml8">{{ item.endTime }}</span>
  66. </p>
  67. <p class="inst-title">
  68. <span>课题组</span>
  69. <span class="title ml8">{{ item.pgName }}</span>
  70. </p>
  71. <p class="inst-title">
  72. <span>课题组负责人</span>
  73. <span class="title ml8">{{ item.mentorName }}</span>
  74. </p>
  75. <footer class="flex justify-end mt4 actions-footer"></footer>
  76. </div>
  77. </template>
  78. </van-cell>
  79. </van-list>
  80. <!-- <vxe-table :height="500" :data="state.outList" ref="outRef" show-overflow="title" border align="center">
  81. <vxe-column type="seq" title="序号" width="60" align="center" fixed="left" />
  82. <vxe-column field="userName" title="出室人员" width="140"></vxe-column>
  83. <vxe-column field="memberPhone" title="联系方式" width="120"></vxe-column>
  84. <vxe-column field="platformName" title="预约平台" width="120"></vxe-column>
  85. <vxe-column field="resClass" title="分配类型" width="100">
  86. <template #default="{ row }">{{ getDictLabel(cellType, row.resClass) }}</template>
  87. </vxe-column>
  88. <vxe-column field="resName" title="分配房间" width="140"></vxe-column>
  89. <vxe-column field="startTime" title="入室日期" width="120">
  90. <template #default="{ row }">{{ formatDate(new Date(row.startTime), 'YYYY-mm-dd') }}</template>
  91. </vxe-column>
  92. <vxe-column field="endTime" title="出室日期" width="120">
  93. <template #default="{ row }">{{ formatDate(new Date(row.endTime), 'YYYY-mm-dd') }}</template>
  94. </vxe-column>
  95. <vxe-column field="pgName" title="课题组" width="100"></vxe-column>
  96. <vxe-column field="mentorName" title="课题组负责人" width="120"></vxe-column>
  97. </vxe-table> -->
  98. </div>
  99. <div class="confirm-table">
  100. <el-alert :title="`待确认队列 (已确认${comfirmTotal}人)`" type="warning" :closable="false" class="mb8" />
  101. <ul>
  102. <li v-for="(item, index) in state.confirmList" :key="index">
  103. <div class="text">
  104. <p>
  105. {{ item.memberName }}【{{ formatDate(new Date(item.appointStartDate), 'mm-dd') }}~{{
  106. formatDate(new Date(item.appointEndDate), 'mm-dd')
  107. }}】-{{ getDictLabel(cellType, item.cellSourceType) }}
  108. </p>
  109. <p>{{ item.pgName }}-{{ item.mentorName }}</p>
  110. </div>
  111. <el-icon v-if="item.checked">
  112. <ele-Select />
  113. </el-icon>
  114. <div class="btns">
  115. <el-button v-if="!item.checked" link type="primary" @click="onConfirm(item)">确认</el-button>
  116. <el-button v-else link @click="item.checked = false">取消</el-button>
  117. <el-button link type="primary" @click="onDetail(item)">查看</el-button>
  118. </div>
  119. </li>
  120. </ul>
  121. </div>
  122. </div>
  123. <template #footer>
  124. <span class="dialog-footer">
  125. <el-button type="info" @click="onCancel" size="default">取 消</el-button>
  126. <el-button color="#2c78ff" @click="onSubmit()" size="default">确 定</el-button>
  127. </span>
  128. </template>
  129. </el-dialog>
  130. <DetailsDialog ref="detailsDialog" />
  131. </div>
  132. </template>
  133. <script setup lang="ts" name="systemProDialog">
  134. import to from 'await-to-js'
  135. import { defineAsyncComponent, reactive, ref, computed, onMounted } from 'vue'
  136. import { ElMessage, ElMessageBox } from 'element-plus'
  137. import { usePlatformAppointApi } from '/@/api/platform/appoint'
  138. import { usePlatformApi } from '/@/api/platform/home'
  139. import { useSystemApi } from '/@/api/platform/system'
  140. import { deepClone, getDictLabel } from '/@/utils/other'
  141. import { useUserInfo } from '/@/stores/userInfo'
  142. import { storeToRefs } from 'pinia'
  143. import { useDictApi } from '/@/api/base/system/dict'
  144. import { useCellAssignApi } from '/@/api/platform/home/assign'
  145. import { formatDate } from '/@/utils/formatTime'
  146. const DetailsDialog = defineAsyncComponent(() => import('/@/view/entry/components/details.vue'))
  147. const stores = useUserInfo()
  148. const { userInfos } = storeToRefs(stores)
  149. // 定义子组件向父组件传值/事件
  150. const emit = defineEmits(['refresh'])
  151. // 定义变量内容
  152. const Api = usePlatformAppointApi()
  153. const systemApi = useSystemApi()
  154. const platformApi = usePlatformApi()
  155. const cellAssignApi = useCellAssignApi()
  156. const dictApi = useDictApi()
  157. const deptRef = ref()
  158. const detailsDialog = ref()
  159. const userTypeList = ref<RowDicDataType[]>([])
  160. const projectGroupList = ref<any[]>([])
  161. const cellType = ref<RowDicDataType[]>([])
  162. const rules = {
  163. memberName: { required: true, message: '不能为空', trigger: 'blur' },
  164. memberType: { required: true, message: '不能为空', trigger: 'change' },
  165. deptId: { required: true, message: '不能为空', trigger: 'change' },
  166. platformName: { required: true, message: '不能为空', trigger: 'blur' },
  167. platformTime: { required: true, message: '不能为空', trigger: 'blur' },
  168. startDate: { required: true, message: '不能为空', trigger: 'change' },
  169. endDate: { required: true, message: '不能为空', trigger: 'change' },
  170. mentorName: { required: true, message: '不能为空', trigger: 'blur' }
  171. }
  172. const state = reactive({
  173. form: {
  174. id: 0,
  175. deptId: null,
  176. deptName: '',
  177. isTemporary: '10',
  178. memberId: 0,
  179. memberName: '',
  180. memberPhone: '',
  181. memberType: '',
  182. memberDeptId: null,
  183. memberDeptName: '',
  184. mentorObj: null,
  185. pgId: null,
  186. pgName: '',
  187. mentorId: null,
  188. mentorName: '',
  189. mentorDeptName: '',
  190. mentorPhone: '',
  191. platformId: null,
  192. platformName: '',
  193. platformTime: null,
  194. platformType: '',
  195. isCellChecked: '20',
  196. cellType: '',
  197. cellSourceType: '',
  198. isMolecularChecked: '20',
  199. molecularTime: null,
  200. platOtherNeed: ''
  201. },
  202. outList: [] as any[],
  203. confirmList: [] as any[],
  204. dialog: {
  205. isShowDialog: false,
  206. type: '',
  207. title: '',
  208. submitTxt: ''
  209. }
  210. })
  211. const autoFlag = ref(false)
  212. const comfirmTotal = computed(() => {
  213. return state.confirmList.reduce((pre: number, cur: any) => {
  214. if (cur.checked) return pre + 1
  215. return pre
  216. }, 0)
  217. })
  218. const outList = ref<any[]>([])
  219. const confirmList = ref<any[]>([])
  220. const belongOrgOption = ref<DeptTreeType[]>([])
  221. const userList = ref<RowUserType[]>([])
  222. const resClass = ref('')
  223. const platform = ref()
  224. const getDicts = async () => {
  225. Promise.all([
  226. systemApi.getDeptTree(),
  227. systemApi.getUserList({ noPage: true }),
  228. platformApi.getDetail({ id: userInfos.value.platformId }),
  229. dictApi.getDictDataByType('sys_user_type'),
  230. systemApi.getProjectGroupList({ noPage: true }),
  231. userInfos.value.platformId != 0 ? platformApi.getResourceTypeDict({ id: userInfos.value.platformId }) : ''
  232. ]).then(([dept, user, plat, type, pjt, cell]) => {
  233. belongOrgOption.value = dept?.data || []
  234. userList.value = user?.data?.list || []
  235. userTypeList.value = type?.data?.values || []
  236. projectGroupList.value = pjt?.data?.list || []
  237. cellType.value = cell?.data || []
  238. platform.value = plat?.data || ''
  239. getOutList()
  240. getConfirmList()
  241. })
  242. }
  243. // 打开弹窗
  244. const openDialog = async (type: string, row: number) => {
  245. await getDicts()
  246. state.dialog.type = type
  247. state.dialog.title = '入室资源确认'
  248. state.dialog.isShowDialog = true
  249. }
  250. const getOutList = async () => {
  251. const [err, res]: ToResponse = await to(Api.nextMonthPerson({ id: userInfos.value.platformId, platformType: platform.value.platformType }))
  252. if (err) return
  253. outList.value = res?.data || []
  254. state.outList = JSON.parse(JSON.stringify(outList.value))
  255. }
  256. const getConfirmList = async () => {
  257. const [err, res]: ToResponse = await to(Api.getConfirmedQueue({ id: userInfos.value.platformId, platformType: platform.value.platformType }))
  258. if (err) return
  259. confirmList.value = res?.data || []
  260. state.confirmList = JSON.parse(JSON.stringify(confirmList.value))
  261. }
  262. // 前端筛选类型
  263. const filterOutList = (val?: string) => {
  264. if (val) {
  265. state.outList = outList.value.filter((item: any) => item.resClass == val)
  266. state.confirmList = confirmList.value.filter((item: any) => item.cellSourceType == val)
  267. } else {
  268. state.outList = [...outList.value]
  269. state.confirmList = [...confirmList.value]
  270. }
  271. }
  272. // 确认
  273. const onConfirm = (row: any) => {
  274. // 验证同类型 下个月出室人员 = 已确认人数 提示无法确认
  275. const total = outList.value.filter((item: any) => item.resClass == row.cellSourceType).length
  276. if (total == confirmList.value.filter((item: any) => item.cellSourceType == row.cellSourceType && item.checked).length) {
  277. ElMessage.warning('该类型下已确认人数与出室人员人数一致,无法确认')
  278. return
  279. }
  280. row.checked = true
  281. const obj = confirmList.value.find((item: any) => item.id == row.id)
  282. obj.checked = true
  283. }
  284. // 自动确认
  285. const autoConfirm = () => {
  286. autoFlag.value = true
  287. // 按待确认列表顺序依次确认
  288. filterOutList()
  289. state.confirmList.forEach((item: any) => {
  290. item.checked = false
  291. })
  292. for (const item of cellType.value) {
  293. const total = state.outList.filter((i: any) => i.resClass == item.dictValue).length
  294. const confirm = state.confirmList.filter((i: any) => i.cellSourceType == item.dictValue)
  295. for (let i = 0; i < total; i++) {
  296. confirm[i].checked = true
  297. }
  298. }
  299. autoFlag.value = false
  300. }
  301. // 关闭弹窗
  302. const closeDialog = () => {
  303. state.outList = []
  304. state.confirmList = []
  305. outList.value = []
  306. confirmList.value = []
  307. state.dialog.isShowDialog = false
  308. }
  309. // 取消
  310. const onCancel = () => {
  311. closeDialog()
  312. }
  313. // 提交
  314. const onSubmit = async () => {
  315. // 验证 所有下个月出室人员 是否全部确认 二次确认
  316. const total = state.outList.length
  317. const arr = state.confirmList.filter((item: any) => item.checked)
  318. // 获取对应下月出室人员后端标记 不再显示在列表中
  319. const outArr: number[] = []
  320. for (const item of cellType.value) {
  321. const confirm = arr.filter((i: any) => i.cellSourceType == item.dictValue)
  322. const out = state.outList.filter((i: any) => i.resClass == item.dictValue)
  323. for (let i = 0; i < confirm.length; i++) {
  324. if (out[i]) outArr.push(out[i].id)
  325. }
  326. }
  327. let confirm: Error | null = null
  328. if (arr.length < total) {
  329. ;[confirm] = await to(
  330. ElMessageBox.confirm('下个月出室人员未全部确认,是否继续提交?', '提示', {
  331. confirmButtonText: '确定',
  332. cancelButtonText: '取消',
  333. type: 'warning'
  334. })
  335. )
  336. }
  337. if (confirm !== null) return
  338. const [err]: ToResponse = await to(
  339. Api.markNextMonthEntry({ ids: arr.map((item: any) => item.id), assignIds: outArr, platformType: platform.value.platformType })
  340. )
  341. if (err) return
  342. ElMessage.success('操作成功')
  343. emit('refresh')
  344. closeDialog()
  345. }
  346. const onDetail = (val: number) => {
  347. detailsDialog.value.openDialog('get', val)
  348. }
  349. // 暴露变量
  350. defineExpose({
  351. openDialog
  352. })
  353. </script>
  354. <style lang="scss" scoped>
  355. h4 {
  356. font-size: 18px;
  357. }
  358. header {
  359. display: flex;
  360. justify-content: space-between;
  361. align-items: center;
  362. height: 32px;
  363. line-height: 32px;
  364. .el-form.el-form--inline .el-form-item {
  365. margin: 0;
  366. }
  367. }
  368. .table-container {
  369. /* display: flex; */
  370. .out-table {
  371. /* width: 808px; */
  372. }
  373. .confirm-table {
  374. margin-top: 12px;
  375. /* width: 340px; */
  376. display: flex;
  377. flex-direction: column;
  378. ul {
  379. height: 500px;
  380. overflow-y: auto;
  381. li {
  382. display: flex;
  383. align-items: center;
  384. justify-content: space-between;
  385. border-radius: 4px;
  386. border: 1px solid #eee;
  387. padding: 8px;
  388. & + li {
  389. margin-top: 8px;
  390. }
  391. .text {
  392. flex: 1;
  393. overflow: hidden;
  394. p {
  395. white-space: nowrap;
  396. overflow: hidden;
  397. text-overflow: ellipsis;
  398. }
  399. }
  400. .el-icon {
  401. color: #fff;
  402. background-color: #0dda83;
  403. font-size: 20px;
  404. padding: 4px;
  405. border-radius: 50%;
  406. margin: 0 12px;
  407. }
  408. .btns {
  409. display: flex;
  410. flex-direction: column;
  411. .el-button {
  412. margin-left: 0;
  413. }
  414. }
  415. }
  416. }
  417. }
  418. }
  419. :deep(.disUoloadSty .el-upload--picture-card) {
  420. display: none; /* 上传按钮隐藏 */
  421. }
  422. .avatar-uploader {
  423. :deep(.el-upload) {
  424. width: 100%;
  425. height: 100%;
  426. border: 1px dashed var(--el-border-color);
  427. border-radius: 6px;
  428. cursor: pointer;
  429. position: relative;
  430. overflow: hidden;
  431. transition: var(--el-transition-duration-fast);
  432. &:hover {
  433. border-color: var(--el-color-primary);
  434. }
  435. }
  436. }
  437. .el-icon.avatar-uploader-icon {
  438. font-size: 28px;
  439. color: #8c939d;
  440. width: 178px;
  441. height: 178px;
  442. text-align: center;
  443. }
  444. </style>