NormalTable.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <div>
  3. <BasicTable @register="registerTable">
  4. <template #action="{ record }">
  5. <!-- <TableAction :actions="getActions(record)" :dropDownActions="getDropDownAction(record)" /> -->
  6. <a class="table-action-link" @click="handleTo(record)">提交</a>
  7. <a class="table-action-link" @click="handleEdit(record)">编辑</a>
  8. <a-popconfirm title="确定删除?" @confirm="handleDelete(record)">
  9. <a class="table-action-link">删除</a>
  10. </a-popconfirm>
  11. <a class="table-action-link" @click="handleDownLoad(record)">下载</a>
  12. <a class="table-action-link" @click="handleSpDetail(record)">审批详情</a>
  13. </template>
  14. <template #bodyCell="{ column, record }">
  15. <slot name="filterCell" v-bind="{ column, record }"></slot>
  16. </template>
  17. </BasicTable>
  18. <DeviceModal :editID="editID" :fileType="fileType" @register="registerDeviceModal" />
  19. <CADModal @register="registerCADModal" />
  20. <!-- 审批-提交弹窗 -->
  21. <a-modal v-model:visible="visibleTj" centered :width="600" title="提交文件" @ok="handleTjOk" @cancel="handleTjCancel">
  22. <a-form :model="formStateTj" labelAlign="right" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }">
  23. <a-form-item label="选择文件" :rules="[{ required: true, message: '请选择是否提交' }]">
  24. <a-select v-model:value="formStateTj.file" style="width: 260px">
  25. <a-select-option v-for="file in fileList " :key="file.label" :value="file.value">{{ file.label
  26. }}</a-select-option>
  27. </a-select>
  28. </a-form-item>
  29. </a-form>
  30. </a-modal>
  31. <!-- 审批详情弹窗 -->
  32. <a-modal v-model:visible="visibleSp" width="1000px" :footer="null" :title="titleSp" centered destroyOnClose>
  33. <HistorySp :historySpList="historySpList" :imgSrc="imgSrc"></HistorySp>
  34. </a-modal>
  35. </div>
  36. </template>
  37. <script lang="ts" name="system-user" setup>
  38. //ts语法
  39. import { ref, provide, reactive, toRaw, defineExpose } from 'vue';
  40. import { BasicTable, TableAction } from '/@/components/Table';
  41. import DeviceModal from './DeviceModal.vue';
  42. import CADModal from './CADModal.vue';
  43. import HistorySp from './HistorySp.vue'
  44. import { useModal } from '/@/components/Modal';
  45. import { getTableHeaderColumns } from '/@/hooks/web/useWebColumns';
  46. import { useListPage } from '/@/hooks/system/useListPage';
  47. import { commit } from '../fileDetail/fileDetail.api'
  48. import {historicFlowNew,getHighlightImgNew} from './comment.api'
  49. import { message } from 'ant-design-vue';
  50. const props = defineProps({
  51. //文件审批-提交信息
  52. submitInfo: {
  53. type: Array,
  54. default: () => {
  55. return []
  56. }
  57. },
  58. //各矿参数
  59. selfParam: {
  60. type: Object,
  61. default: () => {
  62. return {};
  63. },
  64. },
  65. //查询参数
  66. searchParam: {
  67. type: String,
  68. default: '',
  69. },
  70. //菜单树传递参数
  71. nodeParam: {
  72. type: Object,
  73. default: () => {
  74. return {};
  75. },
  76. },
  77. columnsType: {
  78. type: String,
  79. // required: true,
  80. },
  81. columns: {
  82. type: Array,
  83. // required: true,
  84. default: () => [],
  85. },
  86. list: {
  87. type: Function,
  88. required: true,
  89. },
  90. //下载文件接口
  91. downLoad: {
  92. type: Function,
  93. required: true,
  94. },
  95. deleteById: {
  96. type: Function,
  97. required: true,
  98. },
  99. pointList: {
  100. type: Function,
  101. // required: true,
  102. },
  103. designScope: {
  104. type: String,
  105. },
  106. title: {
  107. type: String,
  108. },
  109. });
  110. let fileType = ref(''); //文件类型
  111. let editID = ref(0); //文件ID
  112. const isUpdate = ref(false);
  113. const record = reactive<Record<string, any>>({});
  114. provide('formData', record);
  115. const [registerDeviceModal, { openModal, closeModal }] = useModal();
  116. const columnList = getTableHeaderColumns(props.columnsType);
  117. //是否显示文件审批弹窗
  118. let visibleTj = ref(false)
  119. //文件审批-弹窗参数
  120. let formStateTj = reactive({
  121. file: '',
  122. id: '',
  123. })
  124. //文件审批-提交信息弹窗下拉选项数据
  125. let fileList = reactive<any[]>([])
  126. //审批详情弹窗数据
  127. let visibleSp = ref(false)
  128. let titleSp = ref('审批详情')
  129. //审批详情历史数据
  130. let historySpList = reactive<any[]>([])
  131. let imgSrc=ref('')
  132. // 列表页面公共参数、方法
  133. const { tableContext, doRequest } = useListPage({
  134. designScope: props.designScope,
  135. tableProps: {
  136. title: props.title,
  137. api: props.list,
  138. columns: props.columns.length > 0 ? (props.columns as any[]) : columnList,
  139. // size: 'small',
  140. bordered: false,
  141. scroll: { y: 620 },
  142. // formConfig: {
  143. // // labelWidth: 100,
  144. // labelAlign: 'left',
  145. // labelCol: {
  146. // xs: 24,
  147. // sm: 24,
  148. // md: 24,
  149. // lg: 9,
  150. // xl: 7,
  151. // xxl: 5,
  152. // },
  153. // schemas: props.searchFormSchema as any[],
  154. // },
  155. striped: true,
  156. showIndexColumn: true, //是否显示序列号
  157. actionColumn: {
  158. width: 400,
  159. },
  160. useSearchForm: false, //不使用查询条件
  161. // pagination: false, //不使用分页组件
  162. beforeFetch: (params) => {
  163. params.parentId = props.nodeParam.id ? props.nodeParam.id : '';
  164. params.selectFlag = props.nodeParam.id ? false : true;
  165. params.likeFileName = props.searchParam ? props.searchParam : '';
  166. params.bpmStatus = props.selfParam.bpmStatus ? props.selfParam.bpmStatus : '';
  167. params.sysOrgCode = props.selfParam.sysOrgCode ? props.selfParam.sysOrgCode : '';
  168. },
  169. },
  170. });
  171. //注册table数据
  172. const [registerTable, { reload }, { selectedRowKeys }] = tableContext;
  173. // 审批提交
  174. function handleTo(data) {
  175. visibleTj.value = true
  176. fileList.length = 0
  177. props.submitInfo.forEach(el => {
  178. fileList.push({ label: el.name, value: el.id })
  179. })
  180. formStateTj.id = data.id
  181. }
  182. //确认提交
  183. async function handleTjOk() {
  184. if (formStateTj.file) {
  185. let res = await commit({ procDefId: formStateTj.file, tableId: formStateTj.id, firstGateway: true })
  186. if (res == '提交成功') {
  187. message.success(res);
  188. visibleTj.value = false
  189. }
  190. } else {
  191. message.warning('请先选择要提交的文件!');
  192. }
  193. }
  194. //取消提交
  195. function handleTjCancel() {
  196. formStateTj.file = ''
  197. visibleTj.value = false
  198. }
  199. //审批详情点击
  200. function handleSpDetail(data) {
  201. visibleSp.value = true
  202. getHistoricFlowNewList({tableId:data.id,tableName:data.tableName})
  203. getHighlightImgNewList({tableId:data.id,tableName:data.tableName})
  204. }
  205. //审批详情-审批历史列表
  206. async function getHistoricFlowNewList(params) {
  207. let res = await historicFlowNew({...params})
  208. if (res.length != 0) {
  209. historySpList.length = 0
  210. res.forEach(el => {
  211. historySpList.push({ name: el.name, username: el.assignees[0].username, deleteReason: el.deleteReason, comment: el.comment, startTime: el.startTime, endTime: el.endTime,status:el.status||'待处理' })
  212. })
  213. }
  214. }
  215. //审批详情-流程轨迹
  216. async function getHighlightImgNewList(params){
  217. let res=await getHighlightImgNew({...params})
  218. let imageUrl = window.URL.createObjectURL(res);
  219. imgSrc.value=imageUrl
  220. }
  221. /**
  222. * 编辑事件
  223. */
  224. function handleEdit(data) {
  225. isUpdate.value = true;
  226. Object.assign(record, toRaw(data));
  227. let index = record.fileSuffix.indexOf('.');
  228. fileType.value = record.fileSuffix.substring(index + 1);
  229. editID.value = record.id;
  230. // 根据文件后缀名打开不同的模态框
  231. if (['.dwg', '.mxcad'].includes(data.fileSuffix)) {
  232. openCADModal(true, {
  233. record,
  234. });
  235. } else {
  236. openModal(true, {
  237. record,
  238. });
  239. }
  240. }
  241. /**
  242. * 删除事件
  243. */
  244. async function handleDelete(record) {
  245. await props.deleteById({ id: record.id }, reload);
  246. }
  247. //下载文件
  248. function handleDownLoad(record) {
  249. props.downLoad({ id: record.id }).then((res) => {
  250. let filename = `${record.fileName}`;
  251. downFilePublic(res, filename);
  252. });
  253. }
  254. // 下载公用方法
  255. function downFilePublic(content, fileName) {
  256. const blob = new Blob([content], { type: 'application/xlsx;charset=UTF-8' }); // 构造一个blob对象来处理数据
  257. // 对于<a>标签,只有 Firefox 和 Chrome(内核) 支持 download 属性
  258. // IE10以上支持blob但是依然不支持download
  259. if ('download' in document.createElement('a')) {
  260. // 支持a标签download的浏览器
  261. const link = document.createElement('a'); // 创建a标签
  262. link.download = fileName; // a标签添加属性
  263. link.style.display = 'none';
  264. link.href = URL.createObjectURL(blob);
  265. document.body.appendChild(link);
  266. link.click(); // 执行下载
  267. URL.revokeObjectURL(link.href); // 释放url
  268. document.body.removeChild(link); // 释放标签
  269. } else {
  270. // 其他浏览器
  271. navigator.msSaveBlob(blob, fileName);
  272. }
  273. }
  274. // CAD预览相关的逻辑
  275. const [registerCADModal, { openModal: openCADModal }] = useModal();
  276. defineExpose({
  277. doRequest,
  278. });
  279. </script>
  280. <style scoped lang="less">
  281. @ventSpace: zxm;
  282. @vent-table-no-hover: #00bfff10;
  283. :deep(.@{ventSpace}-table-cell-row-hover) {
  284. background: #264d8833 !important;
  285. }
  286. :deep(.@{ventSpace}-table-row-selected) {
  287. background: #268bc522 !important;
  288. }
  289. :deep(.@{ventSpace}-table-tbody > tr > td) {
  290. background-color: #0dc3ff05;
  291. }
  292. :deep(.jeecg-basic-table-row__striped) {
  293. td {
  294. background-color: @vent-table-no-hover !important;
  295. }
  296. }
  297. ::v-deep .zxm-table-title {
  298. display: none;
  299. }
  300. .zxm-form {
  301. padding-top: 20px !important;
  302. box-sizing: border-box;
  303. }
  304. </style>