list.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <div class="p-4">
  3. <BasicTable @register="registerTable">
  4. <template #toolbar>
  5. <a-button type="primary" @click="openAddModal">{{
  6. t('routes.devices.addCamera')
  7. }}</a-button>
  8. </template>
  9. <template #cameraType="{ record }">
  10. <Tag color="green">{{ rendercameraTypeLabel(record.cameraType) }} </Tag></template
  11. >
  12. <template #Time="{ record }">
  13. <Time v-if="record.activatedTime" :value="record.activatedTime" mode="datetime" />
  14. </template>
  15. <template #own="{ record }">
  16. {{ renderOwnTypeLabel(record.own) }}
  17. </template>
  18. <!-- {
  19. icon: 'ant-design:delete-outlined',
  20. color: 'error',
  21. label: t('common.delText'),
  22. popConfirm: {
  23. title: t('common.delConfirm'),
  24. confirm: () => {
  25. createMessage.info(t('common.notConnect'));
  26. },
  27. },
  28. }, -->
  29. <template #action="{ record }">
  30. <TableAction
  31. :actions="[
  32. {
  33. label: t('common.edit'),
  34. onClick: handleEditScenes.bind(null, record),
  35. },
  36. {
  37. label: t('common.unbind'),
  38. ifShow: !!record.userName,
  39. popConfirm: {
  40. title: t('routes.corporation.isUnBind'),
  41. confirm: handleUnbindDevice.bind(null, record),
  42. },
  43. },
  44. ]"
  45. />
  46. </template>
  47. </BasicTable>
  48. <AddModal @update="reload" @register="registerAddModal" />
  49. <EditModal @register="registerEditModal" @update="reload" />
  50. </div>
  51. </template>
  52. <script lang="ts">
  53. import { defineComponent } from 'vue';
  54. import { BasicTable, useTable, BasicColumn, FormProps, TableAction } from '/@/components/Table';
  55. import { useMessage } from '/@/hooks/web/useMessage';
  56. import { Time } from '/@/components/Time';
  57. import { Tag } from 'ant-design-vue';
  58. import { useModal } from '/@/components/Modal';
  59. import { ListApi, unDeviceApi } from '/@/api/device/list';
  60. import AddModal from './AddModal.vue';
  61. import EditModal from './EditModal.vue';
  62. import { useI18n } from '/@/hooks/web/useI18n';
  63. // import { RoleEnum } from '/@/enums/roleEnum';
  64. // param type 0
  65. export default defineComponent({
  66. components: { BasicTable, TableAction, Tag, AddModal, EditModal, Time },
  67. setup() {
  68. const { createMessage } = useMessage();
  69. const [registerAddModal, { openModal: openAddModal }] = useModal();
  70. const [registerEditModal, { openModal: openEditModal }] = useModal();
  71. const { t } = useI18n();
  72. const columns: BasicColumn[] = [
  73. {
  74. title: t('routes.devices.childName'),
  75. dataIndex: 'childName',
  76. fixed: 'left',
  77. width: 220,
  78. },
  79. {
  80. title: t('routes.devices.phoneName'),
  81. dataIndex: 'userName',
  82. width: 230,
  83. },
  84. {
  85. title: t('routes.devices.companyId'),
  86. dataIndex: 'companyName',
  87. ifShow: false,
  88. width: 260,
  89. },
  90. {
  91. title: t('routes.devices.cameraType'),
  92. dataIndex: 'cameraType',
  93. width: 230,
  94. slots: { customRender: 'cameraType' },
  95. },
  96. {
  97. title: t('routes.devices.snCode'),
  98. dataIndex: 'snCode',
  99. width: 120,
  100. },
  101. {
  102. title: t('routes.devices.wifiName'),
  103. dataIndex: 'wifiName',
  104. width: 180,
  105. },
  106. {
  107. title: t('routes.devices.activationTime'),
  108. dataIndex: 'activatedTime',
  109. slots: { customRender: 'Time' },
  110. width: 150,
  111. },
  112. {
  113. title: t('routes.devices.shipmentType'),
  114. dataIndex: 'own',
  115. slots: { customRender: 'own' },
  116. width: 120,
  117. },
  118. {
  119. title: t('common.operating'),
  120. dataIndex: 'action',
  121. slots: { customRender: 'action' },
  122. // auth: [RoleEnum.SUPER, RoleEnum.PLAT_ADMIN],
  123. width: 130,
  124. },
  125. ];
  126. const searchForm: Partial<FormProps> = {
  127. labelWidth: 100,
  128. schemas: [
  129. // {
  130. // field: 'part',
  131. // component: 'Select',
  132. // label: t('routes.devices.deviceList'),
  133. // defaultValue: '1',
  134. // colProps: {
  135. // span: 4,
  136. // },
  137. // componentProps: {
  138. // options: [
  139. // {
  140. // label: '全部',
  141. // value: '1',
  142. // key: '1',
  143. // },
  144. // {
  145. // label: '正常',
  146. // value: '2',
  147. // key: '2',
  148. // },
  149. // {
  150. // label: '已关闭',
  151. // value: '2',
  152. // key: '2',
  153. // },
  154. // ],
  155. // },
  156. // },
  157. {
  158. field: 'searchKey',
  159. label: '关键字',
  160. labelWidth: 80,
  161. component: 'Input',
  162. componentProps: {
  163. maxLength: 100,
  164. placeholder: '支持搜索 手机号、sn码',
  165. },
  166. colProps: {
  167. span: 12,
  168. },
  169. },
  170. ],
  171. };
  172. // { getForm }
  173. const [registerTable, { reload }] = useTable({
  174. title: t('routes.devices.deviceList'),
  175. api: ListApi,
  176. columns: columns,
  177. useSearchForm: true,
  178. formConfig: searchForm,
  179. showTableSetting: true,
  180. tableSetting: { fullScreen: true },
  181. showIndexColumn: false,
  182. rowKey: 'id',
  183. fetchSetting: {
  184. pageField: 'page',
  185. sizeField: 'limit',
  186. listField: 'list',
  187. totalField: 'totalCount',
  188. },
  189. handleSearchInfoFn: function (searchData) {
  190. if (searchData.fieldTime) {
  191. searchData.startDate = searchData.fieldTime[0];
  192. searchData.endDate = searchData.fieldTime[1];
  193. delete searchData.fieldTime;
  194. }
  195. return searchData;
  196. },
  197. });
  198. function handleEditScenes(record: Recordable) {
  199. console.log('record', record);
  200. openEditModal(true, record);
  201. }
  202. async function handleUnbindDevice(record: Recordable) {
  203. await unDeviceApi({
  204. childName: record.childName,
  205. });
  206. createMessage.success(t('common.optSuccess'));
  207. reload();
  208. }
  209. function rendercameraTypeLabel(cameraType: number): string {
  210. switch (cameraType) {
  211. case 4:
  212. return '四维看看Pro八目相机';
  213. case 1:
  214. return '四维看看Lite双目相机';
  215. case 9:
  216. return '四维看看双目转台相机';
  217. case 10:
  218. return '四维看看激光相机';
  219. case 6:
  220. return '第三方相机';
  221. default:
  222. return '';
  223. }
  224. }
  225. function renderOwnTypeLabel(type: number): string {
  226. switch (type) {
  227. case 0:
  228. return '正常销售';
  229. case 2:
  230. return '礼品赠送';
  231. case 1:
  232. return '员工自用';
  233. case 3:
  234. return '其它';
  235. default:
  236. return '';
  237. }
  238. }
  239. return {
  240. registerTable,
  241. createMessage,
  242. rendercameraTypeLabel,
  243. renderOwnTypeLabel,
  244. registerAddModal,
  245. openAddModal,
  246. handleUnbindDevice,
  247. handleEditScenes,
  248. registerEditModal,
  249. t,
  250. reload,
  251. };
  252. },
  253. });
  254. </script>