index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <div>
  3. <BasicTable :rowSelection="{ type: 'checkbox' }" @register="registerTable" :clickToRowSelect="false">
  4. <template #toolbar>
  5. <Authority>
  6. <a-button type="primary" @click="handleCreate">提交申请</a-button>
  7. </Authority>
  8. <!-- <Authority>
  9. <Popconfirm title="您确定要批量删除数据" ok-text="确定" cancel-text="取消" @confirm="handleDeleteOrBatchDelete(null)">
  10. <a-button type="primary" color="error" :disabled="hasBatchDelete"> 批量删除 </a-button>
  11. </Popconfirm>
  12. </Authority> -->
  13. </template>
  14. <!-- <template #status="{ record }">
  15. <Switch :checked="record.status === 1" :loading="record.pendingStatus" checkedChildren="启用" unCheckedChildren="禁用"
  16. @change="(checked: boolean) => statusChange(checked, record)" />
  17. </template> -->
  18. <template #action="{ record }">
  19. <TableAction :actions="[
  20. // {
  21. // label: '浏览',
  22. // icon: '' /**clarity:note-edit-line*/,
  23. // // ifShow: record.servicealiasname,
  24. // // ifShow: ((action) => action.servicealiasname),
  25. // ifShow: record.servicealiasname,
  26. // onClick: see.bind(null, record),
  27. // },
  28. // {
  29. // label: '查看',
  30. // icon: '' /**clarity:note-edit-line*/,
  31. // onClick: handleEdit.bind(null, record),
  32. // },
  33. // {
  34. // label: '编辑',
  35. // icon: '' /**clarity:note-edit-line*/,
  36. // color: 'warning',
  37. // onClick: handleEdit.bind(null, record),
  38. // },
  39. // {
  40. // label: '删除',
  41. // icon: '' /**ant-design:delete-outlined'*/,
  42. // color: 'error',
  43. // ifShow: record.roleType != RoleEnum.SYS_ADMIN,
  44. // popConfirm: {
  45. // title: '是否确认删除',
  46. // confirm: handleDelete.bind(null, record),
  47. // },
  48. // },
  49. {
  50. label: '提交申请',
  51. icon: '' /**clarity:note-edit-line*/,
  52. // ifShow: record.servicealiasname,
  53. // ifShow: ((action) => action.servicealiasname),
  54. disabled: !(record.shzt == '未提交'),
  55. onClick: submitApply.bind(null, record),
  56. },
  57. {
  58. label: '移出',
  59. tooltip: '移出',
  60. // icon: 'ant-design:form-outlined',
  61. onClick: handleDelete.bind(null, record),
  62. disabled: !(record.shzt === '未提交')
  63. },
  64. ]" />
  65. </template>
  66. <template #pdate="{ record }">
  67. <Tag :color="'red'">
  68. {{
  69. record.publishdate ? moment(record.publishdate).format('YYYY-MM-DD HH:mm:ss') : ''
  70. }}
  71. </Tag>
  72. </template>
  73. <template #status="{ record }">
  74. <Tag :style="`color:${record.shzt == '未提交' ? 'red' : '#05B069'};`">
  75. {{
  76. record.shzt
  77. }}
  78. </Tag>
  79. </template>
  80. </BasicTable>
  81. <MapSourceModal @register="registerModal" @success="handleSuccess" />
  82. </div>
  83. </template>
  84. <script lang="ts">
  85. import { defineComponent, nextTick, onBeforeMount, createVNode } from 'vue';
  86. import { BasicTable, useTable, TableAction } from '/@/components/Table';
  87. import { delRole, setRoleStatus } from '/@/api/system/system';
  88. import { useModal } from '/@/components/Modal';
  89. import MapDrawer from './MapDrawer.vue';
  90. import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
  91. import MapSourceModal from './MapSourceModal.vue';
  92. import { columns, searchFormSchema } from './lib.data';
  93. import { RoleEnum } from '/@/enums/roleEnum';
  94. import { Authority } from '/@/components/Authority';
  95. import { useBatchDelete } from '/@/hooks/web/useBatchDelete';
  96. import { useMessage } from '/@/hooks/web/useMessage';
  97. import { Switch, Popconfirm, message, Modal } from 'ant-design-vue';
  98. import { getAssemblyLibs } from '/@/api/dataAdmin/assembly';
  99. //操作申请库资源
  100. import Moment from 'moment'
  101. import { queryFlowInfoPage, submitExamine } from '/@/api/resource/examine';
  102. import { deleteResInCar } from '/@/api/resource/plat';
  103. export default defineComponent({
  104. name: 'RoleManagement',
  105. components: { BasicTable, MapDrawer, MapSourceModal, TableAction, Authority, Switch, Popconfirm },
  106. setup() {
  107. const [registerModal, { openModal }] = useModal();
  108. const [registerTable, { setProps, reload, setSelectedRowKeys }] = useTable({
  109. title: '地图资源列表',
  110. api: getAssemblyLibs,
  111. columns,
  112. formConfig: {
  113. labelWidth: 100,
  114. schemas: searchFormSchema,
  115. },
  116. useSearchForm: true,
  117. showTableSetting: true,
  118. bordered: true,
  119. showIndexColumn: true,
  120. actionColumn: {
  121. width: 200,
  122. title: '操作',
  123. dataIndex: 'action',
  124. slots: { customRender: 'action' },
  125. fixed: 'right',
  126. },
  127. tableSetting: {
  128. redo: true,
  129. size: true,
  130. setting: false,
  131. fullScreen: false
  132. },
  133. });
  134. const moment = Moment
  135. const { createMessage } = useMessage();
  136. const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } =
  137. useBatchDelete(delRole, handleSuccess, setProps);
  138. selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => {
  139. // Demo:status为1的选择框禁用
  140. if (record.status === 1) {
  141. return { disabled: true };
  142. } else {
  143. return { disabled: false };
  144. }
  145. };
  146. nextTick(() => {
  147. setProps(selectionOptions);
  148. });
  149. function handleCreate() {
  150. openModal(true, {
  151. isUpdate: false,
  152. });
  153. }
  154. function handleEdit(record: Recordable) {
  155. openModal(true, {
  156. record,
  157. isUpdate: true,
  158. });
  159. }
  160. function see(e) {
  161. console.log(e);
  162. if (e.servicealiasname) window.open(`../../mapview.html?onlineIde_${e.servicealiasname}`, '_blank');
  163. }
  164. //组件资源移出申请库
  165. const handleDelete = (record) => {
  166. console.log(record);
  167. Modal.confirm({
  168. title: '移出提示',
  169. icon: createVNode(ExclamationCircleOutlined),
  170. content: '确定移出该资源?',
  171. centered: true,
  172. okText: '确定',
  173. okType: 'danger',
  174. cancelText: '取消',
  175. onOk: (() => {
  176. deleteResInCar({
  177. idList: [record.applyCarInfo.id]
  178. }).then(() => reload())
  179. })
  180. });
  181. }
  182. function handleSuccess() {
  183. openModal(false, {
  184. isUpdate: false,
  185. });
  186. reload();
  187. }
  188. const statusChange = async (checked, record) => {
  189. setProps({
  190. loading: true,
  191. });
  192. setSelectedRowKeys([]);
  193. resetSelectedRowKeys();
  194. const newStatus = checked ? 1 : 0;
  195. try {
  196. await setRoleStatus(record.id, newStatus);
  197. if (newStatus) {
  198. createMessage.success(`启用成功`);
  199. } else {
  200. createMessage.success('禁用成功');
  201. }
  202. } finally {
  203. setProps({
  204. loading: false,
  205. });
  206. reload();
  207. }
  208. };
  209. onBeforeMount(async () => {
  210. })
  211. function submitApply(e) {
  212. console.log("submitApply:", e)
  213. queryFlowInfoPage({
  214. page: 1,
  215. rows: 1000000
  216. }).then(flowRes => {
  217. if (flowRes && flowRes.length) {
  218. var flow = flowRes.filter(i => i.FLOWNAME === '组件资源授权');
  219. if (flow.length) {
  220. let params = {
  221. bussInfo: {
  222. bussname: '组件资源授权',//业务名称
  223. flowid: flow[0].id,//流程id
  224. serverids: e.resInfo.SERVICEID//资源id
  225. }
  226. }
  227. submitExamine(params).then(res => {
  228. if (res.resp_code === 0 && res.resp_msg === '提交成功') {
  229. message.success('申请成功')
  230. reload();
  231. } else {
  232. message.error('申请失败')
  233. }
  234. })
  235. }
  236. }
  237. })
  238. }
  239. return {
  240. submitApply,
  241. moment,
  242. createMessage,
  243. registerTable,
  244. // registerDrawer,
  245. registerModal,
  246. handleCreate,
  247. see,
  248. handleEdit,
  249. handleDelete,
  250. handleSuccess,
  251. RoleEnum,
  252. hasBatchDelete,
  253. handleDeleteOrBatchDelete,
  254. statusChange,
  255. };
  256. },
  257. });
  258. </script>