From b6837f097e9cdb2645368aed4ddb03f580c331e4 Mon Sep 17 00:00:00 2001 From: z8018 <1282578289@qq.com> Date: 星期一, 05 五月 2025 17:29:07 +0800 Subject: [PATCH] 1 --- 项目代码/WCS/WIDESEAWCS_Client/src/components/basic/VolTable.vue | 295 ++++++++++++++++++++++++++-------------------------------- 1 files changed, 131 insertions(+), 164 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Client/src/components/basic/VolTable.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Client/src/components/basic/VolTable.vue" index af51360..4522b33 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Client/src/components/basic/VolTable.vue" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Client/src/components/basic/VolTable.vue" @@ -45,12 +45,7 @@ :selectable="selectable" width="55" ></el-table-column> - <el-table-column - v-if="columnIndex" - type="index" - :fixed="fixed" - width="55" - ></el-table-column> + <el-table-column v-if="columnIndex" type="index" :fixed="fixed" width="55"></el-table-column> <!-- 2020.10.10绉婚櫎table绗竴琛屽己鍒舵帓搴� --> <el-table-column @@ -66,11 +61,8 @@ :show-overflow-tooltip="true" > <template #header> - <span - v-if="(column.require || column.required) && column.edit" - class="column-required" - >*</span - >{{ column.title }} + <span v-if="(column.require || column.required) && column.edit" class="column-required">*</span> + {{ column.title }} </template> <template #default="scope"> @@ -111,15 +103,13 @@ ) " ></div> - <div v-else-if="column.bind"> - {{ formatter(scopeChildren.row, columnChildren, true) }} - </div> - <span v-else-if="column.type == 'date'">{{ + <div v-else-if="column.bind">{{ formatter(scopeChildren.row, columnChildren, true) }}</div> + <span v-else-if="column.type == 'date'"> + {{ formatterDate(scopeChildren.row, columnChildren) - }}</span> - <template v-else> - {{ scopeChildren.row[columnChildren.field] }} - </template> + }} + </span> + <template v-else>{{ scopeChildren.row[columnChildren.field] }}</template> </template> </el-table-column> <!-- 2020.06.18澧炲姞render娓叉煋鑷畾涔夊唴瀹� --> @@ -174,8 +164,7 @@ )" :key="fIndex" @click="dowloadFile(file)" - >{{ file.name }}</a - > + >{{ file.name }}</a> </div> </template> <div @@ -206,8 +195,7 @@ :disabledDate="(val) => getDateOptions(val, column)" :value-format="getDateFormat(column)" :disabled="initColumnDisabled(scope.row, column)" - > - </el-date-picker> + ></el-date-picker> <el-time-picker clearable size="default" @@ -223,8 +211,7 @@ :placeholder="column.placeholder || column.title" :value-format="column.format || 'HH:mm:ss'" :disabled="initColumnDisabled(scope.row, column)" - > - </el-time-picker> + ></el-time-picker> <el-switch v-else-if="column.edit.type == 'switch'" v-model="scope.row[column.field]" @@ -250,8 +237,7 @@ : 0 " :disabled="initColumnDisabled(scope.row, column)" - > - </el-switch> + ></el-switch> <template v-else-if=" ['select', 'selectList'].indexOf(column.edit.type) != -1 @@ -273,9 +259,7 @@ clearable :disabled="initColumnDisabled(scope.row, column)" > - <template #default="{ item }"> - {{ item.label }} - </template> + <template #default="{ item }">{{ item.label }}</template> </el-select-v2> <el-select @@ -304,8 +288,7 @@ :disabled="item.disabled" :label="item.value" :value="item.key" - >{{ item.value }} - </el-option> + >{{ item.value }}</el-option> </el-select> </template> <el-input @@ -314,8 +297,7 @@ :placeholder="column.placeholder || column.title" v-model="scope.row[column.field]" :disabled="initColumnDisabled(scope.row, column)" - > - </el-input> + ></el-input> <input class="table-input" v-else-if="!column.summary && !column.onKeyPress" @@ -333,10 +315,7 @@ :disabled="initColumnDisabled(scope.row, column)" ></el-input> </div> - <div - class="extra" - v-if="column.extra && edit.rowIndex == scope.$index" - > + <div class="extra" v-if="column.extra && edit.rowIndex == scope.$index"> <a :style="column.extra.style" style="text-decoration: none" @@ -379,11 +358,12 @@ )" :key="fIndex" @click="dowloadFile(file)" - >{{ file.name }}</a - > - <span v-else-if="column.type == 'date'">{{ + >{{ file.name }}</a> + <span v-else-if="column.type == 'date'"> + {{ formatterDate(scope.row, column) - }}</span> + }} + </span> <div v-else-if="column.formatter" @click="formatterClick(scope.row, column, $event)" @@ -394,15 +374,11 @@ v-else-if="column.bind && (column.normal || column.edit)" @click="formatterClick(scope.row, column, $event)" :style="column.getStyle && column.getStyle(scope.row, column)" - > - {{ formatter(scope.row, column, true) }} - </div> + >{{ formatter(scope.row, column, true) }}</div> <div v-else-if="column.click && !column.bind" @click="formatterClick(scope.row, column)" - > - {{ scope.row[column.field] }} - </div> + >{{ scope.row[column.field] }}</div> <div @click=" () => { @@ -416,11 +392,12 @@ :class="[isEmptyTag(scope.row, column)]" :type="getColor(scope.row, column)" :effect="column.effect" - >{{ formatter(scope.row, column, true) }}</el-tag - > - <template v-else>{{ + >{{ formatter(scope.row, column, true) }}</el-tag> + <template v-else> + {{ formatter(scope.row, column, true) - }}</template> + }} + </template> </div> <span v-else>{{ formatter(scope.row, column, true) }}</span> @@ -445,14 +422,7 @@ </template> </div> - <VolBox - v-model="uploadModel" - title="涓婁紶" - :height="228" - :width="500" - :padding="15" - lazy - > + <VolBox v-model="uploadModel" title="涓婁紶" :height="228" :width="500" :padding="15" lazy> <!-- 涓婁紶鍥剧墖銆乪xcel鎴栧叾浠栨枃浠躲�佹枃浠舵暟閲忋�佸ぇ灏忛檺鍒堕兘鍙互锛屽弬鐓olupload缁勪欢api --> <div style="height: 200px; display: flex; align-items: center"> <VolUpload @@ -474,12 +444,8 @@ </div> <template #footer> <div style="text-align: center"> - <el-button type="default" size="small" @click="uploadModel = false" - >鍏抽棴</el-button - > - <el-button type="primary" size="small" @click="saveUpload" - >淇濆瓨</el-button - > + <el-button type="default" size="small" @click="uploadModel = false">鍏抽棴</el-button> + <el-button type="primary" size="small" @click="saveUpload">淇濆瓨</el-button> </div> </template> </VolBox> @@ -496,157 +462,157 @@ "tableData.length": { handler(newLen, oldLen) { this.watchRowSelectChange(newLen, oldLen); - }, + } }, "rowData.length": { handler(newLen, oldLen) { this.watchRowSelectChange(newLen, oldLen); - }, - }, + } + } }, components: { "table-render": VolTableRender, VolUpload: defineAsyncComponent(() => import("@/components/basic/VolUpload.vue") ), - VolBox: defineAsyncComponent(() => import("@/components/basic/VolBox.vue")), + VolBox: defineAsyncComponent(() => import("@/components/basic/VolBox.vue")) }, props: { rowKey: { // 鏍戝舰缁撴瀯鐨勪富閿瓧娈碉紝濡傛灉璁剧疆鍊奸粯璁や細寮�鍚爲褰able锛涙敞鎰弐owKey瀛楁鐨勫�煎繀椤绘槸鍞竴锛�2021.05.02锛� typeof: String, - default: undefined, + default: undefined }, loadTreeChildren: { // 鏍戝舰缁撴瀯鍔犺浇瀛愯妭鐐� type: Function, default: (tree, treeNode, resolve) => { return resolve([]); - }, + } }, textInline: { // 琛ㄦ牸鍐呭瓒呭嚭鍚庢槸鍚︽崲琛屾樉绀猴紙2020.01.16锛� type: Boolean, - default: true, + default: true }, tableData: { // 琛ㄦ暟鎹簮,閰嶇疆浜唘rl灏变笉鐢ㄤ紶杩欎釜鍙傛暟浜� type: Array, default: () => { return []; - }, + } }, columns: { type: Array, - default: [], + default: [] }, height: { type: Number, - default: 0, + default: 0 }, maxHeight: { type: Number, - default: 0, + default: 0 }, linkView: { type: Function, - default: function () { + default: function() { return 1; - }, + } }, pagination: { type: Object, - default: function () { + default: function() { return { total: 0, size: 30, sortName: "" }; - }, + } }, url: { type: String, - default: "", + default: "" }, paginationHide: { type: Boolean, - default: true, + default: true }, color: { type: Boolean, - default: true, + default: true }, index: { // 鏄惁鍒涘缓绱㈠紩鍙�,濡傛灉闇�瑕佽〃鏍肩紪杈戝姛鑳斤紝杩欓噷闇�瑕佽缃负true type: Boolean, - default: false, + default: false }, allowEmpty: { // 琛ㄦ牸鏁版嵁涓虹┖鏃舵槸鍚﹂粯璁や负-- type: Boolean, - default: true, + default: true }, defaultLoadPage: { // 浼犲叆浜唘rl锛屾槸鍚﹂粯璁ゅ姞杞借〃鏍兼暟鎹� type: Boolean, - default: true, + default: true }, loadKey: { // 鏄惁鑷姩浠庡悗鍙板姞杞芥暟鎹簮 type: Boolean, - default: true, + default: true }, single: { type: Boolean, // 鏄惁鍗曢�� - default: false, + default: false }, doubleEdit: { type: Boolean, // 鏄惁鍙屽嚮鍚敤缂栬緫鍔熻兘 - default: true, + default: true }, beginEdit: { // 缂栬緫寮�濮� type: Function, - default: function (row, column, index) { + default: function(row, column, index) { return true; - }, + } }, endEditBefore: { // 缁撴潫缂栬緫鍓� type: Function, - default: function (row, column, index) { + default: function(row, column, index) { return true; - }, + } }, endEditAfter: { // 缁撴潫缂栬緫鍓� type: Function, - default: function (row, column, index) { + default: function(row, column, index) { return true; - }, + } }, ck: { // 鏄惁鏄剧ずcheckbox type: Boolean, - default: true, + default: true }, columnIndex: { // 鏄惁鏄剧ず琛屽彿(2020..11.1) type: Boolean, - default: true, + default: true }, highlightCurrentRow: { //澧炲姞閫変腑琛岄珮浜樉绀�(2022.10.07) type: Boolean, - default: true, + default: true }, select2Count: { //瓒呭嚭鏁伴噺鏄剧ずselect2缁勪欢 type: Number, - default: 500, + default: 500 }, selectable: { type: Function, default: (row, index) => { return true; - }, - }, + } + } }, data() { return { @@ -670,7 +636,7 @@ rule: { phone: /^[1][3,4,5,6,7,8,9][0-9]{9}$/, decimal: /(^[\-0-9][0-9]*(.[0-9]+)?)$/, - number: /(^[\-0-9][0-9]*([0-9]+)?)$/, + number: /(^[\-0-9][0-9]*([0-9]+)?)$/ }, columnNames: [], rowData: [], @@ -684,7 +650,7 @@ size: 30, // 榛樿鍒嗛〉澶у皬 Wheres: [], page: 1, - rows: 30, + rows: 30 }, errorFiled: "", edit: { columnIndex: -1, rowIndex: -1 }, // 褰撳墠鍙屽嚮缂栬緫鐨勮涓庡垪鍧愭爣 @@ -705,7 +671,7 @@ currentColumn: [], fileInfo: [], uploadUrl: "", - uploadModel: false, + uploadModel: false }; }, created() { @@ -723,12 +689,12 @@ // } this.realHeight = this.getHeight(); this.realMaxHeight = this.getMaxHeight(); - this.fxRight = this.columns.some((x) => { + this.fxRight = this.columns.some(x => { return x.fixed == "right"; }); //2021.09.21绉婚櫎寮哄埗鍥哄畾琛屽彿涓巆heckbox鍒� if ( - this.columns.some((x) => { + this.columns.some(x => { return x.fixed && x.fixed != "right"; }) ) { @@ -782,33 +748,31 @@ } }); if (keys.length > 0) { - this.http - .post("/api/Sys_Dictionary/GetVueDictionary", keys) - .then((dic) => { - dic.forEach((x) => { - if (x.data.length > this.select2Count) { - x.data.forEach((item) => { - item.label = item.value; - item.value = item.key; + this.http.post("/api/Sys_Dictionary/GetVueDictionary", keys).then(dic => { + dic.forEach(x => { + if (x.data.length > this.select2Count) { + x.data.forEach(item => { + item.label = item.value; + item.value = item.key; + }); + } + columnBind.forEach(c => { + // 杞崲鏁版嵁婧愮殑绫诲瀷涓庡垪鐨勭被鍨嬩竴鑷�(2020.04.04) + if ( + c.key == x.dicNo && + (c.valueTyoe == "int" || c.valueTyoe == "sbyte") + ) { + x.data.forEach(d => { + // 2020.09.01澧炲姞瀵规暟瀛楃被鍨嬬殑浜屾鍒ゆ柇 + if (!isNaN(d.key)) { + d.key = ~~d.key; + } }); } - columnBind.forEach((c) => { - // 杞崲鏁版嵁婧愮殑绫诲瀷涓庡垪鐨勭被鍨嬩竴鑷�(2020.04.04) - if ( - c.key == x.dicNo && - (c.valueTyoe == "int" || c.valueTyoe == "sbyte") - ) { - x.data.forEach((d) => { - // 2020.09.01澧炲姞瀵规暟瀛楃被鍨嬬殑浜屾鍒ゆ柇 - if (!isNaN(d.key)) { - d.key = ~~d.key; - } - }); - } - if (c.key == x.dicNo) c.data.push(...x.data); - }); + if (c.key == x.dicNo) c.data.push(...x.data); }); }); + }); } this.paginations.sort = this.pagination.sortName; @@ -817,10 +781,10 @@ if (this.pagination.size) { this.paginations.rows = this.pagination.size; } - this.enableEdit = this.columns.some((x) => { + this.enableEdit = this.columns.some(x => { return x.hasOwnProperty("edit"); }); - let keyColumn = this.columns.find((x) => { + let keyColumn = this.columns.find(x => { return x.isKey; }); if (keyColumn) { @@ -836,7 +800,7 @@ } return !x.hidden; }); - }, + } }, methods: { watchRowSelectChange(newLen, oldLen) { @@ -904,7 +868,7 @@ if (row.elementIndex == this.edit.rowIndex) { // 鐐瑰嚮鐨勫崟鍏冩牸濡傛灉涓嶅彲浠ョ紪杈戯紝鐩存帴缁撴潫缂栬緫 // 2020.10.12淇缁撴潫缂栬緫鏃讹紝element table楂樼増鏈睘鎬ц幏鍙栦笉鍒扮殑闂 - let _col = this.columns.find((x) => { + let _col = this.columns.find(x => { return x.field == ((event && event.property) || column.property); }); if (_col && (!_col.edit || _col.readonly)) { @@ -930,7 +894,7 @@ file.path, file.name, { - Authorization: this.$store.getters.getToken(), + Authorization: this.$store.getters.getToken() }, this.http.ipAddress ); @@ -947,10 +911,10 @@ if (column.base64 && pathSring.indexOf("data") != -1) { filePath = ("," + pathSring) .split(",data") - .filter((x) => { + .filter(x => { return x; }) - .map((m) => { + .map(m => { return "data" + m; }); } else { @@ -966,14 +930,14 @@ name: "", path: (file.indexOf("data") == -1 ? "data:image/png;base64," : "") + - file, + file }); } else if (file.indexOf(".") != -1) { let splitFile = file.split("/"); if (splitFile.length > 0) { fileInfo.push({ name: splitFile[splitFile.length - 1], - path: this.base.isUrl(file) ? file : this.http.ipAddress + file, + path: this.base.isUrl(file) ? file : this.http.ipAddress + file }); } } @@ -1063,7 +1027,7 @@ if (this.edit.rowIndex != -1) { return; } - let _row = this.columns.find((x) => x.field == column.property); + let _row = this.columns.find(x => x.field == column.property); if (_row) { if (_row.readonly) { return; @@ -1080,10 +1044,10 @@ _errMsg = ""; // 缂栬緫鍓� this.columns - .filter((x) => { + .filter(x => { return x.bind && x.bind.data && x.bind.data.length; }) - .forEach((column) => { + .forEach(column => { let val = row[column.field]; if (typeof column.bind.data[0].key == "string") { if (typeof val == "number") { @@ -1267,7 +1231,7 @@ if (!row) { row = {}; } - this.columns.forEach((x) => { + this.columns.forEach(x => { // 2022.05.06 娣诲姞琛屾椂锛屽鏋滃垪鏈夌紪杈戝睘鎬э紝璁剧疆寮�鍚紪杈�(閬垮厤鍏抽棴缂栬緫鍚庯紝鏃犳硶鍐嶆鍚敤缂栬緫)?? //x.readonly = false; if (!row.hasOwnProperty(x.field)) { @@ -1302,7 +1266,7 @@ // 鍙湁璁剧疆浜嗗睘鎬ndex鎵嶆湁绱㈠紩琛� return []; } - let indexArr = this.selectRows.map((x) => { + let indexArr = this.selectRows.map(x => { return x.elementIndex; }); return indexArr || []; @@ -1316,7 +1280,7 @@ // column.bind.data.splice(0); let key = column.bind.key; let data = []; - rows.forEach((row) => { + rows.forEach(row => { if (row[column.field] || row[column.field] == "0") { if (data.indexOf(row[column.field]) == -1) { data.push(row[column.field]); @@ -1331,9 +1295,9 @@ // ha= Object.assign([], ha, hb) this.http .post("/api/Sys_Dictionary/GetTableDictionary", remoteInfo) - .then((dic) => { - dic.forEach((x) => { - this.remoteColumns.forEach((column) => { + .then(dic => { + dic.forEach(x => { + this.remoteColumns.forEach(column => { if (column.bind.key == x.key) { column.bind.data = Object.assign([], column.bind.data, x.data); // column.bind.data.push(...x.data); @@ -1354,7 +1318,7 @@ rows: this.paginations.rows, sort: this.paginations.sort, order: this.paginations.order, - wheres: [], // 鏌ヨ鏉′欢锛屾牸寮忎负[{ name: "瀛楁", value: "xx" }] + wheres: [] // 鏌ヨ鏉′欢锛屾牸寮忎负[{ name: "瀛楁", value: "xx" }] }; let status = true; // 鍚堝苟鏌ヨ淇℃伅(鍖呮煡璇㈠垎椤点�佹帓搴忋�佹煡璇㈡潯浠剁瓑) @@ -1367,7 +1331,7 @@ callBack(true); }) */ - this.$emit("loadBefore", param, (result) => { + this.$emit("loadBefore", param, result => { status = result; }); if (!status) return; @@ -1377,7 +1341,7 @@ } this.loading = true; this.http.post(this.url, param).then( - (data) => { + data => { //2021.06.04淇tree涓嶅埛鏂扮殑闂 if (this.rowKey) { this.randomTableKey++; @@ -1389,7 +1353,7 @@ this.$emit( "loadAfter", data.rows || [], - (result) => { + result => { status = result; }, data @@ -1404,7 +1368,7 @@ // this.$refs.table.doLayout(); // }); }, - (error) => { + error => { this.loading = false; // this.$Message.error(error || "缃戠粶寮傚父"); } @@ -1422,9 +1386,9 @@ this.summaryData.push(""); } - this.columns.forEach((col) => { + this.columns.forEach(col => { if (col.children && col.children.length) { - col.children.forEach((item) => { + col.children.forEach(item => { this.getColumnSummaries(item, data); }); } else { @@ -1533,7 +1497,9 @@ if ( column.edit && - (column.edit.type == "selectList" || column.edit.type == "treeSelect") + (column.edit.type == "selectList" || + column.edit.type == "selectlist" || + column.edit.type == "treeSelect") ) { if (!Array.isArray(val)) { row[column.field] = val.split(","); @@ -1545,6 +1511,7 @@ // 缂栬緫澶氶�塼able鏄剧ず if ( column.bind.type == "selectList" || + column.bind.type == "selectlist" || column.bind.type == "checkbox" || column.bind.type == "treeSelect" ) { @@ -1552,7 +1519,7 @@ return this.getSelectFormatter(column, val + ""); // } } - let source = column.bind.data.filter((x) => { + let source = column.bind.data.filter(x => { // return x.key != "" && x.key == val; // 2020.06.06淇鍗曠嫭浣跨敤table缁勪欢鏃�,key涓烘暟瀛�0鏃惰浆鎹㈡垚鏂囨湰澶辫触鐨勯棶棰� return x.key !== "" && x.key !== undefined && x.key + "" === val + ""; @@ -1567,7 +1534,7 @@ (column.bind.orginData && column.bind.orginData.length ? column.bind.orginData : column.bind.data - ).forEach((x) => { + ).forEach(x => { // 2020.06.06淇鏁版嵁婧愪负selectList鏃�,key涓烘暟瀛�0鏃朵笉鑳借浆鎹㈡枃鏈殑闂 if ( x.key !== "" && @@ -1669,7 +1636,7 @@ if (!children) { return []; } - return children.filter((x) => { + return children.filter(x => { return !x.hidden; }); }, @@ -1679,10 +1646,10 @@ showUpload(row, column) { this.fileInfo = (row[column.field] || "") .split(",") - .filter((x) => { + .filter(x => { return x; }) - .map((item) => { + .map(item => { return { path: item, name: "" }; }); this.currentRow = row; @@ -1711,7 +1678,7 @@ }, saveUpload() { //鐢熸垚淇濆瓨鍚庤繑鍥炵殑璺緞 - let arr = this.fileInfo.map((x) => { + let arr = this.fileInfo.map(x => { if (x.path) { return x.path; } @@ -1721,8 +1688,8 @@ this.currentRow[this.currentColumn.field] = arr.join(","); this.uploadModel = false; return true; - }, - }, + } + } }); </script> <style lang="less" scoped> -- Gitblit v1.9.3