123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- 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 {
-
- }
- })
- }
- }
- })
- }
- }
- }
|