index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <div>
  3. <BasicTable :rowSelection="{ type: 'checkbox' }" @register="registerTable" :clickToRowSelect="false">
  4. <template #toolbar v-if="props.isChild">
  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" @click="deleteSelect">
  11. 批量删除
  12. </a-button>
  13. <!-- </Popconfirm> -->
  14. </Authority>
  15. </template>
  16. <!-- <template #status="{ record }">
  17. <Switch :checked="record.status === 1" :loading="record.pendingStatus" checkedChildren="启用" unCheckedChildren="禁用"
  18. @change="(checked: boolean) => statusChange(checked, record)" />
  19. </template> -->
  20. <template #action="{ record }">
  21. <TableAction :actions="[
  22. {
  23. label: '浏览',
  24. icon: '' /**clarity:note-edit-line*/,
  25. // ifShow: record.servicealiasname,
  26. // ifShow: ((action) => action.servicealiasname),
  27. ifShow: record.servicealiasname,
  28. onClick: see.bind(null, record),
  29. },
  30. {
  31. label: '查看',
  32. icon: '' /**clarity:note-edit-line*/,
  33. onClick: handleSee.bind(null, record),
  34. },
  35. {
  36. label: '编辑',
  37. icon: '' /**clarity:note-edit-line*/,
  38. color: 'warning',
  39. ifShow: props.isChild,
  40. disabled: record.status == 3 ? false : true,
  41. onClick: handleEdit.bind(null, record),
  42. },
  43. {
  44. label: '提交审核',
  45. color: 'warning',
  46. icon: '' /**clarity:note-edit-line*/,
  47. ifShow: props.isChild,
  48. disabled: record.status == 3 ? false : true,
  49. // ifShow: record.servicealiasname,
  50. onClick: sendApprove.bind(null, record),
  51. },
  52. {
  53. label: '删除',
  54. icon: '' /**ant-design:delete-outlined'*/,
  55. color: 'error',
  56. ifShow: props.isChild,
  57. disabled: record.status == 3 ? false : true,
  58. onClick: deleteSelect.bind(null, record),
  59. // popConfirm: {
  60. // title: '是否确认删除',
  61. // confirm: deleteSelect.bind(null, record),
  62. // },
  63. },
  64. ]" />
  65. </template>
  66. <template #pdate="{ record }">
  67. <Tag :color="'red'">
  68. {{ record.publishdate ? moment(record.publishdate).format('YYYY-MM-DD HH:mm:ss') : '' }}
  69. </Tag>
  70. </template>
  71. <template #nodename="{ record }">
  72. <!-- <Tag>
  73. {{
  74. record.nodename == '归档' ? '已完成' : record.nodename
  75. }}
  76. </Tag> -->
  77. {{ record.nodename }}
  78. </template>
  79. <template #checkname="{ record }">
  80. <!-- <Tag>
  81. {{ record.nodename == '归档' ? '已完成' : record.checkname === '' ? record.publisher : record.checkname }}
  82. </Tag> -->
  83. {{ record.checkname }}
  84. </template>
  85. <template #checktime="{ record }">
  86. {{ record?.checktime?.replace('.0', '') }}
  87. </template>
  88. <template #status="{ record }">
  89. <Tag
  90. :style="`color:${
  91. record.nodename && record.status == 0
  92. ? '#F08718'
  93. : record.status == 1
  94. ? '#05B069'
  95. : record.status == 2
  96. ? 'red'
  97. : '#8A38F5'
  98. };`"
  99. >
  100. {{
  101. record.status == 3
  102. ? '未提交'
  103. : !record.status && record.nodename
  104. ? '审核中'
  105. : record.status == 2
  106. ? '审核不通过'
  107. : record.status == 1
  108. ? '审核通过'
  109. : ''
  110. }}
  111. </Tag>
  112. </template>
  113. </BasicTable>
  114. <MapSourceModal @register="registerModal" @success="handleSuccess" />
  115. </div>
  116. </template>
  117. <script lang="ts">
  118. import { defineComponent, nextTick, onBeforeMount } from 'vue';
  119. import { BasicTable, useTable, TableAction } from '/@/components/Table';
  120. import { delRole, setRoleStatus } from '/@/api/system/system';
  121. import { useModal } from '/@/components/Modal';
  122. import MapDrawer from './MapDrawer.vue';
  123. import MapSourceModal from './MapSourceModal.vue';
  124. import { columns, searchFormSchema } from './map.data';
  125. import { RoleEnum } from '/@/enums/roleEnum';
  126. import { Authority } from '/@/components/Authority';
  127. import { useBatchDelete } from '/@/hooks/web/useBatchDelete';
  128. import { useMessage } from '/@/hooks/web/useMessage';
  129. import { Switch, Popconfirm, message, Modal } from 'ant-design-vue';
  130. import { list, deleteService } from '/@/api/dataAdmin/assembly';
  131. import Moment from 'moment';
  132. //提交授权申请
  133. import { queryFlowInfoPage, submitExamine } from '/@/api/resource/examine';
  134. import uiTool from '/@/utils/uiTool';
  135. import { assList } from '/@/api/dataAdmin/mrerdr';
  136. export default defineComponent({
  137. name: 'RoleManagement',
  138. components: { BasicTable, MapDrawer, MapSourceModal, TableAction, Authority, Switch, Popconfirm },
  139. props: {
  140. isChild: {
  141. type: Boolean,
  142. default: true,
  143. }
  144. },
  145. setup(props) {
  146. const [registerModal, { openModal }] = useModal();
  147. const [registerTable, { setProps, reload, setSelectedRowKeys, getSelectRows }] = useTable({
  148. title: '组件资源列表',
  149. // api: list,
  150. api: assList,
  151. columns,
  152. formConfig: {
  153. labelWidth: 100,
  154. schemas: searchFormSchema,
  155. },
  156. useSearchForm: true,
  157. showTableSetting: true,
  158. bordered: true,
  159. showIndexColumn: true,
  160. actionColumn: {
  161. width: props.isChild ? 250 : 100,
  162. title: '操作',
  163. dataIndex: 'action',
  164. slots: { customRender: 'action' },
  165. fixed: 'right',
  166. },
  167. pagination: {
  168. hideOnSinglePage: false,
  169. },
  170. tableSetting: {
  171. redo: true,
  172. size: true,
  173. setting: false,
  174. fullScreen: false,
  175. },
  176. });
  177. const moment = Moment;
  178. const { createMessage } = useMessage();
  179. const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } =
  180. useBatchDelete(delRole, handleSuccess, setProps);
  181. selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => {
  182. // Demo:status为1的选择框禁用
  183. return { disabled: record.status == 3 ? false : true };
  184. };
  185. nextTick(() => {
  186. setProps(selectionOptions);
  187. });
  188. function handleCreate() {
  189. openModal(true, {
  190. isUpdate: false,
  191. isView: null
  192. });
  193. }
  194. //编辑
  195. function handleEdit(record: Recordable) {
  196. console.log("编辑:", record);
  197. openModal(true, {
  198. record,
  199. isUpdate: true,
  200. isView: false
  201. });
  202. }
  203. //查看
  204. function handleSee(record: Recordable) {
  205. console.log('查看:', record);
  206. openModal(true, {
  207. record,
  208. isUpdate: true,
  209. isView: true,
  210. });
  211. }
  212. function see(e) {
  213. console.log(e);
  214. if (e.servicealiasname)
  215. window.open(`../../mapview.html?onlineIde_${e.servicealiasname}`, '_blank');
  216. }
  217. //删除所有选中
  218. function deleteSelect(record) {
  219. uiTool.delModal('确定删除选中的组件资源?', async () => {
  220. var ids = record?.serviceid
  221. ? record.serviceid
  222. : getSelectRows()
  223. .map((i) => i.serviceid)
  224. .toString();
  225. if (ids) {
  226. const res = await deleteService(ids);
  227. if (res?.status !== '-1') {
  228. reload();
  229. createMessage.success('删除成功!', 1);
  230. } else {
  231. createMessage.error('删除失败!失败原因:' + res?.message, 1);
  232. }
  233. }
  234. });
  235. }
  236. function handleSuccess() {
  237. openModal(false, {
  238. isUpdate: false,
  239. });
  240. reload();
  241. }
  242. const statusChange = async (checked, record) => {
  243. setProps({
  244. loading: true,
  245. });
  246. setSelectedRowKeys([]);
  247. resetSelectedRowKeys();
  248. const newStatus = checked ? 1 : 0;
  249. try {
  250. await setRoleStatus(record.id, newStatus);
  251. if (newStatus) {
  252. createMessage.success(`启用成功`);
  253. } else {
  254. createMessage.success('禁用成功');
  255. }
  256. } finally {
  257. setProps({
  258. loading: false,
  259. });
  260. reload();
  261. }
  262. };
  263. onBeforeMount(async () => {});
  264. function sendApprove(e) {
  265. let params = {
  266. bussInfo: {
  267. bussname: '组件资源上传', //业务名称
  268. flowid: '', //流程id
  269. serverids: e.serviceid, //资源id
  270. },
  271. };
  272. if (e && e.flowid && e.flowid !== '') {
  273. params.bussInfo.flowid = e.flowid;
  274. submitExamine(params).then((res) => {
  275. if (res.resp_code === 0 && res.resp_msg === '提交成功') {
  276. message.success('申请成功');
  277. reload();
  278. } else {
  279. message.error('申请失败');
  280. }
  281. });
  282. } else {
  283. queryFlowInfoPage({
  284. page: 1,
  285. rows: 1000000,
  286. }).then((flowRes) => {
  287. console.log('flowRes:', flowRes);
  288. if (flowRes && flowRes.length) {
  289. var flow = flowRes.filter((i) => i.FLOWNAME === '组件资源上传');
  290. if (flow.length) {
  291. params.bussInfo.flowid = flow[0].id;
  292. submitExamine(params).then((res) => {
  293. if (res.resp_code === 0 && res.resp_msg === '提交成功') {
  294. message.success('申请成功');
  295. reload();
  296. } else {
  297. message.error('申请失败');
  298. }
  299. });
  300. }
  301. }
  302. });
  303. }
  304. }
  305. return {
  306. props,
  307. handleSee,
  308. deleteSelect,
  309. sendApprove,
  310. moment,
  311. createMessage,
  312. registerTable,
  313. registerModal,
  314. handleCreate,
  315. see,
  316. handleEdit,
  317. handleSuccess,
  318. RoleEnum,
  319. hasBatchDelete,
  320. handleDeleteOrBatchDelete,
  321. statusChange,
  322. };
  323. },
  324. });
  325. </script>