import Pagination from '@/components/pagination' import { NButton, NDataTable, NDatePicker, NFormItem, NInput, NModal, NSelect, NSpace, NTag, useDialog, useMessage } from 'naive-ui' import { defineComponent, onMounted, reactive, ref } from 'vue' import SaveForm from '@components/save-form' import { musicalInstrumentPage, musicalInstrumentUpdateStatus } from '@views/system-manage/subject-manage/api' import { getMapValueByKey } from '@/utils/filters' import { defaultScore } from '@/utils/constant' import { getSelectDataFromObj } from '@/utils/objectUtil' import InstrumentSave from '@views/system-manage/subject-manage/instrument/modal/instrument-save' import { filterTimes } from '@/utils/dateUtil' export default defineComponent({ name: 'instrument-list', setup() { const dialog = useDialog() const message = useMessage() const state = reactive({ loading: false, pagination: { page: 1, rows: 10, pageTotal: 0 }, searchForm: { keyword: '', timer: null, startTime: null, endTime: null, defaultScore: null, //默认谱面 code: null, //编码 operatorKeyword: null //操作人 }, dataList: [] as any, showSave: false, saveMode: 'add', rowData: {} }) const saveForm = ref() const onSubmit = () => { state.pagination.page = 1 getList() } const onSearch = () => { saveForm.value?.submit() } const onChangeStatus = (row: any) => { const statusStr = row.enableFlag ? '停用' : '启用' dialog.warning({ title: '提示', content: `是否${statusStr}?`, positiveText: '确定', negativeText: '取消', onPositiveClick: async () => { try { await musicalInstrumentUpdateStatus({ id: row.id }) getList() message.success(`${statusStr}成功`) } catch {} } }) } const onBtnReset = () => { saveForm.value?.reset() } const columns = () => { return [ { title: '编号', key: 'id' }, { title: '乐器名称', key: 'name' }, { title: '乐器编码', key: 'code' }, { title: '声部', key: 'subjectName' }, { title: '默认谱面', key: 'defaultScore', render(row: any) { return getMapValueByKey(row.defaultScore, new Map(Object.entries(defaultScore))) } }, { title: '操作人', key: 'operator', render(row: any) { return (