|
@@ -0,0 +1,233 @@
|
|
|
+<template>
|
|
|
+ <div class="categorySet-wrap">
|
|
|
+ <a-spin :spinning="spinning" tip="Loading...">
|
|
|
+ <a-page-header :ghost="false" :backIcon="false" class="header-bar">
|
|
|
+ <!-- 自定义的二级文字标题 -->
|
|
|
+ <template slot="subTitle">
|
|
|
+ <span class="subTitle-word text-overflow" style="max-width:300px;">用户姓名:测试测试</span>
|
|
|
+ <a-button id="purchaseNewOrderEdit-back-btn" type="link" @click="handleBack" class="button-default"> <a-icon type="rollback" /> 返回列表</a-button>
|
|
|
+ </template>
|
|
|
+ </a-page-header>
|
|
|
+ <a-card size="small" :bordered="false" class="categorySet-cont">
|
|
|
+ <div class="table-operator">
|
|
|
+ <a-button type="primary" class="button-error" @click="addCategory">+新增管辖品类</a-button>
|
|
|
+ </div>
|
|
|
+ <a-table
|
|
|
+ bordered
|
|
|
+ :data-source="dataSource"
|
|
|
+ :columns="columns"
|
|
|
+ ref="table"
|
|
|
+ :style="{ height: tableHeight+84.5+'px' }"
|
|
|
+ :scroll="{ y: tableHeight }"
|
|
|
+ style="word-break: break-all;">
|
|
|
+ <!-- 产品分类 -->
|
|
|
+ <template slot="classify" slot-scope="text,record,index">
|
|
|
+ <a-row v-if="record.classifyList && record.classifyList.length>0">
|
|
|
+ <a-col :span="20">
|
|
|
+ <a-tag closable @close="delLabel(index,i,'classifyList')" v-for="(con,i) in record.classifyList" :key="i">
|
|
|
+ {{ con }}
|
|
|
+ </a-tag>
|
|
|
+ </a-col>
|
|
|
+ <a-col :span="4" style="text-align:right;">
|
|
|
+ <a-tag style="background: #fff; borderStyle: dashed;" @click="addClassifyTag(index, record)" color="blue">
|
|
|
+ <a-icon type="plus" /> 选择
|
|
|
+ </a-tag>
|
|
|
+ </a-col>
|
|
|
+ </a-row>
|
|
|
+ <a-row v-else>
|
|
|
+ <a-col :span="24">
|
|
|
+ <a-tag style="background: #fff; borderStyle: dashed;" @click="addClassifyTag(index, record)" color="blue">
|
|
|
+ <a-icon type="plus" /> 选择
|
|
|
+ </a-tag>
|
|
|
+ </a-col>
|
|
|
+ </a-row>
|
|
|
+ </template>
|
|
|
+ <!-- 产品品牌 -->
|
|
|
+ <template slot="brand" slot-scope="text,record,index">
|
|
|
+ <a-row v-if="record.brandList && record.brandList.length>0">
|
|
|
+ <a-col :span="20">
|
|
|
+ <a-tag closable @close="delLabel(index,j,'brandList')" v-for="(item,j) in record.brandList" :key="j">
|
|
|
+ {{ item }}
|
|
|
+ </a-tag>
|
|
|
+ </a-col>
|
|
|
+ <a-col :span="4" style="text-align:right;">
|
|
|
+ <a-tag style="background: #fff; borderStyle: dashed;" @click="addBrandTag" color="blue">
|
|
|
+ <a-icon type="plus" /> 选择
|
|
|
+ </a-tag>
|
|
|
+ </a-col>
|
|
|
+ </a-row>
|
|
|
+ <a-row v-else>
|
|
|
+ <a-col :span="24">
|
|
|
+ <a-tag style="background: #fff; borderStyle: dashed;" @click="addBrandTag" color="blue">
|
|
|
+ <a-icon type="plus" /> 选择
|
|
|
+ </a-tag>
|
|
|
+ </a-col>
|
|
|
+ </a-row>
|
|
|
+ </template>
|
|
|
+ <span slot="action" slot-scope="text, record">
|
|
|
+ <a-button
|
|
|
+ size="small"
|
|
|
+ type="link"
|
|
|
+ class="button-error"
|
|
|
+ @click="handleDel(text)"
|
|
|
+ >
|
|
|
+ 删除
|
|
|
+ </a-button>
|
|
|
+ </span>
|
|
|
+ </a-table>
|
|
|
+ <div class="table-operator">
|
|
|
+ <a-button type="primary" class="button-info" @click="save">保存</a-button>
|
|
|
+ </div>
|
|
|
+ </a-card>
|
|
|
+ </a-spin>
|
|
|
+ <!-- 选择分类 -->
|
|
|
+ <chooseClassifyModal :openModal="showClassifyModal" @ok="handleClassifyModal" @close="showClassifyModal=false" ></chooseClassifyModal>
|
|
|
+ <!-- 选择品牌 -->
|
|
|
+ <chooseBrandModal :openModal="showBrandModal" @close="showBrandModal=false" ></chooseBrandModal>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { commonMixin } from '@/utils/mixin'
|
|
|
+import chooseBrandModal from './chooseBrandModal'
|
|
|
+import chooseClassifyModal from './chooseClassifyModal'
|
|
|
+export default {
|
|
|
+ name: 'CategorySet',
|
|
|
+ mixins: [commonMixin],
|
|
|
+ components: { chooseBrandModal, chooseClassifyModal },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ spinning: false,
|
|
|
+ tableHeight: 0,
|
|
|
+ queryParam: { // 查询条件
|
|
|
+ warehouseSn: this.$route.params.sn, // 仓库sn
|
|
|
+ name: '' // 仓位名称
|
|
|
+ },
|
|
|
+ disabled: false, // 查询、重置按钮是否可操作
|
|
|
+ columns: [
|
|
|
+ { title: '分类', dataIndex: 'no', width: '42%', align: 'center', scopedSlots: { customRender: 'classify' } },
|
|
|
+ { title: '品牌', dataIndex: 'name', width: '42%', align: 'center', scopedSlots: { customRender: 'brand' } },
|
|
|
+ { title: '操作', scopedSlots: { customRender: 'action' }, width: '16%', align: 'center' }
|
|
|
+ ],
|
|
|
+ dataSource: [],
|
|
|
+ openModal: false, // 新增编辑产品品牌 弹框
|
|
|
+ itemSn: '', // 当前sn
|
|
|
+ nowData: null, // 当前记录数据
|
|
|
+ showClassifyModal: false,
|
|
|
+ showBrandModal: false,
|
|
|
+ ChooseClassifyPos: null
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 返回
|
|
|
+ handleBack () {
|
|
|
+ this.$router.push({ name: 'powerUserList' })
|
|
|
+ },
|
|
|
+ // 新增管辖品类
|
|
|
+ addCategory () {
|
|
|
+ const newData = {
|
|
|
+ classifyList: [],
|
|
|
+ brandList: []
|
|
|
+ }
|
|
|
+ this.dataSource.push(newData)
|
|
|
+ },
|
|
|
+ // 删除分类、品牌标签
|
|
|
+ delLabel (pos, i, name) {
|
|
|
+ this.dataSource[pos][name].splice(i, 1)
|
|
|
+ },
|
|
|
+ // 添加分类标签
|
|
|
+ addClassifyTag (pos, row) {
|
|
|
+ this.ChooseClassifyPos = pos
|
|
|
+ this.showClassifyModal = true
|
|
|
+ },
|
|
|
+ handleClassifyModal (con) {
|
|
|
+ const chooseList = con
|
|
|
+ this.showClassifyModal = false
|
|
|
+ this.dataSource[this.ChooseClassifyPos].classifyList = [...this.dataSource[this.ChooseClassifyPos].classifyList, ...chooseList]
|
|
|
+ },
|
|
|
+ // 添加品牌标签
|
|
|
+ addBrandTag (pos, row) {
|
|
|
+ this.ChooseBrandPos = pos
|
|
|
+ this.showBrandModal = true
|
|
|
+ },
|
|
|
+ // 保存
|
|
|
+ save () {
|
|
|
+
|
|
|
+ },
|
|
|
+ // 新增/编辑
|
|
|
+ handleEdit (row) {
|
|
|
+ if (row) {
|
|
|
+ this.itemSn = row.warehouseLocationSn
|
|
|
+ row.warehouseSn = this.$route.params.sn
|
|
|
+ this.nowData = row
|
|
|
+ } else {
|
|
|
+ this.itemSn = null
|
|
|
+ this.nowData = { warehouseSn: this.$route.params.sn }
|
|
|
+ }
|
|
|
+ this.openModal = true
|
|
|
+ },
|
|
|
+ // 新增/编辑 成功
|
|
|
+ handleOk () {
|
|
|
+ this.$refs.table.refresh(true)
|
|
|
+ },
|
|
|
+ // 关闭弹框
|
|
|
+ closeModal () {
|
|
|
+ this.itemSn = ''
|
|
|
+ this.openModal = false
|
|
|
+ },
|
|
|
+ // 删除
|
|
|
+ handleDel (pos) {
|
|
|
+ const _this = this
|
|
|
+ this.$confirm({
|
|
|
+ title: '提示',
|
|
|
+ content: '删除后不可恢复,确定要进行删除吗?',
|
|
|
+ centered: true,
|
|
|
+ onOk () {
|
|
|
+ _this.dataSource.splice(pos, 1)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ pageInit () {
|
|
|
+ const _this = this
|
|
|
+ this.$nextTick(() => { // 页面渲染完成后的回调
|
|
|
+ _this.setTableH()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ setTableH () {
|
|
|
+ this.tableHeight = window.innerHeight - 350
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
|
|
|
+ this.setTableH()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted () {
|
|
|
+ if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
|
|
|
+ this.pageInit()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ activated () {
|
|
|
+ // 如果是新页签打开,则重置当前页面
|
|
|
+ if (this.$store.state.app.isNewTab) {
|
|
|
+ this.pageInit()
|
|
|
+ }
|
|
|
+ // 仅刷新列表,不重置页面
|
|
|
+ if (this.$store.state.app.updateList) {
|
|
|
+ this.pageInit()
|
|
|
+ this.$refs.table.refresh()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ beforeRouteEnter (to, from, next) {
|
|
|
+ next(vm => {})
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less">
|
|
|
+ .categorySet-wrap{
|
|
|
+ .table-operator{
|
|
|
+ text-align:right;
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|