NormalTable.vue 13 KB

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