index.vue 12 KB

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