-
保存并上架
+
+ 保存并上架
确认
保存草稿
@@ -307,7 +318,7 @@
-
+
@@ -338,7 +349,7 @@
-
+
@@ -365,16 +376,16 @@
-
-
-
-
+
+
+
+
@@ -392,9 +403,9 @@ export default {
token: sessionStorage.getItem("token")
},
editorConfig,
- isDetail: Boolean(this.$route.query.show),
+ isDetail: this.$route.query.show == 1,
+ id: this.$route.query.id || '',
form: {
- id: this.$route.query.id,
supplierIds: [],
tagsIds: [],
typeIds: [],
@@ -417,6 +428,7 @@ export default {
productName: '',
state: 1,
},
+ mallAnnex: [],
mallDisciplines: [
{
professionalClassList: [],
@@ -429,15 +441,19 @@ export default {
mallPrices: [
{
area: 0,
+ cityId: '',
entryType: 0,
settlementPrice: '',
- settlementPriceType: 0
+ settlementPriceType: 0,
+ discountRate: ''
},
{
area: 0,
+ cityId: '',
entryType: 0,
settlementPrice: '',
- settlementPriceType: 1
+ settlementPriceType: 1,
+ discountRate: ''
}
],
},
@@ -471,8 +487,12 @@ export default {
name: '折扣价'
}
],
+ searchTimer: null,
+ selectedProduct: false,
+ isData: false,
uploadList: [],
submiting: false,
+ pass: false,
updateTime: 0,
nameRepeat: false
};
@@ -484,14 +504,38 @@ export default {
this.updateTime++
},
deep:true
+ },
+ productKeyword: function(val) {
+ clearTimeout(this.searchTimer);
+ this.searchTimer = setTimeout(() => {
+ this.initProduct();
+ }, 500);
+ }
+ },
+ // 页面离开的时候如果没有保存则提示
+ beforeRouteLeave(to, from, next) {
+ if (this.submiting) {
+ next()
+ } else if (!this.pass) {
+ // 更改了信息才需要提示
+ if (this.updateTime) {
+ this.$confirm(`所填写内容暂未保存,是否保存?`, '提示', {
+ type: 'warning'
+ }).then(() => {
+ this.submit(this.form.state, next)
+ }).catch(() => {
+ console.log(55)
+ next()
+ })
+ } else {
+ next()
+ }
+ } else {
+ next()
}
},
mounted() {
- this.form.id && this.getData()
- this.getCategory()
- this.getLabel()
- this.getClass()
- this.getSupplier()
+ this.id ? this.getData() : this.getOp()
this.getSubject()
this.getProvince()
},
@@ -500,25 +544,47 @@ export default {
},
methods: {
getData() {
- this.$get(`${this.api.detailsOfGoods}?mallId=${this.form.id}`).then(res => {
+ this.$get(`${this.api.detailsOfGoods}?mallId=${this.id}`).then(res => {
const e = res.orderDetails
if (e.classificationIds && e.classificationIds.length) e.classificationIds = e.classificationIds[0]
if (e.typeIds && e.typeIds.length) e.typeIds = e.typeIds[0]
e.mall.interfaceDiagrams = e.mall.interfaceDiagram ? e.mall.interfaceDiagram.split(',') : []
+ e.mallAnnex.forEach(e => e.name = e.fileName)
this.form = e
+ this.getOp()
this.$nextTick(() => {
+ this.form.mallPrices.forEach(e => {
+ e.area && this.getCity(e)
+ })
this.form.mallDisciplines.forEach(e => {
this.$set(e, 'professionalClassList', [])
this.$set(e, 'professionalList', [])
- this.getProfessionalClassData(e)
- this.getProfessionalData(e)
+ e.categoryId && this.getProfessionalClassData(e)
+ e.professionalCategoryId && this.getProfessionalData(e)
})
+ setTimeout(() => {
+ this.updateTime = 0
+ }, 3000)
})
- console.log("🚀 ~ file: index.vue:503 ~ this.$get ~ this.form:", this.form)
}).catch(err => {})
},
-
+ // 获取页面上的下拉列表
+ getOp() {
+ this.getCategory()
+ this.getLabel()
+ this.getClass()
+ this.getSupplier()
+ },
+ // 关联产品单选回调
+ associatedProductChange(val) {
+ if (val === 1) {
+ const { mall } = this.form
+ mall.associatedProduct = ''
+ mall.associatedProductName = ''
+ this.selectedProduct = false
+ }
+ },
// 显示关联产品弹框
setProduct() {
this.productVisible = true
@@ -528,6 +594,7 @@ export default {
getProduct() {
const active = this.productActive
const keyword = this.productKeyword
+ // 理论、实训
if (!active || active == 1) {
const sid = this.$store.state.dataPer.find(e => e.permissionName === '课程管理')
this.$post(this.api.curriculumList, {
@@ -541,7 +608,7 @@ export default {
this.products = page.records
this.total = page.total
}).catch(err => {})
- } else if (active == 2) {
+ } else if (active == 2) { // 数据前瞻
this.$post(this.api.listByEntity,{
pageNum: this.page,
pageSize: this.pageSize,
@@ -557,7 +624,7 @@ export default {
this.products = list
this.total = res.pageList.total
}).catch(res => {})
- } else {
+ } else { // 职站增值应用
this.$post(this.api.getValueModule + '?platformId=1').then(res => {
const list = res.valueList
list.forEach(e => {
@@ -569,6 +636,10 @@ export default {
}).catch(err => {})
}
},
+ initProduct() {
+ this.page = 1
+ this.getProduct()
+ },
// 关联产品切换
tabChange(i) {
this.page = 1
@@ -588,10 +659,13 @@ export default {
const { form } = this
const { mall } = form
const active = this.productActive
+ this.selectedProduct = false
+ this.isData = false
// 实训、理论需要查询课程详情,把课程信息带过来
if (!active || active == 1) {
this.$post(`${this.api.curriculumDetail}?cid=${id}`).then(({ data }) => {
form.supplierIds = data.supplier.split(',').map(e => +e)
+ this.selectedProduct = true
form.classificationIds = !data.curriculumType ? 2 : data.curriculumType
form.mallDisciplines = [{
professionalClassList: [],
@@ -600,13 +674,28 @@ export default {
professionalId: data.professionalId,
professionalCategoryId: data.professionalCategoryId,
}]
+ form.mallPrices.find(e => e.settlementPriceType && e.area === 0).settlementPrice = data.settlementPrice
this.getProfessionalClassData(form.mallDisciplines[0])
this.getProfessionalData(form.mallDisciplines[0])
mall.courseHours = data.expectedCourse
mall.coverDrawing = data.coverUrl
mall.appletIcon = data.miniProgramPictureAddress
mall.productIntroduction = data.briefIntroduction
+ mall.marketUnitPrice = data.marketPrice
}).catch(err => {})
+ } else {
+ form.classificationIds = active == 2 ? 5 : 3
+ // 数据前瞻要获取供应厂商、市场建议单价等
+ if (active == 2) {
+ const item = this.products.find(e => e.cid == id)
+ if (item) {
+ form.supplierIds = [+item.supplier]
+ this.selectedProduct = true
+ mall.marketUnitPrice = item.market
+ form.mallPrices.find(e => e.settlementPriceType && e.area === 0).settlementPrice = item.settlementPrice
+ this.isData = true
+ }
+ }
}
mall.associatedProduct = id
mall.associatedProductName = this.products.find(e => e.cid == id).curriculumName
@@ -633,6 +722,15 @@ export default {
getLabel() {
this.$get(this.api.tagsList).then(res => {
this.labels = res.tagsList
+ const ids = []
+ this.form.tagsIds.forEach(item => {
+ this.labels.forEach(e => {
+ if (item == e.tagsId) {
+ ids.push(item)
+ }
+ })
+ })
+ this.form.tagsIds = ids
}).catch(err => {})
},
// 显示标签弹框
@@ -667,12 +765,16 @@ export default {
}
},
// 提交标签
- submitLabel(row, showMsg = 1) {
+ async submitLabel(row, showMsg = 1) {
if (!row.tagsName) return Util.errorMsg('请输入主题名称')
- this.$post(`${this.api.addTags}?tagsName=${row.tagsName}`).then(res => {
- showMsg && Util.successMsg('新增成功')
- this.getLabel()
- }).catch(res => {})
+ row.tagsId ?
+ await this.$post(this.api.updateTags, {
+ tagsName: row.tagsName,
+ tagsId: row.tagsId
+ }) :
+ await this.$post(`${this.api.addTags}?tagsName=${row.tagsName}`)
+ showMsg && Util.successMsg(row.tagsId ? '修改成功' : '新增成功')
+ this.getLabel()
},
// 关闭标签
closeLabel() {
@@ -699,7 +801,10 @@ export default {
// 获取产品类型
getClass() {
this.$get(this.api.productTypeList).then(res => {
- this.classifications = res.typeList
+ const list = res.typeList
+ const id = this.form.typeIds
+ if (id && !list.find(e => e.typeId == id)) this.form.typeIds = ''
+ this.classifications = list
}).catch(err => {})
},
// 显示产品类型弹框
@@ -734,12 +839,16 @@ export default {
}
},
// 提交产品类型
- submitClass(row, showMsg = 1) {
+ async submitClass(row, showMsg = 1) {
if (!row.typeName) return Util.errorMsg('请输入分类名称')
- this.$post(`${this.api.addProductType}?typeName=${row.typeName}`).then(res => {
- showMsg && Util.successMsg((row.id ? '修改' : '新增') + '成功')
- this.getClass()
- }).catch(res => {})
+ row.typeId ?
+ await this.$post(this.api.updateProductType, {
+ typeName: row.typeName,
+ typeId: row.typeId
+ }) :
+ await this.$post(`${this.api.addProductType}?typeName=${row.typeName}`)
+ showMsg && Util.successMsg(row.typeId ? '修改成功' : '新增成功')
+ this.getClass()
},
// 关闭产品类型
closeClass() {
@@ -820,17 +929,42 @@ export default {
addArea(type) {
this.form.mallPrices.push({
area: '',
+ cityId: '',
entryType: 0,
settlementPrice: '',
- settlementPriceType: type
+ settlementPriceType: type,
+ discountRate: ''
})
},
+ // 计算折扣后的结算价
+ calcSettlement(item) {
+ // 选的按折扣才需要计算
+ const unit = this.form.mall.marketUnitPrice
+ console.log("🚀 ~ file: index.vue:917 ~ calcSettlement ~ unit:", unit,item)
+
+ if (item.entryType && unit !== '') {
+ item.discountRate = item.settlementPrice / 10 * unit
+ }
+ },
+ // 处理价格单位
+ handleUnit(item) {
+ return item.entryType ? '折' : this.isData ? '元/账号/年' : '元/年'
+ },
// 查询省份
getProvince(){
this.$get(this.api.queryProvince).then(({ list }) => {
this.provinces = list
}).catch(res => {})
},
+ // 查询城市
+ getCity(item, clear) {
+ this.$get(this.api.queryCity, {
+ provinceId: item.area
+ }).then(({ list }) => {
+ this.$set(item, 'cities', list)
+ if (clear) item.cityId = ''
+ }).catch(res => {})
+ },
handleExceed(files, fileList) { // 上传文件
Util.warningMsg("当前限制选择 4 个文件,如需更换,请删除上一个文件再重新选择!");
@@ -845,7 +979,14 @@ export default {
this.form.mall.interfaceDiagrams.push(res.data.filesResult.fileUrl)
},
uploadSuccessFile(res) { // 文件上传成功时的钩子
- this.form.mall.appletIcon = res.data.filesResult.fileUrl;
+ const e = res.filesResult
+ this.form.mallAnnex = [{
+ mallId: this.id,
+ filePath: e.fileUrl,
+ fileName: e.originalFileName,
+ name: e.originalFileName,
+ }]
+ console.log(22, this.form)
},
uploadError(err, file, fileList) {
this.$message({
@@ -863,8 +1004,8 @@ export default {
// this.form.mall.coverDrawing = ''
// }).catch(res => {});
},
- submit(state, isShelves) {
- const { form } = this
+ submit(state, next) {
+ const form = JSON.parse(JSON.stringify(this.form))
const { mall } = form
if (!mall.productName) return Util.errorMsg('请输入产品名称!')
if (!state) {
@@ -893,6 +1034,8 @@ export default {
if (invalid) return
if (!mall.coverDrawing) return Util.errorMsg('请上传封面图!')
if (!mall.marketUnitPrice) return Util.errorMsg('请输入市场建议单价!')
+ if (form.mallPrices.find(e => !e.settlementPriceType && e.area === 0).settlementPrice === '') return Util.errorMsg('请输入厂商结算价!')
+ if (form.mallPrices.find(e => e.settlementPriceType && e.area === 0).settlementPrice === '') return Util.errorMsg('请输入平台结算价!')
if (!mall.productIntroduction) return Util.errorMsg('请输入产品简介!')
if (!mall.detailedIntroduction) return Util.errorMsg('请输入详情介绍!')
}
@@ -900,47 +1043,45 @@ export default {
form.typeIds = [form.typeIds]
mall.interfaceDiagram = mall.interfaceDiagrams.join()
form.mall.state = state
- if (isShelves) form.mall.isShelves = 0
+ form.mall.isShelves = state
if (this.submiting) return false
this.submiting = true
if (form.mall.mallId) {
this.$post(this.api.renewalOfGoods, form).then(res => {
this.submiting = false;
Util.successMsg("修改成功");
- this.$router.back();
+ next ? next() : this.$router.back()
}).catch(err => {
this.submiting = false;
});
} else {
this.$post(this.api.addGoods, form).then(res => {
this.submiting = false;
- Util.successMsg("修改成功");
- this.$router.back();
+ Util.successMsg("新增成功");
+ next ? next() : this.$router.back()
}).catch(err => {
this.submiting = false;
});
}
},
- // 返回上一页
- backPage() {
- this.$router.back()
- },
+ // 返回
back() {
- const { id } = this.form
- const updateTime = this.updateTime
+ this.pass = true
// 更改了信息才需要提示
- if ((id && updateTime > 2) || (!id && updateTime)) {
- this.$confirm(`编辑的内容未保存,是否保存?`, '提示', {
- type: 'warning'
+ if (this.updateTime) {
+ this.$confirm(`所填写内容暂未保存,是否保存?`, '提示', {
+ type: 'warning',
+ confirmButtonText: '是',
+ cancelButtonText: '否',
}).then(() => {
- this.save()
+ this.submit(this.form.mall.state)
}).catch(() => {
- this.backPage()
+ this.$router.back()
})
} else {
- this.backPage()
+ this.$router.back()
}
- }
+ },
}
};
@@ -949,6 +1090,9 @@ export default {
.m-l-5 {
margin-left: 5px;
}
+.m-l-20 {
+ margin-left: 20px;
+}
.model {
height: calc(100vh - 350px);
overflow: auto;
@@ -1045,8 +1189,13 @@ $avatar-width: 104px;
.subject {
padding: 10px;
border: 1px dashed #ccc;
+ &.mini {
+ width: 740px;
+ }
.line {
+ position: relative;
display: flex;
+ padding-right: 50px;
margin-bottom: 10px;
&:last-child {
margin-bottom: 0;
@@ -1055,6 +1204,12 @@ $avatar-width: 104px;
.el-form-item {
margin-bottom: 0;
}
+ .del {
+ position: absolute;
+ top: 11px;
+ right: 20px;
+ cursor: pointer;
+ }
}
.subject-plus {
margin-top: 5px;
diff --git a/src/views/shop/list/product/index.vue b/src/views/shop/list/product/index.vue
index 3838bc8..0a6c31a 100644
--- a/src/views/shop/list/product/index.vue
+++ b/src/views/shop/list/product/index.vue
@@ -45,11 +45,10 @@
新增
- 批量删除
-