index.vue 13 KB

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