|
@@ -2,7 +2,7 @@
|
|
|
<a-card :bordered="false" class="productCategoryList-wrap">
|
|
|
<!-- 操作按钮 -->
|
|
|
<div class="table-operator">
|
|
|
- <a-button id="productCategoryList-add" type="primary" @click="handleAdd" style="margin-top: 18px;">新增一级分类</a-button>
|
|
|
+ <a-button id="productCategoryList-add" type="primary" @click="handleAdd()" style="margin-top: 18px;">新增一级分类</a-button>
|
|
|
</div>
|
|
|
<!-- 列表 -->
|
|
|
<s-table
|
|
@@ -18,12 +18,13 @@
|
|
|
<!-- 操作 -->
|
|
|
<template slot="action" slot-scope="text, record">
|
|
|
<a-button
|
|
|
+ v-if="record.productTypeLevel<3"
|
|
|
type="link"
|
|
|
size="small"
|
|
|
icon="plus"
|
|
|
class="btn-add-s"
|
|
|
id="productCategory-addSubItem"
|
|
|
- @click="handleAdd(text)">新增子级</a-button>
|
|
|
+ @click="handleAdd(record)">新增子级</a-button>
|
|
|
<a-button
|
|
|
v-if="record.pid != 0"
|
|
|
type="link"
|
|
@@ -31,7 +32,7 @@
|
|
|
icon="edit"
|
|
|
class="btn-edit-s"
|
|
|
id="productCategory-edit"
|
|
|
- @click="handleEdit(text)">编辑</a-button>
|
|
|
+ @click="handleEdit(record)">编辑</a-button>
|
|
|
<a-button
|
|
|
v-if="record.pid != 0"
|
|
|
type="link"
|
|
@@ -39,40 +40,20 @@
|
|
|
icon="delete"
|
|
|
class="btn-del-s"
|
|
|
id="productCategory-del"
|
|
|
- @click="handleDel(text)">删除</a-button>
|
|
|
+ @click="handleDel(record)">删除</a-button>
|
|
|
</template>
|
|
|
</s-table>
|
|
|
<!-- 新增/编辑产品类别 -->
|
|
|
- <a-modal
|
|
|
- class="productCategoryList-modal"
|
|
|
- centered
|
|
|
- :title="title"
|
|
|
- :visible="visible"
|
|
|
- :footer="null"
|
|
|
- :closable="true"
|
|
|
- @cancel="onCancel"
|
|
|
- :width="800">
|
|
|
- <!-- 表单 -->
|
|
|
- <a-form-model ref="ruleForm" :model="form" :rules="rules" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
|
|
|
- <a-form-model-item label="产品类别名称" prop="name">
|
|
|
- <a-input v-model.trim="form.name" id="productCategory-itemName" :maxLength="30" placeholder="请输入产品类别名称(最多30个字符)" />
|
|
|
- </a-form-model-item>
|
|
|
- <a-form-model-item class="btn-cont" :labelCol="{span: 0}" :wrapperCol="{span: 24}">
|
|
|
- <a-button type="primary" id="productCategory-save" @click="onSubmit">保存</a-button>
|
|
|
- <a-button class="cancel" id="productCategory-cancel" @click="onCancel">取消</a-button>
|
|
|
- </a-form-model-item>
|
|
|
- </a-form-model>
|
|
|
- </a-modal>
|
|
|
+ <product-category-edit-modal :openModal="openModal" :nowData="nowData" :itemId="itemId" @ok="handleOk" @close="closeModal" />
|
|
|
</a-card>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import moment from 'moment'
|
|
|
-// import { customerBundleDelayList, customerBundleExportDelay } from '@/api/FinancialManagement'
|
|
|
-import { STable, VSelect } from '@/components'
|
|
|
+import { dealerProductTypeQuery, dealerProductTypeDel } from '@/api/dealerProductType'
|
|
|
+import { STable } from '@/components'
|
|
|
import productCategoryEditModal from './editModal.vue'
|
|
|
export default {
|
|
|
- components: { STable, VSelect, productCategoryEditModal },
|
|
|
+ components: { STable, productCategoryEditModal },
|
|
|
data () {
|
|
|
return {
|
|
|
formItemLayout: {
|
|
@@ -80,103 +61,56 @@ export default {
|
|
|
wrapperCol: { span: 16 }
|
|
|
},
|
|
|
columns: [
|
|
|
- { title: '组织机构名称', dataIndex: 'name', width: 200, align: 'left' },
|
|
|
+ { title: '产品类别名称', dataIndex: 'productTypeName', width: 200, align: 'left' },
|
|
|
+ { title: '首字母', dataIndex: 'sss', width: 150, align: 'center' },
|
|
|
{ title: '创建时间', dataIndex: 'createDate', width: 150, align: 'center' },
|
|
|
{ title: '操作', scopedSlots: { customRender: 'action' }, width: 150, align: 'center' }
|
|
|
],
|
|
|
// 加载数据方法 必须为 Promise 对象
|
|
|
loadData: parameter => {
|
|
|
this.disabled = true
|
|
|
- // return customerBundleDelayList( Object.assign(parameter, this.queryParam) ).then(res => {
|
|
|
- // const data = res.data
|
|
|
- // const no = (data.pageNo - 1) * data.pageSize
|
|
|
- // for (var i = 0; i < data.list.length; i++) {
|
|
|
- // data.list[i].no = no + i + 1
|
|
|
- // }
|
|
|
- // this.disabled = false
|
|
|
- // return data
|
|
|
- // })
|
|
|
- // return findOrgTree().then(res => {
|
|
|
- // // 递归去除空children
|
|
|
- // this.recursionFun(res.data)
|
|
|
- // this.defaultExpandedRowKeys[0] = res.data[0].id
|
|
|
- // return res.data
|
|
|
- // })
|
|
|
- const _this = this
|
|
|
- return new Promise(function(resolve, reject){
|
|
|
- const data = {
|
|
|
- pageNo: 1,
|
|
|
- pageSize: 10,
|
|
|
- list: [
|
|
|
- { id: '1', productNum: 'jgqp11111111111', productName: '产品1', productOldNum: 'jgqp111123545', productBrand: '箭冠品牌', productType: '产品分类1', inventoryNum: '5', inventoryMoney: '122' }
|
|
|
- ]
|
|
|
- }
|
|
|
- const no = (data.pageNo - 1) * data.pageSize
|
|
|
- for (var i = 0; i < data.list.length; i++) {
|
|
|
- data.list[i].no = no + i + 1
|
|
|
- }
|
|
|
- _this.disabled = false
|
|
|
- resolve(data)
|
|
|
+ return dealerProductTypeQuery({}).then(res => {
|
|
|
+ // 递归去除空children
|
|
|
+ this.recursionFun(res.data)
|
|
|
+ this.defaultExpandedRowKeys[0] = res.data[0].id
|
|
|
+ return res.data
|
|
|
})
|
|
|
},
|
|
|
- title: '新增', // 对话框标题
|
|
|
- visible: false, // 对话框是否可见
|
|
|
- form: { // 新增编辑 组织机构
|
|
|
- name: ''
|
|
|
- },
|
|
|
- rules: { // 表单校验规则
|
|
|
- name: [{ required: true, message: '请输入组织机构名称', trigger: 'blur' }]
|
|
|
- },
|
|
|
- nowId: '', // 当前操作的数据id
|
|
|
- nowPid: '', // 当前操作的数据上级id
|
|
|
- defaultExpandedRowKeys: [] // 树形数据默认展开项
|
|
|
+ defaultExpandedRowKeys: [], // 树形数据默认展开项
|
|
|
+ openModal: false, // 新增编辑 弹框
|
|
|
+ itemId: '', // 当前id
|
|
|
+ nowData: null // 当前记录数据
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
// 新增子级
|
|
|
- handleAdd (item) {
|
|
|
- this.nowId = ''
|
|
|
- this.form.name = ''
|
|
|
- if (item) { // 子级
|
|
|
- this.nowPid = item.id
|
|
|
- } else { // 最高级
|
|
|
- this.nowPid = ''
|
|
|
+ handleAdd (row) {
|
|
|
+ this.itemId = null
|
|
|
+ if(row){ // 新增子级
|
|
|
+ let nowData = row
|
|
|
+ nowData.psn = nowData && nowData.productTypeSn ? nowData.productTypeSn : null
|
|
|
+ this.nowData = nowData
|
|
|
+ }else{ // 最高级
|
|
|
+ this.nowData = null
|
|
|
}
|
|
|
- this.title = '新增'
|
|
|
- this.visible = true
|
|
|
+ this.openModal = true
|
|
|
},
|
|
|
// 编辑
|
|
|
- handleEdit (item) {
|
|
|
- this.nowId = item.id
|
|
|
- this.nowPid = item.pid
|
|
|
- this.title = '编辑'
|
|
|
- this.form.name = item.name
|
|
|
- this.visible = true
|
|
|
+ handleEdit (row) {
|
|
|
+ this.itemId = row && row.id ? row.id : null
|
|
|
+ let nowData = row
|
|
|
+ nowData.psn = nowData && nowData.productTypeSn ? nowData.productTypeSn : null
|
|
|
+ this.nowData = nowData
|
|
|
+ this.openModal = true
|
|
|
},
|
|
|
- // 保存
|
|
|
- onSubmit () {
|
|
|
- const _this = this
|
|
|
- _this.$refs.ruleForm.validate(valid => {
|
|
|
- if (valid) {
|
|
|
- const formData = JSON.parse(JSON.stringify(_this.form))
|
|
|
- formData.id = _this.nowId
|
|
|
- formData.pid = _this.nowPid
|
|
|
- saveAtorg(formData).then(res => {
|
|
|
- if (res.status == 200) {
|
|
|
- _this.$message.success(res.message)
|
|
|
- _this.$refs.table.refresh(true)
|
|
|
- _this.visible = false
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- return false
|
|
|
- }
|
|
|
- })
|
|
|
+ // 关闭弹框
|
|
|
+ closeModal(){
|
|
|
+ this.itemId = ''
|
|
|
+ this.openModal = false
|
|
|
},
|
|
|
- // 关闭对话框
|
|
|
- onCancel () {
|
|
|
- this.$refs.ruleForm.resetFields()
|
|
|
- this.visible = false
|
|
|
+ // 新增/编辑 成功
|
|
|
+ handleOk(){
|
|
|
+ this.$refs.table.refresh(true)
|
|
|
},
|
|
|
// 删除
|
|
|
handleDel (item) {
|
|
@@ -187,7 +121,7 @@ export default {
|
|
|
centered: true,
|
|
|
content: '删除后原数据不可恢复,是否删除?',
|
|
|
onOk () {
|
|
|
- delAtorg({ id: _this.nowId }).then(res => {
|
|
|
+ dealerProductTypeDel({ id: _this.nowId }).then(res => {
|
|
|
if (res.status == 200) {
|
|
|
_this.$message.success(res.message)
|
|
|
_this.$refs.table.refresh()
|
|
@@ -233,13 +167,4 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // 弹框
|
|
|
- .productCategoryList-modal{
|
|
|
- .btn-cont{
|
|
|
- text-align: center;
|
|
|
- .cancel {
|
|
|
- margin-left: 50px;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
</style>
|