| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- import SaveForm from '@/components/save-form'
- import Pagination from '@/components/pagination'
- import { NButton, NDataTable, NModal, NSpace, useDialog, useMessage } from 'naive-ui'
- import { defineComponent, onMounted, reactive, ref } from 'vue'
- import { helpCenterCatalogPage, helpCenterCatalogRemove } from '../../api'
- import HelpCenterCategoryOperation from '../modal/help-center-category-operation'
- export default defineComponent({
- name: 'content-flash',
- setup() {
- const dialog = useDialog()
- const message = useMessage()
- const state = reactive({
- loading: false,
- pagination: {
- page: 1,
- rows: 10,
- pageTotal: 0
- },
- dataList: [] as any,
- visiableCategory: false,
- categoryOperation: 'add',
- categoryData: {} as any
- })
- const columns = () => {
- return [
- {
- title: '编号',
- key: 'id'
- },
- {
- title: '名称',
- key: 'name'
- },
- {
- title: '操作',
- key: 'operation',
- render(row: any) {
- return (
- <NSpace>
- <NButton
- type="primary"
- size="small"
- text
- //v-auth="helpCenterCatalog/update1599694974123089922"
- onClick={() => {
- state.visiableCategory = true
- state.categoryOperation = 'edit'
- state.categoryData = row
- }}
- >
- 修改
- </NButton>
- <NButton
- type="primary"
- size="small"
- text
- onClick={() => onRmove(row)}
- //v-auth="helpCenterCatalog/remove1599695049448595458"
- >
- 删除
- </NButton>
- </NSpace>
- )
- }
- }
- ]
- }
- const onRmove = (row: any): void => {
- console.log(row, 'row')
- dialog.warning({
- title: '警告',
- content: `是否删除该数据?`,
- positiveText: '确定',
- negativeText: '取消',
- onPositiveClick: async () => {
- try {
- await helpCenterCatalogRemove({ id: row.id })
- getList()
- message.success('删除成功')
- } catch {}
- }
- })
- }
- const getList = async () => {
- try {
- state.loading = true
- const { data } = await helpCenterCatalogPage({ ...state.pagination })
- state.loading = false
- state.pagination.pageTotal = Number(data.total)
- state.dataList = data.rows || []
- } catch {
- state.loading = false
- }
- }
- onMounted(() => {
- getList()
- })
- return () => (
- <div class="system-menu-container">
- <div class={['section-container']}>
- <NSpace style={{ paddingBottom: '12px' }}>
- <NButton
- type="primary"
- //v-auth="helpCenterCatalog/save1599694895257591809"
- onClick={() => {
- state.visiableCategory = true
- state.categoryOperation = 'add'
- state.categoryData = {}
- }}
- >
- 添加分类
- </NButton>
- </NSpace>
- <NDataTable
- loading={state.loading}
- columns={columns()}
- data={state.dataList}
- ></NDataTable>
- <Pagination
- v-model:page={state.pagination.page}
- v-model:pageSize={state.pagination.rows}
- v-model:pageTotal={state.pagination.pageTotal}
- onList={getList}
- sync
- saveKey="help-center-category"
- ></Pagination>
- </div>
- <NModal
- v-model:show={state.visiableCategory}
- preset="dialog"
- showIcon={false}
- title={state.categoryOperation === 'add' ? '新增帮助分类' : '修改帮助分类'}
- style={{ width: '500px' }}
- >
- <HelpCenterCategoryOperation
- type={state.categoryOperation}
- data={state.categoryData}
- onClose={() => (state.visiableCategory = false)}
- onGetList={getList}
- />
- </NModal>
- </div>
- )
- }
- })
|