index copy.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <template>
  2. <div class="examine-container">
  3. <div class="left-container">
  4. <template v-for="source in sourceTypes" :key="source.SERVICETYPE">
  5. <div class="soure-item-row" :class="{ active: current === source.SERVICETYPE }" @click="selectHandle(source)">
  6. {{ source.name }}
  7. </div>
  8. </template>
  9. </div>
  10. <div class="right-container">
  11. <BasicTable @register="registerTable" @fetch-success="onFetchSuccess">
  12. <template #toolbar>
  13. <Authority>
  14. <a-button type="primary" @click="showModalBatch">IP管理</a-button>
  15. </Authority>
  16. </template>
  17. <template #action="{ record }">
  18. <TableAction :actions="[
  19. {
  20. label: 'IP管理',
  21. onClick: showModal.bind(null, record),
  22. },
  23. // {
  24. // label: '删除',
  25. // onClick: handleDel.bind(null, record),
  26. // },
  27. ]" />
  28. </template>
  29. </BasicTable>
  30. </div>
  31. <a-modal v-model:visible="visible" :label-col="labelCol" :wrapper-col="wrapperCol" title="IP管理" @ok="handleOk">
  32. <div class="wapper">
  33. <p><span>IP地址:&nbsp;</span><a-input v-model:value="formState.ipaddress" /></p>
  34. <p><span>服务ID:&nbsp;</span><a-input v-model:value="formState.serviceid" /></p>
  35. </div>
  36. <span style="clear: both;"></span>
  37. </a-modal>
  38. </div>
  39. </template>
  40. <script lang="ts">
  41. import { defineComponent, nextTick, ref, watch } from 'vue';
  42. import { BasicTable, useTable, TableAction } from '/@/components/Table';
  43. import { delRole, setRoleStatus } from '/@/api/system/system';
  44. import {
  45. columns,
  46. searchFormSchemaMR,
  47. searchFormSchemaER,
  48. searchFormSchemaDR,
  49. searchFormSchemaSR,
  50. } from './map.data';
  51. import { RoleEnum } from '/@/enums/roleEnum';
  52. import { Authority } from '/@/components/Authority';
  53. import { useBatchDelete } from '/@/hooks/web/useBatchDelete';
  54. import { Switch, Popconfirm, message } from 'ant-design-vue';
  55. import Moment from 'moment';
  56. import { getProxyList, proxySave, proxyDel } from '/@/api/resource/proxy';
  57. import { useModal } from '/@/components/Modal';
  58. import { useRouter } from 'vue-router';
  59. import { useAppStore } from '/@/store/modules/app';
  60. export default defineComponent({
  61. name: 'RoleManagement',
  62. components: {
  63. BasicTable,
  64. TableAction,
  65. Authority,
  66. Switch,
  67. Popconfirm
  68. },
  69. setup() {
  70. const appStore = useAppStore();
  71. const { currentRoute } = useRouter();
  72. const currRoute = currentRoute.value;
  73. let current = ref(currRoute?.query?.type || 'MR');
  74. let statusShow = ref(1);
  75. const [registerTable, { getSelectRows, setProps, reload, setSelectedRowKeys, getDataSource, getSelectRowKeys }] = useTable({
  76. title: '地图资源审核列表',
  77. api: (param) => {
  78. statusShow.value = param.checkStatus;
  79. const data = Object.assign(param, { serviceType: current.value });
  80. return getProxyList(data);
  81. }, //求接口
  82. //dataSource: dataSources, //表格的数据
  83. columns,
  84. // rowKey: (record) => record.SERVICEID,
  85. rowKey: 'id',
  86. formConfig: {
  87. labelWidth: 90,
  88. schemas: searchFormSchemaMR,
  89. },
  90. useSearchForm: true,
  91. showTableSetting: true,
  92. bordered: true,
  93. showIndexColumn: true,
  94. actionColumn: {
  95. width: 200,
  96. title: '操作',
  97. dataIndex: 'action',
  98. slots: { customRender: 'action' },
  99. fixed: 'right',
  100. },
  101. pagination: {
  102. hideOnSinglePage: false,
  103. // pageSize: 10,
  104. },
  105. clickToRowSelect: true, //点击当前行多选框不选中,默认是true
  106. rowSelection: { type: 'checkbox' }, //是否有多选功能
  107. tableSetting: {
  108. redo: true,
  109. size: true,
  110. setting: false,
  111. fullScreen: false,
  112. },
  113. });
  114. const onFetchSuccess = () => {
  115. // 请求后拿到数据,打开对应的资源审核弹窗
  116. nextTick(() => {
  117. let dataList = getDataSource()
  118. if (currRoute?.query?.bussid && appStore.routerPushAuditFlag) {
  119. dataList.forEach(item => {
  120. item.BUSSID === currRoute.query.bussid && handleEdit(item)
  121. })
  122. let searchFormSchema = searchFormSchemaMR;
  123. let title = '地图资源审核列表';
  124. if (current.value === 'MR') {
  125. searchFormSchema = searchFormSchemaMR;
  126. title = '地图资源审核列表';
  127. } else if (current.value === 'ER') {
  128. searchFormSchema = searchFormSchemaER;
  129. title = '场景资源审核列表';
  130. } else if (current.value === 'DR') {
  131. searchFormSchema = searchFormSchemaDR;
  132. title = '文件资源审核列表';
  133. } else {
  134. searchFormSchema = searchFormSchemaSR;
  135. title = '组件资源审核列表';
  136. }
  137. setProps({
  138. title: title,
  139. formConfig: {
  140. labelWidth: 90,
  141. schemas: searchFormSchema,
  142. },
  143. });
  144. }
  145. });
  146. }
  147. const moment = Moment;
  148. const ischect = ref(true)
  149. const sourceTypes = ref([
  150. { SERVICETYPE: 'MR', name: '地图资源' },
  151. { SERVICETYPE: 'ER', name: '场景资源' },
  152. { SERVICETYPE: 'DR', name: '文件资源' },
  153. { SERVICETYPE: 'SR', name: '组件资源' },
  154. ]);
  155. const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } =
  156. useBatchDelete(delRole, handleSuccess, setProps);
  157. selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => {
  158. // Demo:status为1的选择框禁用
  159. // if (record.status === 1) {
  160. // return { disabled: true };
  161. // } else {
  162. // return { disabled: false };
  163. // }
  164. };
  165. const [registerModal, { openModal }] = useModal();
  166. watch(
  167. () => current.value, (val) => {
  168. let searchFormSchema = searchFormSchemaMR;
  169. let title = '地图资源审核列表';
  170. if (val === 'MR') {
  171. searchFormSchema = searchFormSchemaMR;
  172. title = '地图资源审核列表';
  173. } else if (val === 'ER') {
  174. searchFormSchema = searchFormSchemaER;
  175. title = '场景资源审核列表';
  176. } else if (val === 'DR') {
  177. searchFormSchema = searchFormSchemaDR;
  178. title = '文件资源审核列表';
  179. } else {
  180. searchFormSchema = searchFormSchemaSR;
  181. title = '组件资源审核列表';
  182. }
  183. setProps({
  184. title: title,
  185. formConfig: {
  186. labelWidth: 90,
  187. schemas: searchFormSchema,
  188. },
  189. });
  190. reload();
  191. }
  192. );
  193. nextTick(() => {
  194. setProps(selectionOptions);
  195. });
  196. function selectHandle(record) {
  197. current.value = record.SERVICETYPE;
  198. }
  199. /**
  200. * 详情
  201. */
  202. async function handleDel(record: Recordable) {
  203. console.log(record);
  204. record.serviceid = record.SERVICEID;
  205. record.ipaddress = record.IPS
  206. proxyDel({
  207. serviceid: record.SERVICEID,
  208. serviceType: record.SERVICETYPE,
  209. ipaddress: record.IPS
  210. }).then((r) => {
  211. if (r) {
  212. message.success(r.resp_msg);
  213. reload();
  214. } else {
  215. message.error('删除代理失败!');
  216. }
  217. })
  218. }
  219. /**
  220. * 审核
  221. */
  222. function handleEdit(record: Recordable) {
  223. ischect.value = true;
  224. setTimeout(() => {
  225. openModal(true, {
  226. record,
  227. isUpdate: true,
  228. });
  229. appStore.setRouterPushAuditFlag(false)
  230. }, 100);
  231. }
  232. function handleSuccess() {
  233. openModal(false, {
  234. isUpdate: false,
  235. });
  236. reload();
  237. }
  238. const visible = ref(false);
  239. const disabled = ref(true);
  240. const showModal = (e) => {
  241. console.log(e);
  242. visible.value = true;
  243. disabled.value = e ? true : false;
  244. if (e) {
  245. formState.value.serviceid = e.SERVICEID;
  246. formState.value.ipaddress = e.IPS;
  247. }
  248. };
  249. function showModalBatch() {
  250. var list = getSelectRowKeys();
  251. if (list.length) {
  252. formState.value.serviceid = list.join(',');
  253. visible.value = true;
  254. }
  255. };
  256. function handleOk() {
  257. proxySave(formState.value).then((r) => {
  258. if (r.resp_code == 0) {
  259. visible.value = false;
  260. formState.value.ipaddress = '';
  261. formState.value.serviceid = '';
  262. message.success('保存成功');
  263. reload();
  264. setSelectedRowKeys([]);
  265. } else {
  266. message.error(r.resp_msg);
  267. }
  268. })
  269. };
  270. const formState = ref({
  271. ipaddress: "",
  272. serviceid: ""
  273. });
  274. return {
  275. showModalBatch,
  276. disabled,
  277. labelCol: { span: 2 },
  278. wrapperCol: { span: 6 },
  279. formState,
  280. visible,
  281. handleOk,
  282. showModal,
  283. statusShow,
  284. current,
  285. moment,
  286. ischect,
  287. sourceTypes,
  288. registerTable,
  289. registerModal,
  290. handleDel,
  291. handleEdit,
  292. handleSuccess,
  293. RoleEnum,
  294. hasBatchDelete,
  295. handleDeleteOrBatchDelete,
  296. selectHandle,
  297. onFetchSuccess
  298. };
  299. },
  300. });
  301. </script>
  302. <style scoped lang="less">
  303. .wapper {
  304. padding: 20px;
  305. height: 130px;
  306. }
  307. .wapper p {
  308. margin-bottom: 10px;
  309. height: 43px;
  310. }
  311. .wapper p span {
  312. float: left;
  313. height: 32px;
  314. line-height: 32px;
  315. }
  316. .wapper p input {
  317. float: left;
  318. width: 430px;
  319. }
  320. .examine-container {
  321. display: flex;
  322. height: 100%;
  323. width: 100%;
  324. .left-container {
  325. width: 240px;
  326. height: calc(100% - 32px);
  327. margin: 16px 0 16px 10px;
  328. padding: 10px 20px;
  329. background-color: #fff;
  330. border-radius: 2px;
  331. .soure-item-row {
  332. height: 34px;
  333. width: 100%;
  334. margin: 20px 0;
  335. line-height: 34px;
  336. text-align: center;
  337. font-size: 14px;
  338. font-weight: normal;
  339. letter-spacing: 0px;
  340. color: #333333;
  341. background: #eff0f5;
  342. border-radius: 2px;
  343. cursor: pointer;
  344. }
  345. .active {
  346. background: #0671dd;
  347. color: #fff;
  348. }
  349. }
  350. .right-container {
  351. width: calc(100% - 260px);
  352. height: 100%;
  353. }
  354. }
  355. </style>