index.vue 12 KB

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