NormalTable.vue 14 KB

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