Commit f0a1362c authored by ylpmty's avatar ylpmty

商品列表多选,商品选择组件增加数据回显

parent 3952fdcb
<template> <template>
<el-row class="" :gutter="10"> <el-row class="" :gutter="10">
<el-col :span="10"> <el-col :span="10">
<el-card> <el-card>
<div slot="header" class="header"> <div slot="header" class="header">
<el-select v-model="queryParams.typeId" placeholder="选择类型" style="width:120px" clearable> <el-select v-model="queryParams.typeId" placeholder="选择类型" style="width:120px" clearable>
<el-option v-for="item in typeList" :key="item.id" :label="item.titleZh" :value="item.id" /> <el-option v-for="item in typeList" :key="item.id" :label="item.titleZh" :value="item.id" />
</el-select> </el-select>
<el-select v-model="queryParams.attrId" placeholder="选择属性" style="width:120px" clearable> <el-select v-model="queryParams.attrId" placeholder="选择属性" style="width:120px" clearable>
<el-option v-for="item in attrList" :key="item.id" :label="item.attrName" :value="item.id" /> <el-option v-for="item in attrList" :key="item.id" :label="item.attrName" :value="item.id" />
</el-select> </el-select>
<el-input v-model="queryParams.titleZh" placeholder="产品关键字" style="width:120px" clearable /> <el-input v-model="queryParams.titleZh" placeholder="产品关键字" style="width:120px" clearable />
<el-button type="primary" @click="reLoad">搜搜</el-button> <el-button type="primary" @click="reLoad">搜搜</el-button>
</div> </div>
<div class="list"> <div class="list">
<div class="item" v-for="item in list" :key="item.id"> <div class="item" v-for="item in list" :key="item.id">
<el-checkbox @change="toggleCheck(item, $event)" :value="ids.indexOf(item.id) > -1" /> {{item.titleZh}} <el-checkbox @change="toggleCheck(item, $event)" :value="ids.indexOf(item.id) > -1" /> {{item.titleZh}}
<div>{{item.titleEn}}</div> <div>{{item.titleEn}}</div>
</div> </div>
</div> </div>
</el-card> </el-card>
</el-col> </el-col>
<el-col :span="10"> <el-col :span="10">
<el-card> <el-card>
<div slot="header" class="header"> <div slot="header" class="header">
已选产品 已选产品
</div> </div>
<div class="list"> <div class="list">
<div class="item" v-for="(choosed) in choosedList" :key="choosed.id" :data-data="JSON.stringify(choosed)"> <div class="item" v-for="(choosed) in choosedList" :key="choosed.id" :data-data="JSON.stringify(choosed)">
<el-link class="el-icon-delete" @click="remove(choosed)" /> {{choosed.titleZh}} <el-link class="el-icon-delete" @click="remove(choosed)" /> {{choosed.titleZh}}
<div>{{choosed.titleEn}}</div> <div>{{choosed.titleEn}}</div>
</div> </div>
</div> </div>
</el-card> </el-card>
</el-col> </el-col>
</el-row> </el-row>
</template> </template>
<script> <script>
import {getProductPage} from '@/api/ecw/product' import { getProductPage } from '@/api/ecw/product'
import {getProductTypeList} from '@/api/ecw/productType' import { getProductTypeList } from '@/api/ecw/productType'
import {getProductAttrList} from '@/api/ecw/productAttr' import { getProductAttrList } from '@/api/ecw/productAttr'
export default { export default {
data(){ props: {
return { defaultIds: {
list:[], type: Array,
page: 1, default: []
pages: 1, }
queryParams:{ },
page: 1, data() {
attrId: null, return {
titleZh: null, list: [],
typeId: null page: 1,
}, pages: 1,
choosedList:[], queryParams: {
typeList:[], page: 1,
attrList:[] attrId: null,
} titleZh: null,
typeId: null
},
choosedList: [],
typeList: [],
attrList: []
}
},
computed: {
ids: {
get() {
let arr = []
this.choosedList.forEach(item => {
arr.push(item.id)
})
return arr
},
set(v) {
}
}
},
watch: {
ids(val) {
this.$emit('input', val)
}
},
created() {
getProductTypeList().then(res => this.typeList = res.data)
getProductAttrList().then(res => this.attrList = res.data)
this.reLoad()
this.ids = this.defaultIds //数据回显
},
methods: {
reLoad() {
this.queryParams.page = 1
this.list = []
this.getList()
}, },
computed:{ loadNextPage() {
ids(){ if (this.page >= this.pages) {
let arr = [] return this.$message.error('已加载全部')
this.choosedList.forEach(item => { }
arr.push(item.id) this.queryParams.page++
this.getList()
},
getList() {
getProductPage(this.queryParams).then(res => {
this.list = res.data.list //.concat(res.data.list || [])
this.page = res.data.page
this.pages = res.data.pages
this.choosedList = [] //搜搜重置,数据回显
if (this.defaultIds.length > 0) {
this.defaultIds.map(item => {
this.list.map(items => {
if (items.id == item) {
this.choosedList.push(items)
}
}) })
return arr })
} }
})
}, },
watch:{ toggleCheck(item, checked) {
ids(val){ if (checked) {
this.$emit('input', val) this.choose(item)
} } else {
this.remove(item)
}
}, },
created(){ choose(item) {
getProductTypeList().then(res => this.typeList = res.data) this.choosedList.push(item)
getProductAttrList().then(res => this.attrList = res.data)
this.reLoad()
}, },
methods:{ remove(item) {
reLoad(){ this.choosedList.forEach((choosed, index) => {
this.queryParams.page = 1 if (choosed.id == item.id) this.choosedList.splice(index, 1)
this.list = [] })
this.getList()
},
loadNextPage(){
if(this.page >= this.pages){
return this.$message.error('已加载全部')
}
this.queryParams.page ++
this.getList()
},
getList(){
getProductPage(this.queryParams).then(res => {
this.list = res.data.list //.concat(res.data.list || [])
this.page = res.data.page
this.pages = res.data.pages
})
},
toggleCheck(item, checked){
if(checked){
this.choose(item)
}else{
this.remove(item)
}
},
choose(item){
this.choosedList.push(item)
},
remove(item){
this.choosedList.forEach((choosed,index) => {
if(choosed.id==item.id) this.choosedList.splice(index,1)
})
}
} }
}
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.header{ .header {
>div{ > div {
margin-right: 5px; margin-right: 5px;
} }
} }
.list{ .list {
height: 200px; height: 200px;
border: 1px solid #ccc; border: 1px solid #ccc;
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;
padding: 0 10px; padding: 0 10px;
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
.item{ .item {
width: 50%; width: 50%;
line-height: 20px; line-height: 20px;
height: 50px; height: 50px;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
} }
</style> </style>
\ No newline at end of file
...@@ -4,41 +4,41 @@ ...@@ -4,41 +4,41 @@
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="商品编码" prop="productCode"> <el-form-item label="商品编码" prop="productCode">
<el-input v-model="queryParams.productCode" placeholder="请输入商品编码" clearable @keyup.enter.native="handleQuery"/> <el-input v-model="queryParams.productCode" placeholder="请输入商品编码" clearable @keyup.enter.native="handleQuery" />
</el-form-item> </el-form-item>
<el-form-item label="海关编码" prop="customsCode"> <el-form-item label="海关编码" prop="customsCode">
<el-input v-model="queryParams.customsCode" placeholder="请输入海关编码" clearable @keyup.enter.native="handleQuery"/> <el-input v-model="queryParams.customsCode" placeholder="请输入海关编码" clearable @keyup.enter.native="handleQuery" />
</el-form-item> </el-form-item>
<el-form-item label="商品名称" prop="titleZh"> <el-form-item label="商品名称" prop="titleZh">
<el-input v-model="queryParams.titleZh" placeholder="请输入商品名称" clearable @keyup.enter.native="handleQuery"/> <el-input v-model="queryParams.titleZh" placeholder="请输入商品名称" clearable @keyup.enter.native="handleQuery" />
</el-form-item> </el-form-item>
<el-form-item label="商品类型" prop="typeId"> <el-form-item label="商品类型" prop="typeId">
<el-select v-model="queryParams.typeId" placeholder="选择商品类型" clearable> <el-select v-model="queryParams.typeId" placeholder="选择商品类型" clearable>
<el-option v-for="type in typeList" :key="type.id" :label="type.titleZh" :value="type.id"/> <el-option v-for="type in typeList" :key="type.id" :label="type.titleZh" :value="type.id" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="商品特性" prop="attrId"> <el-form-item label="商品特性" prop="attrId">
<el-select v-model="queryParams.attrId" placeholder="选择商品特性" clearable> <el-select v-model="queryParams.attrId" placeholder="选择商品特性" clearable>
<el-option v-for="attr in attrList" :key="attr.id" :label="attr.attrName" :value="attr.id"/> <el-option v-for="attr in attrList" :key="attr.id" :label="attr.attrName" :value="attr.id" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="审核状态" prop="auditStatus"> <el-form-item label="审核状态" prop="auditStatus">
<el-select v-model="queryParams.auditStatus" placeholder="选择审核状态" clearable> <el-select v-model="queryParams.auditStatus" placeholder="选择审核状态" clearable>
<el-option v-for="auditStatusItem in auditStatusDictDatas" :key="auditStatusItem.id" :label="auditStatusItem.label" :value="auditStatusItem.value"/> <el-option v-for="auditStatusItem in auditStatusDictDatas" :key="auditStatusItem.id" :label="auditStatusItem.label" :value="auditStatusItem.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="上架状态" prop="status"> <el-form-item label="上架状态" prop="status">
<el-select v-model="queryParams.status" placeholder="选择上架状态" clearable> <el-select v-model="queryParams.status" placeholder="选择上架状态" clearable>
<el-option v-for="statusItem in statusDictDatas" :key="statusItem.id" :label="statusItem.value == CommonStatusEnum.ENABLE ? '已上架' : '已下架'" :value="statusItem.value"/> <el-option v-for="statusItem in statusDictDatas" :key="statusItem.id" :label="statusItem.value == CommonStatusEnum.ENABLE ? '已上架' : '已下架'" :value="statusItem.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button> <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button> <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
...@@ -48,15 +48,19 @@ ...@@ -48,15 +48,19 @@
<!-- 操作工具栏 --> <!-- 操作工具栏 -->
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['ecw:product:create']">新增</el-button>
v-hasPermi="['ecw:product:create']">新增</el-button>
</el-col> </el-col>
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-setting" size="mini" @click="handleEdit" :disabled="multiple" v-hasPermi="['ecw:product:attr']">批量设置商品属性</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<!-- 列表 --> <!-- 列表 -->
<el-table v-loading="loading" :data="list"> <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center">
</el-table-column>
<el-table-column label="商品编号" align="center" prop="id" /> <el-table-column label="商品编号" align="center" prop="id" />
<el-table-column label="商品类型" align="center" prop="typeId"> <el-table-column label="商品类型" align="center" prop="typeId">
<template slot-scope="scope"> <template slot-scope="scope">
...@@ -74,44 +78,39 @@ ...@@ -74,44 +78,39 @@
<el-table-column prop="auditStatus" align="center" label="是否审核" width="120"> <el-table-column prop="auditStatus" align="center" label="是否审核" width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.auditStatus" @change="handleStatusChange(scope.row, 'auditStatus')"> <el-select v-model="scope.row.auditStatus" @change="handleStatusChange(scope.row, 'auditStatus')">
<el-option v-for="auditStatusItem in auditStatusDictDatas" :key="auditStatusItem.id" :label="auditStatusItem.label" :value="parseInt(auditStatusItem.value)"/> <el-option v-for="auditStatusItem in auditStatusDictDatas" :key="auditStatusItem.id" :label="auditStatusItem.label" :value="parseInt(auditStatusItem.value)" />
</el-select> </el-select>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="status" align="center" label="状态" width="120"> <el-table-column prop="status" align="center" label="状态" width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.status" @change="handleStatusChange(scope.row, 'status')"> <el-select v-model="scope.row.status" @change="handleStatusChange(scope.row, 'status')">
<el-option v-for="statusItem in statusDictDatas" :key="statusItem.id" :label="statusItem.value == CommonStatusEnum.ENABLE + '' ? '已上架' : '已下架'" :value="parseInt(statusItem.value)"/> <el-option v-for="statusItem in statusDictDatas" :key="statusItem.id" :label="statusItem.value == CommonStatusEnum.ENABLE + '' ? '已上架' : '已下架'" :value="parseInt(statusItem.value)" />
</el-select> </el-select>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button size="mini" type="text" @click="toPriceManager(scope.row)" <el-button size="mini" type="text" @click="toPriceManager(scope.row)" v-hasPermi="['ecw:product-price:query']">路线价格</el-button>
v-hasPermi="['ecw:product-price:query']">路线价格</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['ecw:product:update']">修改</el-button>
v-hasPermi="['ecw:product:update']">修改</el-button> <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['ecw:product:delete']">删除</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
v-hasPermi="['ecw:product:delete']">删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 分页组件 --> <!-- 分页组件 -->
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" @pagination="getList" />
@pagination="getList"/>
<!-- 对话框(添加 / 修改) --> <!-- 对话框(添加 / 修改) -->
<el-dialog :title="title" :visible.sync="open" width="550px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="550px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="110px"> <el-form ref="form" :model="form" :rules="rules" label-width="110px">
<el-form-item label="商品类型" prop="typeId"> <el-form-item label="商品类型" prop="typeId">
<el-select v-model="form.typeId" placeholder="选择商品类型" clearable> <el-select v-model="form.typeId" placeholder="选择商品类型" clearable>
<el-option v-for="type in typeList" :key="type.id" :label="type.titleZh" :value="type.id"/> <el-option v-for="type in typeList" :key="type.id" :label="type.titleZh" :value="type.id" />
</el-select> </el-select>
</el-form-item> </el-form-item>
...@@ -125,10 +124,10 @@ ...@@ -125,10 +124,10 @@
<el-form-item label="商品图片" prop="img"> <el-form-item label="商品图片" prop="img">
<el-col :span="8"> <el-col :span="8">
<el-input v-model="form.imgs" placeholder="请上传图片" disabled/> <el-input v-model="form.imgs" placeholder="请上传图片" disabled />
</el-col> </el-col>
<el-upload action="#" :http-request="requestUpload" :show-file-list="false" :before-upload="beforeUpload"> <el-upload action="#" :http-request="requestUpload" :show-file-list="false" :before-upload="beforeUpload">
<el-button size="small"> <el-button size="small">
上传图片 上传图片
<i class="el-icon-upload el-icon--right"></i> <i class="el-icon-upload el-icon--right"></i>
...@@ -147,30 +146,29 @@ ...@@ -147,30 +146,29 @@
<el-form-item label="商品特性" prop="attrArray"> <el-form-item label="商品特性" prop="attrArray">
<el-select v-model="form.attrArray" placeholder="选择商品特性" clearable multiple> <el-select v-model="form.attrArray" placeholder="选择商品特性" clearable multiple>
<el-option v-for="attr in attrList" :key="attr.id" :label="attr.attrName" :value="attr.id"/> <el-option v-for="attr in attrList" :key="attr.id" :label="attr.attrName" :value="attr.id" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="商品材质" prop="materialType"> <el-form-item label="商品材质" prop="materialType">
<el-select v-model="form.materialType" placeholder="选择商品材质" clearable> <el-select v-model="form.materialType" placeholder="选择商品材质" clearable>
<el-option v-for="materialItem in materialList" :key="materialItem.value" :label="materialItem.label" :value="materialItem.value"/> <el-option v-for="materialItem in materialList" :key="materialItem.value" :label="materialItem.label" :value="materialItem.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="出运要求" prop="requirements"> <el-form-item label="出运要求" prop="requirements">
<el-checkbox v-model="form.requirements" :checked="form.requirements===1? true:false" <el-checkbox v-model="form.requirements" :checked="form.requirements===1? true:false" :true-label="1" :false-label="0">证书要求(支持多证书)</el-checkbox>
:true-label="1" :false-label="0">证书要求(支持多证书)</el-checkbox>
</el-form-item> </el-form-item>
<el-form-item label="包装要求" prop="packaging"> <el-form-item label="包装要求" prop="packaging">
<el-select v-model="form.packaging" placeholder="选择包装要求" clearable> <el-select v-model="form.packaging" placeholder="选择包装要求" clearable>
<el-option v-for="packageItem in packagingList" :key="packageItem.value" :label="packageItem.label" :value="packageItem.value"/> <el-option v-for="packageItem in packagingList" :key="packageItem.value" :label="packageItem.label" :value="packageItem.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="默认货柜位置" prop="containerLocation"> <el-form-item label="默认货柜位置" prop="containerLocation">
<el-select v-model="form.containerLocation" placeholder="选择货柜位置" clearable> <el-select v-model="form.containerLocation" placeholder="选择货柜位置" clearable>
<el-option v-for="locationItem in locationList" :key="locationItem.value" :label="locationItem.label" :value="locationItem.value"/> <el-option v-for="locationItem in locationList" :key="locationItem.value" :label="locationItem.label" :value="locationItem.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
...@@ -190,7 +188,7 @@ ...@@ -190,7 +188,7 @@
<template slot="append">立方米</template> <template slot="append">立方米</template>
</el-input> </el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button> <el-button type="primary" @click="submitForm">确 定</el-button>
...@@ -214,16 +212,22 @@ export default { ...@@ -214,16 +212,22 @@ export default {
}, },
data() { data() {
return { return {
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
//特性列表 //特性列表
attrList:[], attrList: [],
//类型列表 //类型列表
typeList:[], typeList: [],
//材质列表 //材质列表
materialList:[], materialList: [],
//包装列表 //包装列表
packagingList:[], packagingList: [],
//货柜位置 //货柜位置
locationList:[], locationList: [],
// 遮罩层 // 遮罩层
loading: true, loading: true,
...@@ -259,11 +263,11 @@ export default { ...@@ -259,11 +263,11 @@ export default {
attrArray: [{ required: true, message: "商品特性不能为空", trigger: "change" }], attrArray: [{ required: true, message: "商品特性不能为空", trigger: "change" }],
titleZh: [{ required: true, message: "中文标题不能为空", trigger: "blur" }], titleZh: [{ required: true, message: "中文标题不能为空", trigger: "blur" }],
titleEn: [{ required: true, message: "英文标题不能为空", trigger: "blur" }], titleEn: [{ required: true, message: "英文标题不能为空", trigger: "blur" }],
materialType:[{ required: true, message: "商品材质不能为空", trigger: "blur" }], materialType: [{ required: true, message: "商品材质不能为空", trigger: "blur" }],
packaging:[{ required: true, message: "包装要求不能为空", trigger: "blur" }], packaging: [{ required: true, message: "包装要求不能为空", trigger: "blur" }],
containerLocation:[{ required: true, message: "默认货柜位置不能为空", trigger: "blur" }], containerLocation: [{ required: true, message: "默认货柜位置不能为空", trigger: "blur" }],
square:[{ required: true, message: "默认方数不能为空", trigger: "blur" }], square: [{ required: true, message: "默认方数不能为空", trigger: "blur" }],
needBook:[{ required: true, message: "预约入仓不能为空", trigger: "blur" }], needBook: [{ required: true, message: "预约入仓不能为空", trigger: "blur" }],
}, },
CommonStatusEnum: CommonStatusEnum, CommonStatusEnum: CommonStatusEnum,
...@@ -279,9 +283,9 @@ export default { ...@@ -279,9 +283,9 @@ export default {
computed: { computed: {
getTypeName() { getTypeName() {
return typeId => { return typeId => {
for(let index in this.typeList) { for (let index in this.typeList) {
let typeItem = this.typeList[index]; let typeItem = this.typeList[index];
if(typeItem.id == typeId) { if (typeItem.id == typeId) {
return typeItem.titleZh; return typeItem.titleZh;
} }
} }
...@@ -292,11 +296,11 @@ export default { ...@@ -292,11 +296,11 @@ export default {
return attrIds => { return attrIds => {
let productAttrArray = []; let productAttrArray = [];
let attrArray = attrIds.split(','); let attrArray = attrIds.split(',');
for(let attrIndex in attrArray) { for (let attrIndex in attrArray) {
let attrId = attrArray[attrIndex]; let attrId = attrArray[attrIndex];
for(let index in this.attrList) { for (let index in this.attrList) {
let attrItem = this.attrList[index]; let attrItem = this.attrList[index];
if(attrItem.id == attrId) { if (attrItem.id == attrId) {
productAttrArray.push(attrItem.attrName); productAttrArray.push(attrItem.attrName);
} }
} }
...@@ -309,7 +313,7 @@ export default { ...@@ -309,7 +313,7 @@ export default {
created() { created() {
let typeId = this.$route.query.typeId; let typeId = this.$route.query.typeId;
if(typeId) { if (typeId) {
this.queryParams.typeId = parseInt(typeId); this.queryParams.typeId = parseInt(typeId);
} }
this.getAttrList(); this.getAttrList();
...@@ -320,7 +324,7 @@ export default { ...@@ -320,7 +324,7 @@ export default {
/** 获取产品属性列表 */ /** 获取产品属性列表 */
getAttrList() { getAttrList() {
getProductAttrList().then(response => { getProductAttrList().then(response => {
this.attrList = response.data; this.attrList = response.data;
}) })
}, },
...@@ -336,7 +340,7 @@ export default { ...@@ -336,7 +340,7 @@ export default {
/* localStorage.setItem('product', JSON.stringify(row)); /* localStorage.setItem('product', JSON.stringify(row));
localStorage.setItem('typeList', JSON.stringify(this.typeList)); */ localStorage.setItem('typeList', JSON.stringify(this.typeList)); */
this.$router.push({ this.$router.push({
name:'ProductPrice', name: 'ProductPrice',
query: { query: {
product_id: row.id, product_id: row.id,
product_type: row.typeId product_type: row.typeId
...@@ -347,13 +351,13 @@ export default { ...@@ -347,13 +351,13 @@ export default {
handleStatusChange(row, statusType) { handleStatusChange(row, statusType) {
updateProduct(row).then(() => { updateProduct(row).then(() => {
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
}).catch(function() { }).catch(function () {
if(statusType == 'status') { if (statusType == 'status') {
row.status = row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE : CommonStatusEnum.ENABLE; row.status = row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE : CommonStatusEnum.ENABLE;
} else { } else {
row.auditStatus = row.auditStatus === AuditStatusEnum.PASS ? AuditStatusEnum.NOT_PASS : AuditStatusEnum.PASS; row.auditStatus = row.auditStatus === AuditStatusEnum.PASS ? AuditStatusEnum.NOT_PASS : AuditStatusEnum.PASS;
} }
}); });
}, },
...@@ -361,7 +365,7 @@ export default { ...@@ -361,7 +365,7 @@ export default {
getList() { getList() {
this.loading = true; this.loading = true;
// 处理查询参数 // 处理查询参数
let params = {...this.queryParams}; let params = { ...this.queryParams };
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime'); this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
// 执行查询 // 执行查询
getProductPage(params).then(response => { getProductPage(params).then(response => {
...@@ -386,7 +390,7 @@ export default { ...@@ -386,7 +390,7 @@ export default {
titleEn: undefined, titleEn: undefined,
auditStatus: undefined, auditStatus: undefined,
status: undefined, status: undefined,
requirements:0, requirements: 0,
}; };
this.resetForm("form"); this.resetForm("form");
}, },
...@@ -406,7 +410,7 @@ export default { ...@@ -406,7 +410,7 @@ export default {
this.reset(); this.reset();
this.open = true; this.open = true;
this.title = "添加商品"; this.title = "添加商品";
if(this.queryParams.typeId) { if (this.queryParams.typeId) {
this.form.typeId = this.queryParams.typeId; this.form.typeId = this.queryParams.typeId;
} }
}, },
...@@ -417,7 +421,7 @@ export default { ...@@ -417,7 +421,7 @@ export default {
getProduct(id).then(response => { getProduct(id).then(response => {
this.form = response.data; this.form = response.data;
let attrArray = this.form.attrId.split(','); let attrArray = this.form.attrId.split(',');
for(let index in attrArray) { for (let index in attrArray) {
let value = attrArray[index]; let value = attrArray[index];
attrArray[index] = parseInt(value); attrArray[index] = parseInt(value);
} }
...@@ -457,28 +461,28 @@ export default { ...@@ -457,28 +461,28 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const id = row.id; const id = row.id;
this.$modal.confirm('是否确认删除商品编号为"' + id + '"的数据项?').then(function() { this.$modal.confirm('是否确认删除商品编号为"' + id + '"的数据项?').then(function () {
return deleteProduct(id); return deleteProduct(id);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => { });
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
// 处理查询参数 // 处理查询参数
let params = {...this.queryParams}; let params = { ...this.queryParams };
params.pageNo = undefined; params.pageNo = undefined;
params.pageSize = undefined; params.pageSize = undefined;
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime'); this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
// 执行导出 // 执行导出
this.$modal.confirm('是否确认导出所有商品数据项?').then(() => { this.$modal.confirm('是否确认导出所有商品数据项?').then(() => {
this.exportLoading = true; this.exportLoading = true;
return exportProductExcel(params); return exportProductExcel(params);
}).then(response => { }).then(response => {
this.$download.excel(response, '${table.classComment}.xls'); this.$download.excel(response, '${table.classComment}.xls');
this.exportLoading = false; this.exportLoading = false;
}).catch(() => {}); }).catch(() => { });
}, },
// 覆盖默认的上传行为 // 覆盖默认的上传行为
...@@ -504,7 +508,7 @@ export default { ...@@ -504,7 +508,7 @@ export default {
var s = []; var s = [];
var hexDigits = "0123456789abcdef"; var hexDigits = "0123456789abcdef";
for (var i = 0; i < 36; i++) { for (var i = 0; i < 36; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1); s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
} }
s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010 s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01 s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
...@@ -513,6 +517,22 @@ export default { ...@@ -513,6 +517,22 @@ export default {
var uuid = s.join(""); var uuid = s.join("");
return uuid; return uuid;
}, },
// 表格多选
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length !== 1
this.multiple = !selection.length
},
// 批量设置商品属性
handleEdit() {
this.$router.push({
path: "product-attr/edit",
query: {
ids: this.ids
}
});
}
} }
}; };
</script> </script>
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
<div class="app-container"> <div class="app-container">
<el-form ref="form" :model="form" :rules="rules" label-width="120px"> <el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-form-item label="适用商品" prop="idList" v-if="form.type != 1"> <el-form-item label="适用商品" prop="idList">
<products-selector v-model="form.idList" /> <products-selector :defaultIds="form.idList" v-model="form.idList" />
</el-form-item> </el-form-item>
<el-form-item label="货柜位置" prop="containerLocation"> <el-form-item label="货柜位置" prop="containerLocation">
...@@ -36,10 +36,10 @@ ...@@ -36,10 +36,10 @@
<el-checkbox style="width: 100px" v-model="checked[6]">需要修改</el-checkbox> <el-checkbox style="width: 100px" v-model="checked[6]">需要修改</el-checkbox>
<dict-selector v-if="checked[6]" form-type="checkbox" :type="DICT_TYPE.ECW_ORDER_ATTR" v-model="form.attrId" multiple /> <dict-selector v-if="checked[6]" form-type="checkbox" :type="DICT_TYPE.ECW_ORDER_ATTR" v-model="form.attrId" multiple />
</el-form-item> </el-form-item>
<!-- <el-form-item label="商品材质" prop=""> <el-form-item label="商品材质" prop="materialType">
<el-checkbox style="width: 100px" v-model="checked[7]">需要修改</el-checkbox> <el-checkbox style="width: 100px" v-model="checked[7]">需要修改</el-checkbox>
<dict-selector v-if="checked[7]" form-type="checkbox" :type="DICT_TYPE.ECW_PRODUCT_MATERIAL" v-model="form.status" multiple /> <dict-selector v-if="checked[7]" form-type="checkbox" :type="DICT_TYPE.ECW_PRODUCT_MATERIAL" v-model="form.materialType" multiple />
</el-form-item> --> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="submitForm">确 定</el-button> <el-button type="primary" @click="submitForm">确 定</el-button>
...@@ -75,11 +75,12 @@ export default { ...@@ -75,11 +75,12 @@ export default {
"needBook": undefined, "needBook": undefined,
"packaging": undefined, "packaging": undefined,
"requirements": undefined, "requirements": undefined,
"square": undefined "square": undefined,
"materialType": undefined
}, },
// 表单校验 // 表单校验
rules: {}, rules: {},
checked: [false, false, false, false, false, false, false] checked: [false, false, false, false, false, false, false, false]
}; };
}, },
computed: { computed: {
...@@ -88,7 +89,7 @@ export default { ...@@ -88,7 +89,7 @@ export default {
watch: { watch: {
'form.idList'(val) { 'form.idList'(val) {
if (val.length > 0) { if (val.length > 0) {
this.form.isAllProduct = undefined this.form.isAllProduct = 0
} else { } else {
this.form.isAllProduct = 1 this.form.isAllProduct = 1
} }
...@@ -96,6 +97,7 @@ export default { ...@@ -96,6 +97,7 @@ export default {
}, },
created() { created() {
this.reset() this.reset()
this.form.idList = this.$route.query && this.$route.query.ids ? [...this.$route.query.ids].map(item => { return Number(item) }) : []
}, },
methods: { methods: {
/** 表单重置 */ /** 表单重置 */
...@@ -109,7 +111,8 @@ export default { ...@@ -109,7 +111,8 @@ export default {
"needBook": undefined, "needBook": undefined,
"packaging": undefined, "packaging": undefined,
"requirements": undefined, "requirements": undefined,
"square": undefined "square": undefined,
"materialType": undefined
}; };
this.resetForm("form"); this.resetForm("form");
}, },
...@@ -129,18 +132,4 @@ export default { ...@@ -129,18 +132,4 @@ export default {
}, },
}, },
}; };
</script> </script>
<style scoped lang="scss"> \ No newline at end of file
.fee-item {
padding: 5px 0;
> div {
margin-right: 5px;
}
}
.coupon-list {
max-height: 200px;
border: 1px solid #ccc;
padding: 10px;
overflow-y: auto;
}
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment