install.vue 6.4 KB

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