detection-business/pages/order/editorder.vue
2024-11-11 13:18:56 +08:00

656 lines
15 KiB
Vue

<!-- 编辑-->
<template>
<view class="content">
<view style="width: 100%; height: 44px;"></view>
<view class="top-heder">
<view class="t-left" @click="getback()">
<uni-icons type="left" size="18"></uni-icons>
</view>
<view class="t-title">
<text>编辑商品</text>
</view>
<view class="t-you"></view>
</view>
<view class="mub">
<view class="top-ail">
<!-- <view class="upimg">
<image src="../../static/detection/xzbjt.png" mode=""></image>
</view> -->
<u-upload
:fileList="fileList6"
@afterRead="afterRead1"
@delete="deletePic1"
name="6"
multiple
:maxCount="1"
width="345px"
height="126px"
>
<image src="../../static/detection/tjspfmt.png" style="width: 345px;height: 126px;"></image>
</u-upload>
<!-- 上传 -->
<view class="box-list">
<view class="list-box">
<view class="l-left">商品分类</view>
<!-- @click="show=true" -->
<view class="l-right" >
<!-- <input type="text" placeholder=""> -->
<text v-if="!ftitle">{{releasebox.categoryName}}</text>
<text v-if="ftitle">{{ftitle}}</text>
</view>
</view>
<view class="list-box">
<view class="l-left">序号</view>
<view class="l-right">
<input type="number" v-model="releasebox.orderNum" placeholder="请输入排序的序号">
</view>
</view>
<!-- <u-collapse accordion>
<u-collapse-item :title="item.skuName" v-for="(item, index) in releasebox.skuList" :key="index">
<view class="list-box">
<view class="l-left">代办价格</view>
<view class="l-right">
<input type="number" v-model="item.dbPrice" placeholder="请输入代办价格">
</view>
</view>
<view class="list-box">
<view class="l-left">单位管理员价格</view>
<view class="l-right">
<input type="number" v-model="item.dbPrice" placeholder="请输入代办价格">
</view>
</view>
<view class="list-box">
<view class="l-left">员工价格</view>
<view class="l-right">
<input type="number" v-model="item.dbPrice" placeholder="请输入代办价格">
</view>
</view>
</u-collapse-item>
</u-collapse> -->
<!-- <view class="list-box">
<view class="l-left">安检价格:</view>
<view class="l-right">
<input type="number" v-model="releasebox.skuList[0].price" placeholder="请输入安检价格">
</view>
</view>
<view class="list-box">
<view class="l-left">环检价格:</view>
<view class="l-right">
<input type="number" v-model="releasebox.skuList[1].price" placeholder="请输入环检价格">
</view>
</view>
<view class="list-box">
<view class="l-left">安检+环检:</view>
<view class="l-right">
<input type="number" v-model="releasebox.skuList[2].price" placeholder="请输入总和的价格">
</view>
</view> -->
<view class="thui">商品图片</view>
<view class="imgs">
<u-upload
:fileList="fileList4"
@afterRead="afterRead"
@delete="deletePic"
name="4"
multiple
:maxCount="5"
></u-upload>
</view>
</view>
<!-- 是否上架 -->
<!-- <view class="bottom-di">
<view class="b-left">是否上架</view>
<view class="b-right">
<switch @change="getone()" :checked="one" color="#FFCC33" style="transform:scale(0.7)"/>
</view>
</view> -->
<!-- 是否特价 -->
<!-- <view class="bottom-di">
<view class="b-left">是否特价</view>
<view class="b-right">
<switch @change="gettwo()" :checked="two" color="#FFCC33" style="transform:scale(0.7)"/>
</view>
</view> -->
<!-- 是否特价 -->
<!-- <view class="bottom-di">
<view class="b-left">是否参与优惠</view>
<view class="b-right">
<switch @change="getthree()" :checked="three" color="#FFCC33" style="transform:scale(0.7)"/>
</view>
</view> -->
<view class="box-list">
<!-- <view class="">
<u--textarea v-model="releasebox.goodsDesc" placeholder="请输入内容" border="none"></u--textarea>
</view> -->
<Rboy-editor ref="RboyEditor" @uploadFile="uploadFile" :newsContent="releasebox.goodsDesc" :count="6"></Rboy-editor>
</view>
<view class="dlanniu" @click="getgoods()" >
<text>确认修改</text>
</view>
</view>
</view>
<u-picker @change="getxz" @confirm="getyes()" @cancel="getyes()" :show="show" :columns="fenlist" keyName="categoryName"></u-picker>
<!-- 底部 -->
</view>
</template>
<script>
import config from '@/config';
import request from '../../utils/request';
import upload from '@/utils/upload.js'
export default {
data() {
return {
baseUrl:this.$baseUrl,
goodsId:'',
one:false,
two:false,
three:false,
show:false,
guige:false,
msg:'3',
tapnum:0,
value5:'',
tian:{
skuName:'',//规格名称
price:''//规格价格
},
fileList4:[],
fileList6:[],
taplist:[
{Text:'已发布'},
{Text:'待上架'},
],
fenlist:[],
ftitle:null,
releasebox:{
id:'',
title:'', //标题
goodsCategoryId:'',//商品分类id
partnerId:'',//合作商id
price:'',//价格,单位为:分
image:'',//封面图
imageList:[], //商品图片
isListing:'0',//01上架下架
isSpecial:'0',//01是否特价
isAttend:"0",//是否参与优惠0不参与1参与
goodsDesc:'',//详细描述
orderNum:'', //排序
skuList:[
{skuName:'安检',price:''},
{skuName:'环检',price:''},
{skuName:'安检+环检',price:''},
]
}
}
},
onLoad(option) {
this.releasebox.id = option.id
},
mounted() {
this.releasebox.partnerId = uni.getStorageSync('partnerId')
this.getindex()
},
methods: {
async uploadFile(event) {
let that = this
// event 选择的图片
for (var item in event.tempFilePaths) {
// uploadFileApi 为上传到服务端的接口 count大于1 使用 await
upload({
url:'/common/upload',
filePath: event.tempFilePaths[item],
}).then((res)=>{
that.$refs.RboyEditor.editor_insertImage({
src: this.baseUrl + res.fileName,
alt: "图像",
})
})
}
},
async getindex(){
// 回显
let resx = await request({
url:'/partnerOwn/partner/goodsDetail?goodsId='+this.releasebox.id,
method: 'get',
})
this.releasebox = resx.data
this.$refs.RboyEditor.editor_setContentsNew( resx.data.goodsDesc)
this.releasebox.skuList[0].price = resx.data.skuList[0].price / 100
this.releasebox.skuList[1].price =resx.data.skuList[1].price / 100
this.releasebox.skuList[2].price = resx.data.skuList[2].price / 100
if(resx.data.isListing == '1'){
this.one = true
}else{
this.one = false
}
if(resx.data.isSpecial == '1'){
this.two = true
}else{
this.two = false
}
if(resx.data.isAttend == '1'){
this.three = true
}else{
this.three = false
}
this.fileList6.push(
{
url: resx.data.image
}
)
resx.data.imageList.forEach(it=>{
if(it){
this.fileList4.push(
{
url: it
})
}
})
// 获取分类信息
let res = await request({
url:'/system/shopInspectionCategory/list',
data: {
pageNum: 1,
pageSize: 999
},
method: 'get',
})
let arr = res.rows
this.fenlist.push(arr)
},
async getgoods(){
if(this.releasebox.goodsCategoryId == "" ||this.releasebox.partnerId == "" ||this.releasebox.image == "" ||this.releasebox.imageList == ""){
uni.showToast({
title:"以上均为必填项!!!",
icon:"none"
})
return
}
this.releasebox.skuList[0].price = this.releasebox.skuList[0].price * 100
this.releasebox.skuList[1].price = this.releasebox.skuList[1].price * 100
this.releasebox.skuList[2].price = this.releasebox.skuList[2].price * 100
this.releasebox.goodsDesc = await this.$refs.RboyEditor.editor_getcontents()
this.releasebox.images = this.releasebox.imageList.join(",")
let res = await request({
url:'/partnerOwn/partner/editGoods',
method: 'post',
data : this.releasebox
})
if(res.code == 200){
uni.showToast({
title:"修改成功"
})
setTimeout(() => {
uni.navigateBack()
}, 1000);
}
},
getxz(e){
this.releasebox.goodsCategoryId = e.value[0].id
this.ftitle = e.value[0].categoryName
},
// 删除
getdeletesku(index){
this.releasebox.skuList.splice(index,1)
},
getone(){
this.one =! this.one
if(this.one == false){
this.releasebox.isListing = 0
}
if(this.one == true){
this.releasebox.isListing = 1
}
},
gettwo(){
this.two =! this.two
if(this.two == false){
this.releasebox.isSpecial = 0
}
if(this.two == true){
this.releasebox.isSpecial = 1
}
},
getthree(){
this.three =! this.three
if(this.three == false){
this.releasebox.isAttend = 0
}
if(this.three == true){
this.releasebox.isAttend = 1
}
},
gettapindex(index){
this.tapnum = index
},
getback(){
uni.navigateBack()
},
getyes(){
this.show = false
},
open() {
// this.guige = true
},
close() {
this.guige = false
},
// 以下均为图片方法----------------------
// 删除图片
deletePic(event) {
this[`fileList${event.name}`].splice(event.index, 1)
this.imageList.splice(event.index, 1)
},
// 新增图片
async afterRead(event) {
// 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
let lists = [].concat(event.file)
let fileListLen = this[`fileList${event.name}`].length
lists.map((item) => {
this[`fileList${event.name}`].push({
...item,
})
})
for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise(lists[i].url)
let item = this[`fileList${event.name}`][fileListLen]
this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
status: 'success',
message: '',
url: result
}))
fileListLen++
}
},
uploadFilePromise(url) {
upload({
url:'/common/upload',
filePath: url,
}).then((res)=>{
this.releasebox.imageList.push(res.fileName)
})
},
// 第二遍
deletePic1(event) {
this[`fileList${event.name}`].splice(event.index, 1)
this.releasebox.imageList.splice(event.index, 1)
},
// 新增图片
async afterRead1(event) {
// 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
let lists = [].concat(event.file)
let fileListLen = this[`fileList${event.name}`].length
lists.map((item) => {
this[`fileList${event.name}`].push({
...item,
})
})
for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise1(lists[i].url)
let item = this[`fileList${event.name}`][fileListLen]
this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
status: 'success',
message: '',
url: result
}))
fileListLen++
}
},
uploadFilePromise1(url) {
upload({
url:'/common/upload',
filePath: url,
}).then((res)=>{
this.releasebox.image = res.fileName
})
},
}
}
</script>
<style scoped lang="scss">
.content {
box-sizing: border-box;
width: 100%;
height: calc(100vh);
background: white;
}
.top-heder{
width: 100%;
height: 46px;
background: white;
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding: 5px 15px;
}
.t-title{
font-size: 17px;
font-weight: bold;
color: #333333;
}
.t-left{
width: 10%;
}
.t-you{
height: 100%;
background-color: white;
width: 20%;
}
.t-input{
width: 80%;
height: 36px;
background: #F0F0F0;
border-radius: 50px;
box-sizing: border-box;
padding: 0 15px;
display: flex;
align-items: center;
}
.top-ail{
width: 100%;
box-sizing: border-box;
padding: 15px;
background-color: #F4F4F4;
// height: calc(100vh);
}
.mub{
background-color: #F4F4F4;
height: calc(100vh);
}
.dix{
display: flex;
align-items: center;
}
.upimg{
width: 100%;
height: 126px;
border-radius: 8px;
box-sizing: border-box;
background-color: white;
image{
width: 100%;
height: 100%;
}
}
.box-list{
width: 100%;
border-radius: 8px;
box-sizing: border-box;
padding: 10px;
background-color: white;
margin: 10px auto;
}
.list-box{
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding: 15px 5px;
border-bottom: 1px solid #EEEEEE;
}
.l-left{
font-size: 16px;
font-weight: 400;
color: #333333;
}
.l-right{
font-size: 16px;
font-weight: 400;
color: #999999;
text-align: right;
}
.xiaolan{
// width: 109px;
// height: 30px;
background: #E2EAFF;
border-radius: 50px;
display: flex;
align-content: center;
justify-self: center;
box-sizing: border-box;
padding: 5px;
font-size: 14px;
font-weight: 400;
color: #0D2E8D;
}
.xiaohui{
// width: 141px;
// height: 30px;
box-sizing: border-box;
padding: 0px 10px;
background: #F7F7F7;
border-radius: 50px ;
display: flex;
align-items: center;
justify-content: center;
margin: 10px ;
}
.hui-right{
border-left:1px solid #DDDDDD;
padding: 5px;
margin-left: 5px;
}
.wrap-box{
width: 100%;
box-sizing: border-box;
display: flex;
flex-wrap: wrap;
}
.bottom-di{
width: 100%;
height: 56px;
background: #FFFFFF;
border-radius: 8px;
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
padding: 0px 20px;
margin-bottom: 10px;
}
.thui{
font-size: 16px;
font-weight: 400;
color: #666666;
margin-top: 10px;
margin-left: 8px;
}
.imgs{
box-sizing: border-box;
margin-top: 20px;
}
.p-box{
border-radius: 10px;
overflow: hidden;
box-sizing: border-box;
padding: 20px;
width: 100%;
background-color: white;
}
.p-top{
width: 100%;
text-align: center;
font-size: 17px;
font-weight: bold;
color: #000000;
margin-bottom: 20px;
}
.on-input{
width: 100%;
display: flex;
align-items: center;
box-sizing: border-box;
}
.ipt-kuang{
width: 70%;
height: 30px;
background: #FFFFFF;
border-radius: 8px 8px 8px 8px;
opacity: 1;
border: 1px solid #DDDDDD;
display: flex;
align-items: center;
margin: 10px auto;
box-sizing: border-box;
padding: 0px 10px;
}
.t-left{
width: 20%;
font-size: 14px;
font-weight: 400;
color: #000000;
}
.dlanniu{
width: 80%;
height: 45px;
background: linear-gradient(180deg, #3F61C0 0%, #0D2E8D 100%);
border-radius: 50px;
display: flex;
align-items: center;
justify-content: center;
margin: 20px auto;
color: white;
}
.da{
font-size: 16px;
}
</style>