index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <div class="snapshot-info-ssp-config-container layout-padding">
  3. <div class="layout-padding-auto layout-padding-view pd20">
  4. <vxe-grid v-bind="gridOptions" ref="gridRef">
  5. <template #form>
  6. <el-form :model="state.queryParams" ref="ruleFormRef" inline @submit.native.prevent :disabled="gridOptions.loading">
  7. <el-form-item label="审批状态" prop="State">
  8. <el-radio-group v-model="state.queryParams.State" @change="handleQuery">
  9. <el-radio v-for="item in bulletinState" :label="item.value" :value="item.key" :key="item.key"></el-radio>
  10. </el-radio-group>
  11. </el-form-item>
  12. <el-form-item label="标题" prop="Title">
  13. <el-input v-model="state.queryParams.Title" placeholder="请填写标题" clearable @keyup.enter="handleQuery" class="keyword-input" />
  14. </el-form-item>
  15. <el-form-item>
  16. <el-button type="primary" @click="handleQuery" :loading="state.loading"> <SvgIcon name="ele-Search" class="mr5" />查询 </el-button>
  17. <el-button @click="drawer = true" class="default-button"> <SvgIcon name="ele-Search" class="mr5" />更多查询</el-button>
  18. </el-form-item>
  19. </el-form>
  20. </template>
  21. <template #toolbar_buttons>
  22. <el-button type="primary" @click="onAdd" v-auth="'snapshot:info:sspConfig:add'"> <SvgIcon name="ele-Plus" class="mr5" />新增 </el-button>
  23. </template>
  24. <template #action="{ row }">
  25. <el-button link type="primary" @click="onEdit(row)" v-if="[0, 3].includes(row.bulletinState)" v-auth="'snapshot:info:sspConfig:edit'">
  26. 编辑
  27. </el-button>
  28. <el-button link type="danger" @click="onDelete(row)" v-if="[0].includes(row.bulletinState)" v-auth="'snapshot:info:sspConfig:delete'">
  29. 删除
  30. </el-button>
  31. <el-button
  32. link
  33. type="primary"
  34. @click="onCommit(row)"
  35. v-if="[0, 3].includes(row.bulletinState)"
  36. title="提交审批"
  37. v-auth="'snapshot:info:sspConfig:commit'"
  38. >
  39. 提交
  40. </el-button>
  41. <el-button
  42. link
  43. type="primary"
  44. @click="onShelfFn(row)"
  45. v-if="[2].includes(row.bulletinState) && !row.isArrive"
  46. v-auth="'snapshot:info:sspConfig:onShelf'"
  47. >
  48. 上架
  49. </el-button>
  50. <el-button
  51. link
  52. type="primary"
  53. @click="offShelfFn(row)"
  54. v-if="[2].includes(row.bulletinState) && row.isArrive"
  55. v-auth="'snapshot:info:sspConfig:offShelf'"
  56. >
  57. 下架
  58. </el-button>
  59. <el-button link type="primary" @click="onDetail(row)" v-if="[1, 2].includes(row.bulletinState)"> 查看详情 </el-button>
  60. </template>
  61. <template #pager>
  62. <pagination
  63. @pagination="queryList"
  64. :total="state.total"
  65. v-model:current-page="state.queryParams.PageIndex"
  66. v-model:page-size="state.queryParams.PageSize"
  67. :disabled="state.loading"
  68. />
  69. </template>
  70. </vxe-grid>
  71. </div>
  72. <!-- 更多查询 -->
  73. <el-drawer v-model="drawer" title="更多查询" size="500px">
  74. <el-form :model="state.queryParams" ref="drawerRuleFormRef" @submit.native.prevent label-width="100px" :disabled="gridOptions.loading">
  75. <el-form-item label="类别名称" prop="SnapshotBulletinTypeName">
  76. <el-input
  77. v-model="state.queryParams.SnapshotBulletinTypeName"
  78. placeholder="请填写类别名称"
  79. clearable
  80. @keyup.enter="handleQuery"
  81. class="keyword-input"
  82. />
  83. </el-form-item>
  84. <el-form-item label="文档编号" prop="No">
  85. <el-input v-model="state.queryParams.No" placeholder="请填写文档编号" clearable @keyup.enter="handleQuery" />
  86. </el-form-item>
  87. <el-form-item label="部门名称" prop="DepartmentName">
  88. <el-input v-model="state.queryParams.DepartmentName" placeholder="请填写部门名称" clearable @keyup.enter="handleQuery" />
  89. </el-form-item>
  90. <el-form-item label="发布人" prop="CreatorName">
  91. <el-input v-model="state.queryParams.CreatorName" placeholder="请填写发布人" clearable @keyup.enter="handleQuery" />
  92. </el-form-item>
  93. <el-form-item label="发布时间" prop="fbTime">
  94. <el-date-picker
  95. v-model="state.queryParams.fbTime"
  96. type="datetimerange"
  97. unlink-panels
  98. range-separator="至"
  99. start-placeholder="开始时间"
  100. end-placeholder="结束时间"
  101. :shortcuts="shortcuts"
  102. @change="handleQuery"
  103. value-format="YYYY-MM-DD[T]HH:mm:ss"
  104. :default-time="defaultTimeStartEnd"
  105. />
  106. </el-form-item>
  107. </el-form>
  108. <template #footer>
  109. <el-button type="primary" @click="handleQuery" :loading="state.loading"> <SvgIcon name="ele-Search" class="mr5" />查询 </el-button>
  110. <el-button @click="resetQuery(drawerRuleFormRef)" class="default-button"> <SvgIcon name="ele-Refresh" class="mr5" />重置 </el-button>
  111. </template>
  112. </el-drawer>
  113. <!-- 新增 -->
  114. <config-add ref="configAddRef" @updateList="queryList" />
  115. <!-- 修改 -->
  116. <config-edit ref="configEditRef" @updateList="queryList" />
  117. <!-- 详情 -->
  118. <config-detail ref="configDetailRef" @updateList="queryList" />
  119. </div>
  120. </template>
  121. <script lang="tsx" setup name="snapshotInfoSspConfig">
  122. import { defineAsyncComponent, onMounted, reactive, ref } from 'vue';
  123. import { ElMessage, ElMessageBox, FormInstance } from 'element-plus';
  124. import {
  125. delSnapshotBulletin,
  126. getSnapshotBulletinBaseData,
  127. getSnapshotBulletinExport,
  128. getSnapshotBulletinList,
  129. shelfSnapshotBulletin,
  130. submitSnapshotBulletin,
  131. } from '@/api/snapshot/info';
  132. import { defaultTimeStartEnd, shortcuts } from '@/utils/constants';
  133. import Other from '@/utils/other';
  134. // 引入组件
  135. const pagination = defineAsyncComponent(() => import('@/components/ProTable/components/Pagination.vue')); // 分页
  136. const ConfigAdd = defineAsyncComponent(() => import('@/views/snapshot/info/sspConfig/components/Config-add.vue')); // 新增
  137. const ConfigEdit = defineAsyncComponent(() => import('@/views/snapshot/info/sspConfig/components/Config-edit.vue')); // 编辑
  138. const ConfigDetail = defineAsyncComponent(() => import('@/views/snapshot/info/sspConfig/components/Config-detail.vue')); // 详情
  139. // 定义变量内容
  140. const state = reactive<any>({
  141. loading: false,
  142. queryParams: {
  143. // 查询参数
  144. PageIndex: 1,
  145. PageSize: 20,
  146. State: 0, // 审核状态 默认草稿
  147. SnapshotBulletinTypeName: null, // 类型名称
  148. Title: null, // 标题
  149. No: null, // 文档编号
  150. DepartmentName: null, // 部门名称
  151. CreatorName: null, // 发布人
  152. fbTime: [], // 发布时间
  153. BeginCreationTime: null,
  154. EndCreationTime: null,
  155. },
  156. total: 0, // 总条数
  157. });
  158. const requestParams = ref<EmptyObjectType>({});
  159. const gridOptions = reactive<any>({
  160. loading: false,
  161. border: true,
  162. showOverflow: true,
  163. columnConfig: {
  164. resizable: true,
  165. },
  166. scrollY: {
  167. enabled: true,
  168. gt: 100,
  169. },
  170. toolbarConfig: {
  171. zoom: true,
  172. custom: true,
  173. refresh: {
  174. queryMethod: () => {
  175. handleQuery();
  176. },
  177. },
  178. slots: {
  179. buttons: 'toolbar_buttons',
  180. },
  181. tools: [{ toolRender: { name: 'exportCurrent' } }, { toolRender: { name: 'exportAll' } }],
  182. },
  183. params: {
  184. exportMethod: getSnapshotBulletinExport,
  185. exportParams: requestParams,
  186. },
  187. customConfig: {
  188. storage: true,
  189. },
  190. id: 'snapshotConfigClue',
  191. rowConfig: { isHover: true, height: 30, isCurrent: true, useKey: true },
  192. height: 'auto',
  193. columns: [
  194. {
  195. field: 'snapshotBulletinTypeName',
  196. title: '类别名称',
  197. width: 150,
  198. },
  199. {
  200. field: 'title',
  201. title: '标题',
  202. minWidth: 200,
  203. slots: {
  204. default: ({ row }) => {
  205. return (
  206. <el-button link type="primary" onClick={() => onDetail(row)}>
  207. {row.title}
  208. </el-button>
  209. );
  210. },
  211. },
  212. },
  213. {
  214. field: 'no',
  215. title: '文档编码',
  216. width: 100,
  217. },
  218. {
  219. field: 'readedNum',
  220. title: '阅读次数',
  221. width: 100,
  222. },
  223. {
  224. field: 'departmentName',
  225. title: '部门名称',
  226. width: 140,
  227. },
  228. {
  229. field: 'creatorName',
  230. title: '发布人',
  231. width: 120,
  232. },
  233. {
  234. field: 'bulletinTime',
  235. title: '发布时间',
  236. width: 160,
  237. formatter: 'formatDate',
  238. },
  239. {
  240. field: 'isOpen',
  241. title: '是否公开',
  242. width: 100,
  243. slots: {
  244. default: ({ row }) => {
  245. return row.isOpen ? '是' : '否';
  246. },
  247. },
  248. },
  249. {
  250. field: 'isOpenWebsite',
  251. title: '网站公开',
  252. width: 100,
  253. slots: {
  254. default: ({ row }) => {
  255. return row.isOpenWebsite ? '是' : '否';
  256. },
  257. },
  258. },
  259. {
  260. field: 'isWeChat',
  261. title: '微信公开',
  262. width: 100,
  263. slots: {
  264. default: ({ row }) => {
  265. return row.isWeChat ? '是' : '否';
  266. },
  267. },
  268. },
  269. {
  270. field: 'isWeibo',
  271. title: '微博公开',
  272. width: 100,
  273. slots: {
  274. default: ({ row }) => {
  275. return row.isWeibo ? '是' : '否';
  276. },
  277. },
  278. },
  279. {
  280. field: 'bulletinStateText',
  281. title: '审批状态',
  282. width: 100,
  283. },
  284. { title: '操作', width: 200, fixed: 'right', showOverflow: false, align: 'center', slots: { default: 'action' } },
  285. ],
  286. data: [],
  287. });
  288. /** 搜索按钮操作 节流操作 */
  289. const handleQuery = () => {
  290. state.queryParams.PageIndex = 1;
  291. queryList();
  292. };
  293. // 获取参数列表
  294. const queryList = () => {
  295. state.loading = true;
  296. gridOptions.loading = true;
  297. requestParams.value = Other.deepClone(state.queryParams);
  298. requestParams.value.BeginCreationTime = state.queryParams.fbTime === null ? null : state.queryParams.fbTime[0]; // 受理时间
  299. requestParams.value.EndCreationTime = state.queryParams.fbTime === null ? null : state.queryParams.fbTime[1];
  300. Reflect.deleteProperty(requestParams.value, 'fbTime'); // 删除无用的参数
  301. getSnapshotBulletinList(requestParams.value)
  302. .then((res) => {
  303. state.loading = false;
  304. gridOptions.data = res.result.items ?? [];
  305. state.total = res.result.total ?? 0;
  306. gridOptions.loading = false;
  307. })
  308. .finally(() => {
  309. state.loading = false;
  310. gridOptions.loading = false;
  311. });
  312. };
  313. // 重置表单
  314. const drawerRuleFormRef = ref<RefType>();
  315. const ruleFormRef = ref<any>(null); // 表单ref
  316. const drawer = ref(false);
  317. const resetQuery = (formEl: FormInstance | undefined) => {
  318. if (!formEl) return;
  319. formEl.resetFields();
  320. ruleFormRef.value?.resetFields();
  321. queryList();
  322. };
  323. // 新增
  324. const configAddRef = ref<RefType>();
  325. const onAdd = () => {
  326. configAddRef.value.openDialog();
  327. };
  328. // 编辑
  329. const configEditRef = ref<RefType>();
  330. const onEdit = (row: any) => {
  331. configEditRef.value.openDialog(row.id);
  332. };
  333. // 删除
  334. const onDelete = (row: any) => {
  335. ElMessageBox.confirm(`您确定要删除:【${row.title}】,是否继续?`, '提示', {
  336. confirmButtonText: '确认',
  337. cancelButtonText: '取消',
  338. type: 'warning',
  339. draggable: true,
  340. cancelButtonClass: 'default-button',
  341. autofocus: false,
  342. })
  343. .then(() => {
  344. delSnapshotBulletin(row.id).then(() => {
  345. ElMessage.success('操作成功');
  346. queryList();
  347. });
  348. })
  349. .catch(() => {});
  350. };
  351. // 提交
  352. const onCommit = (row: any) => {
  353. ElMessageBox.confirm(`您确定要提交审批:【${row.title}】,是否继续?`, '提示', {
  354. confirmButtonText: '确认',
  355. cancelButtonText: '取消',
  356. type: 'warning',
  357. draggable: true,
  358. cancelButtonClass: 'default-button',
  359. autofocus: false,
  360. })
  361. .then(() => {
  362. submitSnapshotBulletin({ id: row.id }).then(() => {
  363. ElMessage.success('操作成功');
  364. queryList();
  365. });
  366. })
  367. .catch(() => {});
  368. };
  369. // 上架
  370. const onShelfFn = (row: any) => {
  371. ElMessageBox.confirm(`您确定要上架:【${row.title}】,是否继续?`, '提示', {
  372. confirmButtonText: '确认',
  373. cancelButtonText: '取消',
  374. type: 'warning',
  375. draggable: true,
  376. cancelButtonClass: 'default-button',
  377. autofocus: false,
  378. })
  379. .then(() => {
  380. shelfSnapshotBulletin({ id: row.id, isArrive: true }).then(() => {
  381. ElMessage.success('操作成功');
  382. queryList();
  383. });
  384. })
  385. .catch(() => {});
  386. };
  387. // 下架
  388. const offShelfFn = (row: any) => {
  389. ElMessageBox.confirm(`您确定要下架:【${row.title}】,是否继续?`, '提示', {
  390. confirmButtonText: '确认',
  391. cancelButtonText: '取消',
  392. type: 'warning',
  393. draggable: true,
  394. cancelButtonClass: 'default-button',
  395. autofocus: false,
  396. })
  397. .then(() => {
  398. shelfSnapshotBulletin({ id: row.id, isArrive: false }).then(() => {
  399. ElMessage.success('操作成功');
  400. queryList();
  401. });
  402. })
  403. .catch(() => {});
  404. };
  405. // 查看详情
  406. const configDetailRef = ref<RefType>();
  407. const onDetail = (row: any) => {
  408. configDetailRef.value.openDialog(row.id);
  409. };
  410. // 获取基础信息
  411. const bulletinState = ref<EmptyArrayType>([]);
  412. const getBaseInfo = async () => {
  413. try {
  414. const { result } = await getSnapshotBulletinBaseData();
  415. bulletinState.value = result.bulletinState;
  416. } catch (e) {
  417. console.log(e);
  418. }
  419. };
  420. // 页面加载时
  421. onMounted(() => {
  422. queryList();
  423. getBaseInfo();
  424. });
  425. </script>