|
@@ -1,8 +1,8 @@
|
|
<template>
|
|
<template>
|
|
<a-card size="small" :bordered="false" class="productCategoryList-wrap">
|
|
<a-card size="small" :bordered="false" class="productCategoryList-wrap">
|
|
<!-- 操作按钮 -->
|
|
<!-- 操作按钮 -->
|
|
- <div class="table-operator">
|
|
|
|
- <a-button id="productCategoryList-add" type="primary" class="button-error" @click="handleAdd()" style="margin-top: 18px;">新增一级分类</a-button>
|
|
|
|
|
|
+ <div class="table-operator-nobor">
|
|
|
|
+ <a-button id="productCategoryList-add" type="primary" class="button-error" @click="handleAdd()">新增一级分类</a-button>
|
|
</div>
|
|
</div>
|
|
<!-- 列表 -->
|
|
<!-- 列表 -->
|
|
<s-table
|
|
<s-table
|
|
@@ -14,61 +14,66 @@
|
|
:data="loadData"
|
|
:data="loadData"
|
|
:showPagination="false"
|
|
:showPagination="false"
|
|
:defaultExpandedRowKeys="defaultExpandedRowKeys"
|
|
:defaultExpandedRowKeys="defaultExpandedRowKeys"
|
|
|
|
+ :scroll="{ y: tableHeight }"
|
|
bordered>
|
|
bordered>
|
|
<!-- 操作 -->
|
|
<!-- 操作 -->
|
|
<template slot="action" slot-scope="text, record">
|
|
<template slot="action" slot-scope="text, record">
|
|
<a-button
|
|
<a-button
|
|
v-if="record.productTypeLevel<3"
|
|
v-if="record.productTypeLevel<3"
|
|
type="link"
|
|
type="link"
|
|
|
|
+ class="button-success"
|
|
size="small"
|
|
size="small"
|
|
icon="plus"
|
|
icon="plus"
|
|
- class="button-error"
|
|
|
|
id="productCategory-addSubItem"
|
|
id="productCategory-addSubItem"
|
|
@click="handleAdd(record)">新增子级</a-button>
|
|
@click="handleAdd(record)">新增子级</a-button>
|
|
<a-button
|
|
<a-button
|
|
v-if="record.pid != 0"
|
|
v-if="record.pid != 0"
|
|
type="link"
|
|
type="link"
|
|
|
|
+ class="button-info"
|
|
size="small"
|
|
size="small"
|
|
icon="edit"
|
|
icon="edit"
|
|
- class="btn-edit-s"
|
|
|
|
id="productCategory-edit"
|
|
id="productCategory-edit"
|
|
@click="handleEdit(record)">编辑</a-button>
|
|
@click="handleEdit(record)">编辑</a-button>
|
|
<a-button
|
|
<a-button
|
|
v-if="record.pid != 0"
|
|
v-if="record.pid != 0"
|
|
type="link"
|
|
type="link"
|
|
|
|
+ class="button-error"
|
|
size="small"
|
|
size="small"
|
|
icon="delete"
|
|
icon="delete"
|
|
- class="btn-del-s"
|
|
|
|
id="productCategory-del"
|
|
id="productCategory-del"
|
|
@click="handleDel(record)">删除</a-button>
|
|
@click="handleDel(record)">删除</a-button>
|
|
</template>
|
|
</template>
|
|
</s-table>
|
|
</s-table>
|
|
<!-- 新增/编辑产品分类 -->
|
|
<!-- 新增/编辑产品分类 -->
|
|
- <product-category-edit-modal :openModal="openModal" :nowData="nowData" :itemId="itemId" @ok="handleOk" @close="closeModal" />
|
|
|
|
|
|
+ <product-category-edit-modal :openModal="openModal" :nowData="nowData" :itemSn="itemSn" @ok="handleOk" @close="closeModal" />
|
|
</a-card>
|
|
</a-card>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-// import { dealerProductTypeQuery, dealerProductTypeDel } from '@/api/dealerProductType'
|
|
|
|
|
|
+import { productTypeQuery, productTypeDel } from '@/api/productType'
|
|
import { STable } from '@/components'
|
|
import { STable } from '@/components'
|
|
import productCategoryEditModal from './editModal.vue'
|
|
import productCategoryEditModal from './editModal.vue'
|
|
export default {
|
|
export default {
|
|
components: { STable, productCategoryEditModal },
|
|
components: { STable, productCategoryEditModal },
|
|
data () {
|
|
data () {
|
|
return {
|
|
return {
|
|
|
|
+ tableHeight: 0,
|
|
formItemLayout: {
|
|
formItemLayout: {
|
|
labelCol: { span: 6 },
|
|
labelCol: { span: 6 },
|
|
wrapperCol: { span: 16 }
|
|
wrapperCol: { span: 16 }
|
|
},
|
|
},
|
|
columns: [
|
|
columns: [
|
|
{ title: '分类名称', dataIndex: 'productTypeName', align: 'left' },
|
|
{ title: '分类名称', dataIndex: 'productTypeName', align: 'left' },
|
|
- { title: '创建时间', dataIndex: 'createDate', align: 'center' },
|
|
|
|
- { title: '操作', scopedSlots: { customRender: 'action' }, align: 'center' }
|
|
|
|
|
|
+ { title: '创建时间', dataIndex: 'createDate', width: 320, align: 'center' },
|
|
|
|
+ { title: '操作', scopedSlots: { customRender: 'action' }, width: 300, align: 'center' }
|
|
],
|
|
],
|
|
// 加载数据方法 必须为 Promise 对象
|
|
// 加载数据方法 必须为 Promise 对象
|
|
loadData: parameter => {
|
|
loadData: parameter => {
|
|
this.disabled = true
|
|
this.disabled = true
|
|
- return dealerProductTypeQuery({}).then(res => {
|
|
|
|
|
|
+ if (this.tableHeight == 0) {
|
|
|
|
+ this.tableHeight = window.innerHeight - 250
|
|
|
|
+ }
|
|
|
|
+ return productTypeQuery({}).then(res => {
|
|
// 递归去除空children
|
|
// 递归去除空children
|
|
this.recursionFun(res.data)
|
|
this.recursionFun(res.data)
|
|
if (res.data.length > 0) {
|
|
if (res.data.length > 0) {
|
|
@@ -81,17 +86,17 @@ export default {
|
|
},
|
|
},
|
|
defaultExpandedRowKeys: [], // 树形数据默认展开项
|
|
defaultExpandedRowKeys: [], // 树形数据默认展开项
|
|
openModal: false, // 新增编辑 弹框
|
|
openModal: false, // 新增编辑 弹框
|
|
- itemId: '', // 当前id
|
|
|
|
|
|
+ itemSn: '', // 当前sn
|
|
nowData: null // 当前记录数据
|
|
nowData: null // 当前记录数据
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
// 新增子级
|
|
// 新增子级
|
|
handleAdd (row) {
|
|
handleAdd (row) {
|
|
- this.itemId = null
|
|
|
|
|
|
+ this.itemSn = null
|
|
if (row) { // 新增子级
|
|
if (row) { // 新增子级
|
|
const nowData = row
|
|
const nowData = row
|
|
- nowData.psn = nowData && nowData.productTypeSn ? nowData.productTypeSn : null
|
|
|
|
|
|
+ nowData.productTypeSn = nowData && nowData.productTypeSn ? nowData.productTypeSn : null
|
|
this.nowData = nowData
|
|
this.nowData = nowData
|
|
} else { // 最高级
|
|
} else { // 最高级
|
|
this.nowData = null
|
|
this.nowData = null
|
|
@@ -100,15 +105,15 @@ export default {
|
|
},
|
|
},
|
|
// 编辑
|
|
// 编辑
|
|
handleEdit (row) {
|
|
handleEdit (row) {
|
|
- this.itemId = row && row.id ? row.id : null
|
|
|
|
|
|
+ this.itemSn = row && row.productTypeSn ? row.productTypeSn : null
|
|
const nowData = row
|
|
const nowData = row
|
|
- nowData.psn = nowData && nowData.productTypeSn ? nowData.productTypeSn : null
|
|
|
|
|
|
+ nowData.productTypeSn = nowData && nowData.productTypeSn ? nowData.productTypeSn : null
|
|
this.nowData = nowData
|
|
this.nowData = nowData
|
|
this.openModal = true
|
|
this.openModal = true
|
|
},
|
|
},
|
|
// 关闭弹框
|
|
// 关闭弹框
|
|
closeModal () {
|
|
closeModal () {
|
|
- this.itemId = ''
|
|
|
|
|
|
+ this.itemSn = ''
|
|
this.openModal = false
|
|
this.openModal = false
|
|
},
|
|
},
|
|
// 新增/编辑 成功
|
|
// 新增/编辑 成功
|
|
@@ -116,15 +121,15 @@ export default {
|
|
this.$refs.table.refresh(true)
|
|
this.$refs.table.refresh(true)
|
|
},
|
|
},
|
|
// 删除
|
|
// 删除
|
|
- handleDel (item) {
|
|
|
|
|
|
+ handleDel (row) {
|
|
|
|
+ console.log(row)
|
|
const _this = this
|
|
const _this = this
|
|
- _this.nowId = item.id
|
|
|
|
_this.$confirm({
|
|
_this.$confirm({
|
|
title: '提示',
|
|
title: '提示',
|
|
content: '删除后原数据不可恢复,是否删除?',
|
|
content: '删除后原数据不可恢复,是否删除?',
|
|
centered: true,
|
|
centered: true,
|
|
onOk () {
|
|
onOk () {
|
|
- dealerProductTypeDel({ id: _this.nowId }).then(res => {
|
|
|
|
|
|
+ productTypeDel({ sn: row.productTypeSn }).then(res => {
|
|
if (res.status == 200) {
|
|
if (res.status == 200) {
|
|
_this.$message.success(res.message)
|
|
_this.$message.success(res.message)
|
|
_this.$refs.table.refresh()
|
|
_this.$refs.table.refresh()
|