index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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. // ifShow: record.servicealiasname,
  37. // ifShow: ((action) => action.servicealiasname),
  38. ifShow: record.servicealiasname,
  39. onClick: see.bind(null, record),
  40. },
  41. ]" :drop-down-actions="[
  42. {
  43. label: '编辑',
  44. icon: '' /**clarity:note-edit-line*/,
  45. color: 'warning',
  46. onClick: handleEdit.bind(null, record),
  47. },
  48. {
  49. label: '删除',
  50. icon: '' /**ant-design:delete-outlined'*/,
  51. color: 'error',
  52. ifShow: record.roleType != RoleEnum.SYS_ADMIN,
  53. popConfirm: {
  54. title: '是否确认删除',
  55. confirm: handleDelete.bind(null, record),
  56. },
  57. },
  58. ]" />
  59. </template>
  60. <template #pdate="{ record }">
  61. <Tag :color="'red'">
  62. {{
  63. record.publishdate ? moment(record.publishdate).format('YYYY-MM-DD HH:mm:ss') : ''
  64. }}
  65. </Tag>
  66. </template>
  67. <template #status="{ record }">
  68. <Tag :style="`color:${record.status === 3 || record.status === 3 ? 'red' : ''};`">
  69. {{
  70. record.status === 0 ? '待审核' : (record.status === 1 ? '审核通过' : (record.status === 2 ? '审核不通过' : (record.status
  71. === 3 ? '被驳回' : '未提交')))
  72. }}
  73. </Tag>
  74. </template>
  75. </BasicTable>
  76. <!-- <MapDrawer @register="registerDrawer" @success="handleSuccess" /> -->
  77. <MapSourceModal @register="registerModal" @success="handleSuccess" />
  78. </div>
  79. </template>
  80. <script lang="ts">
  81. import { defineComponent, nextTick, onBeforeMount } from 'vue';
  82. import { BasicTable, useTable, TableAction } from '/@/components/Table';
  83. import { delRole, getRoleListByPage, setRoleStatus } from '/@/api/system/system';
  84. // import { useDrawer } from '/@/components/Drawer';
  85. import { useModal } from '/@/components/Modal';
  86. import MapDrawer from './MapDrawer.vue';
  87. import MapSourceModal from './MapSourceModal.vue';
  88. import { columns, searchFormSchema } from './map.data';
  89. import { RoleEnum } from '/@/enums/roleEnum';
  90. import { Authority } from '/@/components/Authority';
  91. import { useBatchDelete } from '/@/hooks/web/useBatchDelete';
  92. import { useMessage } from '/@/hooks/web/useMessage';
  93. import { Switch, Popconfirm } from 'ant-design-vue';
  94. import { list, deleteService } from '/@/api/dataAdmin/assembly';
  95. import Moment from 'moment'
  96. export default defineComponent({
  97. name: 'RoleManagement',
  98. components: { BasicTable, MapDrawer, MapSourceModal, TableAction, Authority, Switch, Popconfirm },
  99. setup() {
  100. //const [registerDrawer, { openDrawer }] = useDrawer();
  101. const [registerModal, { openModal }] = useModal();
  102. const [registerTable, { setProps, reload, setSelectedRowKeys }] = useTable({
  103. title: '地图资源列表',
  104. api: list,
  105. columns,
  106. formConfig: {
  107. labelWidth: 100,
  108. schemas: searchFormSchema,
  109. },
  110. useSearchForm: true,
  111. showTableSetting: true,
  112. bordered: true,
  113. showIndexColumn: true,
  114. actionColumn: {
  115. width: 200,
  116. title: '操作',
  117. dataIndex: 'action',
  118. slots: { customRender: 'action' },
  119. fixed: 'right',
  120. },
  121. });
  122. const moment = Moment
  123. const { createMessage } = useMessage();
  124. const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } =
  125. useBatchDelete(delRole, handleSuccess, setProps);
  126. selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => {
  127. // Demo:status为1的选择框禁用
  128. if (record.status === 1) {
  129. return { disabled: true };
  130. } else {
  131. return { disabled: false };
  132. }
  133. };
  134. nextTick(() => {
  135. setProps(selectionOptions);
  136. });
  137. function handleCreate() {
  138. // openDrawer(true, {
  139. // isUpdate: false,
  140. // });
  141. openModal(true, {
  142. isUpdate: false,
  143. });
  144. }
  145. function handleEdit(record: Recordable) {
  146. // openDrawer(true, {
  147. // record,
  148. // isUpdate: true,
  149. // });
  150. openModal(true, {
  151. record,
  152. isUpdate: true,
  153. });
  154. }
  155. function see(e) {
  156. console.log(e);
  157. if (e.servicealiasname) window.open(`../../mapview.html?onlineIde_${e.servicealiasname}`, '_blank');
  158. }
  159. const handleDelete = async (record: Recordable) => {
  160. if (record?.serviceid) {
  161. const res = await deleteService(record?.serviceid)
  162. if (res?.status !== '-1') {
  163. reload();
  164. createMessage.success('删除成功!', 1)
  165. }
  166. else {
  167. createMessage.error('删除失败!失败原因:' + res?.message, 1)
  168. }
  169. }
  170. }
  171. function handleSuccess() {
  172. openModal(false, {
  173. isUpdate: false,
  174. });
  175. reload();
  176. }
  177. const statusChange = async (checked, record) => {
  178. setProps({
  179. loading: true,
  180. });
  181. setSelectedRowKeys([]);
  182. resetSelectedRowKeys();
  183. const newStatus = checked ? 1 : 0;
  184. try {
  185. await setRoleStatus(record.id, newStatus);
  186. if (newStatus) {
  187. createMessage.success(`启用成功`);
  188. } else {
  189. createMessage.success('禁用成功');
  190. }
  191. } finally {
  192. setProps({
  193. loading: false,
  194. });
  195. reload();
  196. }
  197. };
  198. onBeforeMount(async () => {
  199. })
  200. return {
  201. moment,
  202. createMessage,
  203. registerTable,
  204. // registerDrawer,
  205. registerModal,
  206. handleCreate,
  207. see,
  208. handleEdit,
  209. handleDelete,
  210. handleSuccess,
  211. RoleEnum,
  212. hasBatchDelete,
  213. handleDeleteOrBatchDelete,
  214. statusChange,
  215. };
  216. },
  217. });
  218. </script>