detailModel.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <div>
  3. <BasicModal
  4. v-bind="$attrs"
  5. @register="register"
  6. title="授权详情"
  7. :width="800"
  8. @visible-change="handleVisibleChange"
  9. @ok="handleSubmit"
  10. >
  11. <div class="pt-3px pr-3px">
  12. <div class="table_list">
  13. <BasicTable @register="registerSubtable">
  14. <template #toolbar>
  15. <a-button type="primary" @click="handllogList" v-if="getCheckPerm('empowerCamera-loglist')"
  16. >更换记录</a-button
  17. >
  18. </template>
  19. <template #action="{ record }">
  20. <TableAction
  21. :actions="[
  22. {
  23. label: '更换',
  24. ifShow: getCheckPerm('empowerCamera-change'),
  25. onClick: handleUpdataSn.bind(null, record, 'edit'),
  26. },
  27. ]"
  28. />
  29. </template>
  30. </BasicTable>
  31. </div>
  32. </div>
  33. </BasicModal>
  34. <AddModal @register="registerupdata" @update="reload" />
  35. <AddListModal @register="registerList" @update="reload" />
  36. </div>
  37. </template>
  38. <script lang="ts">
  39. import { defineComponent, nextTick, onMounted, reactive, computed, h, ref } from 'vue';
  40. import { BasicTable, useTable, BasicColumn, TableAction } from '/@/components/Table';
  41. import { BasicModal, useModalInner } from '/@/components/Modal';
  42. import { BasicForm } from '/@/components/Form/index';
  43. import { Time } from '/@/components/Time';
  44. import { useMessage } from '/@/hooks/web/useMessage';
  45. import { useI18n } from '/@/hooks/web/useI18n';
  46. import AddModal from './uploadModal.vue';
  47. import AddListModal from './logListModal.vue';
  48. import { authorizeCameradetail } from '/@/api/authorizeModeling';
  49. import { GetCameraDetailApi, UnbindCameraApi } from '/@/api/account';
  50. import { otherInfoStore } from '/@/store/modules/other';
  51. import { DetailsApi, IncrementDelayApi } from '/@/api/account';
  52. import { usePermissionStore } from '/@/store/modules/permission';
  53. import { useModal } from '/@/components/Modal';
  54. const { t } = useI18n();
  55. export default defineComponent({
  56. components: { BasicModal, BasicForm, BasicTable, TableAction, AddModal, AddListModal },
  57. props: {
  58. userData: { type: Object },
  59. },
  60. emits: ['update'],
  61. setup(props, { emit }) {
  62. const otherInfo = otherInfoStore();
  63. const overviewInfo = computed(() => otherInfo.getOverviewInfo);
  64. const { createMessage, createConfirm } = useMessage();
  65. const [registerupdata, { openModal: openSnModal }] = useModal();
  66. const [registerList, { openModal }] = useModal();
  67. const permissionStore = usePermissionStore();
  68. const { getCheckPerm } = permissionStore;
  69. console.log('overviewInfo', overviewInfo);
  70. // const overviewInfo = getOverviewInfo() || {}
  71. const id = ref('');
  72. const fileFlow = reactive({
  73. file: null,
  74. id: '',
  75. type: 'down', //down-下载,equity-权益
  76. });
  77. const columns: BasicColumn[] = [
  78. {
  79. title: '相机类型',
  80. dataIndex: 'cameraType',
  81. width: 120,
  82. customRender: ({ record }) => {
  83. return t(`routes.product.type.${record.cameraType}`);
  84. },
  85. },
  86. {
  87. title: 'SN码',
  88. dataIndex: 'snCode',
  89. width: 150,
  90. },
  91. {
  92. title: t('common.operating'),
  93. dataIndex: 'action',
  94. ifShow: getCheckPerm('account-equityCameraUnbind'),
  95. slots: { customRender: 'action' },
  96. align: 'center',
  97. fixed: 'right',
  98. width: 30,
  99. },
  100. ];
  101. const [registerSubtable, { reload }] = useTable({
  102. title: `授权相机列表`,
  103. searchInfo: {
  104. userId: overviewInfo.value?.id,
  105. },
  106. api: () => {
  107. return authorizeCameradetail(id.value);
  108. },
  109. columns: columns,
  110. immediate: false,
  111. rowKey: 'id',
  112. fetchSetting: {
  113. pageField: 'pageNum',
  114. sizeField: 'pageSize',
  115. listField: 'list',
  116. totalField: 'total',
  117. },
  118. showIndexColumn: false,
  119. canResize: true,
  120. bordered: true,
  121. });
  122. onMounted(() => {});
  123. let addListFunc = () => {};
  124. const [register, { closeModal }] = useModalInner((data) => {
  125. data && onDataReceive(data);
  126. });
  127. function onDataReceive(data) {
  128. console.log('onDataReceive', data.id);
  129. id.value = data.id;
  130. fileFlow.id = data.id;
  131. reload();
  132. }
  133. function handllogList() {
  134. openModal(true, { id: id.value });
  135. }
  136. async function handleUpdataSn(record: Recordable) {
  137. openSnModal(true, { id: record.id, oldSnCode: record.snCode });
  138. }
  139. const handleSubmit = async () => {
  140. closeModal();
  141. emit('update');
  142. };
  143. function handleVisibleChange(v) {
  144. v && props.userData && nextTick(() => onDataReceive(props.userData));
  145. }
  146. return {
  147. register,
  148. registerList,
  149. registerupdata,
  150. fileFlow,
  151. handleVisibleChange,
  152. handleSubmit,
  153. addListFunc,
  154. registerSubtable,
  155. reload,
  156. handleUpdataSn,
  157. handllogList,
  158. getCheckPerm,
  159. t,
  160. };
  161. },
  162. });
  163. </script>