NormalTable.vue 11 KB

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