From 27dd70096d181051200ec5febf11c99d1940f835 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期三, 13 九月 2023 16:52:18 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.22:9001/r/mom-before
---
src/components/view/standard-table/target.vue | 123 +++++++++++++++++++++++++++++++++++-----
1 files changed, 106 insertions(+), 17 deletions(-)
diff --git a/src/components/view/standard-table/target.vue b/src/components/view/standard-table/target.vue
index 7dcfe2a..9524ae4 100644
--- a/src/components/view/standard-table/target.vue
+++ b/src/components/view/standard-table/target.vue
@@ -1,14 +1,15 @@
<template>
<div class="standard">
<div>
- <el-table ref="table" :data="tableData" row-key="rowId" border max-height="675"
+ <el-table ref="multipleTable" :data="tableData" row-key="rowId" border max-height="675"
+ @select-all="selectAll" @select="selectTr"
@selection-change="handleSelectionChange" default-expand-all
:tree-props="{children: 'children', hasChildren: 'hasChildren'}">
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column type="index" width="60" label="搴忓彿"></el-table-column>
<el-table-column prop="tfather" label="宸ュ簭">
<template slot-scope="scope">
- <el-tag type="primay" v-if="scope.row.tfather != null">01</el-tag>
+ <el-tag type="primary" v-if="scope.row.tfather != null">01</el-tag>
<span>{{scope.row.tfather}}</span>
</template>
</el-table-column>
@@ -18,17 +19,34 @@
<span>{{scope.row.tname}}</span>
</template>
</el-table-column>
+ <el-table-column prop="pfather" label="椤圭洰">
+ <template slot-scope="scope">
+ <el-tag type="info" color="#faf2ff" v-if="scope.row.pfather != null">
+ <span style="color: #e1affb">03</span>
+ </el-tag>
+ <span>{{scope.row.pfather}}</span>
+ </template>
+ </el-table-column>
<el-table-column prop="pname" label="鎸囨爣鍚嶇О">
<template slot-scope="scope">
- <el-tag type="info" color="#faf2ff" v-if="scope.row.pname != null">
- <span style="color: #e1affb">03</span>
- </el-tag>
<span>{{scope.row.pname}}</span>
</template>
</el-table-column>
<el-table-column prop="unit" label="鍗曚綅"></el-table-column>
- <el-table-column prop="internal" label="鍐呮帶鍊�"></el-table-column>
- <el-table-column prop="required" label="鏍囧噯鍊�"></el-table-column>
+ <el-table-column prop="internal" label="鍐呮帶鍊�">
+ <template slot-scope="scope">
+ <el-input v-model="scope.row.internal"
+ v-if="scope.row.pname != null"
+ @blur="updateVal(scope.row)"></el-input>
+ </template>
+ </el-table-column>
+ <el-table-column prop="required" label="鏍囧噯鍊�">
+ <template slot-scope="scope">
+ <el-input v-model="scope.row.required"
+ v-if="scope.row.pname != null"
+ @blur="updateVal(scope.row)"></el-input>
+ </template>
+ </el-table-column>
</el-table>
</div>
</div>
@@ -39,27 +57,98 @@
data() {
return {
selects: [],
+ deleteList:[],
+ isAllSelect:false,
}
},
props:['tableData','tableType'],
created() {},
mounted() {},
methods: {
- handleSelectionChange(val) {
- this.selects = val;
- },
- aaaa(){
- console.log("aaaaa----",this.targetData);
+ // 琛ㄦ牸鏍戝叏閮ㄩ�変腑閰嶇疆
+ // 鍏ㄩ��/鍙栨秷閫夋搷浣�
+ selectAll(val) {
+ this.isAllSelect = !this.isAllSelect;
+ let data = this.tableData;
+ this.toggleSelect(data, this.isAllSelect, "all");
+ },
+ //閫夋嫨鏌愯
+ selectTr(selection, row) {
+ this.$set(row, "isChecked", !row.isChecked);
+ this.$nextTick(() => {
+ this.isAllSelect = row.isChecked;
+ this.toggleSelect(row, row.isChecked, "tr");
+ });
+ },
+ //閫掑綊瀛愮骇
+ toggleSelect(data, flag, type) {
+ if (type === "all") {
+ if (data.length > 0) {
+ data.forEach((item) => {
+ this.toggleSelection(item, flag);
+ if (item.children && item.children.length > 0) {
+ this.toggleSelect(item.children, flag, type);
+ }
+ });
+ }
+ } else {
+ if (data.children && data.children.length > 0) {
+ data.children.forEach((item) => {
+ item.isChecked = !item.isChecked;
+ this.$refs.multipleTable.toggleRowSelection(item, flag);
+ this.toggleSelect(item, flag, type);
+ });
+ }
}
+ },
+ //鏀瑰彉閫変腑
+ toggleSelection(row, flag) {
+ this.$set(row, "isChecked", flag);
+ this.$nextTick(() => {
+ if (flag) {
+ this.$refs.multipleTable.toggleRowSelection(row, flag);
+ } else {
+ this.$refs.multipleTable.clearSelection();
+ }
+ });
+ },
+ handleSelectionChange(val) {
+ this.deleteList = [];
+ val.forEach((v) => {
+ this.searchIdFun(v);
+ });
+ this.$emit("childData",this.deleteList);
+ },
+ //閫掑綊鏌ユ壘閫変腑鏁版嵁id
+ searchIdFun(data){
+ let obj = data;
+ if(obj.children != undefined){
+ this.searchIdFun(obj.children);
+ }else{
+ this.deleteList.push(obj.pid);
+ }
+ },
+ // 琛ㄦ牸鏍戝叏閮ㄩ�変腑閰嶇疆 缁撴潫
+ updateVal(row){
+ this.$axios.post(this.$api.url.productWrite,{
+ id : row.pid,
+ internal : row.internal,
+ required : row.required
+ }).then(res=>{
+ this.$message.success(res.message);
+ }).catch(error=>{
+ this.$message.error(error.message);
+ })
+ },
}
}
</script>
<style scoped>
.expand-button {
- cursor: pointer;
- color: #1890ff;
-}
+ cursor: pointer;
+ color: #1890ff;
+ }
.standard {
width: 100%;
height: 100%;
@@ -98,8 +187,8 @@
/* .standard .el-table__body {
height: 100%;
} */
- .standard .el-table .el-table__row:not([class*="el-table__row--level-"]) td:nth-child(3){
+ /* .standard .el-table .el-table__row:not([class*="el-table__row--level-"]) td:nth-child(3){
padding-left: 23px !important;
- }
+ } */
</style>
\ No newline at end of file
--
Gitblit v1.9.3