index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <template>
  2. <PageWrapper contentBackground>
  3. <div class="desc-wrap-BasicTable">
  4. <BasicTable @register="registerTable">
  5. <template #toolbar>
  6. <a-button type="primary" v-if="hasPermission([RoleEnum.SUPER])" @click="handleAdd"> {{t('routes.retailer.allff')}}</a-button>
  7. </template>
  8. <template #action="{ record }">
  9. <TableAction
  10. stopButtonPropagation
  11. :actions="[
  12. {
  13. label: t('routes.retailer.ff'),
  14. ifShow: !record.subAgentName,
  15. //icon: 'la:file-invoice-dollar',
  16. onClick: headleDetails.bind(null, record),
  17. },
  18. {
  19. label: t('routes.retailer.Unbind'),
  20. ifShow: !!record.subAgentName,
  21. //icon: 'la:file-invoice-dollar',
  22. onClick: headleUnbind.bind(null, record),
  23. },
  24. ]"
  25. />
  26. </template>
  27. </BasicTable>
  28. </div>
  29. <distributeModal @reload="reload" @register="registerAddModal" />
  30. </PageWrapper>
  31. </template>
  32. <script lang="ts">
  33. import { defineComponent, h, onMounted, computed } from 'vue';
  34. import {
  35. BasicTable,
  36. useTable,
  37. TableAction,
  38. BasicColumn,
  39. TableImg,
  40. FormProps,
  41. } from '/@/components/Table';
  42. import { usePermission } from '/@/hooks/web/usePermission';
  43. import { RoleEnum } from '/@/enums/roleEnum';
  44. import { PageWrapper } from '/@/components/Page';
  45. import { Descriptions } from 'ant-design-vue';
  46. import { useI18n } from '/@/hooks/web/useI18n';
  47. import { useMessage } from '/@/hooks/web/useMessage';
  48. import { cameraList } from '/@/api/customer';
  49. import { cameraDelete } from '/@/api/device';
  50. import { useModal } from '/@/components/Modal';
  51. import { getSubAgent } from '/@/api/retailer';
  52. import { useRouter } from 'vue-router';
  53. import { UnbindCameraApi } from '/@/api/account';
  54. import { usePermissionStore } from '/@/store/modules/permission';
  55. import { useLocaleStore } from '/@/store/modules/locale';
  56. import { dincrementList } from '/@/api/equity';
  57. import { useUserStore } from '/@/store/modules/user';
  58. import distributeModal from './distributeModal.vue';
  59. export default defineComponent({
  60. components: {
  61. BasicTable,
  62. TableAction,
  63. PageWrapper,
  64. TableImg,
  65. distributeModal,
  66. [Descriptions.name]: Descriptions,
  67. [Descriptions.Item.name]: Descriptions.Item,
  68. },
  69. setup() {
  70. const { t } = useI18n();
  71. const userStore = useUserStore();
  72. const getUserInfo = userStore.getUserInfo;
  73. const { hasPermission } = usePermission();
  74. const { createMessage, createConfirm } = useMessage();
  75. const permissionStore = usePermissionStore();
  76. const { getCheckPerm } = permissionStore;
  77. const router = useRouter();
  78. const localeStore = useLocaleStore();
  79. const isEn = computed(() => localeStore.getLocale === 'en');
  80. const companyId: Number = router.currentRoute.value.params.id - 0;
  81. const [registerAddModal, { openModal }] = useModal();
  82. onMounted(() => {
  83. // console.log(router.currentRoute.value.params.id);
  84. });
  85. const columns: BasicColumn[] = [
  86. {
  87. title: t('routes.device.snCode'),
  88. dataIndex: 'snCode',
  89. width: 180,
  90. },
  91. {
  92. title: t('routes.device.wifiName'),
  93. dataIndex: 'wifiName',
  94. width: 150,
  95. },
  96. {
  97. title: t('routes.device.deviceType'),
  98. dataIndex: 'type',
  99. ellipsis: false,
  100. width: 100,
  101. customRender: ({ record }) => {
  102. let typeObj = {
  103. '0': t('routes.device.type.0'),
  104. '1': t('routes.device.type.1'),
  105. '2': t('routes.device.type.2'),
  106. '9': t('routes.device.type.9'),
  107. '10': t('routes.device.type.10'),
  108. '11': t('routes.device.type.11'),
  109. };
  110. return typeObj[record.type];
  111. },
  112. },
  113. {
  114. title: t('routes.device.activatedTime'),
  115. dataIndex: 'activatedTime',
  116. width: 180,
  117. },
  118. {
  119. title: t('routes.retailer.fxs'),
  120. dataIndex: 'subAgentName',
  121. ellipsis: true,
  122. width: 160,
  123. ifShow: hasPermission([RoleEnum.SUPER]),
  124. customRender({ record }) {
  125. return record.subAgentName || '-';
  126. }
  127. },
  128. {
  129. title: t('routes.equity.Type'),
  130. dataIndex: 'validTimeType',
  131. width: 180,
  132. customRender({ record }) {
  133. return record.validTimeType == 0
  134. ? t('routes.equity.equityType.0')
  135. : record.validTimeType == 1
  136. ? t('routes.equity.equityType.3')
  137. : t('routes.device.NoBind');
  138. },
  139. },
  140. {
  141. title: t('routes.device.statusName'),
  142. dataIndex: 'incrementStatus',
  143. customRender({ record }) {
  144. if (record.incrementStatus == -1) {
  145. return '-';
  146. } else {
  147. return record.incrementStatus == 0
  148. ? t('routes.device.status.0')
  149. : t('routes.device.status.1');
  150. }
  151. },
  152. width: 180,
  153. },
  154. {
  155. title: t('routes.device.userName'),
  156. dataIndex: 'userName',
  157. width: 180,
  158. customRender({ record }) {
  159. return record.userName ? record.userName : '-';
  160. },
  161. },
  162. ];
  163. const searchForm: Partial<FormProps> = {
  164. labelWidth: 120,
  165. autoAdvancedLine: 1,
  166. actionColOptions: {
  167. span: 24,
  168. },
  169. schemas: [
  170. {
  171. field: 'snCode',
  172. component: 'Input',
  173. label: t('routes.device.snCode'),
  174. colProps: {
  175. xl: 8,
  176. xxl: 8,
  177. },
  178. },
  179. {
  180. field: 'type',
  181. component: 'Select',
  182. label: t('routes.device.deviceType'),
  183. colProps: {
  184. xl: 8,
  185. xxl: 8,
  186. },
  187. componentProps: {
  188. options: [
  189. {
  190. // label: t('routes.device.type.0'),
  191. // value: 0,
  192. // key: '0',
  193. // },{
  194. label: t('routes.device.type.1'),
  195. value: 1,
  196. key: '1',
  197. },
  198. {
  199. label: t('routes.device.type.2'),
  200. value: 9,
  201. key: '9',
  202. },
  203. {
  204. label: t('routes.device.type.3'),
  205. value: 10,
  206. key: '10',
  207. },
  208. {
  209. label: t('routes.device.type.11'),
  210. value: 11,
  211. key: '11',
  212. },
  213. ],
  214. },
  215. },
  216. {
  217. field: 'userName',
  218. component: 'Input',
  219. label: t('routes.device.userName'),
  220. colProps: {
  221. xl: 8,
  222. xxl: 8,
  223. },
  224. },
  225. {
  226. field: 'incrementTypeId',
  227. component: 'ApiSelect',
  228. label: t('routes.equity.Type'),
  229. componentProps: {
  230. maxLength: 50,
  231. api: async function () {
  232. const list = await dincrementList();
  233. return list.map((ele) => {
  234. return {
  235. name: t(`routes.finance.equityType.${ele.validTimeType}`),
  236. value: ele.id,
  237. };
  238. });
  239. },
  240. numberToString: true,
  241. labelField: 'name',
  242. valueField: 'value',
  243. immediate: true,
  244. },
  245. colProps: {
  246. xl: 8,
  247. xxl: 8,
  248. },
  249. },
  250. {
  251. field: 'incrementStatus',
  252. component: 'Select',
  253. label: t('routes.device.statusName'),
  254. colProps: {
  255. xl: 8,
  256. xxl: 8,
  257. },
  258. componentProps: {
  259. options: [
  260. {
  261. label: t('routes.device.status.0'),
  262. value: '0',
  263. key: '0',
  264. },
  265. {
  266. label: t('routes.device.status.1'),
  267. value: '1',
  268. key: '1',
  269. },
  270. ],
  271. },
  272. },
  273. {
  274. field: 'bindStatus',
  275. component: 'Select',
  276. label: t('routes.device.bindStatus'),
  277. colProps: {
  278. xl: 8,
  279. xxl: 8,
  280. },
  281. componentProps: {
  282. options: [
  283. {
  284. label: t('routes.device.status.2'),
  285. value: '1',
  286. key: '1',
  287. },
  288. {
  289. label: t('routes.device.status.3'),
  290. value: '0',
  291. key: '0',
  292. },
  293. ],
  294. },
  295. },
  296. {
  297. field: 'subAgentId',
  298. component: 'ApiSelect',
  299. ifShow: hasPermission([RoleEnum.SUPER]),
  300. label: t('routes.device.subAgentName'),
  301. componentProps: {
  302. maxLength: 50,
  303. api: getSubAgent,
  304. numberToString: true,
  305. labelField: 'name',
  306. valueField: 'id',
  307. immediate: true,
  308. style: { maxWidth: '430px' },
  309. },
  310. colProps: {
  311. xl: 8,
  312. xxl: 8,
  313. },
  314. },
  315. ],
  316. };
  317. const [registerTable, { reload }] = useTable({
  318. api: cameraList,
  319. columns: columns,
  320. searchInfo: { companyId },
  321. useSearchForm: true,
  322. formConfig: searchForm,
  323. showTableSetting: true,
  324. showIndexColumn: false,
  325. rowKey: 'id',
  326. beforeFetch: (T) => {
  327. if (T.ctivated) {
  328. T.activatedStartTime = T.ctivated[0];
  329. T.activatedEndTime = T.ctivated[1];
  330. }
  331. return T;
  332. },
  333. fetchSetting: {
  334. pageField: 'pageNum',
  335. sizeField: 'pageSize',
  336. listField: 'list',
  337. totalField: 'total',
  338. },
  339. actionColumn: {
  340. width: 150,
  341. title: t('common.operating'),
  342. ifShow: hasPermission([RoleEnum.SUPER]),
  343. dataIndex: 'action',
  344. slots: { customRender: 'action' },
  345. },
  346. canResize: false,
  347. });
  348. async function headleUnbind(record: Recordable) {
  349. createConfirm({
  350. iconType: 'warning',
  351. title: () => h('span', t('common.reminder')),
  352. content: t('routes.retailer.UnbindTips'),
  353. onOk: async () => {
  354. await UnbindCameraApi({ id: record.id });
  355. createMessage.success(t('common.optSuccess'));
  356. reload();
  357. },
  358. });
  359. }
  360. async function handleDelete(record: Recordable) {
  361. createConfirm({
  362. iconType: 'warning',
  363. title: () => h('span', t('common.reminder')),
  364. content: '删除设备后需要重新入库<br/>确定删除吗?',
  365. onOk: async () => {
  366. await cameraDelete({ id: record.id });
  367. createMessage.success(t('common.optSuccess'));
  368. reload();
  369. },
  370. });
  371. }
  372. function handleAdd() {
  373. openModal(true, {});
  374. }
  375. function headleDetails(record: Recordable) {
  376. openModal(true, record);
  377. }
  378. return {
  379. registerTable,
  380. headleUnbind,
  381. reload,
  382. handleDelete,
  383. getCheckPerm,
  384. handleAdd,
  385. headleDetails,
  386. registerAddModal,
  387. hasPermission,
  388. RoleEnum,
  389. t,
  390. };
  391. },
  392. });
  393. </script>
  394. <style lang="less" scoped>
  395. .desc-wrap-BasicTable {
  396. background-color: #f0f2f5;
  397. .vben-basic-table-form-container {
  398. padding: 0;
  399. }
  400. }
  401. </style>