NormalTable.vue 15 KB

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