|
@@ -6,51 +6,52 @@
|
|
|
<p class="normal-title normal-margin">{{$t(`产品类别`)}}</p>
|
|
<p class="normal-title normal-margin">{{$t(`产品类别`)}}</p>
|
|
|
<div class="drawer__panel" style="margin-bottom: 0 !important;">
|
|
<div class="drawer__panel" style="margin-bottom: 0 !important;">
|
|
|
<div style="margin-bottom: 10px">
|
|
<div style="margin-bottom: 10px">
|
|
|
- <uploadAllData
|
|
|
|
|
- style="display: inline-block !important;"
|
|
|
|
|
- :total="total"
|
|
|
|
|
- @handlePullApi="handlePullApi"
|
|
|
|
|
- @handleUploadApi="handleUploadApi"
|
|
|
|
|
- @onSuccess="onSuccess"
|
|
|
|
|
- ></uploadAllData>
|
|
|
|
|
- <el-button type="primary" class="inline-16" size="small" :disabled="selectProductLength == 0" @click="onSumit">{{$t(`批 量 添 加`)}}</el-button>
|
|
|
|
|
|
|
+ <el-button type="primary" size="small" :disabled="tableSelectData == 0" @click="batchSelect">{{$t(`批 量 添 加`)}}</el-button>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ class="inline-16"
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ @click="allSelect"
|
|
|
|
|
+ >{{$t('一键全选')}}</el-button
|
|
|
|
|
+ >
|
|
|
<el-input size="small" style="width:200px;margin-bottom:10px" v-model="params.content.where.condition" :placeholder="`${$t(`编号`)}、${$t(`类别名称`)}、${$t(`品牌`)}`" @clear="getProductList(params.content.pageNumber = 1)" @keyup.native.enter="getProductList(params.content.pageNumber = 1)" clearable></el-input>
|
|
<el-input size="small" style="width:200px;margin-bottom:10px" v-model="params.content.where.condition" :placeholder="`${$t(`编号`)}、${$t(`类别名称`)}、${$t(`品牌`)}`" @clear="getProductList(params.content.pageNumber = 1)" @keyup.native.enter="getProductList(params.content.pageNumber = 1)" clearable></el-input>
|
|
|
</div>
|
|
</div>
|
|
|
- <Table :checkbox="true" height="calc(100vh - 220px)" @selectionChange="selectArr" ref="table" id="itemclassid" v-model="itemno" :layout="tablecols" :data="productList" :custom="true" @upDateData="upDateData">
|
|
|
|
|
- <template v-slot:customcol="scope">
|
|
|
|
|
- <div v-if="scope.column.columnname == 'attinfos'">
|
|
|
|
|
- <previewImage
|
|
|
|
|
- v-if="scope.column.data.attinfos[0]"
|
|
|
|
|
- style="width:38px;height:38px;margin:0px"
|
|
|
|
|
- class="image"
|
|
|
|
|
- :image="scope.column.data.attinfos[0]"
|
|
|
|
|
- :list="scope.column.data.attinfos"
|
|
|
|
|
- :deletebtn="false"
|
|
|
|
|
- ></previewImage>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div v-else-if="scope.column.columnname == 'brand'">
|
|
|
|
|
- {{scope.column.data[scope.column.columnname][0] ? $t(scope.column.data[scope.column.columnname])[0].brandname : '--'}}
|
|
|
|
|
- </div>
|
|
|
|
|
- <div v-else>{{$t(scope.column.data[scope.column.columnname])}}</div>
|
|
|
|
|
- <span v-if="!scope.column.data[scope.column.columnname] && scope.column.data[scope.column.columnname] !== 0 && scope.column.columnname != 'operation'">--</span>
|
|
|
|
|
- </template>
|
|
|
|
|
- <template v-slot:opreation="scope">
|
|
|
|
|
- <el-button type="text" size="mini" @click="addProduct(scope.data)">{{$t('添 加')}}</el-button>
|
|
|
|
|
- </template>
|
|
|
|
|
- </Table>
|
|
|
|
|
- <div style="display:flex;justify-content:space-between;align-items:center;margin-top:10px">
|
|
|
|
|
- <!-- <el-pagination
|
|
|
|
|
- style="display:inline-block"
|
|
|
|
|
- background
|
|
|
|
|
- small
|
|
|
|
|
- @size-change="handleSizeChange"
|
|
|
|
|
- @current-change="handleCurrentChange"
|
|
|
|
|
- :current-page="params.content.pageNumber"
|
|
|
|
|
- :page-sizes="[20, 50, 100, 200]"
|
|
|
|
|
- layout="total, prev, pager, next, jumper"
|
|
|
|
|
- :total="total">
|
|
|
|
|
- </el-pagination>-->
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+<!-- <Table :checkbox="true" height="calc(100vh - 220px)" @selectionChange="selectArr" ref="table" id="itemclassid" v-model="itemno" :layout="tablecols" :data="productList" :custom="true" @upDateData="upDateData">-->
|
|
|
|
|
+<!-- <template v-slot:customcol="scope">-->
|
|
|
|
|
+<!-- <div v-if="scope.column.columnname == 'attinfos'">-->
|
|
|
|
|
+<!-- <previewImage-->
|
|
|
|
|
+<!-- v-if="scope.column.data.attinfos[0]"-->
|
|
|
|
|
+<!-- style="width:38px;height:38px;margin:0px"-->
|
|
|
|
|
+<!-- class="image"-->
|
|
|
|
|
+<!-- :image="scope.column.data.attinfos[0]"-->
|
|
|
|
|
+<!-- :list="scope.column.data.attinfos"-->
|
|
|
|
|
+<!-- :deletebtn="false"-->
|
|
|
|
|
+<!-- ></previewImage>-->
|
|
|
|
|
+<!-- </div>-->
|
|
|
|
|
+<!-- <div v-else-if="scope.column.columnname == 'brand'">-->
|
|
|
|
|
+<!-- {{scope.column.data[scope.column.columnname][0] ? $t(scope.column.data[scope.column.columnname])[0].brandname : '--'}}-->
|
|
|
|
|
+<!-- </div>-->
|
|
|
|
|
+<!-- <div v-else>{{$t(scope.column.data[scope.column.columnname])}}</div>-->
|
|
|
|
|
+<!-- <span v-if="!scope.column.data[scope.column.columnname] && scope.column.data[scope.column.columnname] !== 0 && scope.column.columnname != 'operation'">--</span>-->
|
|
|
|
|
+<!-- </template>-->
|
|
|
|
|
+<!-- <template v-slot:opreation="scope">-->
|
|
|
|
|
+<!-- <el-button type="text" size="mini" @click="addProduct(scope.data)">{{$t('添 加')}}</el-button>-->
|
|
|
|
|
+<!-- </template>-->
|
|
|
|
|
+<!-- </Table>-->
|
|
|
|
|
+<!-- <div style="display:flex;justify-content:space-between;align-items:center;margin-top:10px">-->
|
|
|
|
|
+<!-- <!– <el-pagination-->
|
|
|
|
|
+<!-- style="display:inline-block"-->
|
|
|
|
|
+<!-- background-->
|
|
|
|
|
+<!-- small-->
|
|
|
|
|
+<!-- @size-change="handleSizeChange"-->
|
|
|
|
|
+<!-- @current-change="handleCurrentChange"-->
|
|
|
|
|
+<!-- :current-page="params.content.pageNumber"-->
|
|
|
|
|
+<!-- :page-sizes="[20, 50, 100, 200]"-->
|
|
|
|
|
+<!-- layout="total, prev, pager, next, jumper"-->
|
|
|
|
|
+<!-- :total="total">-->
|
|
|
|
|
+<!-- </el-pagination>–>-->
|
|
|
|
|
+<!-- </div>-->
|
|
|
|
|
+ <treeTable ref="treeRef" :table-data="productList" @rowSelect="rowSelect"></treeTable>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
@@ -90,7 +91,7 @@ export default {
|
|
|
itemno:'',
|
|
itemno:'',
|
|
|
total:0,
|
|
total:0,
|
|
|
params: {
|
|
params: {
|
|
|
- "id": 20221124140102,
|
|
|
|
|
|
|
+ "id": 2026012213242302,
|
|
|
"content": {
|
|
"content": {
|
|
|
"sa_contractid": '',
|
|
"sa_contractid": '',
|
|
|
"pageNumber": 1,
|
|
"pageNumber": 1,
|
|
@@ -99,7 +100,8 @@ export default {
|
|
|
"condition": ""
|
|
"condition": ""
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ tableSelectData:[]
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
computed:{
|
|
computed:{
|
|
@@ -134,11 +136,40 @@ export default {
|
|
|
async getProductList () {
|
|
async getProductList () {
|
|
|
this.params.content.sa_contractid = this.$route.query.id
|
|
this.params.content.sa_contractid = this.$route.query.id
|
|
|
let res = await this.$api.requested(this.params)
|
|
let res = await this.$api.requested(this.params)
|
|
|
- this.productList = res.data
|
|
|
|
|
|
|
+ this.productList = this.createMenu(res.data);
|
|
|
this.total = res.total
|
|
this.total = res.total
|
|
|
- this.params.content.pageNumber = res.pageNumber
|
|
|
|
|
- console.log(this)
|
|
|
|
|
- this.$refs.table.$refs.table.doLayout()
|
|
|
|
|
|
|
+ // this.params.content.pageNumber = res.pageNumber
|
|
|
|
|
+ // console.log(this)
|
|
|
|
|
+ // this.$refs.table.$refs.table.doLayout()
|
|
|
|
|
+ },
|
|
|
|
|
+ createMenu (array) {
|
|
|
|
|
+ var that = this
|
|
|
|
|
+ let arr = []
|
|
|
|
|
+ function convertToElementTree(node) {
|
|
|
|
|
+ // 新节点
|
|
|
|
|
+ var elNode = {
|
|
|
|
|
+ itemclassname: node["itemclassname"],
|
|
|
|
|
+ itemclassnum:node["itemclassnum"],
|
|
|
|
|
+ brandname:node["brandname"],
|
|
|
|
|
+ num:node["num"],
|
|
|
|
|
+ isCheck:node["isCheck"],
|
|
|
|
|
+ itemclassid:node['itemclassid'],
|
|
|
|
|
+ selected:false,
|
|
|
|
|
+ children: []
|
|
|
|
|
+ }
|
|
|
|
|
+ if (node.subitemclass && node.subitemclass.length > 0) {
|
|
|
|
|
+ // 如果存在子节点
|
|
|
|
|
+ for (var index = 0; index < node.subitemclass.length; index++) {
|
|
|
|
|
+ // 遍历子节点, 把每个子节点看做一颗独立的树, 传入递归构造子树, 并把结果放回到新node的children中
|
|
|
|
|
+ elNode.children.push(convertToElementTree(node.subitemclass[index]));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return elNode;
|
|
|
|
|
+ }
|
|
|
|
|
+ array.forEach((element) => {
|
|
|
|
|
+ arr.push(convertToElementTree(element))
|
|
|
|
|
+ });
|
|
|
|
|
+ return arr
|
|
|
},
|
|
},
|
|
|
createTreeData (array) {
|
|
createTreeData (array) {
|
|
|
var that = this
|
|
var that = this
|
|
@@ -192,28 +223,27 @@ export default {
|
|
|
this.$emit('onSuccess')
|
|
this.$emit('onSuccess')
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- async onSumit () {
|
|
|
|
|
- let item = this.$refs.table.allArr.map(item => {
|
|
|
|
|
- return {
|
|
|
|
|
- "sa_contract_itemsaleclassid": 0,
|
|
|
|
|
- "itemclassid": item.itemclassid,
|
|
|
|
|
- "discountrate": item.discountrate
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
|
|
+ async onSubmit () {
|
|
|
let res = await this.$api.requested({
|
|
let res = await this.$api.requested({
|
|
|
"id": 20221124110202,
|
|
"id": 20221124110202,
|
|
|
"content": {
|
|
"content": {
|
|
|
"sa_contractid": this.$route.query.id,
|
|
"sa_contractid": this.$route.query.id,
|
|
|
- "items": item
|
|
|
|
|
|
|
+ "items": this.tableSelectData
|
|
|
},
|
|
},
|
|
|
})
|
|
})
|
|
|
- this.tool.showMessage(res,() => {
|
|
|
|
|
- // this.drawer = false
|
|
|
|
|
- this.$emit('onSuccess')
|
|
|
|
|
- this.getProductList()
|
|
|
|
|
- this.$refs.table.allArr = []
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ if (res.code == 0){
|
|
|
|
|
+ this.tableSelectData = []
|
|
|
|
|
+ this.tool.showMessage(res,()=>{})
|
|
|
|
|
+ }else {
|
|
|
|
|
+ this.tool.showMessage(res,() => {
|
|
|
|
|
+ // this.drawer = false
|
|
|
|
|
+ this.tableSelectData = []
|
|
|
|
|
+ this.drawer = false
|
|
|
|
|
+ this.$emit('onSuccess')
|
|
|
|
|
+ // this.getProductList()
|
|
|
|
|
+ // this.$refs.table.allArr = []
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
upDateData (data) {
|
|
upDateData (data) {
|
|
|
this.selectProductLength = data.length
|
|
this.selectProductLength = data.length
|
|
@@ -260,6 +290,62 @@ export default {
|
|
|
onSuccess () {
|
|
onSuccess () {
|
|
|
this.getProductList()
|
|
this.getProductList()
|
|
|
},
|
|
},
|
|
|
|
|
+ batchSelect(){
|
|
|
|
|
+ this.onSubmit()
|
|
|
|
|
+ },
|
|
|
|
|
+ rowSelect (row) {
|
|
|
|
|
+ console.log(row)
|
|
|
|
|
+ const exists = this.tableSelectData.some(item => item.itemclassid === row.itemclassid);
|
|
|
|
|
+ if (exists) {
|
|
|
|
|
+ // 移除
|
|
|
|
|
+ this.tableSelectData = this.tableSelectData.filter(
|
|
|
|
|
+ item => item.itemclassid !== row.itemclassid
|
|
|
|
|
+ );
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 新增
|
|
|
|
|
+ this.tableSelectData = [
|
|
|
|
|
+ ...this.tableSelectData,
|
|
|
|
|
+ {
|
|
|
|
|
+ sa_quotedprice_itemclassid: 0,
|
|
|
|
|
+ itemclassid: row.itemclassid
|
|
|
|
|
+ }
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ // this.tableSelectData.push({
|
|
|
|
|
+ // sa_quotedprice_itemclassid: 0,
|
|
|
|
|
+ // itemclassid: row.itemclassid
|
|
|
|
|
+ // })
|
|
|
|
|
+ console.log(this.tableSelectData)
|
|
|
|
|
+ },
|
|
|
|
|
+ allSelect(){
|
|
|
|
|
+ this.tableSelectData = []
|
|
|
|
|
+ this.productList.forEach(row => {
|
|
|
|
|
+ this.tableSelectData.push({
|
|
|
|
|
+ sa_quotedprice_itemclassid: 0,
|
|
|
|
|
+ itemclassid: row.itemclassid
|
|
|
|
|
+ })
|
|
|
|
|
+ console.log(row,'row输出')
|
|
|
|
|
+ if (row.children.length > 0){
|
|
|
|
|
+ row.children.forEach(item => {
|
|
|
|
|
+ console.log(item,'item')
|
|
|
|
|
+ this.tableSelectData.push({
|
|
|
|
|
+ sa_quotedprice_itemclassid: 0,
|
|
|
|
|
+ itemclassid: item.itemclassid
|
|
|
|
|
+ })
|
|
|
|
|
+ if (item.children.length > 0){
|
|
|
|
|
+ item.children.forEach(kow => {
|
|
|
|
|
+ this.tableSelectData.push({
|
|
|
|
|
+ sa_quotedprice_itemclassid: 0,
|
|
|
|
|
+ itemclassid: kow.itemclassid
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ this.onSubmit()
|
|
|
|
|
+ console.log(this.tableSelectData)
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
|
</script>
|
|
</script>
|