1. 程式人生 > 實用技巧 >Vue + Element 後臺管理頁面之實現報表資料查詢與清空的按鈕

Vue + Element 後臺管理頁面之實現報表資料查詢與清空的按鈕

如圖:

程式碼如下:

<!-- 查詢清空按鈕 -->
          <span class="inline-span butt">
            <el-button type="primary" v-on:click="getFinaDetailsData" plain icon="el-icon-search">查詢</el-button>
            <el-button icon="el-icon-delete" v-on:click="resetData">清空</el-button>
          </span>

//一些資料變數須在data裡先宣告,自行新增
watch: { dateRangeParam: { handler (newValue, oldValue) { this.getFinaDetailsData() }, deep: true } }, methods: { // 點選查詢 getFinaDetailsData () { this.currentPage = 1 this.tempFormData = Object.assign({ start: this.dateRangeParam[0], end: this.dateRangeParam[1], storeId: this.storeId, orderId: this.orderId, payType: this.payType, incPayType: this.incPayType, minAmount: this.minAmount, maxAmount: this.maxAmount, current: this.currentPage, size: this.pageSize }) this.$http({ url: this.$http.adornUrl('專案地址'), method: 'get', params: this.$http.adornParams({ start: this.dateRangeParam[0], end: this.dateRangeParam[1], storeId: this.storeId, orderId: this.orderId, payType: this.payType, incPayType: this.incPayType, minAmount: this.minAmount, maxAmount: this.maxAmount, current: this.currentPage, size: this.pageSize }) }).then(({ data }) => { console.log(data) this.tableData = data.records // 將支付型別(int)轉中文(str) this.tableData.forEach(element => { element.payType = this.payTypeList[element.payType] }) this.currentPage = data.current this.pageSize = data.size this.pageTotal = data.total }) }, // 點選清空 resetData () { this.orderId = null this.payType = -1 this.incPayType = 0 this.maxAmount = null this.minAmount = null } }