NormalTable.vue 15 KB

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