export default { data() { return { loading: false, searchForm: {}, pageInfo: { current: 1, size: 10, total: 0, }, tableData: [] } }, mounted() { this.init() }, onLoad({refresh}) { if(refresh === 'true' || refresh === true) { this.init() } }, methods: { init() { this.getList() }, search() { this.getList() }, reset() { this.$refs.searchForm?.resetFields() this.getList() }, getList() { this.loading = true this.tableData = [] this.getListFun()({ ...this.getConstantsQuery(), ...this.getQuery(), ...this.getPageInfo(), }).then(resp => { const list = this.parseList(resp) this.parsePageInfo(resp) this.tableData = list }).finally(_ => { this.loading = false }) }, parseList(resp) { return resp.data?.records || [] }, parsePageInfo(resp) { this.pageInfo = { current: resp.data.current, total: resp.data.total, size: resp.data.size, } }, getConstantsQuery() { return {} }, getQuery() { return this.searchForm }, getPageInfo() { return this.pageInfo }, getListFun() { return () => Promise.resolve([]) }, paginationChang({ type, current }) { this.pageInfo.current = current this.getList() }, view(data) { uni.navigateTo({ url: `${this.editPath}?action=view&json=${JSON.stringify(data)}` }) }, edit(data) { uni.navigateTo({ url: `${this.editPath}?action=edit&json=${JSON.stringify(data)}` }) }, isDelScucess(resp) { return resp.code === 200 }, getDelParam(data) { return data.id }, del(data) { console.log('dele'); uni.showModal({ title: '提示', content: '确认删除吗?', success: (res) => { if(res.confirm) { this.getDelFun()(this.getDelParam(data)).then(resp => { if(this.isDelScucess(resp)) { this.getList() }else { } }) } } }) } } }