index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <template>
  2. <div>
  3. <BasicTable :rowSelection="{ type: 'checkbox' }" @register="registerTable" :clickToRowSelect="false" class="zjsqkList">
  4. <template #toolbar>
  5. <Authority>
  6. <a-button style="background-color: rgb(252, 139, 1); color: rgb(255, 255, 255);border: none;" type="primary"
  7. @click="handleCreate">提交申请</a-button>
  8. </Authority>
  9. <!-- <Authority>
  10. <Popconfirm title="您确定要批量删除数据" ok-text="确定" cancel-text="取消" @confirm="handleDeleteOrBatchDelete(null)">
  11. <a-button type="primary" color="error" :disabled="hasBatchDelete"> 批量删除 </a-button>
  12. </Popconfirm>
  13. </Authority> -->
  14. </template>
  15. <!-- <template #status="{ record }">
  16. <Switch :checked="record.status === 1" :loading="record.pendingStatus" checkedChildren="启用" unCheckedChildren="禁用"
  17. @change="(checked: boolean) => statusChange(checked, record)" />
  18. </template> -->
  19. <template #action="{ record }">
  20. <TableAction :actions="[
  21. // {
  22. // label: '浏览',
  23. // icon: '' /**clarity:note-edit-line*/,
  24. // // ifShow: record.servicealiasname,
  25. // // ifShow: ((action) => action.servicealiasname),
  26. // ifShow: record.servicealiasname,
  27. // onClick: see.bind(null, record),
  28. // },
  29. // {
  30. // label: '查看',
  31. // icon: '' /**clarity:note-edit-line*/,
  32. // onClick: handleEdit.bind(null, record),
  33. // },
  34. // {
  35. // label: '编辑',
  36. // icon: '' /**clarity:note-edit-line*/,
  37. // color: 'warning',
  38. // onClick: handleEdit.bind(null, record),
  39. // },
  40. // {
  41. // label: '删除',
  42. // icon: '' /**ant-design:delete-outlined'*/,
  43. // color: 'error',
  44. // ifShow: record.roleType != RoleEnum.SYS_ADMIN,
  45. // popConfirm: {
  46. // title: '是否确认删除',
  47. // confirm: handleDelete.bind(null, record),
  48. // },
  49. // },
  50. {
  51. label: '提交申请',
  52. icon: '' /**clarity:note-edit-line*/,
  53. // ifShow: record.servicealiasname,
  54. // ifShow: ((action) => action.servicealiasname),
  55. disabled: record.shzt != '未提交' && record.shzt != '审核不通过',
  56. // onClick: submitApply.bind(null, record),
  57. onClick: applyHandleEdit.bind(null, record),
  58. },
  59. {
  60. label: '移出',
  61. tooltip: '移出',
  62. // icon: 'ant-design:form-outlined',
  63. onClick: handleDelete.bind(null, record),
  64. disabled: record.shzt != '未提交' && record.shzt != '审核不通过'
  65. },
  66. ]" />
  67. </template>
  68. <template #pdate="{ record }">
  69. <Tag :color="'red'">
  70. {{
  71. record.publishdate ? moment(record.publishdate).format('YYYY-MM-DD HH:mm:ss') : ''
  72. }}
  73. </Tag>
  74. </template>
  75. <template #systemkey="{ record }">
  76. <span :id="'zjsqk' + record.id">{{ getAppName(record.systemkey, `zjsqk${record.id}`) }}</span>
  77. </template>
  78. <template #shr="{ record }">
  79. <span :id="'shr' + record.id">{{ getUser(record, `shr${record.id}`) }}</span>
  80. </template>
  81. <template #tjsqsj="{ record }">
  82. {{ record?.tjsqsj?.replace('.0', '') }}
  83. </template>
  84. <template #shyj="{ record }">
  85. <span :id="'shyj' + record.id">{{ getYJ(record, `shyj${record.id}`) }}</span>
  86. </template>
  87. <template #index="{ index }">
  88. {{ index + 1 }}
  89. </template>
  90. <template #status="{ record }">
  91. <Tag :style="`color:${record.shzt == '未提交' ? 'red' : '#05B069'};`">
  92. {{
  93. record.shzt
  94. }}
  95. </Tag>
  96. </template>
  97. </BasicTable>
  98. <MapSourceModal @register="registerModal" @success="handleSuccess" />
  99. <!-- 申请弹出框 -->
  100. <ApplyModal @register="registerModal" @success="applyHandleSuccess" />
  101. </div>
  102. </template>
  103. <script lang="ts">
  104. import { defineComponent, nextTick, onBeforeMount, createVNode, onMounted } from 'vue';
  105. import { BasicTable, useTable, TableAction } from '/@/components/Table';
  106. import { delRole, setRoleStatus } from '/@/api/system/system';
  107. import { useModal } from '/@/components/Modal';
  108. import MapDrawer from './MapDrawer.vue';
  109. import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
  110. import MapSourceModal from './MapSourceModal.vue';
  111. import { columns, searchFormSchema } from './lib.data';
  112. import { RoleEnum } from '/@/enums/roleEnum';
  113. import { Authority } from '/@/components/Authority';
  114. import { useBatchDelete } from '/@/hooks/web/useBatchDelete';
  115. import { useMessage } from '/@/hooks/web/useMessage';
  116. import { Switch, Popconfirm, message, Modal } from 'ant-design-vue';
  117. import { getAssemblyLibs } from '/@/api/dataAdmin/assembly';
  118. //操作申请库资源
  119. import Moment from 'moment'
  120. import { queryFlowInfoPage, submitExamine } from '/@/api/resource/examine';
  121. import { deleteResInCar } from '/@/api/resource/plat';
  122. import eventBus from '/@/utils/eventBus';
  123. import ApplyModal from './applyModal/ApplyModal.vue';
  124. import { list } from '/@/api/authorize/authorize';
  125. export default defineComponent({
  126. name: 'RoleManagement',
  127. components: { BasicTable, MapDrawer, ApplyModal, MapSourceModal, TableAction, Authority, Switch, Popconfirm },
  128. setup() {
  129. const [registerModal, { openModal }] = useModal();
  130. const [registerTable, { setProps, reload, setSelectedRowKeys, getSelectRows, getSelectRowKeys }] = useTable({
  131. title: '组件资源列表',
  132. api: getAssemblyLibs,
  133. columns,
  134. formConfig: {
  135. labelWidth: 100,
  136. schemas: searchFormSchema,
  137. },
  138. useSearchForm: true,
  139. showTableSetting: true,
  140. bordered: true,
  141. showIndexColumn: false,
  142. actionColumn: {
  143. width: 170,
  144. title: '操作',
  145. dataIndex: 'action',
  146. slots: { customRender: 'action' },
  147. fixed: 'right',
  148. },
  149. rowSelection: { type: 'checkbox' },
  150. rowKey: (record) => record.id,
  151. tableSetting: {
  152. redo: true,
  153. size: true,
  154. setting: false,
  155. fullScreen: false
  156. },
  157. });
  158. const moment = Moment
  159. const { createMessage } = useMessage();
  160. const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } =
  161. useBatchDelete(delRole, handleSuccess, setProps);
  162. selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => {
  163. // Demo:status为1的选择框禁用
  164. if (record.status === 1) {
  165. return { disabled: true };
  166. } else {
  167. return { disabled: false };
  168. }
  169. };
  170. nextTick(() => {
  171. setProps(selectionOptions);
  172. });
  173. function handleEdit(record: Recordable) {
  174. openModal(true, {
  175. record,
  176. isUpdate: true,
  177. });
  178. }
  179. function see(e) {
  180. console.log(e);
  181. if (e.servicealiasname) window.open(`../../mapview.html?onlineIde_${e.servicealiasname}`, '_blank');
  182. }
  183. //组件资源移出申请库
  184. const handleDelete = (record) => {
  185. console.log(record);
  186. Modal.confirm({
  187. title: '移出提示',
  188. icon: createVNode(ExclamationCircleOutlined),
  189. content: '确定移出该资源?',
  190. centered: true,
  191. okText: '确定',
  192. okType: 'danger',
  193. cancelText: '取消',
  194. onOk: (() => {
  195. deleteResInCar({
  196. idList: [record.applyCarInfo.id]
  197. }, { resInCarId: record.applyCarInfo.id }).then(() => applyHandleSuccess())
  198. })
  199. });
  200. }
  201. function handleSuccess() {
  202. openModal(false, {
  203. isUpdate: false,
  204. });
  205. reload();
  206. }
  207. /**
  208. * 申请成功
  209. */
  210. function applyHandleSuccess() {
  211. reload();
  212. eventBus.emit('assemblyCenter')
  213. eventBus.emit('getAssemblyLibsTotal')
  214. }
  215. const statusChange = async (checked, record) => {
  216. setProps({
  217. loading: true,
  218. });
  219. setSelectedRowKeys([]);
  220. resetSelectedRowKeys();
  221. const newStatus = checked ? 1 : 0;
  222. try {
  223. await setRoleStatus(record.id, newStatus);
  224. if (newStatus) {
  225. createMessage.success(`启用成功`);
  226. } else {
  227. createMessage.success('禁用成功');
  228. }
  229. } finally {
  230. setProps({
  231. loading: false,
  232. });
  233. reload();
  234. }
  235. };
  236. /**
  237. * 申请弹出框
  238. * @param record
  239. */
  240. function handleCreate() {
  241. var list = getSelectRowKeys();
  242. openModal(true, {
  243. isUpdate: false,
  244. sqzys: list
  245. });
  246. }
  247. /**
  248. * 申请弹出框
  249. * @param record
  250. */
  251. function applyHandleEdit(record: Recordable) {
  252. openModal(true, {
  253. record,
  254. isUpdate: true,
  255. sqzys: [record.resInfo.SERVICEID]
  256. });
  257. }
  258. eventBus.on("assemblyReload", () => reload())
  259. function submitApply(e) {
  260. console.log("submitApply:", e)
  261. queryFlowInfoPage({
  262. page: 1,
  263. rows: 1000000
  264. }).then(flowRes => {
  265. if (flowRes && flowRes.length) {
  266. var flow = flowRes.filter(i => i.FLOWNAME === '组件资源授权');
  267. if (flow.length) {
  268. let params = {
  269. bussInfo: {
  270. bussname: '组件资源授权',//业务名称
  271. flowid: flow[0].id,//流程id
  272. serverids: e.resInfo.SERVICEID//资源id
  273. }
  274. }
  275. submitExamine(params).then(res => {
  276. if (res.resp_code === 0 && res.resp_msg === '提交成功') {
  277. message.success('申请成功')
  278. reload();
  279. } else {
  280. message.error('申请失败')
  281. }
  282. })
  283. }
  284. }
  285. })
  286. }
  287. function getAppName(name, id) {
  288. list().then((r) => {
  289. if (r && r.length) {
  290. var app = r.find((i) => i.KEY == name);
  291. if (app) {
  292. var dom = document.getElementById(id);
  293. if (dom) {
  294. dom.innerHTML = app.NAME;
  295. }
  296. }
  297. }
  298. })
  299. }
  300. function getUser(item, id) {
  301. var shr = [];
  302. if (item?.shlc?.length > 1) {
  303. item.shlc.map((i, index) => {
  304. var lx = item?.shzt == '审核中' ? true : index != item.shlc.length - 1;
  305. if (index != 0 && lx) {
  306. shr.push(i.USER_NAME)
  307. }
  308. })
  309. var dom = document.getElementById(id);
  310. if (dom) {
  311. dom.innerHTML = shr.join(',')
  312. }
  313. }
  314. }
  315. function getYJ(item, id) {
  316. var shyj = [];
  317. if (item?.shlc?.length > 1) {
  318. item.shlc.map((i, index) => {
  319. var lx = item?.shzt == '审核中' ? true : index != item.shlc.length - 1;
  320. if (index != 0 && lx) {
  321. shyj.push(i.CHECKINFO)
  322. }
  323. })
  324. var dom = document.getElementById(id);
  325. if (dom) {
  326. dom.innerHTML = shyj.join(',')
  327. }
  328. }
  329. }
  330. return {
  331. getYJ,
  332. getUser,
  333. getAppName,
  334. applyHandleEdit,
  335. applyHandleSuccess,
  336. submitApply,
  337. moment,
  338. createMessage,
  339. registerTable,
  340. // registerDrawer,
  341. registerModal,
  342. handleCreate,
  343. see,
  344. handleEdit,
  345. handleDelete,
  346. handleSuccess,
  347. RoleEnum,
  348. hasBatchDelete,
  349. handleDeleteOrBatchDelete,
  350. statusChange,
  351. };
  352. },
  353. });
  354. </script>
  355. <style>
  356. .zjsqkList .ant-table-fixed-header .ant-table-scroll .ant-table-header{
  357. width: 1404px !important;
  358. }
  359. </style>