install.vue 6.8 KB

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