From cfa6aa1bba4e4c55a8f88174aa93afab86bb33cd Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期三, 13 九月 2023 15:49:24 +0800
Subject: [PATCH] lingyang配置问卷
---
web_standard/src/components/base/BaseTable.vue | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 104 insertions(+), 15 deletions(-)
diff --git a/web_standard/src/components/base/BaseTable.vue b/web_standard/src/components/base/BaseTable.vue
index 016fbda..b242c97 100644
--- a/web_standard/src/components/base/BaseTable.vue
+++ b/web_standard/src/components/base/BaseTable.vue
@@ -3,7 +3,7 @@
export default {
name: 'BaseTable',
extends: BasePage,
- data () {
+ data() {
return {
// 鎺ュ彛
api: null,
@@ -51,7 +51,7 @@
*
* @param extParams 閰嶇疆鍙傛暟
*/
- config (extParams) {
+ config(extParams) {
if (extParams == null) {
throw new Error('Parameter can not be null of method \'config\' .')
}
@@ -70,13 +70,13 @@
/**
* 鎼滅储锛堢偣鍑绘悳绱㈡寜閽椂瑙﹀彂锛�
*/
- search () {
+ search() {
this.handlePageChange(1)
},
/**
* 瀵煎嚭Excel锛堢偣鍑诲鍑烘寜閽椂瑙﹀彂锛�
*/
- exportExcel () {
+ exportExcel() {
this.__checkApi()
this.$dialog.exportConfirm('纭瀵煎嚭鍚楋紵')
.then(() => {
@@ -108,7 +108,7 @@
/**
* 閲嶇疆鎼滅储鏉′欢锛堢偣鍑婚噸缃寜閽椂瑙﹀彂锛�
*/
- reset () {
+ reset() {
this.$refs.searchForm.resetFields()
this.search()
},
@@ -117,7 +117,7 @@
*
* @param pageSize 椤靛閲�
*/
- handleSizeChange (pageSize) {
+ handleSizeChange(pageSize) {
this.tableData.pagination.pageSize = pageSize
this.search()
},
@@ -126,7 +126,7 @@
*
* @param selectedRows 宸查�変腑鐨勮鏁扮粍
*/
- handleSelectionChange (selectedRows) {
+ handleSelectionChange(selectedRows) {
this.tableData.selectedRows = selectedRows
},
/**
@@ -134,7 +134,7 @@
*
* @param sortData 鎺掑簭鍙傛暟
*/
- handleSortChange (sortData) {
+ handleSortChange(sortData) {
this.tableData.sorts = []
if (sortData.order != null) {
this.tableData.sorts.push({
@@ -149,7 +149,7 @@
*
* @param pageIndex 鏂伴〉鐮�
*/
- handlePageChange (pageIndex) {
+ handlePageChange(pageIndex) {
this.__checkApi()
this.tableData.pagination.pageIndex = pageIndex || this.tableData.pagination.pageIndex
this.isWorking.search = true
@@ -176,7 +176,7 @@
* @param row 琛屽璞�
* @param childConfirm 鍒犻櫎瀛愯妭鐐规椂鏄惁杩涜浜屾纭
*/
- deleteById (row, childConfirm = true) {
+ deleteById(row, childConfirm = true) {
this.__checkApi()
let message = `纭鍒犻櫎${this.module}銆�${row[this.configData['field.main']]}銆戝悧?`
if (childConfirm && row.children != null && row.children.length > 0) {
@@ -196,14 +196,14 @@
this.isWorking.delete = false
})
})
- .catch(() => {})
+ .catch(() => { })
},
/**
* 鎵归噺鍒犻櫎锛堢偣鍑绘壒閲忓垹闄ゆ椂瑙﹀彂锛�
*
* @param childConfirm 鍒犻櫎瀛愯妭鐐规椂鏄惁杩涜浜屾纭
*/
- deleteByIdInBatch (childConfirm = true) {
+ deleteByIdInBatch(childConfirm = true) {
this.__checkApi()
if (this.tableData.selectedRows.length === 0) {
this.$tip.warning('璇疯嚦灏戦�夋嫨涓�鏉℃暟鎹�')
@@ -235,7 +235,7 @@
this.isWorking.delete = false
})
})
- .catch(() => {})
+ .catch(() => { })
},
/**
* 鍒犻櫎鍚庡鐞嗭紝鍦ㄥ崟琛屽垹闄ゆ垨澶氳鍒犻櫎鍚庤皟鐢�
@@ -243,7 +243,7 @@
* @param deleteCount 鍒犻櫎鏁伴噺
* @private
*/
- __afterDelete (deleteCount = 1) {
+ __afterDelete(deleteCount = 1) {
this.$tip.apiSuccess('鍒犻櫎鎴愬姛')
// 鍒犻櫎褰撳墠椤垫渶鍚庝竴鏉¤褰曟椂鏌ヨ涓婁竴椤垫暟鎹�
if (this.tableData.list.length - deleteCount === 0) {
@@ -257,12 +257,101 @@
*
* @private
*/
- __checkApi () {
+ __checkApi() {
console.log(this.api);
if (this.api == null) {
throw new Error('The page is not initialized, you can use method \'this.config\' to initialize this page.')
}
+ },
+ /**
+ * 鏁板瓧鐩稿姞
+ * @param {*} arg1
+ * @param {*} arg2
+ * @returns
+ */
+ accAdd(arg1, arg2) {
+ return this.changeNum(arg1, arg2)
+ },
+
+ /**
+ * 鏁板瓧鐩稿噺
+ * @param {*} arg1
+ * @param {*} arg2
+ * @returns
+ */
+ accSub(arg1, arg2) {
+ return this.changeNum(arg1, arg2, false)
+ },
+
+ /**
+ * 鏁板瓧鐩镐箻
+ * @param {*} arg1
+ * @param {*} arg2
+ * @returns
+ */
+ accMul(arg1, arg2) {
+ let m = 0;
+ m = accAdd(m, getDecimalLength(arg1))
+ m = accAdd(m, getDecimalLength(arg2))
+ return getNum(arg1) * getNum(arg2) / Math.pow(10, m)
+ },
+
+ /**
+ * 鏁板瓧鐩搁櫎
+ * @param {*} arg1
+ * @param {*} arg2
+ * @returns
+ */
+ accDiv(arg1, arg2) {
+ let t1, t2;
+ t1 = this.getDecimalLength(arg1)
+ t2 = this.getDecimalLength(arg2)
+ if (t1 - t2 > 0) {
+ return (this.getNum(arg1) / this.getNum(arg2)) / Math.pow(10, t1 - t2)
+ } else {
+ return (this.getNum(arg1) / this.getNum(arg2)) * Math.pow(10, t2 - t1)
+ }
+ },
+
+ changeNum(arg1 = '', arg2 = '', isAdd = true) {
+ function changeInteger(arg, r, maxR) {
+ if (r != maxR) {
+ let addZero = ''
+ for (let i = 0; i < maxR - r; i++) {
+ addZero += '0'
+ }
+ arg = Number(arg.toString().replace('.', '') + addZero)
+ } else {
+ arg = this.getNum(arg)
+ }
+ return arg
+ }
+ let r1, r2, maxR, m;
+ r1 = this.getDecimalLength(arg1)
+ r2 = this.getDecimalLength(arg2)
+ maxR = Math.max(r1, r2)
+ arg1 = changeInteger(arg1, r1, maxR)
+ arg2 = changeInteger(arg2, r2, maxR)
+ m = Math.pow(10, maxR)
+ if (isAdd) {
+ return (arg1 + arg2) / m
+ } else {
+ return (arg1 - arg2) / m
+ }
+ },
+
+ getDecimalLength(arg = '') {
+ try {
+ return arg.toString().split(".")[1].length
+ } catch (e) {
+ return 0
+ }
+ },
+
+ getNum(arg = '') {
+ return Number(arg.toString().replace(".", ""))
}
+
}
}
</script>
--
Gitblit v1.9.3