NormalTable.vue 11 KB

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