camera.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <div>
  3. <BasicTable @register="registerTable">
  4. <template #toolbar>
  5. <a-button type="primary" @click="handleEdit" v-if="getCheckPerm('dealer-export')"
  6. >授权</a-button
  7. >
  8. </template>
  9. <template #copy="{ text }">
  10. <a @click="handleCopy(text)">
  11. {{ text }}
  12. </a>
  13. </template>
  14. <template #action="{ record }">
  15. <TableAction
  16. :actions="[
  17. {
  18. label: '详情',
  19. ifShow: getCheckPerm('empowerCamera-detail'),
  20. onClick: handleDetail.bind(null, record),
  21. },
  22. {
  23. label: '编辑',
  24. ifShow: getCheckPerm('empowerCamera-updata'),
  25. onClick: handleEdit.bind(null, record),
  26. },
  27. {
  28. label: '删除',
  29. color: 'error',
  30. ifShow: getCheckPerm('empowerCamera-delete'),
  31. onClick: handleDelete.bind(null, record),
  32. },
  33. ]"
  34. />
  35. </template>
  36. </BasicTable>
  37. <AddModal @register="register" @update="reload" />
  38. <DetailModal @register="registerDetail" @update="reload" />
  39. </div>
  40. </template>
  41. <script lang="ts">
  42. import { defineComponent, h } from 'vue';
  43. import {
  44. BasicTable,
  45. useTable,
  46. TableAction,
  47. BasicColumn,
  48. FormProps,
  49. } from '/@/components/Table';
  50. import {
  51. authorizeCameraList,
  52. authorizeCameradelete,
  53. } from '/@/api/authorizeModeling';
  54. import { useModal } from '/@/components/Modal';
  55. import { useI18n } from '/@/hooks/web/useI18n';
  56. import AddModal from './AddCameraModal.vue';
  57. import DetailModal from './detailModel.vue';
  58. import { useMessage } from '/@/hooks/web/useMessage';
  59. import { usePermissionStore } from '/@/store/modules/permission';
  60. import { copyTextToClipboard } from '/@/hooks/web/useCopyToClipboard';
  61. import { incrementUseTypeList } from '/@/api/account';
  62. export default defineComponent({
  63. components: {
  64. BasicTable,
  65. AddModal,
  66. TableAction,
  67. DetailModal,
  68. },
  69. setup() {
  70. const { t } = useI18n();
  71. const { createMessage, createConfirm } = useMessage();
  72. const permissionStore = usePermissionStore();
  73. const { getCheckPerm } = permissionStore;
  74. const [register, { openModal }] = useModal();
  75. const [registerDetail, { openModal: opendetailModel }] = useModal();
  76. const columns: BasicColumn[] = [
  77. {
  78. title: '客户名称',
  79. dataIndex: 'customerName',
  80. ellipsis: true,
  81. width: 250,
  82. },
  83. {
  84. title: '客户类别',
  85. dataIndex: 'customerType',
  86. ellipsis: true,
  87. width: 80,
  88. customRender: ({ record }) => {
  89. return record.customerType == 1 ? '经销' : '直销';
  90. },
  91. },
  92. {
  93. title: '终端客户',
  94. ellipsis: true,
  95. dataIndex: 'endCustomer',
  96. width: 120,
  97. },
  98. {
  99. title: '使用类型',
  100. ellipsis: true,
  101. dataIndex: 'useTypeStr',
  102. width: 120,
  103. },
  104. {
  105. title: '项目号',
  106. ellipsis: true,
  107. dataIndex: 'projectNum',
  108. width: 120,
  109. },
  110. {
  111. title: '设备UUID',
  112. ellipsis: true,
  113. slots: { customRender: 'copy' },
  114. dataIndex: 'machineUuid',
  115. width: 120,
  116. },
  117. {
  118. title: '设备名称',
  119. ellipsis: true,
  120. slots: { customRender: 'copy' },
  121. dataIndex: 'machineName',
  122. width: 120,
  123. },
  124. {
  125. title: '相机授权Key',
  126. ellipsis: true,
  127. slots: { customRender: 'copy' },
  128. dataIndex: 'authorizeKey',
  129. width: 120,
  130. },
  131. {
  132. title: '授权相机数量',
  133. ellipsis: true,
  134. dataIndex: 'cameraNum',
  135. width: 120,
  136. },
  137. {
  138. title: '备注',
  139. ellipsis: true,
  140. dataIndex: 'remark',
  141. width: 120,
  142. },
  143. {
  144. title: '创建人',
  145. ellipsis: true,
  146. dataIndex: 'sysUserName',
  147. width: 120,
  148. },
  149. {
  150. title: '创建时间',
  151. ellipsis: true,
  152. dataIndex: 'createTime',
  153. width: 160,
  154. },
  155. ];
  156. const searchForm: Partial<FormProps> = {
  157. labelWidth: 100,
  158. autoSubmitOnEnter: true,
  159. schemas: [
  160. {
  161. field: 'customerName',
  162. label: '客户名称',
  163. component: 'Input',
  164. colProps: {
  165. xl: 8,
  166. xxl: 8,
  167. },
  168. },
  169. {
  170. field: 'customerType',
  171. label: '客户类别',
  172. component: 'Select',
  173. componentProps: {
  174. options: [
  175. {
  176. label: '直销',
  177. value: 0,
  178. key: '0',
  179. },
  180. {
  181. label: '经销',
  182. value: 1,
  183. key: '1',
  184. },
  185. ],
  186. },
  187. colProps: {
  188. xl: 8,
  189. xxl: 8,
  190. },
  191. },
  192. {
  193. field: 'useType',
  194. label: '使用类型',
  195. component: 'ApiSelect',
  196. componentProps: {
  197. api: incrementUseTypeList,
  198. labelField: 'name',
  199. valueField: 'id',
  200. immediate: true,
  201. },
  202. colProps: {
  203. xl: 8,
  204. xxl: 8,
  205. },
  206. },
  207. {
  208. field: 'machineUuid',
  209. label: '设备UUID',
  210. component: 'Input',
  211. colProps: {
  212. xl: 8,
  213. xxl: 8,
  214. },
  215. },
  216. {
  217. field: 'authorizeKey',
  218. label: '安装授权Key',
  219. component: 'Input',
  220. colProps: {
  221. xl: 8,
  222. xxl: 8,
  223. },
  224. },
  225. ],
  226. };
  227. const [registerTable, { reload }] = useTable({
  228. api: authorizeCameraList,
  229. title: '深时本地版相机授权',
  230. columns: columns,
  231. useSearchForm: true,
  232. formConfig: searchForm,
  233. showTableSetting: true,
  234. showIndexColumn: false,
  235. fetchSetting: {
  236. pageField: 'pageNum',
  237. sizeField: 'pageSize',
  238. listField: 'list',
  239. totalField: 'total',
  240. },
  241. actionColumn: {
  242. width: 150,
  243. title: '操作',
  244. dataIndex: 'action',
  245. slots: { customRender: 'action' },
  246. },
  247. rowKey: 'id',
  248. canResize: true,
  249. });
  250. async function handleDelete(record) {
  251. createConfirm({
  252. iconType: 'warning',
  253. title: () => h('span', '温馨提示'),
  254. content: () => h('span', '确定要删除授权吗?'),
  255. onOk: async () => {
  256. await authorizeCameradelete({ id: record.id });
  257. reload();
  258. createMessage.success(t('common.optSuccess'));
  259. },
  260. });
  261. }
  262. function handleEdit(record = {}) {
  263. openModal(true, record);
  264. }
  265. function handleDetail(record = {}) {
  266. opendetailModel(true, record);
  267. }
  268. function handleCopy(str: string) {
  269. copyTextToClipboard(str);
  270. createMessage.success('复制成功');
  271. }
  272. return {
  273. registerTable,
  274. handleCopy,
  275. handleDelete,
  276. reload,
  277. register,
  278. registerDetail,
  279. getCheckPerm,
  280. handleEdit,
  281. handleDetail,
  282. };
  283. },
  284. });
  285. </script>