|
@@ -0,0 +1,329 @@
|
|
|
+<template>
|
|
|
+ <div class="permissionSetting-wrap">
|
|
|
+ <a-page-header :ghost="false" :backIcon="false" @back="handleBack" class="permissionSetting-cont">
|
|
|
+ <!-- 自定义的二级文字标题 -->
|
|
|
+ <template slot="subTitle">
|
|
|
+ <a id="permissionSetting-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
|
|
|
+ </template>
|
|
|
+ </a-page-header>
|
|
|
+ <a-card size="small" :bordered="false" class="permissionSetting-main">
|
|
|
+ <!-- 搜索条件 -->
|
|
|
+ <div class="table-page-search-wrapper">
|
|
|
+ <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
|
|
|
+ <a-row :gutter="15">
|
|
|
+ <a-col :md="6" :sm="24">
|
|
|
+ <a-form-item label="产品名称">
|
|
|
+ <a-input id="permissionSetting-name" v-model.trim="queryParam.name" allowClear placeholder="请输入产品名称"/>
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :md="6" :sm="24">
|
|
|
+ <a-form-item label="产品编码">
|
|
|
+ <a-input id="permissionSetting-productCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :md="6" :sm="24">
|
|
|
+ <a-form-item label="品牌">
|
|
|
+ <a-select
|
|
|
+ placeholder="请选择"
|
|
|
+ id="permissionSetting-productBrandSn"
|
|
|
+ allowClear
|
|
|
+ v-model="queryParam.productBrandSn"
|
|
|
+ :showSearch="true"
|
|
|
+ option-filter-prop="children"
|
|
|
+ :filter-option="filterOption">
|
|
|
+ <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
|
|
|
+ </a-select>
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ <template v-if="advanced">
|
|
|
+ <a-col :md="6" :sm="24">
|
|
|
+ <a-form-item label="产品分类">
|
|
|
+ <a-cascader
|
|
|
+ @change="changeProductType"
|
|
|
+ expand-trigger="hover"
|
|
|
+ change-on-select
|
|
|
+ :options="productTypeList"
|
|
|
+ :fieldNames="{ label: 'productTypeName', value: 'id', children: 'children' }"
|
|
|
+ id="permissionSetting-productType"
|
|
|
+ placeholder="请选择产品分类"
|
|
|
+ allowClear
|
|
|
+ v-model="productType" />
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ </template>
|
|
|
+ <a-col :md="6" :sm="24">
|
|
|
+ <a-button style="margin-bottom: 18px;" type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="permissionSetting-refresh">查询</a-button>
|
|
|
+ <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="permissionSetting-reset">重置</a-button>
|
|
|
+ <a @click="advanced=!advanced" style="margin-left: 8px">
|
|
|
+ {{ advanced ? '收起' : '展开' }}
|
|
|
+ <a-icon :type="advanced ? 'up' : 'down'"/>
|
|
|
+ </a>
|
|
|
+ </a-col>
|
|
|
+ </a-row>
|
|
|
+ </a-form>
|
|
|
+ </div>
|
|
|
+ <!-- 操作按钮 -->
|
|
|
+ <div class="table-operator">
|
|
|
+ <a-button id="permissionSetting-brand" type="primary" class="button-error" @click="choosePModal('brand')">选择产品品牌</a-button>
|
|
|
+ <a-button id="permissionSetting-type" type="primary" class="button-info" @click="choosePModal('type')">选择产品分类</a-button>
|
|
|
+ <a-button id="permissionSetting-product" type="primary" class="button-success" @click="choosePModal('product')">选择产品</a-button>
|
|
|
+ </div>
|
|
|
+ <!-- 列表 -->
|
|
|
+ <s-table
|
|
|
+ class="sTable"
|
|
|
+ ref="table"
|
|
|
+ size="default"
|
|
|
+ :rowKey="(record) => record.id"
|
|
|
+ :columns="columns"
|
|
|
+ :data="loadData"
|
|
|
+ :scroll="{ x: 1200, y: tableHeight }"
|
|
|
+ bordered>
|
|
|
+ <!-- 操作 -->
|
|
|
+ <template slot="action" slot-scope="text, record">
|
|
|
+ <a-button size="small" type="link" class="button-error" @click="handleDel(record)">删除</a-button>
|
|
|
+ </template>
|
|
|
+ </s-table>
|
|
|
+ </a-card>
|
|
|
+ <!-- 选择产品品牌 -->
|
|
|
+ <chooseBrandModal :openModal="openBrandModal" :chooseData="chooseBrand" @close="openBrandModal=false" @ok="handleBrandOk" />
|
|
|
+ <!-- 选择产品分类 -->
|
|
|
+ <chooseTypeModal :openModal="openTypeModal" :chooseData="chooseType" @close="openTypeModal=false" @ok="handleTypeOk" />
|
|
|
+ <!-- 选择产品 -->
|
|
|
+ <chooseProductsModal :openModal="openProductsModal" :chooseData="chooseProducts" @close="openProductsModal=false" @ok="handleProductsOk" />
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { STable, VSelect } from '@/components'
|
|
|
+import ChooseProductsModal from '@/views/common/chooseProductsModal.vue'
|
|
|
+import ChooseBrandModal from '@/views/common/chooseBrandModal.vue'
|
|
|
+import ChooseTypeModal from '@/views/common/chooseTypeModal.vue'
|
|
|
+import { productBrandQuery } from '@/api/productBrand'
|
|
|
+import { productTypeQuery } from '@/api/productType'
|
|
|
+import { dealerScopeList, dealerScopeDel } from '@/api/dealerScope'
|
|
|
+export default {
|
|
|
+ components: { STable, VSelect, ChooseProductsModal, ChooseBrandModal, ChooseTypeModal },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ advanced: false, // 高级搜索 展开/关闭
|
|
|
+ tableHeight: 0,
|
|
|
+ queryParam: { // 查询条件
|
|
|
+ name: '', // 产品名称
|
|
|
+ productCode: '', // 产品编码
|
|
|
+ productBrandSn: undefined, // 产品品牌
|
|
|
+ productTypeSn1: '', // 产品一级分类
|
|
|
+ productTypeSn2: '', // 产品二级分类
|
|
|
+ productTypeSn3: '' // 产品三级分类
|
|
|
+ },
|
|
|
+ productType: [],
|
|
|
+ disabled: false, // 查询、重置按钮是否可操作
|
|
|
+ columns: [
|
|
|
+ { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
|
|
|
+ { title: '添加时间', dataIndex: 'createDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
|
|
|
+ { title: '类型', dataIndex: 'productBrandName', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
|
|
|
+ { title: '类型名称', dataIndex: 'origCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
|
|
|
+ { title: '产品名称', dataIndex: 'name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
|
|
|
+ { title: '产品编码', dataIndex: 'code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
|
|
|
+ { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
|
|
|
+ ],
|
|
|
+ // 加载数据方法 必须为 Promise 对象
|
|
|
+ loadData: parameter => {
|
|
|
+ this.disabled = true
|
|
|
+ if (this.tableHeight == 0) {
|
|
|
+ this.tableHeight = window.innerHeight - 380
|
|
|
+ }
|
|
|
+ return dealerScopeList(Object.assign(parameter, this.queryParam, { dealerSn: this.$route.params.sn })).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
|
|
|
+ })
|
|
|
+ },
|
|
|
+ productBrandList: [], // 品牌下拉数据
|
|
|
+ productTypeList: [], // 分类下拉数据
|
|
|
+ openBrandModal: false, // 选择产品品牌
|
|
|
+ openTypeModal: false, // 选择产品分类
|
|
|
+ openProductsModal: false, // 选择产品
|
|
|
+ chooseBrand: [], // 所选品牌
|
|
|
+ chooseProducts: [], // 所选产品
|
|
|
+ chooseType: [] // 所选分类
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 选择产品
|
|
|
+ choosePModal (type) {
|
|
|
+ const productList = []
|
|
|
+ const brandList = []
|
|
|
+ const typeList = []
|
|
|
+ // this.loadData.map(item => {
|
|
|
+ // if (item.goodsType == 'PRODUCT') {
|
|
|
+ // productList.push(item)
|
|
|
+ // } else if (item.goodsType == 'BRAND') {
|
|
|
+ // brandList.push(item)
|
|
|
+ // } else if ((item.goodsType == 'TYPE_1') || (item.goodsType == 'TYPE_2') || (item.goodsType == 'TYPE_3')) {
|
|
|
+ // typeList.push(item)
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ if (type == 'product') { // 选择产品
|
|
|
+ this.chooseProducts = productList
|
|
|
+ this.openProductsModal = true
|
|
|
+ } else if (type == 'brand') { // 选择品牌
|
|
|
+ this.chooseBrand = brandList
|
|
|
+ this.openBrandModal = true
|
|
|
+ } else if (type == 'type') { // 选择分类
|
|
|
+ this.chooseType = typeList
|
|
|
+ this.openTypeModal = true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 品牌
|
|
|
+ handleBrandOk (obj) {
|
|
|
+ console.log(obj, '---------------品牌')
|
|
|
+ this.chooseBrand = obj
|
|
|
+ this.changeData('brand')
|
|
|
+ },
|
|
|
+ // 产品
|
|
|
+ handleProductsOk (obj) {
|
|
|
+ console.log(obj, '---------------产品')
|
|
|
+ this.chooseProducts = obj
|
|
|
+ this.changeData('product')
|
|
|
+ },
|
|
|
+ // 分类
|
|
|
+ handleTypeOk (obj) {
|
|
|
+ console.log(obj, '---------------分类')
|
|
|
+ this.chooseType = obj
|
|
|
+ this.changeData('type')
|
|
|
+ },
|
|
|
+ changeData (type) {
|
|
|
+ const _this = this
|
|
|
+ if (type == 'product') { // 选择产品
|
|
|
+
|
|
|
+ } else if (type == 'brand') { // 选择品牌
|
|
|
+ if (_this.chooseBrand.length > 0) {
|
|
|
+ _this.chooseBrand.map(item => {
|
|
|
+ item.goodsType = 'BRAND'
|
|
|
+ item.goodsTypeName = '品牌'
|
|
|
+ item.goodsName = item.brandName
|
|
|
+ item.goodsSn = item.brandSn
|
|
|
+ delete item.id
|
|
|
+ })
|
|
|
+ this.setData()
|
|
|
+ }
|
|
|
+ } else if (type == 'type') { // 选择分类
|
|
|
+
|
|
|
+ }
|
|
|
+ const loadData = []
|
|
|
+
|
|
|
+ if (_this.chooseType.length > 0) {
|
|
|
+ _this.chooseType.map(item => {
|
|
|
+ const obj = {
|
|
|
+ goodsType: 'TYPE_' + item.productTypeLevel,
|
|
|
+ goodsTypeName: (item.productTypeLevel == 1 ? '一级' : item.productTypeLevel == 2 ? '二级' : item.productTypeLevel == 3 ? '三级' : '') + '分类',
|
|
|
+ goodsName: item.productTypeName,
|
|
|
+ goodsSn: item.productTypeSn,
|
|
|
+ orderGoodsUnit: undefined,
|
|
|
+ orderGoodsQty: ''
|
|
|
+ }
|
|
|
+ delete item.id
|
|
|
+ loadData.push(Object.assign(obj, item))
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (_this.chooseProducts.length > 0) {
|
|
|
+ _this.chooseProducts.map(item => {
|
|
|
+ const obj = {
|
|
|
+ goodsType: 'PRODUCT',
|
|
|
+ goodsTypeName: '产品',
|
|
|
+ goodsName: item.name,
|
|
|
+ name: item.name,
|
|
|
+ goodsCode: item.code,
|
|
|
+ goodsSn: item.productSn,
|
|
|
+ orderGoodsUnit: undefined,
|
|
|
+ orderGoodsQty: ''
|
|
|
+ }
|
|
|
+ delete item.id
|
|
|
+ loadData.push(Object.assign(obj, item))
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 删除
|
|
|
+ handleDel (row) {
|
|
|
+ const _this = this
|
|
|
+ this.$confirm({
|
|
|
+ title: '提示',
|
|
|
+ content: '确认要删除吗?',
|
|
|
+ centered: true,
|
|
|
+ onOk () {
|
|
|
+ dealerScopeDel({ sn: row.dealerScopeSn }).then(res => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ _this.$message.success(res.message)
|
|
|
+ _this.$refs.table.refresh()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 重置表单
|
|
|
+ resetSearchForm () {
|
|
|
+ this.queryParam.name = ''
|
|
|
+ this.queryParam.productCode = ''
|
|
|
+ this.queryParam.productBrandSn = undefined
|
|
|
+ this.queryParam.productTypeSn1 = ''
|
|
|
+ this.queryParam.productTypeSn2 = ''
|
|
|
+ this.queryParam.productTypeSn3 = ''
|
|
|
+ this.productType = []
|
|
|
+ this.$refs.table.refresh(true)
|
|
|
+ },
|
|
|
+ // 返回
|
|
|
+ handleBack () {
|
|
|
+ this.$router.push({ name: 'merchantInfoManagementList' })
|
|
|
+ },
|
|
|
+ filterOption (input, option) {
|
|
|
+ return (
|
|
|
+ option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
|
|
+ )
|
|
|
+ },
|
|
|
+ // 产品分类 change
|
|
|
+ changeProductType (val, opt) {
|
|
|
+ this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
|
|
|
+ this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
|
|
|
+ this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
|
|
|
+ },
|
|
|
+ // 产品品牌 列表
|
|
|
+ getProductBrand () {
|
|
|
+ productBrandQuery({}).then(res => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ this.productBrandList = res.data
|
|
|
+ } else {
|
|
|
+ this.productBrandList = []
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 产品分类 列表
|
|
|
+ getProductType () {
|
|
|
+ productTypeQuery({}).then(res => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ this.productTypeList = res.data
|
|
|
+ } else {
|
|
|
+ this.productTypeList = []
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ beforeRouteEnter (to, from, next) {
|
|
|
+ next(vm => {
|
|
|
+ vm.getProductBrand()
|
|
|
+ vm.getProductType()
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+ .permissionSetting-wrap{
|
|
|
+ .permissionSetting-cont{
|
|
|
+ margin-bottom: 10px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|