interesModal.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <div>
  3. <AddModal @register="registerAddModal" />
  4. <BasicModal
  5. v-bind="$attrs"
  6. @register="register"
  7. title="权益详情"
  8. :width="900"
  9. @visible-change="handleVisibleChange"
  10. @ok="handleSubmit"
  11. >
  12. <div class="pt-3px pr-3px">
  13. <div class="table_list">
  14. <BasicTable @register="registerSubtable" >
  15. <template #action="{ record }">
  16. <TableAction
  17. :actions="[
  18. {
  19. label: '续费',
  20. onClick: handleDelete.bind(null, record, 'edit'),
  21. },
  22. ]"
  23. />
  24. </template>
  25. </BasicTable>
  26. </div>
  27. </div>
  28. </BasicModal>
  29. </div>
  30. </template>
  31. <script lang="ts">
  32. import { defineComponent, nextTick, onMounted, reactive, computed,h } from 'vue';
  33. import { BasicTable, useTable, BasicColumn,TableAction } from '/@/components/Table';
  34. import { BasicModal, useModalInner } from '/@/components/Modal';
  35. import { BasicForm } from '/@/components/Form/index';
  36. import { Time } from '/@/components/Time';
  37. import AddModal from './AddModal.vue';
  38. import { useMessage } from '/@/hooks/web/useMessage';
  39. import { useI18n } from '/@/hooks/web/useI18n';
  40. import { GetCameraDetailApi,UnbindCameraApi } from '/@/api/account';
  41. import { otherInfoStore } from '/@/store/modules/other'
  42. import { DetailsApi,IncrementDelayApi } from '/@/api/account';
  43. import { usePermissionStore } from '/@/store/modules/permission';
  44. import { useModal } from '/@/components/Modal';
  45. const { t } = useI18n();
  46. export default defineComponent({
  47. components: { BasicModal, BasicForm, BasicTable,TableAction, AddModal },
  48. props: {
  49. userData: { type: Object },
  50. },
  51. emits: ['update', 'register'],
  52. setup(props, { emit }) {
  53. const otherInfo = otherInfoStore();
  54. const overviewInfo = computed(() => otherInfo.getOverviewInfo);
  55. const { createMessage, createConfirm } = useMessage();
  56. const [registerAddModal, { openModal: openAddModal }] = useModal();
  57. const permissionStore = usePermissionStore();
  58. const { getCheckPerm } = permissionStore;
  59. console.log('overviewInfo',overviewInfo)
  60. // const overviewInfo = getOverviewInfo() || {}
  61. const fileFlow = reactive({
  62. file:null,
  63. id:'',
  64. type:'down',//down-下载,equity-权益
  65. })
  66. const columns: BasicColumn[] = [
  67. {
  68. title: '会员权益ID',
  69. dataIndex: 'id',
  70. width: 100,
  71. customRender: ({ record }) => {
  72. return record.memberLevels? (record.memberLevels +' '+ record.id): record.id;
  73. },
  74. },
  75. {
  76. title: '权益类型',
  77. width: 100,
  78. dataIndex: 'memberLevels',
  79. customRender: ({ record }) => {
  80. let obj = {
  81. 'PR': '专业会员',
  82. 'SE': '高级会员',
  83. }
  84. return obj[record.memberLevels] || '';
  85. },
  86. },
  87. {
  88. title: '使用类型',
  89. width: 100,
  90. dataIndex: 'useTypeStr',
  91. },
  92. {
  93. title: '授权相机S/N吗',
  94. width: 160,
  95. dataIndex: 'snCode',
  96. },
  97. {
  98. title: '购买日期',
  99. dataIndex: 'incrementStartTime',
  100. width: 120,
  101. customRender: ({ record }) => {
  102. return record.incrementStartTime
  103. ? h(Time, {
  104. value: record.incrementStartTime,
  105. mode: 'date',
  106. })
  107. : '-';
  108. },
  109. },
  110. {
  111. title: '到期日期',
  112. dataIndex: 'incrementEndTime',
  113. width: 120,
  114. customRender: ({ record }) => {
  115. return record.incrementEndTime
  116. ? h(Time, {
  117. value: record.incrementEndTime,
  118. mode: 'date',
  119. })
  120. : '-';
  121. },
  122. },
  123. {
  124. title: '项目号',
  125. width: 100,
  126. dataIndex: 'projectNum',
  127. },
  128. {
  129. title: '备注',
  130. width: 100,
  131. dataIndex: 'remark',
  132. },
  133. {
  134. title: t('common.operating'),
  135. ifShow:getCheckPerm('account-equityRenew'),
  136. dataIndex: '',
  137. slots: { customRender: 'action' },
  138. width: 60,
  139. },
  140. ];
  141. const [
  142. registerSubtable,
  143. {
  144. reload,
  145. },
  146. ] = useTable({
  147. // title: `查看相机详情`,
  148. searchInfo:{
  149. id:overviewInfo.value?.id
  150. },
  151. api: DetailsApi,
  152. rowKey: 'id',
  153. fetchSetting: {
  154. pageField: 'pageNum',
  155. sizeField: 'pageSize',
  156. listField: 'list',
  157. totalField: 'total',
  158. },
  159. columns: columns,
  160. showIndexColumn: false,
  161. bordered: true,
  162. canResize: true,
  163. // pagination: false,
  164. });
  165. onMounted(() => {});
  166. let addListFunc = () => {};
  167. const [register, { closeModal }] = useModalInner((data) => {
  168. reload()
  169. data && onDataReceive(data);
  170. });
  171. function onDataReceive(data) {
  172. console.log('onDataReceive',data)
  173. fileFlow.id = data.id
  174. }
  175. async function handleDelete (record: Recordable) {
  176. openAddModal(true, {
  177. userId: overviewInfo.value && overviewInfo.value.id,
  178. ...record,
  179. });
  180. // createConfirm({
  181. // iconType: 'warning',
  182. // title: () => h('span', '续费提示'),
  183. // content: () => h('span', `您确定给权益ID${record.id}续期${record.validTimeType == 1?'1月':'1年'}!`),
  184. // onOk: async () => {
  185. // await await IncrementDelayApi({id:record.id,year:1})
  186. // createMessage.success(t('common.optSuccess'));
  187. // otherInfo.updateOverviewInfo()
  188. // reload()
  189. // },
  190. // });
  191. }
  192. const handleSubmit = async () => {
  193. closeModal();
  194. emit('update');
  195. };
  196. function handleVisibleChange(v) {
  197. v && props.userData && nextTick(() => onDataReceive(props.userData));
  198. }
  199. return {
  200. register,
  201. fileFlow,
  202. handleVisibleChange,
  203. handleSubmit,
  204. addListFunc,
  205. registerSubtable,
  206. reload,
  207. registerAddModal,
  208. handleDelete,
  209. t,
  210. };
  211. },
  212. });
  213. </script>