account.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <PageWrapper contentBackground>
  3. <div class="desc-wrap-BasicTable">
  4. <BasicTable @register="registerTable">
  5. <template #toolbar>
  6. <a-button type="primary" @click="openModal(true, {language})" v-if="getCheckPerm('news-add')">
  7. 新增经销商</a-button
  8. >
  9. </template>
  10. <template #action="{ record }">
  11. <TableAction
  12. stopButtonPropagation
  13. :actions="[
  14. {
  15. label: '权益设置',
  16. //icon: 'icon-park-outline:folder-withdrawal-one',
  17. ifShow: getCheckPerm('news-withdraw'),
  18. onClick: handleWithdraw.bind(null, record),
  19. },
  20. {
  21. label: '编辑',
  22. //icon: 'ep:edit',
  23. ifShow: getCheckPerm('news-edit'),
  24. onClick: handleEdit.bind(null, record),
  25. },
  26. {
  27. label: '删除',
  28. //icon: 'ic:outline-delete-outline',
  29. ifShow: getCheckPerm('news-delete'),
  30. onClick: handleDelete.bind(null, record),
  31. },
  32. ]"
  33. />
  34. </template>
  35. </BasicTable>
  36. </div>
  37. <addNewModal @register="register" @update="reload" />
  38. <editNewModal @register="registerEdit" @update="reload" />
  39. <financeModal @register="registerFinance" @update="reload" />
  40. </PageWrapper>
  41. </template>
  42. <script lang="ts">
  43. import { defineComponent, h, ref } from 'vue';
  44. import {
  45. BasicTable,
  46. useTable,
  47. TableAction,
  48. BasicColumn,
  49. TableImg,
  50. FormProps,
  51. } from '/@/components/Table';
  52. import { PageWrapper } from '/@/components/Page';
  53. import { Time } from '/@/components/Time';
  54. import { agentNewList, agentNewDel } from '/@/api/dealer';
  55. import { Descriptions, Tabs } from 'ant-design-vue';
  56. import { useModal } from '/@/components/Modal';
  57. import { useI18n } from '/@/hooks/web/useI18n';
  58. import { useMessage } from '/@/hooks/web/useMessage';
  59. import addNewModal from './components/addModal.vue';
  60. import editNewModal from './components/editModal.vue';
  61. import financeModal from './components/financeModal.vue';
  62. import { usePermissionStore } from '/@/store/modules/permission';
  63. export default defineComponent({
  64. components: {
  65. BasicTable,
  66. TableAction,
  67. PageWrapper,
  68. TableImg,
  69. addNewModal,
  70. editNewModal,
  71. financeModal,
  72. [Descriptions.name]: Descriptions,
  73. [Descriptions.Item.name]: Descriptions.Item,
  74. [Tabs.name]: Tabs,
  75. [Tabs.TabPane.name]: Tabs.TabPane,
  76. },
  77. setup() {
  78. const { t } = useI18n();
  79. const { createMessage, createConfirm } = useMessage();
  80. const permissionStore = usePermissionStore();
  81. const { getCheckPerm } = permissionStore;
  82. const [register, { openModal }] = useModal();
  83. const [registerEdit, { openModal:openEditModal }] = useModal();
  84. const [registerFinance, { openModal:openFinanceModal }] = useModal();
  85. const language = ref<string>('cn'); //未处理,0已处理(默认1)
  86. const columns: BasicColumn[] = [
  87. {
  88. title: '经销商名称',
  89. dataIndex: 'name',
  90. ellipsis: true,
  91. width: 250,
  92. },
  93. {
  94. title: '联系人',
  95. dataIndex: 'nickName',
  96. ellipsis: true,
  97. width: 250,
  98. },
  99. {
  100. title: '账号',
  101. ellipsis: true,
  102. dataIndex: 'userName',
  103. width: 120,
  104. },
  105. {
  106. title: '创建人',
  107. ellipsis: true,
  108. dataIndex: 'sysUserName',
  109. width: 120,
  110. },
  111. {
  112. title: '创建时间',
  113. dataIndex: 'createTime',
  114. width: 150,
  115. customRender: ({ record }) => {
  116. return (
  117. record.createTime &&
  118. h(Time, {
  119. value: record.createTime,
  120. mode: 'datetime',
  121. })
  122. );
  123. },
  124. },
  125. ];
  126. const searchForm: Partial<FormProps> = {
  127. labelWidth: 100,
  128. autoSubmitOnEnter: true,
  129. schemas: [
  130. {
  131. field: 'name',
  132. label: '经销商名称',
  133. component: 'Input',
  134. colProps: {
  135. xl: 7,
  136. xxl: 7,
  137. },
  138. },
  139. ],
  140. };
  141. const [registerTable, { reload }] = useTable({
  142. api: agentNewList,
  143. title: '经销商账号列表',
  144. columns: columns,
  145. useSearchForm: true,
  146. formConfig: searchForm,
  147. showTableSetting: true,
  148. showIndexColumn: false,
  149. searchInfo: { language },
  150. rowKey: 'id',
  151. fetchSetting: {
  152. pageField: 'pageNum',
  153. sizeField: 'pageSize',
  154. listField: 'list',
  155. totalField: 'total',
  156. },
  157. beforeFetch: (T) => {
  158. if (T.ctivated) {
  159. T.publicTimeStart = T.ctivated[0];
  160. T.publicTimeEnd = T.ctivated[1];
  161. }
  162. return T;
  163. },
  164. actionColumn: {
  165. width: 220,
  166. title: '操作',
  167. dataIndex: 'action',
  168. slots: { customRender: 'action' },
  169. },
  170. canResize: true,
  171. });
  172. async function handleDelete(record: Recordable) {
  173. createConfirm({
  174. iconType: 'warning',
  175. title: () => h('span', '温馨提示'),
  176. content: () => h('span', '确定要删除吗?'),
  177. onOk: async () => {
  178. await agentNewDel({ id: record.id });
  179. createMessage.success(t('common.optSuccess'));
  180. reload();
  181. },
  182. });
  183. }
  184. async function handlePublish(record: Recordable) {
  185. console.log('点击了发布', record);
  186. await casePublicApi({ id: record.id, isPublic: 1 });
  187. createMessage.success(t('common.optSuccess'));
  188. reload();
  189. }
  190. function handleEdit(record: Recordable) {
  191. console.log('点击了编辑', record);
  192. openEditModal(true, {...record,language});
  193. }
  194. async function handleWithdraw(record: Recordable) {
  195. openFinanceModal(true, {...record});
  196. // await casePublicApi({ id: record.id, isPublic: 0 });
  197. // createMessage.success(t('common.optSuccess'));
  198. // reload();
  199. }
  200. function changeTable(val: string) {
  201. language.value = val;
  202. reload();
  203. }
  204. function hendleAddNew() {
  205. console.log('新增新闻');
  206. }
  207. return {
  208. registerTable,
  209. handleDelete,
  210. handleEdit,
  211. handleWithdraw,
  212. handlePublish,
  213. hendleAddNew,
  214. changeTable,
  215. reload,
  216. language,
  217. register,
  218. registerFinance,
  219. registerEdit,
  220. openModal,
  221. getCheckPerm,
  222. };
  223. },
  224. });
  225. </script>