Commit c5f9904d by liwk

commit

1 parent 041a589c
......@@ -85,6 +85,10 @@ export const orderApi = {
createGoods(data = {}) {
return request(data, 'dj.api.scrm.goods.insert')
},
/** 商品修改*/
updateGoods(data = {}) {
return request(data, 'dj.api.scrm.goods.update')
},
}
export const carEquityManageApi = {
/** 获取汽车权益列表*/
......@@ -99,6 +103,14 @@ export const carEquityManageApi = {
updateShelves(data = {}) {
return request(data, 'dj.api.scrm.car.updateShelves')
},
/**新增汽车权益*/
createEquity(data = {}) {
return request(data, 'dj.api.scrm.car.insert')
},
/** 更新汽车权益*/
updateEquity(data = {}) {
return request(data, 'dj.api.scrm.car.update')
},
}
export const goodsEquityManageApi = {
/**获取商品权益列表*/
......@@ -137,6 +149,25 @@ export const goodsEquityManageApi = {
updateShelves(data = {}) {
return request(data, 'dj.api.scrm.goods.groupUpdateShelves')
},
/**新增商品权益*/
createEquity(data = {}) {
return request(data, 'dj.api.scrm.goods.groupInsert')
},
/**更新商品权益*/
updateEquity(data = {}) {
return request(data, 'dj.api.scrm.goods.groupUpdate')
},
/** 获取品牌列表*/
getGoodsBrandList(data = {
supplier: 'HW'
}) {
return request(data, 'dj.api.scrm.goods.brandList')
},
/* 获取品牌下商品形态列表*/
getAppearanceList(data = {}) {
return request({...data, supplier: 'HW' }, 'dj.api.scrm.goods.appearanceList')
},
}
// export const orderApi = {
// /**获取财务管理列表*/
......
<template>
<div class="equity-dialog">
<el-dialog
:title=" type == 1?'汽车权益' : '商品权益'"
:visible.sync="show"
:show-close="false"
:close-on-press-escape="false"
:close-on-click-modal="false"
>
<el-form
:model="form"
:rules="rules"
ref="ruleForm"
>
<el-form-item
v-if="type==1"
label="服务提供方"
required
prop="supplier"
>
<el-select v-model="form.supplier">
<el-option
v-for="item in supplierList"
:key="item.value"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<template v-if="type==2">
<el-form-item
label="产品提供方"
required
prop="supplier"
>
<el-select v-model="form.supplier">
<el-option
label="海威"
value="HW"
></el-option>
</el-select>
</el-form-item>
<el-form-item
label="选择品牌"
required
prop="brandName"
>
<el-select
v-model="form.brandName"
@change="changeBrandName"
>
<el-option
v-for="item in brandList"
:key="item.brandId"
:value="item.brandId"
>{{item.brandName}}</el-option>
</el-select>
</el-form-item>
<el-form-item
label="商品形态"
required
prop="appearance"
v-if="form.brandName"
>
<el-select
v-model="form.appearance"
@change="change"
>
<el-option
v-for="item in appearanceList"
:key="item.value"
:value="item.label"
>{{item.label}}</el-option>
</el-select>
</el-form-item>
</template>
<div class="flex">
<el-form-item
label="权益名称"
required
prop="equityName"
>
<el-input
v-model="form.equityName"
:maxlength="type==1?8:6"
></el-input>
</el-form-item>
<el-form-item
label="描述"
required
prop="equityDesc"
>
<el-input
v-model="form.equityDesc"
:maxlength="type==1?8:6"
></el-input>
</el-form-item>
</div>
<div>
<el-form-item
label="图标"
required
prop="equityIcon"
>
<el-upload
action="#"
class="avatar-uploader"
:show-file-list="false"
:before-upload="upLoadImg"
>
<img
v-if="form.equityIcon"
:src="form.equityIcon"
class="avatar"
>
<i
v-else
class="el-icon-plus avatar-uploader-icon"
></i>
</el-upload>
</el-form-item>
</div>
</el-form>
<div
slot="footer"
class="dialog-footer"
>
<el-button @click="close">取 消</el-button>
<el-button
type="primary"
@click="submit(type)"
>确 定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { goodsEquityManageApi, carEquityManageApi, commonApi } from '@api/api'
const validatorgoodsImage = (rule, value, callback) => {
if (!value) {
callback('请上传图标')
} else {
callback()
}
}
export default {
name: 'equity-dialog',
data () {
return {
form: {},
brandList: [],
appearanceList: [],
appearance: '',
supplierList: [
{
label: '广联-加油',
value: 'GL_OIL'
},
{
label: '广联-道路救援',
value: 'GL_ROAD_RESCUE'
},
{
label: '广联-轮胎保障',
value: 'GL_TIRE_PROTECTION'
},
{
label: '广联-盗抢无忧',
value: 'GL_ROBBERY_PROTECTION'
},
{
label: '广联-碰撞维修',
value: 'GL_COLLISION_REPAIR'
},
{
label: '广联-整车全损',
value: 'GL_CAR_TOTAL_LOSS'
},
{
label: 'e代驾',
value: 'EDJ'
}
],
rules: {
supplier: [
{ required: true, message: '请选择服务提供方', trigger: 'change' }
],
brandName: [
{ required: true, message: '请选择品牌', trigger: 'change' }
],
appearance: [
{ required: true, message: '请选择商品形态', trigger: 'change' }
],
equityName: [
{ required: true, message: '请输入权益名称', trigger: 'blur' }
],
equityDesc: [
{ required: true, message: '请输入描述', trigger: 'blur' }
],
equityIcon: [
{ validator: validatorgoodsImage },
],
}
}
},
props: {
show: {
type: Boolean,
default: false
},
type: Number,
isEdit: Boolean,
data: {
type: Object,
default: () => { }
}
},
mounted () {
goodsEquityManageApi.getGoodsBrandList().then(({ data }) => {
this.brandList = data
})
},
watch: {
'isEdit' (n) {
if (n) {
this.form = JSON.parse(JSON.stringify(this.$parent.editData))
if (this.type == 2) {
this.form.appearance = { 1: '卡券', 2: '直充' }[this.$parent.editData.appearance]
}
}
},
'form.brandId' (n) {
goodsEquityManageApi.getAppearanceList({ brandId: n }).then(({ data }) => {
data.map(i => i.label = { 1: '卡券', 2: '直充' }[i.appearance])
this.appearanceList = data
})
},
},
methods: {
close () {
this.form = {}
this.$emit('update:show', false)
this.$emit('update:isEdit', false)
},
upLoadImg (file) {
let fileName = file.name
if (file.name.lastIndexOf('.') === -1) {
this.$message.info('路径不正确')
return false
}
let AllImgExt = '.jpg|.jpeg|.gif|.bmp|.png|.swf'
let extName = file.name.substring(file.name.lastIndexOf('.')).toLowerCase()
if (AllImgExt.indexOf(extName + '|') === -1) {
this.$message.info('图片格式不正确')
return false
}
// if (fileSize < 3145728) {
if (window.FileReader) {
let reader = new FileReader()
reader.readAsDataURL(file)
reader.onload = (img) => {
console.log(file)
let type = fileName.split('.')[1]
let imgUrl = img.target.result.split(',')[1]
commonApi.upLoadImg({
file: `${type}@${imgUrl}`
}).then(({ code, message, data }) => {
if (code == 0) {
window.vm.$set(this.form, 'equityIcon', data)
} else {
this.$message.error(message)
}
})
}
}
},
change (e) {
},
changeBrandName (e) {
console.log(e)
this.form.brandId = e
this.brandList.map(i => {
if (i.brandId == e) this.form.brandName = i.brandName
})
},
submit (type) {
let { form, isEdit } = this
let target = type == 1 ? carEquityManageApi : goodsEquityManageApi
this.$refs.ruleForm.validate((valid) => {
if (valid) {
if (type == 2) {
this.form.goodsCategoryId = this.$parent.goodsCategoryId
this.form.appearance = form.appearance == '直充' ? 2 : 1
}
let apiName = 'createEquity'
if (isEdit) apiName = 'updateEquity'
console.log(this.form)
target[apiName](this.form).then(({ code, data, message }) => {
if (code == 0) {
this.close()
type == 1 ? this.$parent.getCarList() : this.$parent.getCategoryList()
} else {
this.$message.error(message)
}
})
} else {
return
}
})
}
}
}
</script>
<style scope>
.flex {
display: flex;
align-items: center;
justify-content: space-between;
}
.avatar-uploader {
box-sizing: border-box;
border: 1px dashed #d9d9d9;
border-radius: 6px;
cursor: pointer;
position: relative;
width: 80px;
height: 80px;
margin-left: 80px;
}
.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 80px;
height: 80px;
display: flex;
align-items: center;
justify-content: center;
}
.avatar {
width: 80px;
height: 80px;
display: block;
}
</style>
\ No newline at end of file
......@@ -5,4 +5,6 @@ import Vue from 'vue'
Vue.component('table-tooltip', () =>
import ('./table-tooltip/index.vue'))
Vue.component('d2-table', () =>
import ('./d2-table/index.vue'))
\ No newline at end of file
import ('./d2-table/index.vue'))
Vue.component('equity-dialog', () =>
import ('./equity-dialog/index.vue'))
\ No newline at end of file
......@@ -17,7 +17,7 @@ export default {
minWidth: '200',
},
{
label: '权益图标\n(80*80,支持JPG、PNG、GIF)',
label: '权益图标\n(80*80,支持JPG、PNG、GIF',
minWidth: '200',
formatter: (cell) => {
return `<img class="equity-icon" src="${cell.equityIcon}" />`
......@@ -25,8 +25,18 @@ export default {
},
{
label: '服务提供方',
prop: 'supplier',
minWidth: '200',
formatter: (cell) => {
return {
GL_OIL: '广联-加油',
GL_ROAD_RESCUE: '广联-道路救援',
GL_TIRE_PROTECTION: '广联-轮胎保障',
GL_ROBBERY_PROTECTION: '广联-盗抢无忧',
GL_COLLISION_REPAIR: '广联-碰撞维修',
GL_CAR_TOTAL_LOSS: '广联-整车全损',
EDJ: 'e代驾'
}[cell.supplier]
}
},
]
},
......
......@@ -2,6 +2,7 @@ import { goodsEquityManageApi } from '@api/api'
export default {
data() {
return {
goodsCategoryId: '',
inputValue: '',
tagInputValue: '',
inputVisible: false,
......@@ -54,6 +55,7 @@ export default {
list[0].active = true
this.tags = list || []
this.getGoodsList(list[0].id)
this.goodsCategoryId = list[0].id
})
},
/**商品权益列表 */
......@@ -71,12 +73,14 @@ export default {
this.tags.map(e => e.active = false)
this.tags[index].active = true
this.getGoodsList(id)
this.goodsCategoryId = id
},
/** */
tagHover(index, type) {
this.$refs[`tag-${index}`][0].$el.classList[type]('tag-hover')
},
showInput(index) {
showInput(index, val) {
this.inputValue = val
this.$refs[`tag-input-${index}`][0].$el.classList.add('input-tag-show')
this.$refs[`tag-input-${index}`][0].$refs.input.focus()
},
......
......@@ -3,7 +3,10 @@
<div class="box">
<div class="equity-title">汽车权益</div>
<div class="add-box">
<el-button type="primary">添加</el-button>
<el-button
type="primary"
@click="addEquity(1)"
>添加</el-button>
</div>
<div class="table-box">
<d2-table
......@@ -18,7 +21,10 @@
slot-scope="scope"
:data="scope.scope"
>
<el-button type="text">编辑</el-button>
<el-button
type="text"
@click="editEquity(scope.scope,1)"
>编辑</el-button>
<el-button
type="text"
@click="updateShelves(scope.scope, 'car')"
......@@ -45,14 +51,14 @@
:ref="`tag-${index}`"
>
<div class="mask">
<div
<span
class="edit"
@click.stop="showInput(index)"
>编辑</div>
<div
@click.stop="showInput(index, item.goodsCategory)"
>编辑</span>
<span
class="del"
@click.stop="categoryDelete(item.id)"
>删除</div>
>删除</span>
</div>
{{item.goodsCategory}}
<el-input
......@@ -85,7 +91,10 @@
>添加分类</el-button>
</div>
<div class="add-box">
<el-button type="primary">添加</el-button>
<el-button
type="primary"
@click="addEquity(2)"
>添加</el-button>
</div>
<div class="table-box">
<d2-table
......@@ -100,7 +109,10 @@
slot-scope="scope"
:data="scope.scope"
>
<el-button type="text">编辑</el-button>
<el-button
type="text"
@click="editEquity(scope.scope,2)"
>编辑</el-button>
<el-button
type="text"
@click="updateShelves(scope.scope,'goods')"
......@@ -113,6 +125,11 @@
</d2-table>
</div>
</div>
<equity-dialog
:show.sync="showDialog"
:type="dialogType"
:isEdit.sync="isEdit"
></equity-dialog>
</div>
</template>
......@@ -125,14 +142,20 @@ export default {
mixins: [carMixin, goodsMixin],
data () {
return {
showDialog: false,
isEdit: false,
dialogType: 1,
editData: {}
}
},
mounted () {
},
methods: {
addEquity (type) {
this.dialogType = type
this.showDialog = true
},
setTop (id, type) {
let target = type == 'car' ? carEquityManageApi : goodsEquityManageApi
target.setTop({ id }).then(({ code, message }) => {
......@@ -144,6 +167,11 @@ export default {
}
})
},
editEquity (data, type) {
this.editData = data
this.isEdit = true
this.addEquity(type)
},
updateShelves ({ id, status }, type) {
let target = type == 'car' ? carEquityManageApi : goodsEquityManageApi
status = status == 1 ? 0 : 1
......@@ -228,7 +256,7 @@ export default {
.tag-hover .mask {
display: flex !important;
}
.el-tag .mask div:hover {
.el-tag .mask span:hover {
color: #409eff;
}
.addTag {
......
......@@ -23,7 +23,10 @@
label="产品提供方"
required
>
<el-select v-model="ruleForm.supplier">
<el-select
v-model="ruleForm.supplier"
:disabled="isEdit"
>
<el-option
label="海威"
value="HW"
......@@ -34,7 +37,10 @@
label="商品形态"
required
>
<el-radio-group v-model="ruleForm.appearance">
<el-radio-group
v-model="ruleForm.appearance"
:disabled="isEdit"
>
<el-radio-button label="1">卡券</el-radio-button>
<el-radio-button label="2">直充</el-radio-button>
</el-radio-group>
......@@ -48,10 +54,11 @@
filterable
v-model="ruleForm.brandName"
@change="changeBrandName"
:disabled="isEdit"
>
<el-option
v-for="item in brandNameList"
:key="item.id"
:key="item.brandId"
:label="item.brandName"
:value="item.brandId"
>
......@@ -75,6 +82,7 @@
>
<el-input
v-model="ruleForm.productId"
:disabled="isEdit"
placeholder="365淘券所对应的商品编码"
maxlength="20"
@blur="getEquityOutGoodsBySupplierProductId"
......@@ -87,7 +95,6 @@
>
<el-upload
class="avatar-uploader"
action="#"
:show-file-list="false"
:before-upload="upLoadImg"
>
......@@ -111,7 +118,10 @@
prop="denomination"
required
>
<el-input v-model.number="ruleForm.denomination">
<el-input
v-model.number="ruleForm.denomination"
:disabled="isEdit"
>
<span slot="suffix">
元
</span>
......@@ -122,7 +132,10 @@
prop="salesPrice"
required
>
<el-input v-model.number="ruleForm.salesPrice">
<el-input
v-model.number="ruleForm.salesPrice"
:disabled="isEdit"
>
<span slot="suffix">
元
</span>
......@@ -133,7 +146,11 @@
prop="costPrice"
required
>
<el-input v-model.number="ruleForm.costPrice">
<el-input
v-model.number="ruleForm.costPrice"
:disabled="isEdit"
>
<span slot="suffix">
元
</span>
......@@ -144,7 +161,11 @@
prop="lineationPrice"
required
>
<el-input v-model.number="ruleForm.lineationPrice">
<el-input
v-model.number="ruleForm.lineationPrice"
:disabled="isEdit"
>
<span slot="suffix">
元
</span>
......@@ -155,12 +176,18 @@
prop="warrantyPeriod"
:required="ruleForm.appearance == 1"
>
<el-input v-model.number="ruleForm.warrantyPeriod">
<el-input
v-model.number="ruleForm.warrantyPeriod"
:disabled="isEdit"
>
<template slot="append">小时</template>
</el-input>
</el-form-item>
<el-form-item label="商品有效期">
<el-input v-model.number="ruleForm.validityPeriod">
<el-input
v-model.number="ruleForm.validityPeriod"
:disabled="isEdit"
>
<template slot="prepend">兑换到账户内</template>
<template slot="append">天有效</template>
</el-input>
......@@ -182,6 +209,7 @@
<quill-editor
v-model="ruleForm.buysNotes"
:options="editorOption"
:disabled="isEdit"
>
</quill-editor>
</el-form-item>
......@@ -195,6 +223,7 @@
<quill-editor
v-model="ruleForm.useNotes"
:options="editorOption"
:disabled="isEdit"
>
</quill-editor>
</el-form-item>
......@@ -207,6 +236,7 @@
<quill-editor
v-model="ruleForm.useNotes"
:options="editorOption"
:disabled="isEdit"
>
</quill-editor>
</el-form-item>
......@@ -216,7 +246,7 @@
type="primary"
@click="onSubmit"
>提交</el-button>
<el-button>保存</el-button>
<el-button @click="onSubmit">保存</el-button>
</el-form-item>
</div>
</el-form>
......@@ -269,6 +299,7 @@ export default {
name: '',
data () {
return {
isEdit: false,
resetTime: new Date().getTime(),
editorOption: {
modules: {
......@@ -284,7 +315,6 @@ export default {
]
}
},
ruleForm: {
supplier: 'HW',
appearance: 1,
......@@ -332,6 +362,7 @@ export default {
let { id } = this.getParams()
if (id) {
this.getEquityGoodsById(id)
this.isEdit = true
} else {
this.getListWithPageOutGoods()
}
......@@ -343,6 +374,10 @@ export default {
if (code == 0) {
Object.keys(data).map(key => {
if (data[key] == null) delete data[key]
let ketList = 'denomination|salesPrice|costPrice|lineationPrice|'
if (ketList.indexOf(`${key}|`) != -1) {
data[key] = Number(data[key])
}
})
this.ruleForm = data
} else {
......@@ -404,8 +439,12 @@ export default {
let imgUrl = img.target.result.split(',')[1]
commonApi.upLoadImg({
file: `${type}@${imgUrl}`
}).then(res => {
console.log(res)
}).then(({ code, data, message }) => {
if (code == 0) {
window.vm.$set(this.ruleForm, 'goodsImage', data)
} else {
this.$message.error(message)
}
})
}
}
......@@ -416,7 +455,10 @@ export default {
console.log('error submit!!')
return false
} else {
console.log()
if (this.isEdit) {
this.createGoods('updateGoods')
return
}
let { supplier, brandId, productId } = this.ruleForm
orderApi.sameGoodsCheck({
supplier,
......@@ -435,7 +477,7 @@ export default {
return
}
if (_res.errId == -1006) {
this.$confirm(_res.errId, '提示', {
this.$confirm(_res.message, '提示', {
confirmButtonText: '保存',
cancelButtonText: '取消',
type: 'warning',
......@@ -444,7 +486,7 @@ export default {
this.createGoods()
})
} else if (_res.errId = -1003) {
this.$confirm(_res.errId, '提示', {
this.$confirm(_res.message, '提示', {
confirmButtonText: '提交',
cancelButtonText: '取消',
type: 'warning',
......@@ -461,8 +503,8 @@ export default {
}
})
},
createGoods () {
orderApi.createGoods(this.ruleForm).then(({ code, message }) => {
createGoods (name = 'createGoods') {
orderApi[name](this.ruleForm).then(({ code, message }) => {
if (code == 0) {
window.location.href = './index.html'
} else {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!