Commit 60e80f1c authored by zhanglw's avatar zhanglw

个人中心-产品管理

parent 9b052bdb
......@@ -164,6 +164,14 @@ export const constantRouterMap = [
},
hidden: true
},
{
path: '/console/product',
meta: { title: '个人中心-产品管理', noCache: true },
component: (resolve) => {
return require(['@/views/homepage/console/product'], resolve)
},
hidden: true
},
{
path: '/backstage',
component: Layout,
......
......@@ -4,7 +4,7 @@
<img src="@/assets/home_images/mark_sup.png">
<span>供应</span>
</div>
<div class="vertical-menu-label touch"><span :class="menuIndex==='1'?'active':''" @click="menuClick('/home')">产品管理</span></div>
<div class="vertical-menu-label touch"><span :class="menuIndex==='1'?'active':''" @click="menuClick('/console/product')">产品管理</span></div>
<div class="vertical-menu-label touch"><span :class="menuIndex==='2'?'active':''" @click="menuClick('/home')">被询价记录</span></div>
<el-divider />
<div class="vertical-menu-title">
......
<template>
<!-- 表单渲染 -->
<el-dialog append-to-body :close-on-click-modal="false" :before-close="cancelView" :visible="visible" :title="title" width="1080px">
<el-form ref="formViewRef" :model="formData" :rules="rules" :status-icon="true" label-width="240px">
<el-form-item label="产品名称:" class="form-cell" prop="productName">
<div class="cell-box">
<el-input v-model="formData.productName" placeholder="请输入产品名称" class="cell-input" />
</div>
</el-form-item>
<el-form-item label="产品分类:" class="form-cell" style="margin: 0">
<div class="cell-box" style="display: flex">
<el-form-item prop="productType">
<el-select v-model="formData.productType" placeholder="产品大类" @change="changeProductType">
<el-option v-for="item in dict.product_type" :key="item.id" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item prop="productSubType" style="margin-left: 5px">
<el-select v-model="formData.productSubType" placeholder="产品小类">
<el-option v-for="item in productSubTypeOpts" :key="item.id" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
</div>
</el-form-item>
<el-form-item v-if="formData.productType&&formData.productType<5" label="产品属性:" class="form-cell">
<div class="cell-box" style="max-width: 600px">
<el-row>
<el-col :span="5" class="grid-content">
<div class="grid-label">品牌</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeBrand" placeholder="品牌" />
</el-col>
<el-col :span="5" class="grid-content">
<div class="grid-label">消耗电流</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeConsumptionCurrent" placeholder="消耗电流" />
</el-col>
</el-row>
<el-row>
<el-col :span="5" class="grid-content">
<div class="grid-label">批号</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeBatchNumber" placeholder="批号" />
</el-col>
<el-col :span="5" class="grid-content">
<div class="grid-label">额定功率</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeRatedPower" placeholder="额定功率" />
</el-col>
</el-row>
<el-row>
<el-col :span="5" class="grid-content">
<div class="grid-label">型号</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeModel" placeholder="型号" />
</el-col>
<el-col :span="5" class="grid-content">
<div class="grid-label">反应时间</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeReactionTime" placeholder="反应时间" />
</el-col>
</el-row>
<el-row>
<el-col :span="5" class="grid-content">
<div class="grid-label">工作电压</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeWorkingVoltage" placeholder="工作电压" />
</el-col>
<el-col :span="5" class="grid-content">
<div class="grid-label">封装</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeEncapsulation" placeholder="封装" />
</el-col>
</el-row>
<el-row>
<el-col :span="5" class="grid-content">
<div class="grid-label">质量保证</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeQualityAssurance" placeholder="质量保证" />
</el-col>
<el-col :span="5" class="grid-content">
<div class="grid-label">产地</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeProducingArea" placeholder="产地" />
</el-col>
</el-row>
<el-row>
<el-col :span="5" class="grid-content">
<div class="grid-label">数量</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeNumber" placeholder="数量" />
</el-col>
<el-col :span="5" class="grid-content">
<div class="grid-label">颜色</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeColor" placeholder="颜色" />
</el-col>
</el-row>
<el-row>
<el-col :span="5" class="grid-content">
<div class="grid-label">适用场景</div>
</el-col>
<el-col :span="19" class="grid-content">
<el-input v-model="formData.attributeApplicableScenarios" placeholder="适用场景" />
</el-col>
</el-row>
</div>
</el-form-item>
<el-form-item label="产品价格区间(元):" class="form-cell" style="margin: 0">
<div class="cell-box" style="display: flex">
<el-form-item prop="minPrice">
<el-input v-model.number="formData.minPrice" placeholder="价格区间下限" class="cell-input" style="width: 220px" />
</el-form-item>
<div style="width: 20px;text-align: center">~</div>
<el-form-item prop="maxPrice">
<el-input v-model.number="formData.maxPrice" placeholder="价格区间上限" class="cell-input" style="width: 220px" />
</el-form-item>
</div>
</el-form-item>
<el-form-item label="产品特点:" class="form-cell" prop="productFeature">
<div class="cell-box">
<el-tag
v-for="tag in productFeature"
:key="tag"
closable
size="small"
:type="tagTypes[formData.productType||0]"
:disable-transitions="false"
@close="handleClose(tag)"
>
{{ tag }}
</el-tag>
<el-input
v-show="inputVisible"
ref="saveTagInput"
v-model="inputValue"
class="input-new-tag"
placeholder="请输入特点标签文本"
@keyup.enter.native="handleInputConfirm"
@blur="handleInputConfirm"
/>
<el-button v-show="!inputVisible && productFeature.length < 5" plain round :type="tagTypes[formData.productType||0]" class="button-new-tag" icon="el-icon-price-tag" @click="showInput">添加</el-button>
</div>
</el-form-item>
<el-form-item label="产品照片:" class="form-cell" prop="productPic">
<div class="cell-box">
<el-upload
ref="uploadCom"
action="/api/bsw/product/uploadProductPic"
name="productPic"
list-type="picture-card"
:headers="uploadHeaders"
:limit="5"
:on-exceed="handleExceed"
:on-success="handleImported"
:on-preview="handlePictureCardPreview"
:on-remove="handleRemove"
>
<i class="el-icon-plus" />
</el-upload>
<el-dialog append-to-body :visible.sync="dialogImageVisible">
<img width="100%" :src="dialogImageUrl">
</el-dialog>
</div>
</el-form-item>
<el-form-item label="产品概述:" class="form-cell" prop="productDescribe">
<div class="cell-box">
<div ref="editor" class="editor" />
</div>
</el-form-item>
<el-form-item label="其他说明:" class="form-cell" prop="notes">
<div class="cell-box">
<el-input v-model="formData.notes" type="textarea" placeholder="请输入文本内容" maxlength="1000" :autosize="{ minRows: 4, maxRows: 6}" show-word-limit resize="none" class="cell-input" />
</div>
</el-form-item>
<el-form-item label="交易保障承诺:" class="form-cell" prop="letterOfCommitment">
<div class="cell-box">
<el-checkbox v-model="formData.letterOfCommitment"><em>卖家承诺履约合规诈骗包赔,保障产品交易安全</em></el-checkbox>
</div>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer" style="text-align: center">
<el-button @click="cancelView">取消</el-button>
<el-button type="success" @click="submitForm()">保存</el-button>
<el-button type="primary" @click="submitForm()">提交</el-button>
</div>
</el-dialog>
</template>
<script>
import { getToken } from '@/utils/auth'
import { HttpReq } from '@/api/common'
import { mapGetters } from 'vuex'
import { upload } from '@/utils/upload'
import E from 'wangeditor'
export default {
dicts: ['product_rank', 'product_type', 'product_type_1', 'product_type_2', 'product_type_3', 'product_type_4', 'product_type_5', 'product_type_6', 'product_type_7'],
data() {
const checkPrice = (rule, value, callback) => {
if (!value) {
return callback()
}
if (!Number.isInteger(value)) {
return callback(new Error('请输入数字值'))
}
setTimeout(() => {
if (this.formData.minPrice && value < this.formData.minPrice) {
return callback(new Error('区间值错误'))
}
if (this.formData.maxPrice && value > this.formData.maxPrice) {
return callback(new Error('区间值错误'))
}
return callback()
}, 500)
}
return {
uploadHeaders: { 'Authorization': getToken() },
imgSrcStart: process.env.VUE_APP_BASE_API,
editor: false, // 富文本对象
dialogImageUrl: '',
dialogImageVisible: false,
visible: false,
tagTypes: ['', 'primary', 'success', 'warning', 'danger', 'info', 'info', 'info'],
title: '添加产品信息详情',
productSubTypeOpts: [],
inputVisible: false,
inputValue: '',
productFeature: [], // 产品特点tag列表
formData: {
productId: null,
customerId: null, // 供应商id
enterpriseName: '', // 供应商名称
productName: '', // 产品名称
productType: '1', // 产品大类
productSubType: null, // 产品小类
minPrice: null, // 价格区间-小
maxPrice: null, // 价格区间-大
productFeature: null, // 产品特点
productPic: '', // 产品图片
productDescribe: '', // 产品描述(富文本)
notes: null, // 其他说明
letterOfCommitment: false, // 交易保障承诺
attributeBrand: '', // 属性-品牌
attributeConsumptionCurrent: '', // 属性-消耗电流
attributeProductName: '', // 属性-产品名称
attributeRatedPower: '', // 属性-额定功率
attributeModel: '', // 属性-型号
attributeReactionTime: '', // 属性-反应时间
attributeWorkingVoltage: '', // 属性-工作电压
attributeEncapsulation: '', // 属性-封装
attributeQualityAssurance: '', // 属性-质量保证
attributeProducingArea: '', // 属性-产地
attributeNumber: '', // 属性-数量
attributeColor: '', // 属性-颜色
attributeApplicableScenarios: '', // 属性-品牌
attributeBatchNumber: '', // 属性-批号
rank: '1' // 产品品级
},
rules: {
// productName: { required: true, message: '请填写产品名称', trigger: 'blur' },
// productType: { required: true, message: '请选择产品分类', trigger: 'blur' },
// productPic: { required: true, message: '请上传产品图片', trigger: 'blur' },
// productDescribe: { required: true, message: '请填写产品概述', trigger: 'blur' },
// letterOfCommitment: { required: true, message: '请勾选交易保障承诺', trigger: 'blur' },
enterpriseName: { validator: this.checkEnterpriseName, trigger: 'blur' },
minPrice: [
// { required: true, message: '请填写产品价格区间下限', trigger: 'blur' },
{ validator: checkPrice, trigger: 'blur' }
],
maxPrice: [
// { required: true, message: '请填写产品价格区间上限', trigger: 'blur' },
{ validator: checkPrice, trigger: 'blur' }
]
}
}
},
computed: {
...mapGetters([
'imagesUploadApi',
'baseApi'
])
},
mounted() {
this.productSubTypeOpts = this.dict['product_type_1']
},
methods: {
checkEnterpriseName(rule, value, callback) {
this.$nextTick(_ => {
HttpReq.backstageApi.checkEnterpriseName({
name: value, id: this.formData.customerId
}).then((res) => {
if (res.data) {
callback()
} else {
callback(new Error(res.msg))
}
})
})
},
querySearch(queryString, cb) {
HttpReq.backstageApi.associateQueryEnterpriseName({
name: queryString
}).then((res) => {
cb(res.data)
})
},
handleSelect(item) {
this.formData.customerId = item.id
this.$refs.formViewRef.validateField('enterpriseName', valid => {
return valid
})
},
handleClose(tag) {
this.productFeature.splice(this.productFeature.indexOf(tag), 1)
this.formData.productFeature = this.productFeature.join(';')
},
showInput() {
this.inputVisible = true
this.$nextTick(_ => {
this.$refs.saveTagInput.$refs.input.focus()
})
},
handleInputConfirm() {
const inputValue = this.inputValue
if (inputValue && !this.productFeature.filter(item => { return item === inputValue }).length) {
this.productFeature.push(inputValue)
this.formData.productFeature = this.productFeature.join(';')
}
this.inputValue = ''
this.inputVisible = false
},
handleExceed() {
this.$message({
message: '超出最大上传数量限制',
type: 'info'
})
},
handleRemove(file, fileList) {
HttpReq.backstageApi.deleteProductPic({
productPic: file.response.productPic
}).then((res) => {
this.$notify({
title: res.msg,
type: 'success',
duration: 2500
})
const arr = []
fileList.forEach(item => {
arr.push(item.response.productPic)
})
this.formData.productPic = arr.join(';')
})
},
handlePictureCardPreview(file) {
this.dialogImageUrl = file.url
this.dialogImageVisible = true
},
handleImported(response, file, fileList) {
this.$nextTick(() => {
const arr = this.formData.productPic ? this.formData.productPic.split(';') : []
arr.push(response.productPic)
this.formData.productPic = arr.join(';')
this.$notify({
title: '上传成功!',
type: 'success',
duration: 2500
})
})
},
showView() {
this.visible = true
},
hideView() {
this.$refs.uploadCom.clearFiles()
this.$refs.formViewRef.resetFields()
this.editor.txt.clear()
this.productSubTypeOpts = this.dict['product_type_1']
this.productFeature = []
this.visible = false
},
cancelView() {
this.hideView()
},
submitForm() {
this.$refs.formViewRef.validate(valid => {
if (valid) {
HttpReq.backstageApi.addProduct(this.formData).then((res) => {
this.$notify({
title: res.msg,
type: 'success',
duration: 2500
})
if (res.code === 200) {
this.cancelView()
this.$parent.loadData()
}
})
} else {
this.$message({
message: '表单信息有误,请核对无误后提交!',
type: 'error'
})
}
})
},
changeProductType() {
this.formData.productSubType = null
this.productSubTypeOpts = this.dict['product_type_' + this.formData.productType]
},
loadData() {
this.showView()
if (this.editor) {
return
}
this.$nextTick(() => {
const _this = this
const editor = new E(this.$refs.editor)
editor.config.zIndex = 5
editor.config.customUploadImg = function(files, insert) {
files.forEach(image => {
upload(_this.imagesUploadApi, image).then(res => {
const data = res.data
const url = _this.baseApi + '/file/' + data.type + '/' + data.realName
insert(url)
})
})
}
editor.config.onchange = (html) => {
this.formData.productDescribe = html
}
editor.create()
// 初始化数据
editor.txt.html(this.formData.productDescribe)
this.editor = editor
})
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.grid-content {
border: 1px solid rgba(100, 100, 100, 0.3);
padding: 0;
}
.grid-label {
background: #dedede;
padding: 0 10px;
}
.editor{
text-align:left;
width: 680px;
}
::v-deep .w-e-text-container {
height: 560px !important;
}
.cell-box {
min-width: 120px;
.cell-input {
width: 680px;
}
.cell-select {
width: 300px;
}
.el-tag + .el-tag {
margin-left: 10px;
}
.button-new-tag {
margin-left: 10px;
height: 28px;
line-height: 24px;
padding: 0 8px;
}
.input-new-tag {
width: 140px;
height: 28px;
margin-left: 10px;
vertical-align: bottom;
}
>>>.el-input__inner {
border: 1px solid rgba(100, 100, 100, 0.1);
border-bottom: 1px solid rgba(100, 100, 100, 0.2);
border-radius: 5px;
}
>>>.el-input.is-disabled .el-input__inner {
border-radius: 0;
border: 0;
border-bottom: 1px solid rgba(100, 100, 100, 0.4);
background: white;
cursor: text;
}
>>>.el-input.is-disabled .el-input__icon {
cursor: text;
}
>>>.el-icon-circle-check {
color: #13ce66;
}
//>>>.el-icon-arrow-up:before {
// content: '';
//}
}
</style>
<template>
<!-- 表单渲染 -->
<el-dialog append-to-body :close-on-click-modal="false" :before-close="cancelView" :visible="visible" :title="title" width="1080px">
<el-form ref="formViewRef" :model="formData" :rules="rules" :status-icon="true" label-width="240px">
<el-form-item label="产品名称:" class="form-cell" prop="productName">
<div class="cell-box">
<el-input v-model="formData.productName" placeholder="请输入产品名称" class="cell-input" />
</div>
</el-form-item>
<el-form-item label="产品分类:" class="form-cell" style="margin: 0">
<div class="cell-box" style="display: flex">
<el-form-item prop="productType">
<el-select v-model="formData.productType" placeholder="产品大类" @change="changeProductType">
<el-option v-for="item in dict.product_type" :key="item.id" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item prop="productSubType" style="margin-left: 5px">
<el-select v-model="formData.productSubType" placeholder="产品小类">
<el-option v-for="item in productSubTypeOpts" :key="item.id" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
</div>
</el-form-item>
<el-form-item v-if="formData.productType&&formData.productType<5" label="产品属性:" class="form-cell">
<div class="cell-box" style="max-width: 600px">
<el-row>
<el-col :span="5" class="grid-content">
<div class="grid-label">品牌</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeBrand" placeholder="品牌" />
</el-col>
<el-col :span="5" class="grid-content">
<div class="grid-label">消耗电流</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeConsumptionCurrent" placeholder="消耗电流" />
</el-col>
</el-row>
<el-row>
<el-col :span="5" class="grid-content">
<div class="grid-label">批号</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeBatchNumber" placeholder="批号" />
</el-col>
<el-col :span="5" class="grid-content">
<div class="grid-label">额定功率</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeRatedPower" placeholder="额定功率" />
</el-col>
</el-row>
<el-row>
<el-col :span="5" class="grid-content">
<div class="grid-label">型号</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeModel" placeholder="型号" />
</el-col>
<el-col :span="5" class="grid-content">
<div class="grid-label">反应时间</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeReactionTime" placeholder="反应时间" />
</el-col>
</el-row>
<el-row>
<el-col :span="5" class="grid-content">
<div class="grid-label">工作电压</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeWorkingVoltage" placeholder="工作电压" />
</el-col>
<el-col :span="5" class="grid-content">
<div class="grid-label">封装</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeEncapsulation" placeholder="封装" />
</el-col>
</el-row>
<el-row>
<el-col :span="5" class="grid-content">
<div class="grid-label">质量保证</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeQualityAssurance" placeholder="质量保证" />
</el-col>
<el-col :span="5" class="grid-content">
<div class="grid-label">产地</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeProducingArea" placeholder="产地" />
</el-col>
</el-row>
<el-row>
<el-col :span="5" class="grid-content">
<div class="grid-label">数量</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeNumber" placeholder="数量" />
</el-col>
<el-col :span="5" class="grid-content">
<div class="grid-label">颜色</div>
</el-col>
<el-col :span="7" class="grid-content">
<el-input v-model="formData.attributeColor" placeholder="颜色" />
</el-col>
</el-row>
<el-row>
<el-col :span="5" class="grid-content">
<div class="grid-label">适用场景</div>
</el-col>
<el-col :span="19" class="grid-content">
<el-input v-model="formData.attributeApplicableScenarios" placeholder="适用场景" />
</el-col>
</el-row>
</div>
</el-form-item>
<el-form-item label="产品价格区间(元):" class="form-cell" style="margin: 0">
<div class="cell-box" style="display: flex">
<el-form-item prop="minPrice">
<el-input v-model.number="formData.minPrice" placeholder="价格区间下限" class="cell-input" style="width: 220px" />
</el-form-item>
<div style="width: 20px;text-align: center">~</div>
<el-form-item prop="maxPrice">
<el-input v-model.number="formData.maxPrice" placeholder="价格区间上限" class="cell-input" style="width: 220px" />
</el-form-item>
</div>
</el-form-item>
<el-form-item label="产品特点:" class="form-cell" prop="productFeature">
<div class="cell-box">
<el-tag
v-for="tag in productFeature"
:key="tag"
closable
size="small"
:type="tagTypes[formData.productType||0]"
:disable-transitions="false"
@close="handleClose(tag)"
>
{{ tag }}
</el-tag>
<el-input
v-show="inputVisible"
ref="saveTagInput"
v-model="inputValue"
class="input-new-tag"
placeholder="请输入特点标签文本"
@keyup.enter.native="handleInputConfirm"
@blur="handleInputConfirm"
/>
<el-button v-show="!inputVisible && productFeature.length < 5" plain round :type="tagTypes[formData.productType||0]" class="button-new-tag" icon="el-icon-price-tag" @click="showInput">添加</el-button>
</div>
</el-form-item>
<el-form-item label="产品照片:" class="form-cell" prop="productPic">
<div class="cell-box">
<ul class="el-upload-list el-upload-list--picture-card" style="float: left">
<li v-for="(item, index) in imgList" :key="index" tabindex="0" class="el-upload-list__item is-success">
<img :src="imgSrcStart+'/productPic/'+item" class="el-upload-list__item-thumbnail">
<label class="el-upload-list__item-status-label"><i class="el-icon-upload-success el-icon-check" /></label>
<span class="el-upload-list__item-actions">
<span class="el-upload-list__item-preview" @click="dialogImgUrl=item;dialogImgVisible=true"><i class="el-icon-zoom-in" /></span>
<span class="el-upload-list__item-delete" @click="handleRemoveImg(item)"><i class="el-icon-delete" /></span>
</span>
</li>
</ul>
<el-dialog append-to-body :visible.sync="dialogImgVisible">
<img width="100%" :src="imgSrcStart+'/productPic/'+dialogImgUrl">
</el-dialog>
<el-upload
ref="uploadCom"
action="/api/bsw/product/uploadProductPic"
name="productPic"
list-type="picture-card"
:headers="uploadHeaders"
:limit="5"
:on-exceed="handleExceed"
:on-success="handleImported"
:on-preview="handlePictureCardPreview"
:on-remove="handleRemove"
>
<i class="el-icon-plus" />
</el-upload>
<el-dialog append-to-body :visible.sync="dialogImageVisible">
<img width="100%" :src="dialogImageUrl">
</el-dialog>
</div>
<div style="display: block;clear: both">{{ formData.productPic }}</div>
</el-form-item>
<el-form-item label="产品概述:" class="form-cell" prop="productDescribe">
<div class="cell-box">
<div ref="editor" class="editor" />
</div>
</el-form-item>
<el-form-item label="其他说明:" class="form-cell" prop="notes">
<div class="cell-box">
<el-input v-model="formData.notes" type="textarea" placeholder="请输入文本内容" maxlength="1000" :autosize="{ minRows: 4, maxRows: 6}" show-word-limit resize="none" class="cell-input" />
</div>
</el-form-item>
<el-form-item label="交易保障承诺:" class="form-cell" prop="letterOfCommitment">
<div class="cell-box">
<el-checkbox v-model="formData.letterOfCommitment"><em>卖家承诺履约合规诈骗包赔,保障产品交易安全</em></el-checkbox>
</div>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer" style="text-align: center">
<el-button @click="cancelView">取消</el-button>
<el-button type="primary" @click="submitForm()">提交</el-button>
</div>
</el-dialog>
</template>
<script>
import { getToken } from '@/utils/auth'
import { HttpReq } from '@/api/common'
import { mapGetters } from 'vuex'
import { upload } from '@/utils/upload'
import E from 'wangeditor'
export default {
dicts: ['product_rank', 'product_type', 'product_type_1', 'product_type_2', 'product_type_3', 'product_type_4', 'product_type_5', 'product_type_6', 'product_type_7'],
data() {
const checkPrice = (rule, value, callback) => {
if (!value) {
return callback()
}
if (!Number.isInteger(value)) {
return callback(new Error('请输入数字值'))
}
setTimeout(() => {
if (this.formData.minPrice && value < this.formData.minPrice) {
return callback(new Error('区间值错误'))
}
if (this.formData.maxPrice && value > this.formData.maxPrice) {
return callback(new Error('区间值错误'))
}
return callback()
}, 500)
}
return {
uploadHeaders: { 'Authorization': getToken() },
imgSrcStart: process.env.VUE_APP_BASE_API,
editor: false, // 富文本对象
dialogImageUrl: '',
dialogImageVisible: false,
imgList: [],
dialogImgUrl: '',
dialogImgVisible: false,
visible: false,
tagTypes: ['', 'primary', 'success', 'warning', 'danger', 'info', 'info', 'info'],
title: '编辑产品信息详情',
productSubTypeOpts: [],
inputVisible: false,
inputValue: '',
productFeature: [], // 产品特点tag列表
formData: {
productId: null,
customerId: null, // 供应商id
enterpriseName: '', // 供应商名称
productName: '', // 产品名称
productType: '1', // 产品大类
productSubType: null, // 产品小类
minPrice: null, // 价格区间-小
maxPrice: null, // 价格区间-大
productFeature: null, // 产品特点
productPic: '', // 产品图片
productDescribe: '', // 产品描述(富文本)
notes: null, // 其他说明
letterOfCommitment: false, // 交易保障承诺
attributeBrand: '', // 属性-品牌
attributeConsumptionCurrent: '', // 属性-消耗电流
attributeProductName: '', // 属性-产品名称
attributeRatedPower: '', // 属性-额定功率
attributeModel: '', // 属性-型号
attributeReactionTime: '', // 属性-反应时间
attributeWorkingVoltage: '', // 属性-工作电压
attributeEncapsulation: '', // 属性-封装
attributeQualityAssurance: '', // 属性-质量保证
attributeProducingArea: '', // 属性-产地
attributeNumber: '', // 属性-数量
attributeColor: '', // 属性-颜色
attributeApplicableScenarios: '', // 属性-品牌
attributeBatchNumber: '', // 属性-批号
rank: '1' // 产品品级
},
rules: {
// productName: { required: true, message: '请填写产品名称', trigger: 'blur' },
// productType: { required: true, message: '请选择产品分类', trigger: 'blur' },
// productPic: { required: true, message: '请上传产品图片', trigger: 'blur' },
// productDescribe: { required: true, message: '请填写产品概述', trigger: 'blur' },
// letterOfCommitment: { required: true, message: '请勾选交易保障承诺', trigger: 'blur' },
enterpriseName: { validator: this.checkEnterpriseName, trigger: 'blur' },
minPrice: [
// { required: true, message: '请填写产品价格区间下限', trigger: 'blur' },
{ validator: checkPrice, trigger: 'blur' }
],
maxPrice: [
// { required: true, message: '请填写产品价格区间上限', trigger: 'blur' },
{ validator: checkPrice, trigger: 'blur' }
]
}
}
},
computed: {
...mapGetters([
'imagesUploadApi',
'baseApi'
])
},
mounted() {
this.productSubTypeOpts = this.dict['product_type_1']
},
methods: {
checkEnterpriseName(rule, value, callback) {
this.$nextTick(_ => {
HttpReq.backstageApi.checkEnterpriseName({
name: value, id: this.formData.customerId
}).then((res) => {
if (res.data) {
callback()
} else {
callback(new Error(res.msg))
}
})
})
},
querySearch(queryString, cb) {
HttpReq.backstageApi.associateQueryEnterpriseName({
name: queryString
}).then((res) => {
cb(res.data)
})
},
handleSelect(item) {
this.formData.customerId = item.id
this.$refs.formViewRef.validateField('enterpriseName', valid => {
return valid
})
},
handleClose(tag) {
this.productFeature.splice(this.productFeature.indexOf(tag), 1)
this.formData.productFeature = this.productFeature.join(';')
},
showInput() {
this.inputVisible = true
this.$nextTick(_ => {
this.$refs.saveTagInput.$refs.input.focus()
})
},
handleInputConfirm() {
const inputValue = this.inputValue
if (inputValue && !this.productFeature.filter(item => { return item === inputValue }).length) {
this.productFeature.push(inputValue)
this.formData.productFeature = this.productFeature.join(';')
}
this.inputValue = ''
this.inputVisible = false
},
handleExceed() {
this.$message({
message: '超出最大上传数量限制',
type: 'info'
})
},
handleRemoveImg(item) {
this.imgList.splice(this.imgList.indexOf(item), 1)
const arr = this.formData.productPic.split(';')
arr.splice(arr.indexOf(item), 1)
this.formData.productPic = arr.join(';')
},
handleRemove(file, fileList) {
HttpReq.backstageApi.deleteProductPic({
productPic: file.response.productPic
}).then((res) => {
this.$notify({
title: res.msg,
type: 'success',
duration: 2500
})
const arr = []
fileList.forEach(item => {
arr.push(item.response.productPic)
})
this.formData.productPic = arr.join(';')
})
},
handlePictureCardPreview(file) {
this.dialogImageUrl = file.url
this.dialogImageVisible = true
},
handleImported(response, file, fileList) {
this.$nextTick(() => {
const arr = this.formData.productPic ? this.formData.productPic.split(';') : []
arr.push(response.productPic)
this.formData.productPic = arr.join(';')
this.$notify({
title: '上传成功!',
type: 'success',
duration: 2500
})
})
},
showView() {
this.visible = true
},
hideView() {
this.$refs.uploadCom.clearFiles()
this.$refs.formViewRef.resetFields()
this.editor.txt.clear()
this.productSubTypeOpts = this.dict['product_type_1']
this.productFeature = []
this.visible = false
},
cancelView() {
this.hideView()
},
submitForm() {
this.$refs.formViewRef.validate(valid => {
if (valid) {
HttpReq.backstageApi.updateProductDetail(this.formData).then((res) => {
this.$notify({
title: res.msg,
type: 'success',
duration: 2500
})
if (res.code === 200) {
this.cancelView()
this.$parent.loadData()
}
})
} else {
this.$message({
message: '表单信息有误,请核对无误后提交!',
type: 'error'
})
}
})
},
changeProductType() {
this.formData.productSubType = null
this.productSubTypeOpts = this.dict['product_type_' + this.formData.productType]
},
loadData(productId) {
this.showView()
this.$nextTick(() => {
if (!this.editor) {
const _this = this
const editor = new E(this.$refs.editor)
editor.config.zIndex = 5
editor.config.customUploadImg = function(files, insert) {
files.forEach(image => {
upload(_this.imagesUploadApi, image).then(res => {
const data = res.data
const url = _this.baseApi + '/file/' + data.type + '/' + data.realName
insert(url)
})
})
}
editor.config.onchange = (html) => {
this.formData.productDescribe = html
}
editor.create()
this.editor = editor
}
// 初始化数据
HttpReq.backstageApi.queryProductDetail({ productId }).then((res) => {
if (res.code === 200) {
this.formData = Object.assign(this.formData, res.data)
if (this.formData.productPic) {
this.imgList = this.formData.productPic.split(';')
}
if (this.formData.productType) {
this.productSubTypeOpts = this.dict['product_type_' + this.formData.productType]
}
if (this.formData.productFeature) {
this.productFeature = this.formData.productFeature.split(';')
}
this.editor.txt.html(this.formData.productDescribe)
} else {
this.$message({
message: res.msg,
type: 'error'
})
}
})
})
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.grid-content {
border: 1px solid rgba(100, 100, 100, 0.3);
padding: 0;
}
.grid-label {
background: #dedede;
padding: 0 10px;
}
.editor{
text-align:left;
width: 680px;
}
::v-deep .w-e-text-container {
height: 560px !important;
}
.cell-box {
min-width: 120px;
.cell-input {
width: 680px;
}
.cell-select {
width: 300px;
}
.el-tag + .el-tag {
margin-left: 10px;
}
.button-new-tag {
margin-left: 10px;
height: 28px;
line-height: 24px;
padding: 0 8px;
}
.input-new-tag {
width: 140px;
height: 28px;
margin-left: 10px;
vertical-align: bottom;
}
>>>.el-input__inner {
border: 1px solid rgba(100, 100, 100, 0.1);
border-bottom: 1px solid rgba(100, 100, 100, 0.2);
border-radius: 5px;
}
>>>.el-input.is-disabled .el-input__inner {
border-radius: 0;
border: 0;
border-bottom: 1px solid rgba(100, 100, 100, 0.4);
background: white;
cursor: text;
}
>>>.el-input.is-disabled .el-input__icon {
cursor: text;
}
>>>.el-icon-circle-check {
color: #13ce66;
}
//>>>.el-icon-arrow-up:before {
// content: '';
//}
}
</style>
......@@ -34,10 +34,10 @@
</el-row>
</div>
</div>
<updatePass ref="pass" />
<home-footer ref="homeFooter" />
<inquiry-view ref="inquiryView" />
<el-backtop />
<updatePass ref="pass" />
<myUpload
v-model="uploadVisible"
:headers="headers"
......@@ -63,7 +63,6 @@ import { getToken } from '@/utils/auth'
export default {
components: { titleMenus, userLogin, languageSetting, homeFooter, inquiryView, userMenus, myUpload, updatePass },
dicts: [],
data() {
return {
Avatar: Avatar,
......@@ -98,32 +97,11 @@ export default {
})
},
methods: {
onDictReady(dict) {},
// 点击询价
inquiry(item, type) {
console.log(item, type)
this.$refs.inquiryView.initView(item.id, type)
},
uploadAvatar() {
this.uploadVisible = !this.uploadVisible
},
cropUploadSuccess() {
location.reload()
},
// 跳转到详情
goToDetails(item, type) {
console.log(item, type)
},
pageChange(e) {
this.page = e
this.loadData()
},
loadData() {
},
goTop() {
document.body.scrollTop = 0
document.documentElement.scrollTop = 0
}
}
}
......@@ -139,54 +117,12 @@ export default {
display: inline-block;
}
.ellipsis {
// 多行溢出省略号
display: -webkit-box;
-webkit-box-orient: vertical;
overflow: hidden;
-webkit-line-clamp: 2;
text-overflow: ellipsis;
}
.pagination {
margin-top: 23px;
text-align: center;
padding: 10px;
display: flex;
justify-content: center;
align-items: center;
>>>.el-pagination.is-background .el-pager li {
font-style: normal;
font-weight: 400;
font-size: 14px;
text-align: center;
background-color: #fff;
color: #000000;
border: 1px solid #e5e5ea;
}
/* 激活后的样式 */
>>>.el-pagination.is-background .el-pager li:not(.disabled).active {
background-color: #ffffff;
color: #0366ed;
border: 1px solid #0366ed;
text-align: center;
}
/* 修改左右箭头样式 */
>>>.el-pagination .btn-next .el-icon, >>>.el-pagination .btn-prev .el-icon {
font-style: normal;
font-weight: 400;
font-size: 14px;
text-align: center;
background-color: #fff;
color: #e5e5ea;
border: 1px solid #e5e5ea;
}
>>>.el-pager {
height: 35.5px !important;
}
>>>.number, >>>.el-icon {
height: 35.5px !important;
line-height: 35.5px !important;
}
}
.head-box {
width: 100vw;
top: 0;
......@@ -216,81 +152,6 @@ export default {
font-weight: bold;
color: #333333;
}
.box-card {
display: inline-block;
position: relative;
margin: 12px;
padding: 10px 0;
width: 350px;
background: #FFFFFF;
border: 1px solid rgba(0,0,0,0.12);
box-shadow: 1px 2px 8px 0 rgba(0,0,0,0.12);
border-radius: 10px;
.line-text {
width: 100%;
text-align: center;
padding: 5px;
font-size: 18px;
font-weight: bolder;
opacity: 0.85;
}
.line-text:hover {
opacity: 1;
}
.float-title {
width: 344px;
position: absolute;
padding: 5px;
top: 200px;
left: 2px;
text-align: center;
font-weight: 600;
color: #fff;
background: rgba(0,0,0,0.6);
opacity: 0.9;
}
.float-title:hover {
opacity: 1;
}
.title {
width: 305px;
padding: 2px 20px;
font-size: 18px;
color: #333333;
overflow:hidden;
white-space: nowrap;
text-overflow: ellipsis;
-o-text-overflow:ellipsis;
}
.title:hover {
font-weight: 600;
}
.subTitle {
width: 260px;
padding: 2px 20px;
font-size: 15px;
color: #1961C5;
overflow:hidden;
white-space: nowrap;
text-overflow: ellipsis;
-o-text-overflow:ellipsis;
}
.area {
padding: 2px 0;
font-size: 17px;
color: #666666;
}
.date {
padding: 2px 10px;
font-size: 17px;
color: #999999;
}
.stamp {
border-style: none;
position: absolute;
z-index: 99;
}
}
}
.line-btn {
display: flex;
......
<template>
<div class="page-body">
<div class="head-box">
<div class="head-box-top">
<div class="top-call" />
<div class="top-call"><img src="@/assets/home_images/gemho_logo_b.png"></div>
<div class="top-call"><title-menus ref="titleMenus" menu-index="99" style="padding-top: 15px" /></div>
<div class="top-call"><user-login ref="userLogin" /></div>
<div class="top-call"><language-setting ref="languageSetting" /></div>
</div>
</div>
<div class="content-box">
<div style="width: 88%;padding-left: 9%;">
<el-row :gutter="20" style="padding-top: 10px">
<el-col :span="3">
<user-menus menu-index="1" />
</el-col>
<el-col :span="21" style="padding: 0 20px">
<!--工具栏-->
<div class="head-container">
<el-input v-model="query.productId" clearable placeholder="请输入产品ID" style="width:150px;" />
<el-input v-model="query.productName" clearable placeholder="请输入产品名称" style="width:280px;" />
<el-select v-model="query.productType" clearable placeholder="请选择分类" style="width: 150px">
<el-option v-for="item in dict.product_type" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
<el-select v-model="query.status" clearable placeholder="请选择状态" style="width: 150px">
<el-option v-for="item in dict.product_status" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
<date-range-picker v-model="query.updateTime" start-placeholder="最后维护开始日期" style="width: 320px" />
<el-button type="primary" icon="el-icon-search" style="opacity: 0.9" @click="toSearch">查询</el-button>
<el-button icon="el-icon-refresh" @click="clearLimit">重置</el-button>
</div>
<div class="toolbar">
<div>
<el-button type="primary" icon="el-icon-circle-plus-outline" style="opacity: 0.9" @click="toAdd">新增产品</el-button>
</div>
<div style="text-align: right">
<el-button icon="el-icon-finished" type="primary" plain :disabled="!multipleSelection.length" @click="batchOperate(1, null)">批量发布</el-button>
<el-button icon="el-icon-download" type="primary" plain :disabled="!multipleSelection.length" @click="batchOperate(0, null)">批量下架</el-button>
</div>
</div>
<!-- 表格 -->
<div class="content">
<el-table id="dataTable" ref="dataTable" v-loading="loading" :data="tableData" border height="58vh" :header-cell-style="{background:'#F8F8F8',color:'#333'}" tooltip-effect="dark" @selection-change="handleSelectionChange">
<el-table-column type="selection" align="center" width="55" />
<el-table-column label="产品预览图" align="center" width="100">
<template slot-scope="scope">
<el-image
:src="scope.row.imgSrc?imgSrcStart+'/img'+scope.row.imgSrc:defaultImgProduct"
:preview-src-list="scope.row.imgSrcList?scope.row.imgSrcList:[defaultImgProduct]"
style="width:64px;height: 64px;border: 1px solid rgba(0, 0, 0, 0.2);"
>
<div slot="placeholder" class="image-slot">加载中<span class="dot">...</span></div>
</el-image>
</template>
</el-table-column>
<el-table-column prop="productId" label="产品ID" align="center" width="100" />
<el-table-column prop="productType" label="产品分类" align="center" width="140" :formatter="(row, col, val)=>{return dict.label.product_type[val]}" />
<el-table-column prop="productName" label="产品名称" align="center" />
<el-table-column label="状态" align="center" width="100">
<template slot-scope="scope">
<div :style="'color:'+textColors[scope.row.status]">{{ dict.label.product_status[scope.row.status] }}</div>
</template>
</el-table-column>
<el-table-column prop="updateTime" label="最后维护日期" align="center" width="180" />
<el-table-column label="操作" align="center" width="200">
<template slot-scope="scope">
<div v-if="scope.row.status==='4'" class="table-btn touch" type="text" style="color:#32cd32" @click="batchOperate(1, scope.row)">上架</div>
<div v-if="scope.row.status==='5'" class="table-btn touch" type="text" style="color:#999" @click="batchOperate(0, scope.row)">下架</div>
<div v-if="scope.row.status==='2'" class="table-btn touch" type="text" style="color:#f00" @click="toView(scope.row)">查看原因</div>
<div class="table-btn touch" type="text" @click="toEdit(scope.row)">编辑</div>
</template>
</el-table-column>
</el-table>
<!--分页组件-->
<el-pagination :total="total" :current-page="page" :page-size="pageSize" style="margin-top: 8px;" layout="total, prev, pager, next, sizes" @size-change="sizeChange" @current-change="pageChange" />
</div>
</el-col>
</el-row>
</div>
</div>
<home-footer ref="homeFooter" />
<inquiry-view ref="inquiryView" />
<el-backtop />
<add-page ref="addPage" />
<edit-page ref="editPage" />
<view-page ref="viewPage" />
</div>
</template>
<script>
import default_product from '@/assets/home_images/default_product.png'
import titleMenus from '../components/titleMenusV2'
import userLogin from '../components/userLoginV2'
import languageSetting from '../components/languageSettingV2'
import homeFooter from '../components/homeFooter'
import inquiryView from '../components/inquiryView'
import userMenus from '../components/userMenus'
import DateRangePicker from '@/components/DateRangePicker'
import { HttpReq } from '@/api/common'
import addPage from './add'
import editPage from './edit'
import viewPage from './view'
export default {
components: { titleMenus, userLogin, languageSetting, homeFooter, inquiryView, userMenus, DateRangePicker, addPage, editPage, viewPage },
dicts: ['product_type', 'product_status'],
data() {
return {
defaultImgProduct: default_product,
imgSrcStart: process.env.VUE_APP_BASE_API,
textColors: ['#ccc', '#00008b', '#f00', '#F98052',
'#000', '#32cd32', '#bba'],
loading: false,
page: 1,
pageSize: 20,
total: 0,
query: {},
tableData: [],
multipleSelection: [],
throttle: null, // 节流器
throttleTime: 300
}
},
mounted() {
this.$nextTick(() => {
this.loadData()
})
},
methods: {
indexMethod(index) {
return 1 + index + this.page * this.pageSize - this.pageSize
},
handleSelectionChange(val) {
this.multipleSelection = val
},
loadData() {
// 清除参数无值的情况
Object.keys(this.query).length !== 0 && Object.keys(this.query).forEach(item => {
if (this.query[item] === null || this.query[item] === '') this.query[item] = undefined
})
HttpReq.backstageApi.queryProduct({
page: this.page - 1,
pageSize: this.pageSize,
...this.query
}).then((res) => {
this.tableData = res.data.data
this.total = res.data.total
})
},
batchOperate(type, row) {
if (!row && !this.multipleSelection.length) {
return this.$message({
message: '未选取数据',
type: 'info'
})
}
HttpReq.backstageApi.batchReleaseAndRecovery({
ids: row ? [row.productId] : this.multipleSelection.map(item => { return item.productId }),
type: type
}).then((res) => {
this.$notify({
title: res.msg,
type: res.code === 200 ? 'success' : 'error',
duration: 2500
})
this.loadData()
})
},
toAdd() {
this.$refs.addPage.loadData()
},
toEdit(item) {
this.$refs.editPage.loadData(item.productId)
},
toView(item) {
this.$refs.viewPage.loadData(item.productId)
},
toSearch() {
this.page = 1
this.loadData()
},
clearLimit() {
this.query = {}
this.loadData()
},
pageChange(e) {
this.page = e
this.loadData()
},
sizeChange(e) {
this.page = 1
this.pageSize = e
this.loadData()
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.touch {
cursor:pointer;
}
.clear {
clear: both
}
.inline-block {
display: inline-block;
}
.ellipsis {
// 多行溢出省略号
display: -webkit-box;
-webkit-box-orient: vertical;
overflow: hidden;
-webkit-line-clamp: 2;
text-overflow: ellipsis;
}
.pagination {
margin-top: 23px;
text-align: center;
padding: 10px;
display: flex;
justify-content: center;
align-items: center;
>>>.el-pagination.is-background .el-pager li {
font-style: normal;
font-weight: 400;
font-size: 14px;
text-align: center;
background-color: #fff;
color: #000000;
border: 1px solid #e5e5ea;
}
/* 激活后的样式 */
>>>.el-pagination.is-background .el-pager li:not(.disabled).active {
background-color: #ffffff;
color: #0366ed;
border: 1px solid #0366ed;
text-align: center;
}
/* 修改左右箭头样式 */
>>>.el-pagination .btn-next .el-icon, >>>.el-pagination .btn-prev .el-icon {
font-style: normal;
font-weight: 400;
font-size: 14px;
text-align: center;
background-color: #fff;
color: #e5e5ea;
border: 1px solid #e5e5ea;
}
>>>.el-pager {
height: 35.5px !important;
}
>>>.number, >>>.el-icon {
height: 35.5px !important;
line-height: 35.5px !important;
}
}
.head-box {
width: 100vw;
top: 0;
position: fixed;
background: none repeat scroll 0 0 white;
z-index: 999;
box-shadow: 0px 3px 7px 0px rgba(0,0,0,0.2);
.head-box-top {
display: flex;
justify-content: space-evenly;
align-items: center;
.top-call {
height: 80px;
padding-top: 15px;
}
}
}
.content-box {
min-height: 70vh;
margin-top: 94px;
font-family: Source Han Sans CN;
user-select: none;
>>>.el-table--mini {
font-size: 14px;
}
>>>.el-button--mini {
font-size: 14px;
}
}
.toolbar {
display: flex;
justify-content: space-between;
}
.content {
margin-top: 10px;
.table-btn {
display: inline-block;
margin: 0 10px;
color: #1791E7;
opacity: 0.8;
}
.table-btn:hover {
opacity: 1;
}
}
</style>
<template>
<!-- 表单渲染 -->
<el-dialog append-to-body :close-on-click-modal="false" :show-close="false" :visible="visible" width="520px" top="26vh">
<div class="review-box">
<div class="review-title">审核意见:</div>
<div class="review-text">{{ formData.reviewComments }}</div>
</div>
<div slot="footer" class="dialog-footer" style="text-align: center">
<el-button @click="cancelView">关闭</el-button>
</div>
</el-dialog>
</template>
<script>
import { HttpReq } from '@/api/common'
export default {
data() {
return {
visible: false,
formData: {
reviewComments: '请咨询后台管理员了解详情...'
}
}
},
mounted() {
},
methods: {
showView() {
this.visible = true
},
hideView() {
this.visible = false
},
cancelView() {
this.hideView()
},
loadData(id) {
this.showView()
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.review-box {
padding: 0 50px;
width: 100%;
font-family: Source Han Sans CN;
.review-title {
font-size: 18px;
font-weight: bold;
color: #333;
}
.review-text {
padding-top: 15px;
color: #777;
}
}
</style>
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