rtklist.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <template>
  2. <PageWrapper contentClass="testPageWrapper">
  3. <template #footer>
  4. <a-tabs v-model:activeKey="activeKey" @change="changeTable">
  5. <a-tab-pane :key="0" tab="RTK设备管理" />
  6. <a-tab-pane :key="1" tab="账号使用日志" />
  7. </a-tabs>
  8. </template>
  9. <div>
  10. <BasicTable v-show="activeKey == 1" @register="registerlogTable" />
  11. <BasicTable v-show="activeKey == 0" @register="registerTable">
  12. <template #toolbar>
  13. <a-button type="primary" @click="handleEdit" v-if="getCheckPerm('rtk-add')"
  14. >新增</a-button
  15. >
  16. </template>
  17. <template #copy="{ record }">
  18. <a @click="handleCopy(record.authorizeKey)">
  19. {{ record.authorizeKey }}
  20. </a>
  21. </template>
  22. <template #action="{ record }">
  23. <TableAction
  24. :actions="[
  25. //{
  26. // label: record.status ? '取消激活' : '激活',
  27. // ifShow: getCheckPerm('rtk-activation'),
  28. // onClick: handleActive.bind(null, record),
  29. //},
  30. {
  31. label: '编辑',
  32. ifShow: getCheckPerm('rtk-updata'),
  33. onClick: handleEdit.bind(null, record),
  34. },
  35. {
  36. label: '删除',
  37. color: 'error',
  38. ifShow: getCheckPerm('rtk-delete'),
  39. onClick: handleDelete.bind(null, record),
  40. },
  41. ]"
  42. />
  43. </template>
  44. </BasicTable>
  45. <AddModal @register="register" @update="reload" />
  46. </div>
  47. </PageWrapper>
  48. </template>
  49. <script lang="ts">
  50. import { defineComponent, h, ref } from 'vue';
  51. import { PageWrapper } from '/@/components/Page';
  52. import {
  53. BasicTable,
  54. useTable,
  55. TableAction,
  56. BasicColumn,
  57. TableImg,
  58. FormProps,
  59. } from '/@/components/Table';
  60. import { rtkInfoList, rtkdelOrEdit, activation, rtksaveOrEdit } from '/@/api/product';
  61. import { useModal } from '/@/components/Modal';
  62. import { useI18n } from '/@/hooks/web/useI18n';
  63. import { copyTextToClipboard } from '/@/hooks/web/useCopyToClipboard';
  64. import AddModal from './AddenvModal.vue';
  65. import { Tabs } from 'ant-design-vue';
  66. import { useMessage } from '/@/hooks/web/useMessage';
  67. import { usePermissionStore } from '/@/store/modules/permission';
  68. import { incrementUseTypeList } from '/@/api/account';
  69. import { rtklogColumns, rtklogsearchForm } from './data';
  70. import { rtkUseLogList } from '/@/api/rtk';
  71. import { Switch } from 'ant-design-vue';
  72. export default defineComponent({
  73. components: {
  74. BasicTable,
  75. AddModal,
  76. TableAction,
  77. TableImg,
  78. Switch,
  79. PageWrapper,
  80. [Tabs.name]: Tabs,
  81. [Tabs.TabPane.name]: Tabs.TabPane,
  82. },
  83. setup() {
  84. const { t } = useI18n();
  85. const activeKey = ref(0);
  86. const { createMessage, createConfirm } = useMessage();
  87. const permissionStore = usePermissionStore();
  88. const { getCheckPerm } = permissionStore;
  89. const [register, { openModal }] = useModal();
  90. const columns: BasicColumn[] = [
  91. {
  92. title: '相机sn',
  93. ellipsis: true,
  94. dataIndex: 'cameraSnCode',
  95. width: 100,
  96. },
  97. {
  98. title: '板卡类型',
  99. dataIndex: 'rtkType',
  100. ellipsis: true,
  101. width: 120,
  102. customRender: ({ record }) => {
  103. let obj = {
  104. 0: '千寻板卡千寻账号',
  105. 1: '千寻板卡移动账号',
  106. 2: '北云板卡移动账号',
  107. };
  108. return obj[record.rtkType] || '-';
  109. },
  110. },
  111. {
  112. title: '板卡sn号',
  113. ellipsis: true,
  114. dataIndex: 'rtkSnCode',
  115. width: 150,
  116. },
  117. {
  118. title: '深光rtk插件sn',
  119. ellipsis: true,
  120. dataIndex: 'sgRtkSn',
  121. width: 120,
  122. },
  123. {
  124. title: '运营商',
  125. ellipsis: true,
  126. dataIndex: 'operator',
  127. width: 120,
  128. },
  129. {
  130. title: 'IP地址',
  131. ellipsis: true,
  132. dataIndex: 'ipAddr',
  133. width: 100,
  134. },
  135. {
  136. title: '挂载点',
  137. ellipsis: true,
  138. dataIndex: 'mountPoint',
  139. width: 120,
  140. },
  141. {
  142. title: '端口',
  143. ellipsis: true,
  144. dataIndex: 'port',
  145. width: 50,
  146. },
  147. {
  148. title: '用户名称',
  149. ellipsis: true,
  150. dataIndex: 'userName',
  151. width: 120,
  152. },
  153. {
  154. title: '创建人',
  155. ellipsis: true,
  156. dataIndex: 'createNickName',
  157. width: 100,
  158. },
  159. {
  160. title: '创建时间',
  161. ellipsis: true,
  162. dataIndex: 'createTime',
  163. width: 160,
  164. },
  165. {
  166. title: '到期日期',
  167. ellipsis: true,
  168. dataIndex: 'failureTime',
  169. width: 160,
  170. },
  171. {
  172. title: 'RTK使用状态',
  173. dataIndex: 'status',
  174. width: 100,
  175. // ifShow: getCheckPerm('recruit-publish'),
  176. customRender: ({ record }) => {
  177. if (!Reflect.has(record, 'pendingStatus')) {
  178. record.pendingStatus = false;
  179. }
  180. return h(Switch, {
  181. checked: record.status === 0,
  182. checkedChildren: '正常',
  183. unCheckedChildren: '禁用',
  184. loading: false,
  185. onChange: async (checked: boolean) => {
  186. record.pendingStatus = true;
  187. const status = checked ? 0 : 1;
  188. Reflect.set(record, 'status', status);
  189. await rtksaveOrEdit({ ...record, status: status });
  190. createMessage.success('操作成功');
  191. // reload()
  192. },
  193. });
  194. },
  195. },
  196. ];
  197. const searchForm: Partial<FormProps> = {
  198. labelWidth: 100,
  199. autoSubmitOnEnter: true,
  200. schemas: [
  201. {
  202. field: 'cameraSn',
  203. label: '相机Sn',
  204. component: 'Input',
  205. colProps: {
  206. xl: 8,
  207. xxl: 8,
  208. },
  209. },
  210. {
  211. field: 'rtkSnCode',
  212. label: '板卡sn号',
  213. component: 'Input',
  214. colProps: {
  215. xl: 8,
  216. xxl: 8,
  217. },
  218. },
  219. {
  220. field: 'userName',
  221. label: '用户名称',
  222. component: 'Input',
  223. colProps: {
  224. xl: 8,
  225. xxl: 8,
  226. },
  227. },
  228. {
  229. field: 'operator',
  230. label: '运营商',
  231. component: 'Input',
  232. colProps: {
  233. xl: 8,
  234. xxl: 8,
  235. },
  236. },
  237. {
  238. field: 'sgRtkSn',
  239. label: '深光rtk插件sn',
  240. component: 'Input',
  241. colProps: {
  242. xl: 8,
  243. xxl: 8,
  244. },
  245. },
  246. ],
  247. };
  248. const [registerTable, { reload: reload0 }] = useTable({
  249. api: rtkInfoList,
  250. title: 'rtk列表',
  251. columns: columns,
  252. useSearchForm: true,
  253. showIndexColumn: true,
  254. formConfig: searchForm,
  255. showTableSetting: true,
  256. fetchSetting: {
  257. pageField: 'pageNum',
  258. sizeField: 'pageSize',
  259. listField: 'list',
  260. totalField: 'total',
  261. },
  262. actionColumn: {
  263. width: 160,
  264. title: '操作',
  265. dataIndex: 'action',
  266. slots: { customRender: 'action' },
  267. },
  268. rowKey: 'id',
  269. canResize: false,
  270. });
  271. const [registerlogTable, { reload: reload1 }] = useTable({
  272. api: rtkUseLogList,
  273. title: '账号使用日志',
  274. columns: rtklogColumns,
  275. useSearchForm: true,
  276. showIndexColumn: false,
  277. formConfig: rtklogsearchForm,
  278. showTableSetting: true,
  279. fetchSetting: {
  280. pageField: 'pageNum',
  281. sizeField: 'pageSize',
  282. listField: 'list',
  283. totalField: 'total',
  284. },
  285. rowKey: 'id',
  286. canResize: false,
  287. });
  288. async function handleDelete(record) {
  289. createConfirm({
  290. iconType: 'warning',
  291. title: () => h('span', '温馨提示'),
  292. content: () => h('span', '确定要删除吗?'),
  293. onOk: async () => {
  294. await rtkdelOrEdit({ id: record.id });
  295. reload();
  296. createMessage.success(t('common.optSuccess'));
  297. },
  298. });
  299. }
  300. function handleCopy(str: string) {
  301. copyTextToClipboard(str);
  302. createMessage.success('复制成功');
  303. }
  304. function handleActive(record) {
  305. createConfirm({
  306. iconType: 'warning',
  307. title: () => h('span', '温馨提示'),
  308. content: () => h('span', `确定要${record.status ? '禁用' : '激活'}吗?`),
  309. onOk: async () => {
  310. await activation({ id: record.id, status: record.status ? 0 : 1 });
  311. reload();
  312. createMessage.success(t('common.optSuccess'));
  313. },
  314. });
  315. }
  316. function handleEdit(record = {}) {
  317. openModal(true, {
  318. ...record,
  319. authorizeTime: `${record.authorizeTime || '10'}_${record.authorizeTimeUnit || '1'}`,
  320. });
  321. }
  322. function reload() {
  323. if (activeKey.value == 0) {
  324. reload0();
  325. } else if (activeKey.value == 1) {
  326. reload1();
  327. }
  328. }
  329. return {
  330. registerTable,
  331. handleCopy,
  332. handleDelete,
  333. reload,
  334. register,
  335. handleActive,
  336. getCheckPerm,
  337. handleEdit,
  338. registerlogTable,
  339. activeKey,
  340. };
  341. },
  342. });
  343. </script>