NormalTable.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <template>
  2. <div>
  3. <BasicTable @register="registerTable" :key="resetTable">
  4. <template #actionSp="{ record }">
  5. <a class="table-action-link" @click="handleSpDetail(record)">审批详情</a>
  6. <!-- <a class="table-action-link" @click="handleTo(record)" :disabled="userName==record.createBy">提交</a>
  7. <a class="table-action-link" @click="handleSpRevoke(record)" :disabled="userName==record.createBy">撤回</a> -->
  8. <a class="table-action-link" @click="handleTo(record)">提交</a>
  9. <a class="table-action-link" @click="handleSpRevoke(record)">撤回</a>
  10. </template>
  11. <template #actionWj="{ record }">
  12. <a class="table-action-link" @click="handleEdit(record)">编辑</a>
  13. <a class="table-action-link" @click="handleDownLoad(record)">下载</a>
  14. <a-popconfirm title="确定删除?" @confirm="handleDelete(record)">
  15. <a class="table-action-link">删除</a>
  16. </a-popconfirm>
  17. <a class="table-action-link" @click="handlerJc(nodeParam.id)">{{ nodeParam.id=='1600000000000000001' ? '粉尘报表分析' : nodeParam.id=='1500000000000000002' ? '束管报表分析' : nodeParam.id=='1500000000000000003' ? '束管色谱仪分析' : nodeParam.id=='1400000000000000003' || nodeParam.id=='1400000000000000002' ? '瓦斯日报巡检分析' : '' }}</a>
  18. </template>
  19. <template #bodyCell="{ column, record }">
  20. <slot name="filterCell" v-bind="{ column, record }"></slot>
  21. </template>
  22. </BasicTable>
  23. <DeviceModal :editID="editID" :fileType="fileType" @register="registerDeviceModal" />
  24. <CADModal :fileid="editID" @register="registerCADModal" />
  25. <!-- 审批-提交弹窗 -->
  26. <a-modal v-model:visible="visibleTj" centered :width="600" title="提交文件" @ok="handleTjOk" @cancel="handleTjCancel">
  27. <a-form :model="formStateTj" labelAlign="right" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }">
  28. <a-form-item label="选择审批" :rules="[{ required: true, message: '请选择是否提交' }]">
  29. <a-select v-model:value="formStateTj.file" style="width: 260px">
  30. <a-select-option v-for="file in fileList" :key="file.label" :value="file.value">{{ file.label }}</a-select-option>
  31. </a-select>
  32. </a-form-item>
  33. </a-form>
  34. </a-modal>
  35. <!-- 审批详情弹窗 -->
  36. <a-modal v-model:visible="visibleSp" width="1000px" :footer="null" :title="titleSp" centered destroyOnClose>
  37. <HistorySp :historySpList="historySpList" :imgSrc="imgSrc" :isShow="isShow" :spInfo="spInfo" @spClose="spClose" />
  38. </a-modal>
  39. <!-- 审批-撤销申请弹窗 -->
  40. <a-modal v-model:visible="visibleCx" centered :width="600" title="撤销申请" @ok="handleCxOk" @cancel="handleCxCancel">
  41. <a-textarea
  42. v-model:value="revokeDes"
  43. placeholder="请输入撤回原因..."
  44. :rows="4"
  45. style="width: 96%; margin: 10px; background-color: transparent; color: #fff"
  46. />
  47. </a-modal>
  48. </div>
  49. </template>
  50. <script lang="ts" name="system-user" setup>
  51. //ts语法
  52. import { ref, provide, reactive, toRaw, defineExpose, unref } from 'vue';
  53. import { BasicTable, TableAction } from '/@/components/Table';
  54. import DeviceModal from './DeviceModal.vue';
  55. import CADModal from './CADModal.vue';
  56. import HistorySp from './HistorySp.vue';
  57. import { useModal } from '/@/components/Modal';
  58. import { getTableHeaderColumns } from '/@/hooks/web/useWebColumns';
  59. import { useListPage } from '/@/hooks/system/useListPage';
  60. import { commit } from '../fileDetail/fileDetail.api';
  61. import { historicFlowNew, getHighlightImgNew, getTodoTask, getCancelNew } from './comment.api';
  62. import { message } from 'ant-design-vue';
  63. import { useUserStore } from '/@/store/modules/user';
  64. import {useRouter} from 'vue-router'
  65. const props = defineProps({
  66. //文件审批-提交信息
  67. submitInfo: {
  68. type: Array,
  69. default: () => {
  70. return [];
  71. },
  72. },
  73. //各矿参数
  74. selfParam: {
  75. type: Object,
  76. default: () => {
  77. return {};
  78. },
  79. },
  80. //查询参数
  81. searchParam: {
  82. type: Object,
  83. default: () => {
  84. return {};
  85. },
  86. },
  87. //菜单树传递参数
  88. nodeParam: {
  89. type: Object,
  90. default: () => {
  91. return {};
  92. },
  93. },
  94. columnsType: {
  95. type: String,
  96. // required: true,
  97. },
  98. columns: {
  99. type: Array,
  100. // required: true,
  101. default: () => [],
  102. },
  103. list: {
  104. type: Function,
  105. required: true,
  106. },
  107. //下载文件接口
  108. downLoad: {
  109. type: Function,
  110. required: true,
  111. },
  112. deleteById: {
  113. type: Function,
  114. required: true,
  115. },
  116. pointList: {
  117. type: Function,
  118. // required: true,
  119. },
  120. designScope: {
  121. type: String,
  122. },
  123. title: {
  124. type: String,
  125. },
  126. });
  127. let router = useRouter(); //路由
  128. let resetTable = ref(0);
  129. let fileType = ref(''); //文件类型
  130. let editID = ref(0); //文件ID
  131. const isUpdate = ref(false);
  132. const record = reactive<Record<string, any>>({});
  133. provide('formData', record);
  134. const [registerDeviceModal, { openModal, closeModal }] = useModal();
  135. const columnList = getTableHeaderColumns(props.columnsType);
  136. //是否显示文件审批弹窗
  137. let visibleTj = ref(false);
  138. //文件审批-弹窗参数
  139. let formStateTj = reactive({
  140. file: '',
  141. id: '',
  142. });
  143. //文件审批-提交信息弹窗下拉选项数据
  144. let fileList = reactive<any[]>([]);
  145. //审批详情弹窗数据
  146. let visibleSp = ref(false);
  147. let titleSp = ref('审批详情');
  148. //审批详情历史数据
  149. let historySpList = reactive<any[]>([]);
  150. let imgSrc = ref('');
  151. //审批-是否显示撤回/驳回按钮
  152. let isShow = ref(true);
  153. //审批通过/驳回参数信息
  154. let spInfo = reactive({});
  155. //审批-撤销
  156. let visibleCx = ref(false);
  157. let revokeDes = ref('');
  158. let cxInfo = reactive({});
  159. let userStore = useUserStore(); //获取用户信息
  160. let userName = unref(userStore.getUserInfo).username;
  161. // 列表页面公共参数、方法
  162. const { tableContext, doRequest } = useListPage({
  163. designScope: props.designScope,
  164. tableProps: {
  165. title: props.title,
  166. api: props.list,
  167. columns: props.columns.length > 0 ? (props.columns as any[]) : columnList,
  168. // size: 'small',
  169. bordered: false,
  170. scroll: { y: 620 },
  171. // formConfig: {
  172. // // labelWidth: 100,
  173. // labelAlign: 'left',
  174. // labelCol: {
  175. // xs: 24,
  176. // sm: 24,
  177. // md: 24,
  178. // lg: 9,
  179. // xl: 7,
  180. // xxl: 5,
  181. // },
  182. // schemas: props.searchFormSchema as any[],
  183. // },
  184. striped: true,
  185. showIndexColumn: true, //是否显示序列号
  186. // actionColumn: {
  187. // width: 200,
  188. // },
  189. showActionColumn: false,
  190. useSearchForm: false, //不使用查询条件
  191. // pagination: false, //不使用分页组件
  192. beforeFetch: (params) => {
  193. params.parentId = props.nodeParam.id ? props.nodeParam.id : '';
  194. params.selectFlag = props.nodeParam.id ? false : true;
  195. params.likeFileName = props.searchParam.fileName ? props.searchParam.fileName : '';
  196. params.fileSuffix = props.searchParam.fileType ? '.' + props.searchParam.fileType : '';
  197. params.bpmStatus = props.selfParam.bpmStatus ? props.selfParam.bpmStatus : '';
  198. params.sysOrgCode = props.selfParam.sysOrgCode ? props.selfParam.sysOrgCode : '';
  199. },
  200. },
  201. });
  202. //注册table数据
  203. const [registerTable, { reload }, { selectedRowKeys }] = tableContext;
  204. // 审批提交
  205. function handleTo(data) {
  206. visibleTj.value = true;
  207. fileList.length = 0;
  208. props.submitInfo.forEach((el) => {
  209. fileList.push({ label: el.name, value: el.id });
  210. });
  211. formStateTj.id = data.id;
  212. }
  213. //确认提交
  214. async function handleTjOk() {
  215. if (formStateTj.file) {
  216. let res = await commit({ procDefId: formStateTj.file, tableId: formStateTj.id, firstGateway: true });
  217. if (res == '提交成功') {
  218. message.success(res);
  219. visibleTj.value = false;
  220. resetTable.value = new Date().getTime();
  221. } else {
  222. message.warning(res.message);
  223. }
  224. } else {
  225. message.warning('请先选择要提交的文件!');
  226. }
  227. }
  228. //取消提交
  229. function handleTjCancel() {
  230. formStateTj.file = '';
  231. visibleTj.value = false;
  232. }
  233. //审批详情点击
  234. function handleSpDetail(data) {
  235. visibleSp.value = true;
  236. getTodoTaskShow({ tableId: data.id, tableName: data.tableName });
  237. getHistoricFlowNewList({ tableId: data.id, tableName: data.tableName });
  238. getHighlightImgNewList({ tableId: data.id, tableName: data.tableName });
  239. }
  240. //审批详情-审批历史列表
  241. async function getHistoricFlowNewList(params) {
  242. historySpList.length = 0;
  243. let res = await historicFlowNew({ ...params });
  244. if (res.length != 0) {
  245. res.forEach((el) => {
  246. historySpList.push({
  247. name: el.name,
  248. username: el.assignees[0].username,
  249. deleteReason: el.deleteReason,
  250. comment: el.comment,
  251. startTime: el.startTime,
  252. endTime: el.endTime,
  253. status: el.assignees[0].isExecutor ? '已处理' : '待处理',
  254. });
  255. });
  256. }
  257. }
  258. //审批详情-流程轨迹
  259. async function getHighlightImgNewList(params) {
  260. let res = await getHighlightImgNew({ ...params });
  261. let imageUrl = window.URL.createObjectURL(res);
  262. imgSrc.value = imageUrl;
  263. }
  264. //判断是否显示撤回/驳回按钮
  265. async function getTodoTaskShow(params) {
  266. let res = await getTodoTask({ ...params });
  267. spInfo = Object.assign({}, res);
  268. if (res.result) {
  269. isShow.value = true;
  270. } else {
  271. isShow.value = false;
  272. }
  273. }
  274. //审批通过/驳回弹窗关闭
  275. function spClose() {
  276. visibleSp.value = false;
  277. resetTable.value = new Date().getTime();
  278. }
  279. //审批-撤回提交
  280. function handleSpRevoke(data) {
  281. visibleCx.value = true;
  282. cxInfo = Object.assign({}, data);
  283. }
  284. //审批-撤销-确定
  285. async function handleCxOk() {
  286. let res = await getCancelNew({ reason: revokeDes.value, tableId: cxInfo.id, tableName: cxInfo.tableName });
  287. if (res == '操作成功') {
  288. message.success(res);
  289. } else {
  290. message.warning(res.message);
  291. }
  292. visibleCx.value = false;
  293. revokeDes.value = '';
  294. resetTable.value = new Date().getTime();
  295. }
  296. //审批-撤销-取消
  297. function handleCxCancel() {
  298. revokeDes.value = '';
  299. visibleCx.value = false;
  300. }
  301. /**
  302. * 编辑事件
  303. */
  304. function handleEdit(data) {
  305. isUpdate.value = true;
  306. Object.assign(record, toRaw(data));
  307. let index = record.fileSuffix.indexOf('.');
  308. fileType.value = record.fileSuffix.substring(index + 1);
  309. editID.value = record.id;
  310. // 根据文件后缀名打开不同的模态框
  311. if (['.dwg', '.mxcad'].includes(data.fileSuffix)) {
  312. openCADModal(true, {
  313. record,
  314. });
  315. } else {
  316. openModal(true, {
  317. record,
  318. });
  319. }
  320. }
  321. /**
  322. * 删除事件
  323. */
  324. async function handleDelete(record) {
  325. await props.deleteById({ id: record.id }, reload);
  326. }
  327. //下载文件
  328. function handleDownLoad(record) {
  329. props.downLoad({ id: record.id }).then((res) => {
  330. let filename = `${record.fileName}`;
  331. downFilePublic(res, filename);
  332. });
  333. }
  334. // 下载公用方法
  335. function downFilePublic(content, fileName) {
  336. const blob = new Blob([content], { type: 'application/xlsx;charset=UTF-8' }); // 构造一个blob对象来处理数据
  337. // 对于<a>标签,只有 Firefox 和 Chrome(内核) 支持 download 属性
  338. // IE10以上支持blob但是依然不支持download
  339. if ('download' in document.createElement('a')) {
  340. // 支持a标签download的浏览器
  341. const link = document.createElement('a'); // 创建a标签
  342. link.download = fileName; // a标签添加属性
  343. link.style.display = 'none';
  344. link.href = URL.createObjectURL(blob);
  345. document.body.appendChild(link);
  346. link.click(); // 执行下载
  347. URL.revokeObjectURL(link.href); // 释放url
  348. document.body.removeChild(link); // 释放标签
  349. } else {
  350. // 其他浏览器
  351. navigator.msSaveBlob(blob, fileName);
  352. }
  353. }
  354. //报表监测跳转
  355. function handlerJc(data){
  356. switch(data){
  357. case '1600000000000000001':
  358. //粉尘报表
  359. router.push('/dust/dustMonitorTable')
  360. break;
  361. case '1500000000000000002':
  362. //束管日报
  363. router.push('/bundle/bundleTable')
  364. break;
  365. case '1500000000000000003':
  366. //束管色谱仪
  367. router.push('/bundleSpy/bundleSpyTable')
  368. break;
  369. case '1400000000000000002':
  370. //瓦斯日报巡检分析
  371. router.push('/gas/gas-report-inspect')
  372. break;
  373. case '1400000000000000003':
  374. //瓦斯日报巡检分析
  375. router.push('/gas/gas-report-inspect')
  376. break;
  377. }
  378. }
  379. // CAD预览相关的逻辑
  380. const [registerCADModal, { openModal: openCADModal }] = useModal();
  381. defineExpose({
  382. doRequest,
  383. });
  384. </script>
  385. <style scoped lang="less">
  386. @ventSpace: zxm;
  387. @vent-table-no-hover: #00bfff10;
  388. :deep(.@{ventSpace}-table-cell-row-hover) {
  389. background: #264d8833 !important;
  390. }
  391. :deep(.@{ventSpace}-table-row-selected) {
  392. background: #268bc522 !important;
  393. }
  394. :deep(.@{ventSpace}-table-tbody > tr > td) {
  395. background-color: #0dc3ff05;
  396. }
  397. :deep(.jeecg-basic-table-row__striped) {
  398. td {
  399. background-color: @vent-table-no-hover !important;
  400. }
  401. }
  402. ::v-deep .zxm-table-title {
  403. display: none;
  404. }
  405. .zxm-form {
  406. padding-top: 20px !important;
  407. box-sizing: border-box;
  408. }
  409. a[disabled] {
  410. color: #ccc;
  411. }
  412. </style>