NormalTable.vue 11 KB

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