detail.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <div class="auxiliary-notice-detail-container layout-pd">
  3. <el-card shadow="never" v-loading="loading">
  4. <el-form :model="state.ruleForm" label-width="110px" ref="ruleFormRef" class="show-info-form">
  5. <template v-if="['通知详情'].includes(noticeType)">
  6. <el-row :gutter="0">
  7. <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
  8. <el-form-item label="通知类型">
  9. {{ state.ruleForm.circularTypeName }}
  10. </el-form-item>
  11. </el-col>
  12. <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
  13. <el-form-item label="通知标题">
  14. {{ state.ruleForm.title }}
  15. </el-form-item>
  16. </el-col>
  17. <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
  18. <el-form-item label="必须阅读">
  19. {{ state.ruleForm.isMustRead ? '是' : '否' }}
  20. </el-form-item>
  21. </el-col>
  22. <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
  23. <el-form-item label="失效时间:">
  24. {{ formatDate(state.ruleForm.lostEfficacyTime, 'YYYY-mm-dd HH:MM:SS') }}
  25. </el-form-item>
  26. </el-col>
  27. <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
  28. <el-form-item label="通知对象:">
  29. {{ state.ruleForm.circularTypeText }}
  30. </el-form-item>
  31. </el-col>
  32. <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
  33. <el-form-item label="已阅读数量:">
  34. <el-popover :width="450" trigger="click" popper-class="notice-container">
  35. <template #reference>
  36. <el-button placement="right" link type="primary">{{ state.ruleForm?.readedNum + '/' + state.ruleForm?.needReadNum }}</el-button>
  37. </template>
  38. <div class="notice-container-box">
  39. <div class="notice-container-box-inner">
  40. 已读:{{ state.ruleForm?.readedNum }}
  41. <el-scrollbar class="mt5" v-if="state.ruleForm?.circularReadGroups?.length">
  42. <el-tag v-for="item in state.ruleForm?.circularReadGroups.filter((i) => i.isRead)"
  43. >{{ state.ruleForm.circularType === 1 ? item.userName : item.orgName }}
  44. <span v-if="item.isTimeOut" class="color-danger">(超时阅读)</span>
  45. </el-tag>
  46. </el-scrollbar>
  47. </div>
  48. <div class="notice-container-box-inner">
  49. 未读:{{ state.ruleForm?.needReadNum - state.ruleForm?.readedNum }}
  50. <el-scrollbar class="mt5 mb10" v-if="state.ruleForm.circularReadGroups?.length">
  51. <el-tag v-for="item in state.ruleForm.circularReadGroups.filter((i) => !i.isRead)">{{
  52. state.ruleForm.circularType === 1 ? item.userName : item.orgName
  53. }}</el-tag>
  54. </el-scrollbar>
  55. </div>
  56. </div>
  57. </el-popover>
  58. </el-form-item>
  59. </el-col>
  60. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  61. <el-form-item label="文档内容:">
  62. <div v-html="state.ruleForm.content"></div>
  63. </el-form-item>
  64. </el-col>
  65. </el-row>
  66. </template>
  67. <template v-if="['公告详情'].includes(noticeType)">
  68. <el-row :gutter="10">
  69. <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
  70. <el-form-item label="公告类型:">
  71. {{ state.ruleForm.bulletinTypeName }}
  72. </el-form-item>
  73. </el-col>
  74. <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
  75. <el-form-item label="公告标题:">
  76. {{ state.ruleForm.title }}
  77. </el-form-item>
  78. </el-col>
  79. <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
  80. <el-form-item label="失效时间:">
  81. {{ formatDate(state.ruleForm.loseEfficacyTime, 'YYYY-mm-dd HH:MM:SS') }}
  82. </el-form-item>
  83. </el-col>
  84. <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
  85. <el-form-item label="来源单位:">
  86. {{ state.ruleForm.sourceOrgName }}
  87. </el-form-item>
  88. </el-col>
  89. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  90. <el-form-item label="公告范围:">
  91. {{ state.ruleForm.pushRangesText }}
  92. </el-form-item>
  93. </el-col>
  94. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="editor-content-view">
  95. <el-form-item label="文档内容:">
  96. <div v-html="state.ruleForm.content"></div>
  97. </el-form-item>
  98. </el-col>
  99. </el-row>
  100. </template>
  101. </el-form>
  102. <el-button type="primary" @click="onAudit" title="通知审批" v-if="state.ruleForm?.circularState == 1" v-auth="'auxiliary:notice:audit'">
  103. 审批
  104. </el-button>
  105. <el-button type="primary" @click="onAudit" title="公告审批" v-if="state.ruleForm?.bulletinState == 1" v-auth="'auxiliary:bulletin:audit'">
  106. 审批
  107. </el-button>
  108. </el-card>
  109. <el-dialog v-model="state.dialogVisible" width="500px" draggable :title="noticeType" @close="close">
  110. <el-form :model="state.examineForm" label-width="110px" ref="examineFormRef">
  111. <el-form-item label="审核理由" prop="reason" :rules="[{ required: true, message: '请填写审核理由', trigger: 'blur' }]">
  112. <el-input v-model="state.examineForm.reason" placeholder="请填写审核理由" type="textarea" :autosize="{ minRows: 4, maxRows: 8 }"></el-input>
  113. </el-form-item>
  114. </el-form>
  115. <template #footer>
  116. <span class="dialog-footer">
  117. <el-button @click="state.dialogVisible = false" class="default-button">取 消</el-button>
  118. <el-button type="primary" @click="onReject(examineFormRef)" :loading="loading">审核驳回</el-button>
  119. <el-button type="primary" @click="onPass(examineFormRef)" :loading="loading">审核通过</el-button>
  120. </span>
  121. </template>
  122. </el-dialog>
  123. <!-- 流程审批 -->
  124. <process-audit ref="processAuditRef" @orderProcessSuccess="closePage" />
  125. </div>
  126. </template>
  127. <script setup lang="ts" name="auxiliaryNoticeDetail">
  128. import { reactive, onMounted, ref, defineAsyncComponent, computed } from 'vue';
  129. import { useRoute, useRouter } from 'vue-router';
  130. import { formatDate } from '@/utils/formatTime';
  131. import { bulletinAudit, bulletinDetail, circularAudit, circularDetail, circularRead } from '@/api/auxiliary/notice';
  132. import mittBus from '@/utils/mitt';
  133. import { ElInput, ElMessage, FormInstance } from 'element-plus';
  134. import { throttle } from '@/utils/tools';
  135. const ProcessAudit = defineAsyncComponent(() => import('@/components/ProcessAudit/index.vue')); // 流程审批
  136. // 定义变量内容
  137. const state = reactive<any>({
  138. dialogVisible: false,
  139. ruleForm: <EmptyObjectType>{},
  140. examineForm: <EmptyObjectType>{},
  141. });
  142. const noticeType = ref<any>('通知详情');
  143. const loading = ref<boolean>(false);
  144. const isRead = ref<string | string[]>('0');
  145. const getDetail = async (id: string | string[]) => {
  146. loading.value = true;
  147. try {
  148. switch (noticeType.value) {
  149. case '通知详情':
  150. if (isRead.value === '1') {
  151. // 阅读
  152. const readCircularRes = await circularRead(id);
  153. state.ruleForm = readCircularRes.result;
  154. } else {
  155. // 查看详情
  156. const circularRes = await circularDetail(id);
  157. state.ruleForm = circularRes.result;
  158. }
  159. break;
  160. case '公告详情':
  161. const bulletinRes = await bulletinDetail(id);
  162. state.ruleForm = bulletinRes.result;
  163. break;
  164. default:
  165. break;
  166. }
  167. loading.value = false;
  168. } catch (error) {
  169. loading.value = false;
  170. console.log(error);
  171. }
  172. };
  173. const route = useRoute();
  174. const onAudit = () => {
  175. state.dialogVisible = true;
  176. };
  177. // 关闭当前页
  178. const router = useRouter();
  179. const closePage = () => {
  180. state.dialogVisible = false;
  181. // 关闭当前 tagsView
  182. mittBus.emit('onCurrentContextmenuClick', Object.assign({}, { contextMenuClickId: 1, ...route }));
  183. mittBus.emit('clearCache', 'auxiliaryNotice');
  184. if (noticeType.value === '通知详情') {
  185. router.push({
  186. path: '/auxiliary/notice',
  187. });
  188. } else if (noticeType.value === '公告详情') {
  189. router.push({
  190. name: 'auxiliaryNotice',
  191. state: {
  192. index: '1',
  193. },
  194. });
  195. }
  196. };
  197. const examineFormRef = ref<RefType>();
  198. // 审核通过
  199. const onPass = throttle(async (formEl: FormInstance | undefined) => {
  200. if (!formEl) return;
  201. await formEl.validate((valid: boolean) => {
  202. if (!valid) return;
  203. loading.value = true;
  204. const request = {
  205. reason: state.examineForm.reason,
  206. id: route.params.id,
  207. isPass: true,
  208. };
  209. switch (noticeType.value) {
  210. case '通知详情':
  211. circularAudit(request)
  212. .then(() => {
  213. closePage();
  214. })
  215. .catch(() => {
  216. state.dialogVisible = false;
  217. loading.value = false;
  218. });
  219. break;
  220. case '公告详情':
  221. bulletinAudit(request)
  222. .then(() => {
  223. closePage();
  224. })
  225. .catch(() => {
  226. state.dialogVisible = false;
  227. loading.value = false;
  228. });
  229. break;
  230. default:
  231. state.dialogVisible = false;
  232. loading.value = false;
  233. break;
  234. }
  235. });
  236. }, 300);
  237. // 审核驳回
  238. const onReject = throttle(async (formEl: FormInstance | undefined) => {
  239. if (!formEl) return;
  240. await formEl.validate((valid: boolean) => {
  241. if (!valid) return;
  242. loading.value = true;
  243. const request = {
  244. reason: state.examineForm.reason,
  245. id: route.params.id,
  246. isPass: false,
  247. };
  248. switch (noticeType.value) {
  249. case '通知详情':
  250. circularAudit(request)
  251. .then(() => {
  252. closePage();
  253. })
  254. .catch(() => {
  255. state.dialogVisible = false;
  256. loading.value = false;
  257. });
  258. break;
  259. case '公告详情':
  260. bulletinAudit(request)
  261. .then(() => {
  262. closePage();
  263. })
  264. .catch(() => {
  265. state.dialogVisible = false;
  266. loading.value = false;
  267. });
  268. break;
  269. default:
  270. state.dialogVisible = false;
  271. loading.value = false;
  272. break;
  273. }
  274. });
  275. }, 300);
  276. const close = () => {
  277. examineFormRef.value?.resetFields();
  278. examineFormRef.value?.clearValidate();
  279. };
  280. onMounted(() => {
  281. noticeType.value = route.params?.tagsViewName ?? '通知详情';
  282. isRead.value = route.params?.isRead ?? '0';
  283. getDetail(route.params.id);
  284. });
  285. </script>